Rich Edit Win32 C++, Getting lines, changing fonts in specific areas?

Started by
1 comment, last by ajm113 12 years, 6 months ago
Hello I'm writing a IDE for my programming language that's in WIP, and so far Rich Edit is a big pain trying to manipulate using subclasses to do what I want. I'm trying to make a syntax highlighting system and I want to write it from scratch. So I have more flexibility and gain some experience working with it. The two main problems I'm having is first of all: How do I get a line's text?

I've written this:




int iCommandLen = int(SendMessage(hWnd2, WM_GETTEXTLENGTH, 0, 0));
char *szCommand = new char[iCommandLen+1];
SendMessage(hWnd2, EM_GETLINE, 1, LPARAM(szCommand));
szCommand[iCommandLen] = '\0';


From the get error function from Win32 returns 6 as a invalid handler just after SendMessage, EM_GETLINE. I've done the research and it appears only I am having this issue on the net.

Also of course from my syntax highlighter I have to be able to change color or font of a pacific area of code when a keyword pops up when someone types it. Is there a way I can change font using something like:
const char* appendText = "\f\0\0\255\250\ Keyword! \f\255\255\255\250\"

Where it manipulates the text to have hidden commands for coloring that keyword on rich edit?

Thank you for any help!
-Ajm
Check out my open source code projects/libraries! My Homepage You may learn something.
Advertisement
I would seriously recommend not trying to work with rich edit controls for syntax highlighting; it's just not designed to be extended in this way. Either write your own text box from scratch or grab an existing syntax highlighting control like Scintilla.

In any case, your EM_GETLINE parameters aren't quite right. The buffer you pass with EM_GETLINE should contain the buffer size in the first word. You have it uninitialized.

I would seriously recommend not trying to work with rich edit controls for syntax highlighting; it's just not designed to be extended in this way. Either write your own text box from scratch or grab an existing syntax highlighting control like Scintilla.

In any case, your EM_GETLINE parameters aren't quite right. The buffer you pass with EM_GETLINE should contain the buffer size in the first word. You have it uninitialized.


Hey thanks! eehhh... In that case I may fallow the "NEATpad" tutorials from catch22, if it doesn't work out I'll just go with Scintilla.

Thanks again! :)
Check out my open source code projects/libraries! My Homepage You may learn something.

This topic is closed to new replies.

Advertisement