BCB and Hotkeys

This is a discussion on BCB and Hotkeys within the C++ Programming forums, part of the General Programming Boards category; Im trying to get my app to use a system wide hotkey, (ie.. sees the hotkey even when not in ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    14

    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

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    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.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    14

    Thanx

    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?

    thanx

  4. #4
    Registered User
    Join Date
    Nov 2001
    Posts
    14

    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.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21