Delphi 在任務欄隱藏程序圖標
方法一:
1、修改工程文件中的“Application.MainFormOnTaskbar := True;”為“Application.MainFormOnTaskbar := False;”
2、在主窗體的 OnShow 事件中寫下:ShowWindow(Application.Handle, SW_HIDE);
方法二:
改變窗體樣式 SetWindowLong(Self.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);
----------------------------------------------------------------------------------------
//本程序在任務欄中不顯示MSTaskListWClass
procedure TForm1.FormShow(Sender: TObject); begin ShowWindow(Application.handle,SW_HIDE); end; procedure TForm1.Button1Click(Sender: TObject); begin ShowWindow(Application.Handle, SW_HIDE);//隱藏任務欄中的圖標 SetWindowLong(Application.Handle, GWL_EXSTYLE, GetWindowLong(Application.Handle, GWL_EXSTYLE) or WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW); end; ShowWindow(FindWindow('Form2'),SW_HIDE);//隱藏窗體 ShowWindow(Form2.Handle,SW_HIDE);//隱藏窗體 ShowWindow(Self.Handle,SW_HIDE);//隱藏窗體 ShowWindow(FindWindow('Form2'),SW_NORMAL);//顯示窗體 ShowWindow(Form2.Handle,SW_NORMAL);//顯示窗體 ShowWindow(Self.Handle,SW_NORMAL);//顯示窗體 ShowWindow(Application.Handle,SW_HIDE);//隱藏任務欄中的圖標 {這一句在FormCreate 不能顯示出效果的} ShowWindow(Application.Handle,SW_NORMAL);//顯示任務欄中的圖標 setwindowpos(application.handle,hwnd_top,0,0,0,0,swp_hidewindow);//不顯示在系統欄
參考:http://www.cnblogs.com/xe2011/archive/2012/06/02/2531604.html