Popup im System-Tray blendet nicht mehr aus



  • Hallo Zusammen,
    ich habe zu einer Anwendung ein Icon im System-Tray mit einem Popup-Menu hinzugefügt.
    Jetzt habe ich das Problem, dass sich das Popup-Menu nach dem Klicken auf das Icon nicht mehr von selbst ausblendet.
    Woran kann das liegen.

    HMENU hMenu = CreatePopupMenu();
    
    InsertMenu( hMenu, 
         ...
    
    GetCursorPos(&pt); 
    TrackPopupMenu(hMenu, NULL, pt.x, pt.y, 0, hwnd, NULL); 
    
    PostMessage(hwnd, WM_NULL, 0, 0);
    


  • msdn schrieb:

    To display a context menu for a notification icon, the current window must be the foreground window before the application calls TrackPopupMenu or TrackPopupMenuEx. Otherwise, the menu will not disappear when the user clicks outside of the menu or the window that created the menu (if it is visible). However, when the current window is the foreground window, the second time this menu is displayed, it displays and then immediately disappears. To correct this, you must force a task switch to the application that called TrackPopupMenu. This is done by posting a benign message to the window or thread, as shown in the following code sample[..]

    http://msdn2.microsoft.com/en-us/library/ms648002.aspx



  • Vorher SetForegroundwindow mit dem Fensterhandle aufrufen.


Anmelden zum Antworten