[
]功能是实现了~ 比较笨 [
][
]
例子如下-------
主窗体: Form1
子窗体:Form2
------------------
代码1:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
show_x:boolean;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
form2.Show;
show_x:=true;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
show_x:=false;
end;
end.
------------------------
代码2:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm2 = class(TForm)
procedure FormResize(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm2.FormResize(Sender: TObject);
begin
if show_x then
begin
if form2.WindowState=wsNormal then
form1.WindowState:=wsMinimized;//wsMaximized wsNormal;
end;
end;
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
show_x:=false;
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
BorderStyle:=bsSingle;
end;
end.