MFC工控项目实例之十七添加手动测试界面
承接专栏《MFC工控项目实例之十六输入信号验证》
1、在JogTest.h文件中添加代码
class CJogTest : public CDialog
{
public:
CJogTest(CWnd* pParent = NULL); // standard constructor
CButtonST m_btnStart[16];
CFont m_font;
...
}
2、在JogTest.cpp文件中添加代码
#include "stdafx.h"
#include "SEAL_PRESSURE.h"
#include "JogTest.h"
#include "BtnST.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/
// CJogTest dialog
UINT IDC_CHECK[16]=
{
IDC_CHECK0,
IDC_CHECK1,
IDC_CHECK2,
IDC_CHECK3,
IDC_CHECK4,
IDC_CHECK5,
IDC_CHECK6,
IDC_CHECK7,
IDC_CHECK8,
IDC_CHECK9,
IDC_CHECK10,
IDC_CHECK11,
IDC_CHECK12,
IDC_CHECK13,
IDC_CHECK14,
IDC_CHECK15,
};
CJogTest::CJogTest(CWnd* pParent /*=NULL*/)
: CDialog(CJogTest::IDD, pParent)
{
m_font.CreateFont(-28,0,0,0,700,FALSE,FALSE,
0,134,OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
FF_SWISS,"楷体_GB2312");
}
void CJogTest::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
CDialog::DoDataExchange(pDX);
for (int i=0;i<2;i++)
{
DDX_Control(pDX, IDC_CHECK[i], m_btnStart[i]);
}
}
BEGIN_MESSAGE_MAP(CJogTest, CDialog)
//{{AFX_MSG_MAP(CJogTest)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/
// CJogTest message handlers
BOOL CJogTest::OnInitDialog()
{
CDialog::OnInitDialog();
for (int i=0;i<2;i++)
{
m_btnStart[i].SetIcon(IDI_ICON_LedOff);
}
for ( i=0;i<14;i++)
{
GetDlgItem(IDC_STATIC0+i)->SetFont(&m_font);
SetDlgItemText(IDC_STATIC0+i,"0");
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
运行程序