Use Windows95 / NT / 98 operating system users to know: After Windows starts normally, the taskbar appears at the bottom of a computer screen. From the perspective of system functions, the entire taskbar includes several different sub-regions, from left to right are: Start button, application switching zone (Application Switch Bar), the taskbar notification area (Notification Area) and taskbar clock . Like other Windows applications, taskbar program (systray.exe) composed of several different forms, each of these forms is a window class name, display information methods. Therefore, as long as get information about the window, you can fully control a different area of the Windows taskbar by programming.
1. programming ideas
(1) information window task bar of the form to:
window class name ① taskbar is: ShellTrayWnd.
② start button window class name is: Button.
③ application window class name switching region is: ReBarWindow32.
Window class name ④ taskbar notification area are: TrayNotifyWnd.
Window class name ⑤ taskbar clock are: TrayClockWClass.
(2) calls the FindWindow function to get the window handle of the taskbar.
(3) function to get the window handle calls FindWindowEx each sub-area of the taskbar.
(4) According to the window handle, the taskbar control ShowWindow function is called the regional display or hide (show / hide); En ableWindow regional call control function valid or invalid taskbar (enabled / disabled).
2. Programming Method
(1) In the new construction Delphi3.0 IDE Project1, Project1 contains Form1, a form as shown below:
(2) defines an array of window handle: Wnd: Array [0..4] of THandle;
(. 3) GetHandles procedure code as follows:
Procedure TForm1.GetHandles;
the begin
// get the window handle Tray Bar;
Wnd [0]: = the FindWindow ( 'ShellTrayWnd', nil);
// get the window handle of the start button;
Wnd [. 1]: = the FindWindow ( 'ShellTrayWnd', nil);
Wnd [. 1]: = the FindWindowEx (Wnd [. 1], the HWND (0) , 'Button', nil); // get the application window handle handover region;
Wnd [2]: = the FindWindow ( 'ShellTrayWnd', nil);
Wnd [2]]: = the FindWindowEx (Wnd [2], the HWND (0), 'ReBarWindow32', nil);
// get the window handle of the taskbar notification area;
Wnd [. 3]: = the FindWindow ( 'ShellTrayWnd', nil);
Wnd [. 3]: = the FindWindowEx (Wnd [. 3], the HWND (0), 'TrayNotifyWnd', nil);
// get the window handle of the taskbar clock;
Wnd [. 4]: = the FindWindow ( 'ShellTrayWnd', nil);
Wnd [. 4]: = the 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 event code as follows: // Windows taskbar to restore a normal state;
Procedure TForm1.FormClose (Sender: TObject; var Action: TCloseAction) ;
var I: Integer;
the begin
for I: = 0. 4 to do
the begin
the EnableWindow (Wnd [I], True);
the ShowWindow (Wnd [I], SWShow);
End;
End;
(. 7) press F9 to run the program. In the above procedure Delphi3.0 / 4.0, the Windows95 / 98 Simplified Chinese debugging environment.
(8) Description: The methods described herein are equally applicable to VB, VC, BC, C ++ Builder and other programming tools, but it should be noted that the syntax, the different requirements of the variable type.
Delphi full control of the Windows taskbar
Guess you like
Origin www.cnblogs.com/blogpro/p/11446673.html
Ranking