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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime Menu Shortcut Keys

Status
Not open for further replies.

BobRaney

Programmer
Nov 22, 2001
59
US
Hello,

I am creating a Menu and Submenu using Win32API functions.
I cannot seem to get the Shortcut Keys for the MenuItem to work.

dwTypeData = "E&xit"

Works fine with the Access Key of x.

MSDN says the Shortcut Key should be specified by adding "\tCtrl+F4" to the dwTypeData string.

dwTypeData = E&xit\tCtrl+F4"

This gives me the Access Key of x, but not the Shortcut Key of Ctrl+F4.

Thanks,

Raney
 
>MSDN says the Shortcut Key should be specified by

Afraid not. MSDN says that the text to tell the user what the shortcut should be is specified this way (\t is simply shorthand for tab), but not that an actual shortcut is set up.

To create the actual shortcut you'll need to investigate CreateAcceleratorTable (or RegisterHotKey). With CreateAcceleratorTable the trick is to assign the same command identifier to the accelerator key (shortcut) as the menu item it represents. That way, apart from creating the accelerator, you don't have to do anything else (such as writing your own response to the accelerator ...)
 
Thanks,

I have found the Accelerator Functions and Structure on MSDN.

At least the Menu Text looks as I wanted.

Snow all day tomorrow, I will update when I have it working.

Raney
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top