基于对话框的程序的框架

来源:互联网 发布:python相对路径import 编辑:程序博客网 时间:2024/06/09 21:01

.cpp

#include "resource.h"CMyApp theApp;BOOL CMyApp::InitInstance(){CMainDialog dlg;m_pMainWnd = &dlg;   //给m_pMainWnd 主窗口dlg.DoModal();return FALSE; //不进入消息循环}BEGIN_MESSAGE_MAP(CMainDialog, CDialog)ON_BN_CLICKED(IDC_STOP, OnStop)ON_MESSAGE(WM_CUTTERSTART, OnCutterStart) //自定义消息END_MESSAGE_MAP()//CMainDialogCMainDialog::CMainDialog(CWnd* pParentWnd):CDialog(IDD_MAIN, pParentWnd){}BOOL CMainDialog::OnInitDialog( ){CDialog::OnInitDialog();return TRUE;}void CMainDialog::OnStop(){MessageBox("OnStop");}long CMainDialog::OnCutterStart(WPARAM wParam, LPARAM lParam)   //处理自定义消息{MessageBox("OnCutterStart");return 0;}

.h

#include <afxwin.h>#define  WM_CUTTERSTART WM_USER+100//CMyAppclass CMyApp:public CWinApp{public:BOOL InitInstance();};//CMyDialogclass CMainDialog:public CDialog{public:CMainDialog(CWnd* pParentWnd = NULL);protected:virtual BOOL OnInitDialog( );afx_msg void OnStop();afx_msg long OnCutterStart(WPARAM wParam, LPARAM lParam);  //处理自定义消息的声明DECLARE_MESSAGE_MAP()};


原创粉丝点击