[Lazarus] Error: overloaded identifier "MyButtonsClickHandler" isn't a function
Peter E Williams
foss.game.pascal.developer at iinet.net.au
Wed Sep 1 00:42:48 CEST 2010
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;
}
MyButtonsClickHandler: TButtonClick;
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.SetLayoutDirection := 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)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: buttonlist.pas
Type: text/x-pascal
Size: 12900 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20100901/71f0958b/attachment-0001.pas>
More information about the Lazarus
mailing list