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

📄 smphndlr.cpp

📁 设计模式之singleton模式例程
💻 CPP
字号:
// SmpHndlr.cpp - Implementation of CSmpHndlr class

// CSmpHndlr is dervied from CMsgHndlr and it displays the message in an AfxMessageBox, 
// when HandleMessage method is called

// 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.

#include "stdafx.h"
#include "SmpHndlr.h"
#include "MsgHndlrReg.h"

// Register CSmpHndlr agent in the message handler registry
static CMsgHndlrRegistry< CSmpHndlr > gSmpHndlr( RUNTIME_CLASS( CSmpHndlr ), "SMPHNDLR" );

IMPLEMENT_DYNCREATE( CSmpHndlr, CMsgHndlr )

// CSmpHndlr - Implementation

CSmpHndlr::CSmpHndlr()
{
}

CSmpHndlr::~CSmpHndlr()
{
}

// HandleMessage displays the message with an AfxMessageBox, but this
// can be changed to display the message on any given window
// Application data is ignored in this method
INT CSmpHndlr::HandleMessage( LPCSTR lpszMessage, INT nType, DWORD /* dwAppData */ )
{
	INT nIcon = MB_ICONINFORMATION;

	// Step 1 - Set the icon based on nType
	if( nType == WARNING_TYPE )
	{
		nIcon = MB_ICONEXCLAMATION;
	}
	else if( nType == ERROR_TYPE )
	{
		nIcon = MB_ICONSTOP;
	}
	// Step 2 - Display the message using AfxMessageBox with appropriate icons
	AfxMessageBox( CString( "Simple Message Handler : " ) + lpszMessage, MB_OK | nIcon );
	return SUCCESS;
}

⌨️ 快捷键说明

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