在 FormCreate首句加:
SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);
请问如何实现窗口不在任务栏上显示出来? 如QQ,启动后任务栏上并没他的图标(注意:不是托盘啊!)。 我现在想写个程序,启动窗体后不在任务栏上显示。请问如何 实现呢?用Setwindowlong函数么?知道的朋友能否说下? 我先谢谢了。 “地震无情人有情”-玉树,让我们一起面对未来吧~ ------解决方案-------------------------------------------------------- Delphi(Pascal) code procedure TForm1.FormCreate(Sender: TObject); begin SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW); end;
需要用到的一个函数:
LONG SetWindowLong(
HWND hWnd,
int nIndex,
LONG dwNewLong
);
其中nIndex GWL_EXSTYLE Retrieves the extended window styles.
dwNewLong WS_EX_TOOLWINDOW
Creates a tool window; that is, a window intended to be used as a
floating toolbar. A tool window has a title bar that is shorter than a
normal title bar, and the window title is drawn using a smaller font. A
tool window does not appear in the taskbar or in the dialog that appears
when the user presses ALT+TAB. If a tool window has a system menu, its
icon is not displayed on the title bar. However, you can display the
system menu by right-clicking or by typing ALT+SPACE.
有关dwNewLong的更多预定义值的含义,请自行查阅CreateWindowEx的帮助信息
在窗体创建事件中加入:
SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);
如果要整个程序不在任务栏显示,可以在dpr工程文件中加入以上代码,例如:(需要引用Windows单元)
begin Application.Initialize; SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW); Application.CreateForm(TForm1, Form1); Application.Run; end.
解决了: 把工程里的Application.MainFormOnTaskBar:=true ; 改为 Application.MainFormOnTaskBar:=False ; 在onshow 里加入:ShowWindow(Application.Handle, SW_HIDE); //不在任务栏显示 就搞定.
procedure TForm1.FormCreate(Sender: TObject);
begin
SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
end;
showwindow(application.handle,sw_hide); setwindowlong(application.handle,gwl_exstyle,not (getwindowlong(application.handle,gwl_exstyle,) or ws_ex_toolwindow or not ws_ex_appwindow));
ShowWindow(HTaskbar,SW_SHOW)
隐藏
ShowWindow(HTaskbar,SW_HIDE);
本文来自博客园,作者:del88,转载请注明原文链接:https://www.cnblogs.com/del88/archive/2012/06/10/2543734.html
浙公网安备 33010602011771号