Click here to Skip to main content
11,583,555 members (63,855 online)
Click here to Skip to main content
Articles » Multimedia » GDI » Regions » Downloads
Add your own
alternative version

Guide to WIN32 Regions

, 10 Mar 2002 CPOL 166K 5.1K 120
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 L3 Communications
United States United States
I am a software architect and I have been developing software for nearly two decades. Over the years I have learned to value maintainable solutions first. This has allowed me to adapt my projects to meet the challenges that inevitably appear during development. I use the most beneficial short-term achievements to drive the software I develop towards a long-term vision.

C++ is my strongest language. However, I have also used x86 ASM, ARM ASM, C, C#, JAVA, Python, and JavaScript to solve programming problems. I have worked in a variety of industries throughout my career, which include:
• Manufacturing
• Consumer Products
• Virtualization
• Computer Infrastructure Management
• DoD Contracting

My experience spans these hardware types and operating systems:
• Desktop
o Windows (Full-stack: GUI, Application, Service, Kernel Driver)
o Linux (Application, Daemon)
• Mobile Devices
o Windows CE / Windows Phone
o Linux
• Embedded Devices
o VxWorks (RTOS)
o Greenhills Linux
o Embedded Windows XP

I am a Mentor and frequent contributor to CodeProject.com with tutorial articles that teach others about the inner workings of the Windows APIs.

I am the creator of an open source project on GitHub called Alchemy[^], which is an open-source compile-time data serialization library.

I maintain my own repository and blog at CodeOfTheDamned.com/[^], because code maintenance does not have to be a living hell.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150603.1 | Last Updated 11 Mar 2002
Article Copyright 2002 by Paul M Watt
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid