0

I have created a new unit like so and it should be a custom TShape.

unit MachineShape;


interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, extctrls,myDataModule,Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type

TMachine = class(TShape)
     count : Integer;
  private
    { Private declarations }
  public
    { Public declarations }
    procedure PlaceShape(sizeW,sizeH :integer; name, order,asset : string);
  end;
implementation

    Procedure PlaceShape(sizeW,sizeH :integer; name, order,asset : string);
    begin

    end;

end.

next i pass this to the procedure

MachineShape.TMachine.PlaceShape(44,49,'CM402','first','123/33/123');

How do i set in the procedure to set the shape size as 44 width and 49 height?

I have tried to do TMachine.Width but it does not work? thanks glen

1 Answer 1

2

You've declared PlaceShape to be an instance method and so need to implement it as such:

Procedure TMachine.PlaceShape(sizeW,sizeH :integer; name, order,asset : string);
begin
  Width := sizeW;
  Height := sizeH;
  ....
end;

You declared a function

Procedure PlaceShape(...);

that is not a method of the class.

This question suggests that you are missing some understanding of the Delphi object model. I refer you to the relevant section of the language guide to fill in the missing knowledge.

I would also recommend that you use different names for your dimensions parameters. You should use AWidth and AHeight so that it is clear to future readers of the code that these parameters are going to be used to set the corresponding shape properties.

Sign up to request clarification or add additional context in comments.

1 Comment

I get it now, for some reason when i did TMachine. PlaceShape would not come up a compile / build fixed it .. Thanks!

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.