wxRichTextCtrl - loading HTML file is not working

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
deepti
Earned some good credits
Earned some good credits
Posts: 115
Joined: Tue Jul 17, 2018 5:38 pm

wxRichTextCtrl - loading HTML file is not working

Post 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);

catalin
Moderator
Moderator
Posts: 1618
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: wxRichTextCtrl - loading HTML file is not working

Post 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.
deepti
Earned some good credits
Earned some good credits
Posts: 115
Joined: Tue Jul 17, 2018 5:38 pm

Re: wxRichTextCtrl - loading HTML file is not working

Post by deepti »

Oops! okay..
but is there any other way to get HTML content into a wxRichTextCtrl?
catalin
Moderator
Moderator
Posts: 1618
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: wxRichTextCtrl - loading HTML file is not working

Post by catalin »

Not as far as I know. Unless you want to load it as plain text, without interpreting the markup.
Post Reply