隐藏Windows的工具栏和桌面图标

2019/7/21 23:36:28 人评论 次浏览 分类:学习教程

原文链接:http://www.cnblogs.com/tecsoon/archive/2009/03/27/1423735.html

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TfrmMain = class(TForm)
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    procedure CheckBox1Click(Sender: TObject);
    procedure CheckBox2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmMain: TfrmMain;

implementation

{$R *.dfm}

procedure TfrmMain.CheckBox1Click(Sender: TObject);
var
    wndHandle : THandle;
    wndClass : array[0..50] of Char;
begin
    StrPCopy(@wndClass[0], 'Shell_TrayWnd');
    wndHandle := FindWindow(@wndClass[0], nil);
    if self.CheckBox1.Checked then
    begin
        ShowWindow(wndHandle, SW_HIDE);
    end
    else
    begin
        ShowWindow(wndHandle, SW_RESTORE);
    end;
end;

procedure TfrmMain.CheckBox2Click(Sender: TObject);
var
    wndHandle : THandle;
    wndClass : array[0..50] of Char;
begin
    StrPCopy(@wndClass[0], 'Progman');
    wndHandle := FindWindow(@wndClass[0], nil);
    if self.CheckBox2.Checked then
    begin
        ShowWindow(wndHandle, SW_HIDE);
    end
    else
    begin
        ShowWindow(wndHandle, SW_RESTORE);
    end;
end;

end.

 

FORM

object frmMain: TfrmMain
  Left = 192
  Top = 107
  Width = 249
  Height = 198
  Caption = 'ShowWindow'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object CheckBox1: TCheckBox
    Left = 40
    Top = 48
    Width = 145
    Height = 25
    Caption = #38544#34255'Windows'#30340#24037#20855#26639
    TabOrder = 0
    OnClick = CheckBox1Click
  end
  object CheckBox2: TCheckBox
    Left = 40
    Top = 88
    Width = 153
    Height = 33
    Caption = #38544#34255'Windows'#30340#26700#38754#22270#26631
    TabOrder = 1
    OnClick = CheckBox2Click
  end
end

转载于:https://www.cnblogs.com/tecsoon/archive/2009/03/27/1423735.html

相关资讯

    暂无相关的资讯...

共有访客发表了评论 网友评论

验证码: 看不清楚?
    -->