basedialog.h

来自「打印机监视器」· C头文件 代码 · 共 87 行

H
87
字号

// BaseDialog.h: interface for the CBaseDialog class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_BASEDIALOG_H__07D43161_D237_11D7_97BC_CF60BBD6F143__INCLUDED_)
#define AFX_BASEDIALOG_H__07D43161_D237_11D7_97BC_CF60BBD6F143__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

// Windows Header Files:
#include <windows.h>
// C RunTime Header Files
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>

#include <stdio.h>

//禁止掉不必须的警告
#pragma warning(disable:4786)

#include <map>
class CBaseDialog;

typedef void(CBaseDialog::*fpMessageHandler)(HWND hDlg,WPARAM wParam,LPARAM lParam);

struct t_MessageEntry
{
	fpMessageHandler MsgHandler;
};

/////////////////////////////// MACROS

#define IMPLEMENT_MESSAGE_HANDLER(base,derived) void derived::AddHandler(UINT MessageId, void(derived::*Handler)(HWND hDlg,WPARAM wParam,LPARAM lParam))\
												{\
													AddMessageHandler(MessageId, (void(base::*)(HWND hDlg,WPARAM wParam,LPARAM lParam))Handler);\
												}\

#define DECLARE_MESSAGE_HANDLER(derived) void AddHandler(UINT MessageId, void(derived::*Handler)(HWND hDlg,WPARAM wParam,LPARAM lParam));\
										 void HandleManager(void);\

#define BEGIN_MESSAGE_MAP(derived) void derived::HandleManager(void) {

#define ADD_MESSAGE_HANDLER(message,handler) AddHandler(message, handler);

#define END_MESSAGE_MAP() }

#define ENABLE_MESSAGE_MAP() HandleManager();

class CBaseDialog  
{

	public:

		std::map<UINT,t_MessageEntry>				m_MessageMap;
		std::map<UINT,t_MessageEntry>::iterator	m_MessageMapIterator;

		CBaseDialog(int nResId, HWND hParent=NULL);
		virtual ~CBaseDialog();

		int DoModal(void);
		
		static BOOL CALLBACK DialogProcStatic(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
		BOOL CALLBACK DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);

		void OnOK(void);
		void OnCancel(void);

		void AddMessageHandler(UINT MessageId, void(CBaseDialog::*Handler)(HWND hDlg,WPARAM wParam,LPARAM lParam));

	protected:
		
		int m_nResId;
		HWND m_hParent;

		 HWND m_hWnd;
		 BOOL DlgFlag;
	//	static long m_lSaveThis;
};


#endif // !defined(AFX_BASEDIALOG_H__07D43161_D237_11D7_97BC_CF60BBD6F143__INCLUDED_)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?