Hello again!

Hello again!

I think it shows that I haven't been doing this sort of stuff for a very long time :) So, I got a new set of interfaces I need to put to work.

Because they all are imaging tools of sorts, I want to have something like the BorlandIDEServces variable: instantiate once, use everywhere :)

So, right now I only have one tool, and this is the main class as being declared:

TImageTools = class( TInterfacedObject, IImageTools, IAspectRatio )
  strict private
    FWidth : Integer;
    FHeight: Integer;

    FAspectRatio : TImageAspectRatio;

    function GetHeight: Integer;
    function GetWidth: Integer;
    procedure SetHeight(Value: Integer);
    procedure SetWidth(Value: Integer);
    function GetAspectRatio: IAspectRatio;
  strict protected
    // These are declared because you never know.
    property Width: Integer read GetWidth write SetWidth;
    property Height: Integer read GetHeight write SetHeight;
  public
    constructor Create;reintroduce;virtual;
    destructor Destroy; override;

    property AspectRatio : IAspectRatio read GetAspectRatio implements IAspectRatio;
  end;

The implementing class inherits from a TImageTool one which, in turn, inherits from TAggregatedObject.

In theory, with something like that,  you should be able to
cast directly:

Result := IAspectRatio( Variable ).Method;

but this results in an AV. I know it is so because the breakpoints at the start of the implementation methods in the right class do not even get called, it raises the AV prior to that.

Also, the variable is correctly instantiated because I can use the Width and Height properties without error.

Any ideas what I have wrong here?

Thanks.

A

Comments