Solved

Calling TrackPopupMenu() when a another menu is active

Posted on 1997-04-07
5
283 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
[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
  • 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Nest Related files not working in Visual Studio 4 81
Application vs Workbook.applicaiton 3 45
Problem to adjust sheet 1 94
WPF issue with Trigger 2 130
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

756 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