Use of Hints to Redraw Portion of Window
Mike & Tina Dodd -- dodd@wilmington.net
Sunday, December 01, 1996
Environment : VC++ 4.2b Patched, NT 4.0
I have a window which contains hundreds and possibly thousands of
individual items (Hexagons).=20
When a Dialog box or another window passes infront of the window I
only want to redraw THAT portion vacated by the dialog box when it is
moved or closed.
I know I use OnUpDate, and hints but the example in the tutorial uses
an Ole example with trackers. =20
*How do I get the coordinates for the Dialog boxes old position before
it was moved?, or it's coordinates after it closes?*
I just want to get the rectangle that WAS the old location of the
Dialog and redraw only those hexagons and other objects inside that
region. I also run into the same problem when the dialog box is
moved. At first I was going to have the code inside the dialog box
and call the CView->OnUpdate function, but I thought there ought to be
some way of handling that within the CView itself, rather than inside
every object that could pass over my window.
Is there a document? An example usually helps me the best. If someone
could just point me in the right direction I would be very
appreciative.
Thank you
Mike Dodd
Gerald Alter -- jalter@alt-ego.com
Monday, December 02, 1996
I don't remember the exact manner in which it is done, but there is a way
to retrieve a list of dirty rectangles (areas in which windows has marked
for redraw). The actual process is to get into the list find the area and
validate or invalidate that region for redraw only. The internal workings
is that windows takes this list of dirty rectagle areas, merges them
together (or finds over lapping regions) and then redraws all those areas.
If you get into the list, you can find all the areas on the screen (and
otherwise) that the system has marked for redrawing. You can also remove
areas from the list and add areas to that list. In a sense this is what
the "InvalidateRect()" function does. It adds a dirty rect to the list,
then windows, on a WM_PAINT message does it's redrawing process based on
that list. I'm sorry I don't remember what the actual process is to get to
the list (it's been about 3 years since I've dug around in that area), but
I'm sure if you look around for info on windows Dirty rect information
you'll find it. Good luck.
Jay Alter
FASA Interactive
jalter@alt-ego.com
----------
From: Mike & Tina Dodd
To: mfc-l@netcom.com
Subject: Use of Hints to Redraw Portion of Window
Date: Saturday, November 30, 1996 10:32 PM
Environment : VC++ 4.2b Patched, NT 4.0
I have a window which contains hundreds and possibly thousands of
individual items (Hexagons).
When a Dialog box or another window passes infront of the window I
only want to redraw THAT portion vacated by the dialog box when it is
moved or closed.
I know I use OnUpDate, and hints but the example in the tutorial uses
an Ole example with trackers.
*How do I get the coordinates for the Dialog boxes old position before
it was moved?, or it's coordinates after it closes?*
I just want to get the rectangle that WAS the old location of the
Dialog and redraw only those hexagons and other objects inside that
region. I also run into the same problem when the dialog box is
moved. At first I was going to have the code inside the dialog box
and call the CView->OnUpdate function, but I thought there ought to be
some way of handling that within the CView itself, rather than inside
every object that could pass over my window.
Is there a document? An example usually helps me the best. If someone
could just point me in the right direction I would be very
appreciative.
Thank you
Mike Dodd
----------
Rajesh Babu T -- rbabu@hotmail.com
Tuesday, December 03, 1996
>Environment : VC++ 4.2b Patched, NT 4.0
>
>I have a window which contains hundreds and possibly thousands of
>individual items (Hexagons).=20
>
>When a Dialog box or another window passes infront of the window I
>only want to redraw THAT portion vacated by the dialog box when it is
>moved or closed.
>I know I use OnUpDate, and hints but the example in the tutorial uses
>an Ole example with trackers. =20
>
>*How do I get the coordinates for the Dialog boxes old position before
>it was moved?, or it's coordinates after it closes?*
>
>I just want to get the rectangle that WAS the old location of the
>Dialog and redraw only those hexagons and other objects inside that
>region. I also run into the same problem when the dialog box is
>moved. At first I was going to have the code inside the dialog box
>and call the CView->OnUpdate function, but I thought there ought to be
>some way of handling that within the CView itself, rather than inside
>every object that could pass over my window.
>
>Is there a document? An example usually helps me the best. If someone
>could just point me in the right direction I would be very
>appreciative.
>
>Thank you
>
>Mike Dodd
>
Hi Mike,
If the popup window is part of your application then you can try this
1.Call GetLastActivePopup - which gives the handle of the last active window
2.Then call GetWindowRect which gives the screen coordinates of the window
3.Then map the screen coordinates of the popup window to the client coordinates
of the target window
4.From which U can find the matched portion and Invalidate it.
If the popup window is not part of your application then use
1. Call EnumWindows to find the handle of the active popup window and the
repeat the procedure....
Hope this gives U some idea.
Bye,
Rajesh Babu
KL,Malaysia
_/_/_/ _/_/_/ _/_/_/_/_/
_/ _/ _/ _/ _/
_/ _/ _/ _/ _/
_/_/_/ _/_/_/ _/
_/ _/ _/ _/ _/
_/ _/ _/ _/ _/
_/ _/ _/_/_/_/ _/
---------------------------------------------------------
Get Your *Web-Based* Free Email at http://www.hotmail.com
---------------------------------------------------------
Jim Lawson Williams -- jimlw@mail.ccur.com.au
Wednesday, December 04, 1996
At 03:32 AM 1/12/96 GMT, you wrote:
>Environment : VC++ 4.2b Patched, NT 4.0
>
>I have a window which contains hundreds and possibly thousands of
>individual items (Hexagons).
>
>When a Dialog box or another window passes infront of the window I
>only want to redraw THAT portion vacated by the dialog box when it is
>moved or closed.
>I know I use OnUpDate, and hints but the example in the tutorial uses
>an Ole example with trackers.
>
>*How do I get the coordinates for the Dialog boxes old position before
>it was moved?, or it's coordinates after it closes?*
>
G'day!
I think you will find that GetClipBox() will give you what you want -- i.e., not the entire Client area, just the bit that needs to be redrawn.
Regards,
Jim LW
>From the BBC's "Barchester Chronicles":
"I know that ultimately we are not supposed to understand.
But I also know that we must try."
-- the Reverend Septimus Harding, C++ programmer
Dong Chen -- d_chen@ix.netcom.com
Tuesday, December 03, 1996
The GetUpdateRect function can be used to determine the region which has
been covered by your dialog box after the dialog box has been dismissed. In
this case, the Windows keeps track of the update region for you. You don't
need to use hint at all. If you called the Invalidate function to force your
window to repaint after you finished your dialog box, then you can
InvalidateRect instead. If you are using UpdateAllViews from you document
based class, then you can set the hint parameter and receive it from the
OnUpdate handler.
Hope this helps.
P.S. Which tutorial sample are you mentioning? Is it the ENROLL sample?
--
Dong
d_chen@ix.netcom.com
Bradley A. Burns -- bburns@sprynet.com
Tuesday, December 03, 1996
Hi Mike and Tina...
This is a common problem for people who actually want to go through the
trouble of making their applications more robust. To be honest, it is
usually not that much of a problem. As you obviously know, performing lots
of drawing in a window or a view can be time consuming, especially when the
entire client area is being redrawn when even 1 pixel has been invalidated.
Fortunately, performing a big loop and drawing only what's necessary
increases speed immensly. Try something like this for your view.
1. Get the view's update regions when something in from of your view is
moved.
2. Since you're probably performing a loop or series of loops for drawing
you hexagons, check whether any of the points of the h-gons are within any
of the actual update regions. PtInRect is a good function for this test.
3. If any of the points are in any of the update regiions, draw the
hexagon, otherwise go to the next hexagon in the loop.
This should speed things up for you. It might sound like a bit of work, but
it's definately worth it.
Bradley A. Burns
bburns@sprynet.com
George V. Reilly -- georger@microcrafts.com
Wednesday, December 04, 1996
[Mini-digest: 4 responses]
>From: Mike & Tina Dodd
>
>When a Dialog box or another window passes infront of the window I
>only want to redraw THAT portion vacated by the dialog box when it is
>moved or closed.
>I know I use OnUpDate, and hints but the example in the tutorial uses
>an Ole example with trackers.
If you just want to redraw the area that has been invalidated, use:
CRect rcUpdate;
pDC->GetClipBox(&rcUpdate);
--
/George V. Reilly
MicroCrafts, Inc., 17371 NE 67th Ct #205, Redmond, WA 98052, USA.
Tel: 206/250-0014 Fax: 250-0100 Web: http://www.microcrafts.com
Vim 4 (vi clone) for NT & Windows 95: http://www.halcyon.com/gvr/
pgp fingerprint: e2 b4 83 64 11 52 21 ea bf d8 51 c2 11 00 78 fc
-----From: "Martin J. Mahoney"
Look at the GetUpdateRect() method of the CWND class. It returns to you the
smallest rect that fully encloses the dirty area of your window. That
should give you the information you need. You can also look at the
GetUpdateRgn() method.
Martin J. Mahoney
www.PyramidLogicSystems.com
----------
> From: Mike & Tina Dodd
> To: mfc-l@netcom.com
> Subject: Use of Hints to Redraw Portion of Window
> Date: Saturday, November 30, 1996 10:32 PM
>
> Environment : VC++ 4.2b Patched, NT 4.0
>
> I have a window which contains hundreds and possibly thousands of
> individual items (Hexagons).
>
> When a Dialog box or another window passes infront of the window I
> only want to redraw THAT portion vacated by the dialog box when it is
> moved or closed.
> I know I use OnUpDate, and hints but the example in the tutorial uses
> an Ole example with trackers.
>
> *How do I get the coordinates for the Dialog boxes old position before
> it was moved?, or it's coordinates after it closes?*
>
> I just want to get the rectangle that WAS the old location of the
> Dialog and redraw only those hexagons and other objects inside that
> region. I also run into the same problem when the dialog box is
> moved. At first I was going to have the code inside the dialog box
> and call the CView->OnUpdate function, but I thought there ought to be
> some way of handling that within the CView itself, rather than inside
> every object that could pass over my window.
>
> Is there a document? An example usually helps me the best. If someone
> could just point me in the right direction I would be very
> appreciative.
>
> Thank you
>
> Mike Dodd
>
> ----------
-----From: Curt Sutherland
At 11:42 PM 12/2/96 -0500, you wrote:
>From: Mike & Tina Dodd
>To: mfc-l@netcom.com
>Subject: Use of Hints to Redraw Portion of Window
>Date: Saturday, November 30, 1996 10:32 PM
>
>Environment : VC++ 4.2b Patched, NT 4.0
>
>I have a window which contains hundreds and possibly thousands of
>individual items (Hexagons).
>
>When a Dialog box or another window passes infront of the window I
>only want to redraw THAT portion vacated by the dialog box when it is
>moved or closed.
>I know I use OnUpDate, and hints but the example in the tutorial uses
>an Ole example with trackers.
>
>*How do I get the coordinates for the Dialog boxes old position before
>it was moved?, or it's coordinates after it closes?*
>
>I just want to get the rectangle that WAS the old location of the
>Dialog and redraw only those hexagons and other objects inside that
>region. I also run into the same problem when the dialog box is
>moved. At first I was going to have the code inside the dialog box
>and call the CView->OnUpdate function, but I thought there ought to be
>some way of handling that within the CView itself, rather than inside
>every object that could pass over my window.
>
>Is there a document? An example usually helps me the best. If someone
>could just point me in the right direction I would be very
>appreciative.
>
>Thank you
>
>Mike Dodd
>
>----------
>
Environment: VC++ 4.2b, WinNT 3.51
The following code will retrieve a list of dirty rectangles:
RECT r;
GetClientRect(&r);
CRgn rgn;
rgn.CreateRectRgn( r.left, r.top, r.right, r.bottom );
int nStatus = GetUpdateRgn( &rgn );
if( nStatus == NULLREGION ) return;
if( nStatus == ERROR ) return;
int nSize = rgn.GetRegionData( NULL, 0 ); // Get the size of the rgn struct
RGNDATA *pRgn = (RGNDATA *) new char[nSize];
if( pRgn == NULL ) return;
rgn.GetRegionData( pRgn, nSize ); // Get the rgn struct
RECT *pRect = (RECT *) &pRgn->Buffer[0];
int nRects = (nSize - sizeof RGNDATAHEADER) / sizeof RECT;
RECT rect;
for( int i = 0; i < nRects; i++ )
{
....
}
delete[] pRgn;
Note: I have this code in the OnPaint() callback.
-----From: Spencer Jones
If you have MSDN there is a good article on fast screen repainting. It
is in the books / periodicals section in the book:
Animation Techniques in Win32
by Nigel Thompson
With a Foreword by Charles Petzold
PUBLISHED BY
Microsoft Press
ISBN 1-55615-669-3
See Chapter 10
Spencer Jones
Chief Software Developer
Azure Limited
E-Mail (spencer@azure.com)
Web Page (http://www.azure.com/~spencer)
User Location Service (uls.azure.com)
>----------
>From: dodd@wilmington.net[SMTP:dodd@wilmington.net]
>Sent: Sunday, December 01, 1996 3:32 AM
>To: mfc-l@netcom.com
>Subject: Use of Hints to Redraw Portion of Window
>
>Environment : VC++ 4.2b Patched, NT 4.0
>
>I have a window which contains hundreds and possibly thousands of
>individual items (Hexagons).
>
>When a Dialog box or another window passes infront of the window I
>only want to redraw THAT portion vacated by the dialog box when it is
>moved or closed.
>I know I use OnUpDate, and hints but the example in the tutorial uses
>an Ole example with trackers.
>
>*How do I get the coordinates for the Dialog boxes old position before
>it was moved?, or it's coordinates after it closes?*
>
>I just want to get the rectangle that WAS the old location of the
>Dialog and redraw only those hexagons and other objects inside that
>region. I also run into the same problem when the dialog box is
>moved. At first I was going to have the code inside the dialog box
>and call the CView->OnUpdate function, but I thought there ought to be
>some way of handling that within the CView itself, rather than inside
>every object that could pass over my window.
>
>Is there a document? An example usually helps me the best. If someone
>could just point me in the right direction I would be very
>appreciative.
>
>Thank you
>
>Mike Dodd
>
>
>
| Вернуться в корень Архива
|