15,980
社区成员
发帖
与我相关
我的任务
分享
//指定Button的ID
#define IDC_BUTTON 111111
// view h头文件中
afx_msg void OnButton();
// view cpp文件中消息映射
BEGIN_MESSAGE_MAP(...)
...
ON_BN_CLICKED(IDC_BUTTON, &CXXXView::OnButton)
END_MESSAGE_MAP()
// view cpp文件中Button响应函数
void CXXXView::OnButton()
{
AfxMessageBox(_T("Hello,World"));
}
// 创建Button按钮,可以放在view类的OnCreate函数中
m_button.Create(_T("Button"), WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON, CRect(20, 20, 100, 45), this, IDC_BUTTON1);