Okay okay, if I ask too much, tell me so *g* but understand it more as a compliment, if here weren't so many peeps who actually can HELP, I wouldn't ask that much
well anyway, here's my next problem:
The following function adds a string to the contents of a rich edit:
Code:
BOOL OutputLine(HWND hEdit, LPSTR pszAddText, BYTE red, BYTE green, BYTE blue)
{
static CHARFORMAT2 charFormat;
char pszText[1000];
DWORD dwBufferSize;
int firstChar;
int currentLine;
dwBufferSize = GetWindowTextLength(hEdit)+1;
GetWindowText(hEdit, pszText, dwBufferSize);
strcat(pszText, pszAddText);
SetWindowText(hEdit, pszText);
currentLine = (INT) SendMessage(hEdit, EM_GETLINECOUNT, 0, 0); currentLine-=2;
firstChar = (INT) SendMessage(hEdit, EM_LINEINDEX, (WPARAM) currentLine, 0);
SendMessage(hEdit, EM_SETSEL, (WPARAM) firstChar, (LPARAM) -1);
ZeroMemory(&charFormat,sizeof(CHARFORMAT2));
charFormat.cbSize = sizeof(CHARFORMAT); charFormat.dwMask = CFM_COLOR;
charFormat.crTextColor = RGB(red,green,blue);
SendMessage(hEdit, EM_SETCHARFORMAT, (WPARAM) SCF_SELECTION | SCF_WORD, (LPARAM) &charFormat);
SendMessage( hEdit, EM_LINESCROLL, 0, 1 );
return 1;
}
I call it for example so:
Code:
sprintf(pszTemp, "Temp content: %d\r\n", test);
OutputLine(hEditOutput, pszTemp,0,0,255);
well and it should also set the color of the newly added text.
The thing is, the string is correctly added and scrolled into view, but the thing with the color doesn't work quite the way I wanted it to be. It does set the added line of text in the color I pass to the function, but everything else (including colored lines I added before) goes black again. (I hope this was described in an understandable way.)
I don't really get why it behaves so
PrivatePanic