RE: creating shortcut
Mike Smit <[email protected]>
| Newsgroups | gmane.comp.lang.delphi.programming |
|---|---|
| Message-ID | <[email protected]> |
You must register the key combination as system global hotkeys as follows... // This is needed to get a unique ID that is registered on your system as an atom. Const HK_CTRL_F1 = 'Ctrl+F1'; // This var must be global as you need to save the value stored in it Var iHotKeyID: ATOM; // Get an ID for your hotkey combo iHotKey := GlobalAddAtom(PChar(HK_CTRL_F1)); // Now register your hotkey RegisterHotKey(Self.Handle, iHotKeyID, MOD_CONTROL, VK_F1); That is it, your hotkey is registered, now you need a message handler to catch the key presses and then do whatever you need to do :) Remember when your app closes to unregister the hotkey by calling: UnregisterHotKey(Self.Handle, iHotKeyID); And also to call GlobalDeleteAtom(iHotKeyID); to delete the atom you created above Please note that the above is out of my head so may need some tweaking. There are also no error checks so you must do that. IE: If Ctrl+F1 is already registered by another application on the system as a hotkey then RegisterHotKey returns false, also if there is also an atom on the system for the 'Ctrl+F1' string then the return value is zero. You must check for these things in your app. Read the WinAPI help on these functions to determine how to properly use them. HTH Mike -----Original Message----- From: digitalchandra [mailto:[email protected]] Sent: 23 July 2003 12:19 AM To: [email protected] Subject: [Delphi] creating shortcut Hi All. Currently I'm creating an application that will be resident in system with the icon is shown in system tray. But I have a problem . How to create a shortcut key, for example when we hit CTRL+F1 on keyboard, my application will be come up. TIA. CodeCoffer - new Delphi code protection Tool! http://www.delphicollection.com/public/CodeCoffer.htm --------------------------------------------------------------- Unsubscribe:[email protected] List owner:[email protected] --------------------------------------------------------------- Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ ------------------------ Yahoo! Groups Sponsor ---------------------~--> Free shipping on all inkjet cartridge & refill kit orders to US & Canada. Low prices up to 80% off. We have your brand: HP, Epson, Lexmark & more. http://www.c1tracking.com/l.asp?cid=5510 http://us.click.yahoo.com/GHXcIA/n.WGAA/ySSFAA/i7folB/TM ---------------------------------------------------------------------~-> CodeCoffer - new Delphi code protection Tool! http://www.delphicollection.com/public/CodeCoffer.htm --------------------------------------------------------------- Unsubscribe:[email protected] List owner:[email protected] --------------------------------------------------------------- Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/