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

This topic is 2617 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

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

Share on other sites
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.

Share on other sites

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!

1. 1
2. 2
3. 3
Rutin
18
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• Forum Statistics

• Total Topics
633659
• Total Posts
3013216
×