Solved

TrackPopupMenu()

Posted on 2001-06-08
2
233 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
A short film showing how OnPage and Connectwise integration works.

919 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

12 Experts available now in Live!

Get 1:1 Help Now