OpenThemeData 函数有哪些可能的类?

2022-01-12 00:00:00 winapi themes c++ mfc msdn

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

I'm trying to call the OpenThemeData (see msdn OpenThemeData) function but I couldn't determine what are the acceptable Class names to be passed in by the pszClassList parameter.

HTHEME OpenThemeData(      
    HWND hwnd,
    LPCWSTR pszClassList
);

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

Could anybody tell me what are the acceptable class names that I can pass into that parameter? Thanks!

推荐答案

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

You can look in "AeroStyle.xml" as a previous poster noted, which gives an exact list for Vista/Aero. However, if you want to play safe (and you probably do) the class names should, in general, be Windows class names of Windows common controls. For example, push buttons and check boxes use the class name "Button", the edit control "Edit", etc. I generally pick the class name of the control that's closest to whatever custom element I'm working on is, and use the theme data for that. That way you'll get code that works with XP, Vista and (hopefully) Windows 7, regardless of what the user's selected theme actually is.

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

However, unless you use raw Win32 a lot, you probably don't do much control creation directly using the class name. The class names are rather liberally sprinkled throughout MSDN. A good place to start is usually the "CommCtrl.h" file from the Platform SDK, which has a lot of them, and they're always described in the MSDN help on the individual common controls. You can also often learn them by looking at how dialogs are defined in .rc files by opening them in a text editor: these contain the class name for the controls.

相关文章