|
Borland C ++ Builder FAQ
|
||
| The content | The last update: 12/12/2008 | |
|
How globally to intercept key press or key patterns? The author: OlegGG For an example, we intercept combination ALT + CONTROL + ENTER. At first we register hot key: bool RHKret = RegisterHotKey (Form1-> Handle, //Handle windows which to send messages WM_HOTKEY
0x00F, //the CONDITIONAL identifier of a hot key
MOD_ALT + MOD_CONTROL,//modifiers
VK_RETURN //the key code
);
if (RHKret)//if all о'кей
{
ShowMessage ("Hot Key Registred");
}
Then we allocate on Form1 TApplicationEvents and in OnMessage we write: if (Msg.message == WM_HOTKEY)//our message
{
if (Msg.wParam == 0x00F)//our identifier
{
ShowMessage ("www.sources.ru");//it is loudly shouted "уря"
}
}
When the hot key is not necessary any more, we disconnect it: UnregisterHotKey (Form1-> Handle,//Handle windows 0x00F //our identifier of a hot key );Variant #2 - хуки: http://www.xakep.ru/post/13750/default.asp |