Browse Source

Fixed DnD of text to non FLTK applications expecting CP1252 data.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8010 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
pull/49/head
Manolo Gouy 15 years ago
parent
commit
fa2aea107f
  1. 13
      src/fl_dnd_win32.cxx

13
src/fl_dnd_win32.cxx

@ -416,16 +416,17 @@ public:
delete this; delete this;
return nTemp; return nTemp;
} }
// GetData currently allows ASCII text through Global Memory only // GetData currently allows UNICODE text through Global Memory only
HRESULT STDMETHODCALLTYPE GetData( FORMATETC *pformatetcIn, STGMEDIUM *pmedium ) { HRESULT STDMETHODCALLTYPE GetData( FORMATETC *pformatetcIn, STGMEDIUM *pmedium ) {
if ((pformatetcIn->dwAspect & DVASPECT_CONTENT) && if ((pformatetcIn->dwAspect & DVASPECT_CONTENT) &&
(pformatetcIn->tymed & TYMED_HGLOBAL) && (pformatetcIn->tymed & TYMED_HGLOBAL) &&
(pformatetcIn->cfFormat == CF_TEXT)) (pformatetcIn->cfFormat == CF_UNICODETEXT))
{ {
HGLOBAL gh = GlobalAlloc( GHND, fl_selection_length[0]+1 ); int utf16_len = fl_utf8toUtf16(fl_selection_buffer[0], fl_selection_length[0], 0, 0);
HGLOBAL gh = GlobalAlloc( GHND, utf16_len * 2 + 2 );
char *pMem = (char*)GlobalLock( gh ); char *pMem = (char*)GlobalLock( gh );
memmove( pMem, fl_selection_buffer[0], fl_selection_length[0] ); fl_utf8toUtf16(fl_selection_buffer[0], fl_selection_length[0], (unsigned short*)pMem, utf16_len * 2);
pMem[ fl_selection_length[0] ] = 0; pMem[ 2*utf16_len ] = 0;
// HGLOBAL gh = GlobalAlloc( GHND| GMEM_SHARE, // HGLOBAL gh = GlobalAlloc( GHND| GMEM_SHARE,
// (fl_selection_length[0]+4) * sizeof(short) // (fl_selection_length[0]+4) * sizeof(short)
// + sizeof(DROPFILES)); // + sizeof(DROPFILES));
@ -467,7 +468,7 @@ public:
{ {
if ((pformatetc->dwAspect & DVASPECT_CONTENT) && if ((pformatetc->dwAspect & DVASPECT_CONTENT) &&
(pformatetc->tymed & TYMED_HGLOBAL) && (pformatetc->tymed & TYMED_HGLOBAL) &&
(pformatetc->cfFormat == CF_TEXT)) (pformatetc->cfFormat == CF_UNICODETEXT))
return S_OK; return S_OK;
return DV_E_FORMATETC; return DV_E_FORMATETC;
} }

Loading…
Cancel
Save