Original Post
🔒 Locked
Text loading to richedit?
Advertisement
I''m not sure if it will work or not, but have you checked out the SetWindowText() function? (if you''re using MFC)
--------------------
You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor
--------------------
You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor
Here''s how you can do it (I''m using WTL)
EDITSTREAM es;
es.dwCookie = (DWORD)&m_ReportText; // m_ReportText is a WTL::CString
es.dwError = 0;
es.pfnCallback = StreamReadCallback;
m_RichEdit.StreamIn(SF_TEXT|SF_UNICODE, es);
if(es.dwError)
{
::MessageBox(NULL,L"Error opening report text", L"Error", MB_OK);
this->EndDialog(es.dwError);
return 0;
}
and here''s the callback funcion. dwCookie is the WTL::CString that I want loaded
static DWORD CALLBACK StreamReadCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG FAR *pcb)
{
_ASSERTE(dwCookie != 0);
_ASSERTE(pcb != NULL);
WTL::CString* tmp = (WTL::CString*)dwCookie;
long lng = tmp->GetLength();
if(lng > cb)
{
memcpy(pbBuff, tmp->Left(cb),cb);
*tmp = tmp->Mid(cb);
*pcb = cb;
return 0;
}
else if(lng > 0)
{
memcpy(pbBuff, tmp->Left(lng),lng);
*tmp = tmp->Mid(lng);
*pcb = lng;
return 0;
}
if(lng == 0)
{
*pcb = 0;
return 0;
}
return 0;
}
One thing to note, I stumbled onto some issues with the RTF control not displaying advanced RTF files
using the following will fix this:
::SendMessage(m_RichEdit.m_hWnd, EM_SETTYPOGRAPHYOPTIONS, TO_ADVANCEDTYPOGRAPHY, TO_ADVANCEDTYPOGRAPHY );
HTH,
Dave "Dak Lozar" Loeser
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement