Modal Form and Paint problem 
Author Message
 Modal Form and Paint problem

Much of appearance of my forms are drawn in run time, with various
techniques: Bitblt, VB Functions (Print, Line).
The problem occurs when a modal form is open. If the user drags the modal
form around, the underlying form is not repainted.

Is there any solution without using DoEvents?

Thanks,
Paulo Jean



Wed, 02 Mar 2005 05:46:17 GMT  
 Modal Form and Paint problem

Quote:
> Much of appearance of my forms are drawn in run time, with various
> techniques: Bitblt, VB Functions (Print, Line).
> The problem occurs when a modal form is open. If the user drags the modal
> form around, the underlying form is not repainted.

Set the AutoRedraw property of the underlying form to True.  If may be worth
doing this anyway if you're doing a lot of complicated redraws, the API can
handle simple Bitmap copying far faster.
Hope this helps,

    Mike

 -- EDais --

 - Microsoft Visual Basic MVP -
WWW: Http://EDais.earlsoft.co.uk/




Wed, 02 Mar 2005 05:43:45 GMT  
 Modal Form and Paint problem
Hi,

Just a note regarding using the Form AutoRedraw property...

From what I've been told, each visible Form with AutoRedraw set True will
require equivalent memory of the full screen resolution and color depth to
hold the persistent bitmap (so a single Form on a 1600x1200x32 display will
require 7.5MB, two Forms 15MB, four Forms 30MB, etc.)

One work-around to this that I have seen mentioned (but never tried) is to
place a PictureBox into the Form client region and place all Controls into
that along with any required custom drawing.  This reduces memory
requirements since a PictureBox only requires memory as per its actual size.

Any correctional posts are welcome...

David
lilchips.com



Quote:
> > Much of appearance of my forms are drawn in run time, with various
> > techniques: Bitblt, VB Functions (Print, Line).
> > The problem occurs when a modal form is open. If the user drags the
modal
> > form around, the underlying form is not repainted.

> Set the AutoRedraw property of the underlying form to True.  If may be
worth
> doing this anyway if you're doing a lot of complicated redraws, the API
can
> handle simple Bitmap copying far faster.
> Hope this helps,

>     Mike

>  -- EDais --

>  - Microsoft Visual Basic MVP -
> WWW: Http://EDais.earlsoft.co.uk/





Wed, 02 Mar 2005 06:11:22 GMT  
 Modal Form and Paint problem
Thanks.

Doesn't this consume lots of memory?

Is there any way to call the repaint routine?  The redraws are not that
complicated.

Paulo Jean



Quote:
> > Much of appearance of my forms are drawn in run time, with various
> > techniques: Bitblt, VB Functions (Print, Line).
> > The problem occurs when a modal form is open. If the user drags the
modal
> > form around, the underlying form is not repainted.

> Set the AutoRedraw property of the underlying form to True.  If may be
worth
> doing this anyway if you're doing a lot of complicated redraws, the API
can
> handle simple Bitmap copying far faster.
> Hope this helps,

>     Mike

>  -- EDais --

>  - Microsoft Visual Basic MVP -
> WWW: Http://EDais.earlsoft.co.uk/





Wed, 02 Mar 2005 06:29:41 GMT  
 Modal Form and Paint problem

Quote:
> Doesn't this consume lots of memory?

A little, yes however the reduction in processor usage from the redrawing is
often worth it.  You could also enable AutoRedraw while the form is being
displayed and disable it again when the form receives focus again.

Quote:
> Is there any way to call the repaint routine?  The redraws are not that
> complicated.

Yep, use the RedrawWindow() API but it may not work properly on a modal
form.  I do agree though that using a picture box or usercontrol rather than
a form would be far less memory, unless of course your form is the same size
as the screen.

    Mike

 -- EDais --

 - Microsoft Visual Basic MVP -
WWW: Http://EDais.earlsoft.co.uk/




Wed, 02 Mar 2005 06:54:26 GMT  
 Modal Form and Paint problem


Quote:
>From what I've been told, each visible Form with AutoRedraw set True will
>require equivalent memory of the full screen resolution and color depth to
>hold the persistent bitmap (so a single Form on a 1600x1200x32 display will
>require 7.5MB, two Forms 15MB, four Forms 30MB, etc.)

It doesn't actually have anything to do with AutoRedraw.

A loaded _Resizable_ Form, invisible or not, has a persistent .Image
bitmap the size of the DeskTop irrespective of the AutoRedraw setting.
This persistent bitmap has a color set by Form.BackColor.
Setting AutoRedraw just means that anything drawn to the Client Area is
drawn to the matching area in the persistent .Image bitmap instead of
another, non-persistent, canvas. Actually even that last statement isn't
literally true, but it serves as a behaviour model.

Making a Form non-resizable will give behaviour similar to a PictureBox
as far as image size and AutoRedraw are concerned.

Quote:
>One work-around to this that I have seen mentioned (but never tried) is to
>place a PictureBox into the Form client region and place all Controls into
>that along with any required custom drawing.  This reduces memory
>requirements since a PictureBox only requires memory as per its actual size.

Sorry, there is no workaround and adding a PictureBox will increase
memory requirement. Also a PictureBox doesn't always only require memory
as per its actual size, but that's another story :-)

--
Richard Mason



Wed, 02 Mar 2005 12:13:43 GMT  
 Modal Form and Paint problem

com.br> writes

Quote:
>Much of appearance of my forms are drawn in run time, with various
>techniques: Bitblt, VB Functions (Print, Line).
>The problem occurs when a modal form is open. If the user drags the modal
>form around, the underlying form is not repainted.

If you don't have AutoRedraw True then dragging any Window, Modal or
not, over the underlying Form will erase what's you've drawn. The fact
that an erase takes place means that the underlying Form's Form_Paint
will be fired so either put your drawing commands directly in
Form_Paint, or call your drawing Sub/Function from there.

The Paint Event and AutoRedraw are mutually exclusive.

--
Richard Mason



Wed, 02 Mar 2005 13:10:19 GMT  
 Modal Form and Paint problem
Hi Richard,

Thanks for straightening that out.
I'll try to keep that in mind in the future.

David
lilchips.com


Quote:


> >From what I've been told, each visible Form with AutoRedraw set True will
> >require equivalent memory of the full screen resolution and color depth
to
> >hold the persistent bitmap (so a single Form on a 1600x1200x32 display
will
> >require 7.5MB, two Forms 15MB, four Forms 30MB, etc.)

> It doesn't actually have anything to do with AutoRedraw.

> A loaded _Resizable_ Form, invisible or not, has a persistent .Image
> bitmap the size of the DeskTop irrespective of the AutoRedraw setting.
> This persistent bitmap has a color set by Form.BackColor.
> Setting AutoRedraw just means that anything drawn to the Client Area is
> drawn to the matching area in the persistent .Image bitmap instead of
> another, non-persistent, canvas. Actually even that last statement isn't
> literally true, but it serves as a behaviour model.

> Making a Form non-resizable will give behaviour similar to a PictureBox
> as far as image size and AutoRedraw are concerned.

> >One work-around to this that I have seen mentioned (but never tried) is
to
> >place a PictureBox into the Form client region and place all Controls
into
> >that along with any required custom drawing.  This reduces memory
> >requirements since a PictureBox only requires memory as per its actual
size.

> Sorry, there is no workaround and adding a PictureBox will increase
> memory requirement. Also a PictureBox doesn't always only require memory
> as per its actual size, but that's another story :-)

> --
> Richard Mason



Wed, 02 Mar 2005 13:50:51 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Problem with draw order after calling modal a modal from from a modal form

2. How can I paint a Picture in a Form in a Form Paint method

3. MODAL FORM & NON MODAL FORM

4. Unloading modal owner form also unloads modal form?

5. Modal Form with Modal form using Control?

6. MODAL FORM & NON MODAL FORM

7. Modal Form can't open another Modal Form

8. MODAL FORM & NON MODAL FORM

9. non-modal form when a modal form is displayed

10. MODAL FORM & NON MODAL FORM

11. Loading a Modal Form from a Modal Form

12. Hidden MDI form with Modal Login Form Problems

 

 
Powered by phpBB® Forum Software