Solved

Calling TrackPopupMenu() when a another menu is active

Posted on 1997-04-07
5
271 Views
Last Modified: 2013-12-03
Is it somehow possible to call TrackPopupMenu(..) when
the user is rightclicking on a menu item in a "normal"
popup?  (The problem is not to detect the rightclick but
to successfully call TrackPopupMenu(..))


0
Comment
Question by:dag.garthus
  • 2
  • 2
5 Comments
 

Expert Comment

by:ebritten
ID: 1334436
I don't know if there is a way to check if you right clicked a menu item.  You can call TrackPopupMenu in a WM_COMMAND message handler in response to menu selection.
0
 

Author Comment

by:dag.garthus
ID: 1334437
>I don't know if there is a way to check if you right
>clicked a menu item. You can call TrackPopupMenu in a
>WM_COMMAND message handler in response to menu selection.

Yes i know - but is it possible to call TrackPopupMenu while
the other menu is still visible (nothing is yet selected)?

0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1334438
What would you expect TrackPopupMenu to do?  Popup another menu on top of the current one (in which case, why not just cascade), or popup the other menu in place of the first one (in which case, they aren't both open at once anyway.I think that if you look what happens in other apps when you right click, you'll see that it is possible and that the old popup is closed and a new one opened if you right click again.
0
 

Author Comment

by:dag.garthus
ID: 1334439
> What would you expect TrackPopupMenu to do? Popup
> another menu on top of the current one
... Yes

> (in which case, why not just cascade)
Because that's another menu item.

Let me try to illustrate what I'm seeking.  
Take the Win95 "Start Menu" and assume this a normal
menu with ownerdraw items - all implemented by me :\

When rightclicking on a folder in the startmenu this
would bring up a PopUp with the say "Delete Folder" and
"Create Folder" items - with the startmenu still visible.

Yes - this could be implemented by adding these items
to the sub menu that normally contains that menufolder
items but that's not what I'm looking for.

0
 
LVL 10

Accepted Solution

by:
RONSLOW earned 100 total points
ID: 1334440
TrackPopupMenu is a WIN32 API function which processes window events until a selection is made or the popup menu is dismissed (click somewhere else or ESC key etc). You can select an item with either the right or left mouse buttons. AFTER the menu disappears, a WM_COMMAND event is generated corresponding to the message (and TrackPopupMenu returns).

This means you cannot detect any interaction with the popup menu until AFTER it has disappeared. This would make the direct detection of a right click extremely difficult - let alone displaying another menu ON TOP of the popup menu.

Another thought is to detect which mouse button was used to select a menu item from the popup. However, I don't think this is possible, because all you get is the WM_COMMAND message. But you MAY be able to determine WHERE on the menu that the user clicked the mouse by examining the position member of the MSG structure for the WM_COMMAND message (if you have assess to this). You could use this information to implement some "hot" area on the menu so if the user clicks here another menu appears after the first disappears. You could then pop-up an appropriate menu etc after the original has disappeared.

Yet another thought is, rather than right-clicking on a menu item to customise it, hold down the shift key (say) when right clicking to pop-up the original menu. You program can detect this and pops up another menu which LOOKS like your usual popup. You can either associate different ID's with this other menu that ,when processed, popup your "Delete Folder" etc menu. Alternatively it could be built with cascading options for these.

Still another thought is to write your own popup menu handler - but that would require a LOT of work, 'cause you'd have to draw the menu yourself, and handle the interaction with it.Also note that the way TrackPopupMenu works, you cannot have two active at once (for one task anyway) because of the way TrackPopupMenu controls the message loop, and disappears itself when any other event occurs (other than mouse/keyboard interaction with the menu itself).

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

Suggested Solutions

Title # Comments Views Activity
Why does System.Diagnostics.Process.Start open file with errors? 8 159
dialer.exe 4 57
What are the big features of MVC5? 4 72
WPF issue with Trigger 2 91
This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
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…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

929 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

15 Experts available now in Live!

Get 1:1 Help Now