Exetools  

Go Back   Exetools > General > General Discussion

Notices

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 01-07-2005, 16:47
redbull redbull is offline
Friend
 
Join Date: Mar 2004
Posts: 160
Rept. Given: 17
Rept. Rcvd 5 Times in 4 Posts
Thanks Given: 3
Thanks Rcvd at 6 Times in 6 Posts
redbull Reputation: 5
There is an API function called "RegisterHotKey()" for defining a system-wide hot key. [ Dont forget it's partner UnRegisterHotkey() ]
Code:
BOOL RegisterHotKey(      
HWND hWnd,
int id,
UINT fsModifiers,
UINT vk
);
hxxp://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput
/keyboardinputreference/keyboardinputfunctions/registerhotkey.asp

It generates a WM_HOTKEY and sends it to the supplied HWND so you need to setup a message listener for WM_HOTKEY.
Quick delphi example I found
Code:
/In the main forms OnCreate
//handler assign the hotkey:
If not RegisterHotkey
(Handle, 1, MOD_ALT or MOD_SHIFT, VK_F9) Then
ShowMessage('Unable to assign Alt-Shift-F9 as hotkey.') ;
//In the main forms
//OnClose event remove the handler:
UnRegisterHotkey( Handle, 1 ) ;
//Add a handler for the
//WM_HOTKEY message to the form:
private // form declaration
Procedure WMHotkey( Var msg: TWMHotkey ) ;
message WM_HOTKEY;
Procedure TForm1.WMHotkey( Var msg: TWMHotkey ) ;
Begin
If msg.hotkey = 1 Then Begin
If IsIconic( Application.Handle ) Then
Application.Restore;
BringToFront;
End;
End;
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT +8. The time now is 23:59.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( Since 1998 )