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