-
CStatic
is it possible just to change the text color of a CStatic control? i made a class derived from CStatic and i want to change the text color on MouseMove event i dont wanna use the paint event because i will have to use my own text wrap function and i dont wanna use that, for now i got this code:
Code:
HBRUSH CLabel::CtlColor(CDC* pDC, UINT nCtlColor)
{
CDC dc;
HBRUSH brush;
pDC->SetBkMode(TRANSPARENT);
pDC->SelectObject(&m_font);
pDC->SetTextColor(m_color);
dc.CreateCompatibleDC(pDC);
dc.SelectObject(&((CChateXDlg*)AfxGetMainWnd())->m_bmp);
brush = (HBRUSH)::CreateSolidBrush(dc.GetPixel(24, 24));
dc.DeleteDC();
return brush;
}
thanks
-
You create the brush on the stack. Create a brush as member of the class.
Kuphryn
-
can you give me an example please ? i dont really understand what you mean
thanks
-
Create a class member of type HBRUSH. You only need to create one brush object. Update via SetDCBrushColor().
Kuphryn
-