In Windows 9X, at the bottom of the screen is the taskbar, which users can set. If you right-click the taskbar and select properties, you can set it in the pop-up dialog box, then how to control the taskbar in the program we compiled? The method is: call the API function.
Note: Use FindWindow and SetWindowPos API functions in the following programs to control the hiding and display of the Windows taskbar in the program. The declared contents of the function are in the Windows.pas file.
First, create a new project, place a Button1 (the caption property is the hidden taskbar) and Button2 (the caption property is the display taskbar) on the default Form1, and the other properties remain unchanged, and then enter the following program code:
unit STARTBAR;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
type TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private { Private declarations }
public { Public declarations }
end;
var Form1: TForm1; RET:HWND; //Declare global variables
implementation{SR *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
Begin
RET:=FINDWINDOW(′Shell_traywnd′,′);
end;
procedure TForm1.Button1Click(Sender: TObject); //Hide taskbar
Begin
SETWINDOWPOS(RET, 0, 0, 0, 0, 0, SWP_HIDEWINDOW);
end;
procedure TForm1.Button2Click(Sender: TObject); //Show the taskbar
Begin
SETWINDOWPOS(RET, 0, 0, 0, 0, 0, SWP_SHOWWINDOW);
end;
end.
Now you can run it (press F9). When you press BUTTON1, the taskbar will be hidden. Press BUTTON2 again to display the taskbar again.
Note: The above program was debugged and passed in the Chinese version of Windows 98 and Delphi4.0 C/S.