// PropCommCfg.cpp: 实现文件 // #include "pch.h" #include "MTerm1.h" #include "PropCommCfg.h" #include "afxdialogex.h" // CPropCommCfg 对话框 IMPLEMENT_DYNAMIC(CPropCommCfg, CMyPropPage) CPropCommCfg::CPropCommCfg(CWnd* pParent /*=nullptr*/) : CMyPropPage(IDD_PROP_COMM_CFG, pParent) { } CPropCommCfg::~CPropCommCfg() { } void CPropCommCfg::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CPropCommCfg, CMyPropPage) END_MESSAGE_MAP() // CPropCommCfg 消息处理程序 int CPropCommCfg::ShowParams() { // TODO: 在此处添加实现代码. CString s1; s1.Format(_T("ComCfg ShowParams DataPtr %p "),DataPtr); SysLog(s1); s1.Format(_T("mode %d"), ComPortParam.WorkMode); SysLog(s1); s1.Format(_T("station %d"), ComPortParam.Station); SysLog(s1); s1.Format(_T("baudrate %d"), ComPortParam.BaudRate); SysLog(s1); s1.Format(_T("bytesize %d"), ComPortParam.ByteSize); SysLog(s1); s1.Format(_T("stopbits %d"), ComPortParam.StopBits); SysLog(s1); s1.Format(_T("parity %d"), ComPortParam.Parity); SysLog(s1); s1.Format(_T("eofchar %d"), ComPortParam.EofChar); SysLog(s1); s1.Format(_T("sofchar %d"), ComPortParam.SofChar); SysLog(s1); s1.Format(_T("endtype %d"), ComPortParam.EndType); SysLog(s1); s1.Format(_T("recvaddr %d"), ComPortParam.RecvAddr); SysLog(s1); s1.Format(_T("recvsize %d"), ComPortParam.RecvSize); SysLog(s1); s1.Format(_T("endtime %d"), ComPortParam.EndTime); SysLog(s1); ((CComboBox *)GetDlgItem(IDC_COMBO_WORKMODE))->SetCurSel(ComPortParam.WorkMode); ((CComboBox *)GetDlgItem(IDC_COMBO_STATION))->SetCurSel(ComPortParam.Station); s1.Format(_T("%d"), ComPortParam.BaudRate*100); ((CComboBox *)GetDlgItem(IDC_COMBO_BAUDRATE))->SelectString(0,s1); ((CComboBox *)GetDlgItem(IDC_COMBO_BAUDRATE))->SetWindowText(s1); ((CComboBox *)GetDlgItem(IDC_COMBO_BYTE_SIZE))->SetCurSel(ComPortParam.ByteSize); ((CComboBox *)GetDlgItem(IDC_COMBO_STOP_BIT))->SetCurSel(ComPortParam.StopBits); ((CComboBox *)GetDlgItem(IDC_COMBO_PARITY))->SetCurSel(ComPortParam.Parity); ((CComboBox *)GetDlgItem(IDC_COMBO_EOF_CHAR))->SetCurSel(ComPortParam.EofChar); ((CComboBox *)GetDlgItem(IDC_COMBO_SOF_CHAR))->SetCurSel(ComPortParam.SofChar); ((CComboBox *)GetDlgItem(IDC_COMBO_END_TYPE))->SetCurSel(ComPortParam.EndType); s1.Format(_T("%d"), ComPortParam.RecvAddr); ((CEdit *)GetDlgItem(IDC_EDIT_BUF_ADDR))->SetWindowText(s1); s1.Format(_T("%d"), ComPortParam.RecvSize); ((CEdit *)GetDlgItem(IDC_EDIT_BUF_SIZE))->SetWindowText(s1);; s1.Format(_T("%d"), ComPortParam.EndTime); ((CEdit *)GetDlgItem(IDC_EDIT_END_TIME))->SetWindowText(s1);; return 0; } int CPropCommCfg::GetParams() { // TODO: 在此处添加实现代码. return 0; } int CPropCommCfg::GetData() { // TODO: 在此处添加实现代码. if (DataPtr != nullptr) { memcpy(&ComPortParam, DataPtr, sizeof(ComPortParam)); ShowParams(); } return 0; } int CPropCommCfg::SetData() { // TODO: 在此处添加实现代码. GetParams(); return 0; }