Click here to Skip to main content
15,891,513 members
Articles / Programming Languages / C#

A Managed C++ Wrapper Around the Windows XP Theme API

Rate me:
Please Sign up or sign in to vote.
4.97/5 (31 votes)
27 Aug 2003CPOL5 min read 308.4K   5.5K   72  
Using the XP Theme API safely on any OS from C#
#pragma once

#include "ThemeItem.h"
#include "IHasThemePartId.h"
#include "IRenderableItem.h"

using namespace System::Drawing;

namespace System
{ namespace Windows
{ namespace Forms 
{ namespace Themes
{
	//
	// A ThemePArtState is a discrete state that a part of window class can be in
	// and that may render differently than the default state
	//
	// Examples are normal, hot, disabled.
	__gc public __sealed class ThemePartState : public ThemeItem, public IRenderableItem
	{
	public private:
		ThemePartState( int propTableIndex, IHasThemePartId* parent );

	public:
		__property int get_StateId(){ return m_ID; }

		__property bool get_IsDefined();
		void DrawBackground( Graphics* graphics, System::Drawing::Rectangle Rect, System::Drawing::Rectangle ClipRect );
		void DrawBackground( Graphics* graphics, System::Drawing::Rectangle Rect );

		void DrawText( Graphics* graphics, String* Text, Int32 CharCount, DrawTextFlags TextFlags, bool Grayed, System::Drawing::Rectangle Rect );
		void DrawText( Graphics* graphics, String* Text, DrawTextFlags TextFlags, bool Grayed, System::Drawing::Rectangle Rect );

		System::Drawing::Size GetSize( Graphics* graphics, ThemeSize eSize );

		__property System::Drawing::Color get_TextColor();

	private:
		~ThemePartState(void);

		int m_ID;		// part and state id's are the 1 based index of the row that defines the state
						// i.e. for the record GROUPBOXSTATES, the record immediately following has an id of 1

		IHasThemePartId* m_Parent;
	};
}
}
}
}

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
Team Leader Starkey Laboratories
United States United States
The first computer program I ever wrote was in BASIC on a TRS-80 Model I and it looked something like:
10 PRINT "Don is cool"
20 GOTO 10

It only went downhill from there.

Hey look, I've got a blog

Comments and Discussions