BCB and Hotkeys
Im trying to get my app to use a system wide hotkey, (ie.. sees the hotkey even when not in focus)
I have had trouble finding out how to incorporatre it into my app.
Can anyone tell me how to set and a hotkey and catch it within my app?
Im using Borland C++ Builder 6 with windows 2k.
Thanx in advance
cant be borland specific but the windows API function you are looking for is RegisterHotKey(). Look it up on MSDN or in your compilers helpfiles.There are some funny issues with hotkeys.Are you sure you need to do this.If another app has the same hotkey registered as you do then problems arise.
I'll explain a little more about my program.
It is an app with a hidden window. The program hides/unhides other windows based on their titles, (IE and xchat) Im sure you can guess why.
All I want to do is set a system wide hotkey so that whenever its pressed all windows hide/unhide.
I have found the function you mentioned whilst searching for this and I beleive I am succesfully registering the hotkey.
My problem now is I cant capture the hotkey and run code.
I have found tons of stuff on the winapi for this but i can't incorporate the catching of messages into C++ Builder as I dont know how.
My program is finished as soon as I can do this, so im getting very frustrated with it.
Can anyone please tell me how to accomplish this?
Figured it out
for anyone else that needs this heres what to do.
1. Use the RegisterHotkey function as said above to set the hotkey.
2. Add TApplicationEvents to your program
3. Inside TApplicationEvents OnMessage handler you can catch the messages sent and scrutinise the lparam hwnd etc... from there and identify the hotkey pressing.
Look up RegisterHotkey and WM_HOTKEY in the winapi for more info.
Its bloody easy once you find it.
Thanks to everyone that helped and even read the post, very much appreciated.