⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msghndlr.h

📁 设计模式之singleton模式例程
💻 H
字号:
// 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -