/////////////////////////////////////////////////////////////////////////////
// Name: clipboard.cpp
-// Purpose: clipbaord wxWidgets sample
+// Purpose: clipboard wxWidgets sample
// Author: Robert Roebling
-// RCS-ID: $Id: minimal.cpp 53461 2008-05-05 23:30:33Z VZ $
+// RCS-ID: $Id$
// Copyright: (c) Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
-
+
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/clipbrd.h"
-#if !defined(__WXMSW__) && !defined(__WXPM__)
+#ifndef wxHAS_IMAGES_IN_RESOURCES
#include "../sample.xpm"
#endif
-#define USE_ASYNCHRONOUS_CLIPBOARD_REQUEST 0
+#define USE_ASYNCHRONOUS_CLIPBOARD_REQUEST 0
class MyApp : public wxApp
{
MyFrame *frame = new MyFrame("wxClipboard sample");
frame->Show(true);
-
+
return true;
}
{
// set the frame icon
SetIcon(wxICON(sample));
-
+
#if USE_ASYNCHRONOUS_CLIPBOARD_REQUEST
m_request = Idle;
m_clipboardSupportsText = false;
// the "About" item should be in the help menu
wxMenu *helpMenu = new wxMenu;
- helpMenu->Append(ID_About, "&About...\tF1", "Show about dialog");
+ helpMenu->Append(ID_About, "&About\tF1", "Show about dialog");
fileMenu->Append(ID_Quit, "E&xit\tAlt-X", "Quit this program");
#endif // wxUSE_MENUS
wxPanel *panel = new wxPanel( this, -1 );
-
+
wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
- main_sizer->Add( new wxButton( panel, ID_Write, "Get clipboard text" ) );
+ main_sizer->Add( new wxButton( panel, ID_Write, "Get clipboard text" ), 0, wxALL, 5 );
m_textctrl = new wxTextCtrl( panel, ID_Text, "", wxDefaultPosition,
wxDefaultSize, wxTE_MULTILINE );
main_sizer->Add( m_textctrl, 1, wxGROW );
wxTheClipboard->GetData( data );
m_textctrl->Clear();
m_textctrl->SetValue( data.GetText() );
-
+
}
wxTheClipboard->Close();
}
#if USE_ASYNCHRONOUS_CLIPBOARD_REQUEST
if (m_request == Idle)
{
- wxTheClipboard->IsSupportedAsync( this );
+ if (!wxTheClipboard->IsSupportedAsync( this ))
+ {
+ // request failed, try again later
+ event.Enable( m_clipboardSupportsText ); // not yet known, assume last value
+ return;
+ }
m_request = Waiting;
event.Enable( m_clipboardSupportsText ); // not yet known, assume last value
- }
+ }
else if (m_request == Waiting)
{
event.Enable( m_clipboardSupportsText ); // not yet known, assume last value
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
+ wxMessageBox("Clipboard sample", "About clipboard", wxOK|wxICON_INFORMATION, this);
}