Click here to Skip to main content
15,891,184 members
Articles / Desktop Programming / MFC

CGroupLine

Rate me:
Please Sign up or sign in to vote.
4.84/5 (29 votes)
18 Nov 2008CPOL5 min read 81.6K   3.2K   68  
CStatic enhancement that adds a trailing horizontal line, and supports WinXP themes.
#pragma once
//////////////////////////////////////////////////////////////////////////
// #include "GroupLine.h"
//////////////////////////////////////////////////////////////////////////


// *** NOTE *** read the NOTE ON LINKING (in the .cpp file)
class CGroupLine : public CStatic 
{
	DECLARE_DYNAMIC(CGroupLine)

public:
	// controls use of themes (aka visual styles)
	enum eThemeControl {
		eThemeAutomatic, // checks if themes are used for the app
		eThemeOff,       // no use of themes
		eThemeOn,        // use themes
	};
	
	// controls how the disabled state is drawn
	enum eDisabledThemeStyle {
		eGrayIfDisabled, // draws disabled state with typical disabled gray text
		eSameAsEnabled,  // draws disabled state the same as the enabled state (default for XP Themed GroupBoxes)
	};

	CGroupLine(eThemeControl useTheme = eThemeAutomatic, eDisabledThemeStyle disabledThemeStyle = eGrayIfDisabled);
	virtual ~CGroupLine();

	void SetUseTheme(eThemeControl useTheme);
	void SetDisabledThemeStyle(eDisabledThemeStyle disabledThemeStyle);

protected:
	eThemeControl m_useTheme;          // to force the theme drawing on or off
	eThemeControl m_automaticUseTheme; // is rest of the program using themes
	eDisabledThemeStyle m_disabledThemeStyle;
	
	static void DrawLine(CDC& dc, bool drawAsThemed, int height, int left, int right);
	static BOOL IsThemed();

	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnPaint();
};


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)
Canada Canada
www.IconsReview.com[^]
Huge list of stock icon collections (both free and commercial)

The picture is from September 2006, after picking up a rental car at the airport in Denver, Colorado. I'm smiling in the picture, because I have yet to come to the realization that I just wasted 400 bucks ( because you don't really need a car in downtown Denver - you can just walk everywhere).

Comments and Discussions