Create keyboard short-cuts for Toolbar Control in VB6

2.1k views Asked by At

In my VB6 project, I'm using only Toolbar Control in main MDI From (Not menubar), The Toolbar has big pictures denoting actions like New, Save, View, Help etc. I wanted to know if there is any way to create keyboard short-cut for these actions. As far as I know, properties of Toolbar control of MS Windows Common Controls 6.0 isn't showing any relative option to do this. As MDI form doesn't have any key events, I can't create short-cuts by associating keys as well. I don't want menu bar in my form as it has very few items so only Toolbar makes the job. Please suggest any idea to have short-cuts for toolbar buttons...... :-| Thanks in advance.............

2

There are 2 answers

1
Alex K. On BEST ANSWER

One way is to use a local WH_KEYBOARD hook, this article explains how (and provides a library).

1
taylonr On

Add a key event to your form. You could then process the short cuts by having them call the same function that would have been called on the mouse down event for the menubar.

For example you might have something like

public sub SaveItem_Clicked()
  DoSave()
end sub 

Then in your keypress check for Alt+S etc, and have it call DoSave()