VC + + Interface Programming--reason why the tray icon is hidden for no reason

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.