Discussion:
CEdit text color
(too old to reply)
BobF
2005-10-11 18:34:40 UTC
Permalink
I *assumed* this would be easy ...

I have a dialog-based app with a CEdit control to display data being
monitored by the app.

I add text to the control with ReplaceSel. Each event being displayed is a
single line.

I would like different colored text for different events (lines) being
displayed. How do I specify text color on a ReplaceSel call by ReplaceSel
call basis?

TIA
AliR
2005-10-11 19:22:57 UTC
Permalink
You can change the text color of an edit control by catching WM_CTLCOLOR and
chaning the text color of the DC.

If you want multiple colors to be displayed at the same time, I would use a
CRichEditCtrl.

AliR.
Post by BobF
I *assumed* this would be easy ...
I have a dialog-based app with a CEdit control to display data being
monitored by the app.
I add text to the control with ReplaceSel. Each event being displayed is a
single line.
I would like different colored text for different events (lines) being
displayed. How do I specify text color on a ReplaceSel call by ReplaceSel
call basis?
TIA
BobF
2005-10-11 19:27:42 UTC
Permalink
Post by AliR
You can change the text color of an edit control by catching WM_CTLCOLOR and
chaning the text color of the DC.
If you want multiple colors to be displayed at the same time, I would use a
CRichEditCtrl.
AliR.
I'm in the process of adding the CRichEditCtrl, but the strangest thing
happens. By just adding the control to an otherwise functional application
(dialog-based), the app exits immediately when I try to start it, without
ever displaying the dialog.

Strange ...
Arman Sahakyan
2005-10-11 19:57:04 UTC
Permalink
Hi,

Just call AfxInitRichEdit() at the begining of InitInstance.
--
======
Arman
Post by BobF
Post by AliR
You can change the text color of an edit control by catching WM_CTLCOLOR and
chaning the text color of the DC.
If you want multiple colors to be displayed at the same time, I would use a
CRichEditCtrl.
AliR.
I'm in the process of adding the CRichEditCtrl, but the strangest thing
happens. By just adding the control to an otherwise functional application
(dialog-based), the app exits immediately when I try to start it, without
ever displaying the dialog.
Strange ...
BobF
2005-10-11 20:28:44 UTC
Permalink
Post by Arman Sahakyan
Hi,
Just call AfxInitRichEdit() at the begining of InitInstance.
I got it, thanks. I left it out 'cause the docs say it isn't necessary for
CRichEditCtrl. I went ahead and tried and now everything is good. Well,
except for line endings, but that's a different thing.

Thanks for looking at it
leov SpamMeNot
2005-10-12 21:10:51 UTC
Permalink
You might consider a CListCtrl in Report View for this. Each row in the
CListCtrl would represent a line in what is now your CEdit. Each row can
not only have a different color, but icons and columns that are sortable
(with the appropriate programming on your part, of course).
Post by BobF
I *assumed* this would be easy ...
I have a dialog-based app with a CEdit control to display data being
monitored by the app.
I add text to the control with ReplaceSel. Each event being displayed is a
single line.
I would like different colored text for different events (lines) being
displayed. How do I specify text color on a ReplaceSel call by ReplaceSel
call basis?
TIA
Continue reading on narkive:
Loading...