CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Wm_paint

  1. #1
    Join Date
    Feb 2005
    Location
    Pune (India)
    Posts
    644

    Thumbs up 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"

  2. #2
    Join Date
    Mar 2005
    Location
    Romania,Cluj-Napoca
    Posts
    1,073

    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

  3. #3
    Join Date
    Feb 2005
    Location
    Pune (India)
    Posts
    644

    Thumbs up 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"

  4. #4
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    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

  5. #5
    Join Date
    Feb 2005
    Location
    Pune (India)
    Posts
    644

    Thumbs up Re: Wm_paint

    Thanks Mike !

    -Anant
    "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
  •  





Click Here to Expand Forum to Full Width

Featured