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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with HotKey 2

Status
Not open for further replies.

mischmasch

Programmer
May 10, 2011
11
Hello,

In my App I have some HotKey that is registred, unregistred like below:

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

....
....

procedure TufMain.WMHotKey(var Msg: TWMHotKey);
begin
if (msg.HotKey = ExecuteHotKey) then
... something to do
end;

procedure TufMain.FormCreate(Sender: TObject);
begin
ExecuteHotKey := GlobalAddAtom('ExecuteHotKey');
RegisterHotKey(Handle, ExecuteHotKey, 0, VK_F2);
end;

procedure TufMain.FormDestroy(Sender: TObject);
begin
UnRegisterHotKey(Handle, ExecuteHotKey);
GlobalDeleteAtom(ExecuteHotKey);
end;

In mp App everything works OK, but I've noticed that when I use other application where F2 can be used, I cannot use it, e.g. Excel - I want to edit cell by pressing F2, but it does not work.
I must close my App and then F2 in Excel works normally.
With other HotKey that are the same in my App and other applications (e.g. ESC), is the same.
It seems that my App blocks HotKey in other applications ...
Does anyone know how to solve it?
Thank you in advance.

 
I just tested it and imex's answer will work. Stars for both, imex for a good answer, the op because I was about to look into how to do a global hotkey from my app.

It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top