?? setupdlg.cpp
字號:
// SetupDlg.cpp : implementation file
//
#include "stdafx.h"
#include "GPS_Comm.h"
#include "SetupDlg.h"
//#include "SerialPort.h" //包含串口類
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSetupDlg dialog
CSetupDlg::CSetupDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSetupDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSetupDlg)
m_strBaudRate = _T("");
m_strComm = _T("");
m_strDataBits = _T("");
m_strParity = _T("");
m_strStopBits = _T("");
//}}AFX_DATA_INIT
}
//構造對話框時 傳入串口設備塊
CSetupDlg::CSetupDlg(CWnd* pParent, DCB dcb)
: CDialog(CSetupDlg::IDD, pParent)
{
m_dcb=dcb;
}
//構造對話框時,傳入串口類實例,以取得串口設備塊及串口號
CSetupDlg::CSetupDlg(CWnd* pParent, CSerialPortEx* pPortEx)
: CDialog(CSetupDlg::IDD, pParent)
{
m_dcb=pPortEx->GetDCB();
char temp[10];
m_strComm = _T(CString("COM")+itoa(pPortEx->m_nPortNr,temp,10));
}
void CSetupDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSetupDlg)
DDX_CBString(pDX, IDC_BAUDRATECOMBO, m_strBaudRate);
DDX_CBString(pDX, IDC_COMMCOMBO, m_strComm);
DDX_CBString(pDX, IDC_DATABITSCOMBO, m_strDataBits);
DDX_CBString(pDX, IDC_PARITYCOMBO, m_strParity);
DDX_CBString(pDX, IDC_STOPBITSCOMBO, m_strStopBits);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSetupDlg, CDialog)
//{{AFX_MSG_MAP(CSetupDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSetupDlg message handlers
//對話框初始化時,用先前的值填充各框
BOOL CSetupDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CString strTemp;
strTemp.Format("%d",m_dcb.BaudRate );
((CComboBox*)GetDlgItem(IDC_BAUDRATECOMBO))->SelectString(0,strTemp);
((CComboBox*)GetDlgItem(IDC_PARITYCOMBO))->SetCurSel(m_dcb.Parity);
((CComboBox*)GetDlgItem(IDC_STOPBITSCOMBO))->SetCurSel(m_dcb.StopBits);
strTemp.Format("%d",m_dcb.ByteSize); //數據位
((CComboBox*)GetDlgItem(IDC_DATABITSCOMBO))->SelectString(0,strTemp);
CComboBox* pcommChoice=(CComboBox*)this->GetDlgItem(IDC_COMMCOMBO);
switch(m_strComm[3]) //串口號的第四個字母
{
case '1':
pcommChoice->SetCurSel(0);
break;
case '2':
pcommChoice->SetCurSel(1);
break;
case '3':
pcommChoice->SetCurSel(2);
break;
case '4':
pcommChoice->SetCurSel(3);
break;
default:
break;
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSetupDlg::OnOK()
{
// TODO: Add extra validation here
CDialog::OnOK();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -