📄 dialog_setcom.cpp
字号:
// Dialog_SetCom.cpp : implementation file
//
#include "stdafx.h"
#include "TempHumSystem.h"
#include "Dialog_SetCom.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDialog_SetCom dialog
CDialog_SetCom::CDialog_SetCom(CWnd* pParent /*=NULL*/)
: CDialog(CDialog_SetCom::IDD, pParent)
{
//{{AFX_DATA_INIT(CDialog_SetCom)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CDialog_SetCom::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDialog_SetCom)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDialog_SetCom, CDialog)
//{{AFX_MSG_MAP(CDialog_SetCom)
ON_BN_CLICKED(IDC_BUTTON_SAVE, OnButtonSave)
ON_BN_CLICKED(IDC_BUTTON_BACK, OnButtonBack)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDialog_SetCom message handlers
void CDialog_SetCom::OnButtonSave()
{
// TODO: Add your control notification handler code here
CString str1,str2,str3,str4,str5,str0;
CFile file("comset.ini",CFile::modeCreate|CFile::modeWrite);
GetDlgItemText(IDC_COMBO_PORT,str0);
if(str0=="Port1") str1="0";
if(str0=="Port2") str1="1";
if(str0=="Port3") str1="2";
if(str0=="Port4") str1="3";
if(str0=="Port5") str1="4";
if(str0=="Port6") str1="5";
if(str0=="Port7") str1="6";
if(str0=="Port8") str1="7";
if(str0=="Port9") str1="8";
if(str0=="Port10") str1="9";
if(str0=="Port11") str1="10";
if(str0=="Port12") str1="11";
file.Write(str1,strlen(str1));
//-----------------------------------------------------------------
GetDlgItemText(IDC_COMBO_BOARDRATE,str0);
if(str0=="19200") str2="0";
if(str0=="14400") str2="1";
if(str0=="9600") str2="2";
if(str0=="4800") str2="3";
if(str0=="2400") str2="4";
if(str0=="1800") str2="5";
file.Write(str2,strlen(str2));
//---------------------------------------------------------------------
GetDlgItemText(IDC_COMBO_CHECK,str0);
if(str0=="ODD") str3="0";
if(str0=="EVEN") str3="1";
if(str0=="NONE") str3="2";
file.Write(str3,strlen(str3));
//----------------------------------------------------------------------
GetDlgItemText(IDC_COMBO_DATNUM,str0);
if(str0=="9") str4="0";
if(str0=="8") str4="1";
if(str0=="7") str4="2";
if(str0=="6") str4="3";
if(str0=="5") str4="4";
if(str0=="4") str4="5";
file.Write(str4,strlen(str4));
//-----------------------------------------------------------------------
GetDlgItemText(IDC_COMBO_STOPNUM,str0);
if(str0=="2") str5="0";
if(str0=="1") str5="1";
file.Write(str5,strlen(str5));
file.Close();
CDialog::OnOK();
}
void CDialog_SetCom::OnButtonBack()
{
// TODO: Add your control notification handler code here
CDialog::OnCancel();
}
BOOL CDialog_SetCom::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
((CComboBox*)GetDlgItem(IDC_COMBO_PORT))->SetCurSel(0);
((CComboBox*)GetDlgItem(IDC_COMBO_BOARDRATE))->SetCurSel(0);
((CComboBox*)GetDlgItem(IDC_COMBO_CHECK))->SetCurSel(0);
((CComboBox*)GetDlgItem(IDC_COMBO_DATNUM))->SetCurSel(0);
((CComboBox*)GetDlgItem(IDC_COMBO_STOPNUM))->SetCurSel(0);
CString n;
CString p[24];
CFile file("comset.ini",CFile::modeRead);
char *pBuf;
DWORD dwFileLen;
dwFileLen=file.GetLength();
pBuf=new char[dwFileLen+1];
pBuf[dwFileLen]=0;
file.Read(pBuf,dwFileLen);
file.Close();
n=pBuf;
p[0]=n.Mid(0,1);
p[1]=n.Mid(1,1);
p[2]=n.Mid(2,1);
p[3]=n.Mid(3,1);
p[4]=n.Mid(4,1);
((CComboBox*)GetDlgItem(IDC_COMBO_PORT))->SetCurSel(atoi(p[0]));
((CComboBox*)GetDlgItem(IDC_COMBO_BOARDRATE))->SetCurSel(atoi(p[1]));
((CComboBox*)GetDlgItem(IDC_COMBO_CHECK))->SetCurSel(atoi(p[2]));
((CComboBox*)GetDlgItem(IDC_COMBO_DATNUM))->SetCurSel(atoi(p[3]));
((CComboBox*)GetDlgItem(IDC_COMBO_STOPNUM))->SetCurSel(atoi(p[4]));
delete [] pBuf;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -