帮帮忙,在线立等 ( 积分: 100 )

  • 主题发起人 主题发起人 令狐冲001
  • 开始时间 开始时间

令狐冲001

Unregistered / Unconfirmed
GUEST, unregistred user!
SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);<br>SetWindowLong的用法:托盘程序,如何让窗口既不在任务栏显示,又不在桌面显示。
 
SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);<br>SetWindowLong的用法:托盘程序,如何让窗口既不在任务栏显示,又不在桌面显示。
 
showwindow(form1.handle,sw_hide);
 
来自:gooodlife, 时间:2005-9-11 15:21:02, ID:3201010<br>unit Unit1;<br><br>interface<br><br>uses<br> &nbsp;Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> &nbsp;Dialogs, Menus, ShellAPI;<br> &nbsp;// 自已加入 ShellAPI<br><br>// 自定义 TrayICON 的消息 &nbsp;<br>Const<br> &nbsp;WM_BARICON=WM_USER+200;<br><br><br>type<br> &nbsp;TForm1 = class(TForm)<br> &nbsp; &nbsp;PopupMenu1: TPopupMenu;<br> &nbsp; &nbsp;N1: TMenuItem; // 退出<br> &nbsp; &nbsp;N2: TMenuItem; // 打开/隐藏<br> &nbsp; &nbsp;procedure N1Click(Sender: TObject);<br> &nbsp; &nbsp;procedure N2Click(Sender: TObject);<br> &nbsp; &nbsp;procedure FormShow(Sender: TObject);<br> &nbsp;private<br> &nbsp; &nbsp;R_lpData : PNotifyIconData; &nbsp;// 2004-06-03 用于托盘<br> &nbsp; &nbsp;procedure WMSysCommand(var Message: TMessage); message WM_SYSCOMMAND;<br> &nbsp; &nbsp;procedure WMBarIcon(var Message:TMessage); message WM_BARICON; &nbsp;<br> &nbsp; &nbsp;{ Private declarations }<br> &nbsp;public<br> &nbsp; &nbsp;{ Public declarations }<br> &nbsp;end;<br><br>var<br> &nbsp;Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.N1Click(Sender: TObject);<br>begin &nbsp;// 退出<br> &nbsp;Application.Terminate ;<br>end;<br><br>procedure TForm1.N2Click(Sender: TObject);<br>begin &nbsp;// 打开/隐藏<br> &nbsp;Form1.Visible := Not(Form1.Visible) ;<br>end;<br><br>procedure TForm1.WMBarIcon(var Message: TMessage);<br>var<br> &nbsp;pos : TPoint;<br>Begin<br> &nbsp;Case &nbsp;Message.LParam Of<br> &nbsp;WM_LBUTTONDBLCLK:<br> &nbsp;begin<br> &nbsp; &nbsp;//如果用户双击击任务栏图标则将图标删除并回复窗口。<br> &nbsp; &nbsp;Form1.Visible := True;<br> &nbsp;end;<br> &nbsp;WM_RBUTTONDOWN: &nbsp;//用户单击右键,则弹出菜单<br> &nbsp;begin<br> &nbsp; &nbsp;GetCursorPos(pos);<br> &nbsp; &nbsp;PopupMenu1.Popup(pos.x,pos.y);<br> &nbsp;end;<br> &nbsp;end; // end case &nbsp;Message.LParam of<br>end;<br><br>procedure TForm1.WMSysCommand(var Message: TMessage);<br>begin<br> &nbsp;if Message.WParam = SC_ICON then<br> &nbsp;begin<br> &nbsp; &nbsp;Form1.Visible := False;<br> &nbsp;end<br> &nbsp;else<br> &nbsp;if Message.WParam = SC_CLOSE then<br> &nbsp;begin<br> &nbsp; &nbsp;Form1.Visible := False;<br> &nbsp;end<br> &nbsp;else<br> &nbsp;begin<br> &nbsp; &nbsp;DefWindowProc(Form1.Handle, Message.Msg, Message.WParam, Message.LParam);<br> &nbsp;end;<br>end;<br><br>procedure TForm1.FormShow(Sender: TObject);<br>begin<br> &nbsp;// 开始托盘<br><br> &nbsp;Self.Icon.Handle := Application.Icon.Handle;<br><br> &nbsp;R_lpData := New(PNotifyIconDataA);<br> &nbsp;R_lpData.cbSize := SizeOf(PNotifyIconDataA) ; // 88;<br> &nbsp;R_lpData.Wnd := &nbsp;Form1.Handle;<br> &nbsp;R_lpData.hIcon := Form1.Icon.Handle ;<br> &nbsp;R_lpData.uCallbackMessage := WM_BARICON;<br> &nbsp;R_lpData.uID := 0;<br> &nbsp;R_lpData.szTip := 'QSecurity';<br> &nbsp;R_lpData.uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP;<br><br> &nbsp;Shell_NotifyIcon(NIM_ADD,R_lpData);<br><br> &nbsp;// 结束托盘<br> &nbsp;//---------------------------------------------------------<br>end;<br><br>end.
 
with Application do<br> &nbsp; &nbsp;SetWindowLong(Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW or GetWindowLong(Handle,<br> GWL_EXSTYLE)); <br> &nbsp;with MyNotifyStruct do begin<br> &nbsp; &nbsp;cbSize := sizeof(MyNotifyStruct);<br> &nbsp; &nbsp;Wnd := Handle;<br> &nbsp; &nbsp;uID := 1;<br> &nbsp; &nbsp;uFlags := &nbsp;NIF_ICON or NIF_TIP or NIF_MESSAGE;<br> &nbsp; &nbsp;uCallbackMessage := MI_ICONEVENT;<br> &nbsp; &nbsp;hIcon := Application.Icon.Handle;<br> &nbsp; &nbsp;szTip := '系统托盘程序';<br> &nbsp;end;<br> &nbsp;Shell_NotifyIcon(NIM_ADD, @MyNotifyStruct);<br> &nbsp;ShowWindow(Application.Handle,SW_HIDE);<br>// &nbsp;fmain.Visible :=false<br> &nbsp;SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);<br>我的意思是:执行后在桌面上还有一个最小化了的窗口,如何消除?
 
上面的程序最小化后在桌面上没有窗口了。
 
还有窗口
 
你新建个项目试试!!!
 
后退
顶部