承接专栏《MFC工控项目实例之十一板卡测试信号输入界面》
1、在BoardTest.h文件中添加代码
CButtonST m_btnStart[16],m_btnStart_O[16];
2、在BoardTest.cpp文件中添加代码
UINT No_IDC_CHECK_O[16]=
{
IDC_CHECK16,
IDC_CHECK17,
IDC_CHECK18,
IDC_CHECK19,
IDC_CHECK20,
IDC_CHECK21,
IDC_CHECK22,
IDC_CHECK23,
IDC_CHECK24,
IDC_CHECK25,
IDC_CHECK26,
IDC_CHECK27,
IDC_CHECK28,
IDC_CHECK29,
IDC_CHECK30,
IDC_CHECK31,
};
int m_CountGetCurSel_O[16];//索引号
UINT m_CountComboID_O[16]=//控件ID号
{
IDC_COMBO17,
IDC_COMBO18,
IDC_COMBO19,
IDC_COMBO20,
IDC_COMBO21,
IDC_COMBO22,
IDC_COMBO23,
IDC_COMBO24,
IDC_COMBO25,
IDC_COMBO26,
IDC_COMBO27,
IDC_COMBO28,
IDC_COMBO29,
IDC_COMBO30,
IDC_COMBO31,
IDC_COMBO32,
};
CString COMB_Data_O[17]={"- - - - - -","输出1","输出2","输出3","输出4","输出5","输出6","输出7","输出8","输出9","输出10","输出11","输出12","输出13","输出14","输出15","输出16"};
void CBoardTest::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
for (int i=0;i<16;i++)
{
DDX_Control(pDX, No_IDC_CHECK_O[i], m_btnStart_O[i]);
}
BOOL CBoardTest::OnInitDialog()
{
CDialog::OnInitDialog();
...
for (i=0;i<16;i++)
{
m_btnStart_O[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_O[i]))->AddString(COMB_Data_O[j]);
((CComboBox*)GetDlgItem(m_CountComboID_O[i]))->SetCurSel(0);
}
}
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
运行程序