怎样隐藏和显示桌面的任务栏? ( 积分: 20 )

  • 主题发起人 主题发起人 刘邦
  • 开始时间 开始时间

刘邦

Unregistered / Unconfirmed
GUEST, unregistred user!
我有一个程序需要隐藏和显示桌面的任务栏,怎样写代码
 
我有一个程序需要隐藏和显示桌面的任务栏,怎样写代码
 
加到100分吧
 
试试以下代码:<br>.<br> <br>Procedure TForm1.Button1Click(Sender: TObject);<br>// 开始隐藏任务栏<br>Var<br> &nbsp;hWnd : Integer;<br>begin<br> &nbsp;hWnd := FindWindow('Shell_TrayWnd', '');<br> &nbsp;If hWnd &lt;&gt; 0 then<br> &nbsp; &nbsp;ShowWindow(hWnd, SW_HIDE);<br>end;<br><br>Procedure TForm1.Button2Click(Sender: TObject);<br>// 恢复显示任务栏<br>Var<br> &nbsp;hWnd : Integer;<br>begin<br> &nbsp;hWnd := FindWindow('Shell_TrayWnd', '');<br> &nbsp;If hWnd &lt;&gt; 0 then<br> &nbsp; &nbsp;ShowWindow(hWnd, SW_SHOW);<br>end;<br><br>分析其原理,无非任务栏也是一个窗口,只不过这个的类型是非 Shell_TrayWnd 而已。<br>对其它程序进行操作也能达到类似的效果。
 
上面的不能隐藏开始菜单,按win键还是会弹出开始菜单。还要加个钩子,屏蔽左右win键!
 
procedure HideTaskBar(bHide:boolean=False);<br>var<br> &nbsp;TaskBarHWN:integer;<br>begin<br> &nbsp;TaskBarHWN:=Findwindow('Shell_TrayWnd',nil);<br> &nbsp;if not bhide then<br> &nbsp; &nbsp;SetWindowPos(TaskBarHWN,0,0,0,0,0,SWP_HIDEWINDOW)<br> &nbsp;else<br> &nbsp;SetWindowPos(TaskBarHWN,0,0,0,0,0,SWP_SHOWWINDOW)<br>end;
 
unit Unit1;<br><br>interface<br><br>uses<br> &nbsp;Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> &nbsp;Dialogs, StdCtrls;<br><br>type<br> &nbsp;TForm1 = class(TForm)<br> &nbsp; &nbsp;Button1: TButton;<br> &nbsp; &nbsp;procedure Button1Click(Sender: TObject);<br> &nbsp;private<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.Button1Click(Sender: TObject);<br>var<br> &nbsp; &nbsp;hWnd:integer;<br> &nbsp; &nbsp;TaskBarHWN:integer;<br>begin<br> &nbsp; &nbsp;hWnd:=FindWindow('Shell_TrayWnd','');<br> &nbsp; &nbsp;TaskBarHWN:=Findwindow('Shell_TrayWnd',nil);<br> &nbsp; &nbsp;if hWnd&lt;&gt;0 then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; if not showwindow(hwnd,sw_hide) then<br> &nbsp; &nbsp; &nbsp; begin<br> &nbsp; &nbsp; &nbsp; ShowWindow(hWnd,SW_show);<br> &nbsp; &nbsp; &nbsp; end;<br> &nbsp; &nbsp;end;<br> &nbsp; &nbsp;if not SetWindowPos(TaskBarHWN,0,0,0,0,0,SWP_HIDEWINDOW) &nbsp;then<br> &nbsp; &nbsp; SetWindowPos(TaskBarHWN,0,0,0,0,0,SWP_SHOWWINDOW);<br>end;<br>end.<br>//D6测试通过
 
楼主是不是江苏徐州的?怎么叫刘邦这个名字,我是徐州的;
 
后退
顶部