菜单上选择"edit",然后选择”add to interface“ 增加一个属性如:propery host:widestring;//(注意字符串类型的属性不能用string,要用widestring);修改下面的代码如下: function Tkj2000_chaxun.Get_host: WideString; begin Result:=self.SocketConnection1.Address; end;procedure Tkj2000_chaxun.Set_host(const Value: WideString); begin self.SocketConnection1.Address:=value; end;
访问active form中控件(是不可见控件)的属性
ActiveForm 中的控件相对于窗体本身而言,是私有成员。因此除全局变量外其余均不能被 以 ActiveForm1.Button1 方式进行访问。 弹出时: procedure TActiveFormX.Button1Click(Sender: TObject); var f: TForm1; begin f := TForm1.Create(self);//注意传递SELF,作为FORM1的OWNER try f.ShowModal; finally f.Free; end; end;Form1中的调用方法:procedure TForm1.Button1Click(Sender: TObject); begin if (self.Owner) is TActiveFormX then ((Self.Owner) as TActiveFormX).Button1.Caption := 'changed!' end;
菜单上选择"edit",然后选择”add to interface“ 增加一个属性如:propery host:widestring;//(注意字符串类型的属性不能用string,要用widestring);修改下面的代码如下: function Tkj2000_chaxun.Get_host: WideString; begin Result:=self.SocketConnection1.Address; end;procedure Tkj2000_chaxun.Set_host(const Value: WideString); begin self.SocketConnection1.Address:=value; end;通过这样就可以增加了一个对外公布的host属性,并能通过该host属性给不可见控件SocketConnection1的Address属性赋植或得到该属性的值;调用该OCX控件的时候,直接使用kj2000_chaxun.host:='192.168.0.1';就可以了
增加一个属性如:propery host:widestring;//(注意字符串类型的属性不能用string,要用widestring);修改下面的代码如下:
function Tkj2000_chaxun.Get_host: WideString;
begin
Result:=self.SocketConnection1.Address;
end;procedure Tkj2000_chaxun.Set_host(const Value: WideString);
begin
self.SocketConnection1.Address:=value;
end;
以 ActiveForm1.Button1 方式进行访问。
弹出时:
procedure TActiveFormX.Button1Click(Sender: TObject);
var
f: TForm1;
begin
f := TForm1.Create(self);//注意传递SELF,作为FORM1的OWNER
try
f.ShowModal;
finally
f.Free;
end;
end;Form1中的调用方法:procedure TForm1.Button1Click(Sender: TObject);
begin
if (self.Owner) is TActiveFormX then
((Self.Owner) as TActiveFormX).Button1.Caption := 'changed!'
end;
增加一个属性如:propery host:widestring;//(注意字符串类型的属性不能用string,要用widestring);修改下面的代码如下:
function Tkj2000_chaxun.Get_host: WideString;
begin
Result:=self.SocketConnection1.Address;
end;procedure Tkj2000_chaxun.Set_host(const Value: WideString);
begin
self.SocketConnection1.Address:=value;
end;通过这样就可以增加了一个对外公布的host属性,并能通过该host属性给不可见控件SocketConnection1的Address属性赋植或得到该属性的值;调用该OCX控件的时候,直接使用kj2000_chaxun.host:='192.168.0.1';就可以了
TActiveFormX报错
你看看你那Button1Click前面是什么就换成什么名字,我这里是TActiveFormX就用TActiveFormX
是不是复杂拉点。
如果不怕麻烦的话,指点一下;我试拉一下hu1313(crazyguy)的方法,好象属性是caption还行,如果是上面的属性话好象,我就做不出了;谢谢;
//
bee2518谢谢你,我会在试一下!