Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-09

Error: overloaded identifier "MyButtonsClickHandler" isn't a function

8 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Peter E Williams

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.freepascal.org/pipermail/lazarus/attachments/20100901/71f0958b/attachment-0001.bin>

Reply by email

ik
to Peter E Williams

Please see fixes inline.

http://ik.homelinux.org/

2010/9/1 Peter E Williams

Show quoted text 94 lines
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;
Show quoted text 27 lines
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 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100901/2cfdc1d4/attachment.html>

Reply by email

Peter E Williams
to ik

Hi Ido,

ik wrote
Please see fixes inline. http://ik.homelinux.org/

I went to the above URL and I cannot find any "fixes inline". Please provide an exact URL for the new version.

I have a few bug fixes for it to send to you.

Best Regards,
PEW
Hobart, Tasmania, Australia

[...]

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)

Reply by email

Henry Vermaak
to Peter E Williams
Peter E Williams wrote 10 lines
Hi Ido, On Wed, 2010-09-01 at 10:38 +0300, ik wrote: > Please see fixes inline. > > http://ik.homelinux.org/ > I went to the above URL and I cannot find any "fixes inline". Please provide an exact URL for the new version.

He made the changes in the quoted email, just compare them (gmail highlights the changes for me, which is quite useful).

Henry

Reply by email

Peter E Williams
to Henry Vermaak

Hi Ido, Henry and all,

Henry Vermaak wrote 16 lines
On 1 September 2010 09:39, Peter E Williams wrote: > Hi Ido, > > On Wed, 2010-09-01 at 10:38 +0300, ik wrote: >> Please see fixes inline. >> >> http://ik.homelinux.org/ >> > > I went to the above URL and I cannot find any "fixes inline". Please > provide an exact URL for the new version. He made the changes in the quoted email, just compare them (gmail highlights the changes for me, which is quite useful).

I missed those changes, but I have already worked them out for myself :-)))

ps - I don't use gmail so I don't get the changes highlighted.

Henry

Best Regards,
PEW

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)

Reply by email

ik
to Henry Vermaak: On 1 September 2010 09:39, Peter E Williams He made the changes in the quoted email, just…

I've highlighted them in Blue (in HTML version), but I do not know how it looks like in text based email.

Ido

Henry Vermaak wrote 24 lines
On 1 September 2010 09:39, Peter E Williams wrote: > Hi Ido, > > On Wed, 2010-09-01 at 10:38 +0300, ik wrote: >> Please see fixes inline. >> >> http://ik.homelinux.org/ >> > > I went to the above URL and I cannot find any "fixes inline". Please > provide an exact URL for the new version. He made the changes in the quoted email, just compare them (gmail highlights the changes for me, which is quite useful). Henry -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100901/ca2619df/attachment.html>

Reply by email