Hi,
I looked into forum and found following links that says loading HTML content is not supported in wxRichTextCtrl.
viewtopic.php?t=38274
viewtopic.php?t=45019
I have a function in which I can save the RTC's content as HTML and edit later if needed. I can save the data as HTML but couldn't populate it back.
as wxRichTextHTMLHandler::LoadFile is not implemented.
Can you please suggest any workaround for this? Can I save the richtext in different format so I can load it back? Let me know if there a other way to where user can create, save, load, and edit rich text.
Please suggest.
Thanks,
R.
[wxMSW][wx3.0.3] wxRichTextCtrl: Loading HTML string. Topic is solved
Re: [wxMSW][wx3.0.3] wxRichTextCtrl: Loading HTML string.
Unfortunately that's a big limitation of wxRTC. The only format it can read and write while retaining style information is its proprietary XML based format. That is technically human readable (and editable), but you need to know what you're doing.Can you please suggest any workaround for this? Can I save the richtext in different format so I can load it back? Let me know if there a other way to where user can create, save, load, and edit rich text.
Use the source, Luke!
Re: [wxMSW][wx3.0.3] wxRichTextCtrl: Loading HTML string.
Thanks for the reply. I was stuck.
I tried XML handler and it works for me. I can save the rich text as XML and load it later.
Code is as follows,
I tried XML handler and it works for me. I can save the rich text as XML and load it later.
Code is as follows,
Code: Select all
// Save
wxStringOutputStream strStream(m_rtcStr);
wxRichTextXMLHandler xmlHander;
xmlHander.SetFlags(wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_BASE64); // save embedded image as base 64 str
if(xmlHander.SaveFile(&m_rtcCtrl->GetBuffer(), strStream) == false)
return;
// Load
wxRichTextXMLHandler xmlHander;
wxStringInputStream strStream(m_rtcStr);
xmlHander.SetFlags(wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_BASE64);
xmlHander.LoadFile(&m_rtcCtrl->GetBuffer(), strStream);