|
-
April 14th, 2007, 05:20 AM
#1
Wm_paint
Hi,
Thanks for looking in to this !
I have my paint function,In Which I am calling Draw Method of Objects
Code:
OnPaint(CDC *pDC)
{
For(int i=0;i<Count;i++)
{
CShape *temp=GetShape(i);
temp->Draw(pDC);
}
}
and
CShape as well as Derived classes implemented Draw() method.
Code:
CMyRect::Draw(CDC *pDC)
{
//Some Code
//
pDC->Rectangle(...);
}
CMyDate::Draw(CDC *pDC)
{
//Some Code
pDC->.......
}
I want to ignore the draw code if it does'nt lies in invalidate region.
Code:
CMyDate::Draw(CDC *pDC)
{
if(InvalidateRgn Overlaps this object Rect)
{
//Some Code
pDC->.......
}
else
{
//Ignore
}
}
How to do this ? Is there any API for getting invalidate region.
How to get Update Rect Inside Paint() ? as its get cleared after beginpaint call !
Thanks !
-Anant
Last edited by anantwakode; April 14th, 2007 at 05:33 AM.
"Devise the simplest possible solution that solves the problems"
-
April 14th, 2007, 06:49 AM
#2
Re: Wm_paint
Hi anantwakode,
Did you have a look at
Code:
BOOL GetUpdateRect(
LPRECT lpRect,
BOOL bErase = FALSE
);
Best Regards,
Gili
Please use code tags [code] [/code]
We would change the world, but God won't give us the sourcecode.. 
Undocumented futures are fun and useful....
_________
Gili
-
April 14th, 2007, 07:33 AM
#3
Re: Wm_paint
Hi,
Thanks g_gili !
I tried to get Update Rect by using GeUpdateRect(), but as I am calling it in OnPaint() its get Cleared as OnPaint is get Called after beginpaint().
now I am using getClipBox(). and its working fine.. !
is there any better way ? is there any advantage of using Rgn instead of Rect.
actually getClipbox() returns invalidate rect.
which is fine but problem is if suppose
I have object at pos 10,10 and 200,200 which are continously updated.
then it returns CRect(10,10,200,200),
and if I have Static object at 50,50 which is not overlapped by these two object still Draw() gets called for the object.
I think using Rgn I mean , InvalidateRgn() or something like can provide better solution ! Or is there any better solution ?
what do you think ?
Thanks
-Anant
"Devise the simplest possible solution that solves the problems"
-
April 14th, 2007, 12:10 PM
#4
Re: Wm_paint
In OnDraw, you also need to check whether the object being drawn lies within the invalidated rectangle. Use IntersectRect, and in addition, define a method in your CShape class that returns the bounding rectangle for the shape.
The Scribble tutorial uses this approach. See the three steps at "Using a Hint For Effective Repainting" at http://msdn2.microsoft.com/en-us/lib...88(VS.60).aspx
GetClipRgn will retrieve an application-defined clipping region. This approach will work only if you are also willing to create your own clipping regions using the SetClipRgn function.
Mike
-
April 14th, 2007, 12:38 PM
#5
Re: Wm_paint
"Devise the simplest possible solution that solves the problems"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|