基于对话框的程序的框架

.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()
//CMainDialog
CMainDialog::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
//CMyApp
class CMyApp:public CWinApp
{
public:
	BOOL InitInstance();
};

//CMyDialog
class 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()
};


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值