Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to show shortcut menu on pressing shortcut-key (ie:right click)

Status
Not open for further replies.

wgcs

Programmer
Mar 31, 2002
2,056
EC
Microsoft used their great influence to add two keys to the standard 101 keyboard: The "Windows Key" and the "Shortcut Key" (I think that's what they're called).

The "Windows Key" (or "Start Key") is most famous for bringing up the Start menu, but using it like a shift/ctrl/alt key in combination with other keys have standard actions:
Win+E -- Windows File Explorer
Win+F -- Windows Search (probably going to be linked to WinFS in Longhorn)
Win+R -- Run dialog
Win+U -- Windows "Utility Manager" (magnifier, narrator, onscreen keyboard)
Win+D -- Show Desktop
Win+M -- Minimize all windows
( I include all these just FYI for anyone who hits this thread on a search )

The "Shortcut Key" on the other hand, only has one function that I know of: To be the ONLY Keyboard equivalent of Right-Clicking the selected object.

I want my shortcut menus to appear when this button is pressed, in addition to using the right-mouse-button. However, this key doesn't seem to fire the right-click event.

At first I was going to post a question here, but then, through some experimentation with the event-logger and DEBUGOUT's in the TreeView control's KeyPress, KeyUp and KeyDown events, I found that that key gives a "KeyCode" of 93, and "shift" reflects Shift/Alt/Ctrl as appropriate for any of those shift keys.... so it's pretty simple. But it has to be handled separately from a click-event.
 
However, if you use RELATIVE FROM MROW(),MCOL() in defining the shortcut menu's location, then it shows up related to where the mouse is (which is probably not near the item that was selected). It's probably better to use "RELATIVE FROM 1,1" which seems to be how most other applications handle this situation (rather than trying to locate the exact position of the item, and hoping (or calculating) that the menu won't fall off the bottom of the screen because the item was near the bottom...)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top