Link to home
Start Free TrialLog in
Avatar of irisz
irisz

asked on

CEdit Read-Only question

Hi,
I have a CEdit which I set to Read-Only mode.
But I want the color of the edit to remain white (and not gray).
How can I do it ?

Thanks,
Iris.
Avatar of Andrian
Andrian

Use CStatic instead of CEdit(sunken) and you can color it after!
Avatar of irisz

ASKER

No, I need CEdit...
Can it be done in CEdit ?
Avatar of Meir Rivkin
u could use OnCtlColor to change the background of the CEdit color to white.
HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
     HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
     
     if (pWnd->GetDlgCtrlID() == IDC_MYEDIT)
         pDC->SetBkColor(RGB(255, 255, 255));
     
     return hbr;
}

ASKER CERTIFIED SOLUTION
Avatar of iProgram
iProgram

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
     HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

    if (pWnd->GetDlgCtrlID() == IDC_MYEDIT)        
    {                
        pDC->SetBkColor(RGB(255, 255, 255));

        COLORREF color = RGB(255, 255, 255);
        CBrush* back_brush = new CBrush(color);
        return (HBRUSH) (back_brush->m_hObject);
    }
     return hbr;
}