单击按钮启动、停止交替切欣换
1、在1Dlg.h文件中添加代码
public:CMy1Dlg(CWnd* pParent = NULL); // standard constructorBOOL m_b;
2、在1Dlg.cpp文件中添加代码
CMy1Dlg::CMy1Dlg(CWnd* pParent /*=NULL*/): CDialog(CMy1Dlg::IDD, pParent)
{ m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);m_b = FALSE;
}void CMy1Dlg::OnButton1()
{
if(!m_b){m_b = TRUE;SetDlgItemText(IDC_BUTTON1,"启动");}else{m_b = FALSE;SetDlgItemText(IDC_BUTTON1,"停止");}
}
运行程序