Thema: Delphi HotKey Experimente...

Einzelnen Beitrag anzeigen

Benutzerbild von glkgereon
glkgereon

Registriert seit: 16. Mär 2004
2.287 Beiträge
 
#1

HotKey Experimente...

  Alt 15. Okt 2005, 20:40
Hi

ich spiele im Moment etwas mit Hotkeys rum...

ich möchte drei Systemweite Hotkeys anlegen und auf diese Reagieren.

folgender Code basiert auf einem Code aus dem DF.
Die Hotkeys werden in einer Ini gespeichert
Um die HotKeys zu setzen nutze ich THotKey
Delphi-Quellcode:
procedure WMHotKey(var Msg: TWMHotKey); message WM_HOTKEY;

[.....]

procedure TForm1.WMHotKey(var Msg: TWMHotKey);
begin
  if Msg.HotKey=HKA_Reset then MI_ClpResetClick(Self)
  else if Msg.HotKey=HKA_Code then MI_ClpCodeClick(Self)
  else if Msg.HotKey=HKA_Decode then MI_ClpDecodeClick(Self);
end;

procedure TForm1.CreateHotKeys;
begin
  HKA_Reset:=GlobalAddAtom('ResetClp');
  HKA_Code:=GlobalAddAtom('CodeClp');
  HKA_Decode:=GlobalAddAtom('DecodeClp');
  RegisterHotKey(0,HKA_Reset,0,HKVK_Reset);
  RegisterHotKey(0,HKA_Code,0,HKVK_Code);
  RegisterHotKey(0,HKA_DeCode,0,HKVK_DeCode);
end;

procedure TForm1.DestroyHotKeys;
begin
  UnRegisterHotKey(0,HKA_Reset);
  GlobalDeleteAtom(HKA_Reset);
  UnRegisterHotKey(0,HKA_Code);
  GlobalDeleteAtom(HKA_Code);
  UnRegisterHotKey(0,HKA_DeCode);
  GlobalDeleteAtom(HKA_DeCode);
end;

procedure TForm1.LoadFromIni;
begin
  HKVK_Reset:=Ini.ReadInteger('HotKeys','ResetVK',0);
  HKVK_Code:=Ini.ReadInteger('HotKeys','CodeVK',0);
  HKVK_Decode:=Ini.ReadInteger('HotKeys','DecodeVK',0);
  EdtHK_Reset.HotKey:=HKVK_Reset;
  EdtHK_Code.HotKey:=HKVK_Code;
  EdtHK_Decode.HotKey:=HKVK_Decode;
end;

procedure TForm1.SaveToIni;
begin
  Ini.WriteInteger('HotKeys','ResetVK',HKVK_Reset);
  Ini.WriteInteger('HotKeys','CodeVK',HKVK_Code);
  Ini.WriteInteger('HotKeys','DecodeVK',HKVK_Decode);
  Ini.WriteInteger('HotKeys','DecodeVK',HKVK_Decode);
end;
Die Werte kommen auch ordnungsgemäß in der Ini-Datei an und werden wieder geladen, aber es passiert nichts
ist da irgendein grober Fehler drin?
»Unlösbare Probleme sind in der Regel schwierig...«
  Mit Zitat antworten Zitat