🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Problem solved with RegisterHotKey (solution in this post)

#14427
From: Anibal
Date: Wed, 13 Aug 2003 16:08
57 lines
2624 bytes
/******************************************
This sample code respondes to a hotkey (Alt + F10)
When the user presses Alt + F10 the program gets focus
******************************************/

__fastcall TMyForm::TMyForm(TComponent* Owner)
  : TForm(Owner)
{
  windowHandle = MyForm->Handle;
  HotKeyID = 100;
  // this id is set by the programmer
  // make sure you don't set iqual id's for the same thread
  fsModifiers = MOD_ALT;
  VirtualKeyCode = VK_F10;

  if(RegisterHotKey(windowHandle, HotKeyID, fsModifiers, VirtualKeyCode) ==
true)
  {
    ShowMessage("HotKey Alt + F10 registred");
  }
  else
  {
    ShowMessage("The HotKey could not be registred!");
  }
}
//--------------------------------------------------------------------------
-
__fastcall TMyForm::~TMyForm()
{
  if(UnregisterHotKey(MyForm->Handle, 100))
  {
    ShowMessage("HotKey successfully unregistred");
  }
  else
  {
    ShowMessage("The HotKey could not be unregistred!");
  }
}
//--------------------------------------------------------------------------
-
void __fastcall TMyForm::WndProc(Messages::TMessage &Message)
{
  switch(Message.Msg)
  {
    case WM_HOTKEY:
      MyForm->TrayIcon1->Restore();
    break;

    default:
      TForm::WndProc(Message);
  }
}
//--------------------------------------------------------------------------
-

best regards.
andre|braz
Technical Details
Message-ID: <3f3a61be@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-01!sn-xit-08!supernews.com!priapus.visi.com!news-out.visi.com!petbe.visi.com!in.100proofnews.com!in.100proofnews.com!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3f37d1d2@newsgroups.borland.com> <3f37d2da$1@newsgroups.borland.com> <3f37d498@newsgroups.borland.com> <3f38d0fd@newsgroups.borland.com> <3f392e9b$1@newsgroups.borland.com> <3f3a406b@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,b8d2e09f76f4f6e3
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-08-13 09:11:48 PST
From: "Anibal" <anibal@nospam.trigenius.pt>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3f37d1d2@newsgroups.borland.com> <3f37d2da$1@newsgroups.borland.com> <3f37d498@newsgroups.borland.com> <3f38d0fd@newsgroups.borland.com> <3f392e9b$1@newsgroups.borland.com> <3f3a406b@newsgroups.borland.com>
Subject: Problem solved with RegisterHotKey (solution in this post)
Date: Wed, 13 Aug 2003 17:08:03 +0100
Lines: 59
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: 213.13.119.156
Message-ID: <3f3a61be@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1060790718 213.13.119.156 (13 Aug 2003 09:05:18 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-01!sn-xit-08!supernews.com!priapus.visi.com!news-out.visi.com!petbe.visi.com!in.100proofnews.com!in.100proofnews.com!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail