I’m writing a small app that needs to be small and run on old systems. That’s why I can’t use .NET.
How can I change the color of the Edit control?
Here’s the .NET code:
textBoxLog.SelectionColor = color;
textBoxLog.AppendText(String.Format(s + "\n", parameters));
Update
Okay, so I managed to place the control on my form. How do I use the EM_SETCHARFORMAT message?
LoadLibrary(TEXT("Riched32.dll"));
CreateWindow("richedit", text, WS_VISIBLE | WS_CHILD | type, left, top, width, height, parent, NULL, NULL, NULL);
Update 2
I solved it. Turned out to be pretty easy:
SendMessage( textBoxLog , EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&RedFont);
Where RedFont is
CHARFORMAT cf;
memset( &cf, 0, sizeof cf );
cf.cbSize = sizeof cf;
cf.dwMask = CFM_COLOR;
cf.crTextColor = RGB(255,0,0);
CHARFORMAT RedFont = cf;
Don’t forget to include “richedit.h”
The TextBox class doesn’t have a SelectionColor property. You are using a RichTextBox.
Use a rich edit control in native code, EM_SETCHARFORMAT message.