blog

枪手亨利

博客园 首页 新随笔 联系 订阅 管理

部分代码(csdn上的):
在stdafx.h中

#ifndef WINVER
#define WINVER 0x0400
#endif

#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
#endif

#ifndef _WIN32_WINDOWS
#define  _WIN32_WINDOWS 0x0410
#endif

#ifndef _WIN32_IE
#define _WIN32_IE 0x0400
#endif

....

#include "uxtheme.h"


在运行下面代码的cpp开头加入如下定义
typedef HTHEME (__stdcall * POPENTHEMEDATA)(HWND hwnd, LPCWSTR pszClassList);
typedef HRESULT (__stdcall * PCLOSETHEMEDATA)(HTHEME hTheme);


在判断的地方加入如下代码

BOOL bXpVisualStyle=FALSE;
OSVERSIONINFO osvi;
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);

::GetVersionEx (&osvi);

if((osvi.dwPlatformId==VER_PLATFORM_WIN32_NT)&&(osvi.dwMajorVersion>=5)&&(osvi.dwMinorVersion>=1))
{
HMODULE hUxTheme=::LoadLibrary(_T("UxTheme.dll"));

POPENTHEMEDATA pOpenThemeData;
PCLOSETHEMEDATA pCloseThemeData;
if(hUxTheme!=NULL)
{
   pOpenThemeData=(POPENTHEMEDATA)::GetProcAddress(hUxTheme, "OpenThemeData");
   pCloseThemeData=(PCLOSETHEMEDATA)::GetProcAddress (hUxTheme, "CloseThemeData");
HTHEME hButtonTheme=(*pOpenThemeData)(m_hWnd,L"BUTTON");
if(hButtonTheme!=NULL)
bXpVisualStyle=TRUE;
(*pCloseThemeData)(hButtonTheme);
}

::FreeLibrary(hUxTheme);
}


if(bXpVisualStyle)
   AfxMessageBox(_T("正在使用视觉主题"));
else
   AfxMessageBox(_T("没有使用视觉主题"));










#include <uxtheme.h>
#pragma comment(lib,"uxtheme.lib")
用OpenThemeData打开GetWindowTheme函数的返回值。







GetThemeFont可以获得字体





响应WM_THEMECHANGED消息,即可在外观改变时进行处理。






Visual Styles Reference

--------------------------------------------------------------------------------

This section describes the following API elements used with visual styles.

 


Functions
CloseThemeData
Closes the theme data handle.

DrawThemeBackground
Draws the background image defined by the visual style for the specified control part.

DrawThemeBackgroundEx
Draws the background image defined by the visual style for the specified control part.

DrawThemeEdge
Draws one or more edges defined by the visual style of a rectangle.

DrawThemeIcon
Draws an image from an image list with the icon effect defined by the visual style.

DrawThemeParentBackground
Draws the part of a parent control that is covered by a partially-transparent or alpha-blended child control.

DrawThemeText
Draws text using the color and font defined by the visual style.

EnableThemeDialogTexture
Enables or disables the visual style of a dialog window's background.

EnableTheming
Enables or disables visual styles for the current user in the current and later sessions.

GetCurrentThemeName
Retrieves the name of the current visual style, and optionally retrieves the color scheme name and size name.

GetThemeAppProperties
Retrieves the property flags that control how visual styles are applied in the current application.

GetThemeBackgroundContentRect
Retrieves the size of the content area for the background defined by the visual style.

GetThemeBackgroundExtent
Calculates the size and location of the background, defined by the visual style, given the content area.

GetThemeBackgroundRegion
Computes the region for a regular or partially transparent background that is bounded by a specified rectangle.

GetThemeBool
Retrieves the value of a BOOL property from the SysMetrics section of theme data.

GetThemeColor
Retrieves the value of a color property.

GetThemeDocumentationProperty
Retrieves the value for a theme property from the documentation section of the Themes.ini file.

GetThemeEnumValue
Retrieves the value of an enumerated type property.

GetThemeFilename
Retrieves the value of a filename property.

GetThemeFont
Retrieves the value of a font property.

GetThemeInt
Retrieves the value of an int property.

GetThemeIntList
Retrieves a list of int data from a visual style.

GetThemeMargins
Retrieves the value of a MARGINS property.

GetThemeMetric
Retrieves the value of a metric property.

GetThemePartSize
Calculates the original size of the part defined by a visual style.

GetThemePosition
Retrieves the value of a position property.

GetThemePropertyOrigin
Retrieves the location of the theme property definition for a property.

GetThemeRect
Retrieves the value of a RECT property.

GetThemeString
Retrieves the value of a string property.

GetThemeSysBool
Retrieves the Boolean value of a system metric such as flat menus, fading tool tips, and so forth.

GetThemeSysColor
Retrieves the value of a system color.

GetThemeSysColorBrush
Retrieves a system color brush.

GetThemeSysFont
Retrieves the LOGFONT of a system font.

GetThemeSysInt
Retrieves the value of a system int.

GetThemeSysSize
Retrieves the value of a system size metric from theme data.

GetThemeSysString
Retrieves the value of a system string.

GetThemeTextExtent
Calculates the size and location of the specified text when rendered in the visual style font.

GetThemeTextMetrics
Retrieves information about the font specified by a visual style for a particular part.

GetWindowTheme
Retrieves a theme handle for a window that has visual styles applied.

HitTestThemeBackground
Retrieves a hit test code for a point in the background specified by a visual style.

IsAppThemed
Reports whether the current application's user interface displays using visual styles.

IsThemeActive
Tests if a visual style for the current application is active.

IsThemeBackgroundPartiallyTransparent
Retrieves whether the background specified by the visual style has transparent pieces or alpha-blended pieces.

IsThemeDialogTextureEnabled
Reports whether the dialog supports background texturing.

IsThemePartDefined
Retrieves whether a visual style has defined parameters for the specified part and state.

OpenThemeData
Opens the theme data for a window and its associated class.

SetThemeAppProperties
Sets the flags that determine how visual styles are implemented in the calling application.

SetWindowTheme
Causes a window to use a different set of visual style information than its class normally uses.

 

Visual Styles Structures
DTBGOPTS
Defines the options for the DrawThemeBackgroundEx function.

INTLIST
Contains an array or list of int data items from a visual style.

MARGINS
Defines the margins of windows that have visual styles applied.

 

Enumerated Types
PROPERTYORIGIN
Used to specify where a property was found.

THEME_SIZE
Identifies the size of the visual style part to retrieve.

TM_PROPS
Not currently supported.

 

Visual Styles Samples
Visual Styles Samples
This section lists visual styles samples.

 

Visual Styles Topics
Format Values

Hit Test Options

Hit Test Return Values

Parts and States

Property Type Definitions

Property Types

 

 

posted on 2005-12-12 11:54  henry  阅读(1788)  评论(0)    收藏  举报