Click here to Skip to main content
Click here to Skip to main content
Articles » Multimedia » GDI » Regions » Downloads
 
Add your own
alternative version
Go to top

Guide to WIN32 Regions

, 10 Mar 2002
Guide to understanding how to create and use regions with the WIN32 SDK
rgnguide_demo.zip
RgnGuide.exe
rgnguide_src.zip
arrow.cur
RgnGuide.dsp
res
RgnGuide.ico
cursor1.cur
Toolbar.bmp
/* RgnGuideview.h *************************************************************
Author:		Paul Watt
Date:		3/5/2002
Purpose:	
******************************************************************************/
#ifndef __RGNGUIDEVIEW_H
#define __RGNGUIDEVIEW_H

#include "resource.h"

class CRgnGuideView;

#define ALL  0
#define RGN1 1
#define RGN2 2
#define BREAK1 3
#define BREAK2 4

/* Class **********************************************************************
Author:		Paul Watt
Date:		3/5/2002
Purpose:	
******************************************************************************/
class CRgnGuideSubView : public CWindowImpl<CRgnGuideSubView>
{
private:
	UINT			m_nCombineMode;
	CRgnGuideView	*m_Parent;

	HRGN			m_RgnCombine;

public:
	DECLARE_WND_CLASS(NULL)

	CRgnGuideSubView ();
	~CRgnGuideSubView ();
	BOOL PreTranslateMessage(MSG* pMsg);
	void SetMode(UINT nMode);
	void SetParent(CRgnGuideView *pParent);

	BEGIN_MSG_MAP(CRgnGuideSubView)
		MESSAGE_HANDLER(WM_PAINT, OnPaint)
		MESSAGE_HANDLER(WM_LBUTTONDOWN, OnButtonDown)
		MESSAGE_HANDLER(WM_RBUTTONDOWN, OnButtonDown)
	END_MSG_MAP()

	LRESULT OnButtonDown (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
	LRESULT OnMouseMove (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
	LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
};


/* Class **********************************************************************
Author:		Paul Watt
Date:		3/5/2002
Purpose:	
******************************************************************************/
class CRgnGuideView : public CWindowImpl<CRgnGuideView>
{
private:
	bool	m_isRubberBand;
	POINT	m_ptStart;
	POINT	m_ptCurrent;

	UINT    m_nMode;
	UINT	m_nViewMode;

	HRGN    m_hDraggingRgn;
	BOOL    m_isSrc1;

	CRgnGuideSubView m_viewAnd;
	CRgnGuideSubView m_viewDiff;
	CRgnGuideSubView m_viewOr;
	CRgnGuideSubView m_viewXor;

	HCURSOR m_hCsrDrag1;
	HCURSOR m_hCsrDrag2;

public:
	DECLARE_WND_CLASS(NULL)

	CRgnGuideView ();
	~CRgnGuideView ();
	BOOL PreTranslateMessage(MSG* pMsg);
	UINT GetMode();
	void SetMode(UINT nMode);
	UINT GetViewMode();
	void SetViewMode(UINT ViewMode);

	BEGIN_MSG_MAP(CRgnGuideView)
		MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
		MESSAGE_HANDLER(WM_PAINT, OnPaint)
		MESSAGE_HANDLER(WM_CHAR, OnChar)
		MESSAGE_HANDLER(WM_LBUTTONDOWN, OnButtonDown)
		MESSAGE_HANDLER(WM_LBUTTONUP, OnButtonUp)
		MESSAGE_HANDLER(WM_RBUTTONDOWN, OnButtonDown)
		MESSAGE_HANDLER(WM_RBUTTONUP, OnButtonUp)
		MESSAGE_HANDLER(WM_SIZE, OnSize);
		MESSAGE_HANDLER(WM_CREATE, OnCreate);
	END_MSG_MAP()

	LRESULT OnCreate (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
	LRESULT OnButtonDown (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
	LRESULT OnMouseMove   (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
	LRESULT OnChar   (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
	LRESULT OnButtonUp   (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
	LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	void DrawRubberBand();
	void SetDraggingRegion (HRGN hDraggingRgn, bool isSrc1);
};



#endif // !defined(AFX_RGNGUIDEVIEW_H__AED8256C_7AB2_4B63_8FD9_1E3218DD69CA__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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Paul M Watt
Architect
United States United States
I have been developing software for almost two decades. The majority of my experience has been with C++. I have had the opportunity to develop software applications, application virtualization, web clients, mobile device management, device drivers and embedded system software for routers and microwave frequency modems.
 
Over the years I have learned to value maintainable software more than all of the other qualities. Occasionally I reach a point in a project where the sacrifice must be made to optimize a section of code for performance, or resource usage. However, by starting out with a simple, maintainable design, I am able to adapt my projects to meet the challenges that inevitably appear during development; including my own misjudgments, incomplete requirements, feature creep and poor decisions for which I have no control.
 
I maintain my own repository and blog at CodeOfTheDamned.com/[^], a site dedicated to guiding developers through the damn code.
Follow on   Twitter

| Advertise | Privacy | Mobile
Web01 | 2.8.140905.1 | Last Updated 11 Mar 2002
Article Copyright 2002 by Paul M Watt
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid