📄 configdlg.cpp
字号:
/*
** FILENAME ConfigDlg.cpp
**
** PURPOSE Here the ports can be configured
**
** CREATION DATE 15-09-1997
** LAST MODIFICATION 12-11-1997
**
** AUTHOR Remon Spekreijse
**
*/
#include "stdafx.h"
#include "ConfigDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CConfigDlg dialog
CConfigDlg::CConfigDlg(CWnd* pParent /*=NULL*/)
: CDialog(CConfigDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CConfigDlg)
m_strBaudRate = _T("");
m_strDataBits = _T("");
m_strParity = _T("");
m_strStopBits = _T("");
m_nPort=0;
m_strIO = _T("");
//}}AFX_DATA_INIT
m_bSerial=TRUE;
m_strIO=_T("956");
}
//DEL CConfigDlg::CConfigDlg(CWnd* pParent, WORD nIO)
//DEL : CDialog(CConfigDlg::IDD, pParent)
//DEL {
//DEL m_bSerial=FALSE;
//DEL itoa(nIO,m_strIO.GetBuffer(10),10);
//DEL m_strIO.ReleaseBuffer();
//DEL
//DEL m_dcb.BaudRate=19200;
//DEL m_dcb.ByteSize=8;
//DEL m_dcb.StopBits=1;
//DEL m_dcb.Parity=NOPARITY;
//DEL }
CConfigDlg::CConfigDlg(CWnd* pParent, BOOL bSerial,DCB dcb,WORD nIO,int nPort)
: CDialog(CConfigDlg::IDD, pParent)
{
m_bSerial=bSerial;
m_dcb = dcb;
itoa(nIO,m_strIO.GetBuffer(10),10);
m_strIO.ReleaseBuffer();
m_nPort=nPort;
}
void CConfigDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CConfigDlg)
DDX_CBString(pDX, IDC_BAUDRATECOMBO, m_strBaudRate);
DDX_CBString(pDX, IDC_DATABITSCOMBO, m_strDataBits);
DDX_CBString(pDX, IDC_PARITYCOMBO, m_strParity);
DDX_CBString(pDX, IDC_STOPBITSCOMBO, m_strStopBits);
DDX_CBIndex(pDX, IDC_COMCOMBO, m_nPort);
DDX_Text(pDX, IDC_EDITIO, m_strIO);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CConfigDlg, CDialog)
//{{AFX_MSG_MAP(CConfigDlg)
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CConfigDlg message handlers
BOOL CConfigDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CString strTemp;
strTemp.Format("%d", m_dcb.BaudRate);
((CComboBox*)GetDlgItem(IDC_BAUDRATECOMBO))->SelectString(0, strTemp);
((CComboBox*)GetDlgItem(IDC_PARITYCOMBO))->SetCurSel(m_dcb.Parity);
strTemp.Format("%d", m_dcb.StopBits);
int n=((CComboBox*)GetDlgItem(IDC_STOPBITSCOMBO))->FindStringExact(0,strTemp);
((CComboBox*)GetDlgItem(IDC_STOPBITSCOMBO))->SetCurSel(n);
// SetDlgItemText(IDC_STOPBITSCOMBO,strTemp);
//((CComboBox*)GetDlgItem(IDC_STOPBITSCOMBO))->SelectString(0, strTemp);
strTemp.Format("%d", m_dcb.ByteSize);
((CComboBox*)GetDlgItem(IDC_DATABITSCOMBO))->SelectString(0, strTemp);
((CComboBox*)GetDlgItem(IDC_COMCOMBO))->SetCurSel(m_nPort);
CButton* pBu;
if(m_bSerial)
{
pBu=(CButton*)GetDlgItem(IDC_RADIO1);
pBu->SetCheck(BST_CHECKED);
CWnd* pWnd= GetDlgItem(IDC_BAUDRATECOMBO);
pWnd->EnableWindow(TRUE);
pWnd= GetDlgItem(IDC_PARITYCOMBO);
pWnd->EnableWindow(TRUE);
pWnd= GetDlgItem(IDC_DATABITSCOMBO);
pWnd->EnableWindow(TRUE);
pWnd= GetDlgItem(IDC_STOPBITSCOMBO);
pWnd->EnableWindow(TRUE);
pWnd= GetDlgItem(IDC_COMCOMBO);
pWnd->EnableWindow(TRUE);
pWnd= GetDlgItem(IDC_EDITIO);
pWnd->EnableWindow(FALSE);
}
else
{
pBu=(CButton*)GetDlgItem(IDC_RADIO2);
pBu->SetCheck(BST_CHECKED);
CWnd* pWnd= GetDlgItem(IDC_BAUDRATECOMBO);
pWnd->EnableWindow(FALSE);
pWnd= GetDlgItem(IDC_PARITYCOMBO);
pWnd->EnableWindow(FALSE);
pWnd= GetDlgItem(IDC_DATABITSCOMBO);
pWnd->EnableWindow(FALSE);
pWnd= GetDlgItem(IDC_STOPBITSCOMBO);
pWnd->EnableWindow(FALSE);
pWnd= GetDlgItem(IDC_COMCOMBO);
pWnd->EnableWindow(FALSE);
pWnd= GetDlgItem(IDC_EDITIO);
pWnd->EnableWindow(TRUE);
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CConfigDlg::OnRadio2()
{
// TODO: Add your control notification handler code here
CWnd* pWnd= GetDlgItem(IDC_BAUDRATECOMBO);
pWnd->EnableWindow(FALSE);
pWnd= GetDlgItem(IDC_PARITYCOMBO);
pWnd->EnableWindow(FALSE);
pWnd= GetDlgItem(IDC_DATABITSCOMBO);
pWnd->EnableWindow(FALSE);
pWnd= GetDlgItem(IDC_STOPBITSCOMBO);
pWnd->EnableWindow(FALSE);
pWnd= GetDlgItem(IDC_COMCOMBO);
pWnd->EnableWindow(FALSE);
pWnd= GetDlgItem(IDC_EDITIO);
pWnd->EnableWindow(TRUE);
m_bSerial=FALSE;
}
void CConfigDlg::OnRadio1()
{
// TODO: Add your control notification handler code here
CWnd* pWnd= GetDlgItem(IDC_BAUDRATECOMBO);
pWnd->EnableWindow(TRUE);
pWnd= GetDlgItem(IDC_PARITYCOMBO);
pWnd->EnableWindow(TRUE);
pWnd= GetDlgItem(IDC_DATABITSCOMBO);
pWnd->EnableWindow(TRUE);
pWnd= GetDlgItem(IDC_STOPBITSCOMBO);
pWnd->EnableWindow(TRUE);
pWnd= GetDlgItem(IDC_COMCOMBO);
pWnd->EnableWindow(TRUE);
pWnd= GetDlgItem(IDC_EDITIO);
pWnd->EnableWindow(FALSE);
m_bSerial=TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -