0
In a Form have a Paintbox property Align = alClient and a Button.
I need to draw an object of the type Canvas within the Paintbox at the event Onclick of Button. This is the object of type Canvas which should be created:
const IconSize:Integer = 10
type
  Icon = Class   
  public
    posX, posY:Integer;
    constructor Create(X,Y:Integer);
    destructor Destroy;
    procedure SetX(AValue: Integer);
    procedure SetY(AValue: Integer);
  published
    property LocationX : Integer read posX write SetX;
    property LocationY : Integer read posY write SetY;
end;     
var CanvasIcon: Icon;
This is the method constructor of the object:
constructor Icon.Create(X, Y: Integer);
var Bitmap:TBitmap;
begin
  Bitmap:=TBitmap.Create;
  try
    Bitmap.Height := IconSize;
    Bitmap.Width := IconSize;
    Bitmap.Canvas.Pen.Color := clBlack;
    Bitmap.Canvas.Rectangle(Round(X-(IconSize/2)), Round(Y-(IconSize/2)),
      Round(X+(IconSize/2)), Round(Y+(IconSize/2)));
    PaintBox.Canvas.Draw(0, 0, Bitmap);
  finally
    Bitmap.Free;
  end;
end;   
And this is the event Onclick of Button:
procedure TFormPaintBox.Button1Click(Sender: TObject);
begin
  CanvasIcon:=Icon.Create(10,10);
end;
However, Lazarus displays the following error message:
src/unitpaintbox.pas(121,33) Error: Wrong number of Parameters specified for call to "Create"
But the constructor receives two parameters, exactly as specified in the event onClick of Button. How can I solve this problem?
Problem solved as follows: editing the
IconforCustomIcon, and removing the entries ofconstructor Create;– exg