Re: Owner-Draw Round Button
Yes you did. So your program didn't allow to paint. There is a round button.
//This is OK.
CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
CRect rect = lpDrawItemStruct->rcItem;
CRgn rgn;
rgn.CreateEllipticRgnIndirect(&rect);
//If I doesn't call SelectClipRgn there is a rectangle
button
pDC->SelectClipRgn(&rgn);
pDC->FillSolidRect(&rect, RGB(255,0,0));
But in MSDN, it writes:
"The window region determines the area within the window where the system
permits drawing. The system does not display any portion of a window that
lies outside of the window region "
So can we say this is not completly right?
Because if someone sets region of a window but doesn't make clipping, system
still displays outside of the window region.
"Joseph M. Newcomer" wrote:
Take a look at what I did for the "CAT" buttons in my SetWindowRgn example; they are
owner-draw buttons. I may have done clipping.
joe
On Mon, 20 Jul 2009 09:26:01 -0700, sawer <sawer@discussions.microsoft.com> wrote:
I am just trying to understand why this simple code isn't working:
void CMyButton::PreSubclassWindow()
{
CRect rect;
GetClientRect(&rect);
CRgn rgn;
rgn.CreateEllipticRgnIndirect(&rect);
SetWindowRgn(rgn, TRUE);
rgn.Detach();
CButton::PreSubclassWindow();
}
void CMyButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
CRect rect = lpDrawItemStruct->rcItem;
pDC->FillSolidRect(&rect, RGB(255,0,0));
}
I made an elliptic region in PreSubclassWindow() and then called to
FillSolidRect().
Why is there a rectangle button? Why are top corners seen?
Thanks.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm