🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: catch key combos

#12002
From: JD
Date: Sun, 04 Jan 2004 16:50
57 lines
2777 bytes
"Kevin Johnson" <kevjson@hotmail.com> wrote:
> [...] I need to catch keyboard combinations (ATL+CTRL+K)
> within the form and I don't really know how.

The WM_KEYDOWN message is posted to the window with the
keyboard focus when a nonsystem key is pressed. A nonsystem
key is a key that is pressed when the ALT key is not pressed.

Try changing the ALT to Shift. Then you could try using the
Application::OnMessage event:

private:  // User declarations
    void __fastcall AppMessage( TMsg &Msg, bool &Handled );
//-------------------------------------------------------------
__fastcall TMain::TMain(TComponent* Owner) : TForm(Owner)
{
    Application->OnMessage = AppMessage;
}
//-------------------------------------------------------------
void __fastcall TMain::AppMessage( TMsg &Msg, bool &Handled )
{
    if( Msg.message == WM_KEYDOWN || Msg.message == WM_KEYUP )
      {
      if( Msg.wParam == VK_TAB )
        {
        TForm* pForm = Screen->ActiveForm;
        TControl* pControl = Screen->ActiveControl;
        if( (GetKeyState( VK_SHIFT ) & 0x80 ) != 0x80 )
          {
          // shift not down
          }
        }
      }
}
//-------------------------------------------------------------

OR you could subclass the form's WndProc method (untested):

protected: // User declarations
    virtual void __fastcall WndProc(TMessage &Message);

//-------------------------------------------
void __fastcall TForm1::WndProc(TMessage &Message)
{
    if( Message.Msg == WM_KEYDOWN || Message.Msg == WM_KEYUP )
      {
          // Message.wParam Specifies the virtual-key code of
          // the nonsystem key.
          // Message.lParam Specifies the repeat count, scan
          // code, extended-key flag, context code, previous
          // key-state flag, and transition-state flag.
      }
    TForm::WndProc(Message);
}

~ JD
Technical Details
Message-ID: <3ff85269$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3ff834e3@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,366b8026c8e3e676
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-01-04 10:09:41 PST
From: "JD" <nospam@nospam.com>
Sender: "JD" <nospam@nospam.com>
Reply-To: "JD" <nospam@nospam.com>
Subject: Re: catch key combos
Newsgroups: borland.public.cppbuilder.nativeapi
X-User-Info: 172.138.43.198     
References:  <3ff834e3@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <3ff85269$1@newsgroups.borland.com>
Date: 4 Jan 2004 09:50:33 -0700
X-Trace: newsgroups.borland.com 1073238633 207.105.83.66 (4 Jan 2004 09:50:33 -0700)
Lines: 58
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail