]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/ole/dataobj.cpp
always pass WM_DESTROY to DefWindowProc() - this fixes memory/resource leak for wxListBox
[wxWidgets.git] / src / msw / ole / dataobj.cpp
index f0b939a5c4903df545d62c2bbc7fdb8bad2b0e9f..72776682a698e47047f10c43403f3f5c90975dba 100644 (file)
@@ -62,7 +62,7 @@
 #ifdef __WXDEBUG__
     static const wxChar *GetTymedName(DWORD tymed);
 #else // !Debug
-    #define GetTymedName(tymed) ""
+    #define GetTymedName(tymed) _T("")
 #endif // Debug/!Debug
 
 // ----------------------------------------------------------------------------
@@ -621,7 +621,7 @@ STDMETHODIMP wxIDataObject::EnumFormatEtc(DWORD dwDir,
 
     size_t nFormatCount = m_pDataObject->GetFormatCount(dir);
     wxDataFormat format;
-       wxDataFormat *formats;
+    wxDataFormat *formats;
     formats = nFormatCount == 1 ? &format : new wxDataFormat[nFormatCount];
     m_pDataObject->GetAllFormats(formats, dir);
 
@@ -1029,11 +1029,53 @@ bool wxFileDataObject::GetDataHere(void *pData) const
         *pbuf++ = wxT('\0');
     }
 
-    *pbuf = wxT('\0'); // add final null terminator
+    // add final null terminator
+    *pbuf = wxT('\0');
 
     return TRUE;
 }
 
+// ----------------------------------------------------------------------------
+// wxURLDataObject
+// ----------------------------------------------------------------------------
+
+wxURLDataObject::wxURLDataObject()
+{
+    // we support CF_TEXT and CFSTR_SHELLURL formats which are basicly the same
+    // but it seems that some browsers only provideo ne of them so we have to
+    // support both
+    Add(new wxCustomDataObject(CFSTR_SHELLURL));
+    Add(new wxTextDataObject);
+
+    // we don't have any data yet
+    m_dataObjectLast = NULL;
+}
+
+bool wxURLDataObject::SetData(const wxDataFormat& format,
+                              size_t len,
+                              const void *buf)
+{
+    m_dataObjectLast = GetObject(format);
+
+    wxCHECK_MSG( m_dataObjectLast, FALSE,
+                 wxT("unsupported format in wxURLDataObject"));
+
+    return m_dataObjectLast->SetData(len, buf);
+}
+
+wxString wxURLDataObject::GetURL() const
+{
+    wxString url;
+    wxCHECK_MSG( m_dataObjectLast, url, _T("no data in wxURLDataObject") );
+
+    size_t len = m_dataObjectLast->GetDataSize();
+
+    m_dataObjectLast->GetDataHere(url.GetWriteBuf(len + 1));
+    url.UngetWriteBuf();
+
+    return url;
+}
+
 // ----------------------------------------------------------------------------
 // private functions
 // ----------------------------------------------------------------------------