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 withShell_TrayWnd
class, then locate its child with classTrayNotifyWnd
, then this window's child withTrayClockWClass
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?
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