S
SamHunt
Unregistered / Unconfirmed
GUEST, unregistred user!
我建立了三个窗体,
form1是mid主框,
form2是mid子框,
form3是普通的窗体,
form1 建立 form2 ,form2动态建立form3,
问题是这样的:当form2调用form3时,正常,
但当form3操作form2时,就出现非法操作!!
问题出在那儿?
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Form2},
Unit3 in 'Unit3.pas' {Form3};
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
// Application.CreateForm(TForm3, Form3);
Application.Run;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
// Application.CreateForm(TForm2, Form2);
TForm2.Create(application);
// Form2.ShowModal;
end;
end.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Db, ADODB, Grids, DBGrids, StdCtrls;
type
TForm2 = class(TForm)
DBGrid1: TDBGrid;
DataSource1: TDataSource;
ADOTable1: TADOTable;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses Unit3;
{$R *.DFM}
procedure TForm2.Button1Click(Sender: TObject);
var
aa:TForm3;
begin
aa:=TForm3.Create(Application);
aa.ShowModal;
end;
end.
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm3 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
//var
// Form3: TForm3;
implementation
uses Unit2;
{$R *.DFM}
procedure TForm3.Button1Click(Sender: TObject);
begin
Unit2.Form2.ADOTable1.Next;
end;
end.
form1是mid主框,
form2是mid子框,
form3是普通的窗体,
form1 建立 form2 ,form2动态建立form3,
问题是这样的:当form2调用form3时,正常,
但当form3操作form2时,就出现非法操作!!
问题出在那儿?
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Form2},
Unit3 in 'Unit3.pas' {Form3};
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
// Application.CreateForm(TForm3, Form3);
Application.Run;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
// Application.CreateForm(TForm2, Form2);
TForm2.Create(application);
// Form2.ShowModal;
end;
end.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Db, ADODB, Grids, DBGrids, StdCtrls;
type
TForm2 = class(TForm)
DBGrid1: TDBGrid;
DataSource1: TDataSource;
ADOTable1: TADOTable;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses Unit3;
{$R *.DFM}
procedure TForm2.Button1Click(Sender: TObject);
var
aa:TForm3;
begin
aa:=TForm3.Create(Application);
aa.ShowModal;
end;
end.
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm3 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
//var
// Form3: TForm3;
implementation
uses Unit2;
{$R *.DFM}
procedure TForm3.Button1Click(Sender: TObject);
begin
Unit2.Form2.ADOTable1.Next;
end;
end.