Windows/MFC

[CStatic][CFont] color change, transferant

aucd29 2013. 10. 2. 18:04
MSDN Example

Windows Message Type : WM_CTLCOLOR

[code]
// Code
HBRUSH CZilchDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
    // Call the base class implementation first! Otherwise, it may
    // undo what we're trying to accomplish here.
    HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

    if(pWnd->GetDlgCtrlID() == IDC_MSG_RECEIVEMSG)
    {
        pDC->SetTextColor(RGB(0, 70, 213));
        pDC->SetBkMode(TRANSPARENT);
        return (HBRUSH)GetStockObject(NULL_BRUSH);
    }
    else if (pWnd->GetDlgCtrlID() == IDC_SMSMANAGER_NEWSMS)
    {
        pDC->SetBkMode(TRANSPARENT);
        CFont font;
        font.CreateFont(12, 0, 0, 0, FW_BOLD, FALSE, FALSE, 0, 0, 0, 0, 0, 0, L"MS Sans Serif");        
        CFont *Oldfont= (CFont*) pDC->SelectObject(&font);
        return (HBRUSH)GetStockObject(NULL_BRUSH);
    }
    else if(pWnd->GetDlgCtrlID() == IDC_MSG_RECEIVE ||
            pWnd->GetDlgCtrlID() == IDC_MSG_BYTE ||
            pWnd->GetDlgCtrlID() == IDC_MSG_COUNTYCODE)
    {
        pDC->SetBkMode(TRANSPARENT);
        return (HBRUSH)GetStockObject(NULL_BRUSH);
    }
}
[/code]