Multiline CEdit custom background color problem 
Author Message
 Multiline CEdit custom background color problem

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.*-*-*.com/ ~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?

/anders

--------------------------------------------------------------------------------------

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;

Quote:
}



Mon, 05 Mar 2001 03:00:00 GMT  
 Multiline CEdit custom background color problem
Anders,

Quote:
>I have got a readonly multiline CEdit control that i want to have
>another background color (red in this case) than the default. I

You could switch to using a CRichEditCtrl, which has a
SetBackgroundColor() function.

Chip



Tue, 06 Mar 2001 03:00:00 GMT  
 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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<
<
<
<
<
<
<
<
<
<



Wed, 07 Mar 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. multiline CEdit background color

2. Changing Background Color of CEdit - Problem With Double Clicking On Texts

3. Colored text in MultiLine CEdit

4. Set text color for 1 line in a CEdit control (MultiLine)

5. Win2K: static background color vs. CFormView background color

6. Background & Text color CEdit

7. Background color of CEdit

8. background color of CEdit control

9. How to change background color Of CEdit?

10. Background color of a CEdit object.

11. How to update the background color of CEdit

12. CEdit Background Color

 

 
Powered by phpBB® Forum Software