15

我正在尝试调用 OpenThemeData (请参阅 msdn OpenThemeData)函数,但我无法确定pszClassList参数传递的可接受的类名称是什么。

HTHEME OpenThemeData(      
    HWND hwnd,
    LPCWSTR pszClassList
);

谁能告诉我可以传递给该参数的可接受的类名是什么?谢谢!

4

5 回答 5

14

The article Parts and States on MSDN contains a table which shows the control classes, parts, and states. The values in the table are defined in Vsstyle.h and Vssym32.h.

Here is a quick reference:

BUTTON, CLOCK, COMBOBOX, COMMUNICATIONS, CONTROLPANEL, DATEPICKER, DRAGDROP, 
EDIT, EXPLORERBAR, FLYOUT, GLOBALS, HEADER, LISTBOX, LISTVIEW, MENU, MENUBAND, 
NAVIGATION, PAGE, PROGRESS, REBAR, SCROLLBAR, SEARCHEDITBOX, SPIN, STARTPANEL, 
STATUS, TAB, TASKBAND, TASKBAR, TASKDIALOG, TEXTSTYLE, TOOLBAR, TOOLTIP, 
TRACKBAR, TRAYNOTIFY, TREEVIEW, WINDOW

The answer to the question Windows Visual Themes: Gallery of Parts and States? provides a "Parts and States Explorer" application where you can browse and test most of the styles.

于 2011-06-30T18:55:57.623 回答
6

您可以在“AeroStyle.xml”中查看之前的海报,其中提供了 Vista/Aero 的确切列表。但是,如果您想安全起见(并且您可能会这样做),类名通常应该是 Windows 通用控件的 Windows 类名。例如,按钮和复选框使用类名“Button”,编辑控件“Edit”等。我通常选择最接近我正在处理的任何自定义元素的控件的类名,并使用主题数据。这样,您将获得适用于 XP、Vista 和(希望)Windows 7 的代码,无论用户选择的主题实际上是什么。

但是,除非您经常使用原始 Win32,否则您可能不会直接使用类名创建太多控件。类名在整个 MSDN 中相当随意地散布。一个好的起点通常是 Platform SDK 中的“CommCtrl.h”文件,其中有很多,而且它们总是在 MSDN 帮助中对各个常用控件进行描述。您还可以经常通过在文本编辑器中打开 .rc 文件来查看对话框是如何定义的:这些包含控件的类名。

于 2008-10-20T06:30:24.650 回答
6

I know this is an old question, but I want to give an updated answer (2018) for those who come here from Google.

The accepted answer of DavidK says to look into the file "AeroStyle.xml" where the themes are defined. This file was part of the Windows 7 SDK, but has been removed from the Windows 10 SDK, so the accepted answer is not useful anymore.

The answer of splash links to the MSDN where the list of theme names, parts and states is highly incompetlete and not updated.

The themes are drawn by UxTheme.dll which reads the images and colors, etc. from the file aero.msstyles in the folder C:\Windows\Resources\Themes\Aero on Windows 10.

But when you open this file in a hex editor you will not find the names of all themes. I don't know if there is a way to enumerate all existing theme class names which can be passed to OpenThemeData(). I suppose that this is not possible.

But what I know for sure is that in Windows 10 build 18282 Microsoft has removed the theme "Clock" which is not used anymore and lots of undocumented themes have been added like for example: "TaskBand2CompositedSmallIconsVertical8Light::Taskband2" which is passed as theme class name to OpenThemeData().

And I also know that several themes can only be obtained if you pass the correct window handle. If you pass the handle of the wrong window you may get another theme handle than expected or even NULL.

I also know that Microsoft in the last 2 years internally has changed all their code to use OpenThemeDataForDpi() instead of OpenThemeData() because each monitor on Windows 10 may have a different resolution.

The problem that we have here is a severe lack of documentation in the MSDN and a lack of an API function to enumerate all availabe themes.

于 2018-11-21T15:22:51.123 回答
4

类名取决于主题。例如,正如OpenThemeData的文档所述:

Aero 主题的类名在 AeroStyle.xml 中定义,该文件位于 Microsoft Windows 软件开发工具包 (SDK) 的 Include 文件夹中。

于 2008-10-20T05:25:17.433 回答
0

它与 Aero 无关,它甚至不会在 XP 上退出!请参阅 OpenThemeData() 的源代码。

于 2008-10-20T13:26:14.873 回答