Board index » delphi » "Runtime created button"onclick event linking(2)

"Runtime created button"onclick event linking(2)

Hi Dave,
Thanks for such a quick reaction (that's the military efficiency, I
supppose!)

I have tried what you suggested:

{Closing}
Bubu.OnClick := BubuClick ;
{BubuClick(Bubu.Onclick);}
end;

but now, it gives a compilation error with this message:

[Error] Unit1.pas(124): Incompatible types: method pointer and regular
procedure

So what?

Thanks,

JBF.

 

Re:"Runtime created button"onclick event linking(2)


Quote
> Incompatible types: method pointer and regular procedure

Here's an example of a regular procedure:

  procedure BubuClick(Sender: TObject);

Here's an example of a method pointer:

  procedure TForm1.BubuClick(Sender: TObject);

Most (if not all) VCL event handlers *must* be method pointers -- that is, a
method which is part of a class. This is documented in the event type
declaration -- if the event type declaration contains the keywords "of
object" then the handler must be a method pointer, not a regular procedure.
Here's the declaration for TNotifyEvent (which is the type of OnClick):

type TNotifyEvent = procedure (Sender: TObject) of object;

Note the "of object" keywords.

All of this is very clearly documented, with examples, in the Delphi help.
Please read the "procedural types" and following topics.

- Rick

Other Threads