Entwickler-Ecke

Windows API - Hotkey To ShortCut


F34r0fTh3D4rk - Mi 08.06.05 19:32
Titel: Hotkey To ShortCut
Hallo, ich bin jetzt schon die ganze Zeit am Probieren und möchte ein word und ein uint in einen TShortCut umwandeln, andersherum geht es aber ich krieg den uint net wieder auseinander gefummelt


Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure ShortCutToHotKey(HotKey: TShortCut; var Key : Word; var Modifiers: Uint);
var
  Shift: TShiftState;
begin
  ShortCutToKey(HotKey, Key, Shift);
  Modifiers := 0;
  if (ssShift in Shift) then
    Modifiers := Modifiers or MOD_SHIFT;
  if (ssAlt in Shift) then
    Modifiers := Modifiers or MOD_ALT;
  if (ssCtrl in Shift) then
    Modifiers := Modifiers or MOD_CONTROL;
end;



Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure HotkeyToShortCut(Key: word; Modifiers: Uint; HotKey: TShortCut);
var
  Shift: TShiftState;
begin
  Shift := {???}//Wie mache ich aus dem Uint MOD_ALT etc ?
  Hotkey := ShortCut(Key, Shift);
end;


ich hab im THotkey Code folgendes gefunden:

Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
procedure TCustomHotKey.ShortCutToHotKey(Value: TShortCut);
begin
  FHotKey := Value and not (scShift + scCtrl + scAlt);
  FModifiers := [];
  if Value and scShift <> 0 then Include(FModifiers, hkShift);
  if Value and scCtrl <> 0 then Include(FModifiers, hkCtrl);
  if Value and scAlt <> 0 then Include(FModifiers, hkAlt);
end;

function TCustomHotKey.HotKeyToShortCut(Value: Longint): TShortCut;
begin
  Byte(FModifiers) := LoWord(HiByte(Value));
  FHotKey := LoWord(LoByte(Value));
  Result := FHotKey;
  if hkShift in FModifiers then Inc(Result, scShift);
  if hkCtrl in FModifiers then Inc(Result, scCtrl);
  if hkAlt in FModifiers then Inc(Result, scAlt);
end;


das bringt mich aber jetzt nicht sonderlich weiter :(