Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Customized Visual Studio .NET package: your fully integrated document window inside the IDE

, 20 Dec 2003
Create a fully integrated document window inside the Visual Studio IDE.
#pragma once

#include <windows.h>

class CVsWindow;
typedef LONG (CVsWindow::*TFnMsgHandler)(WPARAM,LPARAM);
struct TMsgEntry
{
	UINT m_uMsg;
	TFnMsgHandler m_pFn;
};

struct TMsgMap
{
	TMsgMap* m_pBaseMap;
	TMsgEntry* m_pMsgEntries;
};

#define MS_DECL_MSG_MAP()		\
	virtual TMsgMap* GetMessageMap(); \
	static TMsgEntry m_pMsgEntries[]; \
	static TMsgMap	m_MsgMap;  \

#define MS_START_MSG_MAP( ClassName, BaseClassName )		\
TMsgMap ClassName::m_MsgMap = { &BaseClassName::m_MsgMap, ClassName::m_pMsgEntries };	\
TMsgMap* ClassName::GetMessageMap()				\
{												\
	return &(ClassName::m_MsgMap);				\
}												\
TMsgEntry ClassName::m_pMsgEntries[] =			\
{												\

#define MS_MSG(MSG_ID,FUNCTION)	{MSG_ID,(TFnMsgHandler)FUNCTION},

#define MS_END_MSG_MAP()	{0xFFFFF,NULL} };


class CVsWindow
{
public:
	CVsWindow(void);
	virtual ~CVsWindow(void);
	BOOL Create(HWND hParent, int iX, int iY, int iCX, int iCY );
	HWND GetHandle() { return m_hWnd; };
	void Invalidate() { if ( m_hWnd ) { ::InvalidateRect(m_hWnd,NULL,FALSE); } };
	void Close();
protected:
	virtual BOOL OnCreate( LPCREATESTRUCT pCS ){return TRUE;};
	virtual void OnNcDestroy(){};
	virtual void OnPaint(HDC hDC){};
	MS_DECL_MSG_MAP();
	HWND m_hWnd;
private:
	static LONG CALLBACK _MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
	static BOOL	m_bClassRegistered;
	LONG OnCreatePriv(WPARAM,LPARAM);
	LONG OnNcDestroyPriv(WPARAM,LPARAM);
	void OnPaintPriv();
};

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

Michael Sheinin
Web Developer
United States United States
For the last 7 years I have developed software in real-time/embedded and MS-Windows environments for military and civil markets. I hold B.Sc. degree in computer engineering. Living in Ontario, Canada, I like hiking and traveling in general. Currently, I'm looking for employment opportunity inside the GTA.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150129.1 | Last Updated 21 Dec 2003
Article Copyright 2003 by Michael Sheinin
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid