Click here to Skip to main content
15,892,737 members
Articles / Programming Languages / C++

X-Window Manager like dragging and resizing of windows

Rate me:
Please Sign up or sign in to vote.
4.88/5 (33 votes)
21 Sep 20051 min read 140.3K   3.1K   43  
This article shows how to make use of a mouse hook to allow simple dragging and resizing of windows.
#ifndef __WMMOUSE_H__
#define __WMMOUSE_H__

#include <windows.h>
#include "wmmousedll.h"

// 
// a wrapper class to access the wmmousedll
//
class WMMouse
{
protected:
	static HINSTANCE			mMouseDllHinst;
	static SETKBHOOK			mSetMouseHook;
	static REMOVEKBHOOK			mRemoveMouseHook;
	static GETINSTANCECOUNT		mGetInstanceCount;

public:
	static bool Init();
	static void Done()
		{ if (mMouseDllHinst) FreeLibrary(mMouseDllHinst); }

	static void SetMouseHook()
		{ if (mMouseDllHinst) mSetMouseHook();	}

	static void RemoveMouseHook()
		{ if (mMouseDllHinst) mRemoveMouseHook(); }
		
	static int GetInstanceCount()
	{
		if (mMouseDllHinst)
			return mGetInstanceCount();
		else
			return 0;
	}
};

#endif // __WMMOUSE_H__

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


Written By
Web Developer
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions