NO

Author Topic: RichEdit PageBreak  (Read 4468 times)

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
RichEdit PageBreak
« on: February 06, 2005, 07:30:31 PM »
Somebody might need this:

Code: [Select]

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;
}
May the source be with you