i need your help! So, i'm creating a RichEdit with syntax highlighter, i'm doing this way:
SendMessage(hWin, WM_SETREDRAW, false, 0);
CHARFORMAT2 format, old;
format.cbSize = sizeof(format);
old.cbSize = sizeof(format);
MainRich.GetFormat(SCF_DEFAULT, &format);
MainRich.GetFormat(SCF_DEFAULT, &old);
format.dwMask = CFM_BOLD;
format.dwEffects = CFE_BOLD;
CHARRANGE* c = MainRich.GetSelectionRange();
int length = MainRich.GetLength();
string str = string(MainRich.GetText());
#define hl "true" //Example of syntax for highlight
int last = 0;
while (str.find(hl, last)!=string::npos)
{
MainRich.Select(str.find(hl, last), str.find(hl, last)+strlen(hl));
MainRich.SetFormat(SCF_SELECTION, &format);
last = str.find(hl, last)+strlen(hl);
}
MainRich.Select(c->cpMin, c->cpMax);
MainRich.SetFormat(SCF_SELECTION, &old);
SendMessage(hWin, WM_SETREDRAW, true, 0);
UpdateWindow(hWin);
}
But i see that in big files with a lot of highlight it gets laggy, do you have a better way of doing that?I checked Iczelion's Assembly but that code is a mess, he seems to be painting the highlight in front of the text but that way the selection doesn't work, right?If it does, can you give me some hints of how to do that?Thanks!