I use wxWidges-2.9.4,compile with Unicode,in Windows 7.
I show a piece of my code below:
Code: Select all
#include <wx/clipbrd.h>
void MyFrame1::OnCopyClick( wxCommandEvent& event )
{
wxString str= m_textCtrl1->GetValue();
wxOpenClipboard();
wxEmptyClipboard();
wxSetClipboardData(wxDF_TEXT,str.mb_str(wxConvUTF8));
wxCloseClipboard();
event.Skip();
}
void MyFrame1::OnPasteClick( wxCommandEvent& event )
{
wxOpenClipboard();
wxString str = wxString((char*)wxGetClipboardData(wxDF_TEXT),wxConvUTF8);
wxCloseClipboard();
m_textCtrl1->SetValue(str);
event.Skip();
}
I can click copy_ and paste_ button to copy chinese character in this program correctlly.
If i click copy_ button to copy value from textctrl, then i use (ctrl + v) to paste to other editors like txt,ms-excel.But it's garbled!!
if i copy some text from other editors,then i click patse_ button to paste it to m_textctrl1.it's garbled too!!
How to use Clipboard in a correct way?
regards.
bulue