15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Q: Need CRichEdit Syntax Coloring Example

Karen Fura -- kfura@pop.seanet.com
Wednesday, October 09, 1996

Environment: VC++ 4.1, Win 95 

I have a CRichEditView in which I need to
do coloring of specific key words.  I believe
that I can do this with strictly plain text using
character formatting and do not need to deal with rtf.
Is there an example that someone could point me to?
Also, the coloring must occur when the user types 
in key words, such as in the Visual C++ editor.  
I have MSDN.

Is it always necessary to pair the CRichEditView
with a CRichEditDoc?  If not, what is the scenario
where one would just use a CDocument?

Thanks,

Karen Fura
kfura@levetate.com




Mike Blaszczak -- mikeblas@nwlink.com
Friday, October 11, 1996

At 08:54 10/9/96 -0700, Karen Fura  wrote:
>Environment: VC++ 4.1, Win 95 

>Also, the coloring must occur when the user types 
>in key words, such as in the Visual C++ editor.  
>I have MSDN.

The Visual C++ editor, as you'd find out if you used Spy++, doesn't
use a rich edit control for the source editor.  It's not very easy
to get text, parse it with the rules of a langiuage, and then force
the repainting of text in an alternate colour using the rich text
edit control.  You'll have to juggle lots and lots of charformat
calls.

[Moderator's note: To be fair to Karen, she did not imply that
the VC++ editor was the RTF control.  People do at times make
incorrect assumptions about MFC based on MS products, but I don't
think this is one of those cases.]

If you're just changing the formatting for particular words, I think
you might be able to pull this off. If you're using rules that affect
whole documents (Eg, like typing /* in the IDE when editing a C++
file would change everything after to the comment colour) I think
you're in for a nightmare.

.B ekiM
http://www.nwlink.com/~mikeblas/
Don't look at my hands: look at my _shoulders_!
These words are my own. I do not speak on behalf of Microsoft.





| Вернуться в корень Архива |