获得托盘区时钟视觉主题的最佳方法是什么? [英] What is the best way to get tray area clock visual theme?
问题描述
系统的托盘区域时钟视觉主题已记录 在 MSDN 中,所以我想微软希望我们能够使用它.我想用它来绘制我的任务栏带的背景,以便更好地与托盘区域融合.当我尝试
System's tray area clock visual theme is documented in MSDN, so I suppose Microsoft expects us to be able to use it. I'd like to use it to draw my taskbar band's background, in order to blend better with the tray area. When I try to
OpenThemeData(NULL, L"时钟");
OpenThemeData(NULL, L"CLOCK");
它总是失败.我发现获得该主题的唯一方法是找到实际的时钟窗口,并请求其主题:
It always fails. The only way I found to get that theme, is locate the actual clock window, and to request its theme:
使用
FindWindowEx
用Shell_TrayWnd
类定位一个窗口,然后用TrayNotifyWnd
类定位它的子窗口,然后用TrayNotifyWnd
类定位它的子窗口TrayClockWClass
类.
Use
FindWindowEx
to locate a window withShell_TrayWnd
class, then locate its child with classTrayNotifyWnd
, then this window's child withTrayClockWClass
class.
调用 OpenThemeData 并传递实际时钟的窗口句柄.
Call OpenThemeData and pass the actual clock's window handle.
显然,内部 Windows 窗口类名称没有记录.虽然上面的方法似乎有效,但我宁愿使用不那么脆弱的东西.
Obviously, internal Windows window class names are undocumented. Although the method above seems to work, I'd rather use something less fragile.
问题:有没有什么合理的方法可以获得托盘区域的时钟视觉主题?
Question: Is there any sane way to get tray area's clock visual theme?
推荐答案
显然你不能总是使用带有 NULL 的 OpenThemeData
http://microsoft.public.platformsdk.shell.narkive.com/gkVTBGA2/cannot-open-theme-data-for-tray-notification-area
Apparently you can't always use OpenThemeData with NULL
http://microsoft.public.platformsdk.shell.narkive.com/gkVTBGA2/cannot-open-theme-data-for-tray-notification-area
吉姆·巴里 6 年前
您需要有一个可以调用 SetWindowTheme 的 HWND.放pszSubAppName 为 "TrayNotifyHoriz" 或 "TrayNotifyVert" 并离开pszSubIdList 为 NULL.然后您可以调用 OpenThemeDatapszClassList 设置为TrayNotify".
You need to have an HWND that you can call SetWindowTheme for. Set pszSubAppName to "TrayNotifyHoriz" or "TrayNotifyVert" and leave pszSubIdList as NULL. You can then call OpenThemeData with pszClassList set to "TrayNotify".
我完全无法理解任何人应该如何弄清楚这些东西.坦率地说,视觉样式文档非常糟糕,绝对的耻辱.
-- Jim Barry,MVP(Windows SDK)
How anyone is supposed to figure this stuff out is totally beyond me.
The visual styles documentation is quite frankly abysmal, an absolute
disgrace.
-- Jim Barry, MVP (Windows SDK)
这篇关于获得托盘区时钟视觉主题的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!