Sign in to follow this  
ajm113

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

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:


[code]

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';
[/code]

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 this post


Link to post
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 this post


Link to post
Share on other sites
[quote name='SiCrane' timestamp='1318347919' post='4871476']
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.
[/quote]

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! :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this