Board index » cppbuilder » Assign Shortcut key to Button

Assign Shortcut key to Button


2004-09-01 01:47:19 AM
cppbuilder102
Dear All,
I would like to assign shortcut key to TButton control.But i
don't want to make this with "&" character.Like "Caption" to
"&Caption" with ALT+C.Could i make this like CTRL+ALT+Key?
Thanks in Advance
Eugene
 
 

Re:Assign Shortcut key to Button

"Eugene" < XXXX@XXXXX.COM >wrote in message
Quote
I would like to assign shortcut key to TButton control.But
i don't want to make this with "&" character.Like "Caption"
to "&Caption" with ALT+C.Could i make this like
CTRL+ALT+Key?
TButton (and most controls in general) do not support what you are asking
for.
With that said, look at the RegisterHotKey() function in the Win32 API.
Then have your code catch WM_HOTKEY messages. When you receive a WM_HOTKEY
message, you can call your button's Click() method.
Alternatively, set your form's KeyPreview property to true and then use its
OnKey... events to catch the hotkey manually.
Gambit
 

Re:Assign Shortcut key to Button

Hi Remy,
I solved my problem with KeyPreview+OnKeyDown+VK_F2 combination
Thank you for your great clue.
Eugene
"Remy Lebeau \(TeamB\)" < XXXX@XXXXX.COM >wrote:
Quote

"Eugene" < XXXX@XXXXX.COM >wrote in message
news:4134b9a7$ XXXX@XXXXX.COM ...

>I would like to assign shortcut key to TButton control.But
>i don't want to make this with "&" character.Like "Caption"
>to "&Caption" with ALT+C.Could i make this like
>CTRL+ALT+Key?

TButton (and most controls in general) do not support what you are asking
for.

With that said, look at the RegisterHotKey() function in the Win32 API.
Then have your code catch WM_HOTKEY messages. When you receive a WM_HOTKEY
message, you can call your button's Click() method.

Alternatively, set your form's KeyPreview property to true and then use its
OnKey... events to catch the hotkey manually.


Gambit


 

{smallsort}