>> But I'm not sure how those positions are specified, are they in the form of line number and char position co-ordinates, <<
The starting and ending character positions.
Code:
#include <windows.h>
#include <stdio.h>
#include <stdarg.h>
#include <tchar.h>
/*
* Sample: AppendText(hwndEdit, "The count is %d\r\n", 23);
* Note: Use "\r\n" instead of just "\n" to start a new line.
*/
void AppendText(HWND hwnd, LPCTSTR szFormat, ...)
{
TCHAR szText[4096];
va_list args;
int nTxtLen;
/* Move selection to end of text */
nTxtLen = GetWindowTextLength(hwnd);
SendMessage(hwnd, EM_SETSEL, nTxtLen, nTxtLen);
/* Format the text into the buffer */
va_start(args, szFormat);
_vsntprintf(szText, sizeof(szText) / sizeof(szText[0]), szFormat, args);
szText[(sizeof(szText) / sizeof(szText[0])) - 1] = TEXT('\0');
va_end(args);
/* Add the text line and scroll it into view */
SendMessage(hwnd, EM_REPLACESEL, FALSE, (LPARAM) szText);
SendMessage(hwnd, EM_SCROLLCARET, 0, 0);
}