
Multiline CEdit custom background color problem
Quote:
>Hi there
>I have got a readonly multiline CEdit control that i want to have
>another background color (red in this case) than the default. I
>implemeted the tip I found at
>http://www.concentric.net/~cgalbrai/backcolor.shtml (see code at end).
>but when the control holds text that is larger than the size of the
>control (so that it has to scroll) the text i garbled when scrolling the
>control. The only way to "ungarble" the text is to select a portion of
>the text.
>Any ideas on how to fix this?
-----------
Quote:
>HBRUSH CInfoBar::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
>{
> // get a pointer to the specific edit control which color you want to
>control
> CEdit * pEdit = (CEdit *)GetDlgItem(IDC_INFO_EDIT);
> //if(nCtlColor == CTLCOLOR_EDIT && pEdit->GetSafeHwnd() ==
>pWnd->GetSafeHwnd()) {
> if(nCtlColor == CTLCOLOR_STATIC && pEdit->GetSafeHwnd() ==
>pWnd->GetSafeHwnd()) {
> // set the back mode so that new background color shows through the
>text
> //pDC->SetBkMode(TRANSPARENT);
> pDC->SetBkMode(RGB(255,255,255));
> // make the text white so that it shows up well over red
> pDC->SetTextColor(RGB(0,0,0));
> // return the red brush
> return (HBRUSH)m_Brush;
> }
> HBRUSH hbr = CControlBar::OnCtlColor(pDC, pWnd, nCtlColor);
> return hbr;
>}
Maybe try pDC->SetBkColor(RGB(255,0,0)) and pDC->SetBkMode(OPAQUE).
You certainly can't SetBkMode(RGB(something))...
cU
--
http://djuga.home.ml.org
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get Retriever 2.1 now: http://retriever.home.ml.org
Shareware image viewer, thumbnailer & database
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<
<
<
<
<
<
<
<
<
<