Let's say you want to be able to log data to a Windows console window and want to use the convenience of
printf.
The hole with this example is that it does not handle cases where the string exceeds the fixed array size.
Thanks to folks
on this forum for the help.
void Log(const char* pszText)
{
int nLength = GetWindowTextLength(hwndEdit);
SendMessage(hwndEdit, EM_SETSEL, (WPARAM)nLength, (LPARAM)nLength);
SendMessage(hwndEdit,EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)pszText);
}
void Logf(char* fmt, ...)
{ char buf[1000];
va_list ap;
va_start (ap, fmt);
vsprintf(buf, fmt, ap);
va_end(ap);
Log(buf);
}
--
MattWalsh - 02 Feb 2006