Delphi Full Control of Windows task bar

Source: Internet
Author: User

Users who use the WINDOWS95/NT/98 operating system know that after Windows starts normally, a taskbar appears under the computer screen. From a system-functional perspective, the entire taskbar includes several different subregions, from left to right: The Start button, the application switching area (application switch bar), the taskbar notification area (Notification region), and the taskbar clock. As with other Windows applications, the taskbar program (Systray.exe) consists of several different forms, which have information such as their respective window class names, display modes, and so on. As a result, you can programmatically control the different areas of the Windows taskbar as long as you get information about the windows.

1. Programming Ideas

(1) The window information for the taskbar form is:

The window class name for the ① taskbar is: Shelltraywnd.

The window class name of the ② Start button is: button.

The window class name for the ③ application switch area is: ReBarWindow32.

④ the window class name of the taskbar notification area is: Traynotifywnd.

The window class name for the ⑤ taskbar clock is: Trayclockwclass.

(2) Call the FindWindow function to get the window handle of the taskbar.

(3) Call the FindWindowEx function to get the window handle of each child area of the taskbar.

(4) According to the window handle, call the ShowWindow function to control the taskbar area to show or hide (Show/hide), and invoke the En Ablewindow function to control each area of the taskbar as valid or invalid (enabled/disabled).

2. Programming methods

(1) New Project Project1 in the Delphi3.0 IDE, Project1 contains Form1, as shown in the following figure:

(2) Define the window handle array: wnd:array[0. 4] of Thandle;

(3) The Gethandles process code is as follows:

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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.