Someone helped me out, this is what they did for anyone that cares:
Code:
long SetRTF(HWND hRicheditWnd, char* szData)
{
ZeroMemory(&yummyCookie, sizeof yummyCookie);
ZeroMemory(&es, sizeof es);
yummyCookie.dwError = NULL;
yummyCookie.pbStart = (LPBYTE)szData;
yummyCookie.pbCur = yummyCookie.pbStart;
yummyCookie.bCount = strlen(szData);
es.dwError = NULL;
es.dwCookie = (DWORD)&yummyCookie;
es.pfnCallback = (EDITSTREAMCALLBACK)EditStreamCallback;
return SendMessage(hRicheditWnd, EM_STREAMIN, SF_RTF, (LPARAM)&es);
}
// -------------------------- Callback, woot.
CALLBACK EditStreamCallback(long *dwCookie, char *szBuffer, long lLength, long *lpBytesTransferred)
{
PCOOKIE pCookie = (PCOOKIE)dwCookie;
long bytesLeft, bytesRead;
bytesRead = pCookie->pbCur - pCookie->pbStart;
if (bytesRead < pCookie->bCount)
bytesLeft = pCookie->bCount - bytesRead;
else
bytesLeft = 0;
if (lLength > bytesLeft) lLength = bytesLeft;
*lpBytesTransferred = lLength;
if (lLength)
{
memcpy(szBuffer, pCookie->pbCur, lLength);
pCookie->pbCur += lLength;
}
return 0;
}
(thanks to vcv - http://sirc.tk)