Background & Text color CEdit 
Author Message
 Background & Text color CEdit

How can I change the backcolor and the textcolor of a CEdit if I know the
resource ID (e.g. IDC_EDIT1)??

Lets say I want the background black and the text white.

Thanx for your help.

Willem



Sat, 12 Oct 2002 03:00:00 GMT  
 Background & Text color CEdit

Quote:
>How can I change the backcolor and the textcolor of a CEdit if I know the
>resource ID (e.g. IDC_EDIT1)??

Willem,

Handle OnCtlColor:

HBRUSH CBitDlgDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
        if ( ( nCtlColor == CTLCOLOR_EDIT ) &&
                ( pWnd->GetWindowsLong(GWL_ID) == IDC_EDIT1 ) )
        {
                   LOGBRUSH LogBrush;

                   LogBrush.lbStyle = BS_SOLID;
                   LogBrush.lbColor = RGB( 127, 127, 127);

                   SetTextColor( pDC->m_hDC, RGB( 255, 255, 255 ) );
                   SetBkColor( pDC->m_hDC, RGB( 127, 127, 127) );

                   hbr = CreateBrushIndirect( &LogBrush );
        }

        return hbr;

Quote:
}

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.


Sat, 12 Oct 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

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

2. Setting text and background color in CEdit

3. Colored background and text in a CEdit control

4. Setting background & text color

5. Background Color, Text Color

6. Background color and text color in menu

7. Change text color and background color in CEditView

8. Change a part of Background color or a part of text color from CListCtrl

9. set the text color and the background color of a Control Cbutton

10. CEditView Background Color & Font Color :: MFC

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

12. Background color of CEdit

 

 
Powered by phpBB® Forum Software