Re: When to create TCustomControl's child controls?




Riaan wrote:
> I need the dimensions in order to size the child controls on creation.
> How do I go about accomplishing this? I'm having to create resizing
> code for each child object on WM_SIZE, and this is not how it's
> supposed to be, I think. The properties and capabilities of the
> controls should be able to do the work for me automatically.

I generally create sub controls in the constructor, another place you
can do it is in the Loaded event.
You will have to handle resizing anyway since your control can be
resized both in the IDE and at run time.

> P.S. I've read that it is safer to give NIL as the owner, (i.e.
> fChildPanel := TPanel.Create(nil)).
No this is not really true. I would use 'self' as the owner, then you
don't have to worry about destroying the controls later.

--
Marc

.



Relevant Pages

  • Object Reference Error. Pls Help!
    ... controls of the custom control are added dynamically at runtime. ... all the child controls are ... private string _selectedViewId; ... protected override void OnInit{ ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Object Reference Error. Pls Help!
    ... controls of the custom control are added dynamically at runtime. ... all the child controls are ... private string _selectedViewId; ... protected override void OnInit{ ...
    (microsoft.public.dotnet.framework.aspnet.buildingcontrols)
  • Re: composite controls... Microsoft Press: Dev ASP.NET Server Controls
    ... This is great if periodic downtime is ok. ... When I started writing composite controls, ... the forwarding of properties to a child controls. ... then creating them in OnInit should be adequate. ...
    (microsoft.public.dotnet.framework.aspnet.buildingcontrols)
  • Re: composite controls... Microsoft Press: Dev ASP.NET Server Controls
    ... This is great if periodic downtime is ok. ... When I started writing composite controls, ... the forwarding of properties to a child controls. ... then creating them in OnInit should be adequate. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: composite controls... Microsoft Press: Dev ASP.NET Server Controls
    ... the parent, when they're forwarded properties. ... try out some of these controls that have been written using just OnInit to ... the forwarding of properties to a child controls. ... then creating them in OnInit should be adequate. ...
    (microsoft.public.dotnet.framework.aspnet)