1. 编程思想?
(1)任务栏窗体的窗口信息为:?
①任务栏的窗口类名是:ShellTrayWnd。?
②开始按钮的窗口类名是:Button。?
③应用程序切换区的窗口类名是:ReBarWindow32。?
④任务栏通知区的窗口类名是:TrayNotifyWnd。?
⑤任务栏时钟的窗口类名是:TrayClockWClass。?
(2)调用FindWindow函数得到任务栏的窗口句柄。?
(3)调用FindWindowEx函数得到任务栏各子区域的窗口句柄。?
(4)根据窗口句柄,调用ShowWindow函数控制任务栏各区域显示或隐藏 (show/hide);调用En ableWindow函数控制任务栏各区域有效或无效(enabled/disabled)。?
2. 编程方法?
(1)在Delphi3.0 IDE中新建工程Project1, Project1中包含Form1, 窗体如下图所示:
(2)定义窗口句柄数组:Wnd:array[0..4] of THandle;?
(3)GetHandles过程代码如下:?
procedure TForm1.GetHandles;?
begin?
//得到Tray Bar的窗口句柄;?
Wnd[0]:=FindWindow(′ShellTrayWnd′,nil);?
//得到开始按钮的窗口句柄;?
Wnd[1]:=FindWindow(′ShellTrayWnd′,nil);?
Wnd[1]:=FindWindowEx(Wnd[1],HWND(0),′Button′,nil);?
//得到应用程序切换区的窗口句柄;?
Wnd[2]:=FindWindow(′ShellTrayWnd′,nil);?
Wnd[2]]:=FindWindowEx(Wnd[2],HWND(0),′ReBarWindow32′,nil);?
//得到任务栏通知区的窗口句柄;?
Wnd[3]:=FindWindow(′ShellTrayWnd′,nil);?
Wnd[3]:=FindWindowEx(Wnd[3],HWND(0),′TrayNotifyWnd′,nil);?
//得到任务栏时钟的窗口句柄;?
Wnd[4]:=FindWindow(′ShellTrayWnd′,nil);?
Wnd[4]:=FindWindowEx(Wnd[4],HWND(0),′TrayNotifyWnd′,nil);?
Wnd[4]:=FindWindowEx(Wnd[4],HWND(0),′TrayCLockWClass′,nil);?
end;?
(4)EnableOrDisable过程代码如下:?
procedure TForm1.EnableOrDisable(Sender:TOBject);?
begin?
GetHandles;?
if TCheckBox(Sender). Checked then?
case TCheckBox(Sender). Tag of?
0: EnableWindow(Wnd[0], False);?
1: EnableWindow(Wnd[1], False);?
2: EnableWindow(Wnd[2], False);?
3: EnableWindow(Wnd[3], False);?
4: EnableWindow(Wnd[4], False);?
end?
else?
case TCheckBox(Sender). Tag of?
0: EnableWindow(Wnd[0], True);?
1: EnableWindow(Wnd[1], True);?
2: EnableWindow(Wnd[2], True);?
3: EnableWindow(Wnd[3], True);?
4: EnableWindow(Wnd[4], True);?
end;?
end;?
(5)HideOrShow过程代码如下:?
procedure TForm1.HideOrShow(Sender:TObject);?
begin?
GetHandles;?
if TCheckBox(Sender). Checked then?
case TCheckBox(Sender). Tag of?
0: ShowWindow(Wnd[0],SWHIDE);?
1: ShowWindow(Wnd[1],SWHIDE);?
2: ShowWindow(Wnd[2],SWHIDE);?
3: ShowWindow(Wnd[3],SWHIDE);?
4: ShowWindow(Wnd[4],SWHIDE);?
end?
else?
case TCheckBox(Sender). Tag of?
0: ShowWindow(Wnd[0],SWShow);?
1: ShowWindow(Wnd[1],SWShow);?
2: ShowWindow(Wnd[2],SWShow);?
3: ShowWindow(Wnd[3],SWShow);?
4: ShowWindow(Wnd[4],SWShow);?
end;?
end;?
(6)FormClose事件代码如下://将Windows任务栏恢复到正常状态;?
procedure TForm1.FormClose(Sender:TObject; var Action: TCloseAction);?
var i:Integer;?
begin?
for i:=0 to 4 do?
begin?
EnableWindow(Wnd[i],True);?
ShowWindow(Wnd[i],SWShow);?
end;?
end;?
(7)按F9运行程序。以上程序在Delphi3.0/4.0、Windows95/98简体中文版环境下调试通过。 ?
(8)说明:本文所述方法同样适用于VB、VC、BC、C++Builder等编程工具,信捷职称论文写作发表网,但应注意语法、 变量类型等不同要求。?