谁有标准的托盘程序?(100分)

  • 主题发起人 主题发起人 13708782004
  • 开始时间 开始时间
1

13708782004

Unregistered / Unconfirmed
GUEST, unregistred user!
1 退出图标要彻底清除!<br>2 点关闭要最小化!
 
unit MianForm;<br><br>interface<br><br>uses<br> &nbsp;Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> &nbsp;Dialogs, StdCtrls, DB, ADODB, ExtCtrls,shellapi, Menus,thread;<br><br>const CM_RestoreMessage=WM_USER+1;<br>const iid=100;<br>type<br> &nbsp;TForm5 = class(TForm)<br> &nbsp; &nbsp;btnStart: TButton;<br> &nbsp; &nbsp;ListBox2: TListBox;<br> &nbsp; &nbsp;btnExit: TButton;<br> &nbsp; &nbsp;ADOConnection1: TADOConnection;<br> &nbsp; &nbsp;ADOQuery1: TADOQuery;<br> &nbsp; &nbsp;Image1: TImage;<br> &nbsp; &nbsp;PopupMenu1: TPopupMenu;<br> &nbsp; &nbsp;ListBox1: TListBox;<br> &nbsp; &nbsp;Close1: TMenuItem;<br> &nbsp; &nbsp;Show1: TMenuItem;<br> &nbsp; &nbsp;Label1: TLabel;<br> &nbsp; &nbsp;Label2: TLabel;<br> &nbsp; &nbsp;Label3: TLabel;<br> &nbsp; &nbsp;Bevel1: TBevel;<br> &nbsp; &nbsp;Label4: TLabel;<br> &nbsp; &nbsp;Timer1: TTimer;<br> &nbsp; &nbsp;Label5: TLabel;<br> &nbsp; &nbsp;procedure FormCreate(Sender: TObject);<br> &nbsp; &nbsp;procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);<br> &nbsp; &nbsp;procedure FormClose(Sender: TObject; var Action: TCloseAction);<br> &nbsp; &nbsp;procedure btnExitClick(Sender: TObject);<br> &nbsp; &nbsp;procedure Show1Click(Sender: TObject);<br> &nbsp; &nbsp;procedure btnStartClick(Sender: TObject);<br> &nbsp; &nbsp;Procedure ondone(Sender:Tobject);<br> &nbsp; &nbsp;procedure FormShow(Sender: TObject);<br> &nbsp;private<br> &nbsp; &nbsp;procedure StoreMessage(var msg:Tmessage);message CM_RestoreMessage;<br> &nbsp; &nbsp;procedure MinMessage(var msg:TWMSysCommand);message WM_SysCommand ;<br> &nbsp; &nbsp;{ Private declarations }<br> &nbsp;public<br> &nbsp; &nbsp;{ Public declarations }<br> &nbsp;end;<br><br>var<br> &nbsp;Form5: TForm5;<br> &nbsp;NotifyIconData:TNotifyIconData;<br> &nbsp;T:TReindex;<br>implementation<br><br>{$R *.dfm}<br><br><br><br>procedure TForm5.Show1Click(Sender: TObject);<br>begin<br> &nbsp;if isiconic(application.Handle) then<br> &nbsp; &nbsp;application.Restore<br> &nbsp;else<br> &nbsp; &nbsp;//application.BringToFront;<br> &nbsp; &nbsp;ShowWindow(Application.Handle,sw_normal);<br> &nbsp; &nbsp;ShowWindow(Application.MainFormHandle,sw_normal);<br> &nbsp; &nbsp;SetForegroundWindow(Application.MainFormHandle);<br>end;<br><br>procedure TForm5.MinMessage(var msg: TWMSysCommand);<br>begin<br> &nbsp;inherited;<br> &nbsp;if msg.CmdType=SC_Minimize then<br> &nbsp;begin<br> &nbsp; &nbsp;ShowWindow(Application.Handle,sw_hide);<br> &nbsp;end;<br><br>end;<br><br>procedure TForm5.StoreMessage(var msg: TMessage);<br>var<br> &nbsp;p:TPoint;<br>begin<br> &nbsp;inherited;<br> &nbsp;if msg.LParam=WM_rButtonUp then<br> &nbsp;begin<br> &nbsp; &nbsp;GetCursorPos(p);<br> &nbsp; &nbsp;popupmenu1.Popup(p.X,p.Y);<br> &nbsp;end<br> &nbsp;else<br> &nbsp;begin<br> &nbsp; &nbsp;if msg.LParam=WM_LButtonDBLClk then show1.Click;<br> &nbsp;end;<br> &nbsp;msg.Result:=0;<br> &nbsp;<br>end;<br><br><br><br>procedure TForm5.FormClose(Sender: TObject; var Action: TCloseAction);<br>begin<br> &nbsp;Action:=caFree;<br> &nbsp;NotifyIconData.cbSize:=sizeof(TNotifyIconData);<br> &nbsp;NotifyIconData.Wnd:=handle;<br> &nbsp;NotifyIconData.uFlags:=nif_icon+nif_tip+nif_message;;<br> &nbsp;NotifyIconData.hIcon:=Image1.Picture.Icon.Handle;<br> &nbsp;NotifyIconData.uCallbackMessage:=CM_RestoreMessage;<br> &nbsp;NotifyIconData.szTip:='PALDBBK tables reindex';<br> &nbsp;NotifyIconData.uID:=iid;<br> &nbsp;Shell_NotifyIcon(NIM_Delete,@NotifyIconData);<br><br>end;<br><br><br>procedure TForm5.FormCreate(Sender: TObject);<br>begin<br> &nbsp;NotifyIconData.cbSize:=sizeof(TNotifyIconData);<br> &nbsp;NotifyIconData.Wnd:=handle;<br> &nbsp;NotifyIconData.uFlags:=nif_icon+nif_tip+nif_message;;<br> &nbsp;NotifyIconData.hIcon:=Image1.Picture.Icon.Handle;<br> &nbsp;NotifyIconData.uCallbackMessage:=CM_RestoreMessage;<br> &nbsp;NotifyIconData.uID:=iid;<br> &nbsp;Shell_NotifyIcon(NIM_Add,@NotifyIconData);<br>end;<br><br><br><br>end.<br>参考一下,希望对你有帮助!
 
后退
顶部