tags:

views:

116

answers:

2

Hi, I've created a simple class and got a little problem: I just want to use the method "findComponent' from the classes-unit. I've included the classes unit, but Delphi can't find the findComponent-method. Why? I'm sure that's a very simple problem...

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.
+10  A: 

Because FindComponent is the function of TComponent class. But your TTest class base on TObject by default.

SimaWB
+1  A: 

As SimaWB said FindComponent is a method in the TComponent class.

If you want to access that method, inherit TComponent class.

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