Solved

TrackPopupMenu()

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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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 tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 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