Delphi的窗体调用
请问我做个主窗体和个子窗体,我主窗体放上一个按钮,我点击按钮时,显示出子窗体,隐藏主窗体,显示出来的子窗体,点击退出按钮,在回到主窗体,这样的调用该怎么写,小弟新手,请多...
请问我做个主窗体和个子窗体,我主窗体放上一个按钮,我点击按钮时,显示出子窗体,隐藏主窗体,显示出来的子窗体,点击退出按钮,在回到主窗体,这样的调用该怎么写,小弟新手,请多多指教
你可以把程序写出来吗?我有点不明白
先谢谢你了 展开
你可以把程序写出来吗?我有点不明白
先谢谢你了 展开
展开全部
第一个窗体中的按钮名字为btn1
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,unit2; //引用窗体2的单元文件
type
TForm1 = class(TForm)
btn1: TButton;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject);
begin
form1.Hide;
Form2.ShowModal;
end;
end.
第二个窗体中按钮的名字为btn2
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
btn2: TButton;
procedure btn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses Unit1; //引用窗体一的单元文件
{$R *.dfm}
procedure TForm2.btn2Click(Sender: TObject);
begin
Form2.Close;
Form1.Show;
end;
end.
这样就实现了。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,unit2; //引用窗体2的单元文件
type
TForm1 = class(TForm)
btn1: TButton;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject);
begin
form1.Hide;
Form2.ShowModal;
end;
end.
第二个窗体中按钮的名字为btn2
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
btn2: TButton;
procedure btn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses Unit1; //引用窗体一的单元文件
{$R *.dfm}
procedure TForm2.btn2Click(Sender: TObject);
begin
Form2.Close;
Form1.Show;
end;
end.
这样就实现了。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询