Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

TrackPopupMenu()

Posted on 2001-06-08
2
Medium Priority
?
262 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 400 total points
ID: 6168496
0
 
LVL 1

Author Comment

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

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

971 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