承接专栏《MFC工控项目实例之十添加系统测试对话框》
相关代码
1、在BoardTest.h文件中添加代码
class CBoardTest : public CDialog
{
// Construction
public:CBoardTest(CWnd* pParent = NULL); // standard constructorCButtonST m_btnStart[16];CWinThread* pThread; bool isThreadBegin ; //线程退出/执行控制void My_Func();static UINT My_TheradFunc(LPVOID lparam);...}
2、在BoardTest.cpp文件中添加代码
UINT No_IDC_CHECK[16]=
{IDC_CHECK15,IDC_CHECK14,IDC_CHECK13,IDC_CHECK12,IDC_CHECK11,IDC_CHECK10,IDC_CHECK9,IDC_CHECK8,IDC_CHECK7,IDC_CHECK6,IDC_CHECK5,IDC_CHECK4,IDC_CHECK3,IDC_CHECK2,IDC_CHECK1,IDC_CHECK0,};int m_CountGetCurSel[16];//索引号
UINT m_CountComboID[16]=//控件ID号{IDC_COMBO1,IDC_COMBO2,IDC_COMBO3,IDC_COMBO4,IDC_COMBO5,IDC_COMBO6,IDC_COMBO7,IDC_COMBO8,IDC_COMBO9,IDC_COMBO10,IDC_COMBO11,IDC_COMBO12,IDC_COMBO13,IDC_COMBO14,IDC_COMBO15, IDC_COMBO16, };
CString COMB_Data[17]={"- - - - - -","信号1","信号2","信号3","信号4","信号5","信号6","信号7","信号8","信号9","信号10","信号11","信号12","信号13","信号14","信号15","信号16"};BOOL CBoardTest::OnInitDialog()
{CDialog::OnInitDialog();for (int i=0;i<16;i++){m_btnStart[i].SetIcon(IDI_ICON_LedOn, IDI_ICON_LedOff);}for ( i=0; i<16; i++){ for (int j=0; j<17; j++){((CComboBox*)GetDlgItem(m_CountComboID[i]))->AddString(COMB_Data[j]);((CComboBox*)GetDlgItem(m_CountComboID[i]))->SetCurSel(0); }}// TODO: Add extra initialization herereturn TRUE; // return TRUE unless you set the focus to a control// EXCEPTION: OCX Property Pages should return FALSE
}
运行程序