delphi 程序不在任务栏显示
published
procedure CreateParams( var Params: TCreateParams ); override;
procedure WndProc(var Message: TMessage); override;
procedure TmainFrm.CreateParams( var Params: TCreateParams ); begin inherited CreateParams( Params ); Params.ExStyle := WS_EX_TOOLWINDOW; end; procedure TmainFrm.WndProc(var Message: TMessage); begin inherited WndProc(Message); if (not Application.MainFormOnTaskBar) and (Message.Msg = WM_SHOWWINDOW) then begin ShowWindow(Application.Handle, SW_HIDE); SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW); end; end;
上面的方法 在桌面上会显示一个小窗口
另外的方式
procedure WMSysCommand(var Message: TWMSysCommand);message WM_SYSCOMMAND; //如果是关闭或者最小化 不显示主窗口 procedure TmainFrm.WMSysCommand(var Message: TWMSysCommand); begin if (Message.CmdType = SC_MINIMIZE) or (Message.CmdType = SC_CLOSE) then Self.Visible:=False // 隐藏窗体 else Inherited; end;
//双击右下角 小图标 显示出来
Self.Visible:=true// 隐藏窗体