msghndlr.h

来自「C++、MFC源代码Singleton_demo」· C头文件 代码 · 共 93 行

H
93
字号
// MsgHndlr.h : interface of the CMsgHndlr class
//
/////////////////////////////////////////////////////////////////////////////

// Written by : T. Kulathu Sarma

// This file is part of Singleton application to demonstrate the concept of Singleton classes.
// This file is provided "as is" with no expressed or implied warranty.

#ifndef _MESSAGEHANDLER
#define _MESSAGEHANDLER

#include <afxtempl.h>
#include "SmtClnr.h"

// List of predefined constants

#ifndef SUCCESS
#define SUCCESS 0
#endif

#ifndef FAILURE
#define FAILURE -1
#endif

// User message to send notification

#define WM_HANDLE_MESSAGE	WM_USER + 1000

// Structure used to send WM_HANDLE_MESSAGE messages

typedef struct tagMSGPACKET
{
	CString	m_csMessage;
	INT		m_nType;
	DWORD		m_dwAppData;
} MSGPACKET, * LPMSGPACKET, ** LPPMSGPACKET;

// List of message types

#define INFO_TYPE			1
#define WARNING_TYPE		2
#define ERROR_TYPE		3

// Class declaration for CMsgHndlr

class CMsgHndlr : public CObject
{
	// Destructor
	public :
		virtual ~CMsgHndlr();

	// Creation - Message Handler Singleton Object
	public :
		DECLARE_DYNCREATE( CMsgHndlr )
		static CMsgHndlr * GetMsgHndlr( LPCSTR = NULL );
		static CMsgHndlr * GetMsgHndlr( CRuntimeClass * = NULL );

	// Method(s) to get information about registered message handlers
	public :
		static INT		GetRegCount();
		static BOOL		IsHndlrRegistered( LPCSTR );

	// Services - Message Handling method(s) that can be redefined by derived class
	public :
		virtual	INT HandleMessage( LPCSTR, INT = INFO_TYPE, DWORD = 0 ); 

	// Services - Windows Notification method(s)
	public :
		INT		SetNotifyWindow( CWnd * );
		CWnd *	GetNotifyWindow();

	protected :
		// Protected constructor
		CMsgHndlr();

	private :
		// Private Copy constructor and Assignment operator, to hide it from clients
		CMsgHndlr( const CMsgHndlr & );
		CMsgHndlr & operator = ( const CMsgHndlr & );

	// Attributes
	protected :
		static CMsgHndlr			* m_pMsgHndlr;
		CWnd							* m_pNotifyWnd;

	// Attributes
	private :
		static CSmartCleaner		m_SmartCleaner;
};
#endif

⌨️ 快捷键说明

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