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.
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.
Use CStatic instead of CEdit(sunken) and you can color it after!
ASKER
No, I need CEdit...
Can it be done in CEdit ?
Can it be done in CEdit ?
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;
}
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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;
}
{
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;
}