Delphi Registration Hotkey Method (i)

Source: Internet
Author: User

usesWindowsMenus;

.....
Statement
Hotkey_key:word;
Hotkey_shift:word;
procedureWmhotkey (var msg:tmessage); Message Wm_hotkey;

......


functionShiftstatetoword (shift:tshiftstate): Word;
Begin
If ssshift in Shift and result: =mod_shift else result: = 0;
If Ssctrl in Shift and Result: =result or Mod_control;
If Ssalt in Shift and then Result:=result or Mod_alt;
End


Realize
procedureTform1.wmhotkey (var msg:tmessage);
Begin
if ((Msg.lparamhi = Hotkey_key) and (Msg.lparamlo = Hotkey_shift) Then
Begin
Do someting .....
End

End

Register Hotkey
procedureTform1.hotkey1change (Sender:tobject);
var ss:tshiftstate;
Begin
Aatom: = Globaladdatom (' ea7276ec-34c1-4a11-8cb3-9940fc76539d '); Global Hotkey ID
Shortcuttokey (Hotkeyset.hotkey, Hotkey_key, SS);
Hotkey_shift: = Shiftstatetoword (SS);
RegisterHotKey (Handle, Aatom, Hotkey_shift, Hotkey_key); Registering a global Hotkey
End

Cancel a registered Hotkey
procedure Tform1.formdestroy (Sender:tobject);
Begin
Unregisterhotkey (Handle, Aatom);
Globaldeleteatom (Aatom);
End

Delphi Registration Hotkey Method (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.