Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

WM_HOTKEY VK_F12 --> ERROR_HOTKEY_ALREADY_REGISTERED

66 views
Skip to first unread message

Norbert Winkler

unread,
Feb 21, 2008, 5:26:03 AM2/21/08
to
Hello,

I've a problem to add a system-hotkey on VK_12 to my application to
activate i.e. the minimized application by on keystroke.

The same code succeeds for VK_10, VK_11. It fails however not only on my
computer but at least on one other in our house.
The failure ERROR_HOTKEY_ALREADY_REGISTERED is not clear, because D7 reacts
on pressing F12 with showing a debug window.

I've tried it with the HkTest.dpr (I found it as an testprogram for
SysHot.pas --> TSysHotKey), the same result.

I'm a little bit confused..

Hier is the code for little testprogramm:

___________________
unit TestVerySimple_WM_HOTKEY_FMU;

interface

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

type
TfoSimple = class(TForm)
F11: TButton;
F12: TButton;
stb: TStatusBar;
procedure F1xClick(Sender: TObject);
private
procedure pWM_HOTKEY(var Msg: TWMHotKey); message WM_HOTKEY;
procedure HotKey(pId : Integer; pKey : Longword);
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;

var
foSimple: TfoSimple;

implementation

{$R *.dfm}

procedure TfoSimple.pWM_HOTKEY(var Msg: TWMHotKey);
begin
stb.SimpleText := Format('%d
%s',[msg.HotKey,FormatDateTime('hh:mm:ss',Now)]);
end;

procedure TfoSimple.F1xClick(Sender: TObject);
begin
if Sender = F11 then HotKey(1011,VK_F11)
else if Sender = F12 then HotKey(1012,VK_F12);
end;
procedure TfoSimple.HotKey(pId: Integer; pKey: Longword);
var
bOK : boolean;
iErr : Integer;
begin
bOK := WordBool(RegisterHotKey(Handle, pId, 0, pKey));
if bOK then stb.SimpleText := Format('%d %d active',[pId,pKey])
else begin
iErr := GetLastError;
stb.SimpleText := Format('Key %d --> Error: %d %s',
[pKey,iErr,SysErrorMessage(iErr)]);
end;
end;

end.
___________________


--
Norbert Winkler
(Win XP, D7, Oracle)

Rob Kennedy

unread,
Feb 21, 2008, 10:05:11 AM2/21/08
to
Norbert Winkler wrote:
> I've a problem to add a system-hotkey on VK_12 to my application to
> activate i.e. the minimized application by on keystroke.
>
> The same code succeeds for VK_10, VK_11. It fails however not only on my
> computer but at least on one other in our house.
> The failure ERROR_HOTKEY_ALREADY_REGISTERED is not clear, because D7 reacts
> on pressing F12 with showing a debug window.

Right. That's standard Windows behavior. F12 is reserved for the
debugger. So it sounds like that error code is completely accurate.

Incidentally, F10 is supposed to be reserved for activating the current
window's menu. Don't re-assign new meanings to that shortcut. (And
Shift+F10 is for the context menu.)

--
Rob

0 new messages