I am using messages to a Rich Edit box to assign a text colour to individual characters or sequences of characters. Here is (part of) the code.
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND reeditbox;
CHARFORMAT2A recf2;
switch (message)
{
case WM_COMMAND:
{
int wmId = LOWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
reeditbox = CreateRichEdit(hWnd, 0, 0, 500, 500, 0);
// --- issue EM_GETCHARFORMAT / EM_SETCHARFORMAT to test changing edit box characteristics
recf2.cbSize = sizeof(struct CHARFORMAT2A);
// --- try Red
SendMessage(reeditbox, EM_SETSEL, (WPARAM)5, (LPARAM)6);
SendMessage(reeditbox, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM) &recf2);
if (recf2.dwEffects & CFE_AUTOCOLOR)
recf2.dwEffects -= CFE_AUTOCOLOR;
recf2.crTextColor = RGB(255, 0, 0);
recf2.dwEffects |= CFE_UNDERLINE;
recf2.dwMask |= CFM_UNDERLINE;
SendMessage(reeditbox, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&recf2);
I am trying to find out whether there is an appropriate way of implementing syntax colouring for C using Rich Edit boxes. I think there is no easy way of doing this. You would have to code a solution to read character attributes eg text colour, and write character attriibutes again eg text colour. There is no function built into Windows to deal with syntax colouring.
Of the solutions to syntax colouring, do any of them involve the coding of Rich Edit boxes?
Please tell me if my understanding is correct. Thank you for your answers.