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.

相关文章:

  • 2021-10-01
  • 2021-10-03
  • 2022-12-23
  • 2022-12-23
  • 2022-03-05
  • 2021-12-23
  • 2021-12-23
  • 2021-11-30
猜你喜欢
  • 2021-11-30
  • 2021-12-28
  • 2021-12-23
  • 2021-07-26
  • 2021-07-27
  • 2022-12-23
  • 2022-01-02
相关资源
相似解决方案