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

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 324
  • Last Modified:

Calling TrackPopupMenu() when a another menu is active

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
dag.garthus
Asked:
dag.garthus
  • 2
  • 2
1 Solution
 
ebrittenCommented:
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
 
dag.garthusAuthor Commented:
>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
 
RONSLOWCommented:
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
 
dag.garthusAuthor Commented:
> 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
 
RONSLOWCommented:
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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now