[lazarus] CreateComponent

Samuel Liddicott sam at campbellsci.co.uk
Tue Aug 17 03:49:26 EDT 1999




> -----Original Message-----
> From: Jeff Wormsley [mailto:daworm at cdc.net]
> Sent: 16 August 1999 06:11 PM
> To: lazarus at miraclec.com
> Subject: RE: RE: [lazarus] CreateComponent
>
>
> On 8/16/99, at 5:25 PM, Samuel Liddicott wrote:
>
> >Is a FHandle supposed to be equivalent to a FComponent ?
> >
> >I mean it seems like under GTK FComponent is the reference to the "real"
> >control, under windows FHandle is the "real" control - do we
> have one that
> >applies to both?
>
> I have been using FComponent as the Hwnd to the WindowsAPI
> functions, since that seemed the closest equivalent to what GTK
> was doing.  I don't remember right off hand, but is FHandle
> visible to a TWinControl, or is it private to TControl?

FHandle is private, but
  protected
    property WindowHandle: HWnd read FHandle write FHandle;

So this is the favoured mechanism for a control finding out its own handle
WITHOUT creating it if it doesn't exist.

For something else to find out the handle of a window, use .Handle - but
this will create it if not already created, so to do so without creating do:

If WinControl.HandleAllocated then
  Result:=WinControl.Handle
else
  Result:=0;

> We do
> need to work out a clear method of handling the window handle,
> owner and parent for this.  What I have done so far has been to
> put the window handle in FComponent, and store self in the HWnd
> structure with SetProp.

Oh.  Good.  I wasn't sure if GTK allowed setprop.

> But this still leaves the question of
> Parent open.  I was planning to use self to find the parent HWnd,
> then GetProp on that HWnd to find the parent's self, but haben't
> had time to work on that.

In what circumstance are you doing this?  Why not just use the "parent"
property?

> The thing that keeps tripping me up is
> the diferences between handling LM_xxx messages recieved via
> SendMessage and handling WM_Messages recieved in the WindoProc.
> LM_xxx messages get a pointer to the LCL object, which has the
> HWnd stored in FComponent.  WM_xxx messages get the HWnd, which
> has the pointer to the LCL object in the !
> propertiy available from GetProp.

Do you use FindControl to get this LCL object?  I don't know how to do this
getprop stuff (GTK is totally new to me, winapi is not) - could you write a
function called FindControl(Hwnd) whch returns a TWinControl or nil for me
please?

> I think with that information,
> everything that needs to be done in either case can be
> determined, but whether this is the best method or not I do not
> know.  Any ideas would be appreciated, as I plan to get back into
> it tonight.  I haven't had time in the last few days.

I think the callback function ought to lookup the hwnd (as it can) and then
call the wndproc as if it were a WM message.  This is neccessary for other
reasons I gave in another post whose subject escapes me right now.

Sam






More information about the Lazarus mailing list