Author: manolo
Date: 2010-12-11 08:25:59 -0800 (Sat, 11 Dec 2010)
New Revision: 8010
Log:
Fixed DnD of text to non FLTK applications expecting CP1252 data.

Modified:
   branches/branch-1.3/src/fl_dnd_win32.cxx

Modified: branches/branch-1.3/src/fl_dnd_win32.cxx
===================================================================
--- branches/branch-1.3/src/fl_dnd_win32.cxx    2010-12-11 14:59:22 UTC (rev 
8009)
+++ branches/branch-1.3/src/fl_dnd_win32.cxx    2010-12-11 16:25:59 UTC (rev 
8010)
@@ -416,16 +416,17 @@
       delete this;
     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 ) {
     if ((pformatetcIn->dwAspect & DVASPECT_CONTENT) &&
         (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 );
-      memmove( pMem, fl_selection_buffer[0], fl_selection_length[0] );
-      pMem[ fl_selection_length[0] ] = 0;
+      fl_utf8toUtf16(fl_selection_buffer[0], fl_selection_length[0], (unsigned 
short*)pMem, utf16_len * 2);
+      pMem[ 2*utf16_len ] = 0;
 //      HGLOBAL gh = GlobalAlloc( GHND| GMEM_SHARE,
 //                            (fl_selection_length[0]+4) * sizeof(short)
 //                            + sizeof(DROPFILES));
@@ -467,7 +468,7 @@
   {
     if ((pformatetc->dwAspect & DVASPECT_CONTENT) &&
         (pformatetc->tymed & TYMED_HGLOBAL) &&
-        (pformatetc->cfFormat == CF_TEXT))
+        (pformatetc->cfFormat == CF_UNICODETEXT))
       return S_OK;
     return DV_E_FORMATETC;
   }

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to