[lazarus] Creating Components...

Michael A. Hess mhess at miraclec.com
Wed Aug 11 23:03:27 EDT 1999


Shane Miller wrote:
> 
> 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 you are using helloform.pp then the button is created in the
Forms.Create constructor not in the OnCreate event handler. If you
notice it follows the inherited Create for the form so all of the Form
information has been established and the Self that is passed to the
TButton.Create(Self); is setting the buttons owner to the Form.

> 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).

Again if you look in buttons.inc you will see that in the TButton.Create
it first calls inherited Create which establishes everything for this
object including setting the owner information. After everything is
created then the CreatComponent method is called. Currently the method
still asks for the Owner to be passed but this has been depricated and
isn't needed any more.
 
> 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.

As Shane indicates all you need to do is use the Sender data being sent
to SendMessage to drill down and find the Senders owner which in your
case will be the form. From that you can get the fComponent of the owner
which will be the HWND which is the Window Handle of the owner control.

Just really repeating what Shane already said.   :-)

-- 
==== Programming my first best destiny! ====

Michael A. Hess      Miracle Concepts, Inc.
mhess at miraclec.com   http://www.miraclec.com






More information about the Lazarus mailing list