Ошибки при создании компонента

Вопросы программирования и использования среды Lazarus.

Модератор: Модераторы

Ответить
Аватара пользователя
whs
новенький
Сообщения: 28
Зарегистрирован: 03.04.2010 18:07:44

Ошибки при создании компонента

Сообщение whs »

Решил опробовать создание компонентов для Lazarus, но видать что-то не до конца понимаю.

Код: Выделить всё

unit ScrollingCredits;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources,Forms, Controls, Graphics, Dialogs,ExtCtrls;

type

  { TScrollingCredits }
  TCreditEvent = procedure(Sender : TObject; CreditText : String) of object;
  TScrollingCredits = class(TGraphicControl)
  private
    FAfterLastCredit: TNotifyEvent;
    FAnimate: Boolean;
    FBackgroundColor: TColor;
    FBackgroundImage: TPicture;
    FBorderColor: TColor;
    FCredits: TStringList;
    FFont: TFont;
    FTimer: TTimer;
    FBitmap: TBitmap;
    YPos: Integer;
    TPos: Integer;
    FInterval: Cardinal;
    FOnShowCredit: TCreditEvent;
    FShowBorder: boolean;
    FVisible: Boolean;
    procedure SetAnimate(const AValue: Boolean);
    procedure ResetAnimation;
    procedure SetBackgroundColor(const AValue: TColor);
    procedure SetBackgroundImage(const AValue: TPicture);
    procedure SetBorderColor(const AValue: TColor);
    procedure SetCredits(const AValue: TStringList);
    procedure SetFont(const AValue: TFont);
    procedure SetInterval(const AValue: Cardinal);
    procedure SetPicture(const AValue: TPicture);
    procedure SetShowBorder(const AValue: boolean);
    procedure SetVisible(const AValue: Boolean);
    procedure BackgroundImageChanged(Sender : TObject);
    { Private declarations }
  protected
    { Protected declarations }
  public
    constructor Create(TheOwner: TComponent); override;
    destructor Destroy; override;
    procedure Paint; override;
    procedure TimerFired(Sender : TObject);
    procedure Reset;
    { Public declarations }
  published
    property Credits:TStringList read FCredits write SetCredits;
    property CreditsFont: TFont read FFont write SetFont;
    property BackgroundColor: TColor read FBackgroundColor write SetBackgroundColor;
    property BorderColor: TColor read FBorderColor write SetBorderColor;
    property Animate: Boolean read FAnimate write SetAnimate;
    property Interval: Cardinal read FInterval write SetInterval;
    property OnShowCredit: TCreditEvent read FOnShowCredit write FOnShowCredit;
    property AfterLastCredit: TNotifyEvent read FAfterLastCredit write FAfterLastCredit;
    property Visible: Boolean read FVisible write SetVisible default True;
    property BackgroundImage: TPicture read FBackgroundImage write SetBackgroundImage;
    property ShowBorder: boolean read FShowBorder write SetShowBorder;
    property OnClick;
    property OnDblClick;
    { Published declarations }
  end;

procedure Register;

implementation

procedure Register;
begin
  {$I scrollingcredits_icon.lrs}
  RegisterComponents('Standard',[TScrollingCredits]);
end;

procedure TScrollingCredits.SetAnimate(const AValue: Boolean);
begin
  if FAnimate=AValue then exit;
  FAnimate:=AValue;
end;

procedure TScrollingCredits.SetBackgroundColor(const AValue: TColor);
begin
  if FBackgroundColor=AValue then exit;
  FBackgroundColor:=AValue;
end;

procedure TScrollingCredits.SetBackgroundImage(const AValue: TPicture);
begin
  if FBackgroundImage=AValue then exit;
  FBackgroundImage:=AValue;
end;

procedure TScrollingCredits.SetBorderColor(const AValue: TColor);
begin
  if FBorderColor=AValue then exit;
  FBorderColor:=AValue;
end;

procedure TScrollingCredits.SetCredits(const AValue: TStringList);
begin
  if FCredits=AValue then exit;
  FCredits:=AValue;
end;

procedure TScrollingCredits.SetFont(const AValue: TFont);
begin
  if FFont=AValue then exit;
  FFont:=AValue;
end;

procedure TScrollingCredits.SetInterval(const AValue: Cardinal);
begin
  if FInterval=AValue then exit;
  FInterval:=AValue;
end;

procedure TScrollingCredits.SetShowBorder(const AValue: boolean);
begin
  if FShowBorder=AValue then exit;
  FShowBorder:=AValue;
end;

procedure TScrollingCredits.SetVisible(const AValue: Boolean);
begin
  if FVisible=AValue then exit;
  FVisible:=AValue;
end;

constructor TScrollingCredits.Create(TheOwner: TComponent);
begin
  inherited Create(TheOwner);
 Width := 305;
 Height := 201;
 FCredits := TStringList.Create;
 FFont := TFont.Create;
 FTimer := TTimer.Create(Self);
 FBitmap := TBitmap.Create;
 FCredits.Add('Test Component');
 FFont.Color := clWhite;
 FFont.Name := 'Tahoma';
 FTimer.Interval := 50;
 FTimer.Enabled := False;
 //FTimer.OnTimer := TimerFired;
 FBitmap.Width := Width;
 FBitmap.Height := Height;
 FBackgroundColor := clBlack;
 FBorderColor := clWhite;
 FAnimate := False;
 FInterval := 50;
 YPos := 4;
 TPos := 0;
 FVisible := True;
 FBackgroundImage := TPicture.Create;
 //FBackgroundImage.OnChange:=BackgroundImageChanged;
 FShowBorder := True;
end;

destructor TScrollingCredits.Destroy;
begin
  inherited Destroy;
end;

procedure TScrollingCredits.Paint;
begin
  inherited Paint;
end;


procedure TScrollingCredits.TimerFired(Sender: TObject);
begin

end;

procedure TScrollingCredits.Reset;
begin

end;


{ TScrollingCredits }



end.


Я что то неправильно делаю но что не понимаю, в Delphi все работало, а здесь ругается.
Mr.Smart
долгожитель
Сообщения: 1796
Зарегистрирован: 29.03.2008 00:01:11
Откуда: из леса!

Сообщение Mr.Smart »

whs код читать лень. А где же всё таки текст ругань?
Аватара пользователя
whs
новенький
Сообщения: 28
Зарегистрирован: 03.04.2010 18:07:44

Сообщение whs »

Mr.Smart писал(а):whs код читать лень. А где же всё таки текст ругань?


(41,15)Warning: An inherited method is hidden by "TScrollingCredits.SetVisible(const Boolean);"
(148,30) Error: Wrong number of parameters specified for call to "TimerFired"
(50,15) Hint: Found declaration: TScrollingCredits.TimerFired(TObject);
(159,51) Error: Wrong number of parameters specified for call to "BackgroundImageChanged"
(42,15) Hint: Found declaration: TScrollingCredits.BackgroundImageChanged(TObject);
(190) Fatal: There were 2 errors compiling module, stopping
Mr.Smart
долгожитель
Сообщения: 1796
Зарегистрирован: 29.03.2008 00:01:11
Откуда: из леса!

Сообщение Mr.Smart »

whs Как то ошибки не соответствуют приведённым выше.

Код: Выделить всё

unit1.pas(53,15) Warning: An inherited method is hidden by "TScrollingCredits.SetVisible(const Boolean);"
unit1.pas(44,15) Error: Forward declaration not solved "TScrollingCredits.ResetAnimation;"
unit1.pas(51,15) Error: Forward declaration not solved "TScrollingCredits.SetPicture(const TPicture);"
unit1.pas(54,15) Error: Forward declaration not solved "TScrollingCredits.BackgroundImageChanged(TObject);"
unit1.pas(195) Fatal: There were 3 errors compiling module, stopping
Аватара пользователя
whs
новенький
Сообщения: 28
Зарегистрирован: 03.04.2010 18:07:44

Сообщение whs »

Mr.Smart писал(а):whs Как то ошибки не соответствуют приведённым выше.

Код: Выделить всё

unit1.pas(53,15) Warning: An inherited method is hidden by "TScrollingCredits.SetVisible(const Boolean);"
unit1.pas(44,15) Error: Forward declaration not solved "TScrollingCredits.ResetAnimation;"
unit1.pas(51,15) Error: Forward declaration not solved "TScrollingCredits.SetPicture(const TPicture);"
unit1.pas(54,15) Error: Forward declaration not solved "TScrollingCredits.BackgroundImageChanged(TObject);"
unit1.pas(195) Fatal: There were 3 errors compiling module, stopping


Код не комментировать, тогда полностью соответствует.

P.S Проблема решена. RTFM.
Ответить