Click here to Skip to main content
15,892,674 members
Articles / Desktop Programming / MFC

SolidGraph CAD System

Rate me:
Please Sign up or sign in to vote.
4.97/5 (78 votes)
12 Sep 20062 min read 375.6K   29.8K   209  
A SolidGraph CAD system source code.
/* ==========================================================================
	Class :			CCornerBox

	Author :		Johan Rosengren, Abstrakt Mekanik AB

	Date :			2004-07-16

	Purpose :		"CCornerBox" is a "CWnd"-derived class, used as a button 
					in the corner of two rulers. When clicked, a dialog box 
					is displayed where the user can select the measurement 
					type for the rulers.

	Description :	The class is an AppWizard-created class. A registered 
					message is sent to the parent when the measurement 
					type is changed.

	Usage :			Add with "Create" to the owning window.

   ========================================================================*/

#include "stdafx.h"
#include "..//resource.h"
#include "CornerBox.h"
#include "StdGrfx.h"

#include "RulerMeasurementsDialog.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

UINT UWM_MEASUREMENTS = ::RegisterWindowMessage( _T( "REPORT_EDITOR_MEASUREMENT" ) );

/////////////////////////////////////////////////////////////////////////////
// CCornerBox

CCornerBox::CCornerBox()
/* ============================================================
	Function :		CCornerBox::CCornerBox
	Description :	Constructor
	Access :		Public

	Return :		void
	Parameters :	none

	Usage :			

   ============================================================*/
{

	SetMeasurements( MEASURE_INCHES );

}

CCornerBox::~CCornerBox()
/* ============================================================
	Function :		CCornerBox::~CCornerBox
	Description :	Destructor
	Access :		Public

	Return :		void
	Parameters :	none

	Usage :			

   ============================================================*/
{
}


BEGIN_MESSAGE_MAP(CCornerBox, CWnd)
	//{{AFX_MSG_MAP(CCornerBox)
	ON_WM_ERASEBKGND()
	ON_WM_PAINT()
	ON_WM_LBUTTONUP()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CCornerBox message handlers

BOOL CCornerBox::OnEraseBkgnd( CDC* /*pDC*/ ) 
/* ============================================================
	Function :		CCornerBox::OnEraseBkgnd
	Description :	Handler for the "WM_ERASEBKGND"-message.
	Access :		Protected

	Return :		BOOL		-	Always "TRUE"
	Parameters :	CDC* pDC	-	Not interested
					
	Usage :			Called from MFC. Handled to avoid flicker 
					as we draw the complete control in "OnPaint".

   ============================================================*/
{

	return TRUE;

}

void CCornerBox::OnPaint() 
/* ============================================================
	Function :		CCornerBox::OnPaint
	Description :	Handler for the "WM_PAINT"-message.
	Access :		Protected

	Return :		void
	Parameters :	none

	Usage :			Called from MFC. Paints the control.

   ============================================================*/
{

	CPaintDC dc(this);
	
	CRect rect;
	GetClientRect( rect );
	int width = rect.Width();
	int height = rect.Height();

	CDC	memDC;
	memDC.CreateCompatibleDC( &dc );
	CBitmap	bitmap;
	bitmap.CreateCompatibleBitmap( &dc, width, height );
	CBitmap* oldbitmap = memDC.SelectObject( &bitmap );

	memDC.SelectObject( CStdGrfx::dialogPen() );
	memDC.SelectObject( CStdGrfx::dialogBrush() );
	memDC.Rectangle( rect );

	rect.InflateRect( -2, -2 );
	CStdGrfx::draw3dFrame( &memDC, rect );

	dc.BitBlt( 0, 0, width, height, &memDC, 0, 0, SRCCOPY );
	memDC.SelectObject( oldbitmap );

}

void CCornerBox::OnLButtonUp(UINT nFlags, CPoint point) 
/* ============================================================
	Function :		CCornerBox::OnLButtonUp
	Description :	Handler for the "WM_LBUTTONUP"-message.
	Access :		Protected

	Return :		void
	Parameters :	UINT nFlags		-	Not interested
					CPoint point	-	Not interested
					
	Usage :			Called from MFC. Signals to the parent.

   ============================================================*/
{

	/*CRulerMeasurementsDialog	dlg;
	dlg.m_measurements = GetMeasurements();

	if( dlg.DoModal() == IDOK )
	{
		SetMeasurements( dlg.m_measurements );
		GetParent()->SendMessage( UWM_MEASUREMENTS, GetMeasurements() );
	}
*/
	CWnd::OnLButtonUp(nFlags, point);

}

void CCornerBox::SetMeasurements( int measurements )
/* ============================================================
	Function :		CCornerBox::SetMeasurements
	Description :	Sets the current measurements
	Access :		Public

	Return :		void
	Parameters :	int measurements	-	New measurements
					
	Usage :			Call to set the measurements of this 
					control. The measurement can be one of
						"MEASURE_PIXELS" In pixels
						"MEASURE_INCHES" In inches
						"MEASURE_CENTIMETERS" In centimeters
   ============================================================*/
{

	m_measurements = measurements;

}

int CCornerBox::GetMeasurements() const
/* ============================================================
	Function :		CCornerBox::GetMeasurements
	Description :	Gets the current measurements
	Access :		Public

	Return :		int		-	Current measurement units.
	Parameters :	none

	Usage :			Call to get the measurements of this 
					control. The measurement can be one of
						"MEASURE_PIXELS" In pixels
						"MEASURE_INCHES" In inches
						"MEASURE_CENTIMETERS" In centimeters

   ============================================================*/
{

	return m_measurements;

}

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
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions