2013年8月8日 星期四

修改 cstatic text color

 
 
// Message Map
BEGIN_MESSAGE_MAP(CDlgDlg, CDialog)
    ...
    ON_WM_CTLCOLOR()
END_MESSAGE_MAP()
HBRUSH CDlgDlg::OnCtlColor( CDC* pDC, CWnd* pWnd, UINT nCtlColor )
{
    // Call base class version at first. Or else it will override your changes.
    HBRUSH hbr = CDialog::OnCtlColor( pDC, pWnd, nCtlColor );
    // Check whether which static label its.
    if( pWnd->GetDlgCtrlID() == IDC_STATIC_OK )
    {
        // Set color as red.
        pDC->SetTextColor( RGB( 255, 0, 0 ));
        pDC->SetBkMode( TRANSPARENT );
    }
    return hbr;
}

沒有留言:

張貼留言