Skip to main content
gamedev.net
🔒 Locked

Text loading to richedit?

Started by Craazer Jul 23, 2003 at 4:26 AM 3 replies 350+ views
Original Post
Craazer
Craazer
Hi I allready made callback to save content''s of richedit to a text file but now I dont understand. Howto make callback for loading becose there isn''t any messages to insert text to edit control?
Yanroy
Yanroy
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

Yanroy@usa.com

--------------------

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
Craazer
Craazer
quote:
Original post by Burning_Ice
you can use WM_SETTEXT or EM_SETTEXTEX





Great, thanks!

Dak Lozar
Dak Lozar



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
Dave Dak Lozar Loeser
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."--anonymous

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.