I got this working a few days ago, gonna post my solution so anyone having the same problem can learn with it :)
HWND richtextHandler //must be global
int chatlog_ADD(const char* msg, int mode=0)
{
CHARRANGE selection;
CHARFORMAT fontFormat;
memset(&fontFormat, 0, sizeof fontFormat);
fontFormat.cbSize = sizeof fontFormat;
switch(mode)
{
case 0: //DEFAULT BLUE TEXT
fontFormat.dwMask = CFM_COLOR;
fontFormat.crTextColor = RGB(0,0,255);
break;
case 1: //BOLD RED TEXT
fontFormat.dwEffects = CFE_BOLD;
fontFormat.dwMask = CFM_COLOR|CFM_BOLD;
fontFormat.crTextColor = RGB(255,0,0);
break;
case 3: //DARK GREEN TEXT
fontFormat.dwMask = CFM_COLOR;
fontFormat.crTextColor = RGB(0,128,0);
break;
}
//Move caret to the end of the text
selection.cpMin = -1;
selection.cpMax = -1;
SendMessage(richtextHandler, EM_EXSETSEL, 0, (LPARAM)&selection);
//Retrieves the curent position
SendMessage(richtextHandler, EM_EXGETSEL, 0, (LPARAM)&selection);
//ADDs the text
SendMessage(richtextHandler, EM_REPLACESEL, 0, (LPARAM)msg);
//Move caret back to the start of the line (position retrieved earlier)
SendMessage(richtextHandler, EM_EXSETSEL, 0, (LPARAM)&selection);
//Set endindg position to the end of the line
selection.cpMax = -1;
//Selects the line you added
SendMessage(richtextHandler, EM_EXSETSEL, 0, (LPARAM)&selection);
//Applies the format
SendMessage(richtextHandler , EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &fontFormat);
//Set the caret to the end again
selection.cpMin = -1;
selection.cpMax = -1;
SendMessage(richtextHandler, EM_SETSEL, 0,(LPARAM)&selection );
//Scrolls down the scroll bar :)
SendMessage(richtextHandler, WM_VSCROLL, SB_BOTTOM, (LPARAM)NULL);
}