MFC: how to create a NULL BRUSH
May 17, 2013 at 9:31am UTC
here's part of my class code, the problem is that I can create a null brush,
the BS_NULL can't be a parameter in CreateSolidBrush nor in CreateHatchBrush, what should I do that I can create a null brush?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
CBrush aBrush;
if (m_brushStyle == BS_SOLID)
{
if (!aBrush.CreateSolidBrush(m_brushColor))
{
//....
}
}
else
{
if ( aBrush.CreateHatchBrush(m_brushStyle, m_brushColor) )
{
//...
}
}
CBrush* oldBrush = pDC->SelectObject(&aBrush);
Last edited on May 17, 2013 at 9:31am UTC
May 17, 2013 at 9:35am UTC
I think this would work, but I think it's not good enough.
1 2 3 4 5 6 7 8
CBrush* oldBrush;
if (m_brushStyle == BS_NULL)
{
oldBrush = (CBrush*)pDC->SelectStockObject(NULL_BRUSH);
} else
{
oldBrush = pDC->SelectObject(&aBrush);
}
Topic archived. No new replies allowed.