Karol
Karol

Reputation: 31

How to change background color in static text visual studio?

I am trying to change background color of static text in our project. We use BCG library also.

In h. file I have

afx_msg HBRUSH CtlColor(CDC * pDC, CWnd * pWnd, UINT nCtlColor);
COLORREF m_bckNewsClr;

In cpp. I have:

m_bckNewsClr = RGB(255, 255, 255);

HBRUSH CStartPage::CtlColor(CDC * pDC, CWnd * pWnd, UINT nCtlColor)
{
    pWnd->GetDlgItem(IDC_STATIC_NEWS_CAPTION_1);
    pDC->SetBkColor(m_bckNewsClr);
    return (HBRUSH)m_Brush.GetSafeHandle();
}

In massage map:

ON_WM_CTLCOLOR()

Anyway, it is even not visible the function CtlColor, when I put the breakpoint.

Does someone know how to change this backgound static text in this case?

Upvotes: 3

Views: 1957

Answers (1)

Mihayl
Mihayl

Reputation: 3911

The ON_WM_CTLCOLOR expects a method named:

afx_msg HBRUSH OnCtlColor(
   CDC* pDC,
   CWnd* pWnd,
   UINT nCtlColor 
);

See also CWnd::OnCtlColor for a sample how to do it.

And also https://stackoverflow.com/a/12007350/8918119

Upvotes: 3

Related Questions