Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RegisterHotKey isn`t working 1

Status
Not open for further replies.

feen

Programmer
Sep 9, 2004
4
LV
Hi!

I want to control my app while i'm working with other programs. Tried it with RegisterHotKey function but it isn't working. And I don't know why.


const id_SnapShot=101;

procedure TForm1.WMHotKey (var Msg : TWMHotKey);
begin
if Msg.HotKey = id_SnapShot then ShowMessage('GotIt');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
RegisterHotKey(Form1.Handle,id_SnapShot,0,VK_SNAPSHOT);
end;


Maybe the problem is in procedure WMHotKey!?
 
I don't see where the problem is.

this works for me, note that I am using windows XP and delphi7 / delphi2005 :

Code:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure WMHotKey (var Msg : TWMHotKey); message WM_HOTKEY;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

 const id_SnapShot=101;

procedure TForm1.WMHotKey (var Msg : TWMHotKey);
begin
 if Msg.HotKey = id_SnapShot then ShowMessage('GotIt');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 RegisterHotKey(Form1.Handle,id_SnapShot,0,VK_SNAPSHOT);
end;


end.

--------------------------------------
What You See Is What You Get
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top