Syntax Highlighting (How?)

Started by
11 comments, last by GameDev.net 17 years, 9 months ago
Quote:// The pointer to my rich edit control.
extern CRichEditCtrl* pmyRichEditCtrl;
CHARFORMAT cf;

// Modify the word format so that the selected word is
// displayed in bold and not striked out.
cf.dwMask = CFM_STRIKEOUT|CFM_BOLD;
cf.dwEffects = CFE_BOLD;
pmyRichEditCtrl->SetWordCharFormat(cf);

That seems like what I need to do...so I have to select the text (from within the program) and then set the color of that text? Hmmm...that seems a little foreign to me. Oh well, how do I select text then?

Whoa, wait...I just noticed this: "CRichEditCtrl". Is that MFC? Sorry, bud, I don't do MFC. I like small/fast programs.

I tried creating a RichEdit using CreateWindowEx(...) but it didn't show up. I can't post the code because I don't have it anymore (sorry...why would I keep code that doesn't work? I just replaced it with a normal edit until I can figure this out).

I can't seem to find any good Rich Edit tutorials online using simple Win32 - They all use MFC! Grr...
Advertisement
Quote:Sorry, bud, I don't do MFC. I like small/fast programs.

Sorry about the MFC code. I work with it everyday so forget other people don't use it. [sidenote] Small is not necessarily fast [/sidenote]

Use EM_SETCHARFORMAT instead.

To create a richedit view call LoadLibraryA("RICHED20.DLL") in winmain.
Then call CreateWindowEx with classname set to RICHEDIT_CLASS
you need to #include <richedit.h> to get access to RICHEDIT_CLASS
Don't forget to FreeLibrary(hRichEditInstance) before you exit.
Marcus SpeightIf at first you don't succeed.
Destroy all evidence that you tried.
http://catch22.net/tuts/editor04.asp is a start

This topic is closed to new replies.

Advertisement