Release 980503

Thu Apr 30 16:28:12 1998  James Juran <jrj120@psu.edu>

	* [scheduler/process.c]
	Implemented GetExitCodeProcess.  The code is a direct translation
	of GetExitCodeThread.

Mon Apr 27 22:20:25 1998  Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>

	* [loader/pe_image.c]
	Unload dummy module when PE_LoadLibraryEx32A fails with
	PE_LoadImage (makes Encarta 98 installer proceed).

	* [files/drive.c]
	Make GetDriveType16 return DRIVE_REMOVABLE for TYPE_CDROM.
	Make GetCurrentDirectory32 behave like the code does and not
	like the help describes.

	* [files/profile.c]
	Revoke recent change in PROFILE_GetSection and try better 
	handling of special case.

	* [include/windows.h]
	Change definition of ACCEL32.

	* [misc/commdlg.c]
	Replace the GetXXXFilename32 macros by normal code.
	Fix two reported bugs in my changes to commdlg.

	* [windows/win.c]
	Add a hook to catch bogus WM_SIZE messages by emitting a warning
	in the appropriate case.

	* [objects/bitmap.c]
	Reject unreasonbable large size arguments in
	CreateCompatibleBitmap32 and add an fixme for that situation.

Sun Apr 26 18:30:07 1998  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [include/ldt.h] [debugger/*.c] [miscemu/instr.c]
	Added IS_SELECTOR_SYSTEM and IS_SELECTOR_32BIT macros.
	Make instruction emulation support system selectors.

	* [loader/*.c]
	Started moving NE specific functions to the new loader/ne
	directory.

	* [memory/environ.c]
	Enforce the 127 chars limit only when creating the environment of
	a Win16 process.

Sun Apr 26 12:22:23 1998  Andreas Mohr <100.30936@germany.net>

	* [files/file.c]
	Fixed an incredible typo in CopyFile32A that made it unusable
	since a rewrite in 970112 (!!).

	* [files/directory.c]
	Fixed GetTempPath32A/W to include trailing backslash.

	* [misc/ver.c]
	Make find_pe_resource "work" with corrupt files.

	* [misc/wsprintf.c]
	Altered WPRINTF_ParseFormatA/W to treat invalid format chars
	as normal output, too.

	* [msdos/dpmi.c]
	Implemented "Allocate/Free real mode callback" (0x0303/0x0304).
	Cross your fingers if you need to use it ;) (completely untested)
	Implemented "Call real mode proc with far return" (0x0301, tested).

	* [msdos/int21.c]
	Fixed ioctlGenericBlkDevReq/0x60.

	* [relay32/dplayx.spec] [relay32/builtin32.c] [relay32/Makefile.in]
	Added built-in DPLAYX.DLL. 

	* [windows/win.c]
	Fixed GetWindowWord()/GWW_HWNDPARENT to return the window's owner
	if it has no parent (SDK).

Sat Apr 25 15:09:53 1998  M.T.Fortescue  <mark@mtfhpc.demon.co.uk>

	* [debugger/db_disasm.c]
	Fixed disassemble bug for no-display option and 'lock',
	'repne' and 'repe' prefixes.

	* [debugger/registers.c]
	Added textual flag description output on 'info regs'.

Sat Apr 25 14:18:26 1998  Matthew Becker <mbecker@glasscity.net>

	* [*/*.c]
	Added stubs and/or documentation for the following functions: 
	LookupPrivilegeValue, OpenService, ControlService, RegGetKeySecurity, 
	StartService, SetComputerName, DeleteService, CloseServiceHandle, 
	OpenProcessToken, OpenSCManager, DeregisterEventSource, 
	WaitForDebugEvent, WaitForInputIdle, RegisterEventSource,
	SetDebugErrorLevel, SetConsoleCursorPosition, ChoosePixelFormat,
	SetPixelFormat, GetPixelFormat, DescribePixelFormat, SwapBuffers,
	PolyBezier, AbortPath, DestroyAcceleratorTable, HeapWalk,
	DdeInitialize, DdeUninitialize, DdeConnectList, DdeDisconnectList,
	DdeCreateStringHandle, DdePostAdvise, DdeGetData, DdeNameService,
	DdeGetLastError, WNetGetDirectoryType, EnumPrinters, RegFlushKey,
	RegGetKeySecurity, DllGetClassObject, DllCanUnloadNow, CreateBitmap,
	CreateCompatibleBitmap, CreateBitmapIndirect, GetBitmapBits,
	SetBitmapBits, LoadImage, CopyImage, LoadBitmap, DrawIcon,
	CreateDiscardableBitmap, SetDIBits, GetCharABCWidths, LoadTypeLib,
	SetConsoleCtrlHandler, CreateConsoleScreenBuffer, ReadConsoleInput,
	GetConsoleCursorInfo, SetConsoleCursorInfo, SetConsoleWindowInfo,
	SetConsoleTextAttribute, SetConsoleScreenBufferSize,
	FillConsoleOutputCharacter, FillConsoleOutputAttribute,
	CreateMailslot, GetMailslotInfo, GetCompressedFileSize,
	GetProcessWindowStation, GetThreadDesktop, SetDebugErrorLevel,
	WaitForDebugEvent, SetComputerName, CreateMDIWindow.

Thu Apr 23 23:54:04 1998  Douglas Ridgway  <ridgway@winehq.com>

	* [include/windows.h] [objects/enhmetafile.c] [relay32/gdi32.spec]
	Implement CopyEnhMetaFile, Get/SetEnhMetaFileBits, other fixes.

	* [include/windows.h] [objects/metafile.c] [relay32/gdi32.spec]
	32-bit metafile fixes, implement EnumMetaFile32, GetMetaFileBitsEx.

	* [objects/font.c] [graphics/x11drv/xfont.c] [graphics/x11drv/text.c]
	Some rotated text support for X11R6 displays.

	* [win32/newfns.c] [ole/ole2nls.c]
	Moved GetNumberFormat32A.

Wed Apr 22 17:38:20 1998  David Lee Lambert <lamber45@egr.msu.edu>

	* [ole/ole2nls.c] [misc/network.c]
	Changed some function documentation to the new style.

	* [misc/network.c] [include/windows.h] [if1632/user.spec]
	  [relay32/mpr.spec] [misc/mpr.c]
	Added stubs for some Win32 network functions;  renamed some 
	16-bit ones with 32-bit counterparts,  as well as
	WNetGetDirectoryType;  moved the stubs in misc/mpr.c (three of
	them!) to misc/network.c.

	* [ole/compobj.c] [ole/storage.c] [ole/ole2disp.c] 
	  [ole/ole2nls.c] [ole/folders.c] [ole/moniker.c] [ole/ole2.c]
	  [graphics/fontengine.c] [graphics/ddraw.c] [graphics/env.c]
	  [graphics/driver.c] [graphics/escape.c]
	Changed fprintf's to proper debug-macros.

	* [include/winnls.h]
	Added some flags (for internal use).

	* [ole/ole2nls.c] 
	Added the Unicode core function, and worked out a way to hide
	the commonality of the core.

	* [relay32/kernel32.spec]
	Added support for GetDate/Time32A/W.

Wed Apr 22 09:16:03 1998  Gordon Chaffee  <chaffee@cs.berkeley.edu>

	* [win32/code_page.c]
	Fixed problem with MultiByteToWideChar that was introduced in
	last release.  Made MultiByteToWideChar more compatible with Win32.

	* [graphics/x11drv/graphics.c]
	Fixed problem with drawing arcs.

Tue Apr 21 11:24:58 1998  Constantine Sapuntzakis  <csapuntz@tma-1.lcs.mit.edu>

	*  [ole/ole2nls.c]
	Move stuff from 0x409 case to Lang_En. 

	*  [relay32/user32.spec] [windows/winpos.c]
	Added stubs for GetWindowRgn32 and SetWindowRgn32. Makes Office
	Paperclip happy.

Tue Apr 21 11:16:16 1998  Constantine Sapuntzakis  <csapuntz@tma-1.lcs.mit.edu>

	*  [loader/pe_image.c]
	If image is relocated, TLS addresses need to be adjusted.

	* [debugger/*.c]
	Generalized tests for 32-bit segments.

Tue Apr 21 02:04:59 1998  James Juran  <jrj120@psu.edu>
	
	* [misc/*.c] [miscemu/*.c] [msdos/*.c] [if1632/*.c] 
	  [include/*.h] [loader/*.c] [memory/*.c] [multimedia/*.c] 
	  [objects/*.c]
	Almost all fprintf statements converted to appropriate 
	debug messages.

	* [README]
	Updated "GETTING MORE INFORMATION" section to include WineHQ.

	* [documentation/debugger]
	Fixed typo.

	* [windows/defwnd.c]
	Added function documentation.

Sun Apr 19 16:30:58 1998  Marcus Meissner <marcus@mud.de>

	* [Make.rules.in]
	Added lint target (using lclint).

	* [relay32/oleaut32.spec][relay32/Makefile.in][ole/typelib.c]
	  [ole/ole2disp.c]
	Added oleaut32 spec, added some SysString functions.

	* [if1632/signal.c]
	Added printing of faultaddress in Linux (using CR2 debug register).

	* [configure.in]
	Added <sys/types.h> for statfs checks.

	* [loader/*.c][debugger/break.c][debugger/hash.c]
	Started to split win32/win16 module handling, preparing support
	for other binary formats (like ELF).

Sat Apr 18 10:07:41 1998  Rein Klazes <rklazes@casema.net>

	* [misc/registry.c]
	Fixed a bug that made RegQueryValuexxx returning
	incorrect registry values.

Fri Apr 17 22:59:22 1998  Alexander V. Lukyanov <lav@long.yar.ru>

	* [misc/lstr.c]
	FormatMessage32*: remove linefeed when nolinefeed set;
	check for target underflow.

Fri Apr 17 00:38:14 1998  Alexander V. Lukyanov <lav@long.yar.ru>

	* [misc/crtdll.c]
	Implement xlat_file_ptr for CRT stdin/stdout/stderr address
	translation.

Wed Apr 15 20:43:56 1998  Jim Peterson <jspeter@birch.ee.vt.edu>

	* [controls/menu.c]
	Added 'odaction' parameter to MENU_DrawMenuItem() and redirected
	WM_DRAWITEM messages to GetWindow(hwnd,GW_OWNER).

Tue Apr 14 16:17:55 1998  Berend Reitsma <berend@united-info.com>

	* [graphics/metafiledrv/init.c]	[graphics/painting.c] 
	  [graphics/win16drv/init.c] [graphics/x11drv/graphics.c]
	  [graphics/x11drv/init.c] [include/gdi.h] [include/x11drv.h]
	  [relay32/gdi32.spec]
	Added PolyPolyline routine.

	* [windows/winproc.c]
	Changed WINPROC_GetProc() to return proc instead of &(jmp proc).
diff --git a/objects/bitmap.c b/objects/bitmap.c
index 71fc644..241eaf3 100644
--- a/objects/bitmap.c
+++ b/objects/bitmap.c
@@ -81,7 +81,7 @@
 	break;
 
     default:
-	fprintf(stderr,"GetBitsPadding: unknown depth %d, please report.\n", bpp );
+	WARN(bitmap,"Unknown depth %d, please report.\n", bpp );
         return -1;
     }
     return pad;
@@ -115,7 +115,7 @@
 	return 2 * ((bmWidth+3) >> 2);
 
     default:
-	fprintf(stderr,"GetBitsPadding: unknown depth %d, please report.\n", bpp );
+	WARN(bitmap,"Unknown depth %d, please report.\n", bpp );
     }
     return -1;
 }
@@ -130,8 +130,19 @@
 }
 
 
-/***********************************************************************
- *           CreateBitmap32    (GDI32.25)
+/******************************************************************************
+ * CreateBitmap32 [GDI32.25]  Creates a bitmap with the specified info
+ *
+ * PARAMS
+ *    width  [I] bitmap width
+ *    height [I] bitmap height
+ *    planes [I] Number of color planes
+ *    bpp    [I] Number of bits to identify a color
+ *    bits   [I] Pointer to array containing color data
+ *
+ * RETURNS
+ *    Success: Handle to bitmap
+ *    Failure: NULL
  */
 HBITMAP32 WINAPI CreateBitmap32( INT32 width, INT32 height, UINT32 planes,
                                  UINT32 bpp, LPCVOID bits )
@@ -142,8 +153,7 @@
     planes = (BYTE)planes;
     bpp    = (BYTE)bpp;
 
-    TRACE(gdi, "%dx%d, %d colors\n", 
-                 width, height, 1 << (planes*bpp) );
+    TRACE(gdi, "%dx%d, %d colors\n", width, height, 1 << (planes*bpp) );
 
       /* Check parameters */
     if (!height || !width || planes != 1) return 0;
@@ -190,17 +200,31 @@
 }
 
 
-/***********************************************************************
- *           CreateCompatibleBitmap32    (GDI32.30)
+/******************************************************************************
+ * CreateCompatibleBitmap32 [GDI32.30]  Creates a bitmap compatible with the DC
+ *
+ * PARAMS
+ *    hdc    [I] Handle to device context
+ *    width  [I] Width of bitmap
+ *    height [I] Height of bitmap
+ *
+ * RETURNS
+ *    Success: Handle to bitmap
+ *    Failure: NULL
  */
-HBITMAP32 WINAPI CreateCompatibleBitmap32(HDC32 hdc, INT32 width, INT32 height)
+HBITMAP32 WINAPI CreateCompatibleBitmap32( HDC32 hdc, INT32 width, INT32 height)
 {
     HBITMAP32 hbmpRet = 0;
     DC *dc;
 
-    TRACE(gdi, "(%04x,%d,%d) = \n", 
-                 hdc, width, height );
+    TRACE(gdi, "(%04x,%d,%d) = \n", hdc, width, height );
     if (!(dc = DC_GetDCPtr( hdc ))) return 0;
+    if ((width >0x1000) || (height > 0x1000))
+      {
+	FIXME(gdi,"got bad width %d or height %d, please look for reason\n",
+	       width, height );
+	return 0;
+      }
     hbmpRet = CreateBitmap32( width, height, 1, dc->w.bitsPerPixel, NULL );
     TRACE(gdi,"\t\t%04x\n", hbmpRet);
     return hbmpRet;
@@ -217,10 +241,15 @@
 }
 
 
-/***********************************************************************
- *           CreateBitmapIndirect32    (GDI32.26)
+/******************************************************************************
+ * CreateBitmapIndirect32 [GDI32.26]  Creates a bitmap with the specifies info
+ *
+ * RETURNS
+ *    Success: Handle to bitmap
+ *    Failure: NULL
  */
-HBITMAP32 WINAPI CreateBitmapIndirect32( const BITMAP32 * bmp )
+HBITMAP32 WINAPI CreateBitmapIndirect32(
+    const BITMAP32 * bmp) /* [in] Pointer to the bitmap data */
 {
     return CreateBitmap32( bmp->bmWidth, bmp->bmHeight, bmp->bmPlanes,
                            bmp->bmBitsPixel, bmp->bmBits );
@@ -249,9 +278,16 @@
 
 
 /***********************************************************************
- *           GetBitmapBits32    (GDI32.143)
+ * GetBitmapBits32 [GDI32.143]  Copies bitmap bits of bitmap to buffer
+ * 
+ * RETURNS
+ *    Success: Number of bytes copied
+ *    Failure: 0
  */
-LONG WINAPI GetBitmapBits32( HBITMAP32 hbitmap, LONG count, LPVOID buffer )
+LONG WINAPI GetBitmapBits32(
+    HBITMAP32 hbitmap, /* [in]  Handle to bitmap */
+    LONG count,        /* [in]  Number of bytes to copy */
+    LPVOID buffer)     /* [out] Pointer to buffer to receive bits */
 {
     BITMAPOBJ * bmp;
     LONG height, old_height;
@@ -261,7 +297,7 @@
     
     /* KLUDGE! */
     if (count < 0) {
-	fprintf(stderr, "Negative number of bytes (%ld) passed to GetBitmapBits???\n", count );
+	WARN(bitmap, "(%ld): Negative number of bytes passed???\n", count );
 	count = -count;
     }
     bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
@@ -356,6 +392,9 @@
 	    }
             tbuf += pad;
 	}
+        break;
+    default:
+        FIXME(bitmap, "Unhandled bits:%d\n", bmp->bitmap.bmBitsPixel);
     }
     XDestroyImage( image );
     LeaveCriticalSection( &X11DRV_CritSection );
@@ -374,10 +413,17 @@
 }
 
 
-/***********************************************************************
- *           SetBitmapBits32    (GDI32.303)
+/******************************************************************************
+ * SetBitmapBits32 [GDI32.303]  Sets bits of color data for a bitmap
+ *
+ * RETURNS
+ *    Success: Number of bytes used in setting the bitmap bits
+ *    Failure: 0
  */
-LONG WINAPI SetBitmapBits32( HBITMAP32 hbitmap, LONG count, LPCVOID buffer )
+LONG WINAPI SetBitmapBits32(
+    HBITMAP32 hbitmap, /* [in] Handle to bitmap */
+    LONG count,        /* [in] Number of bytes in bitmap array */
+    LPCVOID buffer)    /* [in] Address of array with bitmap bits */
 {
     struct XPutImage_descr descr;
     BITMAPOBJ * bmp;
@@ -388,7 +434,7 @@
     
     /* KLUDGE! */
     if (count < 0) {
-	fprintf(stderr, "Negative number of bytes (%ld) passed to SetBitmapBits???\n", count );
+	WARN(bitmap, "(%ld): Negative number of bytes passed???\n", count );
 	count = -count;
     }
     bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
@@ -491,17 +537,19 @@
     return height * bmp->bitmap.bmWidthBytes;
 }
 
+/***********************************************************************
+ * LoadImage16 [USER.389]
+ *
+ */
 HANDLE16 WINAPI LoadImage16( HINSTANCE16 hinst, LPCSTR name, UINT16 type,
                              INT16 desiredx, INT16 desiredy, UINT16 loadflags)
 {
 	if (HIWORD(name)) {
-		fprintf(stddeb,"LoadImage16(0x%04x,%s,%d,%d,%d,0x%08x)\n",
-			hinst,(char *)PTR_SEG_TO_LIN(name),type,desiredx,desiredy,loadflags
-		);
+	    TRACE(resource,"(0x%04x,%s,%d,%d,%d,0x%08x)\n",
+                hinst,(char *)PTR_SEG_TO_LIN(name),type,desiredx,desiredy,loadflags);
 	} else {
-		fprintf(stddeb,"LoadImage16(0x%04x,%p,%d,%d,%d,0x%08x)\n",
-			hinst,name,type,desiredx,desiredy,loadflags
-		);
+	    TRACE(resource,"LoadImage16(0x%04x,%p,%d,%d,%d,0x%08x)\n",
+                hinst,name,type,desiredx,desiredy,loadflags);
 	}
 	switch (type) {
 	case IMAGE_BITMAP:
@@ -514,8 +562,10 @@
 	return 0;
 	
 }
+
 /**********************************************************************
  *	    LoadImage32A    (USER32.365)
+ * 
  * FIXME: implementation still lacks nearly all features, see LR_*
  * defines in windows.h
  */
@@ -543,8 +593,35 @@
 	return 0;
 }
 
+/**********************************************************************
+ *	    LoadImage32W    (USER32.366)
+ * 
+ * FIXME: implementation still lacks nearly all features, see LR_*
+ * defines in windows.h
+ */
+
+
+/******************************************************************************
+ * LoadImage32W [USER32.366]  Loads an icon, cursor, or bitmap
+ *
+ * PARAMS
+ *    hinst     [I] Handle of instance that contains image
+ *    name      [I] Name of image
+ *    type      [I] Type of image
+ *    desiredx  [I] Desired width
+ *    desiredy  [I] Desired height
+ *    loadflags [I] Load flags
+ *
+ * RETURNS
+ *    Success: Handle to newly loaded image
+ *    Failure: NULL
+ *
+ * BUGS
+ *    Implementation still lacks nearly all features, see LR_*
+ *    defines in windows.h
+ */
 HANDLE32 WINAPI LoadImage32W( HINSTANCE32 hinst, LPCWSTR name, UINT32 type,
-                              INT32 desiredx, INT32 desiredy, UINT32 loadflags)
+                INT32 desiredx, INT32 desiredy, UINT32 loadflags )
 {
 	if (HIWORD(name)) {
 		TRACE(resource,"(0x%04x,%p,%d,%d,%d,0x%08x)\n",
@@ -555,20 +632,25 @@
 			hinst,name,type,desiredx,desiredy,loadflags
 		);
 	}
-	switch (type) {
-	case IMAGE_BITMAP:
-		return LoadBitmap32W(hinst,name);
-	case IMAGE_ICON:
-		return LoadIcon32W(hinst,name);
-	case IMAGE_CURSOR:
-		return LoadCursor32W(hinst,name);
-	}
-	return 0;
+
+    switch (type) {
+        case IMAGE_BITMAP:
+            return LoadBitmap32W(hinst,name);
+        case IMAGE_ICON:
+            return LoadIcon32W(hinst,name);
+        case IMAGE_CURSOR:
+            return LoadCursor32W(hinst,name);
+    }
+    return NULL;
 }
 
+
 /**********************************************************************
  *          CopyBitmap32 (not an API)
  *
+ * NOTES
+ *    If it is not an API, why is it declared with WINAPI?
+ *
  */
 HBITMAP32 WINAPI CopyBitmap32 (HBITMAP32 hnd)
 {
@@ -583,8 +665,20 @@
     return res;
 }
 
-/**********************************************************************
- *	    CopyImage32    (USER32.61)
+
+/******************************************************************************
+ * CopyImage32 [USER32.61]  Creates new image and copies attributes to it
+ *
+ * PARAMS
+ *    hnd      [I] Handle to image to copy
+ *    type     [I] Type of image to copy
+ *    desiredx [I] Desired width of new image
+ *    desiredy [I] Desired height of new image
+ *    flags    [I] Copy flags
+ *
+ * RETURNS
+ *    Success: Handle to newly created image
+ *    Failure: NULL
  *
  * FIXME: implementation still lacks nearly all features, see LR_*
  * defines in windows.h
@@ -607,6 +701,9 @@
 
 /**********************************************************************
  *	    LoadBitmap16    (USER.175)
+ *
+ * NOTES
+ *    Can this call LoadBitmap32?
  */
 HBITMAP16 WINAPI LoadBitmap16( HINSTANCE16 instance, SEGPTR name )
 {
@@ -647,10 +744,17 @@
     return hbitmap;
 }
 
-/**********************************************************************
- *	    LoadBitmap32W   (USER32.358)
+
+/******************************************************************************
+ * LoadBitmap32W [USER32.358]  Loads bitmap from the executable file
+ *
+ * RETURNS
+ *    Success: Handle to specified bitmap
+ *    Failure: NULL
  */
-HBITMAP32 WINAPI LoadBitmap32W( HINSTANCE32 instance, LPCWSTR name )
+HBITMAP32 WINAPI LoadBitmap32W(
+    HINSTANCE32 instance, /* [in] Handle to application instance */
+    LPCWSTR name)         /* [in] Address of bitmap resource name */
 {
     HBITMAP32 hbitmap = 0;
     HDC32 hdc;
@@ -754,7 +858,6 @@
 }
     
 
-
 /***********************************************************************
  *           CreateDiscardableBitmap16    (GDI.156)
  */
@@ -765,11 +868,17 @@
 }
 
 
-/***********************************************************************
- *           CreateDiscardableBitmap32    (GDI32.38)
+/******************************************************************************
+ * CreateDiscardableBitmap32 [GDI32.38]  Creates a discardable bitmap
+ *
+ * RETURNS
+ *    Success: Handle to bitmap
+ *    Failure: NULL
  */
-HBITMAP32 WINAPI CreateDiscardableBitmap32( HDC32 hdc, INT32 width,
-                                            INT32 height )
+HBITMAP32 WINAPI CreateDiscardableBitmap32(
+    HDC32 hdc,    /* [in] Handle to device context */
+    INT32 width,  /* [in] Bitmap width */
+    INT32 height) /* [in] Bitmap height */
 {
     return CreateCompatibleBitmap32( hdc, width, height );
 }
@@ -777,6 +886,9 @@
 
 /***********************************************************************
  *           GetBitmapDimensionEx16    (GDI.468)
+ *
+ * NOTES
+ *    Can this call GetBitmapDimensionEx32?
  */
 BOOL16 WINAPI GetBitmapDimensionEx16( HBITMAP16 hbitmap, LPSIZE16 size )
 {
@@ -788,10 +900,16 @@
 }
 
 
-/***********************************************************************
- *           GetBitmapDimensionEx32    (GDI32.144)
+/******************************************************************************
+ * GetBitmapDimensionEx32 [GDI32.144]  Retrieves dimensions of a bitmap
+ *
+ * RETURNS
+ *    Success: TRUE
+ *    Failure: FALSE
  */
-BOOL32 WINAPI GetBitmapDimensionEx32( HBITMAP32 hbitmap, LPSIZE32 size )
+BOOL32 WINAPI GetBitmapDimensionEx32(
+    HBITMAP32 hbitmap, /* [in]  Handle to bitmap */
+    LPSIZE32 size)     /* [out] Address of struct receiving dimensions */
 {
     BITMAPOBJ * bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
     if (!bmp) return FALSE;
@@ -829,11 +947,18 @@
 }
 
 
-/***********************************************************************
- *           SetBitmapDimensionEx32    (GDI32.304)
+/******************************************************************************
+ * SetBitmapDimensionEx32 [GDI32.304]  Assignes dimensions to a bitmap
+ *
+ * RETURNS
+ *    Success: TRUE
+ *    Failure: FALSE
  */
-BOOL32 WINAPI SetBitmapDimensionEx32( HBITMAP32 hbitmap, INT32 x, INT32 y,
-                                      LPSIZE32 prevSize )
+BOOL32 WINAPI SetBitmapDimensionEx32(
+    HBITMAP32 hbitmap, /* [in]  Handle to bitmap */
+    INT32 x,           /* [in]  Bitmap width */
+    INT32 y,           /* [in]  Bitmap height */
+    LPSIZE32 prevSize) /* [out] Address of structure for orig dims */
 {
     BITMAPOBJ * bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
     if (!bmp) return FALSE;
diff --git a/objects/clipping.c b/objects/clipping.c
index 1736092..7025d74 100644
--- a/objects/clipping.c
+++ b/objects/clipping.c
@@ -29,7 +29,7 @@
 
     if (!dc->w.hVisRgn)
     {
-        fprintf( stderr, "UpdateGCRegion: hVisRgn is zero. Please report this.\n" );
+        ERR(region, "hVisRgn is zero. Please report this.\n" );
         exit(1);
     }
 
@@ -463,7 +463,7 @@
     TRACE(clipping, "%04x\n", hdc );
     if (!dc->w.hVisRgn)
     {
-        fprintf( stderr, "SaveVisRgn: hVisRgn is zero. Please report this.\n" );
+        ERR(region, "hVisRgn is zero. Please report this.\n" );
         exit(1);
     }
     if( dc->w.flags & DC_DIRTY ) UPDATE_DIRTY_DC(dc);
diff --git a/objects/color.c b/objects/color.c
index 9f37ebc..50779dc 100644
--- a/objects/color.c
+++ b/objects/color.c
@@ -288,7 +288,7 @@
 
     COLOR_sysPal = (PALETTEENTRY*)xmalloc(sizeof(PALETTEENTRY)*cs->size);
 
-    TRACE(palette,"\tbuilding private map - %i palette entries\n", cs->size);
+    TRACE(palette,"Building private map - %i palette entries\n", cs->size);
 
       /* Allocate system palette colors */ 
 
@@ -347,7 +347,7 @@
    else if (COLOR_max < 20) COLOR_max = 20;
    TRACE(palette,"%d colors configured.\n", COLOR_max);
    
-   TRACE(palette,"\tbuilding shared map - %i palette entries\n", cs->size);
+   TRACE(palette,"Building shared map - %i palette entries\n", cs->size);
 
    /* Be nice and allocate system colors as read-only */
 
@@ -402,7 +402,7 @@
 
         sysPixel[i] = color.pixel;
 
-        TRACE(palette,"\tsyscolor(%lx) -> pixel %i\n",
+        TRACE(palette,"syscolor(%lx) -> pixel %i\n",
 		      *(COLORREF*)(__sysPalTemplate+i), (int)color.pixel);
 
         /* Set EGA mapping if color in the first or last eight */
@@ -419,7 +419,7 @@
      {
 	int c_min = 0, c_max = cs->size, c_val;
 
-	TRACE(palette,"\tdynamic colormap... \n");
+	TRACE(palette,"Dynamic colormap... \n");
 
 	/* comment this out if you want to debug palette init */
 
@@ -453,7 +453,7 @@
 	  if( !TSXAllocColorCells(display, cs->colorMap, False,
                                 plane_masks, 0, pixDynMapping, c_min) )
 	    {
-	      fprintf(stderr,"Inexplicable failure during colorcell allocation.\n");
+	      WARN(palette,"Inexplicable failure during colorcell allocation.\n");
 	      c_min = 0;
 	    }
 
@@ -470,7 +470,7 @@
 	   * to maintain compatibility
 	   */
 	  cs->size = 256;
-	  TRACE(palette,"\tvirtual colorspace - screendepth %i\n", screenDepth);
+	  TRACE(palette,"Virtual colorspace - screendepth %i\n", screenDepth);
 	}
    else cs->size = NB_RESERVED_COLORS;	/* system palette only - however we can alloc a bunch
 			                 * of colors and map to them */
@@ -529,7 +529,7 @@
            else
              COLOR_PaletteToPixel[i] = i;
 
-      TRACE(palette,"\tindex %i -> pixel %i\n", i, COLOR_PaletteToPixel[i]);
+      TRACE(palette,"index %i -> pixel %i\n", i, COLOR_PaletteToPixel[i]);
 
       if( COLOR_PixelToPalette )
           COLOR_PixelToPalette[COLOR_PaletteToPixel[i]] = i;
@@ -798,7 +798,7 @@
   else if( spec_type == 1 ) /* PALETTEINDEX */
     if( (i = color & 0x0000ffff) >= size ) 
       {
-	fprintf(stderr, "\tRGB(%lx) : idx %d is out of bounds, assuming NULL\n", color, i);
+	WARN(palette, "RGB(%lx) : idx %d is out of bounds, assuming NULL\n", color, i);
 	color = *(COLORREF*)palPalEntry;
       }
     else color = *(COLORREF*)(palPalEntry + i);
@@ -888,7 +888,7 @@
 
             if( (idx = color & 0xffff) >= palPtr->logpalette.palNumEntries)
             {
-                fprintf(stderr, "\tRGB(%lx) : idx %d is out of bounds, assuming black\n", color, idx);
+                WARN(palette, "RGB(%lx) : idx %d is out of bounds, assuming black\n", color, idx);
 		GDI_HEAP_UNLOCK( hPal );
                 return 0;
             }
@@ -941,7 +941,7 @@
 
 	if( !palPtr ) return 0;
 	else if( !palPtr->mapping ) 
-            WARN(palette, "\tpalette %04x is not realized\n", dc->w.hPalette);
+            WARN(palette, "Palette %04x is not realized\n", dc->w.hPalette);
 
 	switch(spec_type)	/* we have to peruse DC and system palette */
     	{
@@ -960,24 +960,24 @@
 	    	index = COLOR_PaletteLookupPixel( COLOR_sysPal, 256, 
 						  COLOR_PaletteToPixel, color, FALSE);
 
-		/* TRACE(palette,"\tRGB(%lx) -> pixel %i\n", color, index);
+		/* TRACE(palette,"RGB(%lx) -> pixel %i\n", color, index);
 		 */
 	    	break;
        	    case 1:  /* PALETTEINDEX */
 		index = color & 0xffff;
 
 	        if( index >= palPtr->logpalette.palNumEntries )
-		    fprintf(stderr, "\tRGB(%lx) : index %i is out of bounds\n", color, index); 
+		    WARN(palette, "RGB(%lx) : index %i is out of bounds\n", color, index); 
 		else if( palPtr->mapping ) index = palPtr->mapping[index];
 
-		/*  TRACE(palette,"\tPALETTEINDEX(%04x) -> pixel %i\n", (WORD)color, index);
+		/*  TRACE(palette,"PALETTEINDEX(%04x) -> pixel %i\n", (WORD)color, index);
 		 */
 		break;
             case 2:  /* PALETTERGB */
 		index = COLOR_PaletteLookupPixel( palPtr->logpalette.palPalEntry, 
                                              palPtr->logpalette.palNumEntries,
                                              palPtr->mapping, color, FALSE);
-		/* TRACE(palette,"\tPALETTERGB(%lx) -> pixel %i\n", color, index);
+		/* TRACE(palette,"PALETTERGB(%lx) -> pixel %i\n", color, index);
 		 */
 		break;
 	}
@@ -1020,7 +1020,7 @@
             index = *(WORD*)(palPtr->logpalette.palPalEntry + uStart);
             if( index > 255 || (index >= COLOR_gapStart && index <= COLOR_gapEnd) ) 
             {
-                fprintf(stderr,"PC_EXPLICIT: idx %d out of system palette, assuming black.\n", index); 
+                WARN(palette,"PC_EXPLICIT: idx %d out of system palette, assuming black.\n", index); 
                 index = 0;
             }
             break;
@@ -1077,7 +1077,7 @@
         if( !prevMapping || palPtr->mapping[uStart] != index ) iRemapped++;
         palPtr->mapping[uStart] = index;
 
-        TRACE(palette,"\tentry %i (%lx) -> pixel %i\n", uStart, 
+        TRACE(palette,"entry %i (%lx) -> pixel %i\n", uStart, 
 				*(COLORREF*)(palPtr->logpalette.palPalEntry + uStart), index);
 	
     }
diff --git a/objects/cursoricon.c b/objects/cursoricon.c
index 84170bf..36918ef 100644
--- a/objects/cursoricon.c
+++ b/objects/cursoricon.c
@@ -44,6 +44,7 @@
 #include "keyboard.h"
 
 extern UINT16 COLOR_GetSystemPaletteSize();
+extern void _XInitImageFuncPtrs(XImage *);
 
 Cursor CURSORICON_XCursor = None;    /* Current X cursor */
 static HCURSOR32 hActiveCursor = 0;  /* Active cursor */
@@ -63,7 +64,7 @@
 
     if (dir->idCount < 1)
     {
-        fprintf( stderr, "Icon: empty directory!\n" );
+        WARN(icon, "Empty directory!\n" );
         return NULL;
     }
     if (dir->idCount == 1) return &dir->idEntries[0].icon;  /* No choice... */
@@ -168,7 +169,7 @@
 
     if (dir->idCount < 1)
     {
-        fprintf( stderr, "Cursor: empty directory!\n" );
+        WARN(cursor, "Empty directory!\n" );
         return NULL;
     }
     if (dir->idCount == 1) return &dir->idEntries[0].cursor; /* No choice... */
@@ -278,7 +279,7 @@
  *        Convert to mono when cFlag is LR_MONOCHROME. Do something
  *        with cbSize parameter as well.
  */
-static HGLOBAL16 CURSORICON_CreateFromResource( HINSTANCE32 hInstance, HGLOBAL16 hObj, LPBYTE bits,
+static HGLOBAL16 CURSORICON_CreateFromResource( HINSTANCE16 hInstance, HGLOBAL16 hObj, LPBYTE bits,
 	 					UINT32 cbSize, BOOL32 bIcon, DWORD dwVersion, 
 						INT32 width, INT32 height, UINT32 cFlag )
 {
@@ -400,7 +401,7 @@
 	CURSORICONINFO *info;
 
 	/* Make it owned by the module */
-	if (hInstance) FarSetOwner( hObj, MODULE_HANDLEtoHMODULE16(hInstance));
+	if (hInstance) FarSetOwner( hObj, GetExePtr(hInstance) );
 
 	info = (CURSORICONINFO *)GlobalLock16( hObj );
 	info->ptHotSpot.x   = hotspot.x;
@@ -571,7 +572,7 @@
 	    if( !pRsrcEntry->ResourceHandle ) 
 	    {
 		LPBYTE bits = (LPBYTE)LockResource32( handle );
-		h = CURSORICON_CreateFromResource( hInstance, 0, bits, dirEntry.icon.dwBytesInRes, 
+		h = CURSORICON_CreateFromResource( 0, 0, bits, dirEntry.icon.dwBytesInRes, 
 					!fCursor, 0x00030000, width, height, LR_DEFAULTCOLOR );
 		pRsrcEntry->ResourceHandle = h;
 	    }
@@ -1099,7 +1100,8 @@
         while(hwnd)
         {
             Window win = WIN_GetXWindow( hwnd );
-            if (win) XDefineCursor( display, win, cursor );
+            if (win && win!=DefaultRootWindow(display))
+                XDefineCursor( display, win, cursor );
             hwnd = GetWindow32( hwnd, GW_HWNDNEXT );
         }
     }
@@ -1555,31 +1557,54 @@
     return hObj;
 }
 
+
 /**********************************************************************
  *          DrawIconEx16		(USER.394)
  */
-
 BOOL16 WINAPI DrawIconEx16 (HDC16 hdc, INT16 xLeft, INT16 yTop, HICON16 hIcon,
 			    INT16 cxWidth, INT16 cyWidth, UINT16 istep,
 			    HBRUSH16 hbr, UINT16 flags)
 {
-  return DrawIconEx32 (hdc, xLeft, yTop, hIcon, cxWidth, cyWidth,
-		       istep, hbr, flags);
+    return DrawIconEx32(hdc, xLeft, yTop, hIcon, cxWidth, cyWidth,
+                        istep, hbr, flags);
 }
 
-/**********************************************************************
- *          DrawIconEx32		(USER32.160)
- */
 
-BOOL32 WINAPI DrawIconEx32 (HDC32 hdc, INT32 x0, INT32 y0, HICON32 hIcon,
-			    INT32 cxWidth, INT32 cyWidth, UINT32 istep,
-			    HBRUSH32 hbr, UINT32 flags)
+/******************************************************************************
+ * DrawIconEx32 [USER32.160]  Draws an icon or cursor on device context
+ *
+ * NOTES
+ *    Why is this using SM_CXICON instead of SM_CXCURSOR?
+ *
+ * PARAMS
+ *    hdc     [I] Handle to device context
+ *    x0      [I] X coordinate of upper left corner
+ *    y0      [I] Y coordinate of upper left corner
+ *    hIcon   [I] Handle to icon to draw
+ *    cxWidth [I] Width of icon
+ *    cyWidth [I] Height of icon
+ *    istep   [I] Index of frame in animated cursor
+ *    hbr     [I] Handle to background brush
+ *    flags   [I] Icon-drawing flags
+ *
+ * RETURNS
+ *    Success: TRUE
+ *    Failure: FALSE
+ */
+BOOL32 WINAPI DrawIconEx32( HDC32 hdc, INT32 x0, INT32 y0, HICON32 hIcon,
+                            INT32 cxWidth, INT32 cyWidth, UINT32 istep, 
+                            HBRUSH32 hbr, UINT32 flags )
 {
     CURSORICONINFO *ptr = (CURSORICONINFO *)GlobalLock16 (hIcon);
     HDC32 hMemDC = CreateCompatibleDC32 (hdc);
     BOOL32 result = FALSE;
 
-    FIXME(icon, "part stub.\n");
+    if (istep)
+        FIXME(icon, "Ignoring istep=%d\n", istep);
+    if (hbr)
+        FIXME(icon, "Ignoring hbr=%x\n", hbr);
+    if (flags & DI_COMPAT)
+        FIXME(icon, "Ignoring flag DI_COMPAT\n");
 
     if (hMemDC && ptr)
     {
diff --git a/objects/dc.c b/objects/dc.c
index 8db9adc..6c71c18 100644
--- a/objects/dc.c
+++ b/objects/dc.c
@@ -428,7 +428,7 @@
 		   GCFont, &val );
 	return TRUE;
     } 
-    fprintf( stderr, "DC_SetupGCForText: physical font failure\n" );
+    WARN(dc, "Physical font failure\n" );
     return FALSE;
 }
 
@@ -911,7 +911,7 @@
  */
 HDC16 WINAPI ResetDC16( HDC16 hdc, const DEVMODE16 *devmode )
 {
-    fprintf( stderr, "ResetDC16: empty stub!\n" );
+    FIXME(dc, "stub\n" );
     return hdc;
 }
 
@@ -921,7 +921,7 @@
  */
 HDC32 WINAPI ResetDC32A( HDC32 hdc, const DEVMODE32A *devmode )
 {
-    fprintf( stderr, "ResetDC32A: empty stub!\n" );
+    FIXME(dc, "stub\n" );
     return hdc;
 }
 
@@ -931,7 +931,7 @@
  */
 HDC32 WINAPI ResetDC32W( HDC32 hdc, const DEVMODE32W *devmode )
 {
-    fprintf( stderr, "ResetDC32A: empty stub!\n" );
+    FIXME(dc, "stub\n" );
     return hdc;
 }
 
diff --git a/objects/dib.c b/objects/dib.c
index 7dd033f..a5ae6e3 100644
--- a/objects/dib.c
+++ b/objects/dib.c
@@ -77,7 +77,8 @@
     for( i = 0; bitmapDepthTable[i] ; i++ )
 	 if( bitmapDepthTable[i] == depth )
 	     return (4 * ((width * ximageDepthTable[i] + 31)/32));
-    fprintf(stderr, "DIB: unsupported depth %d.\n", depth );
+    
+    WARN(bitmap, "(%d): Unsupported depth\n", depth );
     return (4 * width);
 }
 
@@ -101,7 +102,7 @@
 	case 24: words = (width * 3 + 3)/4; break;
 
 	default:
-        	fprintf(stderr, "DIB: unsupported depth %d.\n", depth );
+            WARN(bitmap, "(%d): Unsupported depth\n", depth );
 	/* fall through */
 	case 32:
 	        words = width;
@@ -161,8 +162,7 @@
         *bpp    = core->bcBitCount;
         return 0;
     }
-    fprintf( stderr, "DIB_GetBitmapInfo: wrong size (%ld) for header\n",
-             header->biSize );
+    WARN(bitmap, "(%ld): wrong size for header\n", header->biSize );
     return -1;
 }
 
@@ -825,7 +825,7 @@
                              descr->width, descr->xSrc, descr->dc, bmpImage);
 	break;
     default:
-        fprintf( stderr, "Invalid depth %d for SetDIBits!\n", descr->infoBpp );
+        WARN(bitmap, "(%d): Invalid depth\n", descr->infoBpp );
         break;
     }
     if (colorMapping) HeapFree( GetProcessHeap(), 0, colorMapping );
@@ -886,8 +886,21 @@
 }
 
 
-/***********************************************************************
- *           SetDIBits32   (GDI32.312)
+/******************************************************************************
+ * SetDIBits32 [GDI32.312]  Sets pixels in a bitmap using colors from DIB
+ *
+ * PARAMS
+ *    hdc       [I] Handle to device context
+ *    hbitmap   [I] Handle to bitmap
+ *    startscan [I] Starting scan line
+ *    lines     [I] Number of scan lines
+ *    bits      [I] Array of bitmap bits
+ *    info      [I] Address of structure with data
+ *    coloruse  [I] Type of color indexes to use
+ *
+ * RETURNS
+ *    Success: Number of scan lines copied
+ *    Failure: 0
  */
 INT32 WINAPI SetDIBits32( HDC32 hdc, HBITMAP32 hbitmap, UINT32 startscan,
                           UINT32 lines, LPCVOID bits, const BITMAPINFO *info,
@@ -1124,14 +1137,23 @@
 }
 
 
-/***********************************************************************
- *           GetDIBits32    (GDI32.170)
+/******************************************************************************
+ * GetDIBits32 [GDI32.170]  Retrieves bits of bitmap and copies to buffer
+ *
+ * RETURNS
+ *    Success: Number of scan lines copied from bitmap
+ *    Failure: 0
  *
  * http://www.microsoft.com/msdn/sdk/platforms/doc/sdk/win32/func/src/f30_14.htm
  */
-INT32 WINAPI GetDIBits32( HDC32 hdc, HBITMAP32 hbitmap, UINT32 startscan,
-                          UINT32 lines, LPSTR bits, BITMAPINFO * info,
-                          UINT32 coloruse )
+INT32 WINAPI GetDIBits32(
+    HDC32 hdc,         /* [in]  Handle to device context */
+    HBITMAP32 hbitmap, /* [in]  Handle to bitmap */
+    UINT32 startscan,  /* [in]  First scan line to set in dest bitmap */
+    UINT32 lines,      /* [in]  Number of scan lines to copy */
+    LPSTR bits,        /* [out] Address of array for bitmap bits */
+    BITMAPINFO * info, /* [out] Address of structure with bitmap data */
+    UINT32 coloruse)   /* [in]  RGB or palette index */
 {
     DC * dc;
     BITMAPOBJ * bmp;
@@ -1292,9 +1314,8 @@
 		}
 		break;
 	   default:
-	   	fprintf(stderr,"GetDIBits*: unsupported depth %d\n",
-			info->bmiHeader.biBitCount
-		);
+	   	WARN(bitmap,"Unsupported depth %d\n",
+                   info->bmiHeader.biBitCount);
 	   	break;
 	}
 
@@ -1386,7 +1407,7 @@
         }
         else
         {
-            fprintf( stderr, "CreateDIBitmap: wrong size (%ld) for data\n",
+            WARN(bitmap, "(%ld): wrong size for data\n",
                      data->bmiHeader.biSize );
             return 0;
         }
@@ -1422,11 +1443,11 @@
 {
   HBITMAP32 res = 0;
 
-  fprintf(stderr,
-	  "CreateDIBSection(%d,[w=%ld,h=%ld],%d,%p,0x%08x,%ld),semistub\n",
+  FIXME(bitmap,
+	  "(%d,[w=%ld,h=%ld],%d,%p,0x%08x,%ld),semistub\n",
 	  hdc,bmi->bmiHeader.biWidth,bmi->bmiHeader.biHeight,
-	  usage,bits,section,offset
-	);
+	  usage,bits,section,offset);
+
   if (bmi->bmiHeader.biHeight < 0 ) bmi->bmiHeader.biHeight = -bmi->bmiHeader.biHeight;
   if (bmi->bmiHeader.biWidth < 0 ) bmi->bmiHeader.biWidth = -bmi->bmiHeader.biWidth;
   /* FIXME.  The following line isn't quite right.  */
@@ -1439,8 +1460,10 @@
             /* FIXME: this is wrong! (bmBits is always NULL) */
             if (bits) *bits = bmp.bmBits;
 	    /* hmpf */
-	    fprintf(stderr,"allocating %ld bytes of memory\n",bmi->bmiHeader.biWidth*bmi->bmiHeader.biHeight*4);
-	    if (bits) *bits = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,bmi->bmiHeader.biWidth*bmi->bmiHeader.biHeight*4);
+	    TRACE(bitmap,"allocating %ld bytes of memory\n",
+                bmi->bmiHeader.biWidth*bmi->bmiHeader.biHeight*4);
+	    if (bits) *bits = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,
+                bmi->bmiHeader.biWidth*bmi->bmiHeader.biHeight*4);
             return res;
 	}
     }
diff --git a/objects/enhmetafile.c b/objects/enhmetafile.c
index 9745666..d6b784f 100644
--- a/objects/enhmetafile.c
+++ b/objects/enhmetafile.c
@@ -22,7 +22,7 @@
 {
   HENHMETAFILE32 hmf = 0;
   ENHMETAHEADER h;
-  char *p;
+  BYTE *p;
   DWORD read;
   HFILE32 hf = CreateFile32A(lpszMetaFile, GENERIC_READ, 0, 0, 
 			     OPEN_EXISTING, 0, 0);
@@ -31,7 +31,7 @@
   if (read!=sizeof(ENHMETAHEADER)) return 0;
   SetFilePointer(hf, 0, NULL, FILE_BEGIN); 
   /*  hmf = CreateFileMapping32A( hf, NULL, NULL, NULL, NULL, "temp"); */
-  hmf = GlobalAlloc32(GHND, h.nBytes);
+  hmf = GlobalAlloc32(GPTR, h.nBytes);
   p = GlobalLock32(hmf);
   if (!ReadFile(hf, p, h.nBytes, &read, NULL)) return 0;
   GlobalUnlock32(hmf);
@@ -54,6 +54,7 @@
   LPENHMETAHEADER p = GlobalLock32(hmf);
   if (!buf) return sizeof(ENHMETAHEADER);
   memmove(buf, p, MIN(sizeof(ENHMETAHEADER), bufsize));
+  GlobalUnlock32(hmf);
   return MIN(sizeof(ENHMETAHEADER), bufsize);
 }
 
@@ -105,6 +106,32 @@
   return MIN(size,p->nDescription);
 }
 
+/****************************************************************************
+ *    SetEnhMetaFileBits (GDI32.315)
+ *
+ *  Creates an enhanced metafile by copying _bufsize_ bytes from _buf_.
+ */
+HENHMETAFILE32 WINAPI SetEnhMetaFileBits(UINT32 bufsize, const BYTE *buf)
+{
+  HENHMETAFILE32 hmf = GlobalAlloc32(GPTR, bufsize);
+  LPENHMETAHEADER h = GlobalLock32(hmf);
+  memmove(h, buf, bufsize);
+  GlobalUnlock32(hmf);
+  return hmf;
+}
+
+/*****************************************************************************
+ *  GetEnhMetaFileBits (GDI32.175)
+ *
+ */
+UINT32 WINAPI GetEnhMetaFileBits(
+    HENHMETAFILE32 hmf, 
+    UINT32 bufsize, 
+    LPBYTE buf  
+) {
+  return 0;
+}
+
 /*****************************************************************************
  *           PlayEnhMetaFileRecord  (GDI32.264)
  *
@@ -142,11 +169,9 @@
       }
     case EMR_EOF:
       break;
-
     case EMR_GDICOMMENT:
       /* application defined and processed */
       break;
-
     case EMR_SETMAPMODE:
       {
 	DWORD mode = mr->dParm[0];
@@ -212,7 +237,6 @@
 	IntersectClipRect32(hdc, left, top, right, bottom);
 	break;
       }
-
     case EMR_SELECTOBJECT:
       {
 	DWORD obj = mr->dParm[0];
@@ -226,7 +250,6 @@
 	(handletable->objectHandle)[obj] = 0;
 	break;
       }
-
     case EMR_SETWINDOWORGEX:
       {
 	DWORD x = mr->dParm[0], y = mr->dParm[1];
@@ -251,7 +274,6 @@
 	SetViewportExtEx32(hdc, x, y, NULL);
 	break;
       }
-
     case EMR_CREATEPEN:
       {
 	DWORD obj = mr->dParm[0];
@@ -264,7 +286,7 @@
 	DWORD obj = mr->dParm[0];
 	DWORD style = mr->dParm[1], brush = mr->dParm[2];
 	LOGBRUSH32 *b = (LOGBRUSH32 *) &mr->dParm[3];
-	/* FIXME: other args not handled */
+	FIXME(metafile, "Some ExtCreatePen args not handled\n");
 	(handletable->objectHandle)[obj] = 
 	  ExtCreatePen32(style, brush, b, 0, NULL);
 	break;
@@ -283,7 +305,6 @@
 	  CreateFontIndirect32W((LOGFONT32W *) &(mr->dParm[1]));
 	break;
 	}
-
     case EMR_MOVETOEX:
       {
 	DWORD x = mr->dParm[0], y = mr->dParm[1];
@@ -310,14 +331,23 @@
 	Ellipse32(hdc, left, top, right, bottom);
 	break;
       }
-
     case EMR_POLYGON16:
       {
-	/* FIXME: 0-3 : a bounding rectangle? */
+	/* 0-3 : a bounding rectangle? */
 	INT32 count = mr->dParm[4];
+	FIXME(metafile, "Some Polygon16 args not handled\n");
 	Polygon16(hdc, (POINT16 *)&mr->dParm[5], count);
 	break;
       }
+    case EMR_POLYLINE16:
+      {
+	/* 0-3 : a bounding rectangle? */
+	INT32 count = mr->dParm[4];
+	FIXME(metafile, "Some Polyline16 args not handled\n");
+	Polyline16(hdc, (POINT16 *)&mr->dParm[5], count);
+	break;
+      }
+
 #if 0
     case EMR_POLYPOLYGON16:
       {
@@ -338,6 +368,7 @@
 	/* 10-16: ??? */
 	LPWSTR str = (LPWSTR)& mr->dParm[17];
 	/* trailing info: dx array? */
+	FIXME(metafile, "Many ExtTextOut args not handled\n");
 	ExtTextOut32W(hdc, x, y, flags, /* lpRect */ NULL, 
 		      str, count, /* lpDx */ NULL); 
 	break;
@@ -413,27 +444,61 @@
   INT32 count = ((LPENHMETAHEADER) p)->nHandles;
   HANDLETABLE32 *ht = (HANDLETABLE32 *)GlobalAlloc32(GPTR, 
 				    sizeof(HANDLETABLE32)*count);
+  BOOL32 ret = FALSE;
+  if (lpRect) {
+    LPENHMETAHEADER h = (LPENHMETAHEADER) p;
+    FLOAT xscale = (h->rclBounds.right-h->rclBounds.left)/(lpRect->right-lpRect->left);
+    FLOAT yscale = (h->rclBounds.bottom-h->rclBounds.top)/(lpRect->bottom-lpRect->top);
+    XFORM xform = {xscale, 0, 0, yscale, 0, 0};
+    /*    xform.eDx = lpRect->left;
+	  xform.eDy = lpRect->top; */
+    FIXME(metafile, "play into rect doesn't work\n");
+    if (!SetWorldTransform(hdc, &xform)) {
+      WARN(metafile, "World transform failed!\n");
+    }
+  }
+
   ht->objectHandle[0] = hmf;
   while (1) {
     PlayEnhMetaFileRecord(hdc, ht, p, count);
     if (p->iType == EMR_EOF) break;
     p = (void *) p + p->nSize; /* casted so that arithmetic is in bytes */
   }
-  return FALSE;
+  GlobalUnlock32(hmf);
+  return TRUE;
 }
 
 /*****************************************************************************
  *  DeleteEnhMetaFile (GDI32.68)
+ *
+ *  Deletes an enhanced metafile and frees the associated storage.
  */
 BOOL32 WINAPI DeleteEnhMetaFile(HENHMETAFILE32 hmf) {
   return !GlobalFree32(hmf);
 }
 
 /*****************************************************************************
- *  CopyEnhMetaFileA (GDI32.21)
+ *  CopyEnhMetaFileA (GDI32.21)  Duplicate an enhanced metafile
+ *
+ *   
  */
-HENHMETAFILE32 WINAPI CopyEnhMetaFile32A(HENHMETAFILE32 hmf, LPCSTR file) {
-  return 0;
+HENHMETAFILE32 WINAPI CopyEnhMetaFile32A(
+    HENHMETAFILE32 hmf, 
+    LPCSTR file)
+{
+  if (!file) {
+    LPENHMETAHEADER h = GlobalLock32(hmf);
+    HENHMETAFILE32 hmf2 = GlobalAlloc32(GPTR, h->nBytes);
+    LPENHMETAHEADER h2 = GlobalLock32(hmf2);
+    if (!h2) return 0;
+    memmove(h2, h, h->nBytes);
+    GlobalUnlock32(hmf2);
+    GlobalUnlock32(hmf);
+    return hmf2;
+  } else {
+    FIXME(metafile, "write to file not implemented\n");
+    return 0;
+  }
 }
 
 
diff --git a/objects/font.c b/objects/font.c
index 76948e8..7117e7e 100644
--- a/objects/font.c
+++ b/objects/font.c
@@ -221,12 +221,21 @@
 	    fontPtr = (FONTOBJ *) GDI_HEAP_LOCK( hFont );
 	    memcpy( &fontPtr->logfont, font, sizeof(LOGFONT16) );
 
-	    TRACE(font,"(%i %i) '%s' %s %s => %04x\n",
+	    TRACE(font,"(%i %i %i %i) '%s' %s %s => %04x\n",
 				 font->lfHeight, font->lfWidth, 
+		                 font->lfEscapement, font->lfOrientation,
 				 font->lfFaceName ? font->lfFaceName : "NULL",
 				 font->lfWeight > 400 ? "Bold" : "",
 				 font->lfItalic ? "Italic" : "",
 				 hFont);
+
+	    if (font->lfEscapement != font->lfOrientation) {
+	      /* this should really depend on whether GM_ADVANCED is set */
+	      fontPtr->logfont.lfOrientation = fontPtr->logfont.lfEscapement;
+	      WARN(font, 
+       "orientation angle %f set to escapement angle %f for new font %04x\n", 
+	   font->lfOrientation/10., font->lfEscapement/10., hFont);
+	    }
 	    GDI_HEAP_UNLOCK( hFont );
 	}
     }
@@ -1052,19 +1061,32 @@
 BOOL32 WINAPI GetCharABCWidths32A(HDC32 hdc, UINT32 firstChar, UINT32 lastChar,
                                   LPABC32 abc )
 {
-    /* No TrueType fonts in Wine so far */
-    FIXME(font, "(%04x,%04x,%04x,%p): stub\n", hdc, firstChar, lastChar, abc );
-    return FALSE;
+    return GetCharABCWidths32W( hdc, firstChar, lastChar, abc );
 }
 
 
-/***********************************************************************
- *           GetCharABCWidths32W   (GDI32.152)
+/******************************************************************************
+ * GetCharABCWidths32W [GDI32.152]  Retrieves widths of characters in range
+ *
+ * PARAMS
+ *    hdc       [I] Handle of device context
+ *    firstChar [I] First character in range to query
+ *    lastChar  [I] Last character in range to query
+ *    abc       [O] Address of character-width structure
+ *
+ * NOTES
+ *    Only works with TrueType fonts
+ *
+ * RETURNS
+ *    Success: TRUE
+ *    Failure: FALSE
  */
-BOOL32 WINAPI GetCharABCWidths32W(HDC32 hdc, UINT32 firstChar, UINT32 lastChar,
-                                  LPABC32 abc )
+BOOL32 WINAPI GetCharABCWidths32W( HDC32 hdc, UINT32 firstChar, UINT32 lastChar,
+                                   LPABC32 abc )
 {
-    return GetCharABCWidths32A( hdc, firstChar, lastChar, abc );
+    /* No TrueType fonts in Wine so far */
+    FIXME(font, "(%04x,%04x,%04x,%p): stub\n", hdc, firstChar, lastChar, abc);
+    return FALSE;
 }
 
 
diff --git a/objects/gdiobj.c b/objects/gdiobj.c
index 8d060b0..ae4ad7e 100644
--- a/objects/gdiobj.c
+++ b/objects/gdiobj.c
@@ -471,7 +471,7 @@
 	  result = PALETTE_GetObject( (PALETTEOBJ *)ptr, count, buffer );
 	  break;
       default:
-          fprintf( stderr, "GetObject32: magic %04x not implemented\n",
+          FIXME(gdi, "Magic %04x not implemented\n",
                    ptr->wMagic );
           break;
     }
@@ -527,8 +527,8 @@
 	  result = OBJ_METADC;
 	  break;
 
-	  default:
-	  fprintf( stderr, "GetObjectType: magic %04x not implemented\n",
+      default:
+	  FIXME(gdi, "Magic %04x not implemented\n",
 			   ptr->wMagic );
 	  break;
     }
@@ -561,7 +561,7 @@
     case OBJ_BITMAP:	return dc->w.hBitmap;
     default:
     	/* the SDK only mentions those above */
-    	fprintf(stderr,"GetCurrentObject(%08x,%d), unknown type.\n",hdc,type);
+    	WARN(gdi,"(%08x,%d): unknown type.\n",hdc,type);
 	return 0;
     }
 }
@@ -699,7 +699,7 @@
         break;
 
     default:
-        fprintf( stderr, "EnumObjects16: invalid type %d\n", nObjType );
+        WARN(gdi, "(%d): Invalid type\n", nObjType );
         break;
     }
     return retval;
@@ -775,7 +775,7 @@
 
     default:
         /* FIXME: implement Win32 types */
-        fprintf( stderr, "EnumObjects32: invalid type %d\n", nObjType );
+        WARN( gdi, "(%d): Invalid type\n", nObjType );
         break;
     }
     return retval;
@@ -867,7 +867,7 @@
     case 0x0103:  /* LocalHeap */
         return GDI_HeapSel;
     default:
-        fprintf(stderr, "GdiSeeGdiDo: wReqType %04x (unknown)", wReqType);
+        WARN(gdi, "(wReqType=%04x): Unknown\n", wReqType);
         return (DWORD)-1;
     }
 }
diff --git a/objects/metafile.c b/objects/metafile.c
index ea424bc..6e3d0b8 100644
--- a/objects/metafile.c
+++ b/objects/metafile.c
@@ -186,7 +186,7 @@
     METAHEADER *mh2;
     HFILE32 hFile;
     
-    TRACE(metafile,"%s\n", lpFilename);
+    TRACE(metafile,"(%08x,%s)\n", hSrcMetaFile, lpFilename);
     
     mh = (METAHEADER *)GlobalLock16(hSrcMetaFile);
     
@@ -213,7 +213,8 @@
 	memcpy(mh2,mh, mh->mtSize * 2);
 	GlobalUnlock16(handle);
         }
-    
+
+    GlobalUnlock16(hSrcMetaFile);
     return handle;
 }
 
@@ -295,6 +296,8 @@
     
     TRACE(metafile,"(%04x %04x)\n",hdc,hmf);
     if (!mh) return FALSE;
+
+    /* save the current pen, brush and font */
     if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return 0;
     hPen = dc->w.hPen;
     hBrush = dc->w.hBrush;
@@ -311,10 +314,11 @@
     while (offset < mh->mtSize * 2)
     {
         mr = (METARECORD *)((char *)mh + offset);
-	TRACE(metafile,"offset = %04x size = %08lx\n",
-			 offset, mr->rdSize);
+	TRACE(metafile,"offset=%04x,size=%08lx\n",
+            offset, mr->rdSize);
 	if (!mr->rdSize) {
-		fprintf(stderr,"METAFILE entry got size 0 at offset %d, total mf length is %ld\n",offset,mh->mtSize*2);
+            TRACE(metafile,"Entry got size 0 at offset %d, total mf length is %ld\n",
+                offset,mh->mtSize*2);
 		break; /* would loop endlessly otherwise */
 	}
 	offset += mr->rdSize * 2;
@@ -423,6 +427,68 @@
     return result;
 }
 
+BOOL32 WINAPI EnumMetaFile32( 
+			     HDC32 hdc, 
+			     HMETAFILE32 hmf,
+			     MFENUMPROC32 lpEnumFunc, 
+			     LPARAM lpData 
+) {
+    METAHEADER *mh = (METAHEADER *)GlobalLock16(hmf);
+    METARECORD *mr;
+    HANDLETABLE32 *ht;
+    BOOL32 result = TRUE;
+    int i, offset = 0;
+    DC *dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
+    HPEN32 hPen;
+    HBRUSH32 hBrush;
+    HFONT32 hFont;
+
+    TRACE(metafile,"(%08x,%08x,%p,%p)\n",
+		     hdc, hmf, lpEnumFunc, lpData);
+    if (!mh) return 0;
+
+    /* save the current pen, brush and font */
+    if (!dc) return 0;
+    hPen = dc->w.hPen;
+    hBrush = dc->w.hBrush;
+    hFont = dc->w.hFont;
+    GDI_HEAP_UNLOCK(hdc);
+
+
+    ht = (HANDLETABLE32 *) GlobalAlloc32(GPTR, 
+			    sizeof(HANDLETABLE32) * mh->mtNoObjects);
+    
+    /* loop through metafile records */
+    offset = mh->mtHeaderSize * 2;
+    
+    while (offset < (mh->mtSize * 2))
+    {
+	mr = (METARECORD *)((char *)mh + offset);
+        if (!lpEnumFunc( hdc, ht, mr, mh->mtNoObjects, (LONG)lpData ))
+	{
+	    result = FALSE;
+	    break;
+	}
+	
+	offset += (mr->rdSize * 2);
+    }
+
+    /* restore pen, brush and font */
+    SelectObject32(hdc, hBrush);
+    SelectObject32(hdc, hPen);
+    SelectObject32(hdc, hFont);
+
+    /* free objects in handle table */
+    for(i = 0; i < mh->mtNoObjects; i++)
+      if(*(ht->objectHandle + i) != 0)
+        DeleteObject32(*(ht->objectHandle + i));
+
+    /* free handle table */
+    GlobalFree32(ht);
+    GlobalUnlock16(hmf);
+    return result;
+}
+
 static BOOL32 MF_Meta_CreateRegion( METARECORD *mr, HRGN32 hrgn );
 
 /******************************************************************
@@ -893,7 +959,16 @@
      UINT32 handles  
     )
 {
-  PlayMetaFileRecord16(hdc, handletable, metarecord, handles);
+  HANDLETABLE16 * ht = (void *)GlobalAlloc32(GPTR, 
+                               handles*sizeof(HANDLETABLE16));
+  int i = 0;
+  TRACE(metafile, "(%08x,%p,%p,%d)\n", hdc, handletable, metarecord, handles); 
+  for (i=0; i<handles; i++)  
+    ht->objectHandle[i] =  handletable->objectHandle[i];
+  PlayMetaFileRecord16(hdc, ht, metarecord, handles);
+  for (i=0; i<handles; i++) 
+    handletable->objectHandle[i] = ht->objectHandle[i];
+  GlobalFree32(ht);
   return TRUE;
 }
 
@@ -961,11 +1036,39 @@
 {
   HMETAFILE32 hmf = GlobalAlloc16(GHND, size);
   BYTE *p = GlobalLock16(hmf) ;
+  TRACE(metafile, "(%d,%p) returning %08x\n", size, lpData, hmf);
+  if (!hmf || !p) return 0;
   memcpy(p, lpData, size);
   GlobalUnlock16(hmf);
   return hmf;
 }
 
+/*****************************************************************
+ *  GetMetaFileBitsEx     (GDI32.198)  Get raw metafile data
+ * 
+ *  Copies the data from metafile _hmf_ into the buffer _buf_.
+ *  If _buf_ is zero, returns size of buffer required. Otherwise,
+ *  returns number of bytes copied.
+ */
+UINT32 WINAPI GetMetaFileBitsEx( 
+     HMETAFILE32 hmf, /* metafile */
+     UINT32 nSize, /* size of buf */ 
+     LPVOID buf   /* buffer to receive raw metafile data */  
+) {
+  METAHEADER *h = GlobalLock16(hmf);
+  TRACE(metafile, "(%08x,%d,%p)\n", hmf, nSize, buf);
+  if (!h) return 0;  /* FIXME: error code */
+  if (!buf) {
+    GlobalUnlock16(hmf);
+    TRACE(metafile,"returning size %d\n", h->mtSize);
+    return h->mtSize;
+  }
+  memmove(buf, h, MIN(nSize, h->mtSize));
+  GlobalUnlock16(hmf);
+  return MIN(nSize, h->mtSize);
+}
+
+
 /******************************************************************
  *         MF_Meta_CreateRegion
  *
@@ -1008,20 +1111,20 @@
     for(band  = 0, start = &(mr->rdParam[11]); band < mr->rdParam[5];
  					        band++, start = end + 1) {
         if(*start / 2 != (*start + 1) / 2) {
- 	    fprintf(stderr, "META_CREATEREGION: delimiter not even.\n");
+ 	    WARN(metafile, "Delimiter not even.\n");
 	    DeleteObject32( hrgn2 );
  	    return FALSE;
         }
 
 	end = start + *start + 3;
 	if(end > (WORD *)mr + mr->rdSize) {
-	    WARN(metafile, "META_CREATEREGION: end points outside record.\n");
+	    WARN(metafile, "End points outside record.\n");
 	    DeleteObject32( hrgn2 );
 	    return FALSE;
         }
 
 	if(*start != *end) {
-	    WARN(metafile, "META_CREATEREGION: mismatched delimiters.\n");
+	    WARN(metafile, "Mismatched delimiters.\n");
 	    DeleteObject32( hrgn2 );
 	    return FALSE;
 	}
@@ -1384,7 +1487,7 @@
     METARECORD *mr;
     
     if((!flags && rect) || (flags && !rect))
-	fprintf(stderr, "MF_ExtTextOut: Inconsistent flags and rect\n");
+	WARN(metafile, "Inconsistent flags and rect\n");
     len = sizeof(METARECORD) + (((count + 1) >> 1) * 2) + 2 * sizeof(short)
 	    + sizeof(UINT16);
     if(rect)
diff --git a/objects/oembitmap.c b/objects/oembitmap.c
index f7b83ce..9f2cd4b 100644
--- a/objects/oembitmap.c
+++ b/objects/oembitmap.c
@@ -410,7 +410,7 @@
     if (!CALL_LARGE_STACK( OBM_CreateBitmaps, &descr ))
     {
         LeaveCriticalSection( &X11DRV_CritSection );
-        fprintf( stderr, "Error creating OEM bitmap %d\n", OBM_FIRST+id );
+        WARN(bitmap, "Error creating OEM bitmap %d\n", OBM_FIRST+id );
         return 0;
     }
     LeaveCriticalSection( &X11DRV_CritSection );
@@ -462,7 +462,7 @@
     if (!CALL_LARGE_STACK( OBM_CreateBitmaps, &descr ))
     {
         LeaveCriticalSection( &X11DRV_CritSection );
-        fprintf( stderr, "Error creating OEM cursor/icon %d\n", id );
+        WARN(cursor, "Error creating OEM cursor/icon %d\n", id );
         return 0;
     }
     LeaveCriticalSection( &X11DRV_CritSection );
diff --git a/objects/pen.c b/objects/pen.c
index 79ca82c..e9ee9a8 100644
--- a/objects/pen.c
+++ b/objects/pen.c
@@ -85,10 +85,10 @@
     LOGPEN32 logpen;
 
     if ((style & PS_STYLE_MASK) == PS_USERSTYLE)
-	fprintf(stderr, "ExtCreatePen: PS_USERSTYLE not handled\n");
+	FIXME(gdi, "PS_USERSTYLE not handled\n");
     if ((style & PS_TYPE_MASK) == PS_GEOMETRIC)
 	if (brush->lbHatch)
-	    fprintf(stderr, "ExtCreatePen: Hatches not implemented\n");
+	    FIXME(gdi, "Hatches not implemented\n");
 
     logpen.lopnStyle = style & ~PS_TYPE_MASK;
     logpen.lopnWidth.x = (style & PS_GEOMETRIC) ? width : 1;
diff --git a/objects/region.c b/objects/region.c
index 8572d56..9f771ed 100644
--- a/objects/region.c
+++ b/objects/region.c
@@ -536,15 +536,15 @@
 		   lpXform, dwCount, rgndata, hrgn);
     if(!hrgn)
     {
-        fprintf(stderr, "ExtCreateRegion can't create a region!\n");
+        WARN(region, "Can't create a region!\n");
 	return 0;
     }
     if(lpXform)
-        fprintf(stderr, "ExtCreateRegion: Xform not implemented - ignoring\n");
+        WARN(region, "Xform not implemented - ignoring\n");
     
     if(rgndata->rdh.iType != RDH_RECTANGLES)
     {
-        fprintf(stderr, "ExtCreateRegion: type not RDH_RECTANGLES\n");
+        WARN(region, "Type not RDH_RECTANGLES\n");
 	GDI_HEAP_UNLOCK( hrgn );
 	DeleteObject32( hrgn );
 	return 0;
@@ -1923,7 +1923,7 @@
             tmpSLLBlock = HeapAlloc( SystemHeap, 0, sizeof(ScanLineListBlock));
 	    if(!tmpSLLBlock)
 	    {
-	        fprintf(stderr, "REGION_InsertEdgeInET(): Can't alloc SLLB\n");
+	        WARN(region, "Can't alloc SLLB\n");
 		return;
 	    }
             (*SLLBlock)->next = tmpSLLBlock;
@@ -2371,8 +2371,7 @@
                 if (iPts == NUMPTSTOBUFFER) {
                     tmpPtBlock = HeapAlloc( SystemHeap, 0, sizeof(POINTBLOCK));
 		    if(!tmpPtBlock) {
-		        fprintf(stderr, 
-				"CreatePolyPolygonRgn(): can't alloc tPB\n");
+		        WARN(region, "Can't alloc tPB\n");
 			return 0;
 		    }
                     curPtBlock->next = tmpPtBlock;
@@ -2423,8 +2422,7 @@
                         tmpPtBlock = HeapAlloc( SystemHeap, 0,
 					       sizeof(POINTBLOCK) );
 			if(!tmpPtBlock) {
-			    fprintf(stderr, 
-				"CreatePolyPolygonRgn(): can't alloc tPB\n");
+			    WARN(region, "Can't alloc tPB\n");
 			    return 0;
 			}
                         curPtBlock->next = tmpPtBlock;