托盘程序:我将程序放到托盘中去了,但如何将任务栏的隐去呢?(100分)

  • 主题发起人 主题发起人 xwm2k
  • 开始时间 开始时间
X

xwm2k

Unregistered / Unconfirmed
GUEST, unregistred user!
我将程序放到托盘中去了,但如何将任务栏的隐去呢?
 
Form1.visible:=false;
 
用托盘这方面的第三控件
 
谢谢两位的答复<br>Form1.visible:=false; &nbsp;是不行的<br>第三方控件能具体点吗?
 
你是要隐藏任务吗。
 
是的,否则托盘里一个,任务栏再一个了
 
Form1.visible:=false;可以啊?我的程序中就是这么用的
 
Shell_NotifyIcon(NIM_DELETE, @TNotifyIconData);
 
Form1.Hide;
 
Form1.Hide; &nbsp;<br>Form1.visible:=false;<br>都不能隐去状态栏的应用项 &nbsp;<br><br><br>Shell_NotifyIcon(NIM_DELETE, @TNotifyIconData); &nbsp;<br>是删掉托盘的东西,是窗口破坏时调用的<br><br>
 
SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);
 
var<br>&nbsp; WndLong: Integer;<br>&nbsp;<br>//设置程序是否出现在任务栏<br>procedure SetHidden(Hide: Boolean);<br>begin<br>&nbsp; ShowWindow(Application.Handle, SW_HIDE);<br>&nbsp; if Hide then<br>&nbsp; &nbsp; SetWindowLong(Application.Handle, GWL_EXSTYLE,<br>&nbsp; &nbsp; &nbsp; WndLong or WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW or WS_EX_TOPMOST)<br>&nbsp; else<br>&nbsp; &nbsp; SetWindowLong(Application.Handle, GWL_EXSTYLE, WndLong);<br>&nbsp; ShowWindow(Application.Handle, SW_SHOW);<br>end;
 
那就用NotifyIcon(NIM_MODIFY, @TNotifyIconData),把图标设成空不就可以了
 
这个贴发过几遍了:<br><br>uses shellapi;<br>/////////<br>const WM_MYTRAYICONCALLBACK = WM_USER + 1000 ;<br>////////<br>private<br>&nbsp; &nbsp; MyTrayIcon : TNotifyIconData ;<br>&nbsp; &nbsp; procedure WMMyTrayIconCallBack(Var Msg : TMessage);<br>&nbsp; &nbsp; message WM_MYTRAYICONCALLBACK ;//托盘消息处理过程声明<br>&nbsp; &nbsp; procedure Minimize(var mess:TWMNCHitMessage);message WM_NCHitTest;//最小化时放入托盘,并且隐藏任务栏<br>////<br>procedure TFrmMySrv.FormCreate(Sender: TObject);<br>begin<br>&nbsp; //托盘图标---放入托盘过程<br>&nbsp; Icon.Handle := LoadIcon(Hinstance,'MAINICON');<br>&nbsp; MyTrayIcon.cbSize := SizeOf(TNotifyIconData);<br>&nbsp; MyTrayIcon.Wnd := Handle ;<br>&nbsp; MyTrayIcon.uID := 1 ;<br>&nbsp; MyTrayIcon.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE ;<br>&nbsp; MyTrayIcon.uCallBackMessage := WM_MYTRAYICONCALLBACK ;<br>&nbsp; MyTrayIcon.hIcon := Icon.Handle;<br>&nbsp; StrCopy (MyTrayIcon.szTip, PChar(Caption));<br>&nbsp; Shell_NotifyIcon(NIM_ADD,@MyTrayIcon);<br>&nbsp; //下面几句是隐藏任务栏<br>&nbsp; ShowWindow(Handle,sw_Hide);<br>&nbsp; Visible := False ;<br>&nbsp; Application.ShowMainForm := False ;<br>&nbsp; SetForegroundWindow(Application.Handle);<br>end;<br>///托盘消息处理<br>procedure TFrmMySrv.WMMyTrayIconCallBack(var Msg: TMessage);<br>var CursorPos : TPoint;<br>begin<br>&nbsp; case Msg.LParam of<br>&nbsp; &nbsp; WM_LBUTTONDBLCLK : begin<br>&nbsp; &nbsp; &nbsp; Visible := not Visible ;<br>&nbsp; &nbsp; &nbsp; Application.ShowMainForm := Visible ;<br>&nbsp; &nbsp; &nbsp; SetForegroundWindow(Application.Handle);<br>&nbsp; &nbsp; end ;<br>&nbsp; &nbsp; WM_RBUTTONDOWN : begin<br>&nbsp; &nbsp; &nbsp; GetCursorPos(CursorPos);<br>&nbsp; &nbsp; &nbsp; Popupmenu1.Popup(CursorPos.X,CursorPos.Y);<br>&nbsp; &nbsp; end ;<br>&nbsp; end ;<br>end;<br><br>/////最小化隐藏任务栏<br>procedure TFrmMySrv.Minimize(var mess: TWMNCHitMessage);<br>begin<br>&nbsp; if Mess.Hittest=htReduce then<br>&nbsp; begin<br>&nbsp; &nbsp; Self.Hide;<br>&nbsp; end<br>&nbsp; else<br>&nbsp; inherited;<br>end;<br><br>
 
来迟来:(<br>wjh_wy<br>hongxing_dl<br>的方法才是正道!<br>用Form.visable:=false;或form.hide<br>就有点不专业了,呵呵
 
和cjh_xf的意见基本相同!
 
请看我的笔记:<br>http://www.delphibbs.com/keylife/iblog_show.asp?xid=4747
 
感谢这么多热心的老大,我的分都不够分了,请大家见谅
 
多人接受答案了。
 
后退
顶部