level 1
Form1:fsMDIForm;
Form2:fsMDIChild;
//以下是Form2的全部代码-----------------------------------------------------------
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure ReadEdit1;
begin
ShowMessage(form2.Edit1.Text);//问题就在这里,为什么这个过程执行报错。为什么执行过程或函数不能调用mdi子窗口中的控件内容?????????!!!!!!!!
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
ReadEdit1;
end;
end.
//以下是Form1的全部代码-----------------------------------------------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
b1: TMenuItem;
procedure b1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.b1Click(Sender: TObject);
var
newform:TForm2;
i,flag:integer;
begin
flag:=0;
for i:=0 to Form1.MDIChildCount-1 do
begin
if Form1.MDIChildren[i].Caption='Form2' then
begin
SendMessage(mdichildren[i].Handle, WM_SYSCOMMAND, SC_restore, 0);
mdichildren[i].Show;
mdichildren[i].Enabled:=true;
flag:=1;
mdichildren[i].top:=0;
mdichildren[i].Left:=0;
break;
end;
end;
if flag=0 then
begin
newform:=Tform2.Create(application);
newform.Caption:='Form2';
newform.Top:=0;
newform.Left:=0;
newform.Height:=Form1.ClientHeight-24;
newform.Width:=Form1.ClientWidth-4;
end;
end;
end.
2016年02月17日 06点02分
1
Form2:fsMDIChild;
//以下是Form2的全部代码-----------------------------------------------------------
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure ReadEdit1;
begin
ShowMessage(form2.Edit1.Text);//问题就在这里,为什么这个过程执行报错。为什么执行过程或函数不能调用mdi子窗口中的控件内容?????????!!!!!!!!
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
ReadEdit1;
end;
end.
//以下是Form1的全部代码-----------------------------------------------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
b1: TMenuItem;
procedure b1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.b1Click(Sender: TObject);
var
newform:TForm2;
i,flag:integer;
begin
flag:=0;
for i:=0 to Form1.MDIChildCount-1 do
begin
if Form1.MDIChildren[i].Caption='Form2' then
begin
SendMessage(mdichildren[i].Handle, WM_SYSCOMMAND, SC_restore, 0);
mdichildren[i].Show;
mdichildren[i].Enabled:=true;
flag:=1;
mdichildren[i].top:=0;
mdichildren[i].Left:=0;
break;
end;
end;
if flag=0 then
begin
newform:=Tform2.Create(application);
newform.Caption:='Form2';
newform.Top:=0;
newform.Left:=0;
newform.Height:=Form1.ClientHeight-24;
newform.Width:=Form1.ClientWidth-4;
end;
end;
end.
