[Delphi] 등록 단축키
1592 단어 Delphi
type
TForm1 = class(TForm)
HotKey1: THotKey;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
procedure WMHotKey(var Msg:TMessage);message WM_HOTKEY;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
Key, Shift: Word;
Id: Integer;
procedure ShortCutToKey(ShortCut: TShortCut; var Key: Word; var Shift: TShiftState);
begin
Key := ShortCut and not (scShift + scCtrl + scAlt);
Shift := [];
if ShortCut and scShift <> 0 then Include(Shift, ssShift);
if ShortCut and scCtrl <> 0 then Include(Shift, ssCtrl);
if ShortCut and scAlt <> 0 then Include(Shift, ssAlt);
end;
function ShiftStateToWord(TShift: TShiftState): Word;
begin
Result := 0;
if ssShift in TShift then Result := MOD_SHIFT;
if ssCtrl in TShift then Result := Result or MOD_CONTROL;
if ssAlt in TShift then Result:= Result or MOD_ALT;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
T: TShiftState;
begin
Id := GlobalAddAtom('MyHotKey') - $C000;
ShortCutToKey(HotKey1.HotKey, Key, T);
Shift := ShiftStateToWord(T);
RegisterHotKey(Handle, Id, Shift, Key);
end;
procedure TForm1.WMHotKey(var Msg: TMessage);
begin
if (Msg.LparamLo = Shift) AND (Msg.LParamHi = Key) then
ShowMessage('This is HotKey');
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
UnRegisterHotKey(Handle, Id);
GlobalDeleteAtom(Id);
end;
end.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Delphi 목마 자기 복제법 구현목마가 자기 복사를 실현하는 원리는 프로그램이 실행될 때 먼저 자신이 특정 디렉터리에 있는지 확인하고 그렇지 않으면 계속 실행하며 그렇지 않으면 특정 디렉터리에 복사한 다음에 새로운 프로그램을 실행하고 낡은 프로그램...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.