Somebody might need this:
static DWORD CALLBACK PageBreakCallBack(DWORD dwCookie, LPBYTE lpBuffer, LONG lSize, LONG *plWrite)
{
LONG c;
char szString[] = "{\\rtf\\page \\par}\0";
c = lSize;
c = lstrlen(szString);
if (*plWrite > c) {
lstrcpyn(lpBuffer, szString, c+1);
*plWrite = c;
return 0; // keep on reading
} else return c; // stop it
}
int InsertPageBreak(HWND hWndRE)
{
EDITSTREAM es;
CHARRANGE crSel;
DWORD nRead;
SendMessage(hWndEdit, EM_EXGETSEL, 0, (LPARAM)&crSel);
crSel.cpMax = crSel.cpMin; // safe
SendMessage(hWndEdit, EM_EXSETSEL, 0, (LPARAM)&crSel);
es.dwCookie = 0;
es.dwError = 0;
es.pfnCallback = PageBreakCallBack;
nRead = SendMessage(hWndRE, EM_STREAMIN, SF_RTF | SFF_SELECTION, (LPARAM) &es);
return nRead;
}