case TYMED_HGLOBAL:
{
+ wxDataFormat format = pformatetc->cfFormat;
+
+ // this is quite weird, but for file drag and drop, explorer
+ // calls our SetData() with the formats we do *not* support!
+ //
+ // as we can't fix this bug in explorer (it's a bug because it
+ // should only use formats returned by EnumFormatEtc), do the
+ // check here
+ if ( !m_pDataObject->IsSupportedFormat(format) ) {
+ // go away!
+ return DV_E_FORMATETC;
+ }
+
// copy data
void *pBuf = GlobalLock(pmedium->hGlobal);
if ( pBuf == NULL ) {
// synthetise it for known formats and we suppose that all data
// in custom formats starts with a DWORD containing the size
size_t size;
- switch ( pformatetc->cfFormat )
+ switch ( format )
{
case CF_TEXT:
case CF_OEMTEXT:
}
}
- wxDataFormat format = pformatetc->cfFormat;
bool ok = m_pDataObject->SetData(format, size, pBuf);
GlobalUnlock(pmedium->hGlobal);
// get number of files (magic value -1)
UINT nFiles = ::DragQueryFile(hdrop, (unsigned)-1, NULL, 0u);
+ wxCHECK_MSG ( nFiles != (UINT)-1, FALSE, wxT("wrong HDROP handle") );
+
// for each file get the length, allocate memory and then get the name
wxString str;
UINT len, n;
// a double null at the end
// if no filenames in list, size is 0
- if (m_filenames.GetCount() == 0) return 0;
+ if ( m_filenames.GetCount() == 0 )
+ return 0;
// inital size of DROPFILES struct + null byte
size_t sz = sizeof(DROPFILES) + 1;
- int i;
- for (i=0; i<m_filenames.GetCount(); ++i)
+ 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;
}
// 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;
+ 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;
+ 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)
- char *pbuf = (char*)pDrop + sizeof(DROPFILES);
+ wxChar *pbuf = (wxChar*) ((BYTE *)pDrop + sizeof(DROPFILES));
- size_t i;
- for (i=0; i<m_filenames.GetCount(); ++i)
+ 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++ = '\0';
+ *pbuf++ = wxT('\0');
}
- *pbuf = '\0'; // add final null terminator
+
+ *pbuf = wxT('\0'); // add final null terminator
return TRUE;
}