TMS的控件为何如此,晕。。。。(100分)

  • 主题发起人 主题发起人 janker
  • 开始时间 开始时间
J

janker

Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, VrLeds, RzPanel, ExtCtrls, StdCtrls, VrControls, VrButtons,
RzButton, Mask, RzEdit, cxControls, cxContainer, cxEdit, cxGroupBox;
type
TForm1 = class(TForm)
tmsvrsdbtn10: TVrShadowButton;
mmo1: TMemo;
rzpnl1: TRzPanel;
rzgrpb1: TRzGroupBox;
tmsvrul1: TVrUserLed;
tmsvrsdbtn1: TVrShadowButton;
tmsvrul2: TVrUserLed;
tmsvrsdbtn2: TVrShadowButton;
rzgrpb2: TRzGroupBox;
tmsvrul3: TVrUserLed;
tmsvrsdbtn3: TVrShadowButton;
tmsvrul4: TVrUserLed;
tmsvrsdbtn4: TVrShadowButton;
rzbtn1: TRzButton;
rzedt1: TRzEdit;
cxgpb1: TcxGroupBox;
tmsvrul5: TVrUserLed;
tmsvrsdbtn5: TVrShadowButton;
tmsvrul6: TVrUserLed;
tmsvrsdbtn6: TVrShadowButton;
procedure tmsvrsdbtn10Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.tmsvrsdbtn10Click(Sender: TObject);
var
i:Integer;
begin
mmo1.Clear;
mmo1.Lines.Add(IntToStr(rzgrpb1.ControlCount));
for i:=0 to rzgrpb1.ControlCount-1do
begin
mmo1.Lines.Add(rzgrpb1.Controls.Name);
end;

if rzgrpb1.FindComponent('tmsvrul1') <> nil then
begin
mmo1.Lines.Add('Find tmsvrul1');
end
else
begin
mmo1.Lines.Add('No Find tmsvrul1');
//运行这句
mmo1.Lines.Add(tmsvrul1.Parent.Name);
//显示rzgrpb1
end;

if rzgrpb1.FindChildControl('rzedt1') <> nil then
begin
mmo1.Lines.Add('Find rzedt1');
//运行这句
end
else
mmo1.Lines.Add('No Find rzedt1');
mmo1.Lines.Add('---------------------------------');
if cxgpb1.FindChildControl('tmsvrul5') <> nil then
begin
mmo1.Lines.Add('Find tmsvrul5');
end
else
begin
mmo1.Lines.Add('No Find tmsvrul5');
//运行这句
mmo1.Lines.Add(tmsvrul5.Parent.Name);
//显示cxgpb1
end;
end;

end.
 
就是说,FindChildControl()和FindComponent()这两个函数对TMS控件不起作用,这个好象有点开玩笑吧,可是明明它们的“父”还在呀
 
你还是在调试运行下跟踪一下吧,看你给的程序应该没问题啊,跟踪的同时看看if是否执行就知道原因了。
 
呵呵,找到问题了
这些个的TMS都是继承自TGraphicControl,不能用FindChildControl(),只有出自TWinControl的才能用。而FindCompoent则是要由拥有者调用,不能由“父”调用。
想当然了。。。。
 
后退
顶部