Well first you have to create the Rich Edit, of course, so you call LoadLibrary with the proper dll as the argument (see here).
Then you use the EM_SETCHARFORMAT message when you want to change the color. I first filled the CHARFORMAT structure and then selected the end of the edit with the EM_SETSEL message and replaced that selection with the EM_REPLACESEL message like this:
Code:
int len=(GetWindowTextLength(GetDlgItem(hWnd, IDC_CHAT_TEXT))+1); //get edit text length
static CHARFORMAT chr = { sizeof(CHARFORMAT), CFM_COLOR, 0, 0, 0, RGB(0,0,0), 0, 0 }; //initialize the structure, only specifying color
const char* parsedmessage = parseBNMessage(tempBuffer); //this gets the text to add to the edit
switch (CurrentColor) //this is global, set by parseBNMessage()
{//pretty self-explanatory here
case CHAT_COLOR:
chr.crTextColor = RGB(0,0,255);
break;
case EMOTE_COLOR:
chr.crTextColor = RGB(252,158,18);
break;
case ERROR_COLOR:
chr.crTextColor = RGB(255,0,0);
break;
case WHISPER_COLOR:
chr.crTextColor = RGB(120,120,120);
break;
case CHANNEL_COLOR:
chr.crTextColor = RGB(0,255,0);
break;
case INFO_COLOR:
chr.crTextColor = RGB(85,255,85);
break;
case DEFAULT_COLOR:
chr.crTextColor = RGB(0,0,0);
break;
}
static CHARFORMAT* chrformat = &chr; //SendMessage needs a pointer
SendMessage(hChat, EM_SETSEL, len, len); //select the end of the edit
SendMessage(hChat, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)(chrformat)); //color and/or format text
SendMessage(hChat, EM_REPLACESEL, 0, (LPARAM)(parsedmessage)); //add the text
the parseBNMessage and switch statement are specific to my application, but I thought I'd leave it in anyways because it kind of makes it clearer what I'm doing (I think).
Hope that helps!