Delphi - Using Interfaces from Another Device

I keep getting: Undeclared identifier for the type of interface that I defined in another block. Here is what I have:

unit Drawers;

interface

implementation

type

  IDrawer = interface
  ['{070B4742-89C6-4A69-80E2-9441F170F876}']
    procedure Draw();
  end;

end.

unit Field;

interface

uses
  Graphics, Classes, Drawers;

TField = class(TInterfacedObject, IField)
private
  FSymbolDrawer: IDrawer;

In FSymbolDrawer, I get a complier error.

Of course I have drawers for drawers; in the block where TField is defined.

What is it?

thank

+3
source share
2 answers

In the block Drawers, the type declaration IDrawermust be in the interface part of the device. You inserted it into the implementation part, where it is visible only for declarations within the unit.

Here is the code:

unit Drawers;

interface

type

  IDrawer = interface
  ['{070B4742-89C6-4A69-80E2-9441F170F876}']
    procedure Draw();
  end;

implementation

end.
+6
source

In what order of use do you add Drawersin? It should be in the interfaceuses section (above the definition TFieldthat uses it).

+1
source

All Articles