Unit Unit1;
Interface
Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs, Shellapi, Appevnts, Stdctrls, Menus;
Const Wm_nid = wm_user + 1000;
Type
TForm1 = Class (Tform)
Popupmenu1:tpopupmenu;
N1:tmenuitem;
N2:tmenuitem;
Label1:tlabel;
Pm1:tpopupmenu;
Mnin3:tmenuitem;
Mnin4:tmenuitem;
Procedure Formdestroy (Sender:tobject);
Procedure N1click (Sender:tobject);
Procedure N2click (Sender:tobject);
Procedure Formcreate (Sender:tobject);
Procedure Formclose (Sender:tobject; var action:tcloseaction);
Procedure Mnin3click (Sender:tobject);
Procedure Mnin4click (Sender:tobject);
Private
{Private declarations}
Procedure Syscommand (var sysmsg:tmessage); Message Wm_syscommand;
Procedure Wmnid (var msg:tmessage); Message Wm_nid;
Public
{Public declarations}
End
Var
Form1:tform1;
Notifyicon:tnotifyicondata;
Implementation
{$R *.DFM}
{TForm1}
Procedure Tform1.syscommand (var sysmsg:tmessage);
Begin
Case Sysmsg.wparam of
Sc_minimize://When minimized
Begin
SetWindowPos (Application.handle, hwnd_notopmost, 0, 0, 0, 0,
Swp_hidewindow);
Hide; Hiding programs in the taskbar
Show icon in tray area
With NotifyIcon do
Begin
cbsize: = SizeOf (Tnotifyicondata);
WND: = Handle;
UID: = 1;
Uflags: = Nif_icon or nif_message or nif_tip;
Ucallbackmessage: = Wm_nid;
Hicon: = Application.Icon.Handle;
Sztip: = ' pallet procedure ';
End
Shell_NotifyIcon (Nim_add, @NotifyIcon); Show icon in tray area
End
Else
inherited;
End
End
Procedure Tform1.wmnid (var msg:tmessage);
Var
Mousepos:tpoint;
Begin
GetCursorPos (Mousepos); Get mouse position
Case Msg. LParam of
Wm_lbuttonup://After clicking left button in pallet area
Begin
Form1.visible: = Not form1.visible; Show main form or not
Shell_NotifyIcon (Nim_delete, @NotifyIcon); Icon to delete pallet area after displaying main form
SetWindowPos (Application.handle, hwnd_top, 0, 0, 0, 0, Swp_showwindow); //
displaying programs in the taskbar
End
WM_RBUTTONUP:PopupMenu1.Popup (Mousepos. X, Mousepos. Y); pop-up menu
End
End
Procedure Tform1.formdestroy (Sender:tobject);
Begin
Shell_NotifyIcon (Nim_delete, @NotifyIcon); Remove tray icon
End
Procedure Tform1.n1click (Sender:tobject);
Begin
Form1.close;
End
Procedure Tform1.n2click (Sender:tobject);
Begin
Form1.visible: = true; Show form
SetWindowPos (Application.handle, hwnd_top, 0, 0, 0, 0, Swp_showwindow);
Shell_NotifyIcon (Nim_delete, @NotifyIcon); Remove tray icon
End
Procedure Tform1.formcreate (Sender:tobject);
Begin
AnimateWindow (handle,1000,aw_center);//window from small to large
End
Procedure Tform1.formclose (Sender:tobject; var action:tcloseaction);
Begin
AnimateWindow (Handle, aw_hide or aw_blend);/The Window fades away
End
Procedure Tform1.mnin3click (Sender:tobject);
Begin
Form1.close;
End
Procedure Tform1.mnin4click (Sender:tobject);
Begin
ShellExecute (handle, ' open ', ' http://www.aheasy.cn ', nil,nil,sw_show);
End
End.