[lazarus] Problem found and solved

Michael Van Canneyt michael.vancanneyt at wisa.be
Wed Jun 30 03:50:25 EDT 1999




On Tue, 29 Jun 1999, Shane Miller wrote:

> Could someone please pull the source from CVS and take a look at this
> problem and see if you can find a way to make this work?  I'm having
> trouble with it.  2 things you need to do after pulling the latest version:
> 
> Uncomment (if it's commented out yet) the AssignOwnEvents method in the
> TMemo.Create procedure in stdcontrols.pp and in editor.pp go to the
> Memo1Change procedure and tell it to writeln(Caption) or something
> so you can see that when you try to access anything throuigh "SELF"
> that it throws an exception.  

The solution is documented in the new manuals. We now support the
following construct:

Procedure TMyObject.MyCallback (Var Var1: Type1;Self : TMyObject); message 'changed'; cdecl;

begin
  // This will load self from the second parameter.
end;

So you declare your callback function with the correct number of arguments,
(so it matches the gtk_signal_func) and then you do a

gtk_signal_connect(gtk_object(fcomponent),'changed',gtk_signal_func(MyCallback),Self)

Self will be passed through the 'self' argument.

This was implemented especially for GTK and QT; see the docs for more info.

If it isn't clear, just ask.

Michael.







More information about the Lazarus mailing list