CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Threaded View

  1. #1
    Join Date
    Feb 2009
    Location
    Portland, OR
    Posts
    1,488

    TrackPopupMenu and default taskbar menu

    Hi everyone:

    I'm not sure why this happens, so maybe someone can clear this up for me.

    Say, I want to display a pop-up menu from my program's tray icon on the task bar. I do the following:
    Code:
    		int nRes = TrackPopupMenu(hMenu, TPM_RIGHTALIGN | TPM_TOPALIGN |
    			TPM_LEFTBUTTON | TPM_VERPOSANIMATION | TPM_HORNEGANIMATION | TPM_RETURNCMD,
    			pnt.x, pnt.y, 0, hMainWnd, NULL);
    Because of some bug in the Explorer shell the menu isn't dismissed when someone clicks outside of it, so I had to add the following code to accommodate for that (which can be found throughout Win32 forums online):
    Code:
    		::SetForegroundWindow(hMainWnd);
    
    		int nRes = TrackPopupMenu(hMenu, TPM_RIGHTALIGN | TPM_TOPALIGN |
    			TPM_LEFTBUTTON | TPM_VERPOSANIMATION | TPM_HORNEGANIMATION | TPM_RETURNCMD,
    			pnt.x, pnt.y, 0, hMainWnd, NULL);
    
    		PostMessage(WM_NULL, 0, 0);
    That takes away that bug, but what happens is that at times when my tray icon is first displayed on the task bar's tray and I try to right-click it, I get my pop-up menu and also get the default task bar menu (picture below) displayed over it, as if I right-clicked the task bar itself. This happens only the first time I right-click my tray icon.

    Can someone tell me why this happens and how to remedy that?


    PS. I'm running these tests on a Windows 7 with a default theme (and glass effect enabled).
    Attached Images Attached Images

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured