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

    When painting an elliptic custom control, the entire rect gets painted! Why?

    Hello!

    I have an owner-drawn (derived from CButton) control in my dialog box. In it's PreSubclassWindow function, I set it a new region (elliptic region) using SetWindowRgn. And here's the problem: although the control looks elliptic in the dialog box (I checked it with Spy++), when I do a simple draw like this:

    dc.FillSolidRect(&myRect, RGB(0, 0, 0));
    (from within "CSpecialButton::OnPaint" or something alike)

    the entire rectangle gets painted in black; not only the elliptic shape!! The same happens with other draw functions.

    If you have any idea what might be wrong, please post me a response or E-Mail: [email protected]

    Thanx! Ziv


  2. #2
    Join Date
    Aug 1999
    Location
    Western Australia
    Posts
    38

    Re: When painting an elliptic custom control, the entire rect gets painted! Why?

    Try setting the window region AFTER the window has been subclassed. Also, make sure that you don't destroy the region after it has been passed to SetWindowRgn(). Windows does not make a copy of the region, so if you destroy it, Windows uses the default region - rectangular.

    Ryan


  3. #3
    Join Date
    May 1999
    Location
    Farnborough, Hants, England
    Posts
    710

    Re: When painting an elliptic custom control, the entire rect gets painted! Why?

    You have to set the region EVERY time you grab a new DC. Although you set it at the beginning, when you grab a DC for OnPaint() it does not have that clipping region in it (it is a new DC, they get recycled for all windows). You must explicitly set the region before painting.



    --
    Jason Teagle
    [email protected]

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