1

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.

2 Answers 2

11

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

2

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;

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.