Release 961013

Sun Oct 13 15:32:32 1996  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [Make.rules.in] [*/Makefile.in]
	Made it possible to compile from a directory other than the source
	directory.

	* [graphics/metafiledrv/init.c] [include/metafiledrv.h]
	  [objects/metafile.c] [objects/dc.c]
	New graphics driver for metafiles.

	* [if1632/thunk.c]
	Added thunks for SetWindowsHook and SetDCHook.

	* [windows/dialog.c]
	Fixed GetNextDlgGroupItem and GetNextDlgTabItem to skip disabled
	items.

	* [*/*]
	Removed non Win32-clean types HANDLE, HBITMAP, HBRUSH, HFONT,
 	HINSTANCE, HMENU, HRGN and HTASK.

Wed Oct  9 14:59:45 1996  Frans van Dorsselaer  <dorssel@rulhm1.LeidenUniv.nl>

	* [controls/edit.c]
	Fixed EditWndProc() to fall back to DefWndProc() when the
	edit state structure is not available.

Wed Oct  2 14:00:34 1996  Huw D. M. Davies  <h.davies1@physics.oxford.ac.uk>

	* [windows/nonclient.c] [windows/mdi.c]
	AdjustWindowRectEx16() should only take notice of the styles
 	WS_DLGFRAME, WS_BORDER, WS_THICKFRAME and
 	WS_EX_DLGMODALFRAME. Thanks to Alex Korobka.

	* [controls/scroll.c]
	Fixed typo in ShowScrollBar32().

Sun Aug 25 20:18:56 1996  Jukka Iivonen <iivonen@cc.helsinki.fi>

	* [if1632/user32.spec] [if1632/winmm.spec]
	Added SetParent and sndPlaySoundA.
diff --git a/graphics/metafiledrv/init.c b/graphics/metafiledrv/init.c
new file mode 100644
index 0000000..af5aea1
--- /dev/null
+++ b/graphics/metafiledrv/init.c
@@ -0,0 +1,240 @@
+/*
+ * Metafile driver initialisation functions
+ *
+ * Copyright 1996 Alexandre Julliard
+ */
+
+#include "metafiledrv.h"
+#include "dc.h"
+#include "heap.h"
+#include "global.h"
+#include "metafile.h"
+#include "stddebug.h"
+#include "debug.h"
+
+static BOOL32 MFDRV_DeleteDC( DC *dc );
+
+static const DC_FUNCTIONS MFDRV_Funcs =
+{
+    NULL,                            /* pArc */
+    NULL,                            /* pBitBlt */
+    NULL,                            /* pChord */
+    NULL,                            /* pCreateDC */
+    MFDRV_DeleteDC,                  /* pDeleteDC */
+    NULL,                            /* pDeleteObject */
+    NULL,                            /* pEllipse */
+    NULL,                            /* pEscape */
+    NULL,                            /* pExcludeClipRect */
+    NULL,                            /* pExcludeVisRect */
+    NULL,                            /* pExtFloodFill */
+    NULL,                            /* pExtTextOut */
+    NULL,                            /* pFillRgn */
+    NULL,                            /* pFloodFill */
+    NULL,                            /* pFrameRgn */
+    NULL,                            /* pGetTextExtentPoint */
+    NULL,                            /* pGetTextMetrics */
+    NULL,                            /* pIntersectClipRect */
+    NULL,                            /* pIntersectVisRect */
+    NULL,                            /* pInvertRgn */
+    NULL,                            /* pLineTo */
+    NULL,                            /* pMoveToEx */
+    NULL,                            /* pOffsetClipRgn */
+    NULL,                            /* pOffsetViewportOrgEx */
+    NULL,                            /* pOffsetWindowOrgEx */
+    NULL,                            /* pPaintRgn */
+    NULL,                            /* pPatBlt */
+    NULL,                            /* pPie */
+    NULL,                            /* pPolyPolygon */
+    NULL,                            /* pPolygon */
+    NULL,                            /* pPolyline */
+    NULL,                            /* pRealizePalette */
+    NULL,                            /* pRectangle */
+    NULL,                            /* pRestoreDC */
+    NULL,                            /* pRoundRect */
+    NULL,                            /* pSaveDC */
+    NULL,                            /* pScaleViewportExtEx */
+    NULL,                            /* pScaleWindowExtEx */
+    NULL,                            /* pSelectClipRgn */
+    NULL,                            /* pSelectObject */
+    NULL,                            /* pSelectPalette */
+    NULL,                            /* pSetBkColor */
+    NULL,                            /* pSetBkMode */
+    NULL,                            /* pSetDIBitsToDevice */
+    NULL,                            /* pSetMapMode */
+    NULL,                            /* pSetMapperFlags */
+    NULL,                            /* pSetPixel */
+    NULL,                            /* pSetPolyFillMode */
+    NULL,                            /* pSetROP2 */
+    NULL,                            /* pSetRelAbs */
+    NULL,                            /* pSetStretchBltMode */
+    NULL,                            /* pSetTextAlign */
+    NULL,                            /* pSetTextCharacterExtra */
+    NULL,                            /* pSetTextColor */
+    NULL,                            /* pSetTextJustification */
+    NULL,                            /* pSetViewportExtEx */
+    NULL,                            /* pSetViewportOrgEx */
+    NULL,                            /* pSetWindowExtEx */
+    NULL,                            /* pSetWindowOrgEx */
+    NULL,                            /* pStretchBlt */
+    NULL,                            /* pStretchDIBits */
+    NULL                             /* pTextOut */
+};
+
+
+
+/**********************************************************************
+ *	     MFDRV_AllocMetaFile
+ */
+static DC *MFDRV_AllocMetaFile(void)
+{
+    DC *dc;
+    METAFILEDRV_PDEVICE *physDev;
+    
+    if (!(dc = DC_AllocDC( &MFDRV_Funcs ))) return NULL;
+    dc->header.wMagic = METAFILE_DC_MAGIC;
+
+    physDev = (METAFILEDRV_PDEVICE *)HeapAlloc(SystemHeap,0,sizeof(*physDev));
+    if (!physDev)
+    {
+        GDI_HEAP_FREE( dc->hSelf );
+        return NULL;
+    }
+    dc->physDev = physDev;
+
+    if (!(physDev->mh = HeapAlloc( SystemHeap, 0, sizeof(*physDev->mh) )))
+    {
+        HeapFree( SystemHeap, 0, physDev );
+        GDI_HEAP_FREE( dc->hSelf );
+        return NULL;
+    }
+
+    physDev->nextHandle = 0;
+
+    physDev->mh->mtHeaderSize   = sizeof(METAHEADER) / sizeof(WORD);
+    physDev->mh->mtVersion      = 0x0300;
+    physDev->mh->mtSize         = physDev->mh->mtHeaderSize;
+    physDev->mh->mtNoObjects    = 0;
+    physDev->mh->mtMaxRecord    = 0;
+    physDev->mh->mtNoParameters = 0;
+
+/*    DC_InitDC( dc ); */
+    return dc;
+}
+
+
+/**********************************************************************
+*	     MFDRV_DeleteDC
+ */
+static BOOL32 MFDRV_DeleteDC( DC *dc )
+{
+    METAFILEDRV_PDEVICE *physDev = (METAFILEDRV_PDEVICE *)dc->physDev;
+    
+    if (physDev->mh) HeapFree( SystemHeap, 0, physDev->mh );
+    HeapFree( SystemHeap, 0, physDev );
+    dc->physDev = NULL;
+    return TRUE;
+}
+
+
+/**********************************************************************
+ *	     CreateMetafile16   (GDI.125)
+ */
+HDC16 CreateMetaFile16( LPCSTR filename )
+{
+    DC *dc;
+    METAFILEDRV_PDEVICE *physDev;
+    HFILE hFile;
+
+    printf( "CreateMetafile16: '%s'\n", filename );
+    dprintf_metafile( stddeb, "CreateMetaFile16: '%s'\n", filename );
+
+    if (!(dc = MFDRV_AllocMetaFile())) return 0;
+    physDev = (METAFILEDRV_PDEVICE *)dc->physDev;
+    
+    if (filename)  /* disk based metafile */
+    {
+        physDev->mh->mtType = METAFILE_DISK;
+        if ((hFile = _lcreat( filename, 0 )) == HFILE_ERROR)
+        {
+            DeleteDC( dc->hSelf );
+            return 0;
+        }
+        if (_lwrite32( hFile, (LPSTR)physDev->mh,
+                       sizeof(*physDev->mh)) == HFILE_ERROR)
+	{
+            DeleteDC( dc->hSelf );
+            return 0;
+	}
+	physDev->mh->mtNoParameters = hFile; /* store file descriptor here */
+	                            /* windows probably uses this too*/
+    }
+    else  /* memory based metafile */
+	physDev->mh->mtType = METAFILE_MEMORY;
+
+    dprintf_metafile( stddeb, "CreateMetaFile16: returning %04x\n", dc->hSelf);
+    return dc->hSelf;
+}
+
+
+/******************************************************************
+ *	     CloseMetafile16   (GDI.126)
+ */
+HMETAFILE16 CloseMetaFile16( HDC16 hdc )
+{
+    DC *dc;
+    HMETAFILE16 hmf;
+    HFILE hFile;
+    METAFILEDRV_PDEVICE *physDev;
+    
+    dprintf_metafile( stddeb, "CloseMetaFile(%04x)\n", hdc );
+
+    if (!(dc = DC_GetDCPtr( hdc ))) return 0;
+    physDev = (METAFILEDRV_PDEVICE *)dc->physDev;
+
+    /* Construct the end of metafile record - this is documented
+     * in SDK Knowledgebase Q99334.
+     */
+
+    if (!MF_MetaParam0(dc, META_EOF))
+    {
+        DeleteDC( hdc );
+	return 0;
+    }	
+
+    if (physDev->mh->mtType == METAFILE_DISK)  /* disk based metafile */
+    {
+        hFile = physDev->mh->mtNoParameters;
+	physDev->mh->mtNoParameters = 0;
+        if (_llseek(hFile, 0L, 0) == HFILE_ERROR)
+        {
+            DeleteDC( hdc );
+            return 0;
+        }
+        if (_lwrite32( hFile, (LPSTR)physDev->mh,
+                       sizeof(*physDev->mh)) == HFILE_ERROR)
+        {
+            DeleteDC( hdc );
+            return 0;
+        }
+        _lclose(hFile);
+    }
+
+    /* Now allocate a global handle for the metafile */
+
+    hmf = GLOBAL_CreateBlock( GMEM_MOVEABLE, physDev->mh,
+                              physDev->mh->mtSize * sizeof(WORD),
+                              GetCurrentPDB(), FALSE, FALSE, FALSE, NULL );
+    physDev->mh = NULL;  /* So it won't be deleted */
+    DeleteDC( hdc );
+    return hmf;
+}
+
+
+/******************************************************************
+ *	     DeleteMetafile16   (GDI.127)
+ */
+BOOL16 DeleteMetaFile16( HMETAFILE16 hmf )
+{
+    return !GlobalFree16( hmf );
+}
+