+void wxFileDataObject::AddFile(const wxString& file)
+{
+ // just add file to filenames array
+ // all useful data (such as DROPFILES struct) will be
+ // created later as necessary
+ m_filenames.Add(file);
+}
+
+size_t wxFileDataObject::GetDataSize() const
+{
+ // size returned will be the size of the DROPFILES structure,
+ // plus the list of filesnames (null byte separated), plus
+ // a double null at the end
+
+ // if no filenames in list, size is 0
+ if ( m_filenames.GetCount() == 0 )
+ return 0;
+
+ // inital size of DROPFILES struct + null byte
+ size_t sz = sizeof(DROPFILES) + 1;
+
+ size_t count = m_filenames.GetCount();
+ for ( size_t i = 0; i < count; i++ )
+ {
+ // add filename length plus null byte
+ sz += m_filenames[i].Len() + 1;
+ }
+
+ return sz;
+}
+
+bool wxFileDataObject::GetDataHere(void *pData) const
+{
+ // pData points to an externally allocated memory block
+ // created using the size returned by GetDataSize()
+
+ // if pData is NULL, or there are no files, return
+ if ( !pData || m_filenames.GetCount() == 0 )
+ return FALSE;
+
+ // convert data pointer to a DROPFILES struct pointer
+ LPDROPFILES pDrop = (LPDROPFILES) pData;
+
+ // initialize DROPFILES struct
+ pDrop->pFiles = sizeof(DROPFILES);
+ pDrop->fNC = FALSE; // not non-client coords
+#if wxUSE_UNICODE
+ pDrop->fWide = TRUE;
+#else // ANSI
+ pDrop->fWide = FALSE;
+#endif // Unicode/Ansi
+
+ // set start of filenames list (null separated)
+ wxChar *pbuf = (wxChar*) ((BYTE *)pDrop + sizeof(DROPFILES));
+
+ size_t count = m_filenames.GetCount();
+ for (size_t i = 0; i < count; i++ )
+ {
+ // copy filename to pbuf and add null terminator
+ size_t len = m_filenames[i].Len();
+ memcpy(pbuf, m_filenames[i], len);
+ pbuf += len;
+ *pbuf++ = wxT('\0');
+ }
+
+ *pbuf = wxT('\0'); // add final null terminator
+
+ return TRUE;
+}
+