Solved

TrackPopupMenu()

Posted on 2001-06-08
2
232 Views
Last Modified: 2013-12-03
Hi,

I have used the TrackPopupMenu API call to show a popupmenu when someone right-clicks an icon I have placed in the taskbar. The code to show the popupmenu goes like this:

UINT CPopupMenu::Track(HWND hWnd, int x, int y) {

     UINT nID = TrackPopupMenu(
          m_hPopup,
          (TPM_CENTERALIGN | TPM_BOTTOMALIGN | TPM_NONOTIFY | TPM_RETURNCMD ),
          x, y, 0, *g_pMainWindow, NULL
     );

     if (nID==ID_POPUP_AUTOACCEPT) {
          MENUITEMINFO mii = { sizeof(MENUITEMINFO) };
          mii.fMask =     MIIM_STATE;
          GetMenuItemInfo(m_hPopup, nID, FALSE, &mii);


          if (mii.fState & MFS_CHECKED) {
               mii.fState &= ~MFS_CHECKED;
               mii.fState |= MFS_UNCHECKED;
               m_autoaccept = FALSE;
          }

          else {
               mii.fState &= ~MFS_UNCHECKED;
               mii.fState |= MFS_CHECKED;
               m_autoaccept = TRUE;
          }

          SetMenuItemInfo(m_hPopup, nID, FALSE, &mii);
     }
     return nID;
}


So the function CPopupMenu::Track will show the popupmenu, and take care of tick marks and suchs. My only problem is this:

Using this method, makes the popupmenu stay on the screen, and disappear partly behind the taskbar when clicking on the taskbar. The popupmenu will not go away until I have chosen an item on the menu. This behaviour is different than other programs in the taskbar, where the popupmenu disappears when clicking outside it.

How can I achieve this?
0
Comment
Question by:lar_jens
2 Comments
 
LVL 32

Accepted Solution

by:
jhance earned 100 total points
ID: 6168496
0
 
LVL 1

Author Comment

by:lar_jens
ID: 6168939
Just what I wanted.. =))
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video discusses moving either the default database or any database to a new volume.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now