Einzelnen Beitrag anzeigen

hochundweit

Registriert seit: 9. Mär 2014
14 Beiträge
 
#1

FPC / Custom TPaintbox: Onpaint deklarieren

  Alt 16. Mär 2016, 14:45
Hallo liebe Delphi/FPC Freunde,
ich habe eine Frage bzgl. der Onpaint Methode der TPaintbox in FPC.
Der Code unten soll mir eine eigene TPaintbox Klasse namens TMyPB erstellen.
Das Onpaint definiere ich ueber die procedure Mypaint.

Beim Kompilieren bekomme ich die Rueckmeldung:
mypaintbox.pas(49,15) Error: Wrong number of parameters specified for call to "Mypaint"
mypaintbox.pas(17,15) Error: Found declaration: Mypaint(TObject);

Wo liegt der Fehler ?
(FPC 3.0.0)

Besten Dank im voraus fuer Euere Inputs !
LG, Wolfgang



Delphi-Quellcode:
unit Mypaintbox;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  Grids, ExtCtrls, FGL;


type
  TMyPB = class(TPaintBox)
  private
    x, y: Integer;
    binnum: Integer;
[COLOR="Yellow"] procedure Mypaint(Sender: TObject);[/COLOR]
  public
    constructor Create(AOwner: TComponent); overload;
    constructor Create(AOwner: TComponent; TLeft,TTop,TWidth,THeight: Integer; xco,yco: Integer; bin: Integer; bincolor: TColor); overload;
    destructor Destroy; override;
end;




implementation



////////////////////////////////////////////////////////////////////////////////
constructor TMyPB.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
end;


////////////////////////////////////////////////////////////////////////////////
constructor TMyPB.Create(AOwner: TComponent; TLeft,TTop,TWidth,THeight: Integer; xco,yco: Integer; bin: Integer; bincolor: TColor);
begin
  inherited Create(AOwner);
  Left :=TLeft;
  Top :=TTop;
  Width :=TWidth;
  Height :=THeight;
  Color :=bincolor;
  x :=xco;
  y :=yco;
[COLOR="Yellow"] OnPaint :=Mypaint;[/COLOR]
end;


////////////////////////////////////////////////////////////////////////////////
destructor TMyPB.Destroy;
begin
  inherited Destroy;
end;


////////////////////////////////////////////////////////////////////////////////
procedure TMyPB.Mypaint(Sender: TObject);
begin
  TMyPB(Sender).Canvas.FillRect(TMyPB(Sender).Canvas.ClipRect);
end;


end.

Geändert von hochundweit (16. Mär 2016 um 14:47 Uhr)
  Mit Zitat antworten Zitat