]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/clipbrd.cpp
fixed problems with sometimes processing the events twice introduced in rev 1.170...
[wxWidgets.git] / src / msw / clipbrd.cpp
index cd848901bdef147aa096158f0ca33868c97ae08b..044ef30db20b73567dfa0263df8a8170e25aa648 100644 (file)
 // headers
 // ---------------------------------------------------------------------------
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-    #pragma implementation "clipbrd.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
     #pragma hdrstop
 #endif
 
-#ifndef WX_PRECOMP
-    #include "wx/setup.h"
-#endif
-
 #if wxUSE_CLIPBOARD
 
 #ifndef WX_PRECOMP
 #include <string.h>
 
 #include "wx/msw/private.h"
+#include "wx/msw/ole/oleutils.h"
 
 #if wxUSE_WXDIB
-#include "wx/msw/dib.h"
+    #include "wx/msw/dib.h"
 #endif
 
 // wxDataObject is tied to OLE/drag and drop implementation, therefore so are
@@ -301,8 +294,8 @@ bool wxSetClipboardData(wxDataFormat dataFormat,
                 handle = SetClipboardData(dataFormat, hGlobalMemory);
                 break;
             }
-            // Only tested with non-Unicode, Visual C++ 6.0 so far
-#if defined(__VISUALC__) && !defined(UNICODE)
+            // Only tested with Visual C++ 6.0 so far
+#if defined(__VISUALC__)
         case wxDF_HTML:
             {
                 char* html = (char *)data;
@@ -339,19 +332,19 @@ bool wxSetClipboardData(wxDataFormat dataFormat,
                 // string when you overwrite it so you follow up with code to replace
                 // the 0 appended at the end with a '\r'...
                 char *ptr = strstr(buf, "StartHTML");
-                wsprintf(ptr+10, "%08u", strstr(buf, "<html>") - buf);
+                sprintf(ptr+10, "%08u", strstr(buf, "<html>") - buf);
                 *(ptr+10+8) = '\r';
 
                 ptr = strstr(buf, "EndHTML");
-                wsprintf(ptr+8, "%08u", strlen(buf));
+                sprintf(ptr+8, "%08u", strlen(buf));
                 *(ptr+8+8) = '\r';
 
                 ptr = strstr(buf, "StartFragment");
-                wsprintf(ptr+14, "%08u", strstr(buf, "<!--StartFrag") - buf);
+                sprintf(ptr+14, "%08u", strstr(buf, "<!--StartFrag") - buf);
                 *(ptr+14+8) = '\r';
 
                 ptr = strstr(buf, "EndFragment");
-                wsprintf(ptr+12, "%08u", strstr(buf, "<!--EndFrag") - buf);
+                sprintf(ptr+12, "%08u", strstr(buf, "<!--EndFrag") - buf);
                 *(ptr+12+8) = '\r';
 
                 // Now you have everything in place ready to put on the
@@ -534,6 +527,10 @@ IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject)
 
 wxClipboard::wxClipboard()
 {
+#if wxUSE_OLE_CLIPBOARD
+    wxOleInitialize();
+#endif
+
     m_clearOnExit = false;
     m_isOpened = false;
 }
@@ -544,24 +541,30 @@ wxClipboard::~wxClipboard()
     {
         Clear();
     }
+
+#if wxUSE_OLE_CLIPBOARD
+    wxOleUninitialize();
+#endif
 }
 
 void wxClipboard::Clear()
 {
 #if wxUSE_OLE_CLIPBOARD
-    if ( FAILED(OleSetClipboard(NULL)) )
+    HRESULT hr = OleSetClipboard(NULL);
+    if ( FAILED(hr) )
     {
-        wxLogLastError(wxT("OleSetClipboard(NULL)"));
+        wxLogApiError(wxT("OleSetClipboard(NULL)"), hr);
     }
-#endif
+#endif // wxUSE_OLE_CLIPBOARD
 }
 
 bool wxClipboard::Flush()
 {
 #if wxUSE_OLE_CLIPBOARD
-    if ( FAILED(OleFlushClipboard()) )
+    HRESULT hr = OleFlushClipboard();
+    if ( FAILED(hr) )
     {
-        wxLogLastError(wxT("OleFlushClipboard"));
+        wxLogApiError(wxT("OleFlushClipboard"), hr);
 
         return false;
     }