Delphi Tray/Hotkey "lcemeaning"

Source: Internet
Author: User

The following code I compiled under the Delphi XE2

==================================================================

UnitUnit1;Interfaceuseswinapi.windows, Winapi.messages, System.sysutils, System.variants, system.classes, Vcl.graphics, Vcl.Controls, Vcl.forms, Vcl.dialogs, Vcl.extctrls, Vcl.menus;typeTForm1=class(tform) Trayicon1:ttrayicon; //Pallet ControlPm1:tpopupmenu;//Tray MenuN1:tmenuitem;    N2:tmenuitem; procedureN2click (Sender:tobject); procedureN1click (Sender:tobject); procedureTrayicon1dblclick (Sender:tobject); procedureformcreate (Sender:tobject); procedureFormclose (Sender:tobject;varaction:tcloseaction); PrivateAatom:atom; procedureHotkeyvarMsg:tmessage);messageWm_hotkey; //defining Global Hotkey Message Events    procedureWmsyscommand (varMsg:twmsyscommand);messageWm_syscommand; //Pallet message Definition    {Private Declarations}   Public    {Public Declarations}  End;varForm1:tform1;Implementation{$R *.DFM}//Global key Execution procedureprocedureTform1.hotkey (varmsg:tmessage);begin  ifTwmhotkey (msg). Hotkey=aatom Then  beginTrayicon1dblclick (self); End;End;//Delete Global HotkeyprocedureTform1.formclose (Sender:tobject;varaction:tcloseaction);beginUnregisterhotkey (Handle,aatom); Globaldeleteatom (aatom);End;//Create global Keyproceduretform1.formcreate (sender:tobject);begin  ifFindatom ('HotKey')=0  Then   beginAatom:=globaladdatom ('HotKey'); End; RegisterHotKey (handle,aatom,mod_alt,$ +);//ALT + CEnd;procedureTform1.n1click (sender:tobject);beginform1.show;    Openicon (Form1.handle); //Activate windowEnd;procedureTform1.n2click (sender:tobject);begintrayicon1.visible:= False;//Delete tray iconapplication.terminate;End;procedureTform1.trayicon1dblclick (sender:tobject);begin  //Double-click the tray icon to show/hide the window  ifWindowState = wsminimized Then    beginform1.show;    Openicon (Form1.handle); End  Else    beginForm1.hide; WindowState:=wsminimized; End;End;//window shrinks to pallet execution codeprocedureTform1.wmsyscommand (varMsg:twmsyscommand);begin  ifMsg. Cmdtype = Sc_minimize ThenForm1.hide; inherited;End;End.

==================================================================

The code ends.

Delphi Tray/Hotkey "lcemeaning"

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.