Link to home
Start Free TrialLog in
Avatar of ozeegers
ozeegers

asked on

prevent screen-flickering? HOW?

I would like to prevent the user from seeing the screen updating itself:

I have 1 mainform (Main) en let's say 2 'child'forms (it's not an MDI app).
The 2 'child'forms contain a lot of controls (24 editboxes, 30 labels, 1 listbox, 1 combobox, several buttons, 9 checkboxes, 9 spinedits, 3 groupboxes).
On my mainform there is are two buttons (one for each 'child'-form). When you press the button for 'child'form1 'child'form1 is created within the mainform.

PROBLEM:
~~~~~~~

When I switch between the two 'child' forms (via the buttons) you can see the controls being painted:
first the white boxes, then the lines and text.
How do I prevent this? I want the screen to popup at once when all the drawing is finished.

On the ATARI (years ago!) I let everything being painted on an offscreen bitmap. After all the painting was done I copied the bitmap to the screen...!

How do I do this in Delphi? How are the events working (onpaint, WMPAINT)?
createcompatibleBitmap/createCompatibleDC?

Thanx a million for your reaction!
ASKER CERTIFIED SOLUTION
Avatar of icampbe1
icampbe1

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ozeegers
ozeegers

ASKER

Thank you for your quick answer.
I'm not so sure if it helps me any further. I'm not an expert in Delphi so..........
I am destroying my forms in order to keep resource consumption low (the user is able to choose between 30 forms to add to his list; the average user will add 10 forms to the list, so 10 forms with lots of control on is will consume very much resources?).
Could you please write a complete example on how I let windows draw the form on an offscreen bitmap (in memory) first and then copy the bitmap to the screen? I think that will solve the problem because it's not that slow but it's the building up of the control that one can see that is annoying....

Thank you very much in advance,

O.Zeegers
Thank you for your quick answer.
I'm not so sure if it helps me any further. I'm not an expert in Delphi so..........
I am destroying my forms in order to keep resource consumption low (the user is able to choose between 30 forms to add to his list; the average user will add 10 forms to the list, so 10 forms with lots of control on is will consume very much resources?).
Could you please write a complete example on how I let windows draw the form on an offscreen bitmap (in memory) first and then copy the bitmap to the screen? I think that will solve the problem because it's not that slow but it's the building up of the control that one can see that is annoying....

Thank you very much in advance,

O.Zeegers

BTW. What does the field 'incease point to' mean?
The resources used by controls and forms is surprisingly low.  If you want to do a small test, just display the 'InstanceSize' of any object and I'm sure you'll be surprised.  I know when you look at something like a form, it seems big, but you have to remember that it is 'drawn', not a bitmap.

Try:   ShowMessage( IntToStr( Edit1.InstanceSize) );

Or any other object for that matter.  InstanceSize is declared in TObject, so you can use it on any object anywhere, as long as it has been instantiated (who makes up these words?).

With this in mind, you may re-think your ideas about keeping these forms created and ready to go.  It isn't the burden you might think.

Oh yeah, 'increase points to' is used to increase to points that you are offering for a solution in an effort to get someones attention.  Theoretically, the more you offer, the more likely you will have a question answered.  Not at all like the spirit of Christmas.

Cheers,
Ian C.

BTW.  Thanks for the points.
>Could you please write a complete example on how I let windows >draw the form on an offscreen bitmap (in memory) first and then >copy the bitmap to the screen?

please check the source on any errors!

Thanx!
>Could you please write a complete example on how I let windows >draw the form on an offscreen bitmap (in memory) first and then >copy the bitmap to the screen?

please check the source on any errors!

Thanx!
>Could you please write a complete example on how I let windows >draw the form on an offscreen bitmap (in memory) first and then >copy the bitmap to the screen?

please check the source on any errors!

Thanx!
>Could you please write a complete example on how I let windows >draw the form on an offscreen bitmap (in memory) first and then >copy the bitmap to the screen?

please check the source on any errors!

Thanx!
>Could you please write a complete example on how I let
>windows draw the form on an offscreen bitmap (in memory)
>first and then copy the bitmap to the screen?


please check the source on any errors!
Thanx!
Now I see, you stutter....

I know what you're asking for, but that's not how windows does it.  Windows sends a a WM_PAINT message to any control that must paint or draw itself because it must be rendered on the screen.  It isn't your choice per se.  You don't pre-draw, like on a bitmap, and then show it.  Every control on your form is responsible for painting itself as well, and Windows tells it when to do so.

A good portion of the delay you are seeing is the from the PROPERTIES like the lablel.caption and editbox.text being filled in after the constructor has run.   You'll notice that this delay is mostly the 'first time'.

If the main form is the one that's the most annoying, then you can try Application.ShowMainForm := FALSE;  until you are ready to show it, but at least it's ready to go.

I wasn't being evasive when I didn't give you an example of what we did in the old days.  It's just not the same.

Hope this helps a bit more,

Ian C.