Click here to Skip to main content
13,660,809 members
Click here to Skip to main content

Stats

162.4K views
8.2K downloads
128 bookmarked
Posted 6 Apr 2003
Licenced

InterSpy - An integrated Windows message trace and filter utility

, 15 Apr 2003
A utility providing enhanced Windows message debugging.
// ISMsgManager.h: interface for the CISMsgManager class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_ISMSGMANAGER_H__975F4620_557F_44FB_81FF_ECD5C55D9015__INCLUDED_)
#define AFX_ISMSGMANAGER_H__975F4620_557F_44FB_81FF_ECD5C55D9015__INCLUDED_

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

#include <afxtempl.h>

class CISMsgHandler
{
public:
	CISMsgHandler(UINT uMsg, LPCTSTR szMsg, BOOL bHasParams = TRUE) : 
		m_uMsg(uMsg), m_sMsg(szMsg), m_bHasParams(bHasParams) {}
	virtual ~CISMsgHandler() {}
	
	virtual BOOL HandleMsg(const MSG* pMsg, CString& sMsg, CStringArray* pParams)
	{
		ASSERT (pMsg->message == m_uMsg);

		sMsg = m_sMsg;
		return TRUE;
	}

	inline BOOL HasParams() { return m_bHasParams; }

	static void AddParam(CStringArray* pParams, const char *fmt, ...)
	{
		ASSERT (pParams);

		static char gBuffer[1024];
		ZeroMemory(gBuffer, 1024);
		
		va_list marker;
		va_start(marker, fmt);
		vsprintf(gBuffer, fmt, marker);
		va_end(marker);
		
		pParams->Add(gBuffer);
	}
	
protected:
	UINT m_uMsg;
	CString m_sMsg;
	BOOL m_bHasParams;

};

class CISMsgManager
{
public:
	virtual ~CISMsgManager();
	static BOOL HandleMsg(const MSG* pMsg, CString& sMsg, CStringArray* pParams = NULL);

protected:
	static CISMsgManager& GetInstance() { static CISMsgManager isMsgMgr; return isMsgMgr; }

protected:
	CISMsgManager();

	BOOL AddHandler(UINT uMsg, CISMsgHandler* pMsgHandler);
	CISMsgHandler* GetHandler(UINT uMsg);
	void CreateMessageMap();
	void DeleteMessageMap();

protected:
	CMap<UINT, UINT, CISMsgHandler*, CISMsgHandler*&> m_mapHandlers;
};


#endif // !defined(AFX_ISMSGMANAGER_H__975F4620_557F_44FB_81FF_ECD5C55D9015__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

.dan.g.
Software Developer Maptek
Australia Australia
.dan.g. is a naturalised Australian and has been developing commercial windows software since 1998.

You may also be interested in...

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web06-2016 | 2.8.180810.1 | Last Updated 16 Apr 2003
Article Copyright 2003 by .dan.g.
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid