?? dlgbeacon1.cpp
字號:
// DlgBeacon1.cpp : implementation file
//
#include "stdafx.h"
#include "RADIO.h"
#include "DlgBeacon1.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgBeacon1 dialog
CDlgBeacon1::CDlgBeacon1(CWnd* pParent /*=NULL*/)
: CDialog(CDlgBeacon1::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgBeacon1)
m_beaconLa = 120.0;
m_beaconPhi = 30.0;
m_beaconH = 0.0;
//}}AFX_DATA_INIT
}
void CDlgBeacon1::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgBeacon1)
DDX_Control(pDX, IDC_BEACONLIST, m_beaconListBox);
DDX_Control(pDX, IDC_BEACONCOMBO, m_beaconComboType);
DDX_Text(pDX, IDC_BEACONLA, m_beaconLa);
DDX_Text(pDX, IDC_BEACONPHI, m_beaconPhi);
DDX_Text(pDX, IDC_BEACONH, m_beaconH);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgBeacon1, CDialog)
//{{AFX_MSG_MAP(CDlgBeacon1)
ON_BN_CLICKED(IDC_ADDBEACON, OnAddbeacon)
ON_BN_CLICKED(IDC_DELBEACON, OnDelbeacon)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgBeacon1 message handlers
void CDlgBeacon1::OnAddbeacon()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
UINT iType;
CString str,strType;
switch(m_beaconComboType.GetCurSel()){
case 0:
strType="地面";iType=GROUND;
break;
case 1:
strType="空中";iType=AIR;
break;
default:;
}
str.Format(_T("No.%3d. %6.3lf %6.3lf %6.3lf %s"),m_beaconListBox.GetCount()+1,m_beaconLa,m_beaconPhi,m_beaconH,strType);
m_beaconListBox.AddString( str );
BEACON bea={m_beaconLa,m_beaconPhi,m_beaconH,iType};
m_tempBeaconList.Add(bea);
}
BOOL CDlgBeacon1::OnInitDialog()
{
CDialog::OnInitDialog();
m_beaconComboType.SetCurSel(0);
return TRUE;
}
void CDlgBeacon1::UpdateListBox()
{
int i;
CString str,strType("error");
m_beaconListBox.ResetContent();
for(i=0;i<m_tempBeaconList.GetSize();i++){
switch(m_tempBeaconList[i].type){
case GROUND:
strType="地面";
break;
case AIR:
strType="空中";
break;
default:;
}
str.Format(_T("No.%3d. %6.3lf %6.3lf %6.3lf %s"),m_beaconListBox.GetCount()+1,m_tempBeaconList[i].pos.x,m_tempBeaconList[i].pos.y,m_tempBeaconList[i].pos.z,strType);
m_beaconListBox.AddString(str);
}
}
void CDlgBeacon1::OnDelbeacon()
{
UpdateData(TRUE);
CString str,strType;
//得到所有選擇項
int nCount = m_beaconListBox.GetSelCount();
CArray<int,int> aryListBoxSel;
aryListBoxSel.SetSize(nCount);
int nSel=m_beaconListBox.GetSelItems(nCount, aryListBoxSel.GetData());
//
for(int i=0;i<nSel;i++){
m_tempBeaconList.RemoveAt(aryListBoxSel[i]-i);//小心刪掉一個序號就變了。
}
UpdateListBox();
}
void CDlgBeacon1::OnOK()
{
// TODO: Add extra validation here
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -