十万火急,请教动态创建和动态调用控件的问题!(100分)

  • 主题发起人 文木杉
  • 开始时间

文木杉

Unregistered / Unconfirmed
GUEST, unregistred user!
各位高手,十万火急!
当我在程序中动态创建了一个A窗体,又在此A窗体中动态创建了B窗体,请问要在B窗体中调用
A窗体中的控件,代码应在那里写啊?
十万火急,希望各位高首赐教。
 
在B窗体所在单元 use A窗体所在的单元。代码就可以写在B窗体所在的单元里了。
 
[:(!]靠,这也算啊
 
xeen说的对
 
这是送分题哟!
 
我真是菜鸟
请高手再给我讲讲:
我建了form1,form2,form3三个窗体,三个窗体中各放一个button,我通过form1的button
的onclick 事件动态创建了A窗体(A窗体是form2的子类实例),又通过A窗体动态创建了B窗
体(B窗体是form3的子类实例),我想通过B窗体button的onclick事件改变A窗体中的button的caption
属性,具体代码写在?
请高手指教。
 
A.Button.Caption:='Your Caption';
 
A窗体是form2的子类实例?什么意思?
把你动态创建窗体的代码贴出来?
 
楼上说的都是对的,一般的DELPHI的书都有的。
 
这分我要呀。
在form1中由Button1Click动态建立新的窗体与button2控件,
并对button2事件响应。代码如下。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
type
Tform2=class(Tform)
procedure Button2Click(Sender: TObject) ;
end;
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
form2:Tform2;
button2:Tbutton;
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
form2:=Tform2.Create(self);//动态创建新窗体。(正式写时适当位置
//应加入form2.free以释放)
form2.Show;
button2:=Tbutton.Create(self);
button2.Parent:=form2;
//form2.Button2Click(self);
button2.onClick:=Form2.Button2Click; //将button2的响应与 //Button2Click联系起来
end;

procedure TForm2.Button2Click(Sender: TObject);
begin
button2.Caption:='111';
form1.Caption:='111'+form1.Caption; //也可以类似写form1.button.caption
// :='hhhh'
end;
end.
最后告诉你个诀窍:输入检索关键词 动态 控件 响应
呵呵,后悔出这100分了吧。
 
我正在做三层b/s架构的activeform东东,是从三层midas转变过去的,其中众多窗体之间相互调用,
而activeform的每一个窗体在浏览器中浏览时都的动态生成,你们上面说的我都懂,具体到转化时可不是容易的事,
因为在原有的语句的基础上。象micro73高手说的A.Button.Caption:='Your Caption';,这语句又写在哪。
在form1中可以,在form2,form3中根本不认识这个A对象(把A声明称整个程序都可用的变量可能行吧);
希望各高手指教指教,我这个菜鸟真是没有招。
 
你建立b时不能将它的owner定为a吗?
这样在b中就可以访问a了呀
 
顶部