What is the best way to get tray area clock visual theme?

谁说我不能喝 提交于 2019-12-01 05:40:39

问题


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"CLOCK");

It always fails. The only way I found to get that theme, is locate the actual clock window, and to request its theme:

  • Use FindWindowEx to locate a window with Shell_TrayWnd class, then locate its child with class TrayNotifyWnd, then this window's child with TrayClockWClass class.

  • Call OpenThemeData and pass the actual clock's window handle.

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?


回答1:


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

Jim Barry 6 years ago

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".

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)



来源:https://stackoverflow.com/questions/12029043/what-is-the-best-way-to-get-tray-area-clock-visual-theme

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!