Solved

TrackPopupMenu()

Posted on 2001-06-08
2
245 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
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…
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…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

617 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