I'm creating an customized control, and have such hint when creating form with such control:
[HINT] TWinControl.CreateWnd creating Handle during loading Form1:TForm1 csDesigning=False
Is this something bad , or I can live with it ?

Mailing lists / lazarus / 2008-03
15 messages · 4 people ·
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
I'm creating an customized control, and have such hint when creating form with such control:
[HINT] TWinControl.CreateWnd creating Handle during loading Form1:TForm1 csDesigning=False
Is this something bad , or I can live with it ?
It's bad.
It creates a lot of unneeded overhead.
As long as the control is csloading, csdestroying or not becomes visible a Handle is not needed and should not be created.
Use 'if csLoading in ComponentState' to find out if it is still loading. Loading is finished when 'procedure Loaded;' is called. You can override that.
Mattias
I'm creating an customized control, and have such hint when creating form with such…
better to use
if HandleAllocated then
DoSomeOperationWith(Handle)Handle will be created when your control become visible - before that you should not use Handle property.
Best regards,
Paul Ishenin.
This is exact what I'm using, and got that bad HINT message.
Replace
DoSomeOperationWith(Handle)
with
DoSomeOperationThatNeedsAHandle;For example any Canvas operation needs a handle.
> Handle will be created when your control become visible - before > that you should not use Handle property.
Mattias
On Sat, 1 Mar 2008 13:14:05 +0100 It's bad. It creates a lot of unneeded overhead. As…
Is allowed to access event?
Luiz
On Sat, 1 Mar 2008 14:16:02 +0100 Replace DoSomeOperationWith(Handle) with…
tnx, I've found Loaded() satisfies my needs - for runtime, but Loaded() isnt' called during design time ? so ... what to call here ?
error ! it is called during design time, but not first time when I drop new control on to form (i can see my control, but without default settings - it's empty) - I've fixed this by overriding UpdateShowing, and calling defaults when HandleAllocated.
tnx, I've found Loaded() satisfies my needs - for runtime, but Loaded() isnt' called…
I hope, you mean 'override' not to 'call'.
Loaded must *only* be called TReader.
Loaded is called during designtime too. Otherwise you found a bug.
Mattias
Is allowed to access event? Luiz
Yes, with 'if HandleAllocated then'.
Mattias
error ! it is called during design time, but not first time when I drop new control on to…
Maybe what you search a method, when your control got a Handle? It's CreateWnd. Override that.
Mattias
On Sat, 1 Mar 2008 15:44:55 +0100 I hope, you mean 'override' not to 'call'. Loaded must…
yes , I mean 'overrde' I don't call Loaded() ;)
Loaded is called during designtime too. Otherwise you found a bug.
Not when you drop control on to form for the first time. Later, when you start that project, then it properly calls Loaded(). So it could be a bug.
I see.
No that's, not a bug. Loaded is called after the lfm data has been transmitted. No lfm data - no Loaded.
If you tell, what you are trying to do, I can tell you what method to override.
Mattias
I'm creating new component on component palette :) (qt only component), everything works fine, bug when I drop it for the first time on the form it doesn't load it's properties (it is QTableWidget), so it have to load rowcount, colcount etc .... it looks empty - no rows, no cols, white colored etc ...(OI is filled OK with props).
After saving project, and restating laz ide (yes, now Loaded() is called) , I can see all clearly.
No problems during runtime, designtime only.
When your QTTableWidget is created it should pull all values from the 'LCL' control. OR: you can override CreateWnd of your LCL control and push all values.
Mattias