🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #12173

Re: Register windows hotkey problem

#12173
From: Santa
Date: Thu, 25 Dec 2003 02:09
38 lines
2045 bytes
"Martin C" <martinc@aol.com> wrote:
> I am trying to register windows hotkey using the following code
>
>    RegisterHotKey(Handle, 1, MOD_ALT, VK_F1);

According to the win32.hlp file, you can set up a global hot key
or a thread-specific hot key. "...A global hot key is associated
with a particular window; it allows the user to activate the window from any part of the system....".

RegisterHotKey is thread specific. Try setting a global hotkey
by using the WM_SETHOTKEY message. "...The window specified in
WM_SETHOTKEY receives a WM_SYSCOMMAND message that specifies
the SC_HOTKEY value. This message activates the window that
receives it....". Be sure to read the remarks.

You'll also need to subclass the forms WndProd method:

//-- in the header
protected: // User declarations
    virtual void __fastcall WndProc(TMessage &Message);

//-- in the unit
void __fastcall TForm1::WndProc(TMessage &Message)
{
    if( Message.Msg == WM_SYSCOMMAND )
      {
          if( Message.wParam == SC_HOTKEY )
            {
                // You're on your own now
            }
      }
      TForm::WndProc(Message);
}

Good Luck and Happy Holidays

Santa
Technical Details
Message-ID: <3fea54ef@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news-out.visi.com!petbe.visi.com!news.linkpendium.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <3fea38e8$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,fd964279e0f05daa
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-12-24 19:16:02 PST
From: "Santa" <north@pole.com>
Sender: "Santa" <north@pole.com>
Reply-To: "Santa" <north@pole.com>
Subject: Re: Register windows hotkey problem
Newsgroups: borland.public.cppbuilder.nativeapi
X-User-Info: 172.164.99.102     
References:  <3fea38e8$1@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <3fea54ef@newsgroups.borland.com>
Date: 24 Dec 2003 19:09:35 -0700
X-Trace: newsgroups.borland.com 1072321775 207.105.83.66 (24 Dec 2003 19:09:35 -0700)
Lines: 39
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news-out.visi.com!petbe.visi.com!news.linkpendium.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail