- // the documentation states that the first member of DROPFILES structure
- // is a "DWORD offset of double NUL terminated file list". What they mean by
- // this (I wonder if you see it immediately) is that the list starts at
- // ((char *)&(pDropFiles.pFiles)) + pDropFiles.pFiles. We're also advised to
- // use DragQueryFile to work with this structure, but not told where and how
- // to get HDROP.
- HDROP hdrop = (HDROP)pData; // NB: it works, but I'm not sure about it
-
- // get number of files (magic value -1)
- UINT nFiles = ::DragQueryFile(hdrop, (unsigned)-1, NULL, 0u);
-
- // for each file get the length, allocate memory and then get the name
- wxChar **aszFiles = new wxChar *[nFiles];
- UINT len, n;
- for ( n = 0; n < nFiles; n++ ) {
- // +1 for terminating NUL
- len = ::DragQueryFile(hdrop, n, NULL, 0) + 1;
-
- aszFiles[n] = new wxChar[len];
-
- UINT len2 = ::DragQueryFile(hdrop, n, aszFiles[n], len);
- if ( len2 != len - 1 ) {
- wxLogDebug(T("In wxFileDropTarget::OnDrop DragQueryFile returned %d "
- "characters, %d expected."), len2, len - 1);
- }
- }