
Changing Background Color of CEdit - Problem With Double Clicking On Texts
Hi. I've a multiline edit control (IDC_EDIT1) which is
read-only. I tried to set the background color to white
and text color to blue using the default brush with the
following codes:
HBRUSH CCeditDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT
nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd,
nCtlColor);
// TODO: Change any attributes of the DC here
if (pWnd->GetDlgCtrlID() == IDC_EDIT1)
{
CRect rc;
pWnd->GetClientRect(&rc);
pDC->Rectangle(0, 0, rc.Width(), rc.Height
());
pDC->SetBkColor(RGB(255, 255, 255));
pDC->SetTextColor(RGB(0, 0, 255));
}
// TODO: Return a different brush if the default
is not desired
return hbr;
Quote:
}
Although this seems to work, every time I double click on
the texts inside the edit control, problem arises. The
selected texts get highlighted as expected but the rest of
the contents of the edit control simply disappear. Anybody
got any idea on how to fix this? Thanks.