[Mono-winforms-list] System.Windows.Forms.Form:PaintEventHandler is called only when you increase the form

Alexander Reiter r.alex at utanet.at
Tue Nov 1 16:41:03 EST 2005


Hi again,

   thanks a lot for this information... I was not aware of this default behaviour.
   
best regards,
alex 

Am Dienstag, 1. November 2005 22:08 schrieb Kornél Pál:
> Hi,
> 
> This is the expected behavior of Win32 so this is MS SWF behavior as well
> and it is of course the expected behavior of MWF.
> 
> Windows only stores the bitmap you see on the screen. When a part of a
> window becomes visible either because you uncovered it by moving another one
> or increased its size you have to paint that area but only that area that
> saves memory and speeds up drawing as well.
> 
> As Jackson pointed out if you want to redraw the entire form you have to
> change default behavior. Note that there is a protected Control.ResizeRedraw
> property (Form is a Control). The easiest way to get the behavior you want
> is to add
> 
> this.ResizeRedraw = true;
> 
> to the constructor of the form.
> 
> By using the line
> 
> e.Graphics.Clear(Color.FromKnownColor((KnownColor)((i = (i + 1) % 167) +
> 1)));
> 
> in the Paint event of the form you will see how a window is drawn. Note that
> you will have to have a field named i in the form class.
> 
> Kornél
> 
> ----- Original Message -----
> From: "Jackson Harper" <jackson at ximian.com>
> To: "Alexander Reiter" <r.alex at utanet.at>
> Cc: <mono-winforms-list at lists.ximian.com>
> Sent: Tuesday, November 01, 2005 9:23 PM
> Subject: Re: [Mono-winforms-list]
> System.Windows.Forms.Form:PaintEventHandler is called only when you increase
> the form
> 
> 
> > On Tue, 2005-11-01 at 21:13 +0100, Alexander Reiter wrote:
> >> hi all,
> >>
> >>    I've a problem with the System.Windows.Forms.Form Paint Event. I am
> >> calling the paint event with the following
> >>    line: this.Paint += new PaintEventHandler(Draw_Graphics); the
> >> Draw_Graphics part is simple drawing some
> >>    curves and lines to the Form.
> >>    My problem is now, that as soon as I start to resize the form the
> >> Paint event is only called when I increase the
> >>    form size. When I decrease the size nothing is happening.
> >
> > I believe that is the intended behavoir. Have you tested on windows?
> > You can do a SetStyle (ControlStyles.ResizeRedraw, true) or you can
> > subscribe to the SizeChanged event and do drawing there.
> >
> > Cheers,
> > Jackson
> >
> >
> >>    I just started to get deeper into C# and mono + forms, so any hint
> >> where I can start to search ?
> >>
> >> br
> >> alex
> >> _______________________________________________
> >> Mono-winforms-list maillist  -  Mono-winforms-list at lists.ximian.com
> >> http://lists.ximian.com/mailman/listinfo/mono-winforms-list
> >
> > _______________________________________________
> > Mono-winforms-list maillist  -  Mono-winforms-list at lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-winforms-list
> >
> 
> 
> 

-- 
---------------------
Alexander Reiter
Allentsteigerstr. 11
A-3910 Zwettl
Tel.: 02822 / 51657
---------------------


More information about the Mono-winforms-list mailing list