Click here to Skip to main content
15,897,704 members
Articles / Desktop Programming / MFC

ClassLib, A C++ class library

Rate me:
Please Sign up or sign in to vote.
4.80/5 (32 votes)
25 May 2005CPOL8 min read 403K   11.5K   141  
C++ class library.
#ifndef _LRADIOBUTTON_H_
#define _LRADIOBUTTON_H_
//
// lradiobutton.h
//
// (C) Copyright 2000 Jan van den Baard.
//     All Rights Reserved.
//

#include "../windows/controls/radiobutton.h"
#include "../gdi/getdc.h"
#include "../gdi/selector.h"
#include "../strings/string.h"

// A simple radion button control for the layout engine.
class ClsLRadioButton : public ClsRadioButton
{
	_NO_COPY( ClsLRadioButton );
public:
	// Constructor.
	ClsLRadioButton() {;}

	// Destructor.
	virtual ~ClsLRadioButton() {;}

protected:
	// Compute the radiobutton it's minimum size.
	virtual BOOL OnGetMinSize( ClsSize& szMinSize )
	{
		// Setup radio button width.
		szMinSize.CX() = ::GetSystemMetrics( SM_CXMENUCHECK ) + ( 4 * ::GetSystemMetrics( SM_CXEDGE ));		
	
		// Measure caption.
		ClsGetDC	dc( this );
		ClsString	str( GetSafeHWND());

		// Any caption?
		if ( str.GetStringLength())
		{
			// Setup the font to use.
			ClsSelector sel( &dc, ( HFONT )SendMessage( WM_GETFONT ));

			// Add the size of the caption.
			szMinSize.Add( dc.GetTextExtent( str ));

			// Take the largest. Either the text height or the
			// button height.
			int nHeight = ::GetSystemMetrics( SM_CYMENUCHECK );
			if ( nHeight > szMinSize.CY())
				szMinSize.CY() = nHeight;
		}
		return TRUE;
	}
};

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


Written By
Software Developer (Senior)
Netherlands Netherlands
I have been programming for a hobby since 1985. I have started programming on the C= 64. After that I migrated to the C= Amiga which I traded in for a PC back in 1997 I believe. Back in 2000 I decided to lose a hobby and start developing software for a living.

Currently I am working mainly in developing software for building security and access control systems.

Comments and Discussions