gabdube / native-windows-gui

A light windows GUI toolkit for rust
https://gabdube.github.io/native-windows-gui/
MIT License
1.96k stars 127 forks source link

Auto-refresh tray icon if explorer.exe crashes using `WM_TASKBARCREATED` #272

Open DrChat opened 1 year ago

DrChat commented 1 year ago

Currently, any tray icons created by NWG will disappear if the taskbar crashes and restarts.

However, there is a magic message sent across the system when the taskbar gets recreated: WM_TASKBARCREATED You can fetch its constant using this snippet:

WM_TASKBARCREATED = RegisterWindowMessageA("TaskbarCreated") ;

It would be nice if NWG could intercept this system message and attempt to recreate any tray icons the application may have registered.

Reference: https://social.msdn.microsoft.com/Forums/vstudio/en-US/4185c030-d2dc-4597-8034-afe534848595/how-to-know-the-desktop-is-ready-?forum=vclanguage