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.
-
purplex88
- I live to help wx-kind

- Posts: 198
- Joined: Mon Feb 24, 2014 3:14 pm
Post
by purplex88 » Sat Feb 02, 2019 7:02 am
Hello, I have a wxTextCtrl with wxTE_RICH2 style enabled:
Code: Select all
m_textCtrl = new wxTextCtrl(m_panel1, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_RICH2);
It copies rich text with formatting and colors.
Can I copy the text as HTML so I can paste it with formatting into other editors supporting HTML pastes?
-
doublemax
- Moderator

- Posts: 13003
- Joined: Fri Apr 21, 2006 8:03 pm
- Location: $FCE2
Post
by doublemax » Sat Feb 02, 2019 8:41 am
There is nothing built in to do that. You'd have to write something yourself. If it's only for one platform, e.g. Windows, it might be possible to find some code "out there".
Or you could switch to wxRichTextCtrl which supports export (but not import!) in HTML.
Use the source, Luke!
-
purplex88
- I live to help wx-kind

- Posts: 198
- Joined: Mon Feb 24, 2014 3:14 pm
Post
by purplex88 » Sat Feb 02, 2019 1:21 pm
Would I need convert it from Rich Text to HTML under wxTextCtrl?
-
doublemax
- Moderator

- Posts: 13003
- Joined: Fri Apr 21, 2006 8:03 pm
- Location: $FCE2
Post
by doublemax » Sat Feb 02, 2019 2:28 pm
Would I need convert it from Rich Text to HTML under wxTextCtrl?
I'm note 100% sure i understand the question. But if you use wxTextCtrl, you'd have to implement the conversion to HTML yourself.
If you need a Windows version only, you could (probably, untested) get the control's content as RTF using EM_STREAMOUT / SF_RTF. And hopefully find an RTF to HTML conversion in the open source world.
https://docs.microsoft.com/en-us/window ... -streamout
Use the source, Luke!
-
purplex88
- I live to help wx-kind

- Posts: 198
- Joined: Mon Feb 24, 2014 3:14 pm
Post
by purplex88 » Sat Feb 02, 2019 8:00 pm
Libraries can have limitations. Is it best if I write the HTML output myself e.g. format the text with HTML because I saved the formatting information about (highlights, colors, etc.) into a data structure?
-
doublemax
- Moderator

- Posts: 13003
- Joined: Fri Apr 21, 2006 8:03 pm
- Location: $FCE2
Post
by doublemax » Sat Feb 02, 2019 9:33 pm
Is it best if I write the HTML output myself e.g. format the text with HTML because I saved the formatting information about (highlights, colors, etc.) into a data structure?
That's probably the best solution.
Use the source, Luke!