Sometimes we create the tray icon will disappear for no reason, search the next Google, found that is Explorer.exe sometimes can not remember to add the tray icon, when it can't remember, will send a message asking window: There is no need to add tray icon? Then your window will be re-made to add the tray icon action. The following is the original text:
when you ' re a programmer, it seems as you learn something new every day. One of the things I ' ve been working on with the next version of TopDesk is making it survive Explorer crashes. TopDesk has quite a few hooks to Explorer.exe, so when Explorer goes down, TopDesk goes with it. After banging my head against the wall several times I managed to fix the problem, but I noticed that even with the fix in Place the TopDesk system tray (sorry, taskbar notification area ) icon failed to re-appear when Explorer cam e back to life.
what ' s happening is this when Explorer crashes, the taskbar notification area crashes too, forgetting Any icons it had. When Explorer starts back up, it re-creates the taskbar notification area and sends out a registered window message called (strangely enough) taskbarcreated to all top-level windows. It's up-to-application to check-for-this message and re-initialize-taskbar notification area icons it have. Here's how to do it in C + +:
1. Register your application so it can receive taskbarcreated messages:
UINT wmTaskbarCreated = RegisterWindowMessage(_T("TaskbarCreated"));
2. Handle the message in your window procedure:
LRESULT CALLBACK Windowprocedure (HWND hwnd, UINT nmessage, WPARAM WPARAM, LPARAM LPARAM) {switch (nmessage) {default:{if ( Nmessage = = wmtaskbarcreated) {//Call your system tray icon initialization Function/method here}}break;} Return DefWindowProc (HWnd, Umessage, WParam, LParam);}
VC + + Interface Programming--reason why the tray icon is hidden for no reason