📄 comenumeratordlg.cpp
字号:
// COMEnumeratorDlg.cpp : implementation file
//
#include "stdafx.h"
#include "COMEnumerator.h"
#include "COMEnumeratorDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCOMEnumeratorDlg dialog
CCOMEnumeratorDlg::CCOMEnumeratorDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCOMEnumeratorDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCOMEnumeratorDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CCOMEnumeratorDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCOMEnumeratorDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCOMEnumeratorDlg, CDialog)
//{{AFX_MSG_MAP(CCOMEnumeratorDlg)
ON_CBN_EDITCHANGE(IDC_COMBO_PORTS, OnEditchangeComboPorts)
ON_BN_CLICKED(IDC_BTN_RUNENUM, OnBtnRunenum)
ON_CBN_SELCHANGE(IDC_COMBO_PORTS, OnSelchangeComboPorts)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCOMEnumeratorDlg message handlers
BOOL CCOMEnumeratorDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CenterWindow(GetDesktopWindow()); // center to the hpc screen
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CCOMEnumeratorDlg::OnEditchangeComboPorts()
{
// TODO: Add your control notification handler code here
}
void CCOMEnumeratorDlg::OnBtnRunenum()
{
// TODO: Add your control notification handler code here
UINT i;
CButton *p_checkBoxVerify;
p_checkBoxVerify = (CButton *)this->GetDlgItem(IDC_CHECK_VERIFY);
m_pComboComSel = (CComboBox *)this->GetDlgItem(IDC_COMBO_PORTS);
if(p_checkBoxVerify->GetCheck() == BST_CHECKED)
{
this->m_Enumerator.EnumerateCOMs(TRUE);
}
else
{
this->m_Enumerator.EnumerateCOMs(FALSE);
}
while(m_pComboComSel->GetCount() > 0)
{
m_pComboComSel->DeleteString(0);
}
for( i=0 ; i < m_Enumerator.GetTotalComs(); i++ )
{
m_pComboComSel->InsertString(i, m_Enumerator.GetPortName(i));
}
}
void CCOMEnumeratorDlg::OnSelchangeComboPorts()
{
// TODO: Add your control notification handler code here
CStatic *pLocEdit;
CString tmpString;
int index = m_pComboComSel->GetCurSel();
pLocEdit = (CStatic *)this->GetDlgItem(IDC_STATIC_KEYVALUE);
if( index != CB_ERR )
{
pLocEdit->SetWindowText(m_Enumerator.GetPortKey(index));
}
pLocEdit = (CStatic *)this->GetDlgItem(IDC_STATIC_INDEXVALUE);
if( index != CB_ERR )
{
tmpString.Format(_T("%d"), m_Enumerator.GetPortIndex(index));
pLocEdit->SetWindowText(tmpString);
}
}
//void CCOMEnumeratorDlg::OnBtnGetshortkey()
//{
// TODO: Add your control notification handler code here
// CString tmpString;
// tmpString = this->m_Enumerator.GetPortSimpleKey(0);
// AfxMessageBox(tmpString);
//}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -