unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public h:THandle; end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject); begin //隐藏 h:=FindWindow(nil,'我的电脑'); if h<>0 then ShowWindow(h,SW_HIDE); end;procedure TForm1.Button2Click(Sender: TObject); begin //显示 h:=FindWindow(nil,'我的电脑'); if h<>0 then ShowWindow(h,SW_RESTORE); end;end.
少打一个加号用 VS 中带的SPY++
参考的方法:var ExtendedStyle: integer; begin ExtendedStyle := GetWindowLong(Application.Handle, GWL_EXSTYLE); SetWindowLong(Application.Handle, GWL_EXSTYLE, ExtendedStyle or WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW); Application.CreateForm(TForm1, Form1); Form1.show; end;
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
h:THandle;
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
//隐藏
h:=FindWindow(nil,'我的电脑');
if h<>0 then
ShowWindow(h,SW_HIDE);
end;procedure TForm1.Button2Click(Sender: TObject);
begin
//显示
h:=FindWindow(nil,'我的电脑');
if h<>0 then
ShowWindow(h,SW_RESTORE);
end;end.
ExtendedStyle: integer;
begin
ExtendedStyle := GetWindowLong(Application.Handle, GWL_EXSTYLE);
SetWindowLong(Application.Handle, GWL_EXSTYLE, ExtendedStyle or
WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW);
Application.CreateForm(TForm1, Form1);
Form1.show;
end;