Re: Invalidating a region and having only that region drawn
- From: Andrew <Andrew@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 5 Jun 2005 20:25:01 -0700
Doug,
Thanks for your comment.
Andrew.
"Doug Forster" wrote:
> Hi Andrew,
>
> I could be wrong but I get the feeling you haven't fully understood what Bob
> was saying. You shouldn't be attempting to use clipping at all to manipulate
> the logical content of a window. The job of a paint handler is *just* to
> paint part or all of a window with the correct content of the moment as
> ascertained from state maintained external to the whole painting paradigm.
> You should remember that Windows itself can invalidate any part of your
> window at any time. This is not specific to .NET but is simply how Windows
> has always worked.
>
> Cheers
> Doug Forster
>
> "Andrew" <Andrew@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:18697CA9-3687-425F-8458-1E9FA99BAC84@xxxxxxxxxxxxxxxx
> > Thanks,
> >
> > I will need to rethink my drawing strategy paying closer attention to the
> > clipping region.
> >
> >
> > "Bob Powell [MVP]" wrote:
> >
> >> Painting works like this:
> >>
> >> The system stores the results of invalidate calls internally. Invalidate
> >> without parameters will mark a whole window for refreshing, invalidate
> >> with
> >> parameters will add regions to the list of "dirty" areas maintained by
> >> the
> >> system.
> >>
> >> When the queue is empty and there is nothing else to do, the system
> >> checks
> >> for dirty areas and issues a WM_PAINT message if any are found, otherwise
> >> it
> >> issues a WM_ENTERIDLE message to kick-off idle time processing.
> >>
> >> In all cases the result of the WM_PAINT message, for Windows Forms
> >> programs,
> >> is to run the OnPaint override which in turn kicks of the Paint event.
> >>
> >> The clipping region set in the OnPaint event arguments will be the sum of
> >> all the regions or the whole window depending on whether Invalidate was
> >> called without parameters.
> >>
> >> It's up to your code to either keep a list of its own dirty rectangles /
> >> regions OR to do output based on the bounds of the clipping region
> >> provided
> >> by the paint event arguments. Whatever paint strategies you devise, such
> >> as
> >> only drawing partial content or layers, is entirely up to you and needs
> >> to
> >> be managed by you. The system doesn't care about reporting anything
> >> except
> >> that there is an area of screen marked as being in need of a refresh.
> >>
> >> --
> >> Bob Powell [MVP]
> >> Visual C#, System.Drawing
> >>
> >> Find great Windows Forms articles in Windows Forms Tips and Tricks
> >> http://www.bobpowell.net/tipstricks.htm
> >>
> >> Answer those GDI+ questions with the GDI+ FAQ
> >> http://www.bobpowell.net/faqmain.htm
> >>
> >> All new articles provide code in C# and VB.NET.
> >> Subscribe to the RSS feeds provided and never miss a new article.
> >>
> >>
> >>
> >>
> >>
> >> "Andrew" <Andrew@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> >> news:B82AC0B1-5BFF-4867-A7A6-B8E0DB074432@xxxxxxxxxxxxxxxx
> >> > Hello,
> >> >
> >> > In my application I perform all the drawing operations from within the
> >> > form's
> >> > OnPaint method (the form is ultimately a TabPage derivative) ie
> >> >
> >> > protected override void OnPaint(PaintEventArgs e)
> >> > {
> >> > base.OnPaint(e);
> >> > //the base class LayerView.OnPaint handles things like
> >> > AutoScrollPosition
> >> > int s = 1; // temporary dummy scale value
> >> > m_building.DrawBuildingLayer(g,s,this.Name);
> >> > m_columns.DrawColumnsLayer(g,s,this.Name);
> >> > }
> >> >
> >> > The drawing works well and smoothly handles operations such as
> >> > scrolling.
> >> >
> >> > It is my understanding that when Invalidate() is called ie with no
> >> > parameters, the entire client area of the form is added to the update
> >> > region
> >> > and a paint message is sent that raises the Paint event which is
> >> > handled
> >> > by
> >> > the OnPaint handler. OK
> >> >
> >> > When Invalidate(region) is called, I believe that only that region is
> >> > added
> >> > to the form's update region resulting in only that region being redrawn
> >> > at
> >> > the next Paint message.
> >> >
> >> > Either way, calling Invalidate results in OnPaint to be executed.
> >> >
> >> > When I call Invalidate() the entire client area is redrawn with both
> >> > drawing
> >> > functions called and this is exactly the outcome that I want for that
> >> > scenario.
> >> >
> >> > The problem is that when I only want to redraw a invalidated region of
> >> > this
> >> > form,
> >> > the entire form is redrawn( which is causing objects to be appear
> >> > incorrectly).
> >> >
> >> > ie When I call Invalidate(with a specific region) in order to only have
> >> > that
> >> > region redrawn I do NOT intend for the likes of DrawBuildingLayer nor
> >> > DrawColumnsLayer
> >> > to be called. Obviously they are being called because of their presence
> >> > in
> >> > OnPaint().
> >> >
> >> > I cannot think of any other place where I could call these draw
> >> > functions
> >> > other than OnPaint and I want to steer clear of CreateGraphics.
> >> >
> >> > Are there any suggestions regarding a strategy of how I could call
> >> > Invalidate(region) and only have that region redrawn ?
> >> >
> >> >
> >> > Thanks
> >> >
> >> > Andrew.
> >> >
> >>
> >>
> >>
>
>
>
.
- Prev by Date: I use the following for my ChartFX .NET jpeg images
- Next by Date: creating fonts
- Previous by thread: How to do simple memcpy in C#?
- Next by thread: Re: Invalidating a region and having only that region drawn
- Index(es):
Relevant Pages
|