multiline CEdit background color 
Author Message
 multiline CEdit background color

I derived a new class from CEdit called CColorEdit to handle text color
and background color (see below)

It works fine except when the control is multiline, it does not repaint
the background of the whole control.

If I'm doing:

mycoloredit.SetWindowtext("This is a test");

Only the line displaying "This is a test" will be displayed with the
correct background color while the other ones will be displayed as
white|gray.

My edit box is read-only, visible, and transparent.

Anyone know how to do this ?

CColorEdit::CColorEdit()
{
        m_TextColor = RGB(0,0,0);
        m_BkColor = ::GetSysColor(COLOR_3DFACE);
        m_Bkgnd.CreateSolidBrush(m_BkColor);

Quote:
}

void CColorEdit::SetTextColor(COLORREF color)
{
        m_TextColor = color;
        Invalidate();

Quote:
}

void CColorEdit::SetBkColor(COLORREF color)
{
        m_BkColor = color;
        m_Bkgnd.DeleteObject();
        m_Bkgnd.CreateSolidBrush(color);
        Invalidate();

Quote:
}

BEGIN_MESSAGE_MAP(CColorEdit, CEdit)
        //{{AFX_MSG_MAP(CColorEdit)
        ON_WM_CTLCOLOR_REFLECT()
        //}}AFX_MSG_MAP
END_MESSAGE_MAP()

HBRUSH CColorEdit::CtlColor(CDC* pDC, UINT nCtlColor)
{
        pDC->SetTextColor(m_TextColor);
        pDC->SetBkColor(m_BkColor);

        return (HBRUSH) m_Bkgnd;

Quote:
}

--
            \\\\
        o,,,(o o)
       8(o o)(_)Ooo
----ooO--(_)---Ooo------------------------------------------------------

 Stephane BAILLIEZ                   Ph    : +33 1 47 78 67 67
 Software Engineer                   Fax   : +33 1 47 78 67 68
 TECSI                               WWW   : http://www.*-*-*.com/

 If you want creative workers, give them enough time to play.

                                                   ~ John Cleese ~

DISCLAIMER
 All statements above are NOT the opinion or policy of my employer,
 they are actually mine and were told to me by Ferdinand and Luthor, the
 five-inch tall space aliens who live under my desk. In return for these
 ideas I gave them permission to eat any dust-cookies they may find.
------------------------------------------------------------------------



Sat, 05 May 2001 03:00:00 GMT  
 multiline CEdit background color

Quote:

> Only the line displaying "This is a test" will be displayed with the
> correct background color while the other ones will be displayed as
> white|gray.

Ok...I was not doing the right thing in my WM_ERASEBKGND handler.

Here's the piece of code for those who are interested, as usual it is
very simple when you are calling the correct functions with the correct
parameters ;-)

---CODE---

BOOL CColorEdit::OnEraseBkgnd(CDC* pDC)
{
        CRect rcClient;
        GetClientRect( &rcClient );

        pDC->FillRect(rcClient, &m_Bkgnd);
        return TRUE;

Quote:
}

Cheers,

Stephane

--
            \\\\
        o,,,(o o)
       8(o o)(_)Ooo
----ooO--(_)---Ooo------------------------------------------------------

 Stephane BAILLIEZ                   Ph    : +33 1 47 78 67 67
 Software Engineer                   Fax   : +33 1 47 78 67 68
 TECSI                               WWW   : http://www.tecsi.com

 If you want creative workers, give them enough time to play.

                                                   ~ John Cleese ~

DISCLAIMER
 All statements above are NOT the opinion or policy of my employer,
 they are actually mine and were told to me by Ferdinand and Luthor, the
 five-inch tall space aliens who live under my desk. In return for these
 ideas I gave them permission to eat any dust-cookies they may find.
------------------------------------------------------------------------



Sat, 05 May 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Multiline CEdit custom background color problem

2. Colored text in MultiLine CEdit

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

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

5. Background & Text color CEdit

6. Background color of CEdit

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

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