📄 serialdlg.cpp
字号:
// SerialDlg.cpp : implementation file
//
#include "stdafx.h"
#include "moinorcentre.h"
#include "SerialDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSerialDlg dialog
CSerialDlg::CSerialDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSerialDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSerialDlg)
m_sBaud = _T("");
m_sDataBits = _T("");
m_sParity = _T("");
m_sport = _T("");
m_sStopbit = _T("");
//}}AFX_DATA_INIT
}
void CSerialDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSerialDlg)
DDX_Control(pDX, IDC_STOPBIT, m_ctrlStopbit);
DDX_Control(pDX, IDC_PORT, m_ctrlPort);
DDX_Control(pDX, IDC_PARITY, m_ctrkParity);
DDX_Control(pDX, IDC_DATABITS, m_ctrlDataBits);
DDX_Control(pDX, IDC_BAUD, m_ctrlBaud);
DDX_CBString(pDX, IDC_BAUD, m_sBaud);
DDX_CBString(pDX, IDC_DATABITS, m_sDataBits);
DDX_CBString(pDX, IDC_PARITY, m_sParity);
DDX_CBString(pDX, IDC_PORT, m_sport);
DDX_CBString(pDX, IDC_STOPBIT, m_sStopbit);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSerialDlg, CDialog)
//{{AFX_MSG_MAP(CSerialDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSerialDlg message handlers
BOOL CSerialDlg::OnInitDialog()
{
CDialog::OnInitDialog();
HANDLE h = INVALID_HANDLE_VALUE;
for(int i=0;i<6;i++)
{CString kk;
kk.Format("com%d",i);
h = ::CreateFile( kk,
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
0);
DWORD err=0;
if (h == INVALID_HANDLE_VALUE)
{
//取得错误信息
err = ::GetLastError();
}
if(err!=2)
m_ctrlPort.AddString(kk);
CloseHandle(h);
m_sParity="None";
m_sBaud="4800";
m_sDataBits="8";
m_sStopbit="1";
m_sport="com1";
this->UpdateData(FALSE);
}
// TODO: Add extra initialization here
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 + -