unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
procedure FormCreate(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure CheckBox2Click(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{初始化}
procedure TForm1.FormCreate(Sender: TObject);
begin
CheckBox1.Caption := '隐藏桌面图标';
CheckBox2.Caption := '隐藏任务栏';
end;
{隐藏或显示桌面图标}
procedure TForm1.CheckBox1Click(Sender: TObject);
var
h: HWND;
begin
h := FindWindow('Progman', nil); {Progman 是桌面窗口的类名}
if TCheckBox(Sender).Checked then
ShowWindow(h, SW_HIDE)
else
ShowWindow(h, SW_RESTORE);
end;
{隐藏或显示任务栏}
procedure TForm1.CheckBox2Click(Sender: TObject);
var
h: HWND;
begin
h := FindWindow('Shell_TrayWnd', nil); {Shell_TrayWnd 是任务栏窗口的类名}
if TCheckBox(Sender).Checked then
ShowWindow(h, SW_HIDE)
else
ShowWindow(h, SW_RESTORE);
end;
end.