Release 970215

Sat Feb 15 11:59:17 1997  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [*/*]
	Converted a lot of functions to Win32 types.
	Removed HWND type.

Fri Feb 14 15:09:19 1997  Onno Hovers <onno@stack.nl>

	* [memory/global.c]
	Implemented GMEM_MOVEABLE blocks for Win32.

Fri Feb 14 00:24:39 1997  Alex Korobka <alex@trantor.pharm.sunysb.edu>

	* [loader/task.c] [windows/queue.c]
	Do not read X events while in the intertask SendMessage().

	* [misc/lstr.c]
	Fixed CharPrev32A().

	* [windows/hook.c] [include/hook.h]
	Restored broken WH_CALLWNDPROC functionality for dialogs, etc...

	* [windows/win.c] [windows/defwnd.c] [windows/mdi.c]
	  [windows/event.c] [controls/edit.c] 
	Added WIN_ISWIN32 flag to windows created by Win32 calls. 
	Several new Win32 messages are sent when this flag is on.
	
	* [msdos/dosmem.c] [memory/global.c]
	Some changes in DOS memory allocation.

Fri Feb  7 21:46:03 1997  Andrew Taylor  <andrew@riscan.com>

	* [win32/security.c]
	Added SID manipulation functions.

	* [include/debug.h]
	Added debugging class "security".

Fri  Feb 7 20:46:33 1997  Robert Pouliot <krynos@clic.net>

	* [debugger/msc.c] [debugger/source.c] 
	  [documentation/wine_os2.txt] [loader/signal.c]
	Some more changes for OS/2. Doesn't work yet.

Fri  Feb 7 09:31:17 1997  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>

	* [scheduler/process.c]
	Added ExpandEnvironmentStrings*.

	* [misc/ntdll.c] [include/ntdll.h]
	Added some new functions.

	* [objects/cursoricon.c]
	CURSORICON_LoadHandler: check against some bizarre out of memory
	conditions.
	
	* [windows/mdi.c]
	Fixed DefFrameProc32*, added TranslateMDISysAccel32.

Wed Feb  5 01:31:05 1997  John Zero <john@globe.graphisoft.hu>

	* [resources/sysres_Hu.rc] [misc/ole2nls.c] [misc/main.c]
	  [programs/progman/Hu.rc] [programs/winhelp/Hu.rc]
	Added Hungarian language support.
diff --git a/objects/color.c b/objects/color.c
index 76a24cb..5d1abd9 100644
--- a/objects/color.c
+++ b/objects/color.c
@@ -135,7 +135,7 @@
     return cSpace.flags;
 }
 
-COLORREF COLOR_GetSystemPaletteEntry(BYTE i)
+COLORREF COLOR_GetSystemPaletteEntry(UINT32 i)
 {
  return *(COLORREF*)(COLOR_sysPal + i) & 0x00ffffff;
 }
@@ -567,7 +567,7 @@
         palPtr->palPalEntry[i].peBlue = __sysPalTemplate[i].peBlue;
         palPtr->palPalEntry[i].peFlags = 0;  
     }
-    hpalette = CreatePalette( palPtr );
+    hpalette = CreatePalette16( palPtr );
 
     palObj = (PALETTEOBJ*) GDI_GetObjPtr( hpalette, PALETTE_MAGIC );
 
diff --git a/objects/cursoricon.c b/objects/cursoricon.c
index 46a5405..62b4823 100644
--- a/objects/cursoricon.c
+++ b/objects/cursoricon.c
@@ -22,6 +22,7 @@
  * the bits directly :-(
  */
 
+#define NO_TRANSITION_TYPES  /* This file is Win32-clean */
 #include <string.h>
 #include <stdlib.h>
 #include "windows.h"
@@ -38,9 +39,9 @@
 
 extern UINT16 COLOR_GetSystemPaletteSize();
 
-Cursor CURSORICON_XCursor = None;  /* Current X cursor */
-static HCURSOR16 hActiveCursor = 0;  /* Active cursor */
-static int CURSOR_ShowCount = 0;   /* Cursor display count */
+Cursor CURSORICON_XCursor = None;    /* Current X cursor */
+static HCURSOR32 hActiveCursor = 0;  /* Active cursor */
+static INT32 CURSOR_ShowCount = 0;   /* Cursor display count */
 static RECT32 CURSOR_ClipRect;       /* Cursor clipping rect */
 
 /**********************************************************************
@@ -200,9 +201,10 @@
  * Load the icon/cursor directory for a given resource name and find the
  * best matching entry.
  */
-static BOOL CURSORICON_LoadDirEntry(HINSTANCE32 hInstance, SEGPTR name,
-                                    int width, int height, int colors,
-                                    BOOL fCursor, CURSORICONDIRENTRY *dirEntry)
+static BOOL32 CURSORICON_LoadDirEntry( HINSTANCE32 hInstance, SEGPTR name,
+                                       INT32 width, INT32 height,
+                                       INT32 colors, BOOL32 fCursor,
+                                       CURSORICONDIRENTRY *dirEntry )
 {
     HRSRC16 hRsrc;
     HGLOBAL16 hMem;
@@ -234,7 +236,7 @@
  * Create a cursor or icon from a resource.
  */
 HGLOBAL16 CURSORICON_LoadHandler( HGLOBAL16 handle, HINSTANCE16 hInstance,
-                                  BOOL fCursor )
+                                  BOOL32 fCursor )
 {
     HBITMAP32 hAndBits, hXorBits;
     HDC32 hdc;
@@ -294,6 +296,11 @@
 
     hXorBits = CreateDIBitmap32( hdc, &pInfo->bmiHeader, CBM_INIT,
                                  (char*)bmi + size, pInfo, DIB_RGB_COLORS );
+    if (!hXorBits) {
+        free( pInfo );
+    	ReleaseDC32( 0, hdc );
+    	return 0;
+    }
 
     /* Fix the bitmap header to load the monochrome mask */
 
@@ -325,6 +332,11 @@
     hAndBits = CreateDIBitmap32( hdc, &pInfo->bmiHeader, CBM_INIT,
                                  bits, pInfo, DIB_RGB_COLORS );
     ReleaseDC32( 0, hdc );
+    if (!hAndBits) {
+        DeleteObject32( hXorBits );
+        free( pInfo );
+    	return 0;
+    }
 
     /* Now create the CURSORICONINFO structure */
 
@@ -369,8 +381,8 @@
  * Load a cursor or icon.
  */
 static HGLOBAL16 CURSORICON_Load( HINSTANCE16 hInstance, SEGPTR name,
-                                  int width, int height, int colors,
-                                  BOOL fCursor )
+                                  INT32 width, INT32 height, INT32 colors,
+                                  BOOL32 fCursor )
 {
     HGLOBAL16 handle, hRet;
     HRSRC16 hRsrc;
@@ -513,8 +525,9 @@
  return hRet;
 }
 
+
 /***********************************************************************
- *           LoadCursor    (USER.173)
+ *           LoadCursor16    (USER.173)
  */
 HCURSOR16 LoadCursor16( HINSTANCE16 hInstance, SEGPTR name )
 {
@@ -531,9 +544,9 @@
 
 
 /***********************************************************************
- *           LoadIcon    (USER.174)
+ *           LoadIcon16    (USER.174)
  */
-HICON16 LoadIcon16(HINSTANCE16 hInstance,SEGPTR name)
+HICON16 LoadIcon16( HINSTANCE16 hInstance, SEGPTR name )
 {
     if (HIWORD(name))
         dprintf_icon( stddeb, "LoadIcon: %04x '%s'\n",
@@ -549,11 +562,11 @@
 
 
 /***********************************************************************
- *           CreateCursor    (USER.406)
+ *           CreateCursor16    (USER.406)
  */
-HCURSOR16 CreateCursor( HINSTANCE16 hInstance, INT xHotSpot, INT yHotSpot,
-                        INT nWidth, INT nHeight,
-                        const BYTE *lpANDbits, const BYTE *lpXORbits )
+HCURSOR16 CreateCursor16(HINSTANCE16 hInstance, INT16 xHotSpot, INT16 yHotSpot,
+                         INT16 nWidth, INT16 nHeight,
+                         LPCVOID lpANDbits, LPCVOID lpXORbits )
 {
     CURSORICONINFO info = { { xHotSpot, yHotSpot }, nWidth, nHeight, 0, 1, 1 };
 
@@ -564,12 +577,43 @@
 
 
 /***********************************************************************
- *           CreateIcon    (USER.407)
+ *           CreateCursor32    (USER32.66)
  */
-HICON16 CreateIcon( HINSTANCE16 hInstance, INT nWidth, INT nHeight, BYTE bPlanes,
-                  BYTE bBitsPixel, const BYTE* lpANDbits, const BYTE* lpXORbits)
+HCURSOR32 CreateCursor32(HINSTANCE32 hInstance, INT32 xHotSpot, INT32 yHotSpot,
+                         INT32 nWidth, INT32 nHeight,
+                         LPCVOID lpANDbits, LPCVOID lpXORbits )
 {
-    CURSORICONINFO info = { { 0, 0 }, nWidth, nHeight, 0, bPlanes, bBitsPixel };
+    CURSORICONINFO info = { { xHotSpot, yHotSpot }, nWidth, nHeight, 0, 1, 1 };
+
+    dprintf_cursor( stddeb, "CreateCursor: %dx%d spot=%d,%d xor=%p and=%p\n",
+                    nWidth, nHeight, xHotSpot, yHotSpot, lpXORbits, lpANDbits);
+    return CreateCursorIconIndirect( hInstance, &info, lpANDbits, lpXORbits );
+}
+
+
+/***********************************************************************
+ *           CreateIcon16    (USER.407)
+ */
+HICON16 CreateIcon16( HINSTANCE16 hInstance, INT16 nWidth, INT16 nHeight,
+                      BYTE bPlanes, BYTE bBitsPixel,
+                      LPCVOID lpANDbits, LPCVOID lpXORbits )
+{
+    CURSORICONINFO info = { { 0, 0 }, nWidth, nHeight, 0, bPlanes, bBitsPixel};
+
+    dprintf_icon( stddeb, "CreateIcon: %dx%dx%d, xor=%p, and=%p\n",
+                  nWidth, nHeight, bPlanes * bBitsPixel, lpXORbits, lpANDbits);
+    return CreateCursorIconIndirect( hInstance, &info, lpANDbits, lpXORbits );
+}
+
+
+/***********************************************************************
+ *           CreateIcon32    (USER32.74)
+ */
+HICON32 CreateIcon32( HINSTANCE32 hInstance, INT32 nWidth, INT32 nHeight,
+                      BYTE bPlanes, BYTE bBitsPixel,
+                      LPCVOID lpANDbits, LPCVOID lpXORbits )
+{
+    CURSORICONINFO info = { { 0, 0 }, nWidth, nHeight, 0, bPlanes, bBitsPixel};
 
     dprintf_icon( stddeb, "CreateIcon: %dx%dx%d, xor=%p, and=%p\n",
                   nWidth, nHeight, bPlanes * bBitsPixel, lpXORbits, lpANDbits);
@@ -580,10 +624,8 @@
 /***********************************************************************
  *           CreateCursorIconIndirect    (USER.408)
  */
-HGLOBAL16 CreateCursorIconIndirect( HINSTANCE16 hInstance,
-                                    CURSORICONINFO *info,
-                                    const BYTE *lpANDbits,
-                                    const BYTE *lpXORbits )
+HGLOBAL16 CreateCursorIconIndirect(HINSTANCE16 hInstance, CURSORICONINFO *info,
+                                   LPCVOID lpANDbits, LPCVOID lpXORbits )
 {
     HGLOBAL16 handle;
     char *ptr;
@@ -637,9 +679,18 @@
 
 
 /***********************************************************************
- *           DestroyIcon    (USER.457)
+ *           DestroyIcon16    (USER.457)
  */
-BOOL DestroyIcon( HICON16 hIcon )
+BOOL16 DestroyIcon16( HICON16 hIcon )
+{
+    return DestroyIcon32( hIcon );
+}
+
+
+/***********************************************************************
+ *           DestroyIcon32    (USER32.132)
+ */
+BOOL32 DestroyIcon32( HICON32 hIcon )
 {
     dprintf_icon( stddeb, "DestroyIcon: %04x\n", hIcon );
     /* FIXME: should check for OEM icon here */
@@ -648,9 +699,18 @@
 
 
 /***********************************************************************
- *           DestroyCursor    (USER.458)
+ *           DestroyCursor16    (USER.458)
  */
-BOOL DestroyCursor( HCURSOR16 hCursor )
+BOOL16 DestroyCursor16( HCURSOR16 hCursor )
+{
+    return DestroyCursor32( hCursor );
+}
+
+
+/***********************************************************************
+ *           DestroyCursor32    (USER32.131)
+ */
+BOOL32 DestroyCursor32( HCURSOR32 hCursor )
 {
     dprintf_cursor( stddeb, "DestroyCursor: %04x\n", hCursor );
     /* FIXME: should check for OEM cursor here */
@@ -659,13 +719,22 @@
 
 
 /***********************************************************************
- *           DrawIcon    (USER.84)
+ *           DrawIcon16    (USER.84)
  */
-BOOL DrawIcon( HDC16 hdc, INT x, INT y, HICON16 hIcon )
+BOOL16 DrawIcon16( HDC16 hdc, INT16 x, INT16 y, HICON16 hIcon )
+{
+    return DrawIcon32( hdc, x, y, hIcon );
+}
+
+
+/***********************************************************************
+ *           DrawIcon32    (USER32.158)
+ */
+BOOL32 DrawIcon32( HDC32 hdc, INT32 x, INT32 y, HICON32 hIcon )
 {
     CURSORICONINFO *ptr;
     HDC32 hMemDC;
-    HBITMAP16 hXorBits, hAndBits;
+    HBITMAP32 hXorBits, hAndBits;
     COLORREF oldFg, oldBg;
 
     if (!(ptr = (CURSORICONINFO *)GlobalLock16( hIcon ))) return FALSE;
@@ -719,7 +788,7 @@
  *
  * Change the X cursor. Helper function for SetCursor() and ShowCursor().
  */
-static BOOL CURSORICON_SetCursor( HCURSOR16 hCursor )
+static BOOL32 CURSORICON_SetCursor( HCURSOR16 hCursor )
 {
     Pixmap pixmapBits, pixmapMask, pixmapAll;
     XColor fg, bg;
@@ -842,7 +911,7 @@
     else
     {
         /* Set the same cursor for all top-level windows */
-        HWND hwnd = GetWindow32( GetDesktopWindow32(), GW_CHILD );
+        HWND32 hwnd = GetWindow32( GetDesktopWindow32(), GW_CHILD );
         while(hwnd)
         {
             Window win = WIN_GetXWindow( hwnd );
@@ -855,11 +924,20 @@
 
 
 /***********************************************************************
- *           SetCursor    (USER.69)
+ *           SetCursor16    (USER.69)
  */
-HCURSOR16 SetCursor( HCURSOR16 hCursor )
+HCURSOR16 SetCursor16( HCURSOR16 hCursor )
 {
-    HCURSOR16 hOldCursor;
+    return (HCURSOR16)SetCursor32( hCursor );
+}
+
+
+/***********************************************************************
+ *           SetCursor32    (USER32.471)
+ */
+HCURSOR32 SetCursor32( HCURSOR32 hCursor )
+{
+    HCURSOR32 hOldCursor;
 
     if (hCursor == hActiveCursor) return hActiveCursor;  /* No change */
     dprintf_cursor( stddeb, "SetCursor: %04x\n", hCursor );
@@ -872,19 +950,38 @@
 
 
 /***********************************************************************
- *           SetCursorPos    (USER.70)
+ *           SetCursorPos16    (USER.70)
  */
-void SetCursorPos( short x, short y )
+void SetCursorPos16( INT16 x, INT16 y )
 {
-    dprintf_cursor( stddeb, "SetCursorPos: x=%d y=%d\n", x, y );
-    XWarpPointer( display, rootWindow, rootWindow, 0, 0, 0, 0, x, y );
+    SetCursorPos32( x, y );
 }
 
 
 /***********************************************************************
- *           ShowCursor    (USER.71)
+ *           SetCursorPos32    (USER32.473)
  */
-int ShowCursor( BOOL bShow )
+BOOL32 SetCursorPos32( INT32 x, INT32 y )
+{
+    dprintf_cursor( stddeb, "SetCursorPos: x=%d y=%d\n", x, y );
+    XWarpPointer( display, rootWindow, rootWindow, 0, 0, 0, 0, x, y );
+    return TRUE;
+}
+
+
+/***********************************************************************
+ *           ShowCursor16    (USER.71)
+ */
+INT16 ShowCursor16( BOOL16 bShow )
+{
+    return ShowCursor32( bShow );
+}
+
+
+/***********************************************************************
+ *           ShowCursor32    (USER32.529)
+ */
+INT32 ShowCursor32( BOOL32 bShow )
 {
     dprintf_cursor( stddeb, "ShowCursor: %d, count=%d\n",
                     bShow, CURSOR_ShowCount );
@@ -904,9 +1001,18 @@
 
 
 /***********************************************************************
- *           GetCursor    (USER.247)
+ *           GetCursor16    (USER.247)
  */
-HCURSOR16 GetCursor(void)
+HCURSOR16 GetCursor16(void)
+{
+    return hActiveCursor;
+}
+
+
+/***********************************************************************
+ *           GetCursor32    (USER32.226)
+ */
+HCURSOR32 GetCursor32(void)
 {
     return hActiveCursor;
 }
@@ -1027,7 +1133,7 @@
 /**********************************************************************
  *	    LoadIconHandler    (USER.456)
  */
-HICON16 LoadIconHandler( HGLOBAL16 hResource, BOOL bNew )
+HICON16 LoadIconHandler( HGLOBAL16 hResource, BOOL16 bNew )
 {
     dprintf_cursor(stddeb,"LoadIconHandler: hRes=%04x\n",hResource);
 
diff --git a/objects/dc.c b/objects/dc.c
index 02bc5ce..889518f 100644
--- a/objects/dc.c
+++ b/objects/dc.c
@@ -791,14 +791,23 @@
 
 
 /***********************************************************************
- *           GetDeviceCaps    (GDI.80)
+ *           GetDeviceCaps16    (GDI.80)
  */
-int GetDeviceCaps( HDC16 hdc, WORD cap )
+INT16 GetDeviceCaps16( HDC16 hdc, INT16 cap )
+{
+    return GetDeviceCaps32( hdc, cap );
+}
+
+
+/***********************************************************************
+ *           GetDeviceCaps32    (GDI32.171)
+ */
+INT32 GetDeviceCaps32( HDC32 hdc, INT32 cap )
 {
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc) return 0;
 
-    if (cap > sizeof(DeviceCaps)-sizeof(WORD)) return 0;
+    if ((cap < 0) || (cap > sizeof(DeviceCaps)-sizeof(WORD))) return 0;
     
     dprintf_dc(stddeb, "GetDeviceCaps(%04x,%d): returning %d\n",
 	    hdc, cap, *(WORD *)(((char *)dc->w.devCaps) + cap) );
diff --git a/objects/font.c b/objects/font.c
index b4a3a32..edf0266 100644
--- a/objects/font.c
+++ b/objects/font.c
@@ -754,9 +754,18 @@
 
 
 /***********************************************************************
- *           SetMapperFlags    (GDI.349)
+ *           SetMapperFlags16    (GDI.349)
  */
-DWORD SetMapperFlags(HDC16 hDC, DWORD dwFlag)
+DWORD SetMapperFlags16( HDC16 hDC, DWORD dwFlag )
+{
+    return SetMapperFlags32( hDC, dwFlag );
+}
+
+
+/***********************************************************************
+ *           SetMapperFlags32    (GDI32.322)
+ */
+DWORD SetMapperFlags32( HDC32 hDC, DWORD dwFlag )
 {
     dprintf_font(stdnimp,"SetmapperFlags(%04x, %08lX) // Empty Stub !\n", 
 		 hDC, dwFlag); 
diff --git a/objects/gdiobj.c b/objects/gdiobj.c
index 0359343..d8eccaa 100644
--- a/objects/gdiobj.c
+++ b/objects/gdiobj.c
@@ -7,10 +7,10 @@
 #define NO_TRANSITION_TYPES  /* This file is Win32-clean */
 #include <stdlib.h>
 #include <stdio.h>
-#include "gdi.h"
 #include "color.h"
 #include "bitmap.h"
 #include "brush.h"
+#include "dc.h"
 #include "font.h"
 #include "heap.h"
 #include "palette.h"
diff --git a/objects/metafile.c b/objects/metafile.c
index 0174c92..d5dcf12 100644
--- a/objects/metafile.c
+++ b/objects/metafile.c
@@ -55,10 +55,18 @@
 
 
 /******************************************************************
- *         GetMetafile         GDI.124 By Kenny MacDonald 30 Nov 94
+ *         GetMetafile16   (GDI.124)
  */
+HMETAFILE16 GetMetaFile16( LPCSTR lpFilename )
+{
+    return GetMetaFile32A( lpFilename );
+}
 
-HMETAFILE16 GetMetaFile(LPSTR lpFilename)
+
+/******************************************************************
+ *         GetMetafile32A   (GDI32.197)
+ */
+HMETAFILE32 GetMetaFile32A( LPCSTR lpFilename )
 {
   HMETAFILE16 hmf;
   METAHEADER *mh;
@@ -73,17 +81,21 @@
   hmf = GlobalAlloc16(GMEM_MOVEABLE, MFHEADERSIZE);
   mh = (METAHEADER *)GlobalLock16(hmf);
   
-  if (!mh) {
+  if (!mh)
+  {
     GlobalFree16(hmf);
     return 0;
   }
   
-  if ((hFile = _lopen32(lpFilename, OF_READ)) == HFILE_ERROR32) {
+  if ((hFile = _lopen32(lpFilename, OF_READ)) == HFILE_ERROR32)
+  {
     GlobalFree16(hmf);
     return 0;
   }
   
-  if (_lread32(hFile, (char *)mh, MFHEADERSIZE) == HFILE_ERROR32) {
+  if (_lread32(hFile, (char *)mh, MFHEADERSIZE) == HFILE_ERROR32)
+  {
+    _lclose32( hFile );
     GlobalFree16(hmf);
     return 0;
   }
@@ -93,20 +105,25 @@
   hmf = GlobalReAlloc16(hmf,size,GMEM_MOVEABLE);
   mh = (METAHEADER *)GlobalLock16(hmf);
   
-  if (!mh) {
+  if (!mh)
+  {
+    _lclose32( hFile );
     GlobalFree16(hmf);
     return 0;
   }
   
   if (_lread32(hFile, (char*)mh + mh->mtHeaderSize * 2, 
-	        size - mh->mtHeaderSize * 2) == HFILE_ERROR32) {
+	        size - mh->mtHeaderSize * 2) == HFILE_ERROR32)
+  {
+    _lclose32( hFile );
     GlobalFree16(hmf);
     return 0;
   }
   
   _lclose32(hFile);
 
-  if (mh->mtType != 1) {
+  if (mh->mtType != 1)
+  {
     GlobalFree16(hmf);
     return 0;
   }
@@ -118,10 +135,31 @@
 
 
 /******************************************************************
- *         CopyMetafile         GDI.151 Niels de Carpentier, April 1996
+ *         GetMetafile32W   (GDI32.199)
+ */
+HMETAFILE32 GetMetaFile32W( LPCWSTR lpFilename )
+{
+    LPSTR p = HEAP_strdupWtoA( GetProcessHeap(), 0, lpFilename );
+    HMETAFILE32 ret = GetMetaFile32A( p );
+    HeapFree( GetProcessHeap(), 0, p );
+    return ret;
+}
+
+
+/******************************************************************
+ *         CopyMetaFile16   (GDI.151)
  */
 
-HMETAFILE16 CopyMetaFile(HMETAFILE16 hSrcMetaFile, LPCSTR lpFilename)
+HMETAFILE16 CopyMetaFile16( HMETAFILE16 hSrcMetaFile, LPCSTR lpFilename )
+{
+    return CopyMetaFile32A( hSrcMetaFile, lpFilename );
+}
+
+
+/******************************************************************
+ *         CopyMetaFile32A   (GDI32.23)
+ */
+HMETAFILE32 CopyMetaFile32A( HMETAFILE32 hSrcMetaFile, LPCSTR lpFilename )
 {
     HMETAFILE16 handle = 0;
     METAHEADER *mh;
@@ -146,6 +184,7 @@
         _lclose32(hFile);
 	if (i == -1)
 	    return 0;
+        /* FIXME: return value */
         }
     else                     /* memory based metafile */
         {
@@ -158,12 +197,25 @@
     return handle;
 }
 
+
+/******************************************************************
+ *         CopyMetaFile32W   (GDI32.24)
+ */
+HMETAFILE32 CopyMetaFile32W( HMETAFILE32 hSrcMetaFile, LPCWSTR lpFilename )
+{
+    LPSTR p = HEAP_strdupWtoA( GetProcessHeap(), 0, lpFilename );
+    HMETAFILE32 ret = CopyMetaFile32A( hSrcMetaFile, p );
+    HeapFree( GetProcessHeap(), 0, p );
+    return ret;
+}
+
+
 /******************************************************************
  *         IsValidMetaFile   (GDI.410)
  *         (This is not exactly what windows does, see "Undoc Win")
  */
 
-BOOL IsValidMetaFile(HMETAFILE16 hmf)
+BOOL16 IsValidMetaFile(HMETAFILE16 hmf)
 {
     BOOL resu=FALSE;
     METAHEADER *mh = (METAHEADER *)GlobalLock16(hmf);
@@ -179,82 +231,19 @@
 }
 
 
-#if 0
 /******************************************************************
- *         CloseMetafile         GDI.126
+ *         PlayMetafile16   (GDI.123)
  */
-
-HMETAFILE16 CloseMetaFile(HDC16 hdc)
+BOOL16 PlayMetaFile16( HDC16 hdc, HMETAFILE16 hmf )
 {
-    DC *dc;
-    METAHEADER *mh;
-    HMETAFILE16 hmf;
-    HFILE hFile;
-    METAFILEDRV_PDEVICE *physDev;
-    
-    dprintf_metafile(stddeb,"CloseMetaFile\n");
-
-    if (!(dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC))) return 0;
-
-    physDev = (METAFILEDRV_PDEVICE *)dc->physDev;
-    mh = (METAHEADER *)GlobalLock16( physDev->hMetafile );
-
-    /* Construct the end of metafile record - this is documented
-     * in SDK Knowledgebase Q99334.
-     */
-
-    if (!MF_MetaParam0(dc, META_EOF))
-    {
-        DeleteDC32( hdc );
-	return 0;
-    }	
-
-    if (mh->mtType == 1)        /* disk based metafile */
-    {
-        hFile = mh->mtNoParameters;
-	mh->mtNoParameters = 0;
-        if (_llseek(hFile, 0L, 0) == -1)
-        {
-            DeleteDC32( hdc );
-            return 0;
-        }
-        if (_lwrite32(hFile, (char *)mh, MFHEADERSIZE) == -1)
-        {
-            DeleteDC32( hdc );
-            return 0;
-        }
-        _lclose(hFile);
-    }
-
-    hmf = physDev->hMetafile;
-    GlobalUnlock16( hmf );
-    physDev->hMetafile = 0;  /* So it won't be deleted */
-    DeleteDC32( hdc );
-    return hmf;
+    return PlayMetaFile32( hdc, hmf );
 }
 
 
 /******************************************************************
- *         DeleteMetafile         GDI.127
+ *         PlayMetafile32   (GDI32.265)
  */
-
-BOOL DeleteMetaFile(HMETAFILE16 hmf)
-{
-    METAHEADER *mh = (METAHEADER *)GlobalLock16(hmf);
-
-    if (!mh)
-	return FALSE;
-
-    GlobalFree16(hmf);
-    return TRUE;
-}
-#endif
-
-/******************************************************************
- *         PlayMetafile         GDI.123
- */
-
-BOOL PlayMetaFile(HDC16 hdc, HMETAFILE16 hmf)
+BOOL32 PlayMetaFile32( HDC32 hdc, HMETAFILE32 hmf )
 {
     METAHEADER *mh = (METAHEADER *)GlobalLock16(hmf);
     METARECORD *mr;
@@ -592,7 +581,7 @@
     /* W. Magro: Some new metafile operations.  Not all debugged. */
     case META_CREATEPALETTE:
 	MF_AddHandle(ht, nHandles, 
-		     CreatePalette((LPLOGPALETTE)mr->rdParam));
+		     CreatePalette16((LPLOGPALETTE)mr->rdParam));
 	break;
 
     case META_SETTEXTALIGN:
@@ -600,15 +589,15 @@
 	break;
 
     case META_SELECTPALETTE:
-	SelectPalette(hdc, *(ht->objectHandle + *(mr->rdParam+1)),*(mr->rdParam));
+	SelectPalette16(hdc, *(ht->objectHandle + *(mr->rdParam+1)),*(mr->rdParam));
 	break;
 
     case META_SETMAPPERFLAGS:
-	SetMapperFlags(hdc, *(mr->rdParam));
+	SetMapperFlags16(hdc, *(mr->rdParam));
 	break;
 
     case META_REALIZEPALETTE:
-	RealizePalette(hdc);
+	RealizePalette16(hdc);
 	break;
 
     case META_ESCAPE:
@@ -735,7 +724,7 @@
 
 
 /******************************************************************
- *         GetMetaFileBits		by William Magro, 19 Sep 1995
+ *         GetMetaFileBits   (GDI.159)
  *
  * Trade in a meta file object handle for a handle to the meta file memory
  */
@@ -748,11 +737,10 @@
 }
 
 /******************************************************************
- *         SetMetaFileBits		by William Magro, 19 Sep 1995
+ *         SetMetaFileBits   (GDI.160)
  *
  * Trade in a meta file memory handle for a handle to a meta file object
  */
-
 HMETAFILE16 SetMetaFileBits( HGLOBAL16 hMem )
 {
     dprintf_metafile(stddeb,"SetMetaFileBits: hmf out: %04x\n", hMem);
diff --git a/objects/oembitmap.c b/objects/oembitmap.c
index 87929bc..224f658 100644
--- a/objects/oembitmap.c
+++ b/objects/oembitmap.c
@@ -284,7 +284,7 @@
         OBM_Colors[i].value = NULL;
         if (OBM_SymbolicColors[i].color & 0xff000000)  /* PALETTEINDEX */
             OBM_Colors[i].pixel = COLOR_ToPhysical( NULL,
-                              GetSysColor(OBM_SymbolicColors[i].color & 0xff));
+                            GetSysColor32(OBM_SymbolicColors[i].color & 0xff));
         else  /* RGB*/
             OBM_Colors[i].pixel = COLOR_ToPhysical( NULL,
                                                  OBM_SymbolicColors[i].color );
diff --git a/objects/palette.c b/objects/palette.c
index 53089a9..5c38d23 100644
--- a/objects/palette.c
+++ b/objects/palette.c
@@ -5,6 +5,8 @@
  * Copyright 1996 Alex Korobka
  *
  */
+
+#define NO_TRANSITION_TYPES  /* This file is Win32-clean */
 #include <stdlib.h>
 #include <string.h>
 #include <X11/Xlib.h>
@@ -17,11 +19,10 @@
 /* #define DEBUG_PALETTE */
 #include "debug.h"
 
-extern int              COLOR_LookupSystemPixel(COLORREF);      /* lookup pixel among static entries 
-                                                                 * of the system palette */
-extern COLORREF		COLOR_GetSystemPaletteEntry(BYTE);
+ /* lookup pixel among static entries of the system palette */
+extern int COLOR_LookupSystemPixel(COLORREF);
 
-static WORD SystemPaletteUse = SYSPAL_STATIC;	/* currently not considered */
+static UINT32 SystemPaletteUse = SYSPAL_STATIC;  /* currently not considered */
 
 static HPALETTE16 hPrimaryPalette = 0; /* used for WM_PALETTECHANGED */
 static HPALETTE16 hLastRealizedPalette = 0; /* UnrealizeObject() needs it */
@@ -39,17 +40,25 @@
 
 
 /***********************************************************************
- *           CreatePalette    (GDI.360)
+ *           CreatePalette16    (GDI.360)
  */
-HPALETTE16 CreatePalette( const LOGPALETTE* palette )
+HPALETTE16 CreatePalette16( const LOGPALETTE* palette )
+{
+    return CreatePalette32( palette );
+}
+
+
+/***********************************************************************
+ *           CreatePalette32    (GDI32.53)
+ */
+HPALETTE32 CreatePalette32( const LOGPALETTE* palette )
 {
     PALETTEOBJ * palettePtr;
-    HPALETTE16 hpalette;
+    HPALETTE32 hpalette;
     int size = sizeof(LOGPALETTE) + (palette->palNumEntries - 1) * sizeof(PALETTEENTRY);
 
-    dprintf_palette(stddeb,"CreatePalette: ");
-
-    dprintf_palette(stddeb,"%i entries, ", palette->palNumEntries);
+    dprintf_palette(stddeb,"CreatePalette: %i entries, ",
+                    palette->palNumEntries);
 
     hpalette = GDI_AllocObject( size + sizeof(int*) +sizeof(GDIOBJHDR) , PALETTE_MAGIC );
     if (!hpalette) return 0;
@@ -66,15 +75,26 @@
 
 
 /***********************************************************************
- *           GetPaletteEntries    (GDI.363)
+ *           GetPaletteEntries16    (GDI.363)
  */
-WORD GetPaletteEntries( HPALETTE16 hpalette, WORD start, WORD count,
-		        LPPALETTEENTRY entries )
+UINT16 GetPaletteEntries16( HPALETTE16 hpalette, UINT16 start, UINT16 count,
+                            LPPALETTEENTRY entries )
+{
+    return GetPaletteEntries32( hpalette, start, count, entries );
+}
+
+
+/***********************************************************************
+ *           GetPaletteEntries32    (GDI32.209)
+ */
+UINT32 GetPaletteEntries32( HPALETTE32 hpalette, UINT32 start, UINT32 count,
+                            LPPALETTEENTRY entries )
 {
     PALETTEOBJ * palPtr;
-    int numEntries;
+    INT32 numEntries;
 
-    dprintf_palette(stddeb,"GetPaletteEntries: hpal = %04x, %i entries\n", hpalette, count);
+    dprintf_palette( stddeb,"GetPaletteEntries: hpal = %04x, %i entries\n",
+                     hpalette, count );
         
     palPtr = (PALETTEOBJ *) GDI_GetObjPtr( hpalette, PALETTE_MAGIC );
     if (!palPtr) return 0;
@@ -85,21 +105,33 @@
     memcpy( entries, &palPtr->logpalette.palPalEntry[start],
 	    count * sizeof(PALETTEENTRY) );
     for( numEntries = 0; numEntries < count ; numEntries++ )
-         if( entries[numEntries].peFlags & 0xF0 ) entries[numEntries].peFlags = 0;
+         if (entries[numEntries].peFlags & 0xF0)
+             entries[numEntries].peFlags = 0;
     return count;
 }
 
 
 /***********************************************************************
- *           SetPaletteEntries    (GDI.364)
+ *           SetPaletteEntries16    (GDI.364)
  */
-WORD SetPaletteEntries( HPALETTE16 hpalette, WORD start, WORD count,
-		        LPPALETTEENTRY entries )
+UINT16 SetPaletteEntries16( HPALETTE16 hpalette, UINT16 start, UINT16 count,
+                            LPPALETTEENTRY entries )
+{
+    return SetPaletteEntries32( hpalette, start, count, entries );
+}
+
+
+/***********************************************************************
+ *           SetPaletteEntries32    (GDI32.326)
+ */
+UINT32 SetPaletteEntries32( HPALETTE32 hpalette, UINT32 start, UINT32 count,
+                            LPPALETTEENTRY entries )
 {
     PALETTEOBJ * palPtr;
-    int numEntries;
+    INT32 numEntries;
 
-    dprintf_palette(stddeb,"SetPaletteEntries: hpal = %04x, %i entries\n", hpalette, count);
+    dprintf_palette( stddeb,"SetPaletteEntries: hpal = %04x, %i entries\n",
+                     hpalette, count );
 
     palPtr = (PALETTEOBJ *) GDI_GetObjPtr( hpalette, PALETTE_MAGIC );
     if (!palPtr) return 0;
@@ -117,13 +149,23 @@
     return count;
 }
 
+
 /***********************************************************************
- *           ResizePalette          (GDI.368)
+ *           ResizePalette16   (GDI.368)
  */
-BOOL ResizePalette(HPALETTE16 hPal, UINT cEntries)
+BOOL16 ResizePalette16( HPALETTE16 hPal, UINT16 cEntries )
+{
+    return ResizePalette32( hPal, cEntries );
+}
+
+
+/***********************************************************************
+ *           ResizePalette32   (GDI32.289)
+ */
+BOOL32 ResizePalette32( HPALETTE32 hPal, UINT32 cEntries )
 {
     PALETTEOBJ * palPtr = (PALETTEOBJ *) GDI_GetObjPtr( hPal, PALETTE_MAGIC );
-    UINT	 cPrevEnt, prevVer;
+    UINT32	 cPrevEnt, prevVer;
     int		 prevsize, size = sizeof(LOGPALETTE) + (cEntries - 1) * sizeof(PALETTEENTRY);
     int*	 mapping = NULL;
 
@@ -156,44 +198,85 @@
     return TRUE;
 }
 
+
 /***********************************************************************
- *           AnimatePalette          (GDI.367)
+ *           AnimatePalette16   (GDI.367)
  */
-BOOL AnimatePalette(HPALETTE16 hPal, UINT StartIndex, UINT NumEntries,
-		    LPPALETTEENTRY PaletteColors)
+BOOL16 AnimatePalette16( HPALETTE16 hPal, UINT16 StartIndex, UINT16 NumEntries,
+                         LPPALETTEENTRY PaletteColors )
+{
+    return AnimatePalette32( hPal, StartIndex, NumEntries, PaletteColors );
+}
+
+
+/***********************************************************************
+ *           AnimatePalette32   (GDI32.6)
+ */
+BOOL32 AnimatePalette32( HPALETTE32 hPal, UINT32 StartIndex, UINT32 NumEntries,
+                         LPPALETTEENTRY PaletteColors )
 {
     fprintf(stdnimp,"AnimatePalette: empty stub! \n");
     return TRUE;
 }
 
-/***********************************************************************
- *           SetSystemPaletteUse    (GDI.373)
- */
-WORD SetSystemPaletteUse( HDC16 hdc, WORD use)
-{
-	 WORD old=SystemPaletteUse;
-	 fprintf(stdnimp,"SetSystemPaletteUse(%04x,%04x) // empty stub !!!\n", hdc, use);
-	 SystemPaletteUse=use;
-	 return old;
-}
 
 /***********************************************************************
- *           GetSystemPaletteUse    (GDI.374)
+ *           SetSystemPaletteUse16   (GDI.373)
  */
-WORD GetSystemPaletteUse( HDC16 hdc )
+UINT16 SetSystemPaletteUse16( HDC16 hdc, UINT16 use )
 {
-	fprintf(stdnimp,"GetSystemPaletteUse(%04x) // empty stub !!!\n", hdc);
-	return SystemPaletteUse;
+    return SetSystemPaletteUse32( hdc, use );
 }
 
 
 /***********************************************************************
- *           GetSystemPaletteEntries    (GDI.375)
+ *           SetSystemPaletteUse32   (GDI32.335)
  */
-WORD GetSystemPaletteEntries( HDC16 hdc, WORD start, WORD count,
-			      LPPALETTEENTRY entries )
+UINT32 SetSystemPaletteUse32( HDC32 hdc, UINT32 use )
 {
-    WORD i;
+    UINT32 old = SystemPaletteUse;
+    fprintf( stdnimp,"SetSystemPaletteUse(%04x,%04x) // empty stub !!!\n",
+             hdc, use );
+    SystemPaletteUse = use;
+    return old;
+}
+
+
+/***********************************************************************
+ *           GetSystemPaletteUse16   (GDI.374)
+ */
+UINT16 GetSystemPaletteUse16( HDC16 hdc )
+{
+    return SystemPaletteUse;
+}
+
+
+/***********************************************************************
+ *           GetSystemPaletteUse32   (GDI32.223)
+ */
+UINT32 GetSystemPaletteUse32( HDC32 hdc )
+{
+    return SystemPaletteUse;
+}
+
+
+/***********************************************************************
+ *           GetSystemPaletteEntries16   (GDI.375)
+ */
+UINT16 GetSystemPaletteEntries16( HDC16 hdc, UINT16 start, UINT16 count,
+                                  LPPALETTEENTRY entries )
+{
+    return GetSystemPaletteEntries32( hdc, start, count, entries );
+}
+
+
+/***********************************************************************
+ *           GetSystemPaletteEntries32   (GDI32.222)
+ */
+UINT32 GetSystemPaletteEntries32( HDC32 hdc, UINT32 start, UINT32 count,
+                                  LPPALETTEENTRY entries )
+{
+    UINT32 i;
     DC *dc;
 
     dprintf_palette(stddeb,"GetSystemPaletteEntries: hdc = %04x, cound = %i", hdc, count );
@@ -204,27 +287,36 @@
 	count = dc->w.devCaps->sizePalette - start;
     for (i = 0; i < count; i++)
     {
-	*(COLORREF*)(entries + i) = COLOR_GetSystemPaletteEntry((BYTE)(start + i));
+	*(COLORREF*)(entries + i) = COLOR_GetSystemPaletteEntry( start + i );
 
-        dprintf_palette(stddeb,"\tidx(%02x) -> RGB(%08lx)\n", (unsigned char)(start + i), 
-							    *(COLORREF*)(entries + i) );
+        dprintf_palette( stddeb,"\tidx(%02x) -> RGB(%08lx)\n",
+                         start + i, *(COLORREF*)(entries + i) );
     }
     return count;
 }
 
 
 /***********************************************************************
- *           GetNearestPaletteIndex    (GDI.370)
+ *           GetNearestPaletteIndex16   (GDI.370)
  */
-WORD GetNearestPaletteIndex( HPALETTE16 hpalette, COLORREF color )
+UINT16 GetNearestPaletteIndex16( HPALETTE16 hpalette, COLORREF color )
 {
-    PALETTEOBJ*	palObj = (PALETTEOBJ*) GDI_GetObjPtr( hpalette, PALETTE_MAGIC );
-    WORD	index  = 0;
+    return GetNearestPaletteIndex32( hpalette, color );
+}
+
+
+/***********************************************************************
+ *           GetNearestPaletteIndex32   (GDI32.203)
+ */
+UINT32 GetNearestPaletteIndex32( HPALETTE32 hpalette, COLORREF color )
+{
+    PALETTEOBJ*	palObj = (PALETTEOBJ*)GDI_GetObjPtr( hpalette, PALETTE_MAGIC );
+    UINT32 index  = 0;
 
     if( palObj )
         index = COLOR_PaletteLookupPixel( palObj->logpalette.palPalEntry, 
-				          palObj->logpalette.palNumEntries, NULL,
-					  color, FALSE );
+				          palObj->logpalette.palNumEntries,
+                                          NULL, color, FALSE );
 
     dprintf_palette(stddeb,"GetNearestPaletteIndex(%04x,%06lx): returning %d\n", 
                     hpalette, color, index );
@@ -233,9 +325,18 @@
 
 
 /***********************************************************************
- *           GetNearestColor    (GDI.154)
+ *           GetNearestColor16   (GDI.154)
  */
-COLORREF GetNearestColor( HDC16 hdc, COLORREF color )
+COLORREF GetNearestColor16( HDC16 hdc, COLORREF color )
+{
+    return GetNearestColor32( hdc, color );
+}
+
+
+/***********************************************************************
+ *           GetNearestColor32   (GDI32.202)
+ */
+COLORREF GetNearestColor32( HDC32 hdc, COLORREF color )
 {
     COLORREF 	 nearest = 0xFADECAFE;
     DC 		*dc;
@@ -318,12 +419,11 @@
 
 /***********************************************************************
  *           GDIRealizePalette    (GDI.362)
- *
  */
-UINT GDIRealizePalette( HDC16 hdc )
+UINT16 GDIRealizePalette( HDC16 hdc )
 {
     PALETTEOBJ* palPtr;
-    int		realized = 0;
+    int realized = 0;
     DC*		dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc) 
     {
@@ -347,14 +447,14 @@
     else dprintf_palette(stddeb, " skipping ");
     
     dprintf_palette(stdnimp, " realized %i colors\n", realized );
-    return (UINT)realized;
+    return (UINT16)realized;
 }
 
 
 /***********************************************************************
  *           RealizeDefaultPalette    (GDI.365)
  */
-WORD RealizeDefaultPalette( HDC16 hdc )
+UINT16 RealizeDefaultPalette( HDC16 hdc )
 {
     DC          *dc;
     PALETTEOBJ*  palPtr;
@@ -392,16 +492,28 @@
 /***********************************************************************
  *           IsDCCurrentPalette   (GDI.412)
  */
-BOOL IsDCCurrentPalette(HDC16 hDC)
+BOOL16 IsDCCurrentPalette(HDC16 hDC)
 {
     DC* dc = (DC *)GDI_GetObjPtr( hDC, DC_MAGIC );
     return (dc)?(dc->w.hPalette == hPrimaryPalette):FALSE;
 }
 
+
 /***********************************************************************
- *           SelectPalette    (USER.282)
+ *           SelectPalette16    (USER.282)
  */
-HPALETTE16 SelectPalette( HDC16 hDC, HPALETTE16 hPal, BOOL bForceBackground )
+HPALETTE16 SelectPalette16( HDC16 hDC, HPALETTE16 hPal,
+                            BOOL16 bForceBackground )
+{
+    return SelectPalette32( hDC, hPal, bForceBackground );
+}
+
+
+/***********************************************************************
+ *           SelectPalette32    (GDI32.300)
+ */
+HPALETTE32 SelectPalette32( HDC32 hDC, HPALETTE32 hPal,
+                            BOOL32 bForceBackground )
 {
     WORD	wBkgPalette = 1;
     PALETTEOBJ* lpt = (PALETTEOBJ*) GDI_GetObjPtr( hPal, PALETTE_MAGIC );
@@ -429,11 +541,20 @@
 
 
 /***********************************************************************
- *           RealizePalette    (USER.283) (GDI32.280)
+ *           RealizePalette16    (USER.283)
  */
-UINT16 RealizePalette( HDC32 hDC )
+UINT16 RealizePalette16( HDC16 hDC )
 {
-    UINT16 realized = GDIRealizePalette( hDC );
+    return RealizePalette32( hDC );
+}
+
+
+/***********************************************************************
+ *           RealizePalette32    (GDI32.280)
+ */
+UINT32 RealizePalette32( HDC32 hDC )
+{
+    UINT32 realized = GDIRealizePalette( hDC );
 
     /* do not send anything if no colors were changed */
 
@@ -462,7 +583,7 @@
      * but it would take forever given the speed of XGet/PutPixel.
      */
     if (hWnd && !(COLOR_GetSystemPaletteFlags() & COLOR_VIRTUAL) ) 
-	InvalidateRect16( hWnd, NULL, FALSE );
+	InvalidateRect32( hWnd, NULL, FALSE );
     return 0x666;
 }
 
diff --git a/objects/text.c b/objects/text.c
index d178a35..1fcf622 100644
--- a/objects/text.c
+++ b/objects/text.c
@@ -390,18 +390,19 @@
 
 
 /***********************************************************************
- *           GrayString   (USER.185)
+ *           GrayString16   (USER.185)
  */
-BOOL GrayString(HDC16 hdc, HBRUSH16 hbr, GRAYSTRINGPROC16 gsprc, LPARAM lParam, 
-		INT cch, INT x, INT y, INT cx, INT cy)
+BOOL16 GrayString16( HDC16 hdc, HBRUSH16 hbr, GRAYSTRINGPROC16 gsprc,
+                     LPARAM lParam, INT16 cch, INT16 x, INT16 y,
+                     INT16 cx, INT16 cy )
 {
-    BOOL ret;
+    BOOL16 ret;
     COLORREF current_color;
 
     if (!cch) cch = lstrlen16( (LPCSTR)PTR_SEG_TO_LIN(lParam) );
     if (gsprc) return gsprc( hdc, lParam, cch );
     current_color = GetTextColor32( hdc );
-    SetTextColor( hdc, GetSysColor(COLOR_GRAYTEXT) );
+    SetTextColor( hdc, GetSysColor32(COLOR_GRAYTEXT) );
     ret = TextOut16( hdc, x, y, (LPCSTR)PTR_SEG_TO_LIN(lParam), cch );
     SetTextColor( hdc, current_color );
     return ret;
@@ -409,24 +410,65 @@
 
 
 /***********************************************************************
+ *           GrayString32A   (USER32.314)
+ */
+BOOL32 GrayString32A( HDC32 hdc, HBRUSH32 hbr, GRAYSTRINGPROC32 gsprc,
+                      LPARAM lParam, INT32 cch, INT32 x, INT32 y,
+                      INT32 cx, INT32 cy )
+{
+    BOOL32 ret;
+    COLORREF current_color;
+
+    if (!cch) cch = lstrlen32A( (LPCSTR)lParam );
+    if (gsprc) return gsprc( hdc, lParam, cch );
+    current_color = GetTextColor32( hdc );
+    SetTextColor( hdc, GetSysColor32(COLOR_GRAYTEXT) );
+    ret = TextOut32A( hdc, x, y, (LPCSTR)lParam, cch );
+    SetTextColor( hdc, current_color );
+    return ret;
+}
+
+
+/***********************************************************************
+ *           GrayString32W   (USER32.315)
+ */
+BOOL32 GrayString32W( HDC32 hdc, HBRUSH32 hbr, GRAYSTRINGPROC32 gsprc,
+                      LPARAM lParam, INT32 cch, INT32 x, INT32 y,
+                      INT32 cx, INT32 cy )
+{
+    BOOL32 ret;
+    COLORREF current_color;
+
+    if (!cch) cch = lstrlen32W( (LPCWSTR)lParam );
+    if (gsprc) return gsprc( hdc, lParam, cch );
+    current_color = GetTextColor32( hdc );
+    SetTextColor( hdc, GetSysColor32(COLOR_GRAYTEXT) );
+    ret = TextOut32W( hdc, x, y, (LPCWSTR)lParam, cch );
+    SetTextColor( hdc, current_color );
+    return ret;
+}
+
+
+/***********************************************************************
  *           TEXT_TabbedTextOut
  *
  * Helper function for TabbedTextOut() and GetTabbedTextExtent().
  * Note: this doesn't work too well for text-alignment modes other
  *       than TA_LEFT|TA_TOP. But we want bug-for-bug compatibility :-)
  */
-LONG TEXT_TabbedTextOut( HDC16 hdc, int x, int y, LPSTR lpstr, int count, 
-                         int cTabStops, LPINT16 lpTabPos, int nTabOrg,
-                         BOOL fDisplayText)
+LONG TEXT_TabbedTextOut( HDC32 hdc, INT32 x, INT32 y, LPCSTR lpstr,
+                         INT32 count, INT32 cTabStops, const INT16 *lpTabPos16,
+                         const INT32 *lpTabPos32, INT32 nTabOrg,
+                         BOOL32 fDisplayText )
 {
-    WORD defWidth;
+    INT32 defWidth;
     DWORD extent = 0;
     int i, tabPos = x;
     int start = x;
 
     if (cTabStops == 1)
     {
-        defWidth = *lpTabPos;
+        defWidth = lpTabPos32 ? *lpTabPos32 : *lpTabPos16;
         cTabStops = 0;
     }
     else
@@ -441,24 +483,37 @@
         for (i = 0; i < count; i++)
             if (lpstr[i] == '\t') break;
         extent = GetTextExtent( hdc, lpstr, i );
-        while ((cTabStops > 0) && (nTabOrg + *lpTabPos <= x + LOWORD(extent)))
+        if (lpTabPos32)
         {
-            lpTabPos++;
-            cTabStops--;
+            while ((cTabStops > 0) &&
+                   (nTabOrg + *lpTabPos32 <= x + LOWORD(extent)))
+            {
+                lpTabPos32++;
+                cTabStops--;
+            }
+        }
+        else
+        {
+            while ((cTabStops > 0) &&
+                   (nTabOrg + *lpTabPos16 <= x + LOWORD(extent)))
+            {
+                lpTabPos16++;
+                cTabStops--;
+            }
         }
         if (i == count)
             tabPos = x + LOWORD(extent);
         else if (cTabStops > 0)
-            tabPos = nTabOrg + *lpTabPos;
+            tabPos = nTabOrg + (lpTabPos32 ? *lpTabPos32 : *lpTabPos16);
         else
             tabPos = nTabOrg + ((x + LOWORD(extent) - nTabOrg) / defWidth + 1) * defWidth;
         if (fDisplayText)
         {
-            RECT16 r;
-            SetRect16( &r, x, y, tabPos, y+HIWORD(extent) );
-            ExtTextOut16( hdc, x, y,
-                          GetBkMode32(hdc) == OPAQUE ? ETO_OPAQUE : 0,
-                          &r, lpstr, i, NULL );
+            RECT32 r;
+            SetRect32( &r, x, y, tabPos, y+HIWORD(extent) );
+            ExtTextOut32A( hdc, x, y,
+                           GetBkMode32(hdc) == OPAQUE ? ETO_OPAQUE : 0,
+                           &r, lpstr, i, NULL );
         }
         x = tabPos;
         count -= i+1;
@@ -469,26 +524,83 @@
 
 
 /***********************************************************************
- *           TabbedTextOut    (USER.196)
+ *           TabbedTextOut16    (USER.196)
  */
-LONG TabbedTextOut( HDC16 hdc, short x, short y, LPSTR lpstr, short count, 
-                    short cTabStops, LPINT16 lpTabPos, short nTabOrg )
+LONG TabbedTextOut16( HDC16 hdc, INT16 x, INT16 y, LPCSTR lpstr, INT16 count, 
+                      INT16 cTabStops, const INT16 *lpTabPos, INT16 nTabOrg )
 {
-    dprintf_text( stddeb, "TabbedTextOut: %04x %d,%d '%*.*s' %d\n",
-                  hdc, x, y, count, count, lpstr, count );
+    dprintf_text( stddeb, "TabbedTextOut16: %04x %d,%d '%.*s' %d\n",
+                  hdc, x, y, count, lpstr, count );
     return TEXT_TabbedTextOut( hdc, x, y, lpstr, count, cTabStops,
-                               lpTabPos, nTabOrg, TRUE );
+                               lpTabPos, NULL, nTabOrg, TRUE );
 }
 
 
 /***********************************************************************
- *           GetTabbedTextExtent    (USER.197)
+ *           TabbedTextOut32A    (USER32.541)
  */
-DWORD GetTabbedTextExtent( HDC16 hdc, LPSTR lpstr, int count, 
-                          int cTabStops, LPINT16 lpTabPos )
+LONG TabbedTextOut32A( HDC32 hdc, INT32 x, INT32 y, LPCSTR lpstr, INT32 count, 
+                       INT32 cTabStops, const INT32 *lpTabPos, INT32 nTabOrg )
 {
-    dprintf_text( stddeb, "GetTabbedTextExtent: %04x '%*.*s' %d\n",
-                  hdc, count, count, lpstr, count );
+    dprintf_text( stddeb, "TabbedTextOut32A: %04x %d,%d '%.*s' %d\n",
+                  hdc, x, y, count, lpstr, count );
+    return TEXT_TabbedTextOut( hdc, x, y, lpstr, count, cTabStops,
+                               NULL, lpTabPos, nTabOrg, TRUE );
+}
+
+
+/***********************************************************************
+ *           TabbedTextOut32W    (USER32.542)
+ */
+LONG TabbedTextOut32W( HDC32 hdc, INT32 x, INT32 y, LPCWSTR str, INT32 count, 
+                       INT32 cTabStops, const INT32 *lpTabPos, INT32 nTabOrg )
+{
+    LONG ret;
+    LPSTR p = HEAP_xalloc( GetProcessHeap(), 0, count + 1 );
+    lstrcpynWtoA( p, str, count + 1 );
+    ret = TabbedTextOut32A( hdc, x, y, p, count, cTabStops,
+                            lpTabPos, nTabOrg );
+    HeapFree( GetProcessHeap(), 0, p );
+    return ret;
+}
+
+
+/***********************************************************************
+ *           GetTabbedTextExtent16    (USER.197)
+ */
+DWORD GetTabbedTextExtent16( HDC16 hdc, LPCSTR lpstr, INT16 count, 
+                             INT16 cTabStops, const INT16 *lpTabPos )
+{
+    dprintf_text( stddeb, "GetTabbedTextExtent: %04x '%.*s' %d\n",
+                  hdc, count, lpstr, count );
     return TEXT_TabbedTextOut( hdc, 0, 0, lpstr, count, cTabStops,
-                               lpTabPos, 0, FALSE );
+                               lpTabPos, NULL, 0, FALSE );
+}
+
+
+/***********************************************************************
+ *           GetTabbedTextExtent32A    (USER32.292)
+ */
+DWORD GetTabbedTextExtent32A( HDC32 hdc, LPCSTR lpstr, INT32 count, 
+                              INT32 cTabStops, const INT32 *lpTabPos )
+{
+    dprintf_text( stddeb, "GetTabbedTextExtent: %04x '%.*s' %d\n",
+                  hdc, count, lpstr, count );
+    return TEXT_TabbedTextOut( hdc, 0, 0, lpstr, count, cTabStops,
+                               NULL, lpTabPos, 0, FALSE );
+}
+
+
+/***********************************************************************
+ *           GetTabbedTextExtent32W    (USER32.293)
+ */
+DWORD GetTabbedTextExtent32W( HDC32 hdc, LPCWSTR lpstr, INT32 count, 
+                              INT32 cTabStops, const INT32 *lpTabPos )
+{
+    LONG ret;
+    LPSTR p = HEAP_xalloc( GetProcessHeap(), 0, count + 1 );
+    lstrcpynWtoA( p, lpstr, count + 1 );
+    ret = GetTabbedTextExtent32A( hdc, p, count, cTabStops, lpTabPos );
+    HeapFree( GetProcessHeap(), 0, p );
+    return ret;
 }