Search code examples
delphifiremonkeydelphi-10-seattle

Public Types in Delphi Components


I have subclassed an FMX component and I want to override a (Virtual) protected procedure.

This procedure has a number of params, which are declared as "public type" in the class of the component.

When I try to override the procedure, I get an error that one of the types is not declared although my component subclasses the original one. Shouldn't I be able to get access to it?

The class is defined like this:

TTabControl = class (...)
public type
  TTabBarButton = (Left, Right)
  TTabBarButtons = set of TTabButton;
  ....
protected
  procedure DoUpdate(const TabBarButtons: TTabBarButtons; ....); virtual;
  ...
end;

Now, I have subclassed this class and want to override DoUpdate.

TMyClass = class (TTabControl)
protected
  procedure DoUpdate(const TabBarButtons: TTabBarButtons; ....); override;  
  ....
end;

The compiler complains that TTabBarButtons in my class is not defined. If I redefine TTabBarButtons as public type in my class, then it says that the definition differs from the base class.

Can you please help me with this?

Thanks a lot.


Solution

  • This works for me:

    TMyClass = class (TTabControl)
    protected
      procedure DoUpdate(const TabBarButtons: TTabControl.TTabBarButtons; ....); override;  
      ....
    end;
    

    There are other parameters you'll need to do the same thing with; the fun comes when you start tracking all of those types and declarations down. Good luck. :-)