P
paulhong
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit4;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, ExtCtrls, StdCtrls, Buttons,DateUtils, AppEvnts,ShellAPI, Menus;<br><br> const MY_MESSAGE = WM_USER + 1000;<br>type<br> TForm1 = class(TForm)<br> procedure FormCreate(Sender: TObject);<br> procedure FormDestroy(Sender: TObject);<br> private<br> { Private declarations }<br> //procedure WMNID(var msg:TMessage); message MY_MESSAGE;<br> public<br> { Public declarations }<br> end;<br>var<br> Form1:TForm1;<br> NotifyIcon:TNotifyIconData;<br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> with NotifyIcon do<br> begin<br> cbSize:=SizeOf(TNotifyIconData);<br> Wnd:=Handle; //指向当前窗体Form1的句柄<br> uID:=1;<br> uFlags:=NIF_ICON ;//or NIM_MESSAGE or NIM_TIP;<br> uCallBackMessage:=MY_MESSAGE;<br> hIcon:=Application.Icon.Handle;<br> end;<br> Shell_NotifyIcon(NIM_ADD,@NotifyIcon);<br> //SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);//在任务栏上隐藏<br><br><br>end;<br> procedure WMNID(var msg:TMessage); message MY_MESSAGE;<br> begin<br> case msg.LParam of<br> WM_LBUTTONUp: Form1.Visible:=not Form1.Visible;<br> WM_RBUTTONUP: ShowMessage('您点击的是右键');<br> End;<br>End;<br><br>它提示 unknown directive "message" 我不知道怎样该<br><br><br><br>procedure TForm1.FormDestroy(Sender: TObject);<br>begin<br> Shell_NotifyIcon(NIM_DELETE,@NotifyIcon);<br><br>end;<br><br>end.