Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-03

Hint about CreateWnd

15 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

zeljko

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 ?

Reply by email

Mattias Gaertner
to zeljko
Show quoted text 7 lines
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

Reply by email

Paul Ishenin
to zeljko: I'm creating an customized control, and have such hint when creating form with such…
zeljko wrote 8 lines
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 ?

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.

Reply by email

zeljko
to Paul Ishenin
Paul Ishenin wrote 13 lines
zeljko wrote: > 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 ? better to use if HandleAllocated then DoSomeOperationWith(Handle)

This is exact what I'm using, and got that bad HINT message.

Show quoted text 11 lines
Handle will be created when your control become visible - before that you should not use Handle property. Best regards, Paul Ishenin. _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Mattias Gaertner
to zeljko
Show quoted text 16 lines
On Saturday 01 March 2008 13:53, Paul Ishenin wrote: > zeljko wrote: > > 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 ? > > better to use > > if HandleAllocated then > DoSomeOperationWith(Handle) 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

Reply by email

Luiz Americo Pereira Camara
to Mattias Gaertner: On Sat, 1 Mar 2008 13:14:05 +0100 It's bad. It creates a lot of unneeded overhead. As…
Mattias Gaertner wrote 22 lines
On Sat, 1 Mar 2008 13:14:05 +0100 zeljko wrote: > 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.

Is allowed to access event?

Luiz

Reply by email

zeljko
to zeljko
zeljko wrote 10 lines
On Saturday 01 March 2008 14:52, Mattias Gaertner wrote: > Replace > DoSomeOperationWith(Handle) > with > DoSomeOperationThatNeedsAHandle; > > For example any Canvas operation needs a handle. 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.

Reply by email

Mattias Gaertner
to zeljko: tnx, I've found Loaded() satisfies my needs - for runtime, but Loaded() isnt' called…
Show quoted text 10 lines
On Saturday 01 March 2008 14:52, Mattias Gaertner wrote: > Replace > DoSomeOperationWith(Handle) > with > DoSomeOperationThatNeedsAHandle; > > For example any Canvas operation needs a handle. tnx, I've found Loaded() satisfies my needs - for runtime, but Loaded() isnt' called during design time ? so ... what to call here ?

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

Reply by email

Mattias Gaertner
to Luiz Americo Pereira Camara: Is allowed to access event? Luiz
Show quoted text 25 lines
Mattias Gaertner wrote: > On Sat, 1 Mar 2008 13:14:05 +0100 > zeljko wrote: > > >> 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. > Is allowed to access event?

Yes, with 'if HandleAllocated then'.

Mattias

Reply by email

Mattias Gaertner
to zeljko: error ! it is called during design time, but not first time when I drop new control on to…
Show quoted text 17 lines
On Saturday 01 March 2008 15:44, zeljko wrote: > On Saturday 01 March 2008 14:52, Mattias Gaertner wrote: > > Replace > > DoSomeOperationWith(Handle) > > with > > DoSomeOperationThatNeedsAHandle; > > > > For example any Canvas operation needs a handle. > > 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.

Maybe what you search a method, when your control got a Handle? It's CreateWnd. Override that.

Mattias

Reply by email

zeljko
to Mattias Gaertner: On Sat, 1 Mar 2008 15:44:55 +0100 I hope, you mean 'override' not to 'call'. Loaded must…
Mattias Gaertner wrote 15 lines
On Sat, 1 Mar 2008 15:44:55 +0100 zeljko wrote: > On Saturday 01 March 2008 14:52, Mattias Gaertner wrote: > > Replace > > DoSomeOperationWith(Handle) > > with > > DoSomeOperationThatNeedsAHandle; > > > > For example any Canvas operation needs a handle. > > tnx, I've found Loaded() satisfies my needs - for runtime, but > Loaded() isnt' called during design time ? so ... what to call here ? I hope, you mean 'override' not to 'call'.

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.

Reply by email

Mattias Gaertner
to zeljko
Show quoted text 27 lines
On Saturday 01 March 2008 16:07, Mattias Gaertner wrote: > On Sat, 1 Mar 2008 15:44:55 +0100 > > zeljko wrote: > > On Saturday 01 March 2008 14:52, Mattias Gaertner wrote: > > > Replace > > > DoSomeOperationWith(Handle) > > > with > > > DoSomeOperationThatNeedsAHandle; > > > > > > For example any Canvas operation needs a handle. > > > > tnx, I've found Loaded() satisfies my needs - for runtime, but > > Loaded() isnt' called during design time ? so ... what to call > > here ? > > I hope, you mean 'override' not to 'call'. 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

Reply by email

zeljko
to Mattias Gaertner
Mattias Gaertner wrote 35 lines
On Sat, 1 Mar 2008 16:37:35 +0100 zeljko wrote: > On Saturday 01 March 2008 16:07, Mattias Gaertner wrote: > > On Sat, 1 Mar 2008 15:44:55 +0100 > > > > zeljko wrote: > > > On Saturday 01 March 2008 14:52, Mattias Gaertner wrote: > > > > Replace > > > > DoSomeOperationWith(Handle) > > > > with > > > > DoSomeOperationThatNeedsAHandle; > > > > > > > > For example any Canvas operation needs a handle. > > > > > > tnx, I've found Loaded() satisfies my needs - for runtime, but > > > Loaded() isnt' called during design time ? so ... what to call > > > here ? > > > > I hope, you mean 'override' not to 'call'. > > 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.

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.

Reply by email

Mattias Gaertner
to zeljko
Show quoted text 45 lines
On Saturday 01 March 2008 18:23, Mattias Gaertner wrote: > On Sat, 1 Mar 2008 16:37:35 +0100 > > zeljko wrote: > > On Saturday 01 March 2008 16:07, Mattias Gaertner wrote: > > > On Sat, 1 Mar 2008 15:44:55 +0100 > > > > > > zeljko wrote: > > > > On Saturday 01 March 2008 14:52, Mattias Gaertner wrote: > > > > > Replace > > > > > DoSomeOperationWith(Handle) > > > > > with > > > > > DoSomeOperationThatNeedsAHandle; > > > > > > > > > > For example any Canvas operation needs a handle. > > > > > > > > tnx, I've found Loaded() satisfies my needs - for runtime, but > > > > Loaded() isnt' called during design time ? so ... what to call > > > > here ? > > > > > > I hope, you mean 'override' not to 'call'. > > > > 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. 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

Reply by email