Question about wClipboard
Vadim Zeitlin
vadim at wxwidgets.org
Mon Dec 3 14:30:14 PST 2007
On Mon, 03 Dec 2007 23:23:02 +0100 MaxGaspa <nospam at it.sunsite.dk> wrote:
M> I'm trying to use the clipboard using wxWidget 2.8.7, I am using this
M> code to add text into the clipboard
M>
M> void SqlListCtrlFrame::OnCopyAll( wxCommandEvent& event )
M> {
M>
M> if (wxTheClipboard->Open())
M> {
M> wxTheClipboard->Clear();
M> wxTheClipboard->AddData(new wxTextDataObject(wxT("aaa")) );
M> wxTheClipboard->AddData(new wxTextDataObject(wxT("bbbb")) );
M>
M> wxTheClipboard->Flush();
M> wxTheClipboard->Close();
M> }
M>
M> }
M>
M> My understanding is that using AddData I "add" data to clipboard.
M>
M> With the code above the clipboard content is "bbbb" only. The "aaa"
M> string is lost. It seems (to me) that AddData() works like SetData().
M> I.e. like if Clear() is called before any AddData().
No, not quite: if you had data in any other format on the clipboard they
wouldn't be cleared by Add(). But you can have only one piece of data in
wxDF_TEXT format on clipboard at any time (but also, simultaneously, one in
wxDF_BITMAP format and so on).
So you just need to collect all the text data you want to put on clipboard
in one wxString and then call AddData() once.
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
More information about the wx-users
mailing list