CEdit text color 
Author Message
 CEdit text color

Hi all,

I thought it would be very simple to change the text color of the CEdit
text.  I have an edit control that derives from CEdit and I subclass the
edit controls of a dialog box.

I cannot find the message (in DefWindowProc) that would have the DC used for
painting.

What message is used to modify the DC for an edit control?

--
Hank Williams
Quantum Technologies, Inc.



Mon, 13 Dec 2004 17:36:25 GMT  
 CEdit text color

Quote:
>I thought it would be very simple to change the text color of the CEdit
>text.  I have an edit control that derives from CEdit and I subclass the
>edit controls of a dialog box.

>What message is used to modify the DC for an edit control?

Hank,

Handle the WM_CTLCOLOREDIT message - OnCtlColor in MFC.

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.



Mon, 13 Dec 2004 21:26:40 GMT  
 CEdit text color
The WM_CTLCOLOREDIT message is sent from the edit control to the parent
window (dialog).
I am looking for a message in the edit control itself.
I though WM_PAINT would do it, but it does not pass a DC (Device Context).

--
Hank Williams
Quantum Technologies, Inc.


| >I thought it would be very simple to change the text color of the CEdit
| >text.  I have an edit control that derives from CEdit and I subclass the
| >edit controls of a dialog box.
| >
| >What message is used to modify the DC for an edit control?
|
| Hank,
|
| Handle the WM_CTLCOLOREDIT message - OnCtlColor in MFC.
|
| 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.



Tue, 14 Dec 2004 04:16:11 GMT  
 CEdit text color
Have you subclassed the CEdit control?
If so you can handle WM_CTLCOLOREDIT

Nish


Quote:
> The WM_CTLCOLOREDIT message is sent from the edit control to the parent
> window (dialog).
> I am looking for a message in the edit control itself.
> I though WM_PAINT would do it, but it does not pass a DC (Device Context).

> --
> Hank Williams
> Quantum Technologies, Inc.



> | >I thought it would be very simple to change the text color of the CEdit
> | >text.  I have an edit control that derives from CEdit and I subclass
the
> | >edit controls of a dialog box.
> | >
> | >What message is used to modify the DC for an edit control?
> |
> | Hank,
> |
> | Handle the WM_CTLCOLOREDIT message - OnCtlColor in MFC.
> |
> | 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.



Tue, 14 Dec 2004 05:20:09 GMT  
 CEdit text color
Yes, I have subclassed CEdit control.  I also added the WM_CTLCOLOREDIT to
the parent dialog and all I got was painting of the background (not Text
Color).

MSDN states:

    If an application processes this message, it must return the
    handle of a brush. The system uses the brush to paint the
    background of the edit control.

As I said, I am looking for the 'message' in CEdit that can be used to
control the foreground text color.

--
Hank Williams
Quantum Technologies, Inc.



| Have you subclassed the CEdit control?
| If so you can handle WM_CTLCOLOREDIT
|
| Nish
|


| > The WM_CTLCOLOREDIT message is sent from the edit control to the parent
| > window (dialog).
| > I am looking for a message in the edit control itself.
| > I though WM_PAINT would do it, but it does not pass a DC (Device
Context).
| >
| > --
| > Hank Williams
| > Quantum Technologies, Inc.
| >
| >


| > | >I thought it would be very simple to change the text color of the
CEdit
| > | >text.  I have an edit control that derives from CEdit and I subclass
| the
| > | >edit controls of a dialog box.
| > | >
| > | >What message is used to modify the DC for an edit control?
| > |
| > | Hank,
| > |
| > | Handle the WM_CTLCOLOREDIT message - OnCtlColor in MFC.
| > |
| > | 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.
| >
| >
| >
|
|



Tue, 14 Dec 2004 13:24:25 GMT  
 CEdit text color
The point is (if I'm not mistaken) that you should handle the
WM_CTLCOLOREDIT message in your derived CEdit class, not the dialog.

--
Bjarne Nielsen



Quote:
> Yes, I have subclassed CEdit control.  I also added the WM_CTLCOLOREDIT to
> the parent dialog and all I got was painting of the background (not Text
> Color).

> MSDN states:

>     If an application processes this message, it must return the
>     handle of a brush. The system uses the brush to paint the
>     background of the edit control.

> As I said, I am looking for the 'message' in CEdit that can be used to
> control the foreground text color.

> --
> Hank Williams
> Quantum Technologies, Inc.



> | Have you subclassed the CEdit control?
> | If so you can handle WM_CTLCOLOREDIT
> |
> | Nish
> |


> | > The WM_CTLCOLOREDIT message is sent from the edit control to the
parent
> | > window (dialog).
> | > I am looking for a message in the edit control itself.
> | > I though WM_PAINT would do it, but it does not pass a DC (Device
> Context).
> | >
> | > --
> | > Hank Williams
> | > Quantum Technologies, Inc.
> | >
> | >


> | > | >I thought it would be very simple to change the text color of the
> CEdit
> | > | >text.  I have an edit control that derives from CEdit and I
subclass
> | the
> | > | >edit controls of a dialog box.
> | > | >
> | > | >What message is used to modify the DC for an edit control?
> | > |
> | > | Hank,
> | > |
> | > | Handle the WM_CTLCOLOREDIT message - OnCtlColor in MFC.
> | > |
> | > | 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.
> | >
> | >
> | >
> |
> |



Tue, 14 Dec 2004 14:02:27 GMT  
 CEdit text color
The message does not get sent to CEdit.

--
Hank Williams
Quantum Technologies, Inc.


| The point is (if I'm not mistaken) that you should handle the
| WM_CTLCOLOREDIT message in your derived CEdit class, not the dialog.
|
| --
| Bjarne Nielsen
|


| > Yes, I have subclassed CEdit control.  I also added the WM_CTLCOLOREDIT
to
| > the parent dialog and all I got was painting of the background (not Text
| > Color).
| >
| > MSDN states:
| >
| >     If an application processes this message, it must return the
| >     handle of a brush. The system uses the brush to paint the
| >     background of the edit control.
| >
| > As I said, I am looking for the 'message' in CEdit that can be used to
| > control the foreground text color.
| >
| > --
| > Hank Williams
| > Quantum Technologies, Inc.
| >
| >


| > | Have you subclassed the CEdit control?
| > | If so you can handle WM_CTLCOLOREDIT
| > |
| > | Nish
| > |


| > | > The WM_CTLCOLOREDIT message is sent from the edit control to the
| parent
| > | > window (dialog).
| > | > I am looking for a message in the edit control itself.
| > | > I though WM_PAINT would do it, but it does not pass a DC (Device
| > Context).
| > | >
| > | > --
| > | > Hank Williams
| > | > Quantum Technologies, Inc.
| > | >
| > | >


| > | > | >I thought it would be very simple to change the text color of the
| > CEdit
| > | > | >text.  I have an edit control that derives from CEdit and I
| subclass
| > | the
| > | > | >edit controls of a dialog box.
| > | > | >
| > | > | >What message is used to modify the DC for an edit control?
| > | > |
| > | > | Hank,
| > | > |
| > | > | Handle the WM_CTLCOLOREDIT message - OnCtlColor in MFC.
| > | > |
| > | > | 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.
| > | >
| > | >
| > | >
| > |
| > |
| >
| >
| >
|
|



Tue, 14 Dec 2004 15:15:36 GMT  
 CEdit text color

Quote:
>The message does not get sent to CEdit.

Hank,

MFC has a "reflection" mechanism where notification messages can be
handled in the derived class as well as the parent.

MFC also wraps all the WM_CTLCOLOR* messages into a single WM_CTLCOLOR
wrapper (backward compatibility with old 16-bit code) which is made
accessible via reflection and is represented as =WM_CTLCOLOR in the
UI. Have a look at "TN062: Message Reflection for Windows Controls" in
the VC++ help.

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.



Tue, 14 Dec 2004 19:07:20 GMT  
 CEdit text color
Thanks,

Message Reflection does work.

--
Hank Williams
Quantum Technologies, Inc.


| >The message does not get sent to CEdit.
|
| Hank,
|
| MFC has a "reflection" mechanism where notification messages can be
| handled in the derived class as well as the parent.
|
| MFC also wraps all the WM_CTLCOLOR* messages into a single WM_CTLCOLOR
| wrapper (backward compatibility with old 16-bit code) which is made
| accessible via reflection and is represented as =WM_CTLCOLOR in the
| UI. Have a look at "TN062: Message Reflection for Windows Controls" in
| the VC++ help.
|
| 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.



Wed, 15 Dec 2004 16:11:29 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. CEdit text color

2. CEdit text color

3. Disabled CEdit Text Color

4. CEdit Text Color

5. CEdit Text Color

6. Background & Text color CEdit

7. Changing text color in a CEdit box

8. coloring text in CEdit or....?

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

10. Question on changing text color in CEdit Control

11. CEdit and text color

12. CEdit Disabled Text Color

 

 
Powered by phpBB® Forum Software