2010-08-27 41 views
1

我创建了一个简单的类,并得到了一个小问题: 我只是想从类的单位使用“findComponent”的方法 我已经包括了类单元,但德尔福找不到findComponent法。 为什么呢?我敢肯定,这是一个非常简单的问题...德尔福 - 包括单元'类',但找不到函数'FindComponent'

unit U_Test; 

interface 

uses 
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, QStdCtrls; 

type 
    TTest = Class 
    public 
    // 
    private 
    procedure test(); 
    End; 

implementation 

procedure TTest.test(); 
begin 
    FindControl('test'); // FindControl is found in unit controls 
    FindComponent('test'); // FindComponent is NOT found, but unit classes is included 
end; 

end. 

回答

2

由于SimaWB表示FindComponent是一种方法在TComponent类中。

如果要访问该方法,请继承TComponent类。

TTest = Class(TComponent) 
    public 
    // 
    private 
    procedure test(); 
    End; 
11

因为findComponent是TComponent类的功能。但是,您的TTest类默认基于TObject。