[fpc-pascal] how to make a type private to the unit but not defining it in the implementation section?

Michael Van Canneyt michael at freepascal.org
Thu Mar 7 10:01:29 CET 2019



On Thu, 7 Mar 2019, Dennis wrote:

> unit frproxyserver;
>
> {$mode objfpc}{$H+}
>
> interface
>
> uses
>   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, Grids,
>   frBase;
>
> type
>
>   TMyStringGrid=class(TStringGrid) //how to I make this class visible 
> only to this unit?
>   public
>   end;
>
>   { TProxyServerFrame }
>
>   TProxyServerFrame = class(TBaseFrame)
>     Panel_Top: TPanel;
>     StringGrid1: TMyStringGrid;
>   private

Use a nested class:

  TProxyServerFrame = class(TBaseFrame)
    Panel_Top: TPanel;
    StringGrid1: TMyStringGrid;
  private
    type
      TMyStringGrid=class(TStringGrid) //how to I make this class visible   only to this unit?
      public
        Procedure SomeMethod;
      end;
   end;

Implementation

Procedure TProxyServerFrame.TMyStringGrid.SomeMethod;

Michael.


More information about the fpc-pascal mailing list