窗体1的formstyle属性为fsMDIForm
窗体2的formstyle属性为fsMDIChild
窗体3的formstyle属性为fsNormal
现在要求工程启动后首先显示出窗体一,也就是父窗体
然后显示出窗体3,关闭窗体3后根据窗体3返回的值确定是否调用窗体2
怎么写,能告诉我吗?
13 个解决方案
#1
我也不会
#2
让窗体2根据窗体3返回的值动态创建!
#3
请写出程序示例
#4
在窗体1中写:
form2 := TForm2.Create(self);
try
form2.ShowModal;
finally
form2.free;
if form2.ModalResult = mrOK then
begin
form3 := TForm3.Create(self);
form3.Show;
end;
end;
form2 := TForm2.Create(self);
try
form2.ShowModal;
finally
form2.free;
if form2.ModalResult = mrOK then
begin
form3 := TForm3.Create(self);
form3.Show;
end;
end;
#5
if form3.showmodal=mrok then
begin
form2:=tform2.create(self);
form2.show;
end;
form1设为mainform.
begin
form2:=tform2.create(self);
form2.show;
end;
form1设为mainform.
#6
窗体:form1,form2,form3。
unit1的代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
procedure N2Click(Sender: TObject);
procedure N1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses unit2,unit3;
{$R *.DFM}
procedure TForm1.N2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.N1Click(Sender: TObject);
begin
form3.ShowModal;
end;
end.
form3的代码:
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TForm3 = class(TForm)
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
uses unit2;
{$R *.DFM}
procedure TForm3.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if application.MessageBox('要打开form2吗?','提示',mb_yesno+MB_ICONWARNING)=mryes then
begin
form3.Hide;
form2.ShowModal;
end;
end;
end.
unit1的代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
procedure N2Click(Sender: TObject);
procedure N1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses unit2,unit3;
{$R *.DFM}
procedure TForm1.N2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.N1Click(Sender: TObject);
begin
form3.ShowModal;
end;
end.
form3的代码:
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TForm3 = class(TForm)
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
uses unit2;
{$R *.DFM}
procedure TForm3.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if application.MessageBox('要打开form2吗?','提示',mb_yesno+MB_ICONWARNING)=mryes then
begin
form3.Hide;
form2.ShowModal;
end;
end;
end.
#7
procedure TForm1.Button1Click(Sender: TObject);
begin
try
form3.ShowModal; //窗体需要创建,自己加上
finally
if form3.ModalResult = 1 then
form2.ShowModal; //窗体需要创建,自己加上
end;
end;
在form3放两个按纽,分别把ModalResult设置成mbok(确定)和mbcancel(取消)
begin
try
form3.ShowModal; //窗体需要创建,自己加上
finally
if form3.ModalResult = 1 then
form2.ShowModal; //窗体需要创建,自己加上
end;
end;
在form3放两个按纽,分别把ModalResult设置成mbok(确定)和mbcancel(取消)
#8
太高深的问题了,高手来回答吧.
当我没来过.
当我没来过.
#9
对不起,各位可能没有弄清楚我的意思,我的意思是首先显示主窗体一,然后自动出现窗体三(请注意,是自动弹出窗体三),然后在窗体三关闭后(这一步是人工操作的,比如说点击了窗体三上的确定按钮),会返回一个值,然后主窗体一或子窗体二根据这个返回的值确定是否显示子窗体二,请注意(是子窗体二),请给出事例程序,特别要指明是在窗体的什么事件中调用这些程序。
#10
吐血,人家已经说的很清楚了啊,这样还不知道?
#11
这还不简单:
unit1的源代码改为:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
procedure N2Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses unit2,unit3;
{$R *.DFM}
procedure TForm1.N2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
form3.ShowModal;
end;
end.
unit1的源代码改为:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
procedure N2Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses unit2,unit3;
{$R *.DFM}
procedure TForm1.N2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
form3.ShowModal;
end;
end.
#12
UP
#13
wenguang(广) 您好,感谢你对这个问题的关心。不过您的程序运行还是无法通过。我把你的程序总结了一下,是这样的,你看看是不是哪里有问题。
窗体1的formstyle属性为fsMDIForm
窗体2的formstyle属性为fsMDIChild
窗体3的formstyle属性为fsNormal
现在要求工程启动后首先显示出窗体一,也就是父窗体
然后自动显示出窗体3,关闭窗体3后根据窗体3返回的值确定是否调用窗体2
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.Run;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Menus;
type
TForm1 = class(TForm)
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2, Unit3;
{$R *.DFM}
procedure TForm1.FormActivate(Sender: TObject);
begin
form3:=tform3.Create(application);
form3.ShowModal;
end;
end.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm2 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.DFM}
end.
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm3 = class(TForm)
Button1: TButton;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
uses Unit2;
{$R *.DFM}
procedure TForm3.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if application.MessageBox('要打开form2吗?','提示',mb_yesno+MB_ICONWARNING)=mryes then
begin
form3.Hide;
form2:=Tform2.Create(application);
form2.ShowModal;
end;
end;
end.
窗体1的formstyle属性为fsMDIForm
窗体2的formstyle属性为fsMDIChild
窗体3的formstyle属性为fsNormal
现在要求工程启动后首先显示出窗体一,也就是父窗体
然后自动显示出窗体3,关闭窗体3后根据窗体3返回的值确定是否调用窗体2
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.Run;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Menus;
type
TForm1 = class(TForm)
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2, Unit3;
{$R *.DFM}
procedure TForm1.FormActivate(Sender: TObject);
begin
form3:=tform3.Create(application);
form3.ShowModal;
end;
end.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm2 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.DFM}
end.
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm3 = class(TForm)
Button1: TButton;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
uses Unit2;
{$R *.DFM}
procedure TForm3.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if application.MessageBox('要打开form2吗?','提示',mb_yesno+MB_ICONWARNING)=mryes then
begin
form3.Hide;
form2:=Tform2.Create(application);
form2.ShowModal;
end;
end;
end.
#1
我也不会
#2
让窗体2根据窗体3返回的值动态创建!
#3
请写出程序示例
#4
在窗体1中写:
form2 := TForm2.Create(self);
try
form2.ShowModal;
finally
form2.free;
if form2.ModalResult = mrOK then
begin
form3 := TForm3.Create(self);
form3.Show;
end;
end;
form2 := TForm2.Create(self);
try
form2.ShowModal;
finally
form2.free;
if form2.ModalResult = mrOK then
begin
form3 := TForm3.Create(self);
form3.Show;
end;
end;
#5
if form3.showmodal=mrok then
begin
form2:=tform2.create(self);
form2.show;
end;
form1设为mainform.
begin
form2:=tform2.create(self);
form2.show;
end;
form1设为mainform.
#6
窗体:form1,form2,form3。
unit1的代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
procedure N2Click(Sender: TObject);
procedure N1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses unit2,unit3;
{$R *.DFM}
procedure TForm1.N2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.N1Click(Sender: TObject);
begin
form3.ShowModal;
end;
end.
form3的代码:
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TForm3 = class(TForm)
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
uses unit2;
{$R *.DFM}
procedure TForm3.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if application.MessageBox('要打开form2吗?','提示',mb_yesno+MB_ICONWARNING)=mryes then
begin
form3.Hide;
form2.ShowModal;
end;
end;
end.
unit1的代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
procedure N2Click(Sender: TObject);
procedure N1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses unit2,unit3;
{$R *.DFM}
procedure TForm1.N2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.N1Click(Sender: TObject);
begin
form3.ShowModal;
end;
end.
form3的代码:
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TForm3 = class(TForm)
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
uses unit2;
{$R *.DFM}
procedure TForm3.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if application.MessageBox('要打开form2吗?','提示',mb_yesno+MB_ICONWARNING)=mryes then
begin
form3.Hide;
form2.ShowModal;
end;
end;
end.
#7
procedure TForm1.Button1Click(Sender: TObject);
begin
try
form3.ShowModal; //窗体需要创建,自己加上
finally
if form3.ModalResult = 1 then
form2.ShowModal; //窗体需要创建,自己加上
end;
end;
在form3放两个按纽,分别把ModalResult设置成mbok(确定)和mbcancel(取消)
begin
try
form3.ShowModal; //窗体需要创建,自己加上
finally
if form3.ModalResult = 1 then
form2.ShowModal; //窗体需要创建,自己加上
end;
end;
在form3放两个按纽,分别把ModalResult设置成mbok(确定)和mbcancel(取消)
#8
太高深的问题了,高手来回答吧.
当我没来过.
当我没来过.
#9
对不起,各位可能没有弄清楚我的意思,我的意思是首先显示主窗体一,然后自动出现窗体三(请注意,是自动弹出窗体三),然后在窗体三关闭后(这一步是人工操作的,比如说点击了窗体三上的确定按钮),会返回一个值,然后主窗体一或子窗体二根据这个返回的值确定是否显示子窗体二,请注意(是子窗体二),请给出事例程序,特别要指明是在窗体的什么事件中调用这些程序。
#10
吐血,人家已经说的很清楚了啊,这样还不知道?
#11
这还不简单:
unit1的源代码改为:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
procedure N2Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses unit2,unit3;
{$R *.DFM}
procedure TForm1.N2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
form3.ShowModal;
end;
end.
unit1的源代码改为:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
procedure N2Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses unit2,unit3;
{$R *.DFM}
procedure TForm1.N2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
form3.ShowModal;
end;
end.
#12
UP
#13
wenguang(广) 您好,感谢你对这个问题的关心。不过您的程序运行还是无法通过。我把你的程序总结了一下,是这样的,你看看是不是哪里有问题。
窗体1的formstyle属性为fsMDIForm
窗体2的formstyle属性为fsMDIChild
窗体3的formstyle属性为fsNormal
现在要求工程启动后首先显示出窗体一,也就是父窗体
然后自动显示出窗体3,关闭窗体3后根据窗体3返回的值确定是否调用窗体2
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.Run;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Menus;
type
TForm1 = class(TForm)
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2, Unit3;
{$R *.DFM}
procedure TForm1.FormActivate(Sender: TObject);
begin
form3:=tform3.Create(application);
form3.ShowModal;
end;
end.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm2 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.DFM}
end.
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm3 = class(TForm)
Button1: TButton;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
uses Unit2;
{$R *.DFM}
procedure TForm3.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if application.MessageBox('要打开form2吗?','提示',mb_yesno+MB_ICONWARNING)=mryes then
begin
form3.Hide;
form2:=Tform2.Create(application);
form2.ShowModal;
end;
end;
end.
窗体1的formstyle属性为fsMDIForm
窗体2的formstyle属性为fsMDIChild
窗体3的formstyle属性为fsNormal
现在要求工程启动后首先显示出窗体一,也就是父窗体
然后自动显示出窗体3,关闭窗体3后根据窗体3返回的值确定是否调用窗体2
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.Run;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Menus;
type
TForm1 = class(TForm)
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2, Unit3;
{$R *.DFM}
procedure TForm1.FormActivate(Sender: TObject);
begin
form3:=tform3.Create(application);
form3.ShowModal;
end;
end.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm2 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.DFM}
end.
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm3 = class(TForm)
Button1: TButton;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
uses Unit2;
{$R *.DFM}
procedure TForm3.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if application.MessageBox('要打开form2吗?','提示',mb_yesno+MB_ICONWARNING)=mryes then
begin
form3.Hide;
form2:=Tform2.Create(application);
form2.ShowModal;
end;
end;
end.