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);//不显示在系统栏