List Info

Thread: RE: invalidate and paint clip rectangle




RE: invalidate and paint clip rectangle
user name
2006-03-23 11:30:07
I don't think Parent.Invalidate( rect , true ) will
translate the rect
and call a Child.Invalidate( rect , true ), I think it just
calls
Child.Invalidate(true) for any control within the rect,
hence the clip
is set to the client area of the control.

If that's true then panel[B] invalidate clip should = its
client
area.....





-----Original Message-----
From: Discussion forum for developers using Windows Forms to
build apps
and controls [mailtoOTNET-WI
NFORMSDISCUSS.DEVELOP.COM] On Behalf Of
adam
Sent: 23-03-2006 11:07
To: DOTNET-WINFORMSDISCUSS.DEVELOP.COM
Subject: invalidate and paint clip rectangle

Summary: I call invalidate with a rectangle but the clip
rect in the
paint event is the full client area.


I have a user control with this control containment
hierarchy;

My User control [A]
  |
  +- Panel [B]
      |
      +- Panel [C]

as things need to be re-drawn (on [C]) I either call
[C].Invalidate(rect) or [A].Invalidate(rect, true) to get
the children
painted. Which one I call depends on what I have access to.

I have provided overrides [1] to debug calls to invalidate.
These always
give a rect of the expected size. However my trace point [2]
on the
paint event handler for [C] always gives the full client
area of [C] as
the clip rect.

I'm stumped as to how to fix it or even find out where the
problem lies.

adam

[1] implemented in [A],[B],[C]
protected override void OnInvalidated(InvalidateEventArgs e)
{
     // TracePoint, WhenHit "invalidate 
{e.InvalidRect}"
     base.OnInvalidated(e);
}
[2]
TracePoint "paint Panel {e.ClipRectangle}"



Opinions expressed in this email are those of the writer and
not the company. 
 E-mail traffic is monitored within Johnston Press and
messages may be 
viewed.  This e-mail and any files with it are solely for
the use of the 
addressee(s).    If you are not the intended recipient,
you have received 
this e-mail in error.  Please delete it or return it to the
sender or notify 
us by email at postmasterjpress.co.uk
invalidate and paint clip rectangle
user name
2006-03-23 11:55:20
Adrian Martin wrote:
 > I don't think Parent.Invalidate( rect , true ) will
translate the rect
 > and call a Child.Invalidate( rect , true ), I think it
just calls
 > Child.Invalidate(true) for any control within the
rect, hence the clip
 > is set to the client area of the control.

you inspired me to see what it actually does do.

The code [1] (via reflector) gets the rect and passes it to
the
User32.dll!RedrawWindow method, the help [2] for which does
not indicate
what happens to the rectangle.

I will try to avoid using the invalidate children call and
see where it
gets me.

Cheers,

adam

[1]
public void Invalidate(Rectangle rc, bool
invalidateChildren)
{
     /* ... snip ...*/
     NativeMethods.RECT rect1 =
         NativeMethods.RECT.FromXYWH(rc.X, rc.Y, rc.Width,
rc.Height);

     SafeNativeMethods.RedrawWindow(
         new HandleRef(this.window, this.Handle),
         ref rect1,
         NativeMethods.NullHandleRef,
         RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN);

     /* ... snip ...*/
     NotifyInvalidate(rc);
}

[2]
http://msdn.microsoft.com/
library/default.asp?url=/library/en-us/gdi/pantdraw_81pz.asp

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )