Click here to Skip to main content
15,881,882 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 307.8K   5.5K   72  
Using the XP Theme API safely on any OS from C#
/////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2003 - Don Kackman
//
// Distribute and change freely, but please don't remove my name from the source 
//
// No warrantee of any kind, express or implied, is included with this
// software; use at your own risk, responsibility for damages (if any) to
// anyone resulting from the use of this software rests entirely with the
// user.
//
// The class CVisualStylesXp and the conept of theme browser app are borrowed from
// David Y Zhao. His example can be seen at http://www.codeproject.com/w2k/xpvisualstyle.asp
//
// questions - contact me at dkackman_2000@yahoo.com
//

#include "StdAfx.h"
#include ".\statescollection.h"
#using <mscorlib.dll>
#include < vcclr.h >
#include "Proptable.h"

using namespace System;
using namespace System::Windows::Forms::Themes;
using namespace System::Runtime::InteropServices;

StatesCollection::StatesCollection( int startIndex, String* parentPartName, IHasThemePartId* parent )
{
	m_Parent = parent;

	const wchar_t szParts[] = L"PARTS";
	const wchar_t szStates[] = L"STATES";

	wchar_t findName[35];

	wchar_t __pin* name = PtrToStringChars( parentPartName );

	wcsncpy( findName, name, min( 29, parentPartName->Length + 1 ) );
	wcscat( findName, szStates );

	m_StartIndex = -1;

	PropTable table;

	for ( int i = startIndex + 1; i < table.GetCount(); i++ )
	{
		if ( wcsstr( table[i], szParts ) )
			break;
		else if ( wcscmp( findName, table[i] ) == 0 )
		{
			m_StartIndex = i;
			break;
		}
	}
}

StatesCollection::~StatesCollection(void)
{
}

ThemePartState* StatesCollection::get_Item( int index )
{
	return new ThemePartState( GetItemTableIndex( index ), m_Parent );
}

ThemePartState* StatesCollection::get_Item( String* partName )
{
	return new ThemePartState( GetItemTableIndex( partName ), 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