NO

Author Topic: How do I create an accelerator table to handle keyboard input?  (Read 4383 times)

tpekar

  • Guest
Control keys like CTRL-a, ALT-a, and/or F1, F10 etc.  Does anyone have an example of what one looks like?

CommonTater

  • Guest
Re: How do I create an accelerator table to handle keyboard input?
« Reply #1 on: June 27, 2011, 11:56:48 PM »
There is a visual editor for this....

In a project click on File -> New -> Resources
This will create an untitled resource for you.
Right click the untitled item in the right pane.
Select new -> Accelerator Table
This will create a basic table for you
Double click the table item.
Now you have two choices...

Double click on an existing item to change it
Or
Right click and select new to add to the table.

When it's finished just save the file and when asked add it to the project.

This creates the table itself...
To use the table you need to load it at run time using LoadAccelerator() and pass it's handle to the TranslateAccelerator() function in your message dispatcher as I showed you in the other thread.

Inside the .rc file it will look like this...
Code: [Select]
HOTKEYS ACCELERATORS
{
  80, 1000, VIRTKEY
  VK_SPACE, 1001, VIRTKEY
  83, 1002, VIRTKEY
  VK_PRIOR, 1003, VIRTKEY
  VK_NEXT, 1004, VIRTKEY
  VK_LEFT, 1005, VIRTKEY
  VK_RIGHT, 1006, VIRTKEY
  VK_UP, 1007, VIRTKEY
  VK_DOWN, 1008, VIRTKEY
  49, 1009, VIRTKEY
  50, 1010, VIRTKEY
  51, 1011, VIRTKEY
  52, 1012, VIRTKEY
  VK_RETURN, 1013, VIRTKEY
  84, 1014, VIRTKEY
  88, 1015, VIRTKEY
}

The visual editor makes it very easy to set this up.
« Last Edit: June 28, 2011, 12:00:10 AM by CommonTater »

tpekar

  • Guest
Re: How do I create an accelerator table to handle keyboard input?
« Reply #2 on: June 28, 2011, 10:50:08 PM »
I got it working.  Thanks.

CommonTater

  • Guest
Re: How do I create an accelerator table to handle keyboard input?
« Reply #3 on: June 29, 2011, 12:38:35 AM »
No worries...