[lazarus] Problem found

Shane Miller smiller at lakefield.net
Mon Jun 28 23:08:26 EDT 1999


Found a problem:
I have set up TMemo to use the "changed" signal and when GTK fires that
signal I do :
If assigned FChanged then FChanged(Self);

In Editor.pp I have a function called Memo1Change(Sender : TObject);
It gets called when the TMemo class calls FChanged(Self);

The problem is that when your in TEditor.Memo1Change, it no longer has any
reference to TEditor's properties (like it's caption, left and top values,
etc) and if you try to access Memo1 which is a child of TEditor, an
exception is thrown.
Obviously when the callback is used, the connection to self is lost and
therefore it's children no longer retain their values.

Any thoughts on a solution?
Feel free to look at the code.
 Go into stdcontrols.pp and look at TMemo's create.
 It has a function commented out called AssignOwnEvents. remove the comments
and save the file.
Now go into the editor.pp file and go to the procedure Memo1Change and add
some code like

Writeln('The caption of the editor is '+Caption);

Compile and run.  When you OPEN a file, click on the memo.  Then press a key
and the onchange event should fire.  You'll notice the exception occurs
there.......please help!


Shane







More information about the Lazarus mailing list