Change the background color of a dialog box and change text color of Edit Box, Static Text, Rich Edit 
Author Message
 Change the background color of a dialog box and change text color of Edit Box, Static Text, Rich Edit

Hi

Does any one know how to change the background color of a dialog boxes
and the buttons?

How do you how to change the text color and font of an Edit Box, Static
Text, and Rich Edit?

Please reply soon.

Thanks



Fri, 19 Apr 2002 03:00:00 GMT  
 Change the background color of a dialog box and change text color of Edit Box, Static Text, Rich Edit
Egan:

To change color of CEdit and CStatic you have to override WM_CTLCOLOR. Same
goes for a dialog.

A push button background can only be changed by making it owner draw. Take a
look at codeguru.developer.com for examples.

Following MSDN articles are also helpful:

HOWTO: Change the Color of an MFC Child Control Class
Article ID: Q132080

 HOWTO: Change the Color of an Edit Control
Article ID: Q74043

HOWTO: Change Window Background Color with Foundation Classes
Article ID: Q103786

HOWTO: Change the Background Color of an MFC Edit Control
Article ID: Q117778

SAMPLE: Owner-Draw: OdButton.exe - 3-D Push Button
Article ID: Q64328

HOWTO: Change Dialog Box Background Color in MFC 2.0 or Later
Article ID: Q98201

--
Ajay Kalra

Microsoft Visual C++  MVP

Quote:

>Hi

>Does any one know how to change the background color of a dialog boxes
>and the buttons?

>How do you how to change the text color and font of an Edit Box, Static
>Text, and Rich Edit?

>Please reply soon.

>Thanks



Fri, 19 Apr 2002 03:00:00 GMT  
 Change the background color of a dialog box and change text color of Edit Box, Static Text, Rich Edit
Wilson:

WM_CTLCOLOR is sent for each of the children which can respond to it.. So if
you have two edit controls, you would get it twice. 2nd parameter of this
function call: OnCtlColor( CDC* pDC, CWnd* pWnd, UINT nCtlColor ), points
the window which is asking for color. Compare window handles and you would
know which window called it.

--
Ajay Kalra

Microsoft Visual C++  MVP

Quote:

>The WM_CTLCOLOR would change all the edit control 's color, if i want to
>change one of the edit box.

>How i can do it?



>> Egan:

>> To change color of CEdit and CStatic you have to override WM_CTLCOLOR.
>Same
>> goes for a dialog.

>> A push button background can only be changed by making it owner draw.
Take
>a
>> look at codeguru.developer.com for examples.

>> Following MSDN articles are also helpful:

>> HOWTO: Change the Color of an MFC Child Control Class
>> Article ID: Q132080

>>  HOWTO: Change the Color of an Edit Control
>> Article ID: Q74043

>> HOWTO: Change Window Background Color with Foundation Classes
>> Article ID: Q103786

>> HOWTO: Change the Background Color of an MFC Edit Control
>> Article ID: Q117778

>> SAMPLE: Owner-Draw: OdButton.exe - 3-D Push Button
>> Article ID: Q64328

>> HOWTO: Change Dialog Box Background Color in MFC 2.0 or Later
>> Article ID: Q98201

>> --
>> Ajay Kalra

>> Microsoft Visual C++  MVP


>> >Hi

>> >Does any one know how to change the background color of a dialog boxes
>> >and the buttons?

>> >How do you how to change the text color and font of an Edit Box, Static
>> >Text, and Rich Edit?

>> >Please reply soon.

>> >Thanks



Fri, 19 Apr 2002 03:00:00 GMT  
 Change the background color of a dialog box and change text color of Edit Box, Static Text, Rich Edit
The WM_CTLCOLOR would change all the edit control 's color, if i want to
change one of the edit box.

How i can do it?


Quote:
> Egan:

> To change color of CEdit and CStatic you have to override WM_CTLCOLOR.
Same
> goes for a dialog.

> A push button background can only be changed by making it owner draw. Take
a
> look at codeguru.developer.com for examples.

> Following MSDN articles are also helpful:

> HOWTO: Change the Color of an MFC Child Control Class
> Article ID: Q132080

>  HOWTO: Change the Color of an Edit Control
> Article ID: Q74043

> HOWTO: Change Window Background Color with Foundation Classes
> Article ID: Q103786

> HOWTO: Change the Background Color of an MFC Edit Control
> Article ID: Q117778

> SAMPLE: Owner-Draw: OdButton.exe - 3-D Push Button
> Article ID: Q64328

> HOWTO: Change Dialog Box Background Color in MFC 2.0 or Later
> Article ID: Q98201

> --
> Ajay Kalra

> Microsoft Visual C++  MVP


> >Hi

> >Does any one know how to change the background color of a dialog boxes
> >and the buttons?

> >How do you how to change the text color and font of an Edit Box, Static
> >Text, and Rich Edit?

> >Please reply soon.

> >Thanks



Sat, 20 Apr 2002 03:00:00 GMT  
 Change the background color of a dialog box and change text color of Edit Box, Static Text, Rich Edit
try

HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
        HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

        static CBrush  rBr(RGB(255,255,255));
     // TODO: Change any attributes of the DC here
        UINT ID = pWnd->GetDlgCtrlID();
        if (ID == IDC_THE_ID_YOU_WANT)
pDC->SetBkColor(RGB(255,255,255));

        return(rBr);

Quote:
}



Quote:
> The WM_CTLCOLOR would change all the edit control 's color, if i want to
> change one of the edit box.

> How i can do it?



> > Egan:

> > To change color of CEdit and CStatic you have to override WM_CTLCOLOR.
> Same
> > goes for a dialog.

> > A push button background can only be changed by making it owner draw.
Take
> a
> > look at codeguru.developer.com for examples.

> > Following MSDN articles are also helpful:

> > HOWTO: Change the Color of an MFC Child Control Class
> > Article ID: Q132080

> >  HOWTO: Change the Color of an Edit Control
> > Article ID: Q74043

> > HOWTO: Change Window Background Color with Foundation Classes
> > Article ID: Q103786

> > HOWTO: Change the Background Color of an MFC Edit Control
> > Article ID: Q117778

> > SAMPLE: Owner-Draw: OdButton.exe - 3-D Push Button
> > Article ID: Q64328

> > HOWTO: Change Dialog Box Background Color in MFC 2.0 or Later
> > Article ID: Q98201

> > --
> > Ajay Kalra

> > Microsoft Visual C++  MVP


> > >Hi

> > >Does any one know how to change the background color of a dialog boxes
> > >and the buttons?

> > >How do you how to change the text color and font of an Edit Box, Static
> > >Text, and Rich Edit?

> > >Please reply soon.

> > >Thanks



Sat, 20 Apr 2002 03:00:00 GMT  
 Change the background color of a dialog box and change text color of Edit Box, Static Text, Rich Edit

Quote:

>OnCtlColor( CDC* pDC, CWnd* pWnd, UINT nCtlColor ), points
>the window which is asking for color. Compare window handles and you would
>know which window called it

PMJI....

Note carefully what Ajay said here, by the way : you must compare
window handles (or use GetDlgCtrlID and compare IDs), because the CWnd
pointer returned with OnCtlColor is a temporary pointer and can't be
compared directly with the current CWnd* for the control.

--
Bob Moore [MVP]
http://www.mooremvp.freeserve.co.uk
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Due to an unreasonable amount of queries, I no
longer answer unsolicited email questions. Sorry,
no exceptions.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Sat, 20 Apr 2002 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. How to change the background color of an edit box

2. Help, VC++ Edit Box: change the text color

3. How to change text color of edit box?

4. Change background color of dialog box title

5. Change Dialog Box Background Color

6. Change background color of a Dialog box?

7. I would like to change the background color of a dialog box

8. Change background color of a Dialog box?

9. How to change the color,size,font of text in a dialog box

10. How to change the color,size,font of text in a dialog box

11. Change text color and background color in CEditView

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

 

 
Powered by phpBB® Forum Software