Page 1 of 1

wxRichTextCtrl - loading HTML file is not working

Posted: Mon Aug 27, 2018 2:28 pm
by deepti
Hi All,

Need yet another help badly!
I have a wxRichTextCtrl instance, into which i need to load HTML contents, saved in the file "mail.html".
This is code i have, but it says "File could not be loaded", and the wxRichTextCtrl remains empty.
What wrong am i doing? Please help!

Code: Select all

wxRichTextCtrl* richTextMailBody = new wxRichTextCtrl(m_panelNBContainer, wxID_ANY, wxEmptyString, wxDefaultPosition,
		                                                              wxSize(400, 400), wxVSCROLL | wxHSCROLL | wxBORDER_NONE | wxWANTS_CHARS);

wxRichTextHTMLHandler* handler = new wxRichTextHTMLHandler();
wxRichTextBuffer buffer = richTextMailBody->GetBuffer();
buffer.AddHandler(handler);
richTextMailBody->LoadFile("./mail.html", wxRICHTEXT_TYPE_HTML);


Re: wxRichTextCtrl - loading HTML file is not working

Posted: Mon Aug 27, 2018 3:05 pm
by catalin
You're probably out of luck with this one. I don't think loading from html is implemented, only saving is. Looking at wxRichTextHTMLHandler::DoLoadFile(), it only returns false.
But stepping into LoadFile() with a debugger would have shown you the same thing, faster than posting the question and waiting for an answer.

Re: wxRichTextCtrl - loading HTML file is not working

Posted: Mon Aug 27, 2018 3:08 pm
by deepti
Oops! okay..
but is there any other way to get HTML content into a wxRichTextCtrl?

Re: wxRichTextCtrl - loading HTML file is not working

Posted: Mon Aug 27, 2018 3:12 pm
by catalin
Not as far as I know. Unless you want to load it as plain text, without interpreting the markup.