Get rid of (Close|Delete)MetaFile16()

Dimitrie O. Paun dpaun at rogers.com
Sat Apr 2 17:21:53 CST 2005


The fact that a HMETAFILE16 is just a GlobalAlloc16'ed
piece of memory seems to be hardwired (in the sense that
it's a well known fact, I doubt it can ever change).
Given that, it seems a waste to rely on a non-standard
export (DeleteMetaFile16()) to just call GlobalFree16().
Similarly, once we know that fact, we can just use 32-bit
functions to create the metafile, and then copy it into
a GlobalAlloc16'ed buffer.

This cleans up a bit our exports from gdi32.

ChangeLog
    Remove the need for the non-standard (Close|Delete)MetaFile16().


Index: dlls/x11drv/clipboard.c
===================================================================
RCS file: /var/cvs/wine/dlls/x11drv/clipboard.c,v
retrieving revision 1.40
diff -u -r1.40 clipboard.c
--- dlls/x11drv/clipboard.c	28 Mar 2005 10:06:06 -0000	1.40
+++ dlls/x11drv/clipboard.c	2 Apr 2005 21:22:31 -0000
@@ -750,7 +750,9 @@
 
         if (lpMetaPict)
         {
-            DeleteMetaFile16(lpMetaPict->hMF);
+            /* To delete 16-bit meta file, we just need to free the associated
+               handle. See DeleteMetaFile16() in dlls/gdi/metafile.c. */
+            GlobalFree16(lpMetaPict->hMF);
             lpMetaPict->hMF = 0;
         }
 
Index: dlls/ole32/ole2_16.c
===================================================================
RCS file: /var/cvs/wine/dlls/ole32/ole2_16.c,v
retrieving revision 1.3
diff -u -r1.3 ole2_16.c
--- dlls/ole32/ole2_16.c	23 Jan 2004 22:51:42 -0000	1.3
+++ dlls/ole32/ole2_16.c	2 Apr 2005 23:19:27 -0000
@@ -93,12 +93,12 @@
 	LPCOLESTR16 lpszSourceFile,
 	UINT16 iIconIndex
 ) {
-    METAFILEPICT16 *mf;
-    HGLOBAL16 hmf;
+    METAFILEPICT16 *mf16;
+    HGLOBAL16 hmf16;
+    HMETAFILE hmf;
+    INT mfSize;
     HDC hdc;
 
-    FIXME("(%04x, '%s', '%s', %d): incorrect metrics, please try to correct them !\n\n\n", hIcon, lpszLabel, lpszSourceFile, iIconIndex);
-
     if (!hIcon) {
         if (lpszSourceFile) {
 	    HINSTANCE16 hInstance = LoadLibrary16(lpszSourceFile);
@@ -110,16 +110,27 @@
 	    return 0;
     }
 
-    hdc = CreateMetaFileA(NULL);
+    FIXME("(%04x, '%s', '%s', %d): incorrect metrics, please try to correct them !\n", 
+          hIcon, lpszLabel, lpszSourceFile, iIconIndex);
+
+    hdc = CreateMetaFileW(NULL);
     DrawIcon(hdc, 0, 0, HICON_32(hIcon)); /* FIXME */
     TextOutA(hdc, 0, 0, lpszLabel, 1); /* FIXME */
-    hmf = GlobalAlloc16(0, sizeof(METAFILEPICT16));
-    mf = (METAFILEPICT16 *)GlobalLock16(hmf);
-    mf->mm = MM_ANISOTROPIC;
-    mf->xExt = 20; /* FIXME: bogus */
-    mf->yExt = 20; /* dito */
-    mf->hMF = CloseMetaFile16(HDC_16(hdc));
-    return hmf;
+    hmf = CloseMetaFile(hdc);
+
+    hmf16 = GlobalAlloc16(0, sizeof(METAFILEPICT16));
+    mf16 = (METAFILEPICT16 *)GlobalLock16(hmf16);
+    mf16->mm = MM_ANISOTROPIC;
+    mf16->xExt = 20; /* FIXME: bogus */
+    mf16->yExt = 20; /* dito */
+    mfSize = GetMetaFileBitsEx(hmf, 0, 0);
+    mf16->hMF = GlobalAlloc16(GMEM_MOVEABLE, mfSize);
+    if(mf16->hMF)
+    {
+        GetMetaFileBitsEx(hmf, mfSize, GlobalLock16(mf16->hMF));
+        GlobalUnlock16(mf16->hMF);
+    }
+    return hmf16;
 }
 
 
Index: dlls/gdi/gdi32.spec
===================================================================
RCS file: /var/cvs/wine/dlls/gdi/gdi32.spec,v
retrieving revision 1.44
diff -u -r1.44 gdi32.spec
--- dlls/gdi/gdi32.spec	12 Jan 2005 19:57:08 -0000	1.44
+++ dlls/gdi/gdi32.spec	2 Apr 2005 22:11:15 -0000
@@ -421,8 +421,6 @@
 # Wine extensions: Win16 functions that are needed by other dlls
 #
 @ stdcall CloseJob16(long)
-@ stdcall CloseMetaFile16(long)
-@ stdcall DeleteMetaFile16(long)
 @ stdcall DrvGetPrinterData16(str str ptr ptr long ptr)
 @ stdcall DrvSetPrinterData16(str str long ptr long)
 @ stdcall OpenJob16(str str long)

-- 
Dimi.



More information about the wine-patches mailing list