🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: System wide shortcut

#15047
From: Remy Lebeau (TeamB)
Date: Tue, 22 Jul 2003 23:57
65 lines
2683 bytes
"micheal davis" <micheal_davis@hotmail.com> wrote in message
news:3f1dc0e4@newsgroups.borland.com...

> HWND dwnd;

You do not need to use a separate HWND, especially one that you are not
actually assigning to anything.  Just use the form's own HWND itself, which
is accessible via the form's Handle property.

>   if(RegisterHotKey(dwnd,1, MOD_CONTROL && MOD_ALT, VK_F6)==true)

Use Handle instead of dwnd.  Also, you need to use the '|' operator rather
than '&&':

    if( RegisterHotKey(Handle, 1, MOD_CONTROL | MOD_ALT, VK_F6) )

>   UnregisterHotKey(dwnd,1);

Here too, use Handle instead:

    UnregisterHotKey(Handle, 1);

> //here comes my problem I don't know how and where shall I put the
WM_HOTKEY

Declare a MESSAGE_MAP for it, or override the inherited WndProc() method:

1)
    class TForm1 : public TForm
    {
    private:
        void __fastcall WMHotKey(TMessage &Message);
    public:
        BEGIN_MESSAGE_MAP
            VCL_MESSAGE_HANDLER(WM_HOTKEY, TMessage, WMHotKey)
        END_MESSAGE_MAP(TForm)
    };

    void __fastcall TForm1::WMHotKey(TMessage &Message)
    {
        if( Message.WParam == 1 )
            // do something
        else
            TForm::Dispatch(&Message);
    }


2)
    class TForm1 : public TForm
    {
    protected:
        void __fastcall WndProc(TMessage &Message);
    };

    void __fastcall TForm1::WndProc(TMessage &Message)
    {
        if( (Message.Msg == WM_HOTKEY) && (Message.WParam == 1) )
            // do something
        else
            TForm::WndProc(Message);
    }


Gambit
Technical Details
Message-ID: <3f1dce10$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!pln-w!extra.newsguy.com!lotsanews.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3f1d3cf2@newsgroups.borland.com> <3f1d62de@newsgroups.borland.com> <3f1dc0e4@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,b82a70152a2e1a91
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-07-22 17:10:17 PST
From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3f1d3cf2@newsgroups.borland.com> <3f1d62de@newsgroups.borland.com> <3f1dc0e4@newsgroups.borland.com>
Subject: Re: System wide shortcut
Date: Tue, 22 Jul 2003 16:57:17 -0700
Lines: 67
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 207.175.226.26
Message-ID: <3f1dce10$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1058917904 207.175.226.26 (22 Jul 2003 16:51:44 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!pln-w!extra.newsguy.com!lotsanews.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail