[Lazarus] Error: overloaded identifier "MyButtonsClickHandler" isn't a function
ik
idokan at gmail.com
Wed Sep 1 09:38:05 CEST 2010
Please see fixes inline.
http://ik.homelinux.org/
2010/9/1 Peter E Williams <foss.game.pascal.developer at iinet.net.au>
> Hi Lazarus List and Alvaro,
>
> I am trying to write a short test project for buttonlist.pas which is a
> modified version of Ido's untbuttonlist.pas ... but with some extra
> procedures and functions. The problem I am now having is that there is
> no sample project showing how to write a ButtonClick Handler. Lazarus
> complains that it is not a function, although it is declared as a
> procedure.
>
> from buttonlist.pas, type declaration:
> TButtonClick = procedure (Index : Word) of object;
>
> //line 33
> procedure TForm1.MyButtonsClickHandler(index: word);
>
> testunit1.pas(33,39) Error: overloaded identifier
> "MyButtonsClickHandler" isn't a function
> testunit1.pas(33,18) Error: function header doesn't match any method of
> this class "TForm1.MyButtonsClickHandler$33(Word);"
>
> //line 58
> MyButtons.SetLayoutDirection := ldHorizontal;
>
> testunit1.pas(58,13) Error: identifier idents no member
> "SetLayoutDirection"
> testunit1.pas(74) Fatal: There were 3 errors compiling module, stopping
>
> unit testunit1;
>
> {$mode objfpc}{$H+}
>
> interface
>
> uses
> Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics,
> Dialogs,
> StdCtrls, ButtonList;
>
> type
>
> { TForm1 }
>
> TForm1 = class(TForm)
> procedure FormCreate(Sender: TObject);
> private
> { private declarations }
> public
> { public declarations }
> MyButtons: TButtonList;
>
> { from buttonlist.pas
> type
> TLayoutDirection = (ldHorizontal, ldVertical);
> [...]
> TButtonClick = procedure (Index : Word) of object;
> }
>
> procedure MyButtonsClickHandler(Index : Word);
> constructor Create(aOwner: TComponent); override;
> end;
>
> var
> Form1: TForm1;
>
> implementation
>
> { TForm1 }
>
> procedure TForm1.MyButtonsClickHandler(index: word);
> begin
> showmessage( 'You clicked button number ' + inttostr(index) );
> end;
>
> constructor TForm1.Create(aOwner: TComponent);
> begin
> inherited;
> MyButtons.OnButtonClick := @MyButtonsClickHandler;
> end;
>
> procedure TForm1.FormCreate(Sender: TObject);
> var
> b: integer;
>
> const
> max_level = 8;
> max_byte = 255;
> demo = false;
> X_str = 'X';
> O_str = 'O';
> empty_cell = '';
>
> begin
> // MyButtons := TButtonList.Create(self);
>
> MyButtons.LayoutDirection := ldHorizontal;
>
> MyButtons.Count := max_level;
> MyButtons.parent := self;
> MyButtons.visible := True;
>
> for b := 1 to max_level do
> begin
> MyButtons.SetSpecificCaption( b, X_str + inttostr(b) );
> end;
> end;
>
> initialization
> {$I testunit1.lrs}
>
> end.
>
> --
> Proudly developing Quality Cross Platform Open Source Games
> Since 1970 with a Commodore PET 4016 with 16 KRAM
> http://pews-freeware-games.org (<--- brand new)
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20100901/2cfdc1d4/attachment-0004.html>
More information about the Lazarus
mailing list