Re: When to create TCustomControl's child controls?
- From: "Riaan" <rmoll@xxxxxxxxxxxx>
- Date: 28 Oct 2005 03:51:44 -0700
As I've demonstrated, you can use CreateWND, but then your dimensions
are 0 unless you've specified default values beforehand, which I did in
Create. The advantage of doing it this way is that those values are can
be automatically overridden when the control is streamed in, but are
still available should you choose dynamic creation.
Another, though clunky, method, is to use Paint as your common hook,
although you need a variable and a test for it in Paint, for example:
Type TMyControl = class(TCustomControl);
private
fControlInitialised : Boolean;
Procedure InitControl;
.
protected
Procedure Paint; override;
.
.
end;
..
..
..
Procedure TMyControl.Paint;
begin
if not fControlInitialized then InitControl;
..
..// do your painting as usual
..
end
Procedure TMyControl.InitControl;
begin
// create your objects and so on
.
.
fControlinitialised := true;
end;
As you can see it's not the most efficient way of doing it, although it
might be the most intuitive for novices.
On the other hand, Paint will only be called once the form and the
control becomes visible, so you have to take extra care to make sure
you don't reference those controls before they have been created....
Yep, a recipe for problems.
.
- References:
- When to create TCustomControl's child controls?
- From: Riaan
- Re: When to create TCustomControl's child controls?
- From: alanglloyd
- Re: When to create TCustomControl's child controls?
- From: Riaan
- Re: When to create TCustomControl's child controls?
- From: Riaan
- Re: When to create TCustomControl's child controls?
- From: Bruce Roberts
- When to create TCustomControl's child controls?
- Prev by Date: Re: When to create TCustomControl's child controls?
- Next by Date: Re: Version after Version
- Previous by thread: Re: When to create TCustomControl's child controls?
- Next by thread: Dang 'em Rags
- Index(es):
Relevant Pages
|