[lazarus] Creating Components...

Shane Miller smiller at lakefield.net
Wed Aug 11 22:42:58 EDT 1999




>Looking a bit deeper, I see that the button is created in the Form's
>oncreate event passing Self.  I would have thought that Self would refer to
>the Form, but instead it is referring to the button.  Didn't someone else
>have this problem recently?  Do you recall their fix?
>
>Jeff.

The button is created in the Forms OnCreate?  The Button is created where
ever the user puts the Button := TButton.Create(Owner).  Owner is set to the
Form that the TButton is owned by.

If the stdcontrols (or where ever the TButton class is defined) it should
eventually call SendMessage3 sending the SELF (which in this case is the
button).

The button should have it's parent assigned already in Control.Create or
TWinControl.Create.
You may need to look at the difference of "owner" and "Parent".  Parent is
used in TControl to hold the TWinControl I believe, so I think you should
use owner.

If Owner is set in TControl's create (which is called whne tbutton calls the
inherited creates) then by the time the sendmessage is called, FOwner is
set.

In win32int.pp (or whatever) you recieve this message (LM_CREATE) call
Createcomponent.  When you case the fcompstyle and determine it's a
csButton, you can also check TControl(data).Owner.handle (or whatever) to
get it's owners handle.

Shane







More information about the Lazarus mailing list