delphi 如何通过单击一个窗体的按钮给一个frame的控件赋值 5
代码:unit1为form主窗体,unit2为form子窗体,unit3为frame嵌套在form中unitUnit1;interfaceusesWinapi.Windo...
代码:unit1为form主窗体,unit2为form子窗体,unit3为frame嵌套在form中
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs,Unit3, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
frame3: TFrame3;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if frame3 = nil then
begin
frame3 := TFrame3.Create(Application);
frame3.Parent := Form1;
frame3.Align := alClient;
frame3.Show;
end;
end;
end.
unit Unit3;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TFrame3 = class(TFrame)
Edit1: TEdit;
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frame3: TFrame3;
implementation
{$R *.dfm}
uses Unit2;
procedure TFrame3.Button1Click(Sender: TObject);
begin
form2.Show();
end;
end.
unit Unit2;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm2 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses Unit1,Unit3;
var frame3: TFrame3;
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
frame3.Edit1.Text:=Form2.Edit1.Text;
end;
end.
现在执行 frame3.Edit1.Text:=Form2.Edit1.Text;这句时报错:
Access violation at address 008A6B96 in module 'server.exe'. Read of address 000002B0. 展开
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs,Unit3, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
frame3: TFrame3;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if frame3 = nil then
begin
frame3 := TFrame3.Create(Application);
frame3.Parent := Form1;
frame3.Align := alClient;
frame3.Show;
end;
end;
end.
unit Unit3;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TFrame3 = class(TFrame)
Edit1: TEdit;
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frame3: TFrame3;
implementation
{$R *.dfm}
uses Unit2;
procedure TFrame3.Button1Click(Sender: TObject);
begin
form2.Show();
end;
end.
unit Unit2;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm2 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses Unit1,Unit3;
var frame3: TFrame3;
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
frame3.Edit1.Text:=Form2.Edit1.Text;
end;
end.
现在执行 frame3.Edit1.Text:=Form2.Edit1.Text;这句时报错:
Access violation at address 008A6B96 in module 'server.exe'. Read of address 000002B0. 展开
展开全部
设置一个按钮,
点击后弹出另外一个窗体form2。
procedure TForm1.Button1Click(Sender: TObject);
var frm2 : TForm2;
begin
frm2 := TForm2.Create(nil);
frm2.Show;
//或者 frm2.ShowModal;
frm2.Free ;
end;
光标移到按钮的时候,光标变为手指图案(handpoint)
procedure TForm1.Button1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
Button1.Cursor:=crHandPoint;
end;
点击后弹出另外一个窗体form2。
procedure TForm1.Button1Click(Sender: TObject);
var frm2 : TForm2;
begin
frm2 := TForm2.Create(nil);
frm2.Show;
//或者 frm2.ShowModal;
frm2.Free ;
end;
光标移到按钮的时候,光标变为手指图案(handpoint)
procedure TForm1.Button1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
Button1.Cursor:=crHandPoint;
end;
2018-05-27
展开全部
楼主解决了吗?怎么解决的?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询