Re: Need Help Fixing GDI Leaks
From: Scott McPhillips [MVP] (org-dot-mvps-at-scottmcp)
Date: 02/26/05
- Next message: Daniel James: "Re: using C++ visual Studio.net to write programs for c++ 6.0"
- Previous message: Larry Brasfield: "Re: Need Help Fixing GDI Leaks"
- In reply to: Phillip N Rounds: "Re: Need Help Fixing GDI Leaks"
- Next in thread: Joseph M. Newcomer: "Re: Need Help Fixing GDI Leaks"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 25 Feb 2005 19:43:54 -0500
Phillip N Rounds wrote:
> The reason OnDraw() gets called throughout this app is that the app
> controls an external piece of lab equipment ( actually 3 ), and collects &
> presents data from one of the machines. Each of the machines, and of course
> the user, can instigate a need to redraw one of the views, with one machine
> instigating a need to redraw the view every second. The OnDraw() function
> switches on some data in the associated Doc to determine if the entire view
> needs to be redrawn, or simply has to add the next line segment(s) in the
> graph. What I was trying to do in all of this was to minimize the amount of
> work involved in each update to the view.
>
> So, the real reason I am responding except to say thanks is that it is
> entirely possible that I have taken the wrong approach to this and I wanted
> to understand your response better. I really can't just repaint the entire
> for each new data point, that would be too graphics intensive. With this
> further input, do you still think I have taken the wrong approach?
You are still breaking Rule 1 of Windows painting.
Have you experimented with covering and then uncovering parts of your
view with some other program's window? What happens, for example, if
you bring up the Windows clock and move that window around? According
to your description, your view would not properly repaint when uncovered.
In other words, your doc variables do not know enough to determine how
much of the view needs to be redrawn.
The solution is to call the view Invalidate() to force the whole view to
repaint, or you can call InvalidateRect() if you want to request only a
partial repaint. To reduce or avoid unnecessary repainting the OnDraw
code can call GetClipBox to determine how much of the view to redraw.
GetClipBox gives you the union of the area you invalidated and the area
that Windows may have invalidated.
-- Scott McPhillips [VC++ MVP]
- Next message: Daniel James: "Re: using C++ visual Studio.net to write programs for c++ 6.0"
- Previous message: Larry Brasfield: "Re: Need Help Fixing GDI Leaks"
- In reply to: Phillip N Rounds: "Re: Need Help Fixing GDI Leaks"
- Next in thread: Joseph M. Newcomer: "Re: Need Help Fixing GDI Leaks"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|