diff --git a/ANNOUNCE b/ANNOUNCE
index 1d05e423f77dae6643b99fd495cd83d0454c4c4d..d5d35fef2de588bea27e7e246e73812ab1e9227d 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,13 +1,12 @@
-This is release 961023 of Wine, the MS Windows emulator.  This is still a
+This is release 961102 of Wine, the MS Windows emulator.  This is still a
 developer's only release.  There are many bugs and many unimplemented API
 features.  Most applications still do not work correctly.
 
 Patches should be submitted to "julliard@lrc.epfl.ch".  Please don't
 forget to include a ChangeLog entry.
 
-WHAT'S NEW with Wine-961023: (see ChangeLog for details)
-	- Printer driver fixes.
-	- Faster make depend.
+WHAT'S NEW with Wine-961102: (see ChangeLog for details)
+	- More Win32 functions.
 	- Lots of bug fixes.
 
 See the README file in the distribution for installation instructions.
@@ -16,10 +15,10 @@ Because of lags created by using mirror, this message may reach you before
 the release is available at the ftp sites.  The sources will be available
 from the following locations:
 
-  ftp://sunsite.unc.edu/pub/Linux/ALPHA/wine/development/Wine-961023.tar.gz
-  ftp://tsx-11.mit.edu/pub/linux/ALPHA/Wine/development/Wine-961023.tar.gz
-  ftp://ftp.infomagic.com/pub/mirrors/linux/wine/development/Wine-961023.tar.gz
-  ftp://aris.com/pub/linux/ALPHA/Wine/development/Wine-961023.tar.gz
+  ftp://sunsite.unc.edu/pub/Linux/ALPHA/wine/development/Wine-961102.tar.gz
+  ftp://tsx-11.mit.edu/pub/linux/ALPHA/Wine/development/Wine-961102.tar.gz
+  ftp://ftp.infomagic.com/pub/mirrors/linux/wine/development/Wine-961102.tar.gz
+  ftp://aris.com/pub/linux/ALPHA/Wine/development/Wine-961102.tar.gz
 
 It should also be available from any site that mirrors tsx-11 or sunsite.
 
diff --git a/ChangeLog b/ChangeLog
index e9787add5c8985bfed2c919d5bd54190c4ddd11a..fec97ddd3b7f54405650734f32c93d64765d9dec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,51 @@
+----------------------------------------------------------------------
+Sat Nov  2 12:50:40 1996  Alexandre Julliard  <julliard@lrc.epfl.ch>
+
+	* [files/dos_fs.c]
+	Added long file name mask in DOSFS_FindNext().
+
+	* [loader/pe_image.c] [loader/task.c]
+	Moved Win32 task startup into TASK_CallToStart().
+
+	* [objects/dc.c]
+	Fixed SetDCState() for memory DC (thanks to Constantine
+	Sapuntzakis for spotting this one).
+
+	* [windows/winpos.c]
+	Fixed WINPOS_ForceXWindowRaise() to preserve correct Z-order.
+
+	* [*/*]
+	Added Win32 version for many graphics functions.
+
+Thu Oct 31 10:00:18 1996  Huw D. M. Davies <h.davies1@physics.oxford.ac.uk>
+
+	* [controls/button.c]
+	BUTTON_CheckAutoRadioButton() unchecks only auto radio buttons.
+
+	* [controls/edit.c]
+	EM_GETSEL result should have HIWORD(result) >= LOWORD(result); old
+	EDIT_EM_GetSel() renamed to EDIT_GetSel(). 
+
+	* [windows/dialog.c]
+	DS_LOCALEDIT is a dialog style not an edit style.
+
+	* [windows/winproc.c]
+	Stop stack trashing when wndPtr->text == NULL.
+
+Tue Oct 29 23:35:04 1996   Constantine P Sapuntzakis <csapuntz@mit.edu>
+
+	* [windows/dce.c]
+	GetDCEx32 - The determination of whether to use the DC cache or
+ 	not should be independent of DCX_USESTYLE.
+
+Sat Oct 26 17:31:00 1996  Thomas Sandford <t.d.g.sandford@prds-grn.demon.co.uk>
+
+	* [files/directory.c]
+	Added errno.h to #includes
+
+	* [tools/makedep.c]
+	Close files once they have been processed.
+
 ----------------------------------------------------------------------
 Tue Oct 22 20:09:52 1996  Alexandre Julliard  <julliard@lrc.epfl.ch>
 
diff --git a/Make.rules.in b/Make.rules.in
index 4e7b95b4051a1443c39ed2f8015f85822171576d..43d024abb4c21d10a050d60d925240c98489050c 100644
--- a/Make.rules.in
+++ b/Make.rules.in
@@ -1,4 +1,4 @@
-# Global rules shared by all makefiles
+# Global rules shared by all makefiles     -*-Makefile-*-
 #
 # Each individual makefile should define the following variables:
 # TOPSRCDIR  : top-level source directory
@@ -36,7 +36,7 @@ WINERC    = $(TOPOBJDIR)/rc/winerc
 SUBMAKE   = $(MAKE) 'CC=$(CC)' 'CFLAGS=$(CFLAGS)' 'OPTIONS=$(OPTIONS)'
 @SET_MAKE@
 
-OBJS = $(C_SRCS:.c=.o) $(GEN_C_SRCS:.c=.o) $(ASM_SRCS:.S=.o) $(EXTRA_OBJS)
+OBJS = $(GEN_C_SRCS:.c=.o) $(C_SRCS:.c=.o) $(ASM_SRCS:.S=.o) $(EXTRA_OBJS)
 
 # Implicit rules
 
diff --git a/controls/button.c b/controls/button.c
index fcf591b94a53a40b8cef8803cf625496b8095e4e..8d92822cf869eeb10a779de6910b5ae4c9c2f822 100644
--- a/controls/button.c
+++ b/controls/button.c
@@ -252,38 +252,38 @@ LRESULT ButtonWndProc(HWND32 hWnd, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam)
 static void PB_Paint( WND *wndPtr, HDC32 hDC, WORD action )
 {
     RECT32 rc;
-    HPEN16 hOldPen;
-    HBRUSH16 hOldBrush;
+    HPEN32 hOldPen;
+    HBRUSH32 hOldBrush;
     BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
 
     GetClientRect32( wndPtr->hwndSelf, &rc );
 
       /* Send WM_CTLCOLOR to allow changing the font (the colors are fixed) */
-    if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont );
+    if (infoPtr->hFont) SelectObject32( hDC, infoPtr->hFont );
     BUTTON_SEND_CTLCOLOR( wndPtr, hDC );
-    hOldPen = (HPEN16)SelectObject(hDC, sysColorObjects.hpenWindowFrame);
-    hOldBrush = (HBRUSH16)SelectObject(hDC, sysColorObjects.hbrushBtnFace);
+    hOldPen = (HPEN32)SelectObject32(hDC, sysColorObjects.hpenWindowFrame);
+    hOldBrush = (HBRUSH32)SelectObject32(hDC, sysColorObjects.hbrushBtnFace);
     SetBkMode(hDC, TRANSPARENT);
-    Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
+    Rectangle32(hDC, rc.left, rc.top, rc.right, rc.bottom);
     if (action == ODA_DRAWENTIRE)
     {
-        SetPixel( hDC, rc.left, rc.top, GetSysColor(COLOR_WINDOW) );
-        SetPixel( hDC, rc.left, rc.bottom-1, GetSysColor(COLOR_WINDOW) );
-        SetPixel( hDC, rc.right-1, rc.top, GetSysColor(COLOR_WINDOW) );
-        SetPixel( hDC, rc.right-1, rc.bottom-1, GetSysColor(COLOR_WINDOW) );
+        SetPixel32( hDC, rc.left, rc.top, GetSysColor(COLOR_WINDOW) );
+        SetPixel32( hDC, rc.left, rc.bottom-1, GetSysColor(COLOR_WINDOW) );
+        SetPixel32( hDC, rc.right-1, rc.top, GetSysColor(COLOR_WINDOW) );
+        SetPixel32( hDC, rc.right-1, rc.bottom-1, GetSysColor(COLOR_WINDOW) );
     }
     InflateRect32( &rc, -1, -1 );
 
     if ((wndPtr->dwStyle & 0x000f) == BS_DEFPUSHBUTTON)
     {
-        Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
+        Rectangle32(hDC, rc.left, rc.top, rc.right, rc.bottom);
         InflateRect32( &rc, -1, -1 );
     }
 
     if (infoPtr->state & BUTTON_HIGHLIGHTED)
     {
         /* draw button shadow: */
-        SelectObject(hDC, sysColorObjects.hbrushBtnShadow );
+        SelectObject32(hDC, sysColorObjects.hbrushBtnShadow );
         PatBlt(hDC, rc.left, rc.top, 1, rc.bottom-rc.top, PATCOPY );
         PatBlt(hDC, rc.left, rc.top, rc.right-rc.left, 1, PATCOPY );
         rc.left += 2;  /* To position the text down and right */
@@ -324,8 +324,8 @@ static void PB_Paint( WND *wndPtr, HDC32 hDC, WORD action )
         }   
     }
 
-    SelectObject( hDC, hOldPen );
-    SelectObject( hDC, hOldBrush );
+    SelectObject32( hDC, hOldPen );
+    SelectObject32( hDC, hOldBrush );
 }
 
 
@@ -349,17 +349,17 @@ void PB_PaintGrayOnGray(HDC32 hDC,HFONT32 hFont,RECT32 *rc,char *text)
     rect.left=(rc->right-rect.right)/2;       /* for centering text bitmap */
     rect.top=(rc->bottom-rect.bottom)/2;
     hbmMem = CreateCompatibleBitmap( hDC,rect.right,rect.bottom);
-    SelectObject( hdcMem, hbmMem);
-    hBr = SelectObject( hdcMem,CreatePatternBrush(hbm));
-    DeleteObject( hbm);
+    SelectObject32( hdcMem, hbmMem);
+    hBr = SelectObject32( hdcMem, CreatePatternBrush32(hbm) );
+    DeleteObject32( hbm );
     PatBlt( hdcMem,0,0,rect.right,rect.bottom,WHITENESS);
-    if (hFont) SelectObject( hdcMem, hFont);
+    if (hFont) SelectObject32( hdcMem, hFont);
     DrawText32A( hdcMem, text, -1, &rc2, DT_SINGLELINE);  
     PatBlt( hdcMem,0,0,rect.right,rect.bottom,0xFA0089);
-    DeleteObject( SelectObject( hdcMem,hBr));
+    DeleteObject32( SelectObject32( hdcMem,hBr) );
     BitBlt( hDC,rect.left,rect.top,rect.right,rect.bottom,hdcMem,0,0,0x990000);
     DeleteDC( hdcMem);
-    DeleteObject( hbmMem);
+    DeleteObject32( hbmMem );
 }
 
 
@@ -377,7 +377,7 @@ static void CB_Paint( WND *wndPtr, HDC32 hDC, WORD action )
 
     GetClientRect16(wndPtr->hwndSelf, &rc);
 
-    if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont );
+    if (infoPtr->hFont) SelectObject32( hDC, infoPtr->hFont );
     hBrush = BUTTON_SEND_CTLCOLOR( wndPtr, hDC );
     if (action == ODA_DRAWENTIRE) FillRect16( hDC, &rc, hBrush );
 
@@ -427,7 +427,7 @@ static void CB_Paint( WND *wndPtr, HDC32 hDC, WORD action )
 /**********************************************************************
  *       BUTTON_CheckAutoRadioButton
  *
- * wndPtr is checked, uncheck everything else in group
+ * wndPtr is checked, uncheck every other auto radio button in group
  */
 static void BUTTON_CheckAutoRadioButton( WND *wndPtr )
 {
@@ -435,9 +435,10 @@ static void BUTTON_CheckAutoRadioButton( WND *wndPtr )
     if (!(wndPtr->dwStyle & WS_CHILD)) return;
     parent = wndPtr->parent->hwndSelf;
     for(sibling = GetNextDlgGroupItem32( parent, wndPtr->hwndSelf, FALSE );
-        sibling != wndPtr->hwndSelf;
+        sibling != wndPtr->hwndSelf && sibling != 0;
         sibling = GetNextDlgGroupItem32( parent, sibling, FALSE ))
-	    SendMessage32A( sibling, BM_SETCHECK32, BUTTON_UNCHECKED, 0 );
+	    if((WIN_FindWndPtr(sibling)->dwStyle & 0x0f) == BS_AUTORADIOBUTTON)
+		SendMessage32A( sibling, BM_SETCHECK32, BUTTON_UNCHECKED, 0 );
 }
 
 
@@ -452,17 +453,17 @@ static void GB_Paint( WND *wndPtr, HDC32 hDC, WORD action )
 
     if (action != ODA_DRAWENTIRE) return;
 
-    if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont );
+    if (infoPtr->hFont) SelectObject32( hDC, infoPtr->hFont );
     BUTTON_SEND_CTLCOLOR( wndPtr, hDC );
-    SelectObject( hDC, sysColorObjects.hpenWindowFrame );
+    SelectObject32( hDC, sysColorObjects.hpenWindowFrame );
 
     GetClientRect16( wndPtr->hwndSelf, &rc);
 
     MoveTo( hDC, rc.left, rc.top+2 );
-    LineTo( hDC, rc.right-1, rc.top+2 );
-    LineTo( hDC, rc.right-1, rc.bottom-1 );
-    LineTo( hDC, rc.left, rc.bottom-1 );
-    LineTo( hDC, rc.left, rc.top+2 );
+    LineTo32( hDC, rc.right-1, rc.top+2 );
+    LineTo32( hDC, rc.right-1, rc.bottom-1 );
+    LineTo32( hDC, rc.left, rc.bottom-1 );
+    LineTo32( hDC, rc.left, rc.top+2 );
 
     if (!wndPtr->text) return;
     if (wndPtr->dwStyle & WS_DISABLED)
@@ -486,7 +487,7 @@ static void UB_Paint( WND *wndPtr, HDC32 hDC, WORD action )
 
     GetClientRect16( wndPtr->hwndSelf, &rc);
 
-    if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont );
+    if (infoPtr->hFont) SelectObject32( hDC, infoPtr->hFont );
     hBrush = BUTTON_SEND_CTLCOLOR( wndPtr, hDC );
     FillRect16( hDC, &rc, hBrush );
 
diff --git a/controls/combo.c b/controls/combo.c
index 1f540f4a61951fd7e6d7764f2b71c1451e076a77..c3f429e4277ea2b8e85465bc1e0831badfe11985 100644
--- a/controls/combo.c
+++ b/controls/combo.c
@@ -224,8 +224,8 @@ static LRESULT CBPaint(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
   LPHEADCOMBO lphc = ComboGetStorageHeader(hwnd);
   LPLISTSTRUCT lpls;
   PAINTSTRUCT16  ps;
-  HBRUSH16 hBrush;
-  HFONT16  hOldFont;
+  HBRUSH32 hBrush;
+  HFONT32 hOldFont;
   HDC16 hdc;
   RECT16 rect;
   
@@ -238,8 +238,8 @@ static LRESULT CBPaint(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
 
   if (hComboBit != 0 && !IsRectEmpty16(&lphc->RectButton))
   {
-    Rectangle(hdc,lphc->RectButton.left-1,lphc->RectButton.top-1,
-	      lphc->RectButton.right+1,lphc->RectButton.bottom+1);
+    Rectangle32(hdc,lphc->RectButton.left-1,lphc->RectButton.top-1,
+                lphc->RectButton.right+1,lphc->RectButton.bottom+1);
     {
         RECT32 r;
         CONV_RECT16TO32( &lphc->RectButton, &r );
@@ -257,10 +257,10 @@ static LRESULT CBPaint(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
     return 0;
   }
 
-  hOldFont = SelectObject(hdc, lphl->hFont);
+  hOldFont = SelectObject32(hdc, lphl->hFont);
 
   hBrush = SendMessage32A( lphl->hParent, WM_CTLCOLORLISTBOX, hdc, hwnd );
-  if (hBrush == 0) hBrush = GetStockObject(WHITE_BRUSH);
+  if (hBrush == 0) hBrush = GetStockObject32(WHITE_BRUSH);
 
   lpls = ListBoxGetItem(lphl,lphl->ItemFocused);
   if (lpls != NULL) {  
@@ -270,7 +270,7 @@ static LRESULT CBPaint(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
     ListBoxDrawItem (hwnd,lphl, hdc, lpls, &rect, ODA_FOCUS, ODS_FOCUS);
   }
   else FillRect16(hdc, &rect, hBrush);
-  SelectObject(hdc,hOldFont);
+  SelectObject32(hdc,hOldFont);
   EndPaint16(hwnd, &ps);
   return 0;
 }
@@ -556,7 +556,7 @@ static LRESULT CBSetFont(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
   LPHEADCOMBO lphc = ComboGetStorageHeader(hwnd);
   
   if (wParam == 0)
-    lphl->hFont = GetStockObject(SYSTEM_FONT);
+    lphl->hFont = GetStockObject32(SYSTEM_FONT);
   else
     lphl->hFont = (HFONT16)wParam;
   if (lphc->hWndEdit)
@@ -914,8 +914,8 @@ static LRESULT CBLPaint( HWND hwnd, WPARAM16 wParam, LPARAM lParam )
   LPHEADLIST   lphl = CLBoxGetListHeader(hwnd);
   LPLISTSTRUCT lpls;
   PAINTSTRUCT16  ps;
-  HBRUSH16 hBrush;
-  HFONT16 hOldFont;
+  HBRUSH32 hBrush;
+  HFONT32 hOldFont;
   WND * wndPtr = WIN_FindWndPtr(hwnd);
   HWND  combohwnd = CLBoxGetCombo(hwnd);
   HDC16 hdc;
@@ -930,9 +930,9 @@ static LRESULT CBLPaint( HWND hwnd, WPARAM16 wParam, LPARAM lParam )
     return 0;
   }
 
-  hOldFont = SelectObject(hdc, lphl->hFont);
+  hOldFont = SelectObject32(hdc, lphl->hFont);
   /* listboxes should be white */
-  hBrush = GetStockObject(WHITE_BRUSH);
+  hBrush = GetStockObject32(WHITE_BRUSH);
 
   GetClientRect16(hwnd, &rect);
   FillRect16(hdc, &rect, hBrush);
@@ -977,7 +977,7 @@ static LRESULT CBLPaint( HWND hwnd, WPARAM16 wParam, LPARAM lParam )
   if (wndPtr->dwStyle & WS_VSCROLL) 
       SetScrollRange32(hwnd, SB_VERT, 0, ListMaxFirstVisible(lphl), TRUE);
 
-  SelectObject(hdc,hOldFont);
+  SelectObject32(hdc,hOldFont);
   EndPaint16( hwnd, &ps );
   return 0;
 
diff --git a/controls/desktop.c b/controls/desktop.c
index f7529e8c61c181d5522cb209a0021e766d1a9521..87cde85523ce88fe5f7d868064d091b2945d0fde 100644
--- a/controls/desktop.c
+++ b/controls/desktop.c
@@ -80,7 +80,7 @@ static LRESULT DESKTOP_DoEraseBkgnd( HWND32 hwnd, HDC32 hdc,
     RECT32 rect;
     WND*   Wnd = WIN_FindWndPtr( hwnd );
 
-    if( Wnd->hrgnUpdate > 1 ) DeleteObject( Wnd->hrgnUpdate );
+    if (Wnd->hrgnUpdate > 1) DeleteObject32( Wnd->hrgnUpdate );
     Wnd->hrgnUpdate = 0;
 
     GetClientRect32( hwnd, &rect );    
@@ -208,7 +208,7 @@ BOOL32 SetDeskWallPaper32( LPCSTR filename )
     hdc = GetDC32( 0 );
     hbitmap = DESKTOP_LoadBitmap( hdc, filename );
     ReleaseDC32( 0, hdc );
-    if (infoPtr->hbitmapWallPaper) DeleteObject( infoPtr->hbitmapWallPaper );
+    if (infoPtr->hbitmapWallPaper) DeleteObject32( infoPtr->hbitmapWallPaper );
     infoPtr->hbitmapWallPaper = hbitmap;
     infoPtr->fTileWallPaper = GetProfileInt( "desktop", "TileWallPaper", 0 );
     if (hbitmap)
@@ -233,7 +233,7 @@ BOOL32 DESKTOP_SetPattern( LPCSTR pattern )
     DESKTOPINFO *infoPtr = (DESKTOPINFO *)wndPtr->wExtra;
     int pat[8];
 
-    if (infoPtr->hbrushPattern) DeleteObject( infoPtr->hbrushPattern );
+    if (infoPtr->hbrushPattern) DeleteObject32( infoPtr->hbrushPattern );
     memset( pat, 0, sizeof(pat) );
     if (pattern && sscanf( pattern, " %d %d %d %d %d %d %d %d",
 			   &pat[0], &pat[1], &pat[2], &pat[3],
@@ -245,10 +245,10 @@ BOOL32 DESKTOP_SetPattern( LPCSTR pattern )
 
 	for (i = 0; i < 8; i++) pattern[i] = pat[i] & 0xffff;
 	hbitmap = CreateBitmap( 8, 8, 1, 1, (LPSTR)pattern );
-	infoPtr->hbrushPattern = CreatePatternBrush( hbitmap );
-	DeleteObject( hbitmap );
+	infoPtr->hbrushPattern = CreatePatternBrush32( hbitmap );
+	DeleteObject32( hbitmap );
     }
-    else infoPtr->hbrushPattern = CreateSolidBrush( GetSysColor(COLOR_BACKGROUND) );
+    else infoPtr->hbrushPattern = CreateSolidBrush32( GetSysColor(COLOR_BACKGROUND) );
     return TRUE;
 }
 
diff --git a/controls/edit.c b/controls/edit.c
index f37c058825ae1f108a5d883bc160d14afb03e1b0..e86af1485c943434f1d267872af15060f02553f0 100644
--- a/controls/edit.c
+++ b/controls/edit.c
@@ -119,6 +119,7 @@ static char *  EDIT_GetPointer(WND *wndPtr);
 static char *  EDIT_GetPasswordPointer(WND *wndPtr);
 static LRESULT EDIT_GetRect(WND *wndPtr, WPARAM32 wParam, LPARAM lParam);
 static BOOL    EDIT_GetRedraw(WND *wndPtr);
+static LRESULT EDIT_GetSel(WND *wndPtr, WPARAM32 wParam, LPARAM lParam);
 static UINT    EDIT_GetTextWidth(WND *wndPtr);
 static UINT    EDIT_GetVisibleLineCount(WND *wndPtr);
 static UINT    EDIT_GetWndWidth(WND *wndPtr);
@@ -511,7 +512,7 @@ static void EDIT_BuildLineDefs(WND *wndPtr)
 	int ww = EDIT_GetWndWidth(wndPtr);
 	HDC32 hdc;
 	HFONT16 hFont;
-	HFONT16 oldFont = 0;
+	HFONT32 oldFont = 0;
 	char *start, *cp;
 	int prev, next;
 	int width;
@@ -520,8 +521,7 @@ static void EDIT_BuildLineDefs(WND *wndPtr)
 
 	hdc = GetDC32(wndPtr->hwndSelf);
 	hFont = (HFONT16)EDIT_WM_GetFont(wndPtr, 0, 0L);
-	if (hFont)
-		oldFont = SelectObject(hdc, hFont);
+	if (hFont) oldFont = SelectObject32(hdc, hFont);
 
 	if (!IsMultiLine(wndPtr)) {
 		es->LineCount = 1;
@@ -602,8 +602,7 @@ static void EDIT_BuildLineDefs(WND *wndPtr)
 			}
 		} while (*start || (ending == END_SOFT) || (ending == END_HARD));
 	}
-	if (hFont)
-		SelectObject(hdc, oldFont);
+	if (hFont) SelectObject32(hdc, oldFont);
 	ReleaseDC32(wndPtr->hwndSelf, hdc);
 
 	free(text);
@@ -819,6 +818,22 @@ static BOOL EDIT_GetRedraw(WND *wndPtr)
 }
 
 
+/*********************************************************************
+ *
+ *	EDIT_GetSel
+ *
+ *	Beware: This is not the function called on EM_GETSEL.
+ *	It returns the start in the low word and the end in the high word.
+ *	NB s can be greater than e.
+ *
+ */
+static LRESULT EDIT_GetSel(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
+{
+	EDITSTATE *es = EDITSTATEPTR(wndPtr);
+
+	return MAKELONG(es->SelStart, es->SelEnd);
+}
+
 /*********************************************************************
  *
  *	EDIT_GetTextWidth
@@ -999,8 +1014,8 @@ static BOOL EDIT_MakeFit(WND *wndPtr, UINT size)
  */
 static void EDIT_MoveBackward(WND *wndPtr, BOOL extend)
 {
-	UINT s = LOWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
-	UINT e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+	UINT s = LOWORD(EDIT_GetSel(wndPtr, 0, 0L));
+	UINT e = HIWORD(EDIT_GetSel(wndPtr, 0, 0L));
 	UINT l = (UINT)EDIT_EM_LineFromChar(wndPtr, e, 0L);
 	UINT li = (UINT)EDIT_EM_LineIndex(wndPtr, l, 0L);
 
@@ -1024,8 +1039,8 @@ static void EDIT_MoveBackward(WND *wndPtr, BOOL extend)
  */
 static void EDIT_MoveDownward(WND *wndPtr, BOOL extend)
 {
-	UINT s = LOWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
-	UINT e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+	UINT s = LOWORD(EDIT_GetSel(wndPtr, 0, 0L));
+	UINT e = HIWORD(EDIT_GetSel(wndPtr, 0, 0L));
 	UINT l = (UINT)EDIT_EM_LineFromChar(wndPtr, e, 0L);
 	UINT lc = (UINT)EDIT_EM_GetLineCount(wndPtr, e, 0L);
 	UINT li = (UINT)EDIT_EM_LineIndex(wndPtr, l, 0L);
@@ -1050,8 +1065,8 @@ static void EDIT_MoveDownward(WND *wndPtr, BOOL extend)
  */
 static void EDIT_MoveEnd(WND *wndPtr, BOOL extend)
 {
-	UINT s = LOWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
-	UINT e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+	UINT s = LOWORD(EDIT_GetSel(wndPtr, 0, 0L));
+	UINT e = HIWORD(EDIT_GetSel(wndPtr, 0, 0L));
 	UINT l = (UINT)EDIT_EM_LineFromChar(wndPtr, e, 0L);
 	UINT ll = (UINT)EDIT_EM_LineLength(wndPtr, e, 0L);
 	UINT li = (UINT)EDIT_EM_LineIndex(wndPtr, l, 0L);
@@ -1070,8 +1085,8 @@ static void EDIT_MoveEnd(WND *wndPtr, BOOL extend)
  */
 static void EDIT_MoveForward(WND *wndPtr, BOOL extend)
 {
-	UINT s = LOWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
-	UINT e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+	UINT s = LOWORD(EDIT_GetSel(wndPtr, 0, 0L));
+	UINT e = HIWORD(EDIT_GetSel(wndPtr, 0, 0L));
 	UINT l = (UINT)EDIT_EM_LineFromChar(wndPtr, e, 0L);
 	UINT lc = (UINT)EDIT_EM_GetLineCount(wndPtr, e, 0L);
 	UINT ll = (UINT)EDIT_EM_LineLength(wndPtr, e, 0L);
@@ -1097,8 +1112,8 @@ static void EDIT_MoveForward(WND *wndPtr, BOOL extend)
  */
 static void EDIT_MoveHome(WND *wndPtr, BOOL extend)
 {
-	UINT s = LOWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
-	UINT e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+	UINT s = LOWORD(EDIT_GetSel(wndPtr, 0, 0L));
+	UINT e = HIWORD(EDIT_GetSel(wndPtr, 0, 0L));
 	UINT l = (UINT)EDIT_EM_LineFromChar(wndPtr, e, 0L);
 	UINT li = (UINT)EDIT_EM_LineIndex(wndPtr, l, 0L);
 
@@ -1116,8 +1131,8 @@ static void EDIT_MoveHome(WND *wndPtr, BOOL extend)
  */
 static void EDIT_MovePageDown(WND *wndPtr, BOOL extend)
 {
-	UINT s = LOWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
-	UINT e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+	UINT s = LOWORD(EDIT_GetSel(wndPtr, 0, 0L));
+	UINT e = HIWORD(EDIT_GetSel(wndPtr, 0, 0L));
 	UINT l = (UINT)EDIT_EM_LineFromChar(wndPtr, e, 0L);
 	UINT lc = (UINT)EDIT_EM_GetLineCount(wndPtr, e, 0L);
 	UINT li = (UINT)EDIT_EM_LineIndex(wndPtr, l, 0L);
@@ -1142,8 +1157,8 @@ static void EDIT_MovePageDown(WND *wndPtr, BOOL extend)
  */
 static void EDIT_MovePageUp(WND *wndPtr, BOOL extend)
 {
-	UINT s = LOWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
-	UINT e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+	UINT s = LOWORD(EDIT_GetSel(wndPtr, 0, 0L));
+	UINT e = HIWORD(EDIT_GetSel(wndPtr, 0, 0L));
 	UINT l = (UINT)EDIT_EM_LineFromChar(wndPtr, e, 0L);
 	UINT li = (UINT)EDIT_EM_LineIndex(wndPtr, l, 0L);
 	INT x;
@@ -1167,8 +1182,8 @@ static void EDIT_MovePageUp(WND *wndPtr, BOOL extend)
  */
 static void EDIT_MoveUpward(WND *wndPtr, BOOL extend)
 {
-	UINT s = LOWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
-	UINT e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+	UINT s = LOWORD(EDIT_GetSel(wndPtr, 0, 0L));
+	UINT e = HIWORD(EDIT_GetSel(wndPtr, 0, 0L));
 	UINT l = (UINT)EDIT_EM_LineFromChar(wndPtr, e, 0L);
 	UINT li = (UINT)EDIT_EM_LineIndex(wndPtr, l, 0L);
 	INT x;
@@ -1192,8 +1207,8 @@ static void EDIT_MoveUpward(WND *wndPtr, BOOL extend)
  */
 static void EDIT_MoveWordBackward(WND *wndPtr, BOOL extend)
 {
-	UINT s = LOWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
-	UINT e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+	UINT s = LOWORD(EDIT_GetSel(wndPtr, 0, 0L));
+	UINT e = HIWORD(EDIT_GetSel(wndPtr, 0, 0L));
 	UINT l = (UINT)EDIT_EM_LineFromChar(wndPtr, e, 0L);
 	UINT ll = (UINT)EDIT_EM_LineLength(wndPtr, e, 0L);
 	UINT li = (UINT)EDIT_EM_LineIndex(wndPtr, l, 0L);
@@ -1222,8 +1237,8 @@ static void EDIT_MoveWordBackward(WND *wndPtr, BOOL extend)
  */
 static void EDIT_MoveWordForward(WND *wndPtr, BOOL extend)
 {
-	UINT s = LOWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
-	UINT e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+	UINT s = LOWORD(EDIT_GetSel(wndPtr, 0, 0L));
+	UINT e = HIWORD(EDIT_GetSel(wndPtr, 0, 0L));
 	UINT l = (UINT)EDIT_EM_LineFromChar(wndPtr, e, 0L);
 	UINT lc = (UINT)EDIT_EM_GetLineCount(wndPtr, e, 0L);
 	UINT ll = (UINT)EDIT_EM_LineLength(wndPtr, e, 0L);
@@ -1270,8 +1285,8 @@ static void EDIT_PaintLine(WND *wndPtr, HDC32 hdc, UINT line, BOOL rev)
 	y = EDIT_WndYFromLine(wndPtr, line);
 	li = (UINT)EDIT_EM_LineIndex(wndPtr, line, 0L);
 	ll = (UINT)EDIT_EM_LineLength(wndPtr, li, 0L);
-	s = LOWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
-	e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+	s = LOWORD(EDIT_GetSel(wndPtr, 0, 0L));
+	e = HIWORD(EDIT_GetSel(wndPtr, 0, 0L));
 	ORDER_UINT(s, e);
 	s = MIN(li + ll, MAX(li, s));
 	e = MIN(li + ll, MAX(li, e));
@@ -1357,8 +1372,8 @@ static LRESULT EDIT_ReplaceSel(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
 	const char *str = (char *)lParam;
 	int strl = strlen(str);
 	UINT tl = (UINT)EDIT_WM_GetTextLength(wndPtr, 0, 0L);
-	UINT s = LOWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
-	UINT e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+	UINT s = LOWORD(EDIT_GetSel(wndPtr, 0, 0L));
+	UINT e = HIWORD(EDIT_GetSel(wndPtr, 0, 0L));
 	int i;
 	char *p;
 	char *text;
@@ -1373,7 +1388,7 @@ static LRESULT EDIT_ReplaceSel(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
 	EDIT_WM_SetRedraw(wndPtr, FALSE, 0L);
 	EDIT_WM_Clear(wndPtr, 0, 0L);
 	tl = EDIT_WM_GetTextLength(wndPtr, 0, 0L);
-	e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+	e = HIWORD(EDIT_GetSel(wndPtr, 0, 0L));
 	text = EDIT_GetPointer(wndPtr);
 	for (p = text + tl ; p >= text + e ; p--)
 		p[strl] = p[0];
@@ -1406,7 +1421,7 @@ static LRESULT EDIT_ReplaceSel(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
  */
 static void EDIT_ScrollIntoView(WND *wndPtr)
 {
-	UINT e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+	UINT e = HIWORD(EDIT_GetSel(wndPtr, 0, 0L));
 	UINT l = (UINT)EDIT_EM_LineFromChar(wndPtr, e, 0L);
 	UINT li = (UINT)EDIT_EM_LineIndex(wndPtr, l, 0L);
 	UINT fv = (UINT)EDIT_EM_GetFirstVisibleLine(wndPtr, 0, 0L);
@@ -1449,7 +1464,7 @@ static INT EDIT_WndXFromCol(WND *wndPtr, UINT line, UINT col)
 	INT ret;
 	HDC32 hdc;
 	HFONT16 hFont;
-	HFONT16 oldFont = 0;
+	HFONT32 oldFont = 0;
 	UINT lc = (UINT)EDIT_EM_GetLineCount(wndPtr, 0, 0L);
 	UINT li = (UINT)EDIT_EM_LineIndex(wndPtr, line, 0L);
 	UINT ll = (UINT)EDIT_EM_LineLength(wndPtr, li, 0L);
@@ -1457,15 +1472,13 @@ static INT EDIT_WndXFromCol(WND *wndPtr, UINT line, UINT col)
 
 	hdc = GetDC32(wndPtr->hwndSelf);
 	hFont = (HFONT16)EDIT_WM_GetFont(wndPtr, 0, 0L);
-	if (hFont)
-		oldFont = SelectObject(hdc, hFont);
+	if (hFont) oldFont = SelectObject32(hdc, hFont);
 	line = MAX(0, MIN(line, lc - 1));
 	col = MIN(col, ll);
 	ret = LOWORD(GetTabbedTextExtent(hdc,
 			text + li, col,
 			es->NumTabStops, es->TabStops)) - xoff;
-	if (hFont)
-		SelectObject(hdc, oldFont);
+	if (hFont) SelectObject32(hdc, oldFont);
 	ReleaseDC32(wndPtr->hwndSelf, hdc);
 	free(text);
 	return ret;
@@ -1699,12 +1712,17 @@ static LRESULT EDIT_EM_GetRect(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
  *
  *	EM_GETSEL
  *
+ *	Returns the ordered selection range so that
+ *	LOWORD(result) < HIWORD(result)
+ *
  */
 static LRESULT EDIT_EM_GetSel(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
 {
-	EDITSTATE *es = EDITSTATEPTR(wndPtr);
+	UINT s = LOWORD(EDIT_GetSel(wndPtr, 0, 0L));
+	UINT e = HIWORD(EDIT_GetSel(wndPtr, 0, 0L));
 
-	return MAKELONG(es->SelStart, es->SelEnd);
+	ORDER_UINT(s, e);
+	return MAKELONG(s, e);
 }
 
 
@@ -1771,7 +1789,7 @@ static LRESULT EDIT_EM_LineFromChar(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
 	if (!IsMultiLine(wndPtr))
 		return 0L;
 	if ((INT)wParam == -1)
-		wParam = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+		wParam = HIWORD(EDIT_GetSel(wndPtr, 0, 0L));
 	l = (UINT)EDIT_EM_GetLineCount(wndPtr, 0, 0L) - 1;
 	while ((UINT)EDIT_EM_LineIndex(wndPtr, l, 0L) > (UINT)wParam)
 		l--;
@@ -1792,7 +1810,7 @@ static LRESULT EDIT_EM_LineIndex(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
 	UINT lc = (UINT)EDIT_EM_GetLineCount(wndPtr, 0, 0L);
 
 	if ((INT)wParam == -1) {
-		e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+		e = HIWORD(EDIT_GetSel(wndPtr, 0, 0L));
 		l = lc - 1;
 		while (es->LineDefs[l].offset > e)
 			l--;
@@ -1820,8 +1838,8 @@ static LRESULT EDIT_EM_LineLength(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
 	if (!IsMultiLine(wndPtr))
 		return (LRESULT)es->LineDefs[0].length;
 	if ((INT)wParam == -1) {
-		s = LOWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
-		e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+		s = LOWORD(EDIT_GetSel(wndPtr, 0, 0L));
+		e = HIWORD(EDIT_GetSel(wndPtr, 0, 0L));
 		sl = (UINT)EDIT_EM_LineFromChar(wndPtr, s, 0L);
 		el = (UINT)EDIT_EM_LineFromChar(wndPtr, e, 0L);
 		return (LRESULT)(s - es->LineDefs[sl].offset +
@@ -2013,8 +2031,8 @@ static LRESULT EDIT_EM_SetSel(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
 	EDITSTATE *es = EDITSTATEPTR(wndPtr);
 	UINT ns = LOWORD(lParam);
 	UINT ne = HIWORD(lParam);
-	UINT s = LOWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
-	UINT e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+	UINT s = LOWORD(EDIT_GetSel(wndPtr, 0, 0L));
+	UINT e = HIWORD(EDIT_GetSel(wndPtr, 0, 0L));
 	UINT el;
 	UINT eli;
 	UINT tl = (UINT)EDIT_WM_GetTextLength(wndPtr, 0, 0L);
@@ -2148,8 +2166,8 @@ static LRESULT EDIT_WM_Char(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
  */
 static LRESULT EDIT_WM_Clear(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
 {
-	UINT s = LOWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
-	UINT e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+	UINT s = LOWORD(EDIT_GetSel(wndPtr, 0, 0L));
+	UINT e = HIWORD(EDIT_GetSel(wndPtr, 0, 0L));
 	char *text;
 	BOOL redraw;
 	
@@ -2180,8 +2198,8 @@ static LRESULT EDIT_WM_Clear(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
  */
 static LRESULT EDIT_WM_Copy(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
 {
-	UINT s = LOWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
-	UINT e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+	UINT s = LOWORD(EDIT_GetSel(wndPtr, 0, 0L));
+	UINT e = HIWORD(EDIT_GetSel(wndPtr, 0, 0L));
 	HGLOBAL16 hdst;
 	char *text;
 	char *dst;
@@ -2317,15 +2335,15 @@ static LRESULT EDIT_WM_Enable(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
  */
 static LRESULT EDIT_WM_EraseBkGnd(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
 {
-	HBRUSH16 hBrush;
+	HBRUSH32 hBrush;
 	RECT16 rc;
 
 	hBrush = (HBRUSH16)EDIT_SEND_CTLCOLOR(wndPtr, wParam);
-	if (!hBrush)
-		hBrush = (HBRUSH16)GetStockObject(WHITE_BRUSH);
+	if (!hBrush) hBrush = (HBRUSH32)GetStockObject32(WHITE_BRUSH);
 
 	GetClientRect16(wndPtr->hwndSelf, &rc);
-	IntersectClipRect((HDC16)wParam, rc.left, rc.top, rc.right, rc.bottom);
+	IntersectClipRect16( (HDC16)wParam, rc.left, rc.top,
+                             rc.right, rc.bottom);
 	GetClipBox16((HDC16)wParam, &rc);
 	/*
 	 *	FIXME:	specs say that we should UnrealizeObject() the brush,
@@ -2468,8 +2486,8 @@ static LRESULT EDIT_WM_HScroll(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
  */
 static LRESULT EDIT_WM_KeyDown(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
 {
-	UINT s = LOWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
-	UINT e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+	UINT s = LOWORD(EDIT_GetSel(wndPtr, 0, 0L));
+	UINT e = HIWORD(EDIT_GetSel(wndPtr, 0, 0L));
 	BOOL shift;
 	BOOL control;
 
@@ -2560,8 +2578,8 @@ static LRESULT EDIT_WM_KillFocus(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
 
 	DestroyCaret();
 	if(!(wndPtr->dwStyle & ES_NOHIDESEL)) {
-		s = LOWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
-		e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+		s = LOWORD(EDIT_GetSel(wndPtr, 0, 0L));
+		e = HIWORD(EDIT_GetSel(wndPtr, 0, 0L));
 		EDIT_InvalidateText(wndPtr, s, e);
 	}
 	EDIT_NOTIFY_PARENT(wndPtr, EN_KILLFOCUS);
@@ -2579,7 +2597,7 @@ static LRESULT EDIT_WM_KillFocus(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
 static LRESULT EDIT_WM_LButtonDblClk(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
 {
 	UINT s;
-	UINT e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+	UINT e = HIWORD(EDIT_GetSel(wndPtr, 0, 0L));
 	UINT l = (UINT)EDIT_EM_LineFromChar(wndPtr, e, 0L);
 	UINT li = (UINT)EDIT_EM_LineIndex(wndPtr, l, 0L);
 	UINT ll = (UINT)EDIT_EM_LineLength(wndPtr, e, 0L);
@@ -2617,7 +2635,7 @@ static LRESULT EDIT_WM_LButtonDown(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
 	li = (UINT)EDIT_EM_LineIndex(wndPtr, l, 0L);
 	e = li + c;
 	if (GetKeyState(VK_SHIFT) & 0x8000)
-		s = LOWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+		s = LOWORD(EDIT_GetSel(wndPtr, 0, 0L));
 	else 
 		s = e;
 	EDIT_EM_SetSel(wndPtr, 0, MAKELPARAM(s, e));
@@ -2663,7 +2681,7 @@ static LRESULT EDIT_WM_MouseMove(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
 		l = MIN(fv + vlc - 1, MAX(fv, l));
 		x = MIN(EDIT_GetWndWidth(wndPtr), MAX(0, x));
 		c = EDIT_ColFromWndX(wndPtr, l, x);
-		s = LOWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+		s = LOWORD(EDIT_GetSel(wndPtr, 0, 0L));
 		li = (UINT)EDIT_EM_LineIndex(wndPtr, l, 0L);
 		EDIT_EM_SetSel(wndPtr, 1, MAKELPARAM(s, li + c));
 	}
@@ -2685,7 +2703,7 @@ static LRESULT EDIT_WM_Paint(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
 	UINT lc = (UINT)EDIT_EM_GetLineCount(wndPtr, 0, 0L);
 	HDC16 hdc;
 	HFONT16 hFont;
-	HFONT16 oldFont = 0;
+	HFONT32 oldFont = 0;
 	RECT16 rc;
 	RECT16 rcLine;
 	RECT16 rcRgn;
@@ -2695,10 +2713,9 @@ static LRESULT EDIT_WM_Paint(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
 
 	hdc = BeginPaint16(wndPtr->hwndSelf, &ps);
 	GetClientRect16(wndPtr->hwndSelf, &rc);
-	IntersectClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom);
+	IntersectClipRect16( hdc, rc.left, rc.top, rc.right, rc.bottom );
 	hFont = EDIT_WM_GetFont(wndPtr, 0, 0L);
-	if (hFont)
-		oldFont = SelectObject(hdc, hFont);
+	if (hFont) oldFont = SelectObject32(hdc, hFont);
 	EDIT_SEND_CTLCOLOR(wndPtr, hdc);
 	if (!IsWindowEnabled(wndPtr->hwndSelf))
 		SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT));
@@ -2708,8 +2725,7 @@ static LRESULT EDIT_WM_Paint(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
 		if (IntersectRect16(&rc, &rcRgn, &rcLine))
 			EDIT_PaintLine(wndPtr, hdc, i, rev);
 	}
-	if (hFont)
-		SelectObject(hdc, oldFont);
+	if (hFont) SelectObject32(hdc, oldFont);
 	EndPaint16(wndPtr->hwndSelf, &ps);
 	return 0L;
 }
@@ -2758,8 +2774,8 @@ static LRESULT EDIT_WM_SetCursor(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
  */
 static LRESULT EDIT_WM_SetFocus(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
 {
-	UINT s = LOWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
-	UINT e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+	UINT s = LOWORD(EDIT_GetSel(wndPtr, 0, 0L));
+	UINT e = HIWORD(EDIT_GetSel(wndPtr, 0, 0L));
 
 	CreateCaret(wndPtr->hwndSelf, 0, 2, EDIT_GetLineHeight(wndPtr));
 	EDIT_EM_SetSel(wndPtr, 1, MAKELPARAM(s, e));
@@ -2780,19 +2796,17 @@ static LRESULT EDIT_WM_SetFont(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
 {
 	TEXTMETRIC16 tm;
 	EDITSTATE *es = EDITSTATEPTR(wndPtr);
-	LPARAM sel = EDIT_EM_GetSel(wndPtr, 0, 0L);
+	LPARAM sel = EDIT_GetSel(wndPtr, 0, 0L);
 	HDC32 hdc;
-	HFONT16 oldFont = 0;
+	HFONT32 oldFont = 0;
 
 	es->hFont = (HFONT16)wParam;
 	hdc = GetDC32(wndPtr->hwndSelf);
-	if (es->hFont)
-		oldFont = SelectObject(hdc, es->hFont);
+	if (es->hFont) oldFont = SelectObject32(hdc, es->hFont);
 	GetTextMetrics16(hdc, &tm);
 	es->LineHeight = HIWORD(GetTextExtent(hdc, "X", 1));
 	es->AveCharWidth = tm.tmAveCharWidth;
-	if (es->hFont)
-		SelectObject(hdc, oldFont);
+	if (es->hFont) SelectObject32(hdc, oldFont);
 	ReleaseDC32(wndPtr->hwndSelf, hdc);
 	EDIT_BuildLineDefs(wndPtr);
 	if ((BOOL)lParam && EDIT_GetRedraw(wndPtr))
diff --git a/controls/listbox.c b/controls/listbox.c
index d3c4a94b9210b8b3a4a7d334694e4d31a81fb24d..1fe77b25f99eac935d6e669f6d42bdd60e168e9d 100644
--- a/controls/listbox.c
+++ b/controls/listbox.c
@@ -74,7 +74,7 @@ void CreateListBoxStruct(HWND hwnd, WORD CtlType, LONG styles, HWND parent)
   lphl->bRedrawFlag    = TRUE;
   lphl->iNumStops      = 0;
   lphl->TabStops       = NULL;
-  lphl->hFont          = GetStockObject(SYSTEM_FONT);
+  lphl->hFont          = GetStockObject32(SYSTEM_FONT);
   lphl->hSelf          = hwnd;  
   if (CtlType==ODT_COMBOBOX)              /* use the "faked" style for COMBOLBOX */
                                           /* LBS_SORT instead CBS_SORT e.g.      */
@@ -227,7 +227,7 @@ void ListBoxDrawItem(HWND hwnd, LPHEADLIST lphl, HDC16 hdc, LPLISTSTRUCT lpls,
 
       if (itemState != 0) {
 	dwOldTextColor = SetTextColor(hdc, 0x00FFFFFFL);
-	FillRect16(hdc, rect, GetStockObject(BLACK_BRUSH));
+	FillRect16(hdc, rect, GetStockObject32(BLACK_BRUSH));
       }
 
       if (lphl->dwStyle & LBS_USETABSTOPS) {
@@ -783,7 +783,8 @@ LONG ListBoxDirectory(LPHEADLIST lphl, UINT attrib, LPCSTR filespec)
 
     skip = ret = 0;
     attrib &= ~FA_LABEL;
-    while ((count = DOSFS_FindNext( path, mask, 0, attrib, skip, &entry )) > 0)
+    while ((count = DOSFS_FindNext( path, mask, NULL, 0,
+                                    attrib, skip, &entry )) > 0)
     {
         skip += count;
         if (entry.attr & FA_DIRECTORY)
@@ -1407,7 +1408,7 @@ static LONG LBSetFont(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
   HDC32 hdc;
 
   if (wParam == 0)
-    lphl->hFont = GetStockObject(SYSTEM_FONT);
+    lphl->hFont = GetStockObject32(SYSTEM_FONT);
   else
     lphl->hFont = (HFONT16)wParam;
 
@@ -1436,7 +1437,7 @@ static LONG LBPaint(HWND hwnd, WORD wParam, LONG lParam)
   LPLISTSTRUCT lpls;
   PAINTSTRUCT16 ps;
   HBRUSH16 hBrush;
-  HFONT16 hOldFont;
+  HFONT32 hOldFont;
   HDC16 hdc    = BeginPaint16( hwnd, &ps );
   DC    *dc    = (DC *)GDI_GetObjPtr(hdc, DC_MAGIC);
   RECT16  rect, paintRect, scratchRect;
@@ -1453,11 +1454,11 @@ static LONG LBPaint(HWND hwnd, WORD wParam, LONG lParam)
   GetClientRect16(hwnd, &rect);
   IntersectRect16(&paintRect,&rect,&paintRect);
 
-  hOldFont = SelectObject(hdc, lphl->hFont);
+  hOldFont = SelectObject32(hdc, lphl->hFont);
 
   hBrush = (HBRUSH16)SendMessage32A( lphl->hParent, WM_CTLCOLORLISTBOX,
                                      (WPARAM32)hdc, (LPARAM)hwnd);
-  if (hBrush == 0) hBrush = GetStockObject(WHITE_BRUSH);
+  if (hBrush == 0) hBrush = GetStockObject32(WHITE_BRUSH);
 
   FillRect16(hdc, &rect, hBrush);
 
@@ -1520,7 +1521,7 @@ static LONG LBPaint(HWND hwnd, WORD wParam, LONG lParam)
     lpls = lpls->lpNext;
   }
   ListBoxUpdateWindow(hwnd,lphl,FALSE);
-  SelectObject(hdc,hOldFont);
+  SelectObject32(hdc,hOldFont);
   EndPaint16( hwnd, &ps );
   return 0;
 }
@@ -1537,14 +1538,14 @@ static LONG LBSetFocus(HWND hwnd, WORD wParam, LONG lParam)
        if( lphl->ItemsCount && lphl->ItemFocused != -1)
          {
            HDC32        hDC = GetDC32(hwnd);
-           HFONT16      hOldFont = SelectObject(hDC, lphl->hFont);
+           HFONT32 hOldFont = SelectObject32(hDC, lphl->hFont);
            LPLISTSTRUCT lpls;
 
            lpls = ListBoxGetItem(lphl,lphl->ItemFocused);
            lpls->itemState |= ODS_FOCUS;
 
            ListBoxDrawItem(hwnd,lphl,hDC,lpls,&lpls->itemRect, ODA_FOCUS, lpls->itemState);
-           SelectObject(hDC, hOldFont);
+           SelectObject32(hDC, hOldFont);
            ReleaseDC32(hwnd,hDC);
          }
 
@@ -1567,14 +1568,14 @@ static LONG LBKillFocus(HWND hwnd, WORD wParam, LONG lParam)
            if( lphl->ItemFocused != -1 )
              {
               HDC32        hDC = GetDC32(hwnd);
-              HFONT16      hOldFont = SelectObject(hDC, lphl->hFont);
+              HFONT32 hOldFont = SelectObject32(hDC, lphl->hFont);
               LPLISTSTRUCT lpls;
 
               lpls = ListBoxGetItem(lphl,lphl->ItemFocused);
               lpls->itemState &= ~ODS_FOCUS;
 
               ListBoxDrawItem(hwnd,lphl,hDC,lpls,&lpls->itemRect, ODA_FOCUS, lpls->itemState);
-              SelectObject(hDC, hOldFont);
+              SelectObject32(hDC, hOldFont);
               ReleaseDC32(hwnd,hDC);
              }
            else
diff --git a/controls/menu.c b/controls/menu.c
index ce9a146024550da6574ef755c1004fc5c4f02abc..84433760b252b57476ecda20c31fc53c521a4cdc 100644
--- a/controls/menu.c
+++ b/controls/menu.c
@@ -591,15 +591,15 @@ static void MENU_DrawMenuItem( HWND hwnd, HDC32 hdc, MENUITEM *lpitem,
 
     if (!menuBar && (lpitem->item_flags & MF_MENUBARBREAK))
     {
-	SelectObject( hdc, sysColorObjects.hpenWindowFrame );
+	SelectObject32( hdc, sysColorObjects.hpenWindowFrame );
 	MoveTo( hdc, rect.left, 0 );
-	LineTo( hdc, rect.left, height );
+	LineTo32( hdc, rect.left, height );
     }
     if (lpitem->item_flags & MF_SEPARATOR)
     {
-	SelectObject( hdc, sysColorObjects.hpenWindowFrame );
+	SelectObject32( hdc, sysColorObjects.hpenWindowFrame );
 	MoveTo( hdc, rect.left, rect.top + SEPARATOR_HEIGHT/2 );
-	LineTo( hdc, rect.right, rect.top + SEPARATOR_HEIGHT/2 );
+	LineTo32( hdc, rect.right, rect.top + SEPARATOR_HEIGHT/2 );
 	return;
     }
 
@@ -741,9 +741,9 @@ UINT MENU_DrawMenuBar( HDC32 hDC, LPRECT16 lprect, HWND hwnd,
     if (suppress_draw) return lppop->Height;
     
     FillRect16(hDC, lprect, sysColorObjects.hbrushMenu );
-    SelectObject( hDC, sysColorObjects.hpenWindowFrame );
+    SelectObject32( hDC, sysColorObjects.hpenWindowFrame );
     MoveTo( hDC, lprect->left, lprect->bottom );
-    LineTo( hDC, lprect->right, lprect->bottom );
+    LineTo32( hDC, lprect->right, lprect->bottom );
 
     if (lppop->nItems == 0) return SYSMETRICS_CYMENU;
     for (i = 0; i < lppop->nItems; i++)
diff --git a/controls/scroll.c b/controls/scroll.c
index 1364fc13ea03caaa44e2dbebef011ff5efbacdfb..481f6cbb4c3d4bf8452bf37c27a45ea910d1c8ca 100644
--- a/controls/scroll.c
+++ b/controls/scroll.c
@@ -312,7 +312,7 @@ static void SCROLL_DrawArrows( HDC32 hdc, SCROLLBAR_INFO *infoPtr,
                                BOOL32 top_pressed, BOOL32 bottom_pressed )
 {
     HDC32 hdcMem = CreateCompatibleDC( hdc );
-    HBITMAP32 hbmpPrev = SelectObject( hdcMem, vertical ?
+    HBITMAP32 hbmpPrev = SelectObject32( hdcMem, vertical ?
                                     TOP_ARROW(infoPtr->flags, top_pressed)
                                     : LEFT_ARROW(infoPtr->flags, top_pressed));
     SetStretchBltMode( hdc, STRETCH_DELETESCANS );
@@ -323,9 +323,9 @@ static void SCROLL_DrawArrows( HDC32 hdc, SCROLLBAR_INFO *infoPtr,
                 SYSMETRICS_CXVSCROLL + 1, SYSMETRICS_CYHSCROLL + 1,
                 SRCCOPY );
 
-    SelectObject( hdcMem, vertical ?
-                  BOTTOM_ARROW( infoPtr->flags, bottom_pressed )
-                  : RIGHT_ARROW( infoPtr->flags, bottom_pressed ) );
+    SelectObject32( hdcMem, vertical ?
+                    BOTTOM_ARROW( infoPtr->flags, bottom_pressed )
+                    : RIGHT_ARROW( infoPtr->flags, bottom_pressed ) );
     if (vertical)
         StretchBlt( hdc, rect->left, rect->bottom - arrowSize - 1,
                    rect->right - rect->left, arrowSize + 1,
@@ -338,7 +338,7 @@ static void SCROLL_DrawArrows( HDC32 hdc, SCROLLBAR_INFO *infoPtr,
                    hdcMem, 0, 0,
                    SYSMETRICS_CXVSCROLL + 1, SYSMETRICS_CYHSCROLL + 1,
                    SRCCOPY );
-    SelectObject( hdcMem, hbmpPrev );
+    SelectObject32( hdcMem, hbmpPrev );
     DeleteDC( hdcMem );
 }
 
@@ -389,11 +389,11 @@ static void SCROLL_DrawInterior( HWND32 hwnd, HDC32 hdc, INT32 nBar,
 
       /* Select the correct brush and pen */
 
-    SelectObject( hdc, sysColorObjects.hpenWindowFrame );
+    SelectObject32( hdc, sysColorObjects.hpenWindowFrame );
     if ((flags & ESB_DISABLE_BOTH) == ESB_DISABLE_BOTH)
     {
           /* This ought to be the color of the parent window */
-        SelectObject( hdc, sysColorObjects.hbrushWindow );
+        SelectObject32( hdc, sysColorObjects.hbrushWindow );
     }
     else
     {
@@ -401,9 +401,9 @@ static void SCROLL_DrawInterior( HWND32 hwnd, HDC32 hdc, INT32 nBar,
         {
             HBRUSH32 hbrush = SendMessage32A(GetParent32(hwnd),
                                              WM_CTLCOLORSCROLLBAR, hdc, hwnd );
-            SelectObject( hdc, hbrush );
+            SelectObject32( hdc, hbrush );
         }
-        else SelectObject( hdc, sysColorObjects.hbrushScrollbar );
+        else SelectObject32( hdc, sysColorObjects.hbrushScrollbar );
     }
 
       /* Calculate the scroll rectangle */
@@ -423,10 +423,10 @@ static void SCROLL_DrawInterior( HWND32 hwnd, HDC32 hdc, INT32 nBar,
       /* Draw the scroll bar frame */
 
     MoveTo( hdc, r.left, r.top );
-    LineTo( hdc, r.right-1, r.top );
-    LineTo( hdc, r.right-1, r.bottom-1 );
-    LineTo( hdc, r.left, r.bottom-1 );
-    LineTo( hdc, r.left, r.top );
+    LineTo32( hdc, r.right-1, r.top );
+    LineTo32( hdc, r.right-1, r.bottom-1 );
+    LineTo32( hdc, r.left, r.bottom-1 );
+    LineTo32( hdc, r.left, r.top );
 
       /* Draw the scroll rectangles and thumb */
 
@@ -466,8 +466,8 @@ static void SCROLL_DrawInterior( HWND32 hwnd, HDC32 hdc, INT32 nBar,
 
       /* Draw the thumb */
 
-    SelectObject( hdc, sysColorObjects.hbrushBtnFace );
-    Rectangle( hdc, r.left, r.top, r.right, r.bottom );
+    SelectObject32( hdc, sysColorObjects.hbrushBtnFace );
+    Rectangle32( hdc, r.left, r.top, r.right, r.bottom );
     InflateRect32( &r, -1, -1 );
     GRAPH_DrawReliefRect( hdc, &r, 1, 2, FALSE );
     if (SCROLL_MovingThumb &&
diff --git a/controls/static.c b/controls/static.c
index 09441ac47ccdb28872e1d140cd0a3d26d01a8d80..289b0a599682e02dedfc4f9f583a325e7d79151d 100644
--- a/controls/static.c
+++ b/controls/static.c
@@ -220,10 +220,10 @@ static void STATIC_PaintTextfn( WND *wndPtr, HDC32 hdc )
     if (style & SS_NOPREFIX)
 	wFormat |= DT_NOPREFIX;
 
-    if (infoPtr->hFont) SelectObject( hdc, infoPtr->hFont );
+    if (infoPtr->hFont) SelectObject32( hdc, infoPtr->hFont );
     hBrush = SendMessage32A( GetParent32(wndPtr->hwndSelf), WM_CTLCOLORSTATIC,
                              hdc, wndPtr->hwndSelf );
-    if (!hBrush) hBrush = GetStockObject(WHITE_BRUSH);
+    if (!hBrush) hBrush = GetStockObject32(WHITE_BRUSH);
     FillRect16(hdc, &rc, hBrush);
     if (wndPtr->text) DrawText16( hdc, wndPtr->text, -1, &rc, wFormat );
 }
@@ -231,40 +231,40 @@ static void STATIC_PaintTextfn( WND *wndPtr, HDC32 hdc )
 static void STATIC_PaintRectfn( WND *wndPtr, HDC32 hdc )
 {
     RECT16 rc;
-    HBRUSH16 hBrush;
+    HBRUSH32 hBrush;
 
     GetClientRect16( wndPtr->hwndSelf, &rc);
     
     switch (wndPtr->dwStyle & 0x0f)
     {
     case SS_BLACKRECT:
-	hBrush = CreateSolidBrush(color_windowframe);
+	hBrush = CreateSolidBrush32(color_windowframe);
         FillRect16( hdc, &rc, hBrush );
 	break;
     case SS_GRAYRECT:
-	hBrush = CreateSolidBrush(color_background);
+	hBrush = CreateSolidBrush32(color_background);
         FillRect16( hdc, &rc, hBrush );
 	break;
     case SS_WHITERECT:
-	hBrush = CreateSolidBrush(color_window);
+	hBrush = CreateSolidBrush32(color_window);
         FillRect16( hdc, &rc, hBrush );
 	break;
     case SS_BLACKFRAME:
-	hBrush = CreateSolidBrush(color_windowframe);
+	hBrush = CreateSolidBrush32(color_windowframe);
         FrameRect16( hdc, &rc, hBrush );
 	break;
     case SS_GRAYFRAME:
-	hBrush = CreateSolidBrush(color_background);
+	hBrush = CreateSolidBrush32(color_background);
         FrameRect16( hdc, &rc, hBrush );
 	break;
     case SS_WHITEFRAME:
-	hBrush = CreateSolidBrush(color_window);
+	hBrush = CreateSolidBrush32(color_window);
         FrameRect16( hdc, &rc, hBrush );
 	break;
     default:
         return;
     }
-    DeleteObject( hBrush );
+    DeleteObject32( hBrush );
 }
 
 
diff --git a/controls/status.c b/controls/status.c
index 7996a26dfe3a09104d90847681555589f03f542b..971651ac0955160530cd9f705a207049e1aa0a84 100644
--- a/controls/status.c
+++ b/controls/status.c
@@ -49,19 +49,19 @@ void DrawStatusText32A( HDC32 hdc, LPRECT32 lprc, LPCSTR text, UINT32 style )
     if (style == 0 ||
 	style == SBT_POPOUT) {
 	InflateRect32(&r, -1, -1);
-	SelectObject(hdc, sysColorObjects.hbrushScrollbar);
-	Rectangle(hdc, r.left, r.top, r.right, r.bottom);
+	SelectObject32(hdc, sysColorObjects.hbrushScrollbar);
+	Rectangle32(hdc, r.left, r.top, r.right, r.bottom);
 
 	/* draw border */
-	SelectObject(hdc, sysColorObjects.hpenWindowFrame);
+	SelectObject32(hdc, sysColorObjects.hpenWindowFrame);
 	if (style == 0)
 	    DrawEdge32(hdc, &r, EDGE_SUNKEN, BF_RECT);
 	else
 	    DrawEdge32(hdc, &r, EDGE_RAISED, BF_RECT);
     }
     else if (style == SBT_NOBORDERS) {
-	SelectObject(hdc, sysColorObjects.hbrushScrollbar);
-	Rectangle(hdc, r.left, r.top, r.right, r.bottom);
+	SelectObject32(hdc, sysColorObjects.hbrushScrollbar);
+	Rectangle32(hdc, r.left, r.top, r.right, r.bottom);
     }
     else {	/* fixme for SBT_OWNERDRAW, SBT_RTLREADING */
 	
@@ -69,7 +69,7 @@ void DrawStatusText32A( HDC32 hdc, LPRECT32 lprc, LPCSTR text, UINT32 style )
 
     /* now draw text */
     if ((style != SBT_OWNERDRAW) && text) {
-	SelectObject(hdc, sysColorObjects.hpenWindowText);
+	SelectObject32(hdc, sysColorObjects.hpenWindowText);
 	oldbkmode = SetBkMode(hdc, TRANSPARENT);
 	rt = r;
 	rt.left += 3;
diff --git a/debugger/debug.l b/debugger/debug.l
index 71b2215b65abd376e81394ddd4105377a542038d..7b8d27849d0a23a82d4d77cdc3206f08989dcecf 100644
--- a/debugger/debug.l
+++ b/debugger/debug.l
@@ -1,4 +1,4 @@
-/*
+/* -*-C-*-
  * Lexical scanner for command line parsing
  *
  * Copyright 1993 Eric Youngdale
@@ -26,6 +26,8 @@ void flush_symbols();
 
 #endif  /* DONT_USE_READLINE */
 
+#define YY_NO_UNPUT
+
 static int syntax_error;
 %}
 
diff --git a/files/directory.c b/files/directory.c
index 5d12ef2890b675d8aca79651a3d14fe24d1a0cb8..f83d81bc1fce97eae880ee15de136f6865bd3446 100644
--- a/files/directory.c
+++ b/files/directory.c
@@ -7,6 +7,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <errno.h>
 
 #include "windows.h"
 #include "dos_fs.h"
diff --git a/files/dos_fs.c b/files/dos_fs.c
index 4ed1544fc60d98bcc9f76048e4b6ca816b3ef626..3e3c8dcfa606c125f12854a69ceb2e07614754ab 100644
--- a/files/dos_fs.c
+++ b/files/dos_fs.c
@@ -244,11 +244,11 @@ const char *DOSFS_ToDosDTAFormat( const char *name )
 
 
 /***********************************************************************
- *           DOSFS_Match
+ *           DOSFS_MatchShort
  *
  * Check a DOS file name against a mask (both in FCB format).
  */
-int DOSFS_Match( const char *mask, const char *name )
+static int DOSFS_MatchShort( const char *mask, const char *name )
 {
     int i;
     for (i = 11; i > 0; i--, mask++, name++)
@@ -257,6 +257,40 @@ int DOSFS_Match( const char *mask, const char *name )
 }
 
 
+/***********************************************************************
+ *           DOSFS_MatchLong
+ *
+ * Check a long file name against a mask.
+ */
+static int DOSFS_MatchLong( const char *mask, const char *name,
+                            int case_sensitive )
+{
+    while (*name && *mask)
+    {
+        if (*mask == '*')
+        {
+            mask++;
+            while (*mask == '*') mask++;  /* Skip consecutive '*' */
+            if (!*mask) return 1;
+            if (case_sensitive) while (*name && (*name != *mask)) name++;
+            else while (*name && (toupper(*name) != toupper(*mask))) name++;
+            if (!*name) return 0;
+        }
+        else if (*mask != '?')
+        {
+            if (case_sensitive)
+            {
+                if (*mask != *name) return 0;
+            }
+            else if (toupper(*mask) != toupper(*name)) return 0;
+        }
+        mask++;
+        name++;
+    }
+    return (!*name && !*mask);
+}
+
+
 /***********************************************************************
  *           DOSFS_ToDosDateTime
  *
@@ -273,6 +307,31 @@ void DOSFS_ToDosDateTime( time_t unixtime, WORD *pDate, WORD *pTime )
 }
 
 
+/***********************************************************************
+ *           DOSFS_UnixTimeToFileTime
+ *
+ * Convert a Unix time to FILETIME format.
+ */
+void DOSFS_UnixTimeToFileTime( time_t unixtime, FILETIME *filetime )
+{
+    /* FIXME :-) */
+    filetime->dwLowDateTime  = unixtime;
+    filetime->dwHighDateTime = 0;
+}
+
+
+/***********************************************************************
+ *           DOSFS_FileTimeToUnixTime
+ *
+ * Convert a FILETIME format to Unix time.
+ */
+time_t DOSFS_FileTimeToUnixTime( FILETIME *filetime )
+{
+    /* FIXME :-) */
+    return filetime->dwLowDateTime;
+}
+
+
 /***********************************************************************
  *           DOSFS_Hash
  *
@@ -665,9 +724,12 @@ const char * DOSFS_GetDosTrueName( const char *name, int unix_format )
  *
  * Find the next matching file. Return the number of entries read to find
  * the matching one, or 0 if no more entries.
+ * 'short_mask' is the 8.3 mask (in FCB format), 'long_mask' is the long
+ * file name mask. Either or both can be NULL.
  */
-int DOSFS_FindNext( const char *path, const char *mask, int drive,
-                    BYTE attr, int skip, DOS_DIRENT *entry )
+int DOSFS_FindNext( const char *path, const char *short_mask,
+                    const char *long_mask, int drive, BYTE attr,
+                    int skip, DOS_DIRENT *entry )
 {
     static DIR *dir = NULL;
     struct dirent *dirent;
@@ -714,20 +776,38 @@ int DOSFS_FindNext( const char *path, const char *mask, int drive,
     p = buffer + strlen(buffer);
     attr |= FA_UNUSED | FA_ARCHIVE | FA_RDONLY;
     flags = DRIVE_GetFlags( drive );
+    hash_name = NULL;
 
     while ((dirent = readdir( dir )) != NULL)
     {
         if (skip-- > 0) continue;
         count++;
-        hash_name = DOSFS_Hash( dirent->d_name, TRUE,
-                                !(flags & DRIVE_CASE_SENSITIVE) );
-        if (!DOSFS_Match( mask, hash_name )) continue;
+
         /* Don't return '.' and '..' in the root of the drive */
         if (drive_root && (dirent->d_name[0] == '.') &&
             (!dirent->d_name[1] ||
              ((dirent->d_name[1] == '.') && !dirent->d_name[2]))) continue;
-        lstrcpyn32A( p, dirent->d_name, sizeof(buffer) - (int)(p - buffer) );
 
+        /* Check the long mask */
+
+        if (long_mask)
+        {
+            if (!DOSFS_MatchLong( long_mask, dirent->d_name,
+                                  flags & DRIVE_CASE_SENSITIVE )) continue;
+        }
+
+        /* Check the short mask */
+
+        if (short_mask)
+        {
+            hash_name = DOSFS_Hash( dirent->d_name, TRUE,
+                                    !(flags & DRIVE_CASE_SENSITIVE) );
+            if (!DOSFS_MatchShort( short_mask, hash_name )) continue;
+        }
+
+        /* Check the file attributes */
+
+        lstrcpyn32A( p, dirent->d_name, sizeof(buffer) - (int)(p - buffer) );
         if (!FILE_Stat( buffer, &entry->attr, &entry->size,
                         &entry->date, &entry->time ))
         {
@@ -735,6 +815,12 @@ int DOSFS_FindNext( const char *path, const char *mask, int drive,
             continue;
         }
         if (entry->attr & ~attr) continue;
+
+        /* We now have a matching entry; fill the result and return */
+
+        if (!hash_name)
+            hash_name = DOSFS_Hash( dirent->d_name, TRUE,
+                                    !(flags & DRIVE_CASE_SENSITIVE) );
         strcpy( entry->name, hash_name );
         lstrcpyn32A( entry->unixname, dirent->d_name, sizeof(entry->unixname));
         if (!(flags & DRIVE_CASE_PRESERVING)) AnsiLower( entry->unixname );
@@ -778,6 +864,7 @@ DWORD GetShortPathName32W( LPCWSTR longpath, LPWSTR shortpath, DWORD shortlen )
     return strlen(dostruename);
 }
 
+
 /***********************************************************************
  *           GetFullPathNameA   (KERNEL32.272)
  */
diff --git a/graphics/win16drv/init.c b/graphics/win16drv/init.c
index 7b285fe9e8d67a8a8dbccb97c22cfcda0d73ad35..4b0d8b7a4ba93d3d0de6d65ae30e206d4376bfce 100644
--- a/graphics/win16drv/init.c
+++ b/graphics/win16drv/init.c
@@ -658,7 +658,7 @@ BOOL32 WIN16DRV_CreateDC( DC *dc, LPCSTR driver, LPCSTR device, LPCSTR output,
 
     /* Add this to the DC */
     dc->w.devCaps = printerDevCaps;
-    dc->w.hVisRgn = CreateRectRgn(0, 0, dc->w.devCaps->horzRes, dc->w.devCaps->vertRes);
+    dc->w.hVisRgn = CreateRectRgn32(0, 0, dc->w.devCaps->horzRes, dc->w.devCaps->vertRes);
     dc->w.bitsPerPixel = dc->w.devCaps->bitsPixel;
     
     printf("Got devcaps width %d height %d bits %d planes %d\n",
diff --git a/graphics/x11drv/init.c b/graphics/x11drv/init.c
index bcfe29833f07825c8973bf2327a8b5d59e4c39fd..5d43e8ddb632411f603ed251d47f62e38768cf03 100644
--- a/graphics/x11drv/init.c
+++ b/graphics/x11drv/init.c
@@ -114,15 +114,15 @@ static BOOL32 X11DRV_CreateDC( DC *dc, LPCSTR driver, LPCSTR device,
         physDev->drawable  = bmp->pixmap;
         physDev->gc        = XCreateGC( display, physDev->drawable, 0, NULL );
         dc->w.bitsPerPixel = bmp->bitmap.bmBitsPixel;
-        dc->w.hVisRgn      = CreateRectRgn( 0, 0, bmp->bitmap.bmWidth,
-                                            bmp->bitmap.bmHeight );
+        dc->w.hVisRgn      = CreateRectRgn32( 0, 0, bmp->bitmap.bmWidth,
+                                              bmp->bitmap.bmHeight );
     }
     else
     {
         physDev->drawable  = rootWindow;
         physDev->gc        = XCreateGC( display, physDev->drawable, 0, NULL );
         dc->w.bitsPerPixel = screenDepth;
-        dc->w.hVisRgn      = CreateRectRgn( 0, 0, screenWidth, screenHeight );
+        dc->w.hVisRgn      = CreateRectRgn32( 0, 0, screenWidth, screenHeight);
     }
 
     if (!dc->w.hVisRgn)
diff --git a/if1632/gdi.spec b/if1632/gdi.spec
index e131b6c1f83d0fb2dc55ffd7bd2ffc2c81c96be9..2f0433c5002570a098111fdcf60934aab64b96f1 100644
--- a/if1632/gdi.spec
+++ b/if1632/gdi.spec
@@ -20,24 +20,23 @@ heap	65488  # 65536 - 16 (instance data) - 32 (stock objects)
 16  pascal ScaleWindowExt(word s_word s_word s_word s_word) ScaleWindowExt
 17  pascal OffsetViewportOrg(word s_word s_word) OffsetViewportOrg
 18  pascal ScaleViewportExt(word s_word s_word s_word s_word) ScaleViewportExt
-19  pascal16 LineTo(word s_word s_word) LineTo
+19  pascal16 LineTo(word s_word s_word) LineTo16
 20  pascal   MoveTo(word s_word s_word) MoveTo
-21  pascal16 ExcludeClipRect(word s_word s_word s_word s_word) ExcludeClipRect
-22  pascal16 IntersectClipRect(word s_word s_word s_word s_word)
-             IntersectClipRect
+21  pascal16 ExcludeClipRect(word s_word s_word s_word s_word) ExcludeClipRect16
+22  pascal16 IntersectClipRect(word s_word s_word s_word s_word) IntersectClipRect16
 23  pascal16 Arc(word s_word s_word s_word s_word s_word s_word s_word s_word)
-             Arc
-24  pascal16 Ellipse(word s_word s_word s_word s_word) Ellipse
-25  pascal16 FloodFill(word s_word s_word long) FloodFill
+             Arc16
+24  pascal16 Ellipse(word s_word s_word s_word s_word) Ellipse16
+25  pascal16 FloodFill(word s_word s_word long) FloodFill16
 26  pascal16 Pie(word s_word s_word s_word s_word s_word s_word s_word s_word)
-             Pie
-27  pascal16 Rectangle(word s_word s_word s_word s_word) Rectangle
+             Pie16
+27  pascal16 Rectangle(word s_word s_word s_word s_word) Rectangle16
 28  pascal16 RoundRect(word s_word s_word s_word s_word s_word s_word)
-             RoundRect
+             RoundRect16
 29  pascal16 PatBlt(word s_word s_word s_word s_word long) PatBlt
 30  pascal16 SaveDC(word) SaveDC
-31  pascal   SetPixel(word s_word s_word long) SetPixel
-32  pascal16 OffsetClipRgn(word s_word s_word) OffsetClipRgn
+31  pascal   SetPixel(word s_word s_word long) SetPixel16
+32  pascal16 OffsetClipRgn(word s_word s_word) OffsetClipRgn16
 33  pascal16 TextOut(word s_word s_word ptr word) TextOut16
 34  pascal16 BitBlt( word s_word s_word s_word s_word word s_word s_word long)
              BitBlt
@@ -47,39 +46,39 @@ heap	65488  # 65536 - 16 (instance data) - 32 (stock objects)
 37  pascal16 Polyline (word ptr word) Polyline16
 38  pascal Escape(word word word segptr segptr) Escape
 39  pascal16 RestoreDC(word s_word) RestoreDC
-40  pascal16 FillRgn(word word word) FillRgn
-41  pascal16 FrameRgn(word word word word word) FrameRgn
-42  pascal16 InvertRgn(word word) InvertRgn
-43  pascal16 PaintRgn(word word) PaintRgn
-44  pascal16 SelectClipRgn(word word) SelectClipRgn
-45  pascal16 SelectObject(word word) SelectObject
+40  pascal16 FillRgn(word word word) FillRgn16
+41  pascal16 FrameRgn(word word word word word) FrameRgn16
+42  pascal16 InvertRgn(word word) InvertRgn16
+43  pascal16 PaintRgn(word word) PaintRgn16
+44  pascal16 SelectClipRgn(word word) SelectClipRgn16
+45  pascal16 SelectObject(word word) SelectObject16
 #46  pascal __GP?
-47  pascal16 CombineRgn(word word word s_word) CombineRgn
+47  pascal16 CombineRgn(word word word s_word) CombineRgn16
 48  pascal16 CreateBitmap(word word word word ptr) CreateBitmap
 49  pascal16 CreateBitmapIndirect(ptr) CreateBitmapIndirect16
-50  pascal16 CreateBrushIndirect(ptr) CreateBrushIndirect
+50  pascal16 CreateBrushIndirect(ptr) CreateBrushIndirect16
 51  pascal16 CreateCompatibleBitmap(word word word) CreateCompatibleBitmap
 52  pascal16 CreateCompatibleDC(word) CreateCompatibleDC
 53  pascal16 CreateDC(ptr ptr ptr ptr) CreateDC
-54  pascal16 CreateEllipticRgn(s_word s_word s_word s_word) CreateEllipticRgn
+54  pascal16 CreateEllipticRgn(s_word s_word s_word s_word) CreateEllipticRgn16
 55  pascal16 CreateEllipticRgnIndirect(ptr) CreateEllipticRgnIndirect16
 56  pascal16 CreateFont(s_word s_word s_word s_word s_word word word word
                         word word word word word ptr) CreateFont16
 57  pascal16 CreateFontIndirect(ptr) CreateFontIndirect16
-58  pascal16 CreateHatchBrush(word long) CreateHatchBrush
-60  pascal16 CreatePatternBrush(word) CreatePatternBrush
-61  pascal16 CreatePen(s_word s_word long) CreatePen
-62  pascal16 CreatePenIndirect(ptr) CreatePenIndirect
+58  pascal16 CreateHatchBrush(word long) CreateHatchBrush16
+60  pascal16 CreatePatternBrush(word) CreatePatternBrush16
+61  pascal16 CreatePen(s_word s_word long) CreatePen16
+62  pascal16 CreatePenIndirect(ptr) CreatePenIndirect16
 63  pascal16 CreatePolygonRgn(ptr word word) CreatePolygonRgn16
-64  pascal16 CreateRectRgn(s_word s_word s_word s_word) CreateRectRgn
+64  pascal16 CreateRectRgn(s_word s_word s_word s_word) CreateRectRgn16
 65  pascal16 CreateRectRgnIndirect(ptr) CreateRectRgnIndirect16
-66  pascal16 CreateSolidBrush(long) CreateSolidBrush
+66  pascal16 CreateSolidBrush(long) CreateSolidBrush16
 67  pascal16 DPtoLP(word ptr s_word) DPtoLP16
 68  pascal16 DeleteDC(word) DeleteDC
-69  pascal16 DeleteObject(word) DeleteObject
+69  pascal16 DeleteObject(word) DeleteObject16
 70  pascal16 EnumFonts(word ptr segptr long) THUNK_EnumFonts16
 71  pascal16 EnumObjects(word word segptr long) THUNK_EnumObjects16
-72  pascal16 EqualRgn(word word) EqualRgn
+72  pascal16 EqualRgn(word word) EqualRgn16
 73  pascal16 ExcludeVisRect(word s_word s_word s_word s_word) ExcludeVisRect
 74  pascal GetBitmapBits(word long ptr) GetBitmapBits
 75  pascal GetBkColor(word) GetBkColor
@@ -90,11 +89,11 @@ heap	65488  # 65536 - 16 (instance data) - 32 (stock objects)
 80  pascal16 GetDeviceCaps(word s_word) GetDeviceCaps
 81  pascal16 GetMapMode(word) GetMapMode
 82  pascal16 GetObject(word s_word ptr) GetObject16
-83  pascal GetPixel(word s_word s_word) GetPixel
+83  pascal   GetPixel(word s_word s_word) GetPixel16
 84  pascal16 GetPolyFillMode(word) GetPolyFillMode
 85  pascal16 GetROP2(word) GetROP2
 86  pascal16 GetRelAbs(word) GetRelAbs
-87  pascal16 GetStockObject(word) GetStockObject
+87  pascal16 GetStockObject(word) GetStockObject16
 88  pascal16 GetStretchBltMode(word) GetStretchBltMode
 89  pascal16 GetTextCharacterExtra(word) GetTextCharacterExtra
 90  pascal GetTextColor(word) GetTextColor
@@ -109,9 +108,9 @@ heap	65488  # 65536 - 16 (instance data) - 32 (stock objects)
              IntersectVisRect
 99  pascal16 LPtoDP(word ptr s_word) LPtoDP16
 100 pascal16 LineDDA(s_word s_word s_word s_word segptr long) THUNK_LineDDA16
-101 pascal16 OffsetRgn(word s_word s_word) OffsetRgn
+101 pascal16 OffsetRgn(word s_word s_word) OffsetRgn16
 102 pascal16 OffsetVisRgn(word s_word s_word) OffsetVisRgn
-103 pascal16 PtVisible(word s_word s_word) PtVisible
+103 pascal16 PtVisible(word s_word s_word) PtVisible16
 104 pascal16 RectVisibleOld(word ptr) RectVisible16
 105 pascal16 SelectVisRgn(word word) SelectVisRgn
 106 pascal SetBitmapBits(word long ptr) SetBitmapBits
@@ -135,7 +134,7 @@ heap	65488  # 65536 - 16 (instance data) - 32 (stock objects)
 136 pascal16 RemoveFontResource(ptr) RemoveFontResource
 148 pascal SetBrushOrg(word s_word s_word) SetBrushOrg
 149 pascal GetBrushOrg(word) GetBrushOrg
-150 pascal16 UnrealizeObject(word) UnrealizeObject
+150 pascal16 UnrealizeObject(word) UnrealizeObject16
 151 pascal16 CopyMetaFile(word ptr) CopyMetaFile
 153 pascal16 CreateIC(ptr ptr ptr ptr) CreateIC
 154 pascal GetNearestColor(word long) GetNearestColor
@@ -144,7 +143,7 @@ heap	65488  # 65536 - 16 (instance data) - 32 (stock objects)
 158 pascal16 EnumCallback(ptr ptr word long) WineEnumDFontCallback
 159 pascal16 GetMetaFileBits(word) GetMetaFileBits
 160 pascal16 SetMetaFileBits(word) SetMetaFileBits
-161 pascal16 PtInRegion(word s_word s_word) PtInRegion
+161 pascal16 PtInRegion(word s_word s_word) PtInRegion16
 162 pascal   GetBitmapDimension(word) GetBitmapDimension
 163 pascal   SetBitmapDimension(word s_word s_word) SetBitmapDimension
 169 stub IsDCDirty
@@ -233,7 +232,7 @@ heap	65488  # 65536 - 16 (instance data) - 32 (stock objects)
 345 pascal16 GetTextAlign(word) GetTextAlign
 346 pascal16 SetTextAlign(word word) SetTextAlign
 348 pascal16 Chord(word s_word s_word s_word s_word s_word s_word
-                   s_word s_word) Chord
+                   s_word s_word) Chord16
 349 pascal SetMapperFlags(word long) SetMapperFlags
 350 pascal16 GetCharWidth(word word word ptr) GetCharWidth
 351 pascal16 ExtTextOut(word s_word s_word word ptr ptr word ptr) ExtTextOut16
@@ -251,7 +250,7 @@ heap	65488  # 65536 - 16 (instance data) - 32 (stock objects)
 367 pascal16 AnimatePalette(word word word ptr) AnimatePalette
 368 pascal16 ResizePalette(word word) ResizePalette
 370 pascal16 GetNearestPaletteIndex(word long) GetNearestPaletteIndex
-372 pascal16 ExtFloodFill(word s_word s_word long word) ExtFloodFill
+372 pascal16 ExtFloodFill(word s_word s_word long word) ExtFloodFill16
 373 pascal16 SetSystemPaletteUse(word word) SetSystemPaletteUse
 374 pascal16 GetSystemPaletteUse(word) GetSystemPaletteUse
 375 pascal16 GetSystemPaletteEntries(word word word ptr)
@@ -281,8 +280,8 @@ heap	65488  # 65536 - 16 (instance data) - 32 (stock objects)
 443 pascal16 SetDIBitsToDevice(word s_word s_word word word word word
                                word word ptr ptr word) SetDIBitsToDevice
 444 pascal16 CreateRoundRectRgn(s_word s_word s_word s_word s_word s_word)
-             CreateRoundRectRgn
-445 pascal16 CreateDIBPatternBrush(word word) CreateDIBPatternBrush
+             CreateRoundRectRgn16
+445 pascal16 CreateDIBPatternBrush(word word) CreateDIBPatternBrush16
 449 stub DEVICECOLORMATCH
 450 pascal16 PolyPolygon(word ptr ptr word) PolyPolygon16
 451 pascal16 CreatePolyPolygonRgn(ptr ptr word word) CreatePolyPolygonRgn16
diff --git a/if1632/gdi32.spec b/if1632/gdi32.spec
index 7c00df714e389559b7d960a3aec6837fe368750e..aad949ca84ea0e17ec5f203a5a72d15f33d6dcb4 100644
--- a/if1632/gdi32.spec
+++ b/if1632/gdi32.spec
@@ -9,19 +9,19 @@ base	1
 0004 stub AddFontResourceW
 0005 stub AngleArc
 0006 stub AnimatePalette
-0007 stub Arc
+0007 stdcall Arc(long long long long long long long long long) Arc32
 0008 stub ArcTo
 0009 stub BeginPath
 0010 stdcall BitBlt(long long long long long long long long long) BitBlt
 0011 stub CancelDC
 0012 stub CheckColorsInGamut
 0013 stub ChoosePixelFormat
-0014 stub Chord
+0014 stdcall Chord(long long long long long long long long long) Chord32
 0015 stub CloseEnhMetaFile
 0016 stub CloseFigure
 0017 stub CloseMetaFile
 0018 stub ColorMatchToTarget
-0019 stdcall CombineRgn(long long long long) CombineRgn
+0019 stdcall CombineRgn(long long long long) CombineRgn32
 0020 stub CombineTransform
 0021 stub CopyEnhMetaFileA
 0022 stub CopyEnhMetaFileW
@@ -29,19 +29,19 @@ base	1
 0024 stub CopyMetaFileW
 0025 stdcall CreateBitmap(long long long long ptr) CreateBitmap
 0026 stdcall CreateBitmapIndirect(ptr) CreateBitmapIndirect32
-0027 stub CreateBrushIndirect
+0027 stdcall CreateBrushIndirect(ptr) CreateBrushIndirect32
 0028 stub CreateColorSpaceA
 0029 stub CreateColorSpaceW
 0030 stdcall CreateCompatibleBitmap(long long long) CreateCompatibleBitmap
 0031 stdcall CreateCompatibleDC(long) CreateCompatibleDC
 0032 stub CreateDCA
 0033 stub CreateDCW
-0034 stdcall CreateDIBPatternBrush(long long) CreateDIBPatternBrush
+0034 stdcall CreateDIBPatternBrush(long long) CreateDIBPatternBrush32
 0035 stub CreateDIBPatternBrushPt
 0036 stub CreateDIBSection
 0037 stdcall CreateDIBitmap(long ptr long ptr ptr long) CreateDIBitmap
 0038 stdcall CreateDiscardableBitmap(long long long) CreateDiscardableBitmap
-0039 stdcall CreateEllipticRgn(long long long long) CreateEllipticRgn
+0039 stdcall CreateEllipticRgn(long long long long) CreateEllipticRgn32
 0040 stdcall CreateEllipticRgnIndirect(ptr) CreateEllipticRgnIndirect32
 0041 stub CreateEnhMetaFileA
 0042 stub CreateEnhMetaFileW
@@ -52,34 +52,35 @@ base	1
 0046 stdcall CreateFontW(long long long long long long long long
                         long long long long long ptr) CreateFont32W
 0047 stub CreateHalftonePalette
-0048 stub CreateHatchBrush
+0048 stdcall CreateHatchBrush(long long) CreateHatchBrush32
 0049 stdcall CreateICA(ptr ptr ptr ptr) CreateIC
 0050 stub CreateICW
 0051 stub CreateMetaFileA
 0052 stub CreateMetaFileW
 0053 stdcall CreatePalette(ptr) CreatePalette
-0054 stdcall CreatePatternBrush(long) CreatePatternBrush
-0055 stdcall CreatePen(long long long) CreatePen
-0056 stub CreatePenIndirect
+0054 stdcall CreatePatternBrush(long) CreatePatternBrush32
+0055 stdcall CreatePen(long long long) CreatePen32
+0056 stdcall CreatePenIndirect(ptr) CreatePenIndirect32
 0057 stub CreatePolyPolygonRgn
 0058 stub CreatePolygonRgn
-0059 stdcall CreateRectRgn(long long long long) CreateRectRgn
+0059 stdcall CreateRectRgn(long long long long) CreateRectRgn32
 0060 stdcall CreateRectRgnIndirect(ptr) CreateRectRgnIndirect32
-0061 stdcall CreateRoundRectRgn(long long long long long long) CreateRoundRectRgn
+0061 stdcall CreateRoundRectRgn(long long long long long long)
+             CreateRoundRectRgn32
 0062 stub CreateScalableFontResourceA
 0063 stub CreateScalableFontResourceW
-0064 stdcall CreateSolidBrush(long) CreateSolidBrush
+0064 stdcall CreateSolidBrush(long) CreateSolidBrush32
 0065 stdcall DPtoLP(long ptr long) DPtoLP32
 0066 stub DeleteColorSpace
 0067 stdcall DeleteDC(long) DeleteDC
 0068 stub DeleteEnhMetaFile
 0069 stub DeleteMetaFile
-0070 stdcall DeleteObject(long)	DeleteObject
+0070 stdcall DeleteObject(long)	DeleteObject32
 0071 stub DescribePixelFormat
 0072 stub DeviceCapabilitiesExA
 0073 stub DeviceCapabilitiesExW
 0074 stub DrawEscape
-0075 stub Ellipse
+0075 stdcall Ellipse(long long long long long) Ellipse32
 0076 stub EndDoc
 0077 stub EndPage
 0078 stub EndPath
@@ -93,23 +94,23 @@ base	1
 0086 stub EnumICMProfilesA
 0087 stub EnumICMProfilesW
 0088 stub EnumMetaFile
-0089 stub EnumObjects
-0090 stdcall EqualRgn(long long) EqualRgn
+0089 stdcall EnumObjects(long long ptr long) EnumObjects32
+0090 stdcall EqualRgn(long long) EqualRgn32
 0091 stub Escape
-0092 stub ExcludeClipRect
+0092 stdcall ExcludeClipRect(long long long long long) ExcludeClipRect32
 0093 stub ExtCreatePen
 0094 stub ExtCreateRegion
 0095 stub ExtEscape
-0096 stdcall ExtFloodFill(long long long long long) ExtFloodFill
+0096 stdcall ExtFloodFill(long long long long long) ExtFloodFill32
 0097 stub ExtSelectClipRgn
 0098 stdcall ExtTextOutA(long long long long ptr ptr long ptr) ExtTextOut32A
 0099 stdcall ExtTextOutW(long long long long ptr ptr long ptr) ExtTextOut32W
 0100 stub FillPath
-0101 stub FillRgn
+0101 stdcall FillRgn(long long long) FillRgn32
 0102 stub FixBrushOrgEx
 0103 stub FlattenPath
-0104 stdcall FloodFill(long long long long) FloodFill
-0105 stub FrameRgn
+0104 stdcall FloodFill(long long long long) FloodFill32
+0105 stdcall FrameRgn(long long long long long) FrameRgn32
 0106 stub FreeImageColorMatcher
 0107 stub GdiAssociateObject
 0108 stub GdiCleanCacheDC
@@ -215,7 +216,7 @@ base	1
 0208 stub GetOutlineTextMetricsW
 0209 stdcall GetPaletteEntries(long long long ptr) GetPaletteEntries
 0210 stub GetPath
-0211 stdcall GetPixel(long long long)	GetPixel
+0211 stdcall GetPixel(long long long) GetPixel32
 0212 stub GetPixelFormat
 0213 stub GetPolyFillMode
 0214 stub GetROP2
@@ -224,7 +225,7 @@ base	1
 0217 stub GetRegionData
 0218 stub GetRelAbs
 0219 stdcall GetRgnBox(long ptr) GetRgnBox32
-0220 stdcall GetStockObject(long) GetStockObject
+0220 stdcall GetStockObject(long) GetStockObject32
 0221 stub GetStretchBltMode
 0222 stdcall GetSystemPaletteEntries(long long long ptr) GetSystemPaletteEntries
 0223 stub GetSystemPaletteUse
@@ -249,24 +250,24 @@ base	1
 0242 stub GetWindowExtEx
 0243 stub GetWindowOrgEx
 0244 stub GetWorldTransform
-0245 stub IntersectClipRect
-0246 stdcall InvertRgn(long long) InvertRgn
+0245 stdcall IntersectClipRect(long long long long long) IntersectClipRect32
+0246 stdcall InvertRgn(long long) InvertRgn32
 0247 stdcall LPtoDP(long ptr long) LPtoDP32
 0248 stdcall LineDDA(long long long long ptr long) THUNK_LineDDA32
-0249 stdcall LineTo(long long long) LineTo
+0249 stdcall LineTo(long long long) LineTo32
 0250 stub LoadImageColorMatcherA
 0251 stub LoadImageColorMatcherW
 0252 stub MaskBlt
 0253 stub ModifyWorldTransform
 0254 stdcall MoveToEx(long long long ptr) MoveToEx32
-0255 stub OffsetClipRgn
-0256 stdcall OffsetRgn(long long long) OffsetRgn
+0255 stdcall OffsetClipRgn(long long long) OffsetClipRgn32
+0256 stdcall OffsetRgn(long long long) OffsetRgn32
 0257 stdcall OffsetViewportOrgEx(long long long ptr) OffsetViewportOrgEx32
 0258 stdcall OffsetWindowOrgEx(long long long ptr) OffsetWindowOrgEx32
-0259 stub PaintRgn
+0259 stdcall PaintRgn(long long) PaintRgn32
 0260 stdcall PatBlt(long long long long long long) PatBlt
 0261 stub PathToRegion
-0262 stub Pie
+0262 stdcall Pie(long long long long long long long long long) Pie32
 0263 stub PlayEnhMetaFile
 0264 stub PlayEnhMetaFileRecord
 0265 stub PlayMetaFile
@@ -282,12 +283,12 @@ base	1
 0275 stub Polygon
 0276 stub Polyline
 0277 stub PolylineTo
-0278 stdcall PtInRegion(long long long) PtInRegion
-0279 stdcall PtVisible(long long long) PtVisible
+0278 stdcall PtInRegion(long long long) PtInRegion32
+0279 stdcall PtVisible(long long long) PtVisible32
 0280 stdcall RealizePalette(long) RealizePalette
 0281 stdcall RectInRegion(long ptr) RectInRegion32
 0282 stdcall RectVisible(long ptr) RectVisible32
-0283 stdcall Rectangle(long long long long long) Rectangle
+0283 stdcall Rectangle(long long long long long) Rectangle32
 0284 stub RemoveFontResourceA
 0285 stub RemoveFontResourceTracking
 0286 stub RemoveFontResourceW
@@ -295,15 +296,15 @@ base	1
 0288 stub ResetDCW
 0289 stub ResizePalette
 0290 stdcall RestoreDC(long long) RestoreDC
-0291 stub RoundRect
+0291 stdcall RoundRect(long long long long long long long) RoundRect32
 0292 stdcall SaveDC(long) SaveDC
 0293 stdcall ScaleViewportExtEx(long long long long long ptr) ScaleViewportExtEx32
 0294 stdcall ScaleWindowExtEx(long long long long long ptr) ScaleWindowExtEx32
 0295 stub SelectBrushLocal
 0296 stub SelectClipPath
-0297 stdcall SelectClipRgn(long long) SelectClipRgn
+0297 stdcall SelectClipRgn(long long) SelectClipRgn32
 0298 stub SelectFontLocal
-0299 stdcall SelectObject(long long) SelectObject
+0299 stdcall SelectObject(long long) SelectObject32
 0300 stdcall SelectPalette(long long long) SelectPalette
 0301 stub SetAbortProc
 0302 stub SetArcDirection
@@ -332,7 +333,7 @@ base	1
 0324 stub SetMetaRgn
 0325 stub SetMiterLimit
 0326 stub SetPaletteEntries
-0327 stdcall SetPixel(long long long long)	SetPixel
+0327 stdcall SetPixel(long long long long) SetPixel32
 0328 stub SetPixelFormat
 0329 stub SetPixelV
 0330 stub SetPolyFillMode
@@ -364,7 +365,7 @@ base	1
 0355 stdcall TextOutA(long long long ptr long) TextOut32A
 0356 stdcall TextOutW(long long long ptr long) TextOut32W
 0357 stub UnloadNetworkFonts
-0358 stdcall UnrealizeObject(long) UnrealizeObject
+0358 stdcall UnrealizeObject(long) UnrealizeObject32
 0359 stub UpdateColors
 0360 stub WidenPath
 0361 stub pstackConnect
diff --git a/if1632/thunk.c b/if1632/thunk.c
index 19694ce5fcfe1111dbda35e4d5cc3cb9a89293f2..844154293cfbd657ac84fb4b436dad94ea219365 100644
--- a/if1632/thunk.c
+++ b/if1632/thunk.c
@@ -95,7 +95,18 @@ INT16 THUNK_EnumObjects16( HDC16 hdc, INT16 nObjType,
                            GOBJENUMPROC16 func, LPARAM lParam )
 {
     DECL_THUNK( thunk, func, CallTo16_word_ll );
-    return EnumObjects( hdc, nObjType, (GOBJENUMPROC16)&thunk, lParam );
+    return EnumObjects16( hdc, nObjType, (GOBJENUMPROC16)&thunk, lParam );
+}
+
+
+/***********************************************************************
+ *           THUNK_EnumObjects32   (GDI32.89)
+ */
+INT32 THUNK_EnumObjects32( HDC32 hdc, INT32 nObjType,
+                           GOBJENUMPROC32 func, LPARAM lParam )
+{
+    DECL_THUNK( thunk, func, CallTo32_4 );
+    return EnumObjects32( hdc, nObjType, (GOBJENUMPROC32)&thunk, lParam );
 }
 
 
@@ -302,9 +313,11 @@ FARPROC16 THUNK_SetWindowsHook16( INT16 id, HOOKPROC16 proc )
  */
 BOOL16 THUNK_UnhookWindowsHook16( INT16 id, HOOKPROC16 proc )
 {
-    BOOL16 ret = FALSE;
+    BOOL16 ret;
     THUNK *thunk = THUNK_Find( (FARPROC16)proc );
-    if (thunk) ret = UnhookWindowsHook16( id, (HOOKPROC16)thunk );
+    if (!thunk) return FALSE;
+    ret = UnhookWindowsHook16( id, (HOOKPROC16)thunk );
+    THUNK_Free( thunk );
     return ret;
 }
 
diff --git a/if1632/user.spec b/if1632/user.spec
index 3b40231742d859870c926570345d0fcf2bc84f61..77c3c6286b0ba2c6d4a80ab9cd0bbf898f1b9357 100644
--- a/if1632/user.spec
+++ b/if1632/user.spec
@@ -284,7 +284,7 @@ heap	65520
 278 pascal16 GetDesktopHwnd() GetDesktopHwnd
 279 stub OldSetDeskPattern
 280 stub SetSystemMenu
-281 pascal16 GetSysColorBrush(word) GetSysColorBrush
+281 pascal16 GetSysColorBrush(word) GetSysColorBrush16
 282 pascal16 SelectPalette(word word word) SelectPalette
 283 pascal16 RealizePalette(word) RealizePalette
 284 pascal16 GetFreeSystemResources(word) GetFreeSystemResources
diff --git a/if1632/user32.spec b/if1632/user32.spec
index 59697941018fee116d63de8540c7d6d999b34330..0c123133300522773fca15c6b75f2d989e19a4d3 100644
--- a/if1632/user32.spec
+++ b/if1632/user32.spec
@@ -293,7 +293,7 @@ base	1
 0286 return GetShellWindow 0 0
 0287 stdcall GetSubMenu(long long) GetSubMenu
 0288 stdcall GetSysColor(long) GetSysColor
-0289 stdcall GetSysColorBrush(long) GetSysColorBrush
+0289 stdcall GetSysColorBrush(long) GetSysColorBrush32
 0290 stdcall GetSystemMenu(long long) GetSystemMenu
 0291 stdcall GetSystemMetrics(long) GetSystemMetrics
 0292 stub GetTabbedTextExtentA
diff --git a/if1632/wprocs.spec b/if1632/wprocs.spec
index 3f33bbce5605004ba9b00c4904f39afc41c5a68c..07d63e76ea67464665aa9d4b804b40b8dd73c580 100644
--- a/if1632/wprocs.spec
+++ b/if1632/wprocs.spec
@@ -21,7 +21,6 @@ type	win16
 21 pascal AboutDlgProc(word word word long) AboutDlgProc
 22 pascal ComboLBoxWndProc(word word word long) ComboLBoxWndProc
 24 pascal16 TASK_Reschedule() TASK_Reschedule
-26 register Win32CallToStart() PE_Win32CallToStart
 27 pascal EntryAddrProc(word word) MODULE_GetEntryPoint
 28 pascal MyAlloc(word word word) MODULE_AllocateSegment
 30 pascal FormatCharDlgProc(word word word long) FormatCharDlgProc
@@ -288,9 +287,9 @@ type	win16
 
 # VxDs. The first Vxd is at 400
 #
-#400+VXD_ID register <VxD handler>(word) <VxD handler>
+#400+VXD_ID register <VxD handler>() <VxD handler>
 #
-414 register VXD_Comm(word) VXD_Comm
-#415 register VXD_Printer(word) VXD_Printer
-423 register VXD_Shell(word) VXD_Shell
-433 register VXD_PageFile(word) VXD_PageFile
+414 register VXD_Comm() VXD_Comm
+#415 register VXD_Printer() VXD_Printer
+423 register VXD_Shell() VXD_Shell
+433 register VXD_PageFile() VXD_PageFile
diff --git a/include/brush.h b/include/brush.h
index 25803e66869248635a7f6d4bced180bd48425295..f03ad8fa6a36e101d1f50e1636ea05c88d7aa462 100644
--- a/include/brush.h
+++ b/include/brush.h
@@ -13,12 +13,13 @@
 typedef struct
 {
     GDIOBJHDR   header;
-    LOGBRUSH16  logbrush;
+    LOGBRUSH32  logbrush;
 } BRUSHOBJ;
 
-extern BOOL BRUSH_Init(void);
-extern int BRUSH_GetObject( BRUSHOBJ * brush, int count, LPSTR buffer );
+extern BOOL32 BRUSH_Init(void);
+extern INT16 BRUSH_GetObject16( BRUSHOBJ * brush, INT16 count, LPSTR buffer );
+extern INT32 BRUSH_GetObject32( BRUSHOBJ * brush, INT32 count, LPSTR buffer );
 extern BOOL32 BRUSH_DeleteObject( HBRUSH16 hbrush, BRUSHOBJ * brush );
-extern HBRUSH16 BRUSH_SelectObject(DC * dc, HBRUSH16 hbrush, BRUSHOBJ * brush);
+extern HBRUSH32 BRUSH_SelectObject(DC * dc, HBRUSH32 hbrush, BRUSHOBJ * brush);
 
 #endif  /* __WINE_BRUSH_H */
diff --git a/include/dos_fs.h b/include/dos_fs.h
index 8a2631e7c60598a4d23e4ebfffab511cb6aca9bd..303cbbb07bd04aa90dcd47169614e67d1a84f815 100644
--- a/include/dos_fs.h
+++ b/include/dos_fs.h
@@ -32,8 +32,9 @@ extern const char *DOSFS_IsDevice( const char *name );
 extern const char * DOSFS_GetUnixFileName( const char * name, int check_last );
 extern const char * DOSFS_GetDosTrueName( const char *name, int unix_format );
 extern int DOSFS_GetDosFileName( const char *name, char *buffer, int len );
-extern int DOSFS_FindNext( const char *path, const char *mask, int drive,
-                           BYTE attr, int skip, DOS_DIRENT *entry );
+extern int DOSFS_FindNext( const char *path, const char *short_mask,
+                           const char *long_mask, int drive, BYTE attr,
+                           int skip, DOS_DIRENT *entry );
 
 
 extern int DOS_GetFreeSpace(int drive, long *size, long *available);
diff --git a/include/nonclient.h b/include/nonclient.h
index 764f08198e379e35f60ba5989f09cdec875478b5..e8a5980e11b8cb8f27f26f2ada2f6e5c688c456f 100644
--- a/include/nonclient.h
+++ b/include/nonclient.h
@@ -9,16 +9,17 @@
 
 #include "win.h"
 
-extern void NC_GetMinMaxInfo( HWND hwnd, POINT16 *maxSize, POINT16 *maxPos,
+extern void NC_GetMinMaxInfo( WND *pWnd, POINT16 *maxSize, POINT16 *maxPos,
                               POINT16 *minTrack, POINT16 *maxTrack );
-extern void NC_DoNCPaint( HWND hwnd, HRGN32 clip, BOOL suppress_menupaint );
-extern LONG NC_HandleNCPaint( HWND hwnd , HRGN32 clip);
+extern void NC_DoNCPaint( HWND32 hwnd, HRGN32 clip, BOOL32 suppress_menupaint);
+extern LONG NC_HandleNCPaint( HWND32 hwnd , HRGN32 clip);
 extern LONG NC_HandleNCActivate( WND *pwnd, WPARAM16 wParam );
 extern LONG NC_HandleNCCalcSize( WND *pWnd, RECT16 *winRect );
-extern LONG NC_HandleNCHitTest( HWND hwnd, POINT16 pt );
-extern LONG NC_HandleNCLButtonDown( HWND hwnd, WPARAM16 wParam, LPARAM lParam );
+extern LONG NC_HandleNCHitTest( HWND32 hwnd, POINT16 pt );
+extern LONG NC_HandleNCLButtonDown( HWND32 hwnd, WPARAM16 wParam,
+                                    LPARAM lParam );
 extern LONG NC_HandleNCLButtonDblClk( WND *pWnd, WPARAM16 wParam, LPARAM lParam);
-extern LONG NC_HandleSysCommand( HWND hwnd, WPARAM16 wParam, POINT16 pt );
-extern LONG NC_HandleSetCursor( HWND hwnd, WPARAM16 wParam, LPARAM lParam );
+extern LONG NC_HandleSysCommand( HWND32 hwnd, WPARAM16 wParam, POINT16 pt );
+extern LONG NC_HandleSetCursor( HWND32 hwnd, WPARAM16 wParam, LPARAM lParam );
 
 #endif /* __WINE_NONCLIENT_H */
diff --git a/include/pen.h b/include/pen.h
index 0a43406436f950b74953835cb8ff0260b8a82f96..ab4f5b2e487efbd3786e2ba1111fb3f20261a581 100644
--- a/include/pen.h
+++ b/include/pen.h
@@ -13,10 +13,11 @@
 typedef struct
 {
     GDIOBJHDR   header;
-    LOGPEN16    logpen;
+    LOGPEN32    logpen;
 } PENOBJ;
 
-extern int PEN_GetObject( PENOBJ * pen, int count, LPSTR buffer );
-extern HPEN16 PEN_SelectObject( DC * dc, HPEN16 hpen, PENOBJ * pen );
+extern INT16 PEN_GetObject16( PENOBJ * pen, INT16 count, LPSTR buffer );
+extern INT32 PEN_GetObject32( PENOBJ * pen, INT32 count, LPSTR buffer );
+extern HPEN32 PEN_SelectObject( DC * dc, HPEN32 hpen, PENOBJ * pen );
 
 #endif  /* __WINE_PEN_H */
diff --git a/include/region.h b/include/region.h
index 5aecf71f80b933027164ec1c4a2f24c3091474be..eb44f4f838f0a53d9ced2940f76a1842bb3e9fbe 100644
--- a/include/region.h
+++ b/include/region.h
@@ -17,8 +17,8 @@ typedef struct
 } RGNOBJ;
 
 
-extern BOOL16 REGION_DeleteObject( HRGN32 hrgn, RGNOBJ * obj );
-extern BOOL16 REGION_UnionRectWithRgn( HRGN32 hrgn, LPRECT16 lpRect );
-extern BOOL16 REGION_FrameRgn( HRGN32 dest, HRGN32 src, INT32 x, INT32 y );
+extern BOOL32 REGION_DeleteObject( HRGN32 hrgn, RGNOBJ * obj );
+extern BOOL32 REGION_UnionRectWithRgn( HRGN32 hrgn, LPRECT16 lpRect );
+extern BOOL32 REGION_FrameRgn( HRGN32 dest, HRGN32 src, INT32 x, INT32 y );
 
 #endif  /* __WINE_REGION_H */
diff --git a/include/syscolor.h b/include/syscolor.h
index a7b58091475b936e84a4a249a491c4c1dd04d703..c8fa8c92e174dba742861a116ee34c809292cbd0 100644
--- a/include/syscolor.h
+++ b/include/syscolor.h
@@ -11,27 +11,27 @@
 
 struct SysColorObjects
 {
-    HBRUSH16 hbrushScrollbar;        /* COLOR_SCROLLBAR           */
+    HBRUSH32 hbrushScrollbar;        /* COLOR_SCROLLBAR           */
                                      /* COLOR_BACKGROUND          */
-    HBRUSH16 hbrushActiveCaption;    /* COLOR_ACTIVECAPTION       */
-    HBRUSH16 hbrushInactiveCaption;  /* COLOR_INACTIVECAPTION     */
-    HBRUSH16 hbrushMenu;             /* COLOR_MENU                */
-    HBRUSH16 hbrushWindow;           /* COLOR_WINDOW              */
-    HPEN16   hpenWindowFrame;        /* COLOR_WINDOWFRAME         */
+    HBRUSH32 hbrushActiveCaption;    /* COLOR_ACTIVECAPTION       */
+    HBRUSH32 hbrushInactiveCaption;  /* COLOR_INACTIVECAPTION     */
+    HBRUSH32 hbrushMenu;             /* COLOR_MENU                */
+    HBRUSH32 hbrushWindow;           /* COLOR_WINDOW              */
+    HPEN32   hpenWindowFrame;        /* COLOR_WINDOWFRAME         */
                                      /* COLOR_MENUTEXT            */
-    HPEN16   hpenWindowText;         /* COLOR_WINDOWTEXT          */
+    HPEN32   hpenWindowText;         /* COLOR_WINDOWTEXT          */
                                      /* COLOR_CAPTIONTEXT         */
-    HBRUSH16 hbrushActiveBorder;     /* COLOR_ACTIVEBORDER        */
-    HBRUSH16 hbrushInactiveBorder;   /* COLOR_INACTIVEBORDER      */
+    HBRUSH32 hbrushActiveBorder;     /* COLOR_ACTIVEBORDER        */
+    HBRUSH32 hbrushInactiveBorder;   /* COLOR_INACTIVEBORDER      */
                                      /* COLOR_APPWORKSPACE        */
-    HBRUSH16 hbrushHighlight;        /* COLOR_HIGHLIGHT           */
+    HBRUSH32 hbrushHighlight;        /* COLOR_HIGHLIGHT           */
                                      /* COLOR_HIGHLIGHTTEXT       */
-    HBRUSH16 hbrushBtnFace;          /* COLOR_BTNFACE             */
-    HBRUSH16 hbrushBtnShadow;        /* COLOR_BTNSHADOW           */
+    HBRUSH32 hbrushBtnFace;          /* COLOR_BTNFACE             */
+    HBRUSH32 hbrushBtnShadow;        /* COLOR_BTNSHADOW           */
                                      /* COLOR_GRAYTEXT            */
                                      /* COLOR_BTNTEXT             */
                                      /* COLOR_INACTIVECAPTIONTEXT */
-    HBRUSH16 hbrushBtnHighlight;     /* COLOR_BTNHIGHLIGHT        */
+    HBRUSH32 hbrushBtnHighlight;     /* COLOR_BTNHIGHLIGHT        */
 };
 
 extern void SYSCOLOR_Init(void);
diff --git a/include/windows.h b/include/windows.h
index 3210170b356a6bf8d252cbc42465ba25466b829a..7359e0b814b8dce2f792373d6bba46da54b68693 100644
--- a/include/windows.h
+++ b/include/windows.h
@@ -805,16 +805,16 @@ DECL_WINELIB_TYPE(LPBITMAP);
 
 typedef struct
 { 
-    UINT16     lbStyle; 
+    UINT16     lbStyle;
     COLORREF   lbColor WINE_PACKED;
-    INT16      lbHatch; 
+    INT16      lbHatch;
 } LOGBRUSH16, *LPLOGBRUSH16;
 
 typedef struct
 { 
-    UINT32     lbStyle; 
+    UINT32     lbStyle;
     COLORREF   lbColor;
-    INT32      lbHatch; 
+    INT32      lbHatch;
 } LOGBRUSH32, *LPLOGBRUSH32;
 
 DECL_WINELIB_TYPE(LOGBRUSH);
@@ -3639,6 +3639,7 @@ BOOL16     DCHook(HDC16,WORD,DWORD,LPARAM);
 VOID       DirectedYield(HTASK16);
 HGLOBAL16  DirectResAlloc(HINSTANCE16,WORD,UINT16);
 BOOL16     EnableHardwareInput(BOOL16);
+INT16      ExcludeVisRect(HDC16,INT16,INT16,INT16,INT16);
 HANDLE16   FarGetOwner(HGLOBAL16);
 VOID       FarSetOwner(HGLOBAL16,HANDLE16);
 VOID       FillWindow(HWND16,HWND16,HDC16,HBRUSH16);
@@ -3673,12 +3674,16 @@ WORD       GlobalDOSFree(WORD);
 WORD       GlobalPageLock(HGLOBAL16);
 WORD       GlobalPageUnlock(HGLOBAL16);
 INT16      InitApp(HINSTANCE16);
+INT16      IntersectVisRect(HDC16,INT16,INT16,INT16,INT16);
+BOOL16     IsGDIObject(HGDIOBJ16);
 BOOL16     IsSharedSelector(HANDLE16);
 BOOL16     IsTask(HTASK16);
 HTASK16    IsTaskLocked(void);
 BOOL16     LocalInit(HANDLE16,WORD,WORD);
 HTASK16    LockCurrentTask(BOOL16);
+DWORD      MoveTo(HDC16,INT16,INT16);
 DWORD      OffsetViewportOrg(HDC16,INT16,INT16);
+INT16      OffsetVisRgn(HDC16,INT16,INT16);
 DWORD      OffsetWindowOrg(HDC16,INT16,INT16);
 VOID       OldYield(void);
 INT16      OpenComm(LPCSTR,UINT16,UINT16);
@@ -3686,9 +3691,12 @@ VOID       PaintRect(HWND16,HWND16,HDC16,HBRUSH16,const RECT16*);
 VOID       PostEvent(HTASK16);
 WORD       PrestoChangoSelector(WORD,WORD);
 INT16      ReadComm(INT16,LPSTR,INT16);
+INT16      RestoreVisRgn(HDC16);
+HRGN16     SaveVisRgn(HDC16);
 DWORD      ScaleViewportExt(HDC16,INT16,INT16,INT16,INT16);
 DWORD      ScaleWindowExt(HDC16,INT16,INT16,INT16,INT16);
 WORD       SelectorAccessRights(WORD,WORD,WORD);
+INT16      SelectVisRgn(HDC16,HRGN16);
 DWORD      SetBitmapDimension(HBITMAP16,INT16,INT16);
 DWORD      SetBrushOrg(HDC16,INT16,INT16);
 UINT16*    SetCommEventMask(INT16,UINT16);
@@ -3740,6 +3748,9 @@ DWORD      GetFileInformationByHandle(HFILE,BY_HANDLE_FILE_INFORMATION*);
 VOID       GetLocalTime(LPSYSTEMTIME);
 DWORD      GetLogicalDrives(void);
 HANDLE32   GetProcessHeap(void);
+DWORD      GetShortPathName32A(LPCSTR,LPSTR,DWORD);
+DWORD      GetShortPathName32W(LPCWSTR,LPWSTR,DWORD);
+#define    GetShortPathName WINELIB_NAME_AW(GetShortPathName)
 HFILE      GetStdHandle(DWORD);
 BOOL32     GetSystemPowerStatus(LPSYSTEM_POWER_STATUS);
 VOID       GetSystemTime(LPSYSTEMTIME);
@@ -3801,21 +3812,14 @@ BOOL32     WriteFile(HFILE,LPVOID,DWORD,LPDWORD,LPOVERLAPPED);
 
 BOOL16     CheckDlgButton(HWND32,INT32,UINT32);
 BOOL16     CheckRadioButton(HWND32,UINT32,UINT32,UINT32);
-INT16      CombineRgn(HRGN32,HRGN32,HRGN32,INT32);
 LONG       CopyLZFile(HFILE,HFILE);
 HBITMAP16  CreateBitmap(INT32,INT32,UINT32,UINT32,LPCVOID);
 BOOL16     CreateCaret(HWND32,HBITMAP32,INT32,INT32);
 HBITMAP16  CreateCompatibleBitmap(HDC32,INT32,INT32);
 HBITMAP16  CreateDiscardableBitmap(HDC32,INT32,INT32);
-HRGN16     CreateEllipticRgn(INT32,INT32,INT32,INT32);
-HRGN16     CreateRectRgn(INT32,INT32,INT32,INT32);
-HRGN16     CreateRoundRectRgn(INT32,INT32,INT32,INT32,INT32,INT32);
 BOOL16     DestroyCaret(void);
 BOOL16     EndDialog(HWND32,INT32);
-BOOL16     EqualRgn(HRGN32,HRGN32);
 INT16      ExcludeUpdateRgn(HDC32,HWND32);
-BOOL16     ExtFloodFill(HDC32,INT32,INT32,COLORREF,UINT32);
-BOOL16     FloodFill(HDC32,INT32,INT32,COLORREF);
 DWORD      GetAppCompatFlags(HTASK32);
 LONG       GetBitmapBits(HBITMAP32,LONG,LPVOID);
 WORD       GetClassWord(HWND32,INT32);
@@ -3833,9 +3837,7 @@ void       LZDone(void);
 HFILE      LZInit(HFILE);
 LONG       LZSeek(HFILE,LONG,INT32);
 INT16      LZStart(void);
-INT16      OffsetRgn(HRGN32,INT32,INT32);
 HFILE      OpenFile(LPCSTR,OFSTRUCT*,UINT32);
-BOOL16     PtInRegion(HRGN32,INT32,INT32);
 UINT16     RealizePalette(HDC32);
 DWORD      RegCloseKey(HKEY);
 DWORD      RegFlushKey(HKEY);
@@ -3879,6 +3881,9 @@ BOOL16     AppendMenu16(HMENU16,UINT16,UINT16,SEGPTR);
 BOOL32     AppendMenu32A(HMENU32,UINT32,UINT32,LPCSTR);
 BOOL32     AppendMenu32W(HMENU32,UINT32,UINT32,LPCWSTR);
 #define    AppendMenu WINELIB_NAME_AW(AppendMenu)
+BOOL16     Arc16(HDC16,INT16,INT16,INT16,INT16,INT16,INT16,INT16,INT16);
+BOOL32     Arc32(HDC32,INT32,INT32,INT32,INT32,INT32,INT32,INT32,INT32);
+#define    Arc WINELIB_NAME(Arc)
 HDC16      BeginPaint16(HWND16,LPPAINTSTRUCT16);
 HDC32      BeginPaint32(HWND32,LPPAINTSTRUCT32);
 #define    BeginPaint WINELIB_NAME(BeginPaint)
@@ -3930,6 +3935,9 @@ BOOL32     CharToOemBuff32W(LPCWSTR,LPSTR,DWORD);
 HWND16     ChildWindowFromPoint16(HWND16,POINT16);
 HWND32     ChildWindowFromPoint32(HWND32,POINT32);
 #define    ChildWindowFromPoint WINELIB_NAME(ChildWindowFromPoint)
+BOOL16     Chord16(HDC16,INT16,INT16,INT16,INT16,INT16,INT16,INT16,INT16);
+BOOL32     Chord32(HDC32,INT32,INT32,INT32,INT32,INT32,INT32,INT32,INT32);
+#define    Chord WINELIB_NAME(Chord)
 INT16      ClearCommBreak16(INT16);
 BOOL32     ClearCommBreak32(INT32);
 #define    ClearCommBreak WINELIB_NAME(ClearCommBreak)
@@ -3942,6 +3950,9 @@ BOOL32     ClipCursor32(const RECT32*);
 HMETAFILE16 CloseMetaFile16(HDC16);
 HMETAFILE32 CloseMetaFile32(HDC32);
 #define    CloseMetaFile WINELIB_NAME(CloseMetaFile)
+INT16      CombineRgn16(HRGN16,HRGN16,HRGN16,INT16);
+INT32      CombineRgn32(HRGN32,HRGN32,HRGN32,INT32);
+#define    CombineRgn WINELIB_NAME(CombineRgn)
 UINT16     CompareString16(DWORD,DWORD,LPCSTR,DWORD,LPCSTR,DWORD);
 UINT32     CompareString32A(DWORD,DWORD,LPCSTR,DWORD,LPCSTR,DWORD);
 UINT32     CompareString32W(DWORD,DWORD,LPCWSTR,DWORD,LPCWSTR,DWORD);
@@ -3958,6 +3969,9 @@ BOOL32     CopyRect32(RECT32*,const RECT32*);
 HBITMAP16  CreateBitmapIndirect16(const BITMAP16*);
 HBITMAP32  CreateBitmapIndirect32(const BITMAP32*);
 #define    CreateBitmapIndirect WINELIB_NAME(CreateBitmapIndirect)
+HBRUSH16   CreateBrushIndirect16(const LOGBRUSH16*);
+HBRUSH32   CreateBrushIndirect32(const LOGBRUSH32*);
+#define    CreateBrushIndirect WINELIB_NAME(CreateBrushIndirect)
 HWND16     CreateDialog16(HINSTANCE16,SEGPTR,HWND16,DLGPROC16);
 #define    CreateDialog32A(inst,ptr,hwnd,dlg) \
            CreateDialogParam32A(inst,ptr,hwnd,dlg,0)
@@ -3978,10 +3992,16 @@ HWND16     CreateDialogParam16(HINSTANCE16,SEGPTR,HWND16,DLGPROC16,LPARAM);
 HWND32     CreateDialogParam32A(HINSTANCE32,LPCSTR,HWND32,DLGPROC32,LPARAM);
 HWND32     CreateDialogParam32W(HINSTANCE32,LPCWSTR,HWND32,DLGPROC32,LPARAM);
 #define    CreateDialogParam WINELIB_NAME_AW(CreateDialogParam)
+HBRUSH16   CreateDIBPatternBrush16(HGLOBAL16,UINT16);
+HBRUSH32   CreateDIBPatternBrush32(HGLOBAL32,UINT32);
+#define    CreateDIBPatternBrush WINELIB_NAME(CreateDIBPatternBrush)
 BOOL16     CreateDirectory16(LPCSTR,LPVOID);
 BOOL32     CreateDirectory32A(LPCSTR,LPSECURITY_ATTRIBUTES);
 BOOL32     CreateDirectory32W(LPCWSTR,LPSECURITY_ATTRIBUTES);
 #define    CreateDirectory WINELIB_NAME_AW(CreateDirectory)
+HRGN16     CreateEllipticRgn16(INT16,INT16,INT16,INT16);
+HRGN32     CreateEllipticRgn32(INT32,INT32,INT32,INT32);
+#define    CreateEllipticRgn WINELIB_NAME(CreateEllipticRgn)
 HRGN16     CreateEllipticRgnIndirect16(const RECT16 *);
 HRGN32     CreateEllipticRgnIndirect32(const RECT32 *);
 #define    CreateEllipticRgnIndirect WINELIB_NAME(CreateEllipticRgnIndirect)
@@ -3993,19 +4013,40 @@ HFONT16    CreateFontIndirect16(const LOGFONT16*);
 HFONT32    CreateFontIndirect32A(const LOGFONT32A*);
 HFONT32    CreateFontIndirect32W(const LOGFONT32W*);
 #define    CreateFontIndirect WINELIB_NAME_AW(CreateFontIndirect)
+HBRUSH16   CreateHatchBrush16(INT16,COLORREF);
+HBRUSH32   CreateHatchBrush32(INT32,COLORREF);
+#define    CreateHatchBrush WINELIB_NAME(CreateHatchBrush)
 HDC16      CreateMetaFile16(LPCSTR);
 HDC32      CreateMetaFile32A(LPCSTR);
 HDC32      CreateMetaFile32W(LPCWSTR);
 #define    CreateMetaFile WINELIB_NAME_AW(CreateMetaFile)
+HBRUSH16   CreatePatternBrush16(HBITMAP16);
+HBRUSH32   CreatePatternBrush32(HBITMAP32);
+#define    CreatePatternBrush WINELIB_NAME(CreatePatternBrush)
+HPEN16     CreatePen16(INT16,INT16,COLORREF);
+HPEN32     CreatePen32(INT32,INT32,COLORREF);
+#define    CreatePen WINELIB_NAME(CreatePen)
+HPEN16     CreatePenIndirect16(const LOGPEN16*);
+HPEN32     CreatePenIndirect32(const LOGPEN32*);
+#define    CreatePenIndirect WINELIB_NAME(CreatePenIndirect)
 HRGN16     CreatePolyPolygonRgn16(const POINT16*,const INT16*,INT16,INT16);
 HRGN32     CreatePolyPolygonRgn32(const POINT32*,const INT32*,INT32,INT32);
 #define    CreatePolyPolygonRgn WINELIB_NAME(CreatePolyPolygonRgn)
 HRGN16     CreatePolygonRgn16(const POINT16*,INT16,INT16);
 HRGN32     CreatePolygonRgn32(const POINT32*,INT32,INT32);
 #define    CreatePolygonRgn WINELIB_NAME(CreatePolygonRgn)
+HRGN16     CreateRectRgn16(INT16,INT16,INT16,INT16);
+HRGN32     CreateRectRgn32(INT32,INT32,INT32,INT32);
+#define    CreateRectRgn WINELIB_NAME(CreateRectRgn)
 HRGN16     CreateRectRgnIndirect16(const RECT16*);
 HRGN32     CreateRectRgnIndirect32(const RECT32*);
 #define    CreateRectRgnIndirect WINELIB_NAME(CreateRectRgnIndirect)
+HRGN16     CreateRoundRectRgn16(INT16,INT16,INT16,INT16,INT16,INT16);
+HRGN32     CreateRoundRectRgn32(INT32,INT32,INT32,INT32,INT32,INT32);
+#define    CreateRoundRectRgn WINELIB_NAME(CreateRoundRectRgn)
+HBRUSH16   CreateSolidBrush16(COLORREF);
+HBRUSH32   CreateSolidBrush32(COLORREF);
+#define    CreateSolidBrush WINELIB_NAME(CreateSolidBrush)
 HWND16     CreateWindow16(LPCSTR,LPCSTR,DWORD,INT16,INT16,INT16,INT16,HWND16,HMENU16,HINSTANCE16,LPVOID);
 #define    CreateWindow32A(className,titleName,style,x,y,width,height,\
                            parent,menu,instance,param) \
@@ -4043,6 +4084,9 @@ BOOL32     DeleteFile32W(LPCWSTR);
 BOOL16     DeleteMetaFile16(HMETAFILE16);
 BOOL32     DeleteMetaFile32(HMETAFILE32);
 #define    DeleteMetaFile WINELIB_NAME(DeleteMetaFile)
+BOOL16     DeleteObject16(HGDIOBJ16);
+BOOL32     DeleteObject32(HGDIOBJ32);
+#define    DeleteObject WINELIB_NAME(DeleteObject)
 INT16      DialogBox16(HINSTANCE16,SEGPTR,HWND16,DLGPROC16);
 #define    DialogBox32A(inst,template,owner,func) \
            DialogBoxParam32A(inst,template,owner,func,0)
@@ -4083,6 +4127,9 @@ INT16      DrawText16(HDC16,LPCSTR,INT16,LPRECT16,UINT16);
 INT32      DrawText32A(HDC32,LPCSTR,INT32,LPRECT32,UINT32);
 INT32      DrawText32W(HDC32,LPCWSTR,INT32,LPRECT32,UINT32);
 #define    DrawText WINELIB_NAME_AW(DrawText)
+BOOL16     Ellipse16(HDC16,INT16,INT16,INT16,INT16);
+BOOL32     Ellipse32(HDC32,INT32,INT32,INT32,INT32);
+#define    Ellipse WINELIB_NAME(Ellipse)
 BOOL16     EnableScrollBar16(HWND16,INT16,UINT16);
 BOOL32     EnableScrollBar32(HWND32,INT32,UINT32);
 #define    EnableScrollBar WINELIB_NAME(EnableScrollBar)
@@ -4092,6 +4139,9 @@ BOOL32     EndPaint32(HWND32,const PAINTSTRUCT32*);
 BOOL16     EnumChildWindows16(HWND16,WNDENUMPROC16,LPARAM);
 BOOL32     EnumChildWindows32(HWND32,WNDENUMPROC32,LPARAM);
 #define    EnumChildWindows WINELIB_NAME(EnumChildWindows)
+INT16      EnumObjects16(HDC16,INT16,GOBJENUMPROC16,LPARAM);
+INT32      EnumObjects32(HDC32,INT32,GOBJENUMPROC32,LPARAM);
+#define    EnumObjects WINELIB_NAME(EnumObjects)
 INT16      EnumProps16(HWND16,PROPENUMPROC16);
 INT32      EnumProps32A(HWND32,PROPENUMPROC32A);
 INT32      EnumProps32W(HWND32,PROPENUMPROC32W);
@@ -4106,9 +4156,18 @@ BOOL32     EnumWindows32(WNDENUMPROC32,LPARAM);
 BOOL16     EqualRect16(const RECT16*,const RECT16*);
 BOOL32     EqualRect32(const RECT32*,const RECT32*);
 #define    EqualRect WINELIB_NAME(EqualRect)
+BOOL16     EqualRgn16(HRGN16,HRGN16);
+BOOL32     EqualRgn32(HRGN32,HRGN32);
+#define    EqualRgn WINELIB_NAME(EqualRgn)
 LONG       EscapeCommFunction16(UINT16,UINT16);
 BOOL32     EscapeCommFunction32(INT32,UINT32);
 #define    EscapeCommFunction WINELIB_NAME(EscapeCommFunction)
+INT16      ExcludeClipRect16(HDC16,INT16,INT16,INT16,INT16);
+INT32      ExcludeClipRect32(HDC32,INT32,INT32,INT32,INT32);
+#define    ExcludeClipRect WINELIB_NAME(ExcludeClipRect)
+BOOL16     ExtFloodFill16(HDC16,INT16,INT16,COLORREF,UINT16);
+BOOL32     ExtFloodFill32(HDC32,INT32,INT32,COLORREF,UINT32);
+#define    ExtFloodFill WINELIB_NAME(ExtFloodFill)
 BOOL16     ExtTextOut16(HDC16,INT16,INT16,UINT16,const RECT16*,LPCSTR,UINT16,const INT16*);
 BOOL32     ExtTextOut32A(HDC32,INT32,INT32,UINT32,const RECT32*,LPCSTR,UINT32,const INT32*);
 BOOL32     ExtTextOut32W(HDC32,INT32,INT32,UINT32,const RECT32*,LPCWSTR,UINT32,const INT32*);
@@ -4116,6 +4175,9 @@ BOOL32     ExtTextOut32W(HDC32,INT32,INT32,UINT32,const RECT32*,LPCWSTR,UINT32,c
 INT16      FillRect16(HDC16,const RECT16*,HBRUSH16);
 INT32      FillRect32(HDC32,const RECT32*,HBRUSH32);
 #define    FillRect WINELIB_NAME(FillRect)
+BOOL16     FillRgn16(HDC16,HRGN16,HBRUSH16);
+BOOL32     FillRgn32(HDC32,HRGN32,HBRUSH32);
+#define    FillRgn WINELIB_NAME(FillRgn)
 BOOL16     FindClose16(HANDLE16);
 BOOL32     FindClose32(HANDLE32);
 #define    FindClose WINELIB_NAME(FindClose)
@@ -4139,9 +4201,15 @@ HWND16     FindWindowEx16(HWND16,HWND16,SEGPTR,LPCSTR);
 HWND32     FindWindowEx32A(HWND32,HWND32,LPCSTR,LPCSTR);
 HWND32     FindWindowEx32W(HWND32,HWND32,LPCWSTR,LPCWSTR);
 #define    FindWindowEx WINELIB_NAME_AW(FindWindowEx)
+BOOL16     FloodFill16(HDC16,INT16,INT16,COLORREF);
+BOOL32     FloodFill32(HDC32,INT32,INT32,COLORREF);
+#define    FloodFill WINELIB_NAME(FloodFill)
 INT16      FrameRect16(HDC16,const RECT16*,HBRUSH16);
 INT32      FrameRect32(HDC32,const RECT32*,HBRUSH32);
 #define    FrameRect WINELIB_NAME(FrameRect)
+BOOL16     FrameRgn16(HDC16,HRGN16,HBRUSH16,INT16,INT16);
+BOOL32     FrameRgn32(HDC32,HRGN32,HBRUSH32,INT32,INT32);
+#define    FrameRgn WINELIB_NAME(FrameRgn)
 BOOL16     FreeModule16(HMODULE16);
 #define    FreeModule32(handle) FreeLibrary32(handle)
 #define    FreeModule WINELIB_NAME(FreeModule)
@@ -4263,6 +4331,9 @@ INT32      GetObject32W(HANDLE32,INT32,LPVOID);
 HWND16     GetParent16(HWND16);
 HWND32     GetParent32(HWND32);
 #define    GetParent WINELIB_NAME(GetParent)
+COLORREF   GetPixel16(HDC16,INT16,INT16);
+COLORREF   GetPixel32(HDC32,INT32,INT32);
+#define    GetPixel WINELIB_NAME(GetPixel)
 FARPROC16  GetProcAddress16(HMODULE16,SEGPTR);
 FARPROC32  GetProcAddress32(HMODULE32,LPCSTR);
 #define    GetProcAddress WINELIB_NAME(GetProcAddress)
@@ -4282,9 +4353,12 @@ INT32      GetScrollPos32(HWND32,INT32);
 BOOL16     GetScrollRange16(HWND16,INT16,LPINT16,LPINT16);
 BOOL32     GetScrollRange32(HWND32,INT32,LPINT32,LPINT32);
 #define    GetScrollRange WINELIB_NAME(GetScrollRange)
-DWORD      GetShortPathName32A(LPCSTR,LPSTR,DWORD);
-DWORD      GetShortPathName32W(LPCWSTR,LPWSTR,DWORD);
-#define    GetShortPathName WINELIB_NAME_AW(GetShortPathName)
+HGDIOBJ16  GetStockObject16(INT16);
+HGDIOBJ32  GetStockObject32(INT32);
+#define    GetStockObject WINELIB_NAME(GetStockObject)
+HBRUSH16   GetSysColorBrush16(INT16);
+HBRUSH32   GetSysColorBrush32(INT32);
+#define    GetSysColorBrush WINELIB_NAME(GetSysColorBrush)
 HWND16     GetSysModalWindow16(void);
 #define    GetSysModalWindow32() ((HWND32)0)
 #define    GetSysModalWindow WINELIB_NAME(GetSysModalWindow)
@@ -4398,6 +4472,9 @@ BOOL16     InsertMenu16(HMENU16,UINT16,UINT16,UINT16,SEGPTR);
 BOOL32     InsertMenu32A(HMENU32,UINT32,UINT32,UINT32,LPCSTR);
 BOOL32     InsertMenu32W(HMENU32,UINT32,UINT32,UINT32,LPCWSTR);
 #define    InsertMenu WINELIB_NAME_AW(InsertMenu)
+INT16      IntersectClipRect16(HDC16,INT16,INT16,INT16,INT16);
+INT32      IntersectClipRect32(HDC32,INT32,INT32,INT32,INT32);
+#define    IntersectClipRect WINELIB_NAME(IntersectClipRect)
 BOOL16     IntersectRect16(LPRECT16,const RECT16*,const RECT16*);
 BOOL32     IntersectRect32(LPRECT32,const RECT32*,const RECT32*);
 #define    IntersectRect WINELIB_NAME(IntersectRect)
@@ -4407,6 +4484,9 @@ void       InvalidateRect32(HWND32,const RECT32*,BOOL32);
 void       InvertRect16(HDC16,const RECT16*);
 void       InvertRect32(HDC32,const RECT32*);
 #define    InvertRect WINELIB_NAME(InvertRect)
+BOOL16     InvertRgn16(HDC16,HRGN16);
+BOOL32     InvertRgn32(HDC32,HRGN32);
+#define    InvertRgn WINELIB_NAME(InvertRgn)
 BOOL16     IsBadCodePtr16(SEGPTR);
 BOOL32     IsBadCodePtr32(FARPROC32);
 #define    IsBadCodePtr WINELIB_NAME(IsBadCodePtr)
@@ -4461,6 +4541,9 @@ INT32      LZRead32(HFILE,LPVOID,UINT32);
 VOID       LineDDA16(INT16,INT16,INT16,INT16,LINEDDAPROC16,LPARAM);
 BOOL32     LineDDA32(INT32,INT32,INT32,INT32,LINEDDAPROC32,LPARAM);
 #define    LineDDA WINELIB_NAME(LineDDA)
+BOOL16     LineTo16(HDC16,INT16,INT16);
+BOOL32     LineTo32(HDC32,INT32,INT32);
+#define    LineTo WINELIB_NAME(LineTo)
 HACCEL16   LoadAccelerators16(HINSTANCE16,SEGPTR);
 HACCEL32   LoadAccelerators32A(HINSTANCE32,LPCSTR);
 HACCEL32   LoadAccelerators32W(HINSTANCE32,LPCWSTR);
@@ -4556,19 +4639,31 @@ BOOL32     OemToChar32W(LPCSTR,LPWSTR);
 BOOL32     OemToCharBuff32A(LPSTR,LPSTR,DWORD);
 BOOL32     OemToCharBuff32W(LPCSTR,LPWSTR,DWORD);
 #define    OemToCharBuff WINELIB_NAME_AW(OemToCharBuff)
+INT16      OffsetClipRgn16(HDC16,INT16,INT16);
+INT32      OffsetClipRgn32(HDC32,INT32,INT32);
+#define    OffsetClipRgn WINELIB_NAME(OffsetClipRgn)
 void       OffsetRect16(LPRECT16,INT16,INT16);
 void       OffsetRect32(LPRECT32,INT32,INT32);
 #define    OffsetRect WINELIB_NAME(OffsetRect)
+INT16      OffsetRgn16(HRGN16,INT16,INT16);
+INT32      OffsetRgn32(HRGN32,INT32,INT32);
+#define    OffsetRgn WINELIB_NAME(OffsetRgn)
 BOOL16     OffsetViewportOrgEx16(HDC16,INT16,INT16,LPPOINT16);
 BOOL32     OffsetViewportOrgEx32(HDC32,INT32,INT32,LPPOINT32);
 #define    OffsetViewportOrgEx WINELIB_NAME(OffsetViewportOrgEx)
 BOOL16     OffsetWindowOrgEx16(HDC16,INT16,INT16,LPPOINT16);
 BOOL32     OffsetWindowOrgEx32(HDC32,INT32,INT32,LPPOINT32);
 #define    OffsetWindowOrgEx WINELIB_NAME(OffsetWindowOrgEx)
+BOOL16     PaintRgn16(HDC16,HRGN16);
+BOOL32     PaintRgn32(HDC32,HRGN32);
+#define    PaintRgn WINELIB_NAME(PaintRgn)
 BOOL16     PeekMessage16(LPMSG16,HWND16,UINT16,UINT16,UINT16);
 BOOL32     PeekMessage32A(LPMSG32,HWND32,UINT32,UINT32,UINT32);
 BOOL32     PeekMessage32W(LPMSG32,HWND32,UINT32,UINT32,UINT32);
 #define    PeekMessage WINELIB_NAME_AW(PeekMessage)
+BOOL16     Pie16(HDC16,INT16,INT16,INT16,INT16,INT16,INT16,INT16,INT16);
+BOOL32     Pie32(HDC32,INT32,INT32,INT32,INT32,INT32,INT32,INT32,INT32);
+#define    Pie WINELIB_NAME(Pie)
 BOOL16     PolyPolygon16(HDC16,LPPOINT16,LPINT16,UINT16);
 BOOL32     PolyPolygon32(HDC32,LPPOINT32,LPINT32,UINT32);
 #define    PolyPolygon WINELIB_NAME(PolyPolygon)
@@ -4587,6 +4682,15 @@ BOOL16     PostAppMessage16(HTASK16,UINT16,WPARAM16,LPARAM);
 BOOL16     PtInRect16(const RECT16*,POINT16);
 BOOL32     PtInRect32(const RECT32*,POINT32);
 #define    PtInRect WINELIB_NAME(PtInRect)
+BOOL16     PtInRegion16(HRGN16,INT16,INT16);
+BOOL32     PtInRegion32(HRGN32,INT32,INT32);
+#define    PtInRegion WINELIB_NAME(PtInRegion)
+BOOL16     PtVisible16(HDC16,INT16,INT16);
+BOOL32     PtVisible32(HDC32,INT32,INT32);
+#define    PtVisible WINELIB_NAME(PtVisible)
+BOOL16     Rectangle16(HDC16,INT16,INT16,INT16,INT16);
+BOOL32     Rectangle32(HDC32,INT32,INT32,INT32,INT32);
+#define    Rectangle WINELIB_NAME(Rectangle)
 BOOL16     RectInRegion16(HRGN16,const RECT16 *);
 BOOL32     RectInRegion32(HRGN32,const RECT32 *);
 #define    RectInRegion WINELIB_NAME(RectInRegion)
@@ -4659,6 +4763,9 @@ BOOL16     RemoveDirectory16(LPCSTR);
 BOOL32     RemoveDirectory32A(LPCSTR);
 BOOL32     RemoveDirectory32W(LPCWSTR);
 #define    RemoveDirectory WINELIB_NAME_AW(RemoveDirectory)
+BOOL16     RoundRect16(HDC16,INT16,INT16,INT16,INT16,INT16,INT16);
+BOOL32     RoundRect32(HDC32,INT32,INT32,INT32,INT32,INT32,INT32);
+#define    RoundRect WINELIB_NAME(RoundRect)
 BOOL16     ScaleViewportExtEx16(HDC16,INT16,INT16,INT16,INT16,LPSIZE16);
 BOOL32     ScaleViewportExtEx32(HDC32,INT32,INT32,INT32,INT32,LPSIZE32);
 #define    ScaleViewportExtEx WINELIB_NAME(ScaleViewportExtEx)
@@ -4668,6 +4775,12 @@ BOOL32     ScaleWindowExtEx32(HDC32,INT32,INT32,INT32,INT32,LPSIZE32);
 void       ScreenToClient16(HWND16,LPPOINT16);
 void       ScreenToClient32(HWND32,LPPOINT32);
 #define    ScreenToClient WINELIB_NAME(ScreenToClient)
+INT16      SelectClipRgn16(HDC16,HRGN16);
+INT32      SelectClipRgn32(HDC32,HRGN32);
+#define    SelectClipRgn WINELIB_NAME(SelectClipRgn)
+HGDIOBJ16  SelectObject16(HDC16,HGDIOBJ16);
+HGDIOBJ32  SelectObject32(HDC32,HGDIOBJ32);
+#define    SelectObject WINELIB_NAME(SelectObject)
 LRESULT    SendDlgItemMessage16(HWND16,INT16,UINT16,WPARAM16,LPARAM);
 LRESULT    SendDlgItemMessage32A(HWND32,INT32,UINT32,WPARAM32,LPARAM);
 LRESULT    SendDlgItemMessage32W(HWND32,INT32,UINT32,WPARAM32,LPARAM);
@@ -4718,6 +4831,9 @@ UINT32     SetHandleCount32(UINT32);
 void       SetInternalWindowPos16(HWND16,UINT16,LPRECT16,LPPOINT16);
 void       SetInternalWindowPos32(HWND32,UINT32,LPRECT32,LPPOINT32);
 #define    SetInternalWindowPos WINELIB_NAME(SetInternalWindowPos)
+COLORREF   SetPixel16(HDC16,INT16,INT16,COLORREF);
+COLORREF   SetPixel32(HDC32,INT32,INT32,COLORREF);
+#define    SetPixel WINELIB_NAME(SetPixel)
 BOOL16     SetProp16(HWND16,LPCSTR,HANDLE16);
 BOOL32     SetProp32A(HWND32,LPCSTR,HANDLE32);
 BOOL32     SetProp32W(HWND32,LPCWSTR,HANDLE32);
@@ -4805,6 +4921,9 @@ BOOL32     UnionRect32(LPRECT32,const RECT32*,const RECT32*);
 void       UnlockSegment16(HGLOBAL16);
 #define    UnlockSegment32(handle) GlobalUnfix((HANDLE32)(handle))
 #define    UnlockSegment WINELIB_NAME(UnlockSegment)
+BOOL16     UnrealizeObject16(HGDIOBJ16);
+BOOL32     UnrealizeObject32(HGDIOBJ32);
+#define    UnrealizeObject WINELIB_NAME(UnrealizeObject)
 BOOL16     UnregisterClass16(SEGPTR,HINSTANCE16);
 BOOL32     UnregisterClass32A(LPCSTR,HINSTANCE32);
 BOOL32     UnregisterClass32W(LPCWSTR,HINSTANCE32);
@@ -4938,7 +5057,6 @@ void       AnsiToOemBuff(LPCSTR,LPSTR,UINT);
 LPSTR      AnsiUpper(LPSTR);
 UINT       AnsiUpperBuff(LPSTR,UINT);
 BOOL       AnyPopup(void);
-BOOL       Arc(HDC16,INT,INT,INT,INT,INT,INT,INT,INT);
 UINT       ArrangeIconicWindows(HWND);
 HDWP16     BeginDeferWindowPos(INT);
 BOOL       BitBlt(HDC16,INT,INT,INT,INT,HDC16,INT,INT,DWORD);
@@ -4948,7 +5066,6 @@ BOOL       CallMsgFilter(SEGPTR,INT);
 LRESULT    CallNextHookEx(HHOOK,INT,WPARAM16,LPARAM);
 BOOL       ChangeClipboardChain(HWND,HWND);
 INT        CheckMenuItem(HMENU16,UINT,UINT);
-BOOL       Chord(HDC16,INT,INT,INT,INT,INT,INT,INT,INT);
 BOOL       CloseClipboard(void);
 void       CloseSound(void);
 BOOL       CloseWindow(HWND);
@@ -4956,29 +5073,21 @@ int        ConvertRequest(HWND,LPKANJISTRUCT);
 HMETAFILE16 CopyMetaFile(HMETAFILE16,LPCSTR);
 INT        CountClipboardFormats(void);
 INT        CountVoiceNotes(INT);
-HBRUSH16   CreateBrushIndirect(const LOGBRUSH16*);
 HDC16      CreateCompatibleDC(HDC16);
 HCURSOR16  CreateCursor(HINSTANCE16,INT,INT,INT,INT,const BYTE*,const BYTE*);
 HGLOBAL16  CreateCursorIconIndirect(HINSTANCE16,CURSORICONINFO*,const BYTE*,const BYTE*);
 HDC16      CreateDC(LPCSTR,LPCSTR,LPCSTR,const DEVMODE*);
-HBRUSH16   CreateDIBPatternBrush(HGLOBAL16,UINT);
 HBITMAP16  CreateDIBitmap(HDC16,BITMAPINFOHEADER*,DWORD,LPVOID,BITMAPINFO*,UINT);
-HBRUSH16   CreateHatchBrush(INT,COLORREF);
 HDC16      CreateIC(LPCSTR,LPCSTR,LPCSTR,const DEVMODE*);
 HICON16    CreateIcon(HINSTANCE16,INT,INT,BYTE,BYTE,const BYTE*,const BYTE*);
 HMENU16    CreateMenu(void);
 HPALETTE16 CreatePalette(const LOGPALETTE*);
-HBRUSH16   CreatePatternBrush(HBITMAP16);
-HPEN16     CreatePen(INT,INT,COLORREF);
-HPEN16     CreatePenIndirect(const LOGPEN16*);
 HMENU16    CreatePopupMenu(void);
-HBRUSH16   CreateSolidBrush(COLORREF);
 DWORD      DefHookProc(short,WORD,DWORD,HHOOK*);
 HDWP16     DeferWindowPos(HDWP16,HWND,HWND,INT,INT,INT,INT,UINT);
 ATOM       DeleteAtom(ATOM);
 BOOL       DeleteDC(HDC16);
 BOOL       DeleteMenu(HMENU16,UINT,UINT);
-BOOL       DeleteObject(HGDIOBJ16);
 BOOL       DestroyCursor(HCURSOR16);
 BOOL       DestroyIcon(HICON16);
 BOOL       DestroyMenu(HMENU16);
@@ -4992,7 +5101,6 @@ DWORD      DragObject(HWND, HWND, WORD, HANDLE16, WORD, HCURSOR16);
 BOOL       DrawIcon(HDC16,INT,INT,HICON16);
 void       DrawMenuBar(HWND);
 DWORD      DumpIcon(SEGPTR,WORD*,SEGPTR*,SEGPTR*);
-BOOL       Ellipse(HDC16,INT,INT,INT,INT);
 BOOL       EmptyClipboard(void);
 BOOL       EnableMenuItem(HMENU16,UINT,UINT);
 BOOL       EnableWindow(HWND,BOOL);
@@ -5001,19 +5109,14 @@ UINT16     EnumClipboardFormats(UINT16);
 INT        EnumFontFamilies(HDC16,LPCSTR,FONTENUMPROC16,LPARAM);
 INT        EnumFonts(HDC16,LPCSTR,FONTENUMPROC16,LPARAM);
 BOOL       EnumMetaFile(HDC16,HMETAFILE16,MFENUMPROC16,LPARAM);
-INT        EnumObjects(HDC16,INT,GOBJENUMPROC16,LPARAM);
 INT        Escape(HDC16,INT,INT,SEGPTR,SEGPTR);
-int        ExcludeClipRect(HDC16,short,short,short,short);
-int        ExcludeVisRect(HDC16,short,short,short,short);
 BOOL       ExitWindows(DWORD,WORD);
 HICON16    ExtractIcon(HINSTANCE16,LPCSTR,WORD);
 void       FatalAppExit(UINT,LPCSTR);
 void       FatalExit(int);
-BOOL       FillRgn(HDC16,HRGN32,HBRUSH16);
 ATOM       FindAtom(SEGPTR);
 HINSTANCE16 FindExecutable(LPCSTR,LPCSTR,LPSTR);
 BOOL       FlashWindow(HWND,BOOL);
-BOOL       FrameRgn(HDC16,HRGN32,HBRUSH16,int,int);
 void       FreeLibrary(HINSTANCE16);
 UINT       GDIRealizePalette(HDC16);
 HPALETTE16 GDISelectPalette(HDC16,HPALETTE16,WORD);
@@ -5076,7 +5179,6 @@ WORD       GetNearestPaletteIndex(HPALETTE16,DWORD);
 HWND       GetNextWindow(HWND,WORD);
 HWND       GetOpenClipboardWindow(void);
 WORD       GetPaletteEntries(HPALETTE16,WORD,WORD,LPPALETTEENTRY);
-DWORD      GetPixel(HDC16,short,short);
 WORD       GetPolyFillMode(HDC16);
 int        GetPriorityClipboardFormat(WORD*,short);
 UINT       GetPrivateProfileInt(LPCSTR,LPCSTR,INT,LPCSTR);
@@ -5087,7 +5189,6 @@ DWORD      GetQueueStatus(UINT);
 BOOL       GetRasterizerCaps(LPRASTERIZER_STATUS,UINT);
 WORD       GetROP2(HDC16);
 WORD       GetRelAbs(HDC16);
-HGDIOBJ16  GetStockObject(INT16);
 WORD       GetStretchBltMode(HDC16);
 HMENU16    GetSubMenu(HMENU16,short);
 HMENU16    GetSystemMenu(HWND,BOOL);
@@ -5122,22 +5223,17 @@ BOOL       HiliteMenuItem(HWND,HMENU16,UINT,UINT);
 BOOL       InSendMessage(void);
 WORD       InitAtomTable(WORD);
 HRGN32     InquireVisRgn(HDC16);
-int        IntersectClipRect(HDC16,short,short,short,short);
-int        IntersectVisRect(HDC16,short,short,short,short);
 void       InvalidateRgn(HWND32,HRGN32,BOOL32);
-BOOL       InvertRgn(HDC16,HRGN32);
 BOOL       IsChild(HWND,HWND);
 BOOL       IsClipboardFormatAvailable(WORD);
 BOOL       IsDialogMessage(HWND,LPMSG16);
 WORD       IsDlgButtonChecked(HWND,WORD);
-BOOL16     IsGDIObject(HGDIOBJ16);
 BOOL       IsIconic(HWND);
 BOOL       IsMenu(HMENU16);
 BOOL       IsValidMetaFile(HMETAFILE16);
 BOOL       IsWindowEnabled(HWND);
 BOOL       IsWindowVisible(HWND);
 BOOL       IsZoomed(HWND);
-BOOL       LineTo(HDC16,short,short);
 HINSTANCE16 LoadLibrary(LPCSTR);
 HINSTANCE16 LoadModule(LPCSTR,LPVOID);
 FARPROC16  LocalNotify(FARPROC16);
@@ -5145,19 +5241,15 @@ HMENU16    LookupMenuHandle(HMENU16,INT);
 WORD       MapVirtualKey(WORD,WORD);
 void       MessageBeep(WORD);
 int        MessageBox(HWND,LPCSTR,LPCSTR,WORD);
-DWORD      MoveTo(HDC16,short,short);
 BOOL       MoveWindow(HWND,short,short,short,short,BOOL);
 DWORD      OemKeyScan(WORD);
 BOOL       OemToAnsi(LPCSTR,LPSTR);
 void       OemToAnsiBuff(LPCSTR,LPSTR,INT);
-int        OffsetClipRgn(HDC16,short,short);
 BOOL       OpenClipboard(HWND);
 BOOL       OpenIcon(HWND);
 int        OpenSound(void);
 void       OutputDebugString(LPCSTR);
-BOOL       PaintRgn(HDC16,HRGN32);
 BOOL       PatBlt(HDC16,short,short,short,short,DWORD);
-BOOL       Pie(HDC16,INT,INT,INT,INT,INT,INT,INT,INT);
 BOOL       PlayMetaFile(HDC16,HMETAFILE16);
 void       PlayMetaFileRecord(HDC16,LPHANDLETABLE16,LPMETARECORD,WORD);
 BOOL       PostMessage(HWND,WORD,WORD,LONG);
@@ -5170,9 +5262,7 @@ void       ProfSampRate(int,int);
 void       ProfSetup(int,int);
 void       ProfStart(void);
 void       ProfStop(void);
-BOOL       PtVisible(HDC16,short,short);
 WORD       RealizeDefaultPalette(HDC16);
-BOOL       Rectangle(HDC16,INT,INT,INT,INT);
 WORD       RegisterClipboardFormat(LPCSTR);
 BOOL       RemoveFontResource(LPSTR);
 BOOL       RemoveMenu(HMENU16,UINT,UINT);
@@ -5180,18 +5270,12 @@ void       ReplyMessage(LRESULT);
 HDC16      ResetDC(HDC16,LPVOID);
 BOOL       ResizePalette(HPALETTE16,UINT);
 BOOL       RestoreDC(HDC16,short);
-int        RestoreVisRgn(HDC16);
-BOOL       RoundRect(HDC16,INT,INT,INT,INT,INT,INT);
 int        SaveDC(HDC16);
-HRGN32     SaveVisRgn(HDC16);
 void       ScrollChildren(HWND,UINT,WPARAM16,LPARAM);
 BOOL       ScrollDC(HDC16,short,short,LPRECT16,LPRECT16,HRGN32,LPRECT16);
 void       ScrollWindow(HWND,short,short,LPRECT16,LPRECT16);
 int        ScrollWindowEx(HWND,short,short,LPRECT16,LPRECT16,HRGN32,LPRECT16,WORD);
-int        SelectClipRgn(HDC16,HRGN32);
-HGDIOBJ16  SelectObject(HDC16,HGDIOBJ16);
 HPALETTE16 SelectPalette(HDC16,HPALETTE16,BOOL);
-int        SelectVisRgn(HDC16,HRGN32);
 HWND       SetActiveWindow(HWND);
 WORD       SetBkMode(HDC16,WORD);
 HANDLE16   SetClipboardData(WORD,HANDLE16);
@@ -5215,7 +5299,6 @@ BOOL       SetMessageQueue(int);
 HMETAFILE16 SetMetaFileBits(HGLOBAL16);
 WORD       SetPaletteEntries(HPALETTE16,WORD,WORD,LPPALETTEENTRY);
 HWND       SetParent(HWND,HWND);
-COLORREF   SetPixel(HDC16,short,short,COLORREF);
 WORD       SetPolyFillMode(HDC16,WORD);
 WORD       SetROP2(HDC16,WORD);
 WORD       SetRelAbs(HDC16,WORD);
@@ -5254,7 +5337,6 @@ int        ToAscii(WORD,WORD,LPSTR,LPVOID,WORD);
 INT16      TranslateAccelerator(HWND,HACCEL16,LPMSG16);
 BOOL       TranslateMDISysAccel(HWND,LPMSG16);
 BOOL       TranslateMessage(LPMSG16);
-BOOL       UnrealizeObject(HGDIOBJ16);
 int        UpdateColors(HDC16);
 void       ValidateCodeSegments(void);
 LPSTR      ValidateFreeSpaces(void);
diff --git a/loader/module.c b/loader/module.c
index 6dadc3f1122a406c974e2aed522c1de39941cc41..5707003d54324d86d5af88410e9f6a7b88d95e6b 100644
--- a/loader/module.c
+++ b/loader/module.c
@@ -26,6 +26,7 @@
 #include "stddebug.h"
 #include "debug.h"
 #include "callback.h"
+#include "xmalloc.h"
 
 extern HINSTANCE16 PE_LoadModule( int fd, OFSTRUCT *ofs, LOADPARAMS* params );
 
@@ -514,7 +515,7 @@ static HMODULE16 MODULE_LoadExeHeader( HFILE hFile, OFSTRUCT *ofs )
         fastload_length=ne_header.fastload_length<<ne_header.align_shift_count;
         dprintf_module( stddeb, "Using fast-load area offset=%x len=%d\n",
                         fastload_offset, fastload_length );
-        if ((fastload = (char *)malloc( fastload_length )) != NULL)
+        if ((fastload = (char *)xmalloc( fastload_length )) != NULL)
         {
             _llseek( hFile, mz_header.ne_offset + fastload_offset, SEEK_SET );
             if (_lread32(hFile, fastload, fastload_length) != fastload_length)
@@ -536,7 +537,7 @@ static HMODULE16 MODULE_LoadExeHeader( HFILE hFile, OFSTRUCT *ofs )
     /* Get the segment table */
 
     pModule->seg_table = (int)pData - (int)pModule;
-    buffer = malloc( ne_header.n_segment_tab * sizeof(struct ne_segment_table_entry_s) );
+    buffer = xmalloc( ne_header.n_segment_tab * sizeof(struct ne_segment_table_entry_s) );
     if (buffer)
     {
         int i;
diff --git a/loader/pe_image.c b/loader/pe_image.c
index 5168949432a96f89dc6b81cf77d3f9f1e227139f..370b9261d5de0102116f2997449665065d76c07b 100644
--- a/loader/pe_image.c
+++ b/loader/pe_image.c
@@ -153,8 +153,9 @@ FARPROC32 PE_FindExportedFunction(struct pe_data *pe, LPCSTR funcName)
 			name++;
 		}
 	} else {
-		if (funcName-exports->Base > exports->Number_Of_Functions) {
-			dprintf_win32(stddeb,"	ordinal %d out of range!\n",funcName);
+		if (LOWORD(funcName)-exports->Base > exports->Number_Of_Functions) {
+			dprintf_win32(stddeb,"	ordinal %d out of range!\n",
+                                      LOWORD(funcName));
 			return NULL;
 		}
 		return (FARPROC32)(load_addr+function[(int)funcName-exports->Base]);
@@ -224,7 +225,7 @@ fixup_imports (struct pe_data *pe, HMODULE16 hModule)
 		if ((unsigned) *import_list & 0x80000000) {
 		    int ordinal = *import_list & (0x80000000 - 1);
 		    dprintf_win32 (stddeb, "--- Ordinal %s,%d\n", Module, ordinal);
-		    *thunk_list = GetProcAddress32(MODULE_FindModule (Module),
+		    *thunk_list = (unsigned)GetProcAddress32(MODULE_FindModule (Module),
 		    				   (LPCSTR) ordinal);
 		    if (!*thunk_list) {
 			fprintf(stderr,"No implementation for %s.%d, setting to NULL\n",
@@ -233,7 +234,7 @@ fixup_imports (struct pe_data *pe, HMODULE16 hModule)
 		    }
 		} else {		/* import by name */
 		    dprintf_win32 (stddeb, "--- %s %s.%d\n", pe_name->Name, Module, pe_name->Hint);
-		    *thunk_list = GetProcAddress32(MODULE_FindModule (Module),
+		    *thunk_list = (unsigned)GetProcAddress32(MODULE_FindModule (Module),
 						   pe_name->Name);
 		    if (!*thunk_list) {
 			fprintf(stderr, "No implementation for %s.%d(%s), setting to NULL\n",
@@ -253,7 +254,7 @@ fixup_imports (struct pe_data *pe, HMODULE16 hModule)
 		    /* not sure about this branch, but it seems to work */
 		    int ordinal = *thunk_list & ~0x80000000;
 		    dprintf_win32(stddeb,"--- Ordinal %s.%d\n",Module,ordinal);
-		    *thunk_list = GetProcAddress32(MODULE_FindModule (Module),
+		    *thunk_list = (unsigned)GetProcAddress32(MODULE_FindModule (Module),
 						   (LPCSTR) ordinal);
 		    if (!*thunk_list) {
 			fprintf(stderr, "No implementation for %s.%d, setting to NULL\n",
@@ -263,7 +264,7 @@ fixup_imports (struct pe_data *pe, HMODULE16 hModule)
 		} else {
 		    dprintf_win32(stddeb,"--- %s %s.%d\n",
 		   		  pe_name->Name, Module, pe_name->Hint);
-		    *thunk_list = GetProcAddress32(MODULE_FindModule(Module),
+		    *thunk_list = (unsigned)GetProcAddress32(MODULE_FindModule(Module),
 						   pe_name->Name);
 		    if (!*thunk_list) {
 		    	fprintf(stderr, "No implementation for %s.%d, setting to NULL\n",
@@ -373,7 +374,7 @@ static struct pe_data *PE_LoadImage( int fd, HMODULE16 hModule, WORD offset )
 {
     struct pe_data *pe;
     int i, result;
-    unsigned int load_addr;
+    int load_addr;
     struct Directory dir;
     char	buffer[200];
     DBG_ADDR	daddr;
@@ -405,7 +406,7 @@ static struct pe_data *PE_LoadImage( int fd, HMODULE16 hModule, WORD offset )
 	   I don't know if mmap("/dev/null"); would do any better.
 	   What I'd really like to do is a Win32 style VirtualAlloc/MapViewOfFile
 	   sequence */
-	load_addr = pe->load_addr = malloc(pe->vma_size);
+	load_addr = pe->load_addr = (int)xmalloc(pe->vma_size);
 	dprintf_win32(stddeb, "Load addr is really %x, range %x\n",
 		pe->load_addr, pe->vma_size);
 
@@ -416,7 +417,7 @@ static struct pe_data *PE_LoadImage( int fd, HMODULE16 hModule, WORD offset )
 		if(pe->pe_seg[i].Characteristics & 
 			~ IMAGE_SCN_TYPE_CNT_UNINITIALIZED_DATA)
 		if(lseek(fd,pe->pe_seg[i].PointerToRawData,SEEK_SET) == -1
-		|| read(fd,load_addr + pe->pe_seg[i].Virtual_Address,
+		|| read(fd,(char *)load_addr + pe->pe_seg[i].Virtual_Address,
 				pe->pe_seg[i].Size_Of_Raw_Data) 
 				!= pe->pe_seg[i].Size_Of_Raw_Data)
 		{
@@ -471,37 +472,37 @@ static struct pe_data *PE_LoadImage( int fd, HMODULE16 hModule, WORD offset )
 	if(dir.Size)
 	{
 		if(pe->pe_export && 
-			pe->pe_export!=load_addr+dir.Virtual_address)
+			(int)pe->pe_export!=load_addr+dir.Virtual_address)
 			fprintf(stderr,"wrong export directory??\n");
 		/* always trust the directory */
-		pe->pe_export = load_addr+dir.Virtual_address;
+		pe->pe_export = (void *)(load_addr+dir.Virtual_address);
 	}
 
 	dir=pe->pe_header->opt_coff.DataDirectory[IMAGE_FILE_IMPORT_DIRECTORY];
 	if(dir.Size)
 	{
 		if(pe->pe_import && 
-			pe->pe_import!=load_addr+dir.Virtual_address)
+			(int)pe->pe_import!=load_addr+dir.Virtual_address)
 			fprintf(stderr,"wrong import directory??\n");
-		pe->pe_import = load_addr+dir.Virtual_address;
+		pe->pe_import = (void *)(load_addr+dir.Virtual_address);
 	}
 
 	dir=pe->pe_header->opt_coff.DataDirectory[IMAGE_FILE_RESOURCE_DIRECTORY];
 	if(dir.Size)
 	{
 		if(pe->pe_resource && 
-			pe->pe_resource!=load_addr+dir.Virtual_address)
+			(int)pe->pe_resource!=load_addr+dir.Virtual_address)
 			fprintf(stderr,"wrong resource directory??\n");
-		pe->pe_resource = load_addr+dir.Virtual_address;
+		pe->pe_resource = (void *)(load_addr+dir.Virtual_address);
 	}
 
 	dir=pe->pe_header->opt_coff.DataDirectory[IMAGE_FILE_BASE_RELOCATION_TABLE];
 	if(dir.Size)
 	{
 		if(pe->pe_reloc && 
-			pe->pe_reloc!=load_addr+dir.Virtual_address)
+			(int)pe->pe_reloc!=load_addr+dir.Virtual_address)
 			fprintf(stderr,"wrong relocation list??\n");
-		pe->pe_reloc = load_addr+dir.Virtual_address;
+		pe->pe_reloc = (void *)(load_addr+dir.Virtual_address);
 	}
 
 	if(pe->pe_header->opt_coff.DataDirectory
@@ -566,8 +567,6 @@ HINSTANCE16 PE_LoadModule( int fd, OFSTRUCT *ofs, LOADPARAMS* params )
     HMODULE16 hModule;
     HINSTANCE16 hInstance;
     NE_MODULE *pModule;
-    SEGTABLEENTRY *pSegment;
-    FARPROC16 startup;
     struct mz_header_s mz_header;
 
     if ((hModule = MODULE_CreateDummyModule( ofs )) < 32) return hModule;
@@ -577,13 +576,6 @@ HINSTANCE16 PE_LoadModule( int fd, OFSTRUCT *ofs, LOADPARAMS* params )
     lseek( fd, 0, SEEK_SET );
     read( fd, &mz_header, sizeof(mz_header) );
 
-    /* Set the startup address */
-
-    startup = MODULE_GetWndProcEntry16("Win32CallToStart");
-    pSegment = NE_SEG_TABLE(pModule) + pModule->cs - 1;
-    pSegment->selector = SELECTOROF(startup); /* FIXME */
-    pModule->ip = OFFSETOF(startup);
-
     pModule->pe_module = PE_LoadImage( fd, hModule, mz_header.ne_offset );
 
     hInstance = MODULE_CreateInstance( hModule, params );
@@ -598,28 +590,6 @@ HINSTANCE16 PE_LoadModule( int fd, OFSTRUCT *ofs, LOADPARAMS* params )
     return hInstance;
 }
 
-void PE_InitTEB(int hTEB);
-
-void PE_InitializeDLLs(HMODULE16 hModule);
-void PE_Win32CallToStart( SIGCONTEXT *context )
-{
-    int fs;
-    HMODULE16 hModule;
-    NE_MODULE *pModule;
-
-    dprintf_win32(stddeb,"Going to start Win32 program\n");	
-    InitTask( context );
-    hModule = GetExePtr( GetCurrentTask() );
-    pModule = MODULE_GetPtr( hModule );
-    InitApp( hModule );
-    fs=(int)GlobalAlloc16( GMEM_FIXED | GMEM_ZEROINIT, 0x10000 );
-    PE_InitTEB(fs);
-    __asm__ __volatile__("movw %w0,%%fs"::"r" (fs));
-    PE_InitializeDLLs( hModule );
-    CallTaskStart32( (FARPROC32)(pModule->pe_module->load_addr + 
-                               pModule->pe_module->pe_header->opt_coff.AddressOfEntryPoint) );
-}
-
 int PE_UnloadImage( HMODULE16 hModule )
 {
 	printf("PEunloadImage() called!\n");
@@ -647,7 +617,7 @@ static void PE_InitDLL(HMODULE16 hModule)
         printf("InitPEDLL() called!\n");
         CallDLLEntryProc32( (FARPROC32)(pe->load_addr + 
                                   pe->pe_header->opt_coff.AddressOfEntryPoint),
-                            hModule, DLL_PROCESS_ATTACH, (void *)-1 );
+                            hModule, DLL_PROCESS_ATTACH, -1 );
     }
 }
 
@@ -655,12 +625,12 @@ static void PE_InitDLL(HMODULE16 hModule)
 /* FIXME: This stuff is all on a "well it works" basis. An implementation
 based on some kind of documentation would be greatly appreciated :-) */
 
-typedef struct
+typedef struct _TEB
 {
     void        *Except;
     void        *stack;
     int	        dummy1[4];
-    struct TEB  *TEBDSAlias;
+    struct _TEB *TEBDSAlias;
     int	        dummy2[2];
     int	        taskid;
 } TEB;
@@ -672,7 +642,7 @@ void PE_InitTEB(int hTEB)
 
     pTask = (TDB *)(GlobalLock16(GetCurrentTask() & 0xffff));
     pTEB  = (TEB *)(GlobalLock16(hTEB));
-    pTEB->stack = pTask->esp;
+    pTEB->stack = (void *)pTask->esp;
     pTEB->Except = (void *)(-1); 
     pTEB->TEBDSAlias = pTEB;
     pTEB->taskid = getpid();
diff --git a/loader/task.c b/loader/task.c
index 87b1e3753c9ef329e41259bbd93456d56fbf082a..97b2ac3f38437f6c640f42d601410627afecb258 100644
--- a/loader/task.c
+++ b/loader/task.c
@@ -349,38 +349,59 @@ static BOOL TASK_FreeThunk( HTASK16 hTask, SEGPTR thunk )
 #ifndef WINELIB
 static void TASK_CallToStart(void)
 {
-    int cs_reg, ds_reg, ip_reg;
+    int cs_reg, ds_reg, fs_reg, ip_reg;
     TDB *pTask = (TDB *)GlobalLock16( hCurrentTask );
     NE_MODULE *pModule = MODULE_GetPtr( pTask->hModule );
     SEGTABLEENTRY *pSegTable = NE_SEG_TABLE( pModule );
 
-    /* Registers at initialization must be:
-     * ax   zero
-     * bx   stack size in bytes
-     * cx   heap size in bytes
-     * si   previous app instance
-     * di   current app instance
-     * bp   zero
-     * es   selector to the PSP
-     * ds   dgroup of the application
-     * ss   stack selector
-     * sp   top of the stack
-     */
-
-    cs_reg = pSegTable[pModule->cs - 1].selector;
-    ip_reg = pModule->ip;
-    ds_reg = pSegTable[pModule->dgroup - 1].selector;
-
     IF1632_Saved16_ss = pTask->ss;
     IF1632_Saved16_sp = pTask->sp;
-    dprintf_task( stddeb, "Starting main program: cs:ip=%04x:%04x ds=%04x ss:sp=%04x:%04x\n",
-                 cs_reg, ip_reg, ds_reg,
-                 IF1632_Saved16_ss, IF1632_Saved16_sp);
 
-    CallTo16_regs_( (FARPROC16)(cs_reg << 16 | ip_reg), ds_reg,
-                   pTask->hPDB /*es*/, 0 /*bp*/, 0 /*ax*/,
-                   pModule->stack_size /*bx*/, pModule->heap_size /*cx*/,
-                   0 /*dx*/, 0 /*si*/, ds_reg /*di*/ );
+    if (pModule->flags & NE_FFLAGS_WIN32)
+    {
+        /* FIXME: all this is an ugly hack */
+
+        extern void PE_InitTEB( int hTEB );
+        extern void InitTask( SIGCONTEXT *context );
+        extern void PE_InitializeDLLs( HMODULE16 hModule );
+
+        InitTask( NULL );
+        InitApp( pTask->hModule );
+        fs_reg = (int)GlobalAlloc16( GMEM_FIXED | GMEM_ZEROINIT, 0x10000 );
+        PE_InitTEB( fs_reg );
+        __asm__ __volatile__("movw %w0,%%fs"::"r" (fs_reg));
+        PE_InitializeDLLs( pTask->hModule );
+        CallTaskStart32( (FARPROC32)(pModule->pe_module->load_addr + 
+                pModule->pe_module->pe_header->opt_coff.AddressOfEntryPoint) );
+    }
+    else
+    {
+        /* Registers at initialization must be:
+         * ax   zero
+         * bx   stack size in bytes
+         * cx   heap size in bytes
+         * si   previous app instance
+         * di   current app instance
+         * bp   zero
+         * es   selector to the PSP
+         * ds   dgroup of the application
+         * ss   stack selector
+         * sp   top of the stack
+         */
+
+        cs_reg = pSegTable[pModule->cs - 1].selector;
+        ip_reg = pModule->ip;
+        ds_reg = pSegTable[pModule->dgroup - 1].selector;
+
+        dprintf_task( stddeb, "Starting main program: cs:ip=%04x:%04x ds=%04x ss:sp=%04x:%04x\n",
+                      cs_reg, ip_reg, ds_reg,
+                      IF1632_Saved16_ss, IF1632_Saved16_sp);
+
+        CallTo16_regs_( (FARPROC16)(cs_reg << 16 | ip_reg), ds_reg,
+                        pTask->hPDB /*es*/, 0 /*bp*/, 0 /*ax*/,
+                        pModule->stack_size /*bx*/, pModule->heap_size /*cx*/,
+                        0 /*dx*/, 0 /*si*/, ds_reg /*di*/ );
+    }
 
     /* This should never return */
     fprintf( stderr, "TASK_CallToStart: Main program returned!\n" );
@@ -814,7 +835,7 @@ void InitTask( SIGCONTEXT *context )
     LONG stacklow, stackhi;
 
 #ifndef WINELIB
-    EAX_reg(context) = 0;
+    if (context) EAX_reg(context) = 0;
 #endif
     if (!(pTask = (TDB *)GlobalLock16( hCurrentTask ))) return;
     if (!(pModule = MODULE_GetPtr( pTask->hModule ))) return;
@@ -822,21 +843,24 @@ void InitTask( SIGCONTEXT *context )
 #ifndef WINELIB
     NE_InitializeDLLs( pTask->hModule );
 
-    /* Registers on return are:
-     * ax     1 if OK, 0 on error
-     * cx     stack limit in bytes
-     * dx     cmdShow parameter
-     * si     instance handle of the previous instance
-     * di     instance handle of the new task
-     * es:bx  pointer to command-line inside PSP
-     */
-    EAX_reg(context) = 1;
-    EBX_reg(context) = 0x81;
-    ECX_reg(context) = pModule->stack_size;
-    EDX_reg(context) = pTask->nCmdShow;
-    ESI_reg(context) = (DWORD)pTask->hPrevInstance;
-    EDI_reg(context) = (DWORD)pTask->hInstance;
-    ES_reg (context) = (WORD)pTask->hPDB;
+    if (context)
+    {
+        /* Registers on return are:
+         * ax     1 if OK, 0 on error
+         * cx     stack limit in bytes
+         * dx     cmdShow parameter
+         * si     instance handle of the previous instance
+         * di     instance handle of the new task
+         * es:bx  pointer to command-line inside PSP
+         */
+        EAX_reg(context) = 1;
+        EBX_reg(context) = 0x81;
+        ECX_reg(context) = pModule->stack_size;
+        EDX_reg(context) = pTask->nCmdShow;
+        ESI_reg(context) = (DWORD)pTask->hPrevInstance;
+        EDI_reg(context) = (DWORD)pTask->hInstance;
+        ES_reg (context) = (WORD)pTask->hPDB;
+    }
 
     /* Initialize the local heap */
     if ( pModule->heap_size )
diff --git a/misc/clipboard.c b/misc/clipboard.c
index 32b89c618a80c8e9e2b60272f4ac009179bde864..ad09adac468cf88ddec2fb4810d1a898ced86ec7 100644
--- a/misc/clipboard.c
+++ b/misc/clipboard.c
@@ -144,7 +144,7 @@ void CLIPBOARD_DeleteRecord(LPCLIPFORMAT lpFormat)
 {
   if( lpFormat->wFormatID >= CF_GDIOBJFIRST &&
       lpFormat->wFormatID <= CF_GDIOBJLAST )
-      DeleteObject(lpFormat->hData);
+      DeleteObject32(lpFormat->hData);
   else if( lpFormat->hData )
            GlobalFree16(lpFormat->hData);
 
diff --git a/misc/commdlg.c b/misc/commdlg.c
index ec93f7c7eb65e2ee0fbb9f36e7435c546514372b..0133f88e0f36636d02a866363359360969ba9630 100644
--- a/misc/commdlg.c
+++ b/misc/commdlg.c
@@ -218,7 +218,7 @@ static LONG FILEDLG_WMDrawItem(HWND hWnd, WPARAM16 wParam, LPARAM lParam,int sav
 {
     LPDRAWITEMSTRUCT16 lpdis = (LPDRAWITEMSTRUCT16)PTR_SEG_TO_LIN(lParam);
     char *str;
-    HBRUSH16 hBrush;
+    HBRUSH32 hBrush;
     HBITMAP16 hBitmap, hPrevBitmap;
     BITMAP16 bm;
     HDC16 hMemDC;
@@ -226,8 +226,8 @@ static LONG FILEDLG_WMDrawItem(HWND hWnd, WPARAM16 wParam, LPARAM lParam,int sav
     if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst1)
     {
         if (!(str = SEGPTR_ALLOC(512))) return FALSE;
-	hBrush = SelectObject(lpdis->hDC, GetStockObject(LTGRAY_BRUSH));
-	SelectObject(lpdis->hDC, hBrush);
+	hBrush = SelectObject32(lpdis->hDC, GetStockObject32(LTGRAY_BRUSH));
+	SelectObject32(lpdis->hDC, hBrush);
 	FillRect16(lpdis->hDC, &lpdis->rcItem, hBrush);
 	SendMessage16(lpdis->hwndItem, LB_GETTEXT16, lpdis->itemID, 
                       (LPARAM)SEGPTR_GET(str));
@@ -251,8 +251,8 @@ static LONG FILEDLG_WMDrawItem(HWND hWnd, WPARAM16 wParam, LPARAM lParam,int sav
     if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst2)
     {
         if (!(str = SEGPTR_ALLOC(512))) return FALSE;
-	hBrush = SelectObject(lpdis->hDC, GetStockObject(LTGRAY_BRUSH));
-	SelectObject(lpdis->hDC, hBrush);
+	hBrush = SelectObject32(lpdis->hDC, GetStockObject32(LTGRAY_BRUSH));
+	SelectObject32(lpdis->hDC, hBrush);
 	FillRect16(lpdis->hDC, &lpdis->rcItem, hBrush);
 	SendMessage16(lpdis->hwndItem, LB_GETTEXT16, lpdis->itemID, 
                       (LPARAM)SEGPTR_GET(str));
@@ -262,10 +262,10 @@ static LONG FILEDLG_WMDrawItem(HWND hWnd, WPARAM16 wParam, LPARAM lParam,int sav
 	TextOut16(lpdis->hDC, lpdis->rcItem.left + bm.bmWidth, 
                   lpdis->rcItem.top, str, strlen(str));
 	hMemDC = CreateCompatibleDC(lpdis->hDC);
-	hPrevBitmap = SelectObject(hMemDC, hBitmap);
+	hPrevBitmap = SelectObject32(hMemDC, hBitmap);
 	BitBlt(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
 	       bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
-	SelectObject(hMemDC, hPrevBitmap);
+	SelectObject32(hMemDC, hPrevBitmap);
 	DeleteDC(hMemDC);
 	if (lpdis->itemState != 0) InvertRect16(lpdis->hDC, &lpdis->rcItem);
         SEGPTR_FREE(str);
@@ -274,8 +274,8 @@ static LONG FILEDLG_WMDrawItem(HWND hWnd, WPARAM16 wParam, LPARAM lParam,int sav
     if (lpdis->CtlType == ODT_COMBOBOX && lpdis->CtlID == cmb2)
     {
         if (!(str = SEGPTR_ALLOC(512))) return FALSE;
-	hBrush = SelectObject(lpdis->hDC, GetStockObject(LTGRAY_BRUSH));
-	SelectObject(lpdis->hDC, hBrush);
+	hBrush = SelectObject32(lpdis->hDC, GetStockObject32(LTGRAY_BRUSH));
+	SelectObject32(lpdis->hDC, hBrush);
 	FillRect16(lpdis->hDC, &lpdis->rcItem, hBrush);
 	SendMessage16(lpdis->hwndItem, CB_GETLBTEXT, lpdis->itemID, 
                       (LPARAM)SEGPTR_GET(str));
@@ -291,10 +291,10 @@ static LONG FILEDLG_WMDrawItem(HWND hWnd, WPARAM16 wParam, LPARAM lParam,int sav
 	TextOut16(lpdis->hDC, lpdis->rcItem.left + bm.bmWidth, 
                   lpdis->rcItem.top, str, strlen(str));
 	hMemDC = CreateCompatibleDC(lpdis->hDC);
-	hPrevBitmap = SelectObject(hMemDC, hBitmap);
+	hPrevBitmap = SelectObject32(hMemDC, hBitmap);
 	BitBlt(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
 	       bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
-	SelectObject(hMemDC, hPrevBitmap);
+	SelectObject32(hMemDC, hPrevBitmap);
 	DeleteDC(hMemDC);
 	if (lpdis->itemState != 0) InvertRect16(lpdis->hDC, &lpdis->rcItem);
         SEGPTR_FREE(str);
@@ -1476,24 +1476,24 @@ static void CC_PaintSelectedColor(HWND hDlg,COLORREF cr)
 {
  RECT16 rect;
  HDC32  hdc;
- HBRUSH16 hBrush;
+ HBRUSH32 hBrush;
  HWND hwnd=GetDlgItem(hDlg,0x2c5);
  if (IsWindowVisible(GetDlgItem(hDlg,0x2c6)))   /* if full size */
  {
   hdc=GetDC32(hwnd);
   GetClientRect16 (hwnd, &rect) ;
-  hBrush = CreateSolidBrush(cr);
+  hBrush = CreateSolidBrush32(cr);
   if (hBrush)
   {
-   hBrush = SelectObject (hdc, hBrush) ;
-   Rectangle (hdc, rect.left,rect.top,rect.right/2,rect.bottom);
-   DeleteObject (SelectObject (hdc,hBrush)) ;
-   hBrush=CreateSolidBrush(GetNearestColor(hdc,cr));
+   hBrush = SelectObject32 (hdc, hBrush) ;
+   Rectangle32(hdc, rect.left,rect.top,rect.right/2,rect.bottom);
+   DeleteObject32 (SelectObject32 (hdc,hBrush)) ;
+   hBrush=CreateSolidBrush32(GetNearestColor(hdc,cr));
    if (hBrush)
    {
-    hBrush= SelectObject (hdc, hBrush) ;
-    Rectangle (hdc, rect.right/2-1,rect.top,rect.right,rect.bottom);
-    DeleteObject (SelectObject (hdc, hBrush)) ;
+    hBrush= SelectObject32 (hdc, hBrush) ;
+    Rectangle32( hdc, rect.right/2-1,rect.top,rect.right,rect.bottom);
+    DeleteObject32( SelectObject32 (hdc, hBrush)) ;
    }
   }
   ReleaseDC32(hwnd,hdc);
@@ -1534,7 +1534,7 @@ static void CC_PaintTriangle(HWND hDlg,int y)
    points[2].x=points[1].x=points[0].x + w;
 
    if (lpp->old3angle.left)
-    FillRect16(hDC,&lpp->old3angle,GetStockObject(WHITE_BRUSH));
+    FillRect16(hDC,&lpp->old3angle,GetStockObject32(WHITE_BRUSH));
    lpp->old3angle.left  =points[0].x;
    lpp->old3angle.right =points[1].x+1;
    lpp->old3angle.top   =points[2].y-1;
@@ -1556,15 +1556,15 @@ static void CC_PaintCross(HWND hDlg,int x,int y)
  struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER); 
  RECT16 rect;
  POINT16 point;
- HPEN16 hPen;
+ HPEN32 hPen;
 
  if (IsWindowVisible(GetDlgItem(hDlg,0x2c6)))   /* if full size */
  {
    GetClientRect16(hwnd,&rect);
    hDC=GetDC32(hwnd);
-   SelectClipRgn(hDC,CreateRectRgnIndirect16(&rect));   
-   hPen=CreatePen(PS_SOLID,2,0);
-   hPen=SelectObject(hDC,hPen);
+   SelectClipRgn32(hDC,CreateRectRgnIndirect16(&rect));
+   hPen=CreatePen32(PS_SOLID,2,0);
+   hPen=SelectObject32(hDC,hPen);
    point.x=((long)rect.right*(long)x)/(long)MAXHORI;
    point.y=rect.bottom-((long)rect.bottom*(long)y)/(long)MAXVERT;
    if (lpp->oldcross.left!=lpp->oldcross.right)
@@ -1578,10 +1578,10 @@ static void CC_PaintCross(HWND hDlg,int x,int y)
    lpp->oldcross.bottom=point.y+w+1; 
 
    MoveTo(hDC,point.x-w,point.y); 
-   LineTo(hDC,point.x+w,point.y);
+   LineTo32(hDC,point.x+w,point.y);
    MoveTo(hDC,point.x,point.y-w); 
-   LineTo(hDC,point.x,point.y+w);
-   DeleteObject(SelectObject(hDC,hPen));
+   LineTo32(hDC,point.x,point.y+w);
+   DeleteObject32(SelectObject32(hDC,hPen));
    ReleaseDC32(hwnd,hDC);
  }
 }
@@ -1599,7 +1599,7 @@ static void CC_PrepareColorGraph(HWND hDlg)
  int sdif,hdif,xdif,ydif,r,g,b,hue,sat;
  HWND hwnd=GetDlgItem(hDlg,0x2c6);
  struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);  
- HBRUSH16 hbrush;
+ HBRUSH32 hbrush;
  HDC32 hdc ;
  RECT16 rect,client;
  HCURSOR16 hcursor=SetCursor(LoadCursor16(0,IDC_WAIT));
@@ -1608,7 +1608,7 @@ static void CC_PrepareColorGraph(HWND hDlg)
  hdc=GetDC32(hwnd);
  lpp->hdcMem = CreateCompatibleDC(hdc);
  lpp->hbmMem = CreateCompatibleBitmap(hdc,client.right,client.bottom);
- SelectObject(lpp->hdcMem,lpp->hbmMem);
+ SelectObject32(lpp->hdcMem,lpp->hbmMem);
 
  xdif=client.right /XSTEPS;
  ydif=client.bottom/YSTEPS+1;
@@ -1624,9 +1624,9 @@ static void CC_PrepareColorGraph(HWND hDlg)
    r=CC_HSLtoRGB('R',hue,sat,120);
    g=CC_HSLtoRGB('G',hue,sat,120);
    b=CC_HSLtoRGB('B',hue,sat,120);
-   hbrush=CreateSolidBrush(RGB(r,g,b));
+   hbrush=CreateSolidBrush32(RGB(r,g,b));
    FillRect16(lpp->hdcMem,&rect,hbrush);
-   DeleteObject(hbrush);
+   DeleteObject32(hbrush);
    rect.bottom=rect.top;
   }
   rect.left=rect.right;
@@ -1666,7 +1666,7 @@ static void CC_PaintLumBar(HWND hDlg,int hue,int sat)
  HWND hwnd=GetDlgItem(hDlg,0x2be);
  RECT16 rect,client;
  int lum,ldif,ydif,r,g,b;
- HBRUSH16 hbrush;
+ HBRUSH32 hbrush;
  HDC32 hDC;
 
  if (IsWindowVisible(hwnd))
@@ -1683,13 +1683,13 @@ static void CC_PaintLumBar(HWND hDlg,int hue,int sat)
    r=CC_HSLtoRGB('R',hue,sat,lum);
    g=CC_HSLtoRGB('G',hue,sat,lum);
    b=CC_HSLtoRGB('B',hue,sat,lum);
-   hbrush=CreateSolidBrush(RGB(r,g,b));
+   hbrush=CreateSolidBrush32(RGB(r,g,b));
    FillRect16(hDC,&rect,hbrush);
-   DeleteObject(hbrush);
+   DeleteObject32(hbrush);
    rect.bottom=rect.top;
   }
   GetClientRect16(hwnd,&rect);
-  FrameRect16(hDC,&rect,GetStockObject(BLACK_BRUSH));
+  FrameRect16(hDC,&rect,GetStockObject32(BLACK_BRUSH));
   ReleaseDC32(hwnd,hDC);
  }
 }
@@ -1776,7 +1776,7 @@ static void CC_PaintPredefColorArray(HWND hDlg,int rows,int cols)
  HWND hwnd=GetDlgItem(hDlg,0x2d0);
  RECT16 rect;
  HDC32  hdc;
- HBRUSH16 hBrush;
+ HBRUSH32 hBrush;
  int dx,dy,i,j,k;
 
  GetClientRect16(hwnd,&rect);
@@ -1791,14 +1791,14 @@ static void CC_PaintPredefColorArray(HWND hDlg,int rows,int cols)
  {
   for (i=0;i<cols;i++)
   {
-   hBrush = CreateSolidBrush(predefcolors[j][i]);
+   hBrush = CreateSolidBrush32(predefcolors[j][i]);
    if (hBrush)
    {
-    hBrush = SelectObject (hdc, hBrush) ;
-    Rectangle (hdc, rect.left,     rect.top,
-		    rect.left+dx-DISTANCE,rect.top+dy-DISTANCE);
+    hBrush = SelectObject32 (hdc, hBrush) ;
+    Rectangle32(hdc, rect.left, rect.top,
+                rect.left+dx-DISTANCE, rect.top+dy-DISTANCE);
     rect.left=rect.left+dx;
-    DeleteObject (SelectObject (hdc, hBrush)) ;
+    DeleteObject32( SelectObject32 (hdc, hBrush)) ;
    }
   }
   rect.top=rect.top+dy;
@@ -1815,7 +1815,7 @@ static void CC_PaintUserColorArray(HWND hDlg,int rows,int cols,COLORREF* lpcr)
  HWND hwnd=GetDlgItem(hDlg,0x2d1);
  RECT16 rect;
  HDC32  hdc;
- HBRUSH16 hBrush;
+ HBRUSH32 hBrush;
  int dx,dy,i,j,k;
 
  GetClientRect16(hwnd,&rect);
@@ -1831,14 +1831,14 @@ static void CC_PaintUserColorArray(HWND hDlg,int rows,int cols,COLORREF* lpcr)
   {
    for (i=0;i<cols;i++)
    {
-    hBrush = CreateSolidBrush(lpcr[i+j*cols]);
+    hBrush = CreateSolidBrush32(lpcr[i+j*cols]);
     if (hBrush)
     {
-     hBrush = SelectObject (hdc, hBrush) ;
-     Rectangle (hdc, rect.left,     rect.top,
-		    rect.left+dx-DISTANCE,rect.top+dy-DISTANCE);
+     hBrush = SelectObject32 (hdc, hBrush) ;
+     Rectangle32( hdc, rect.left, rect.top,
+                  rect.left+dx-DISTANCE, rect.top+dy-DISTANCE);
      rect.left=rect.left+dx;
-     DeleteObject (SelectObject (hdc, hBrush)) ;
+     DeleteObject32( SelectObject32 (hdc, hBrush)) ;
     }
    }
    rect.top=rect.top+dy;
@@ -2165,7 +2165,7 @@ LRESULT ColorDlgProc(HWND hDlg, UINT message,
 	                return CC_WMInitDialog(hDlg,wParam,lParam);
 	  case WM_NCDESTROY:
 	                DeleteDC(lpp->hdcMem); 
-	                DeleteObject(lpp->hbmMem); 
+	                DeleteObject32(lpp->hbmMem); 
 	                free(lpp);
 	                SetWindowLong32A(hDlg, DWL_USER, 0L); /* we don't need it anymore */
 	                break;
@@ -2321,10 +2321,10 @@ static int SetFontStylesToCombo2(HWND hwnd, HDC16 hdc, LPLOGFONT16 lplf,
      lplf->lfItalic=fontstyles[i].italic;
      lplf->lfWeight=fontstyles[i].weight;
      hf=CreateFontIndirect16(lplf);
-     hf=SelectObject(hdc,hf);
+     hf=SelectObject32(hdc,hf);
      GetTextMetrics16(hdc,lptm);
-     hf=SelectObject(hdc,hf);
-     DeleteObject(hf);
+     hf=SelectObject32(hdc,hf);
+     DeleteObject32(hf);
 
      if (lptm->tmWeight==fontstyles[i].weight &&
          lptm->tmItalic==fontstyles[i].italic)    /* font successful created ? */
@@ -2568,8 +2568,8 @@ LRESULT CFn_WMDrawItem(HWND hDlg, WPARAM16 wParam, LPARAM lParam)
   {
    if (lpdi->CtlType == ODT_COMBOBOX)
    {
-     hBrush = SelectObject(lpdi->hDC, GetStockObject(LTGRAY_BRUSH));
-     SelectObject(lpdi->hDC, hBrush);
+     hBrush = SelectObject32(lpdi->hDC, GetStockObject32(LTGRAY_BRUSH));
+     SelectObject32(lpdi->hDC, hBrush);
      FillRect16(lpdi->hDC, &lpdi->rcItem, hBrush);
    }
    else
@@ -2591,10 +2591,10 @@ LRESULT CFn_WMDrawItem(HWND hDlg, WPARAM16 wParam, LPARAM lParam)
 		if (nFontType&TRUETYPE_FONTTYPE)
 		{
 		  hMemDC = CreateCompatibleDC(lpdi->hDC);
-		  hBitmap = SelectObject(hMemDC, hBitmapTT);
+		  hBitmap = SelectObject32(hMemDC, hBitmapTT);
 		  BitBlt(lpdi->hDC, lpdi->rcItem.left, lpdi->rcItem.top,
 			bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
-		  SelectObject(hMemDC, hBitmap);
+		  SelectObject32(hMemDC, hBitmap);
 		  DeleteDC(hMemDC);
 		}
 #endif
@@ -2613,16 +2613,17 @@ LRESULT CFn_WMDrawItem(HWND hDlg, WPARAM16 wParam, LPARAM lParam)
 		TextOut16(lpdi->hDC, lpdi->rcItem.left +  25+5,
                           lpdi->rcItem.top, buffer, lstrlen16(buffer));
 		cr = SendMessage16(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L);
-		hBrush = CreateSolidBrush(cr);
+		hBrush = CreateSolidBrush32(cr);
 		if (hBrush)
 		{
-		  hBrush = SelectObject (lpdi->hDC, hBrush) ;
+		  hBrush = SelectObject32 (lpdi->hDC, hBrush) ;
 		  rect.right=rect.left+25;
 		  rect.top++;
 		  rect.left+=5;
 		  rect.bottom--;
-		  Rectangle(lpdi->hDC,rect.left,rect.top,rect.right,rect.bottom);
-		  DeleteObject (SelectObject (lpdi->hDC, hBrush)) ;
+		  Rectangle32( lpdi->hDC, rect.left, rect.top,
+                               rect.right, rect.bottom );
+		  DeleteObject32( SelectObject32 (lpdi->hDC, hBrush)) ;
 		}
 		rect=lpdi->rcItem;
 		rect.left+=25+5;
@@ -2648,7 +2649,7 @@ LRESULT CFn_WMCtlColor(HWND hDlg, WPARAM16 wParam, LPARAM lParam)
    if (HIWORD(lParam)==CTLCOLOR_STATIC && GetDlgCtrlID(LOWORD(lParam))==stc6)
    {
      SetTextColor(wParam,lpcf->rgbColors);
-     return GetStockObject(WHITE_BRUSH);
+     return GetStockObject32(WHITE_BRUSH);
    }
   return 0;
 }
diff --git a/misc/main.c b/misc/main.c
index ae853fcbf4536488a9bac332243d29c7c1b8215b..b9113a764b8a1555253e214aa87cc8bead57f284 100644
--- a/misc/main.c
+++ b/misc/main.c
@@ -1030,7 +1030,7 @@ LPVOID GetEnvironmentStringsW(void)
 		wenvtable[count]=(WCHAR)envtable[count];
 	free(envtable);
 
-    return envtable;
+    return wenvtable;
 }
 
 void FreeEnvironmentStringsA(void *e)
diff --git a/misc/registry.c b/misc/registry.c
index a0606ff5d255d9fe401e8bea622fbe13957ad3f5..b5ba088a9b348cda32941ed0b5385c63dd6ef69a 100644
--- a/misc/registry.c
+++ b/misc/registry.c
@@ -1204,7 +1204,8 @@ _w95_loadreg(char* fn,LPKEYSTRUCT lpkey) {
 	}
 	free(data);
 
-	qsort(nr2da,nrofdkes,sizeof(nr2da[0]),_w95dkecomp);
+	qsort(nr2da,nrofdkes,sizeof(nr2da[0]),
+              (int(*)(const void *,const void*))_w95dkecomp);
 
 	/* STEP 2: keydata & values */
 	if (!GetFileInformationByHandle(hfd,&hfdinfo))
diff --git a/misc/shell.c b/misc/shell.c
index 90f89cab44b60ecd9f553bf39ae7ce7e3cc4489c..3bec8c7438246c999b2d86a2ac2ae93a3013c06c 100644
--- a/misc/shell.c
+++ b/misc/shell.c
@@ -395,9 +395,9 @@ INT ShellAbout(HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff, HICON16 hIcon)
     handle = SYSRES_LoadResource( SYSRES_DIALOG_SHELL_ABOUT_MSGBOX );
     if (!handle) return FALSE;
     bRet = DialogBoxIndirectParam16( WIN_GetWindowInstance( hWnd ),
-                                   handle, hWnd,
-                                   MODULE_GetWndProcEntry16("AboutDlgProc"), 
-				   (LONG)hIcon );
+                                     handle, hWnd,
+                                     (DLGPROC16)MODULE_GetWndProcEntry16("AboutDlgProc"), 
+                                     (LPARAM)hIcon );
     SYSRES_FreeResource( handle );
     return bRet;
 }
diff --git a/misc/ver.c b/misc/ver.c
index d3043cab1fbb9435b1f58798d761bef6988b336d..c53ba8534e2527e0e90c9fe13a31907fcc61b0eb 100644
--- a/misc/ver.c
+++ b/misc/ver.c
@@ -408,31 +408,37 @@ VerFindFile16(
 DWORD
 VerFindFile32A(
 	UINT32 flags,LPCSTR filename,LPCSTR windir,LPCSTR appdir,
-	LPSTR curdir,UINT32 *curdirlen,LPSTR destdir,UINT32 *destdirlen
-) {
-	return VerFindFile16(flags,filename,windir,appdir,curdir,curdirlen,destdir,destdirlen);
+	LPSTR curdir,UINT32 *pcurdirlen,LPSTR destdir,UINT32 *pdestdirlen )
+{
+    UINT16 curdirlen, destdirlen;
+    DWORD ret = VerFindFile16(flags,filename,windir,appdir,
+                              curdir,&curdirlen,destdir,&destdirlen);
+    *pcurdirlen = curdirlen;
+    *pdestdirlen = destdirlen;
+    return ret;
 }
 
 /* VerFindFileW						[VERSION.6] */
 DWORD
 VerFindFile32W(
 	UINT32 flags,LPCWSTR filename,LPCWSTR windir,LPCWSTR appdir,
-	LPWSTR curdir,UINT32 *curdirlen,LPWSTR destdir,UINT32 *destdirlen
-) {
-	LPSTR	wfn,wwd,wad,wdd,wcd;
-	DWORD	ret;
-
-	wfn = strdupW2A(filename);
-	wwd = strdupW2A(windir);
-	wad = strdupW2A(appdir);
-	wcd = (LPSTR)malloc(*curdirlen);
-	wdd = (LPSTR)malloc(*destdirlen);
-	ret=VerFindFile16(flags,wfn,wwd,wad,wcd,curdirlen,wdd,destdirlen);
-	STRING32_AnsiToUni(curdir,wcd);
-	STRING32_AnsiToUni(destdir,wdd);
-	*curdirlen	= strlen(wcd);
-	*destdirlen	= strlen(wdd);
-	return ret;
+	LPWSTR curdir,UINT32 *pcurdirlen,LPWSTR destdir,UINT32 *pdestdirlen )
+{
+    UINT16 curdirlen, destdirlen;
+    LPSTR wfn,wwd,wad,wdd,wcd;
+    DWORD ret;
+
+    wfn = strdupW2A(filename);
+    wwd = strdupW2A(windir);
+    wad = strdupW2A(appdir);
+    wcd = (LPSTR)malloc(*pcurdirlen);
+    wdd = (LPSTR)malloc(*pdestdirlen);
+    ret=VerFindFile16(flags,wfn,wwd,wad,wcd,&curdirlen,wdd,&destdirlen);
+    STRING32_AnsiToUni(curdir,wcd);
+    STRING32_AnsiToUni(destdir,wdd);
+    *pcurdirlen = strlen(wcd);
+    *pdestdirlen = strlen(wdd);
+    return ret;
 }
 
 /* VerInstallFile					[VER.9] */
@@ -454,9 +460,13 @@ VerInstallFile16(
 DWORD
 VerInstallFile32A(
 	UINT32 flags,LPCSTR srcfilename,LPCSTR destfilename,LPCSTR srcdir,
-	LPCSTR destdir,LPSTR tmpfile,UINT32 *tmpfilelen
-) {
-	return VerInstallFile16(flags,srcfilename,destfilename,srcdir,destdir,tmpfile,tmpfilelen);
+	LPCSTR destdir,LPSTR tmpfile,UINT32 *tmpfilelen )
+{
+    UINT16 filelen;
+    DWORD ret= VerInstallFile16(flags,srcfilename,destfilename,srcdir,
+                                destdir,tmpfile,&filelen);
+    *tmpfilelen = filelen;
+    return ret;
 }
 
 /* VerFindFileW					[VERSION.6] */
diff --git a/miscemu/int21.c b/miscemu/int21.c
index fb5aff479bbe9036f4a7ac536ac5d7026a6bebd1..d701a8bc01594bc76eb3c8e8d405d0a584062577 100644
--- a/miscemu/int21.c
+++ b/miscemu/int21.c
@@ -592,7 +592,7 @@ static int INT21_FindNext( SIGCONTEXT *context )
     int count;
 
     if (!dta->unixPath) return 0;
-    if (!(count = DOSFS_FindNext( dta->unixPath, dta->mask, dta->drive,
+    if (!(count = DOSFS_FindNext( dta->unixPath, dta->mask, NULL, dta->drive,
                                   dta->search_attr, dta->count, &entry )))
     {
         free( dta->unixPath );
@@ -741,7 +741,7 @@ static int INT21_FindNextFCB( SIGCONTEXT *context )
     }
 
     if (!pFCB->unixPath) return 0;
-    if (!(count = DOSFS_FindNext( pFCB->unixPath, pFCB->filename,
+    if (!(count = DOSFS_FindNext( pFCB->unixPath, pFCB->filename, NULL,
                                   DOS_GET_DRIVE( pFCB->drive ), attr,
                                   pFCB->count, &entry )))
     {
diff --git a/miscemu/vxd.c b/miscemu/vxd.c
index 0a5a1889deab0d233da8c2506dfe67bade7213e0..92bf08eeb4dfed82bd1c46d72e5b531a9d4f8697 100644
--- a/miscemu/vxd.c
+++ b/miscemu/vxd.c
@@ -13,6 +13,14 @@
 #include "debug.h"
 
 
+#define VXD_BARF(context,name) \
+    fprintf( stderr, "vxd %s: unknown/not implemented parameters:\n" \
+                     "vxd %s: AX %04x, BX %04x, CX %04x, DX %04x, " \
+                     "SI %04x, DI %04x, DS %04x, ES %04x\n", \
+             (name), (name), AX_reg(context), BX_reg(context), \
+             CX_reg(context), DX_reg(context), SI_reg(context), \
+             DI_reg(context), DS_reg(context), ES_reg(context) )
+
 /***********************************************************************
  *           VXD_PageFile
  */
@@ -52,7 +60,7 @@ void VXD_PageFile( SIGCONTEXT *context )
     case 0x05: /* cancel?? INTERRUP.D */
     case 0x06: /* test I/O valid INTERRUP.D */
     default:
-	INT_BARF( context, 0x2f);
+	VXD_BARF( context, "pagefile" );
 	break;
     }
 }
@@ -79,7 +87,7 @@ void VXD_Shell( SIGCONTEXT *context )
     case 0x0004:
     case 0x0005:
 	dprintf_vxd(stddeb,"VxD Shell: EDX = %08lx\n",EDX_reg(context));
-	INT_BARF( context, 0x2f);
+	VXD_BARF( context, "shell" );
 	break;
 
     case 0x0006: /* SHELL_Get_VM_State */
@@ -110,7 +118,7 @@ void VXD_Shell( SIGCONTEXT *context )
     case 0x0016:
     default:
  	dprintf_vxd(stddeb,"VxD Shell: EDX = %08lx\n",EDX_reg(context)); 
-	INT_BARF( context, 0x2f);
+	VXD_BARF( context, "shell");
 	break;
     }
 }
@@ -135,6 +143,6 @@ void VXD_Comm( SIGCONTEXT *context )
     case 0x0002: /* get focus */
     case 0x0003: /* virtualise port */
     default:
-        INT_BARF( context, 0x2f);
+        VXD_BARF( context, "comm" );
     }
 }
diff --git a/objects/bitmap.c b/objects/bitmap.c
index 926f176e61775b2302fa0e3cf2623345f025201f..8d3d57c9f11949fee188157a840e2d5d9b945d23 100644
--- a/objects/bitmap.c
+++ b/objects/bitmap.c
@@ -430,7 +430,7 @@ HBITMAP16 BITMAP_SelectObject( DC * dc, HBITMAP16 hbitmap,
        SetRectRgn(dc->w.hVisRgn, 0, 0, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight );
     else
     { 
-       hrgn = CreateRectRgn( 0, 0, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight );
+       hrgn = CreateRectRgn32(0, 0, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight);
        if (!hrgn) return 0;
        dc->w.hVisRgn    = hrgn;
     }
diff --git a/objects/brush.c b/objects/brush.c
index 38161704cf08dd5f34808940eb214d809273f0b2..ecb71cc4ce910e249d2c1e17c1832d0b7a9a8a48 100644
--- a/objects/brush.c
+++ b/objects/brush.c
@@ -4,6 +4,7 @@
  * Copyright 1993, 1994  Alexandre Julliard
  */
 
+#define NO_TRANSITION_TYPES  /* This file is Win32-clean */
 #include <stdlib.h>
 #include "brush.h"
 #include "bitmap.h"
@@ -93,7 +94,7 @@ static XImage *ditherImage = NULL;
  *
  * Create the X image used for dithering.
  */
-BOOL BRUSH_Init(void)
+BOOL32 BRUSH_Init(void)
 {
     XCREATEIMAGE( ditherImage, MATRIX_SIZE, MATRIX_SIZE, screenDepth );
     return (ditherImage != NULL);
@@ -139,37 +140,76 @@ Pixmap BRUSH_DitherColor( DC *dc, COLORREF color )
 
 
 /***********************************************************************
- *           CreateBrushIndirect    (GDI.50)
+ *           CreateBrushIndirect16    (GDI.50)
  */
-HBRUSH16 CreateBrushIndirect( const LOGBRUSH16 * brush )
+HBRUSH16 CreateBrushIndirect16( const LOGBRUSH16 * brush )
 {
     BRUSHOBJ * brushPtr;
     HBRUSH16 hbrush = GDI_AllocObject( sizeof(BRUSHOBJ), BRUSH_MAGIC );
     if (!hbrush) return 0;
     brushPtr = (BRUSHOBJ *) GDI_HEAP_LIN_ADDR( hbrush );
-    memcpy( &brushPtr->logbrush, brush, sizeof(*brush) );
+    brushPtr->logbrush.lbStyle = brush->lbStyle;
+    brushPtr->logbrush.lbColor = brush->lbColor;
+    brushPtr->logbrush.lbHatch = brush->lbHatch;
     return hbrush;
 }
 
 
 /***********************************************************************
- *           CreateHatchBrush    (GDI.58)
+ *           CreateBrushIndirect32    (GDI32.27)
  */
-HBRUSH16 CreateHatchBrush( INT style, COLORREF color )
+HBRUSH32 CreateBrushIndirect32( const LOGBRUSH32 * brush )
 {
-    LOGBRUSH16 logbrush = { BS_HATCHED, color, style };
-    dprintf_gdi(stddeb, "CreateHatchBrush: %d %06lx\n", style, color );
+    BRUSHOBJ * brushPtr;
+    HBRUSH32 hbrush = GDI_AllocObject( sizeof(BRUSHOBJ), BRUSH_MAGIC );
+    if (!hbrush) return 0;
+    brushPtr = (BRUSHOBJ *) GDI_HEAP_LIN_ADDR( hbrush );
+    brushPtr->logbrush.lbStyle = brush->lbStyle;
+    brushPtr->logbrush.lbColor = brush->lbColor;
+    brushPtr->logbrush.lbHatch = brush->lbHatch;
+    return hbrush;
+}
+
+
+/***********************************************************************
+ *           CreateHatchBrush16    (GDI.58)
+ */
+HBRUSH16 CreateHatchBrush16( INT16 style, COLORREF color )
+{
+    LOGBRUSH32 logbrush = { BS_HATCHED, color, style };
+    dprintf_gdi(stddeb, "CreateHatchBrush16: %d %06lx\n", style, color );
     if ((style < 0) || (style >= NB_HATCH_STYLES)) return 0;
-    return CreateBrushIndirect( &logbrush );
+    return CreateBrushIndirect32( &logbrush );
+}
+
+
+/***********************************************************************
+ *           CreateHatchBrush32    (GDI32.48)
+ */
+HBRUSH32 CreateHatchBrush32( INT32 style, COLORREF color )
+{
+    LOGBRUSH32 logbrush = { BS_HATCHED, color, style };
+    dprintf_gdi(stddeb, "CreateHatchBrush32: %d %06lx\n", style, color );
+    if ((style < 0) || (style >= NB_HATCH_STYLES)) return 0;
+    return CreateBrushIndirect32( &logbrush );
+}
+
+
+/***********************************************************************
+ *           CreatePatternBrush16    (GDI.60)
+ */
+HBRUSH16 CreatePatternBrush16( HBITMAP16 hbitmap )
+{
+    return (HBRUSH16)CreatePatternBrush32( hbitmap );
 }
 
 
 /***********************************************************************
- *           CreatePatternBrush    (GDI.60)
+ *           CreatePatternBrush32    (GDI32.54)
  */
-HBRUSH16 CreatePatternBrush( HBITMAP16 hbitmap )
+HBRUSH32 CreatePatternBrush32( HBITMAP32 hbitmap )
 {
-    LOGBRUSH16 logbrush = { BS_PATTERN, 0, 0 };
+    LOGBRUSH32 logbrush = { BS_PATTERN, 0, 0 };
     BITMAPOBJ *bmp, *newbmp;
 
     dprintf_gdi(stddeb, "CreatePatternBrush: %04x\n", hbitmap );
@@ -178,29 +218,65 @@ HBRUSH16 CreatePatternBrush( HBITMAP16 hbitmap )
 
     if (!(bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC )))
 	return 0;
-    logbrush.lbHatch = (INT16)CreateBitmapIndirect16( &bmp->bitmap );
-    newbmp = (BITMAPOBJ *) GDI_GetObjPtr( (HGDIOBJ16)logbrush.lbHatch, BITMAP_MAGIC );
+    logbrush.lbHatch = (INT32)CreateBitmapIndirect16( &bmp->bitmap );
+    newbmp = (BITMAPOBJ *) GDI_GetObjPtr( (HGDIOBJ32)logbrush.lbHatch,
+                                          BITMAP_MAGIC );
     if (!newbmp) return 0;
     XCopyArea( display, bmp->pixmap, newbmp->pixmap, BITMAP_GC(bmp),
 	       0, 0, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight, 0, 0 );
-    return CreateBrushIndirect( &logbrush );
+    return CreateBrushIndirect32( &logbrush );
+}
+
+
+/***********************************************************************
+ *           CreateDIBPatternBrush16    (GDI.445)
+ */
+HBRUSH16 CreateDIBPatternBrush16( HGLOBAL16 hbitmap, UINT16 coloruse )
+{
+    LOGBRUSH32 logbrush = { BS_DIBPATTERN, coloruse, 0 };
+    BITMAPINFO *info, *newInfo;
+    INT32 size;
+    
+    dprintf_gdi(stddeb, "CreateDIBPatternBrush: %04x\n", hbitmap );
+
+      /* Make a copy of the bitmap */
+
+    if (!(info = (BITMAPINFO *)GlobalLock16( hbitmap ))) return 0;
+
+    if (info->bmiHeader.biCompression)
+        size = info->bmiHeader.biSizeImage;
+    else
+	size = (info->bmiHeader.biWidth * info->bmiHeader.biBitCount + 31) / 32
+	         * 8 * info->bmiHeader.biHeight;
+    size += DIB_BitmapInfoSize( info, coloruse );
+
+    if (!(logbrush.lbHatch = (INT16)GlobalAlloc16( GMEM_MOVEABLE, size )))
+    {
+	GlobalUnlock16( hbitmap );
+	return 0;
+    }
+    newInfo = (BITMAPINFO *) GlobalLock16( (HGLOBAL16)logbrush.lbHatch );
+    memcpy( newInfo, info, size );
+    GlobalUnlock16( (HGLOBAL16)logbrush.lbHatch );
+    GlobalUnlock16( hbitmap );
+    return CreateBrushIndirect32( &logbrush );
 }
 
 
 /***********************************************************************
- *           CreateDIBPatternBrush    (GDI.445)
+ *           CreateDIBPatternBrush32    (GDI32.34)
  */
-HBRUSH16 CreateDIBPatternBrush( HGLOBAL16 hbitmap, UINT coloruse )
+HBRUSH32 CreateDIBPatternBrush32( HGLOBAL32 hbitmap, UINT32 coloruse )
 {
-    LOGBRUSH16 logbrush = { BS_DIBPATTERN, coloruse, 0 };
+    LOGBRUSH32 logbrush = { BS_DIBPATTERN, coloruse, 0 };
     BITMAPINFO *info, *newInfo;
-    int size;
+    INT32 size;
     
     dprintf_gdi(stddeb, "CreateDIBPatternBrush: %04x\n", hbitmap );
 
       /* Make a copy of the bitmap */
 
-    if (!(info = (BITMAPINFO *) GlobalLock16( hbitmap ))) return 0;
+    if (!(info = (BITMAPINFO *)GlobalLock32( hbitmap ))) return 0;
 
     if (info->bmiHeader.biCompression)
         size = info->bmiHeader.biSizeImage;
@@ -209,7 +285,7 @@ HBRUSH16 CreateDIBPatternBrush( HGLOBAL16 hbitmap, UINT coloruse )
 	         * 8 * info->bmiHeader.biHeight;
     size += DIB_BitmapInfoSize( info, coloruse );
 
-    if (!(logbrush.lbHatch = (INT)GlobalAlloc16( GMEM_MOVEABLE, size )))
+    if (!(logbrush.lbHatch = (INT32)GlobalAlloc16( GMEM_MOVEABLE, size )))
     {
 	GlobalUnlock16( hbitmap );
 	return 0;
@@ -218,18 +294,29 @@ HBRUSH16 CreateDIBPatternBrush( HGLOBAL16 hbitmap, UINT coloruse )
     memcpy( newInfo, info, size );
     GlobalUnlock16( (HGLOBAL16)logbrush.lbHatch );
     GlobalUnlock16( hbitmap );
-    return CreateBrushIndirect( &logbrush );
+    return CreateBrushIndirect32( &logbrush );
 }
 
 
 /***********************************************************************
  *           CreateSolidBrush    (GDI.66)
  */
-HBRUSH16 CreateSolidBrush( COLORREF color )
+HBRUSH16 CreateSolidBrush16( COLORREF color )
+{
+    LOGBRUSH32 logbrush = { BS_SOLID, color, 0 };
+    dprintf_gdi(stddeb, "CreateSolidBrush16: %06lx\n", color );
+    return CreateBrushIndirect32( &logbrush );
+}
+
+
+/***********************************************************************
+ *           CreateSolidBrush32    (GDI32.64)
+ */
+HBRUSH32 CreateSolidBrush32( COLORREF color )
 {
-    LOGBRUSH16 logbrush = { BS_SOLID, color, 0 };
-    dprintf_gdi(stddeb, "CreateSolidBrush: %06lx\n", color );
-    return CreateBrushIndirect( &logbrush );
+    LOGBRUSH32 logbrush = { BS_SOLID, color, 0 };
+    dprintf_gdi(stddeb, "CreateSolidBrush32: %06lx\n", color );
+    return CreateBrushIndirect32( &logbrush );
 }
 
 
@@ -268,12 +355,22 @@ BOOL32 SetBrushOrgEx( HDC32 hdc, INT32 x, INT32 y, LPPOINT32 oldorg )
 
 
 /***********************************************************************
- *           GetSysColorBrush    (USER.281)
+ *           GetSysColorBrush16    (USER.281)
+ */
+HBRUSH16 GetSysColorBrush16( INT16 index )
+{
+    fprintf( stderr, "Unimplemented stub: GetSysColorBrush16(%d)\n", index );
+    return GetStockObject32(LTGRAY_BRUSH);
+}
+
+
+/***********************************************************************
+ *           GetSysColorBrush32    (USER32.289)
  */
-HBRUSH16 GetSysColorBrush(WORD x)
+HBRUSH32 GetSysColorBrush32( INT32 index)
 {
-    fprintf( stderr, "Unimplemented stub: GetSysColorBrush(%d)\n", x );
-    return GetStockObject(LTGRAY_BRUSH);
+    fprintf( stderr, "Unimplemented stub: GetSysColorBrush32(%d)\n", index );
+    return GetStockObject32(LTGRAY_BRUSH);
 }
 
 
@@ -285,7 +382,7 @@ BOOL32 BRUSH_DeleteObject( HBRUSH16 hbrush, BRUSHOBJ * brush )
     switch(brush->logbrush.lbStyle)
     {
       case BS_PATTERN:
-	  DeleteObject( (HGDIOBJ16)brush->logbrush.lbHatch );
+	  DeleteObject32( (HGDIOBJ32)brush->logbrush.lbHatch );
 	  break;
       case BS_DIBPATTERN:
 	  GlobalFree16( (HGLOBAL16)brush->logbrush.lbHatch );
@@ -296,9 +393,25 @@ BOOL32 BRUSH_DeleteObject( HBRUSH16 hbrush, BRUSHOBJ * brush )
 
 
 /***********************************************************************
- *           BRUSH_GetObject
+ *           BRUSH_GetObject16
  */
-int BRUSH_GetObject( BRUSHOBJ * brush, int count, LPSTR buffer )
+INT16 BRUSH_GetObject16( BRUSHOBJ * brush, INT16 count, LPSTR buffer )
+{
+    LOGBRUSH16 logbrush;
+
+    logbrush.lbStyle = brush->logbrush.lbStyle;
+    logbrush.lbColor = brush->logbrush.lbColor;
+    logbrush.lbHatch = brush->logbrush.lbHatch;
+    if (count > sizeof(logbrush)) count = sizeof(logbrush);
+    memcpy( buffer, &logbrush, count );
+    return count;
+}
+
+
+/***********************************************************************
+ *           BRUSH_GetObject32
+ */
+INT32 BRUSH_GetObject32( BRUSHOBJ * brush, INT32 count, LPSTR buffer )
 {
     if (count > sizeof(brush->logbrush)) count = sizeof(brush->logbrush);
     memcpy( buffer, &brush->logbrush, count );
@@ -330,7 +443,7 @@ static void BRUSH_SelectSolidBrush( DC *dc, COLORREF color )
 /***********************************************************************
  *           BRUSH_SelectPatternBrush
  */
-static BOOL BRUSH_SelectPatternBrush( DC * dc, HBITMAP16 hbitmap )
+static BOOL32 BRUSH_SelectPatternBrush( DC * dc, HBITMAP32 hbitmap )
 {
     BITMAPOBJ * bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
     if (!bmp) return FALSE;
@@ -357,7 +470,7 @@ static BOOL BRUSH_SelectPatternBrush( DC * dc, HBITMAP16 hbitmap )
 /***********************************************************************
  *           BRUSH_SelectObject
  */
-HBRUSH16 BRUSH_SelectObject( DC * dc, HBRUSH16 hbrush, BRUSHOBJ * brush )
+HBRUSH32 BRUSH_SelectObject( DC * dc, HBRUSH32 hbrush, BRUSHOBJ * brush )
 {
     HBITMAP16 hBitmap;
     BITMAPINFO * bmpInfo;
@@ -367,22 +480,22 @@ HBRUSH16 BRUSH_SelectObject( DC * dc, HBRUSH16 hbrush, BRUSHOBJ * brush )
                 dc->hSelf,hbrush);
     if (dc->header.wMagic == METAFILE_DC_MAGIC)
     {
+        LOGBRUSH16 logbrush = { brush->logbrush.lbStyle,
+                                brush->logbrush.lbColor,
+                                brush->logbrush.lbHatch };
 	switch (brush->logbrush.lbStyle)
 	{
 	case BS_SOLID:
 	case BS_HATCHED:
 	case BS_HOLLOW:
-	    if (!MF_CreateBrushIndirect(dc, hbrush, &(brush->logbrush)))
-		return (HBRUSH16)0;
+	    if (!MF_CreateBrushIndirect( dc, hbrush, &logbrush )) return 0;
 	    break;
-
 	case BS_PATTERN:
 	case BS_DIBPATTERN:
-	    if (!MF_CreatePatternBrush(dc, hbrush, &(brush->logbrush)))
-		return (HBRUSH16)0;
+	    if (!MF_CreatePatternBrush( dc, hbrush, &logbrush )) return 0;
 	    break;
 	}
-	return (HBRUSH16)1;
+	return 1;  /* FIXME? */
     }
     
     dc->w.hBrush = hbrush;
@@ -427,7 +540,7 @@ HBRUSH16 BRUSH_SelectObject( DC * dc, HBRUSH16 hbrush, BRUSHOBJ * brush )
 				      ((char *)bmpInfo) + size, bmpInfo,
 				      (WORD) brush->logbrush.lbColor );
 	    BRUSH_SelectPatternBrush( dc, hBitmap );
-	    DeleteObject( hBitmap );
+	    DeleteObject16( hBitmap );
 	    GlobalUnlock16( (HGLOBAL16)brush->logbrush.lbHatch );	    
 	}
 	
diff --git a/objects/clipping.c b/objects/clipping.c
index f5a7c273f736d0e5d47c884c5bb3649211f02e77..c7f55fc3e2c5a32e716ce09c3863b6f3b912d742 100644
--- a/objects/clipping.c
+++ b/objects/clipping.c
@@ -4,12 +4,12 @@
  * Copyright 1993 Alexandre Julliard
  */
 
+#define NO_TRANSITION_TYPES  /* This file is Win32-clean */
 #include <stdio.h>
 #include "dc.h"
 #include "metafile.h"
 #include "region.h"
 #include "stddebug.h"
-/* #define DEBUG_CLIPPING */
 #include "debug.h"
 
 #define UPDATE_DIRTY_DC(dc) \
@@ -27,7 +27,7 @@
  */
 void CLIPPING_UpdateGCRegion( DC * dc )
 {
-    if (!dc->w.hGCClipRgn) dc->w.hGCClipRgn = CreateRectRgn( 0, 0, 0, 0 );
+    if (!dc->w.hGCClipRgn) dc->w.hGCClipRgn = CreateRectRgn32( 0, 0, 0, 0 );
 
     if (!dc->w.hVisRgn)
     {
@@ -42,19 +42,28 @@ void CLIPPING_UpdateGCRegion( DC * dc )
     }
 
     if (!dc->w.hClipRgn)
-        CombineRgn( dc->w.hGCClipRgn, dc->w.hVisRgn, 0, RGN_COPY );
+        CombineRgn32( dc->w.hGCClipRgn, dc->w.hVisRgn, 0, RGN_COPY );
     else
-        CombineRgn( dc->w.hGCClipRgn, dc->w.hClipRgn, dc->w.hVisRgn, RGN_AND );
+        CombineRgn32(dc->w.hGCClipRgn, dc->w.hClipRgn, dc->w.hVisRgn, RGN_AND);
     if (dc->funcs->pSetDeviceClipping) dc->funcs->pSetDeviceClipping( dc );
 }
 
 
 /***********************************************************************
- *           SelectClipRgn    (GDI.44)
+ *           SelectClipRgn16    (GDI.44)
  */
-int SelectClipRgn( HDC16 hdc, HRGN32 hrgn )
+INT16 SelectClipRgn16( HDC16 hdc, HRGN16 hrgn )
 {
-    int retval;
+    return (INT16)SelectClipRgn32( hdc, hrgn );
+}
+
+
+/***********************************************************************
+ *           SelectClipRgn32    (GDI32.297)
+ */
+INT32 SelectClipRgn32( HDC32 hdc, HRGN32 hrgn )
+{
+    INT32 retval;
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc) return ERROR;
 
@@ -62,12 +71,12 @@ int SelectClipRgn( HDC16 hdc, HRGN32 hrgn )
 
     if (hrgn)
     {
-	if (!dc->w.hClipRgn) dc->w.hClipRgn = CreateRectRgn(0,0,0,0);
-	retval = CombineRgn( dc->w.hClipRgn, hrgn, 0, RGN_COPY );
+	if (!dc->w.hClipRgn) dc->w.hClipRgn = CreateRectRgn32(0,0,0,0);
+	retval = CombineRgn32( dc->w.hClipRgn, hrgn, 0, RGN_COPY );
     }
     else
     {
-	if (dc->w.hClipRgn) DeleteObject( dc->w.hClipRgn );
+	if (dc->w.hClipRgn) DeleteObject16( dc->w.hClipRgn );
 	dc->w.hClipRgn = 0;
 	retval = SIMPLEREGION; /* Clip region == whole DC */
     }
@@ -80,7 +89,7 @@ int SelectClipRgn( HDC16 hdc, HRGN32 hrgn )
 /***********************************************************************
  *           SelectVisRgn    (GDI.105)
  */
-int SelectVisRgn( HDC16 hdc, HRGN32 hrgn )
+INT16 SelectVisRgn( HDC16 hdc, HRGN16 hrgn )
 {
     int retval;
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
@@ -90,16 +99,25 @@ int SelectVisRgn( HDC16 hdc, HRGN32 hrgn )
 
     dc->w.flags &= ~DC_DIRTY;
 
-    retval = CombineRgn( dc->w.hVisRgn, hrgn, 0, RGN_COPY );
+    retval = CombineRgn16( dc->w.hVisRgn, hrgn, 0, RGN_COPY );
     CLIPPING_UpdateGCRegion( dc );
     return retval;
 }
 
 
 /***********************************************************************
- *           OffsetClipRgn    (GDI.32)
+ *           OffsetClipRgn16    (GDI.32)
+ */
+INT16 OffsetClipRgn16( HDC16 hdc, INT16 x, INT16 y )
+{
+    return (INT16)OffsetClipRgn32( hdc, x, y );
+}
+
+
+/***********************************************************************
+ *           OffsetClipRgn32    (GDI32.255)
  */
-int OffsetClipRgn( HDC16 hdc, short x, short y )
+INT32 OffsetClipRgn32( HDC32 hdc, INT32 x, INT32 y )
 {
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc) 
@@ -114,9 +132,9 @@ int OffsetClipRgn( HDC16 hdc, short x, short y )
 
     if (dc->w.hClipRgn)
     {
-	int retval = OffsetRgn( dc->w.hClipRgn, XLPTODP(dc,x), YLPTODP(dc,y) );
+	INT32 ret = OffsetRgn32( dc->w.hClipRgn, XLPTODP(dc,x), YLPTODP(dc,y));
 	CLIPPING_UpdateGCRegion( dc );
-	return retval;
+	return ret;
     }
     else return SIMPLEREGION; /* Clip region == client area */
 }
@@ -125,13 +143,13 @@ int OffsetClipRgn( HDC16 hdc, short x, short y )
 /***********************************************************************
  *           OffsetVisRgn    (GDI.102)
  */
-int OffsetVisRgn( HDC16 hdc, short x, short y )
+INT16 OffsetVisRgn( HDC16 hdc, INT16 x, INT16 y )
 {
-    int retval;
+    INT16 retval;
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc) return ERROR;    
     dprintf_clipping(stddeb, "OffsetVisRgn: %04x %d,%d\n", hdc, x, y );
-    retval = OffsetRgn( dc->w.hVisRgn, x, y );
+    retval = OffsetRgn32( dc->w.hVisRgn, x, y );
     CLIPPING_UpdateGCRegion( dc );
     return retval;
 }
@@ -144,14 +162,14 @@ int OffsetVisRgn( HDC16 hdc, short x, short y )
  * elsewhere (like ExtTextOut()) to skip redundant metafile update and
  * coordinate conversion.
  */
-int CLIPPING_IntersectClipRect( DC * dc, short left, short top,
-                                         short right, short bottom, UINT16 flags)
+INT32 CLIPPING_IntersectClipRect( DC * dc, INT32 left, INT32 top,
+                                  INT32 right, INT32 bottom, UINT32 flags )
 {
     HRGN32 newRgn;
-    int 	ret;
+    INT32 ret;
 
-    if ( !(newRgn = CreateRectRgn( left, top, right, bottom )) ) return ERROR;
-    if ( !dc->w.hClipRgn )
+    if (!(newRgn = CreateRectRgn32( left, top, right, bottom ))) return ERROR;
+    if (!dc->w.hClipRgn)
     {
        if( flags & CLIP_INTERSECT )
        {
@@ -161,24 +179,34 @@ int CLIPPING_IntersectClipRect( DC * dc, short left, short top,
        return SIMPLEREGION;
     }
 
-    ret = CombineRgn( newRgn, dc->w.hClipRgn, newRgn, 
-			     (flags & CLIP_EXCLUDE)? RGN_DIFF : RGN_AND);
+    ret = CombineRgn32( newRgn, dc->w.hClipRgn, newRgn, 
+                        (flags & CLIP_EXCLUDE) ? RGN_DIFF : RGN_AND );
     if (ret != ERROR)
     {
-        if ( !(flags & CLIP_KEEPRGN) ) DeleteObject( dc->w.hClipRgn );
+        if (!(flags & CLIP_KEEPRGN)) DeleteObject32( dc->w.hClipRgn );
         dc->w.hClipRgn = newRgn;    
         CLIPPING_UpdateGCRegion( dc );
     }
-    else DeleteObject( newRgn );
+    else DeleteObject32( newRgn );
     return ret;
 }
 
 
 /***********************************************************************
- *           ExcludeClipRect    (GDI.21)
+ *           ExcludeClipRect16    (GDI.21)
+ */
+INT16 ExcludeClipRect16( HDC16 hdc, INT16 left, INT16 top,
+                         INT16 right, INT16 bottom )
+{
+    return (INT16)ExcludeClipRect32( hdc, left, top, right, bottom );
+}
+
+
+/***********************************************************************
+ *           ExcludeClipRect32    (GDI32.92)
  */
-int ExcludeClipRect( HDC16 hdc, short left, short top,
-		     short right, short bottom )
+INT32 ExcludeClipRect32( HDC32 hdc, INT32 left, INT32 top,
+                         INT32 right, INT32 bottom )
 {
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc) 
@@ -201,10 +229,20 @@ int ExcludeClipRect( HDC16 hdc, short left, short top,
 
 
 /***********************************************************************
- *           IntersectClipRect    (GDI.22)
+ *           IntersectClipRect16    (GDI.22)
+ */
+INT16 IntersectClipRect16( HDC16 hdc, INT16 left, INT16 top,
+                           INT16 right, INT16 bottom )
+{
+    return (INT16)IntersectClipRect32( hdc, left, top, right, bottom );
+}
+
+
+/***********************************************************************
+ *           IntersectClipRect32    (GDI32.245)
  */
-int IntersectClipRect( HDC16 hdc, short left, short top,
-		       short right, short bottom )
+INT32 IntersectClipRect32( HDC32 hdc, INT32 left, INT32 top,
+                           INT32 right, INT32 bottom )
 {
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc) 
@@ -231,37 +269,38 @@ int IntersectClipRect( HDC16 hdc, short left, short top,
  *
  * Helper function for {Intersect,Exclude}VisRect
  */
-static int CLIPPING_IntersectVisRect( DC * dc, short left, short top,
-                                      short right, short bottom, BOOL exclude )
+static INT32 CLIPPING_IntersectVisRect( DC * dc, INT32 left, INT32 top,
+                                        INT32 right, INT32 bottom,
+                                        BOOL32 exclude )
 {
     HRGN32 tempRgn, newRgn;
-    int ret;
+    INT32 ret;
 
     left   = XLPTODP( dc, left );
     right  = XLPTODP( dc, right );
     top    = YLPTODP( dc, top );
     bottom = YLPTODP( dc, bottom );
 
-    if (!(newRgn = CreateRectRgn( 0, 0, 0, 0 ))) return ERROR;
-    if (!(tempRgn = CreateRectRgn( left, top, right, bottom )))
+    if (!(newRgn = CreateRectRgn32( 0, 0, 0, 0 ))) return ERROR;
+    if (!(tempRgn = CreateRectRgn32( left, top, right, bottom )))
     {
-        DeleteObject( newRgn );
+        DeleteObject32( newRgn );
         return ERROR;
     }
-    ret = CombineRgn( newRgn, dc->w.hVisRgn, tempRgn,
-                      exclude ? RGN_DIFF : RGN_AND);
-    DeleteObject( tempRgn );
+    ret = CombineRgn32( newRgn, dc->w.hVisRgn, tempRgn,
+                        exclude ? RGN_DIFF : RGN_AND );
+    DeleteObject32( tempRgn );
 
     if (ret != ERROR)
     {
         RGNOBJ *newObj  = (RGNOBJ*)GDI_GetObjPtr( newRgn, REGION_MAGIC);
         RGNOBJ *prevObj = (RGNOBJ*)GDI_GetObjPtr( dc->w.hVisRgn, REGION_MAGIC);
         if (newObj && prevObj) newObj->header.hNext = prevObj->header.hNext;
-        DeleteObject( dc->w.hVisRgn );
+        DeleteObject32( dc->w.hVisRgn );
         dc->w.hVisRgn = newRgn;    
         CLIPPING_UpdateGCRegion( dc );
     }
-    else DeleteObject( newRgn );
+    else DeleteObject32( newRgn );
     return ret;
 }
 
@@ -269,8 +308,8 @@ static int CLIPPING_IntersectVisRect( DC * dc, short left, short top,
 /***********************************************************************
  *           ExcludeVisRect    (GDI.73)
  */
-int ExcludeVisRect( HDC16 hdc, short left, short top,
-                    short right, short bottom )
+INT16 ExcludeVisRect( HDC16 hdc, INT16 left, INT16 top,
+                      INT16 right, INT16 bottom )
 {
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc) return ERROR;    
@@ -284,8 +323,8 @@ int ExcludeVisRect( HDC16 hdc, short left, short top,
 /***********************************************************************
  *           IntersectVisRect    (GDI.98)
  */
-int IntersectVisRect( HDC16 hdc, short left, short top,
-                      short right, short bottom )
+INT16 IntersectVisRect( HDC16 hdc, INT16 left, INT16 top,
+                        INT16 right, INT16 bottom )
 {
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc) return ERROR;    
@@ -297,9 +336,18 @@ int IntersectVisRect( HDC16 hdc, short left, short top,
 
 
 /***********************************************************************
- *           PtVisible    (GDI.103)
+ *           PtVisible16    (GDI.103)
+ */
+BOOL16 PtVisible16( HDC16 hdc, INT16 x, INT16 y )
+{
+    return PtVisible32( hdc, x, y );
+}
+
+
+/***********************************************************************
+ *           PtVisible32    (GDI32.279)
  */
-BOOL PtVisible( HDC16 hdc, short x, short y )
+BOOL32 PtVisible32( HDC32 hdc, INT32 x, INT32 y )
 {
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc) return ERROR;    
@@ -310,7 +358,7 @@ BOOL PtVisible( HDC16 hdc, short x, short y )
     if( dc->w.flags & DC_DIRTY ) UPDATE_DIRTY_DC(dc);
     dc->w.flags &= ~DC_DIRTY;
 
-    return PtInRegion( dc->w.hGCClipRgn, XLPTODP(dc,x), YLPTODP(dc,y) );
+    return PtInRegion32( dc->w.hGCClipRgn, XLPTODP(dc,x), YLPTODP(dc,y) );
 }
 
 
@@ -374,7 +422,7 @@ INT32 GetClipBox32( HDC32 hdc, LPRECT32 rect )
 /***********************************************************************
  *           SaveVisRgn    (GDI.129)
  */
-HRGN32 SaveVisRgn( HDC16 hdc )
+HRGN16 SaveVisRgn( HDC16 hdc )
 {
     HRGN32 copy;
     RGNOBJ *obj, *copyObj;
@@ -391,8 +439,8 @@ HRGN32 SaveVisRgn( HDC16 hdc )
 
     if (!(obj = (RGNOBJ *) GDI_GetObjPtr( dc->w.hVisRgn, REGION_MAGIC )))
 	return 0;
-    if (!(copy = CreateRectRgn( 0, 0, 0, 0 ))) return 0;
-    CombineRgn( copy, dc->w.hVisRgn, 0, RGN_COPY );
+    if (!(copy = CreateRectRgn32( 0, 0, 0, 0 ))) return 0;
+    CombineRgn32( copy, dc->w.hVisRgn, 0, RGN_COPY );
     if (!(copyObj = (RGNOBJ *) GDI_GetObjPtr( copy, REGION_MAGIC )))
 	return 0;
     copyObj->header.hNext = obj->header.hNext;
@@ -404,7 +452,7 @@ HRGN32 SaveVisRgn( HDC16 hdc )
 /***********************************************************************
  *           RestoreVisRgn    (GDI.130)
  */
-int RestoreVisRgn( HDC16 hdc )
+INT16 RestoreVisRgn( HDC16 hdc )
 {
     HRGN32 saved;
     RGNOBJ *obj, *savedObj;
@@ -416,7 +464,7 @@ int RestoreVisRgn( HDC16 hdc )
     if (!(saved = obj->header.hNext)) return ERROR;
     if (!(savedObj = (RGNOBJ *) GDI_GetObjPtr( saved, REGION_MAGIC )))
 	return ERROR;
-    DeleteObject( dc->w.hVisRgn );
+    DeleteObject32( dc->w.hVisRgn );
     dc->w.hVisRgn = saved;
     CLIPPING_UpdateGCRegion( dc );
     return savedObj->xrgn ? COMPLEXREGION : NULLREGION;
diff --git a/objects/cursoricon.c b/objects/cursoricon.c
index 57875c4cb3f8077d46786f2a860a09a1758ce469..a3388af2d255f1e7117d3ca7ceb4f48ade364750 100644
--- a/objects/cursoricon.c
+++ b/objects/cursoricon.c
@@ -335,8 +335,8 @@ HGLOBAL16 CURSORICON_LoadHandler( HGLOBAL16 handle, HINSTANCE16 hInstance,
     if (!(handle = GlobalAlloc16( GMEM_MOVEABLE,
                                   sizeof(CURSORICONINFO) + sizeXor + sizeAnd)))
     {
-        DeleteObject( hXorBits );
-        DeleteObject( hAndBits );
+        DeleteObject32( hXorBits );
+        DeleteObject32( hAndBits );
         return 0;
     }
 
@@ -356,8 +356,8 @@ HGLOBAL16 CURSORICON_LoadHandler( HGLOBAL16 handle, HINSTANCE16 hInstance,
 
     GetBitmapBits( hAndBits, sizeAnd, (char *)(info + 1) );
     GetBitmapBits( hXorBits, sizeXor, (char *)(info + 1) + sizeAnd );
-    DeleteObject( hXorBits );
-    DeleteObject( hAndBits );
+    DeleteObject32( hXorBits );
+    DeleteObject32( hAndBits );
     GlobalUnlock16( handle );
     return handle;
 }
@@ -626,15 +626,15 @@ BOOL DrawIcon( HDC16 hdc, INT x, INT y, HICON16 hIcon )
 
     if (hXorBits && hAndBits)
     {
-        HBITMAP16 hBitTemp = SelectObject( hMemDC, hAndBits );
+        HBITMAP32 hBitTemp = SelectObject32( hMemDC, hAndBits );
         BitBlt( hdc, x, y, ptr->nWidth, ptr->nHeight, hMemDC, 0, 0, SRCAND );
-        SelectObject( hMemDC, hXorBits );
+        SelectObject32( hMemDC, hXorBits );
         BitBlt( hdc, x, y, ptr->nWidth, ptr->nHeight, hMemDC, 0, 0, SRCINVERT);
-        SelectObject( hMemDC, hBitTemp );
+        SelectObject32( hMemDC, hBitTemp );
     }
     DeleteDC( hMemDC );
-    if (hXorBits) DeleteObject( hXorBits );
-    if (hAndBits) DeleteObject( hAndBits );
+    if (hXorBits) DeleteObject32( hXorBits );
+    if (hAndBits) DeleteObject32( hAndBits );
     GlobalUnlock16( hIcon );
     SetTextColor( hdc, oldFg );
     SetBkColor( hdc, oldBg );
diff --git a/objects/dc.c b/objects/dc.c
index 215bc50f04c7a6d3d92df6a935d9222d1d97ba81..834e0f88e54ff797ff0311d1375fd468459d4471 100644
--- a/objects/dc.c
+++ b/objects/dc.c
@@ -185,9 +185,9 @@ void DC_InitDC( DC* dc )
     RealizeDefaultPalette( dc->hSelf );
     SetTextColor( dc->hSelf, dc->w.textColor );
     SetBkColor( dc->hSelf, dc->w.backgroundColor );
-    SelectObject( dc->hSelf, dc->w.hPen );
-    SelectObject( dc->hSelf, dc->w.hBrush );
-    SelectObject( dc->hSelf, dc->w.hFont );
+    SelectObject32( dc->hSelf, dc->w.hPen );
+    SelectObject32( dc->hSelf, dc->w.hBrush );
+    SelectObject32( dc->hSelf, dc->w.hFont );
     CLIPPING_UpdateGCRegion( dc );
 }
 
@@ -379,19 +379,18 @@ HDC16 GetDCState( HDC16 hdc )
 
     memset( &newdc->u.x, 0, sizeof(newdc->u.x) );
     memcpy( &newdc->w, &dc->w, sizeof(dc->w) );
-    memcpy( &newdc->u.x.pen, &dc->u.x.pen, sizeof(dc->u.x.pen) );
 
     newdc->hSelf = (HDC32)handle;
     newdc->saveLevel = 0;
     newdc->w.flags |= DC_SAVED;
 
     newdc->w.hGCClipRgn = 0;
-    newdc->w.hVisRgn = CreateRectRgn( 0, 0, 0, 0 );
-    CombineRgn( newdc->w.hVisRgn, dc->w.hVisRgn, 0, RGN_COPY );	
+    newdc->w.hVisRgn = CreateRectRgn32( 0, 0, 0, 0 );
+    CombineRgn32( newdc->w.hVisRgn, dc->w.hVisRgn, 0, RGN_COPY );	
     if (dc->w.hClipRgn)
     {
-	newdc->w.hClipRgn = CreateRectRgn( 0, 0, 0, 0 );
-	CombineRgn( newdc->w.hClipRgn, dc->w.hClipRgn, 0, RGN_COPY );
+	newdc->w.hClipRgn = CreateRectRgn32( 0, 0, 0, 0 );
+	CombineRgn32( newdc->w.hClipRgn, dc->w.hClipRgn, 0, RGN_COPY );
     }
     return handle;
 }
@@ -402,37 +401,56 @@ HDC16 GetDCState( HDC16 hdc )
  */
 void SetDCState( HDC16 hdc, HDC16 hdcs )
 {
-    DC * dc, * dcs;
-    HRGN32 hVisRgn, hClipRgn, hGCClipRgn;
-    HFONT16 hfont;
-    HBRUSH16 hbrush;
+    DC *dc, *dcs;
     
     if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return;
     if (!(dcs = (DC *) GDI_GetObjPtr( hdcs, DC_MAGIC ))) return;
     if (!dcs->w.flags & DC_SAVED) return;
     dprintf_dc(stddeb, "SetDCState: %04x %04x\n", hdc, hdcs );
 
-      /* Save the regions, font & brush before overwriting everything */
-    hVisRgn    = dc->w.hVisRgn;
-    hClipRgn   = dc->w.hClipRgn;
-    hGCClipRgn = dc->w.hGCClipRgn;
-    hfont      = dc->w.hFont;
-    hbrush     = dc->w.hBrush;
-    memcpy( &dc->w, &dcs->w, sizeof(dc->w) );
-    memcpy( &dc->u.x.pen, &dcs->u.x.pen, sizeof(dc->u.x.pen) );
-    dc->w.flags &= ~DC_SAVED;
-
-      /* Restore the regions */
-    dc->w.hVisRgn    = hVisRgn;
-    dc->w.hClipRgn   = hClipRgn;
-    dc->w.hGCClipRgn = hGCClipRgn;
-    dc->w.hFont      = hfont;
-    dc->w.hBrush     = hbrush;
-    CombineRgn( dc->w.hVisRgn, dcs->w.hVisRgn, 0, RGN_COPY );
-    SelectClipRgn( hdc, dcs->w.hClipRgn );
-
-    SelectObject( hdc, dcs->w.hBrush );
-    SelectObject( hdc, dcs->w.hFont );
+    dc->w.flags           = dcs->w.flags & ~DC_SAVED;
+    dc->w.devCaps         = dcs->w.devCaps;
+    dc->w.hFirstBitmap    = dcs->w.hFirstBitmap;
+    dc->w.hDevice         = dcs->w.hDevice;
+    dc->w.ROPmode         = dcs->w.ROPmode;
+    dc->w.polyFillMode    = dcs->w.polyFillMode;
+    dc->w.stretchBltMode  = dcs->w.stretchBltMode;
+    dc->w.relAbsMode      = dcs->w.relAbsMode;
+    dc->w.backgroundMode  = dcs->w.backgroundMode;
+    dc->w.backgroundColor = dcs->w.backgroundColor;
+    dc->w.textColor       = dcs->w.textColor;
+    dc->w.backgroundPixel = dcs->w.backgroundPixel;
+    dc->w.textPixel       = dcs->w.textPixel;
+    dc->w.brushOrgX       = dcs->w.brushOrgX;
+    dc->w.brushOrgY       = dcs->w.brushOrgY;
+    dc->w.textAlign       = dcs->w.textAlign;
+    dc->w.charExtra       = dcs->w.charExtra;
+    dc->w.breakTotalExtra = dcs->w.breakTotalExtra;
+    dc->w.breakCount      = dcs->w.breakCount;
+    dc->w.breakExtra      = dcs->w.breakExtra;
+    dc->w.breakRem        = dcs->w.breakRem;
+    dc->w.MapMode         = dcs->w.MapMode;
+    dc->w.DCOrgX          = dcs->w.DCOrgX;
+    dc->w.DCOrgY          = dcs->w.DCOrgY;
+    dc->w.CursPosX        = dcs->w.CursPosX;
+    dc->w.CursPosY        = dcs->w.CursPosY;
+    dc->w.WndOrgX         = dcs->w.WndOrgX;
+    dc->w.WndOrgY         = dcs->w.WndOrgY;
+    dc->w.WndExtX         = dcs->w.WndExtX;
+    dc->w.WndExtY         = dcs->w.WndExtY;
+    dc->w.VportOrgX       = dcs->w.VportOrgX;
+    dc->w.VportOrgY       = dcs->w.VportOrgY;
+    dc->w.VportExtX       = dcs->w.VportExtX;
+    dc->w.VportExtY       = dcs->w.VportExtY;
+
+    if (!(dc->w.flags & DC_MEMORY)) dc->w.bitsPerPixel = dcs->w.bitsPerPixel;
+    CombineRgn32( dc->w.hVisRgn, dcs->w.hVisRgn, 0, RGN_COPY );
+    SelectClipRgn32( hdc, dcs->w.hClipRgn );
+    SelectObject32( hdc, dcs->w.hBitmap );
+    SelectObject32( hdc, dcs->w.hBrush );
+    SelectObject32( hdc, dcs->w.hFont );
+    SelectObject32( hdc, dcs->w.hPen );
+    GDISelectPalette( hdc, dcs->w.hPalette, FALSE );
 }
 
 
@@ -564,7 +582,7 @@ HDC16 CreateCompatibleDC( HDC16 hdc )
         !dc->funcs->pCreateDC( dc, NULL, NULL, NULL, NULL ))
     {
         dprintf_dc( stddeb, "CreateDC: creation aborted by device\n" );
-        DeleteObject( hbitmap );
+        DeleteObject32( hbitmap );
         GDI_HEAP_FREE( dc->hSelf );
         return 0;
     }
@@ -596,16 +614,16 @@ BOOL DeleteDC( HDC16 hdc )
     
     if (!(dc->w.flags & DC_SAVED))
     {
-	SelectObject( hdc, STOCK_BLACK_PEN );
-	SelectObject( hdc, STOCK_WHITE_BRUSH );
-	SelectObject( hdc, STOCK_SYSTEM_FONT );
-        if (dc->w.flags & DC_MEMORY) DeleteObject( dc->w.hFirstBitmap );
+	SelectObject32( hdc, STOCK_BLACK_PEN );
+	SelectObject32( hdc, STOCK_WHITE_BRUSH );
+	SelectObject32( hdc, STOCK_SYSTEM_FONT );
+        if (dc->w.flags & DC_MEMORY) DeleteObject32( dc->w.hFirstBitmap );
         if (dc->funcs->pDeleteDC) dc->funcs->pDeleteDC(dc);
     }
 
-    if (dc->w.hClipRgn) DeleteObject( dc->w.hClipRgn );
-    if (dc->w.hVisRgn) DeleteObject( dc->w.hVisRgn );
-    if (dc->w.hGCClipRgn) DeleteObject( dc->w.hGCClipRgn );
+    if (dc->w.hClipRgn) DeleteObject32( dc->w.hClipRgn );
+    if (dc->w.hVisRgn) DeleteObject32( dc->w.hVisRgn );
+    if (dc->w.hGCClipRgn) DeleteObject32( dc->w.hGCClipRgn );
     
     return GDI_FreeObject( hdc );
 }
diff --git a/objects/dib.c b/objects/dib.c
index 556e89f30ada978d57292e4bf6369b8c9310d959..8ec1ce16dbcba17cbffff68a11720379635b66a9 100644
--- a/objects/dib.c
+++ b/objects/dib.c
@@ -632,12 +632,12 @@ int StretchDIBits( HDC16 hdc,
     hBitmap = CreateDIBitmap( hdc, &info->bmiHeader, CBM_INIT,
                               bits, info, wUsage );
     hdcMem = CreateCompatibleDC( hdc );
-    hOldBitmap = SelectObject( hdcMem, hBitmap );
+    hOldBitmap = SelectObject32( hdcMem, hBitmap );
     StretchBlt( hdc, xDest, yDest, wDestWidth, wDestHeight,
                 hdcMem, xSrc, ySrc, wSrcWidth, wSrcHeight, dwRop );
-    SelectObject( hdcMem, hOldBitmap );
+    SelectObject32( hdcMem, hOldBitmap );
     DeleteDC( hdcMem );
-    DeleteObject( hBitmap );
+    DeleteObject32( hBitmap );
     return wSrcHeight;
 }
 
diff --git a/objects/font.c b/objects/font.c
index d41a6e1b67d6b03339ba11bb97695a841bacce4f..0c4f2fe4d31e80564ac12f42874ca02e1df312ee 100644
--- a/objects/font.c
+++ b/objects/font.c
@@ -1203,10 +1203,10 @@ INT EnumFonts(HDC16 hDC, LPCSTR lpFaceName, FONTENUMPROC16 lpEnumFunc, LPARAM lp
     dprintf_font(stddeb,"EnumFonts // %p !\n", lpLogFontList[i]);
     memcpy(lpLogFont, lpLogFontList[i], sizeof(LOGFONT16) + LF_FACESIZE);
     hFont = CreateFontIndirect16(lpLogFont);
-    hOldFont = SelectObject(hDC, hFont);
+    hOldFont = SelectObject32(hDC, hFont);
     GetTextMetrics16(hDC, lptm);
-    SelectObject(hDC, hOldFont);
-    DeleteObject(hFont);
+    SelectObject32(hDC, hOldFont);
+    DeleteObject32(hFont);
     dprintf_font(stddeb,"EnumFonts // i=%d lpLogFont=%p lptm=%p\n", i, lpLogFont, lptm);
     nRet = lpEnumFunc( GDI_HEAP_SEG_ADDR(hLog), GDI_HEAP_SEG_ADDR(hMet),
                        0, (LONG)lpData );
@@ -1272,10 +1272,10 @@ INT EnumFontFamilies(HDC16 hDC, LPCSTR lpszFamily, FONTENUMPROC16 lpEnumFunc, LP
     strcpy(lpEnumLogFont->elfFullName,"");
     strcpy(lpEnumLogFont->elfStyle,"");
     hFont = CreateFontIndirect16((LPLOGFONT16)lpEnumLogFont);
-    hOldFont = SelectObject(hDC, hFont);
+    hOldFont = SelectObject32(hDC, hFont);
     GetTextMetrics16(hDC, lptm);
-    SelectObject(hDC, hOldFont);
-    DeleteObject(hFont);
+    SelectObject32(hDC, hOldFont);
+    DeleteObject32(hFont);
     dprintf_font(stddeb, "EnumFontFamilies // i=%d lpLogFont=%p lptm=%p\n", i, lpEnumLogFont, lptm);
     
     nRet = lpEnumFunc( GDI_HEAP_SEG_ADDR(hLog), GDI_HEAP_SEG_ADDR(hMet),
diff --git a/objects/gdiobj.c b/objects/gdiobj.c
index 9392bd969ba7f6b80c709def8e41590f1acd1bf1..0502c69576f33fea81cdd77d6412d0470265a4af 100644
--- a/objects/gdiobj.c
+++ b/objects/gdiobj.c
@@ -4,6 +4,7 @@
  * Copyright 1993 Alexandre Julliard
  */
 
+#define NO_TRANSITION_TYPES  /* This file is Win32-clean */
 #include <stdlib.h>
 #include <stdio.h>
 #include "gdi.h"
@@ -242,14 +243,23 @@ GDIOBJHDR * GDI_GetObjPtr( HGDIOBJ16 handle, WORD magic )
 
 
 /***********************************************************************
- *           DeleteObject    (GDI.69)
+ *           DeleteObject16    (GDI.69)
  */
-BOOL DeleteObject( HGDIOBJ16 obj )
+BOOL16 DeleteObject16( HGDIOBJ16 obj )
+{
+    return DeleteObject32( obj );
+}
+
+
+/***********************************************************************
+ *           DeleteObject32    (GDI32.70)
+ */
+BOOL32 DeleteObject32( HGDIOBJ32 obj )
 {
       /* Check if object is valid */
 
     GDIOBJHDR * header = (GDIOBJHDR *) GDI_HEAP_LIN_ADDR( obj );
-    if (!header) return FALSE;
+    if (!header || HIWORD(obj)) return FALSE;
 
     dprintf_gdi(stddeb, "DeleteObject: %04x\n", obj );
 
@@ -269,9 +279,18 @@ BOOL DeleteObject( HGDIOBJ16 obj )
 
 
 /***********************************************************************
- *           GetStockObject    (GDI.87)
+ *           GetStockObject16    (GDI.87)
+ */
+HGDIOBJ16 GetStockObject16( INT16 obj )
+{
+    return (HGDIOBJ16)GetStockObject32( obj );
+}
+
+
+/***********************************************************************
+ *           GetStockObject32    (GDI32.220)
  */
-HGDIOBJ16 GetStockObject( INT16 obj )
+HGDIOBJ32 GetStockObject32( INT32 obj )
 {
     if ((obj < 0) || (obj >= NB_STOCK_OBJECTS)) return 0;
     if (!StockObjects[obj]) return 0;
@@ -299,9 +318,9 @@ INT16 GetObject16( HANDLE16 handle, INT16 count, LPVOID buffer )
     switch(ptr->wMagic)
     {
       case PEN_MAGIC:
-	  return PEN_GetObject( (PENOBJ *)ptr, count, buffer );
+	  return PEN_GetObject16( (PENOBJ *)ptr, count, buffer );
       case BRUSH_MAGIC: 
-	  return BRUSH_GetObject( (BRUSHOBJ *)ptr, count, buffer );
+	  return BRUSH_GetObject16( (BRUSHOBJ *)ptr, count, buffer );
       case BITMAP_MAGIC: 
 	  return BITMAP_GetObject16( (BITMAPOBJ *)ptr, count, buffer );
       case FONT_MAGIC:
@@ -330,12 +349,14 @@ INT32 GetObject32A( HANDLE32 handle, INT32 count, LPVOID buffer )
     
     switch(ptr->wMagic)
     {
+      case PEN_MAGIC:
+	  return PEN_GetObject32( (PENOBJ *)ptr, count, buffer );
+      case BRUSH_MAGIC: 
+	  return BRUSH_GetObject32( (BRUSHOBJ *)ptr, count, buffer );
       case BITMAP_MAGIC: 
 	  return BITMAP_GetObject32( (BITMAPOBJ *)ptr, count, buffer );
       case FONT_MAGIC:
 	  return FONT_GetObject32A( (FONTOBJ *)ptr, count, buffer );
-      case PEN_MAGIC:
-      case BRUSH_MAGIC: 
       case PALETTE_MAGIC:
           fprintf( stderr, "GetObject32: magic %04x not implemented\n",
                    ptr->wMagic );
@@ -355,9 +376,18 @@ INT32 GetObject32W( HANDLE32 handle, INT32 count, LPVOID buffer )
 
 
 /***********************************************************************
- *           SelectObject    (GDI.45)
+ *           SelectObject16    (GDI.45)
+ */
+HGDIOBJ16 SelectObject16( HDC16 hdc, HGDIOBJ16 handle )
+{
+    return (HGDIOBJ16)SelectObject32( hdc, handle );
+}
+
+
+/***********************************************************************
+ *           SelectObject32    (GDI32.299)
  */
-HGDIOBJ16 SelectObject( HDC16 hdc, HGDIOBJ16 handle )
+HGDIOBJ32 SelectObject32( HDC32 hdc, HGDIOBJ32 handle )
 {
     GDIOBJHDR * ptr = NULL;
     DC * dc;
@@ -387,16 +417,25 @@ HGDIOBJ16 SelectObject( HDC16 hdc, HGDIOBJ16 handle )
       case FONT_MAGIC:
 	  return FONT_SelectObject( dc, handle, (FONTOBJ *)ptr );	  
       case REGION_MAGIC:
-	  return (HGDIOBJ16)SelectClipRgn( hdc, handle );
+	  return (HGDIOBJ16)SelectClipRgn16( hdc, handle );
     }
     return 0;
 }
 
 
 /***********************************************************************
- *           UnrealizeObject    (GDI.150)
+ *           UnrealizeObject16    (GDI.150)
+ */
+BOOL16 UnrealizeObject16( HGDIOBJ16 obj )
+{
+    return UnrealizeObject32( obj );
+}
+
+
+/***********************************************************************
+ *           UnrealizeObject    (GDI32.358)
  */
-BOOL UnrealizeObject( HGDIOBJ16 obj )
+BOOL32 UnrealizeObject32( HGDIOBJ32 obj )
 {
       /* Check if object is valid */
 
@@ -421,10 +460,10 @@ BOOL UnrealizeObject( HGDIOBJ16 obj )
 
 
 /***********************************************************************
- *           EnumObjects    (GDI.71)
+ *           EnumObjects16    (GDI.71)
  */
-INT EnumObjects( HDC16 hdc, INT nObjType, GOBJENUMPROC16 lpEnumFunc,
-                 LPARAM lParam )
+INT16 EnumObjects16( HDC16 hdc, INT16 nObjType, GOBJENUMPROC16 lpEnumFunc,
+                     LPARAM lParam )
 {
     /* Solid colors to enumerate */
     static const COLORREF solid_colors[] =
@@ -438,11 +477,11 @@ INT EnumObjects( HDC16 hdc, INT nObjType, GOBJENUMPROC16 lpEnumFunc,
       RGB(0x80,0x80,0x80), RGB(0xc0,0xc0,0xc0)
     };
     
-    int i, retval = 0;
+    INT16 i, retval = 0;
     LOGPEN16 *pen;
     LOGBRUSH16 *brush = NULL;
 
-    dprintf_gdi( stddeb, "EnumObjects: %04x %d %08lx %08lx\n",
+    dprintf_gdi( stddeb, "EnumObjects16: %04x %d %08lx %08lx\n",
                  hdc, nObjType, (DWORD)lpEnumFunc, lParam );
     switch(nObjType)
     {
@@ -456,7 +495,7 @@ INT EnumObjects( HDC16 hdc, INT nObjType, GOBJENUMPROC16 lpEnumFunc,
             pen->lopnWidth.y = 0;
             pen->lopnColor   = solid_colors[i];
             retval = lpEnumFunc( SEGPTR_GET(pen), lParam );
-            dprintf_gdi( stddeb, "EnumObject: solid pen %08lx, ret=%d\n",
+            dprintf_gdi( stddeb, "EnumObjects16: solid pen %08lx, ret=%d\n",
                          solid_colors[i], retval);
             if (!retval) break;
         }
@@ -472,7 +511,7 @@ INT EnumObjects( HDC16 hdc, INT nObjType, GOBJENUMPROC16 lpEnumFunc,
             brush->lbColor = solid_colors[i];
             brush->lbHatch = 0;
             retval = lpEnumFunc( SEGPTR_GET(brush), lParam );
-            dprintf_gdi( stddeb, "EnumObject: solid brush %08lx, ret=%d\n",
+            dprintf_gdi( stddeb, "EnumObjects16: solid brush %08lx, ret=%d\n",
                          solid_colors[i], retval);
             if (!retval) break;
         }
@@ -484,7 +523,7 @@ INT EnumObjects( HDC16 hdc, INT nObjType, GOBJENUMPROC16 lpEnumFunc,
             brush->lbColor = RGB(0,0,0);
             brush->lbHatch = i;
             retval = lpEnumFunc( SEGPTR_GET(brush), lParam );
-            dprintf_gdi( stddeb, "EnumObject: hatched brush %d, ret=%d\n",
+            dprintf_gdi( stddeb, "EnumObjects16: hatched brush %d, ret=%d\n",
                          i, retval);
             if (!retval) break;
         }
@@ -492,7 +531,83 @@ INT EnumObjects( HDC16 hdc, INT nObjType, GOBJENUMPROC16 lpEnumFunc,
         break;
 
     default:
-        fprintf( stderr, "EnumObjects: invalid type %d\n", nObjType );
+        fprintf( stderr, "EnumObjects16: invalid type %d\n", nObjType );
+        break;
+    }
+    return retval;
+}
+
+
+/***********************************************************************
+ *           EnumObjects32    (GDI32.89)
+ */
+INT32 EnumObjects32( HDC32 hdc, INT32 nObjType, GOBJENUMPROC32 lpEnumFunc,
+                     LPARAM lParam )
+{
+    /* Solid colors to enumerate */
+    static const COLORREF solid_colors[] =
+    { RGB(0x00,0x00,0x00), RGB(0xff,0xff,0xff),
+      RGB(0xff,0x00,0x00), RGB(0x00,0xff,0x00),
+      RGB(0x00,0x00,0xff), RGB(0xff,0xff,0x00),
+      RGB(0xff,0x00,0xff), RGB(0x00,0xff,0xff),
+      RGB(0x80,0x00,0x00), RGB(0x00,0x80,0x00),
+      RGB(0x80,0x80,0x00), RGB(0x00,0x00,0x80),
+      RGB(0x80,0x00,0x80), RGB(0x00,0x80,0x80),
+      RGB(0x80,0x80,0x80), RGB(0xc0,0xc0,0xc0)
+    };
+    
+    INT32 i, retval = 0;
+    LOGPEN32 pen;
+    LOGBRUSH32 brush;
+
+    dprintf_gdi( stddeb, "EnumObjects32: %04x %d %08lx %08lx\n",
+                 hdc, nObjType, (DWORD)lpEnumFunc, lParam );
+    switch(nObjType)
+    {
+    case OBJ_PEN:
+        /* Enumerate solid pens */
+        for (i = 0; i < sizeof(solid_colors)/sizeof(solid_colors[0]); i++)
+        {
+            pen.lopnStyle   = PS_SOLID;
+            pen.lopnWidth.x = 1;
+            pen.lopnWidth.y = 0;
+            pen.lopnColor   = solid_colors[i];
+            retval = lpEnumFunc( &pen, lParam );
+            dprintf_gdi( stddeb, "EnumObjects32: solid pen %08lx, ret=%d\n",
+                         solid_colors[i], retval);
+            if (!retval) break;
+        }
+        break;
+
+    case OBJ_BRUSH:
+        /* Enumerate solid brushes */
+        for (i = 0; i < sizeof(solid_colors)/sizeof(solid_colors[0]); i++)
+        {
+            brush.lbStyle = BS_SOLID;
+            brush.lbColor = solid_colors[i];
+            brush.lbHatch = 0;
+            retval = lpEnumFunc( &brush, lParam );
+            dprintf_gdi( stddeb, "EnumObjects32: solid brush %08lx, ret=%d\n",
+                         solid_colors[i], retval);
+            if (!retval) break;
+        }
+
+        /* Now enumerate hatched brushes */
+        if (retval) for (i = HS_HORIZONTAL; i <= HS_DIAGCROSS; i++)
+        {
+            brush.lbStyle = BS_HATCHED;
+            brush.lbColor = RGB(0,0,0);
+            brush.lbHatch = i;
+            retval = lpEnumFunc( &brush, lParam );
+            dprintf_gdi( stddeb, "EnumObjects32: hatched brush %d, ret=%d\n",
+                         i, retval);
+            if (!retval) break;
+        }
+        break;
+
+    default:
+        /* FIXME: implement Win32 types */
+        fprintf( stderr, "EnumObjects32: invalid type %d\n", nObjType );
         break;
     }
     return retval;
diff --git a/objects/metafile.c b/objects/metafile.c
index 6b2ccd6e5fa159e178ed8d9e12ca1057897d4b2b..ad885d6ca5559dcd53d90734744ed7c3105033ca 100644
--- a/objects/metafile.c
+++ b/objects/metafile.c
@@ -284,7 +284,7 @@ BOOL PlayMetaFile(HDC16 hdc, HMETAFILE16 hmf)
     /* free objects in handle table */
     for(i = 0; i < mh->mtNoObjects; i++)
       if(*(ht->objectHandle + i) != 0)
-        DeleteObject(*(ht->objectHandle + i));
+        DeleteObject32(*(ht->objectHandle + i));
     
     /* free handle table */
     GlobalFree16(hHT);
@@ -400,7 +400,7 @@ void PlayMetaFileRecord(HDC16 hdc, HANDLETABLE16 *ht, METARECORD *mr,
       break;
 
     case META_DELETEOBJECT:
-      DeleteObject(*(ht->objectHandle + *(mr->rdParam)));
+      DeleteObject32(*(ht->objectHandle + *(mr->rdParam)));
       *(ht->objectHandle + *(mr->rdParam)) = 0;
       break;
 
@@ -471,7 +471,7 @@ void PlayMetaFileRecord(HDC16 hdc, HANDLETABLE16 *ht, METARECORD *mr,
 	break;
 
     case META_LINETO:
-	LineTo(hdc, *(mr->rdParam + 1), *(mr->rdParam));
+	LineTo32(hdc, *(mr->rdParam + 1), *(mr->rdParam));
 	break;
 
     case META_MOVETO:
@@ -479,46 +479,46 @@ void PlayMetaFileRecord(HDC16 hdc, HANDLETABLE16 *ht, METARECORD *mr,
 	break;
 
     case META_EXCLUDECLIPRECT:
-	ExcludeClipRect(hdc, *(mr->rdParam + 3), *(mr->rdParam + 2),
-			*(mr->rdParam + 1), *(mr->rdParam));
+	ExcludeClipRect16( hdc, *(mr->rdParam + 3), *(mr->rdParam + 2),
+                           *(mr->rdParam + 1), *(mr->rdParam) );
 	break;
 
     case META_INTERSECTCLIPRECT:
-	IntersectClipRect(hdc, *(mr->rdParam + 3), *(mr->rdParam + 2),
-			*(mr->rdParam + 1), *(mr->rdParam));
+	IntersectClipRect16( hdc, *(mr->rdParam + 3), *(mr->rdParam + 2),
+                             *(mr->rdParam + 1), *(mr->rdParam) );
 	break;
 
     case META_ARC:
-	Arc(hdc, *(mr->rdParam + 7), *(mr->rdParam + 6), *(mr->rdParam + 5),
-	    *(mr->rdParam + 4), *(mr->rdParam + 3), *(mr->rdParam + 2),
-	    *(mr->rdParam + 1), *(mr->rdParam));
+	Arc32(hdc, *(mr->rdParam + 7), *(mr->rdParam + 6), *(mr->rdParam + 5),
+              *(mr->rdParam + 4), *(mr->rdParam + 3), *(mr->rdParam + 2),
+              *(mr->rdParam + 1), *(mr->rdParam));
 	break;
 
     case META_ELLIPSE:
-	Ellipse(hdc, *(mr->rdParam + 3), *(mr->rdParam + 2),
-		*(mr->rdParam + 1), *(mr->rdParam));
+	Ellipse32(hdc, *(mr->rdParam + 3), *(mr->rdParam + 2),
+                  *(mr->rdParam + 1), *(mr->rdParam));
 	break;
 
     case META_FLOODFILL:
-	FloodFill(hdc, *(mr->rdParam + 3), *(mr->rdParam + 2),
-		  MAKELONG(*(mr->rdParam + 1), *(mr->rdParam)));
+	FloodFill32(hdc, *(mr->rdParam + 3), *(mr->rdParam + 2),
+                    MAKELONG(*(mr->rdParam + 1), *(mr->rdParam)));
 	break;
 
     case META_PIE:
-	Pie(hdc, *(mr->rdParam + 7), *(mr->rdParam + 6), *(mr->rdParam + 5),
-	    *(mr->rdParam + 4), *(mr->rdParam + 3), *(mr->rdParam + 2),
-	    *(mr->rdParam + 1), *(mr->rdParam));
+	Pie32(hdc, *(mr->rdParam + 7), *(mr->rdParam + 6), *(mr->rdParam + 5),
+              *(mr->rdParam + 4), *(mr->rdParam + 3), *(mr->rdParam + 2),
+              *(mr->rdParam + 1), *(mr->rdParam));
 	break;
 
     case META_RECTANGLE:
-	Rectangle(hdc, *(mr->rdParam + 3), *(mr->rdParam + 2),
-		*(mr->rdParam + 1), *(mr->rdParam));
+	Rectangle32(hdc, *(mr->rdParam + 3), *(mr->rdParam + 2),
+                    *(mr->rdParam + 1), *(mr->rdParam));
 	break;
 
     case META_ROUNDRECT:
-	RoundRect(hdc, *(mr->rdParam + 5), *(mr->rdParam + 4),
-		  *(mr->rdParam + 3), *(mr->rdParam + 2),
-		  *(mr->rdParam + 1), *(mr->rdParam));
+	RoundRect32(hdc, *(mr->rdParam + 5), *(mr->rdParam + 4),
+                    *(mr->rdParam + 3), *(mr->rdParam + 2),
+                    *(mr->rdParam + 1), *(mr->rdParam));
 	break;
 
     case META_PATBLT:
@@ -532,12 +532,12 @@ void PlayMetaFileRecord(HDC16 hdc, HANDLETABLE16 *ht, METARECORD *mr,
 	break;
 
     case META_SETPIXEL:
-	SetPixel(hdc, *(mr->rdParam + 3), *(mr->rdParam + 2),
-		 MAKELONG(*(mr->rdParam + 1), *(mr->rdParam)));
+	SetPixel32(hdc, *(mr->rdParam + 3), *(mr->rdParam + 2),
+                   MAKELONG(*(mr->rdParam + 1), *(mr->rdParam)));
 	break;
 
     case META_OFFSETCLIPRGN:
-	OffsetClipRgn(hdc, *(mr->rdParam + 1), *(mr->rdParam));
+	OffsetClipRgn16( hdc, *(mr->rdParam + 1), *(mr->rdParam) );
 	break;
 
     case META_TEXTOUT:
@@ -565,13 +565,13 @@ void PlayMetaFileRecord(HDC16 hdc, HANDLETABLE16 *ht, METARECORD *mr,
 	break;
 
     case META_SELECTOBJECT:
-	SelectObject(hdc, *(ht->objectHandle + *(mr->rdParam)));
+	SelectObject32(hdc, *(ht->objectHandle + *(mr->rdParam)));
 	break;
 
     case META_CHORD:
-	Chord(hdc, *(mr->rdParam + 7), *(mr->rdParam + 6), *(mr->rdParam + 5),
-	      *(mr->rdParam + 4), *(mr->rdParam + 3), *(mr->rdParam + 2),
-	      *(mr->rdParam + 1), *(mr->rdParam));
+	Chord32(hdc, *(mr->rdParam + 7), *(mr->rdParam + 6), *(mr->rdParam+5),
+                *(mr->rdParam + 4), *(mr->rdParam + 3), *(mr->rdParam + 2),
+                *(mr->rdParam + 1), *(mr->rdParam));
 	break;
 
     case META_CREATEPATTERNBRUSH:
@@ -580,7 +580,7 @@ void PlayMetaFileRecord(HDC16 hdc, HANDLETABLE16 *ht, METARECORD *mr,
 	case BS_PATTERN:
 	    infohdr = (BITMAPINFOHEADER *)(mr->rdParam + 2);
 	    MF_AddHandle(ht, nHandles,
-			 CreatePatternBrush(CreateBitmap(infohdr->biWidth, 
+			 CreatePatternBrush32(CreateBitmap(infohdr->biWidth, 
 				      infohdr->biHeight, 
 				      infohdr->biPlanes, 
 				      infohdr->biBitCount,
@@ -595,14 +595,14 @@ void PlayMetaFileRecord(HDC16 hdc, HANDLETABLE16 *ht, METARECORD *mr,
 	    memcpy(ptr, mr->rdParam + 2, s1);
 	    GlobalUnlock16(hndl);
 	    MF_AddHandle(ht, nHandles,
-			 CreateDIBPatternBrush(hndl, *(mr->rdParam + 1)));
+			 CreateDIBPatternBrush32(hndl, *(mr->rdParam + 1)));
 	    GlobalFree16(hndl);
 	}
 	break;
 	
     case META_CREATEPENINDIRECT:
 	MF_AddHandle(ht, nHandles, 
-		     CreatePenIndirect((LOGPEN16 *)(&(mr->rdParam))));
+		     CreatePenIndirect16((LOGPEN16 *)(&(mr->rdParam))));
 	break;
 
     case META_CREATEFONTINDIRECT:
@@ -612,7 +612,7 @@ void PlayMetaFileRecord(HDC16 hdc, HANDLETABLE16 *ht, METARECORD *mr,
 
     case META_CREATEBRUSHINDIRECT:
 	MF_AddHandle(ht, nHandles, 
-		     CreateBrushIndirect((LOGBRUSH16 *)(&(mr->rdParam))));
+		     CreateBrushIndirect16((LOGBRUSH16 *)(&(mr->rdParam))));
 	break;
 
     /* W. Magro: Some new metafile operations.  Not all debugged. */
@@ -704,7 +704,7 @@ void PlayMetaFileRecord(HDC16 hdc, HANDLETABLE16 *ht, METARECORD *mr,
                                       mr->rdParam[13], /*Planes*/
                                       mr->rdParam[14], /*BitsPixel*/
                                       (LPSTR)&mr->rdParam[15]);  /*bits*/
-       SelectObject(hdcSrc,hbitmap);
+       SelectObject32(hdcSrc,hbitmap);
        StretchBlt(hdc,mr->rdParam[9],mr->rdParam[8],
                     mr->rdParam[7],mr->rdParam[6],
 		    hdcSrc,mr->rdParam[5],mr->rdParam[4],
@@ -720,7 +720,7 @@ void PlayMetaFileRecord(HDC16 hdc, HANDLETABLE16 *ht, METARECORD *mr,
        HBITMAP16 hbitmap=CreateBitmap(mr->rdParam[7]/*Width */,mr->rdParam[8]/*Height*/,
                             mr->rdParam[10]/*Planes*/,mr->rdParam[11]/*BitsPixel*/,
                             (LPSTR)&mr->rdParam[12]/*bits*/);
-       SelectObject(hdcSrc,hbitmap);
+       SelectObject32(hdcSrc,hbitmap);
        BitBlt(hdc,mr->rdParam[6],mr->rdParam[5],
                     mr->rdParam[4],mr->rdParam[3],
 		    hdcSrc,
@@ -919,12 +919,12 @@ BOOL32 MF_MetaParam8(DC *dc, short func, short param1, short param2,
 BOOL32 MF_CreateBrushIndirect(DC *dc, HBRUSH16 hBrush, LOGBRUSH16 *logbrush)
 {
     int index;
-    char buffer[sizeof(METARECORD) - 2 + sizeof(LOGBRUSH16)];
+    char buffer[sizeof(METARECORD) - 2 + sizeof(*logbrush)];
     METARECORD *mr = (METARECORD *)&buffer;
 
-    mr->rdSize = (sizeof(METARECORD) + sizeof(LOGBRUSH16) - 2) / 2;
+    mr->rdSize = (sizeof(METARECORD) + sizeof(*logbrush) - 2) / 2;
     mr->rdFunction = META_CREATEBRUSHINDIRECT;
-    memcpy(&(mr->rdParam), logbrush, sizeof(LOGBRUSH16));
+    memcpy(&(mr->rdParam), logbrush, sizeof(*logbrush));
     if (!(MF_WriteRecord( dc, mr, mr->rdSize * 2))) return FALSE;
 
     mr->rdSize = sizeof(METARECORD) / 2;
@@ -1024,12 +1024,12 @@ BOOL32 MF_CreatePatternBrush(DC *dc, HBRUSH16 hBrush, LOGBRUSH16 *logbrush)
 BOOL32 MF_CreatePenIndirect(DC *dc, HPEN16 hPen, LOGPEN16 *logpen)
 {
     int index;
-    char buffer[sizeof(METARECORD) - 2 + sizeof(LOGPEN16)];
+    char buffer[sizeof(METARECORD) - 2 + sizeof(*logpen)];
     METARECORD *mr = (METARECORD *)&buffer;
 
-    mr->rdSize = (sizeof(METARECORD) + sizeof(LOGPEN16) - 2) / 2;
+    mr->rdSize = (sizeof(METARECORD) + sizeof(*logpen) - 2) / 2;
     mr->rdFunction = META_CREATEPENINDIRECT;
-    memcpy(&(mr->rdParam), logpen, sizeof(LOGPEN16));
+    memcpy(&(mr->rdParam), logpen, sizeof(*logpen));
     if (!(MF_WriteRecord( dc, mr, mr->rdSize * 2))) return FALSE;
 
     mr->rdSize = sizeof(METARECORD) / 2;
diff --git a/objects/oembitmap.c b/objects/oembitmap.c
index 774d2640fb043c1e94ba2d5169bf5565d4791b41..87929bc7ee16c61ca0332d6f70abcb8d2399fddc 100644
--- a/objects/oembitmap.c
+++ b/objects/oembitmap.c
@@ -5,6 +5,7 @@
  *
  */
 
+#define NO_TRANSITION_TYPES  /* This file is Win32-clean */
 #include <stdlib.h>
 #include <string.h>
 #include <X11/Xlib.h>
@@ -77,7 +78,7 @@
 static const struct
 {
     char** data;   /* Pointer to bitmap data */
-    BOOL   color;  /* Is it a color bitmap?  */
+    BOOL32 color;  /* Is it a color bitmap?  */
 } OBM_Pixmaps_Data[OBM_LAST-OBM_FIRST+1] = {
     { obm_trtype, TRUE },	/* OBM_TRTYPE */    
     { obm_cdrom, TRUE },        /* OBM_CDROM    */
@@ -268,7 +269,7 @@ static XpmColorSymbol *OBM_Colors = NULL;
 /***********************************************************************
  *           OBM_InitColorSymbols
  */
-static BOOL OBM_InitColorSymbols()
+static BOOL32 OBM_InitColorSymbols()
 {
     int i;
 
@@ -328,8 +329,8 @@ static HBITMAP16 OBM_MakeBitmap( WORD width, WORD height,
  *
  * Create the 2 bitmaps from XPM data.
  */
-static BOOL OBM_CreateBitmaps( char **data, BOOL color, HBITMAP16 *hBitmap,
-                               HBITMAP16 *hBitmapMask, POINT16 *hotspot )
+static BOOL32 OBM_CreateBitmaps( char **data, BOOL32 color, HBITMAP16 *hBitmap,
+                                 HBITMAP16 *hBitmapMask, POINT32 *hotspot )
 {
     Pixmap pixmap, pixmask;
     XpmAttributes *attrs;
@@ -405,7 +406,7 @@ HGLOBAL16 OBM_LoadCursorIcon( WORD id, BOOL32 fCursor )
     CURSORICONINFO *pInfo;
     BITMAPOBJ *bmpXor, *bmpAnd;
     HBITMAP16 hXorBits, hAndBits;
-    POINT16 hotspot;
+    POINT32 hotspot;
     int sizeXor, sizeAnd;
 
     if (fCursor)
@@ -443,8 +444,8 @@ HGLOBAL16 OBM_LoadCursorIcon( WORD id, BOOL32 fCursor )
     if (!(handle = GlobalAlloc16( GMEM_MOVEABLE,
                                   sizeof(CURSORICONINFO) + sizeXor + sizeAnd)))
     {
-        DeleteObject( hXorBits );
-        DeleteObject( hAndBits );
+        DeleteObject32( hXorBits );
+        DeleteObject32( hAndBits );
         return 0;
     }
 
@@ -485,8 +486,8 @@ HGLOBAL16 OBM_LoadCursorIcon( WORD id, BOOL32 fCursor )
     else memset( (char *)(pInfo + 1), 0xff, sizeAnd );
     GetBitmapBits( hXorBits, sizeXor, (char *)(pInfo + 1) + sizeAnd );
 
-    DeleteObject( hXorBits );
-    DeleteObject( hAndBits );
+    DeleteObject32( hXorBits );
+    DeleteObject32( hAndBits );
 
     if (fCursor) OBM_Cursors[id] = handle;
     return handle;
diff --git a/objects/pen.c b/objects/pen.c
index c32ca204cc946f0ac0078e011a75380fd50e9ffd..bb147914d94ad8fd18ea7891ff2ca543a96e594d 100644
--- a/objects/pen.c
+++ b/objects/pen.c
@@ -4,27 +4,45 @@
  * Copyright 1993 Alexandre Julliard
  */
 
+#define NO_TRANSITION_TYPES  /* This file is Win32-clean */
 #include "pen.h"
 #include "metafile.h"
-#include "stddebug.h"
 #include "color.h"
+#include "stddebug.h"
 #include "debug.h"
 
+
+static const char PEN_dash[]       = { 5,3 };      /* -----   -----   -----  */
+static const char PEN_dot[]        = { 2,2 };      /* --  --  --  --  --  -- */
+static const char PEN_dashdot[]    = { 4,3,2,3 };  /* ----   --   ----   --  */
+static const char PEN_dashdotdot[] = { 4,2,2,2,2,2 }; /* ----  --  --  ----  */
+
+/***********************************************************************
+ *           CreatePen16    (GDI.61)
+ */
+HPEN16 CreatePen16( INT16 style, INT16 width, COLORREF color )
+{
+    LOGPEN32 logpen = { style, { width, 0 }, color };
+    dprintf_gdi(stddeb, "CreatePen16: %d %d %06lx\n", style, width, color );
+    return CreatePenIndirect32( &logpen );
+}
+
+
 /***********************************************************************
- *           CreatePen    (GDI.61)
+ *           CreatePen32    (GDI32.55)
  */
-HPEN16 CreatePen( INT style, INT width, COLORREF color )
+HPEN32 CreatePen32( INT32 style, INT32 width, COLORREF color )
 {
-    LOGPEN16 logpen = { style, { width, 0 }, color };
-    dprintf_gdi(stddeb, "CreatePen: %d %d %06lx\n", style, width, color );
-    return CreatePenIndirect( &logpen );
+    LOGPEN32 logpen = { style, { width, 0 }, color };
+    dprintf_gdi(stddeb, "CreatePen32: %d %d %06lx\n", style, width, color );
+    return CreatePenIndirect32( &logpen );
 }
 
 
 /***********************************************************************
- *           CreatePenIndirect    (GDI.62)
+ *           CreatePenIndirect16    (GDI.62)
  */
-HPEN16 CreatePenIndirect( const LOGPEN16 * pen )
+HPEN16 CreatePenIndirect16( const LOGPEN16 * pen )
 {
     PENOBJ * penPtr;
     HPEN16 hpen;
@@ -32,16 +50,52 @@ HPEN16 CreatePenIndirect( const LOGPEN16 * pen )
     if (pen->lopnStyle > PS_INSIDEFRAME) return 0;
     hpen = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC );
     if (!hpen) return 0;
-    penPtr = (PENOBJ *) GDI_HEAP_LIN_ADDR( hpen );    
-    memcpy( &penPtr->logpen, pen, sizeof(*pen) );
+    penPtr = (PENOBJ *)GDI_HEAP_LIN_ADDR( hpen );
+    penPtr->logpen.lopnStyle = pen->lopnStyle;
+    penPtr->logpen.lopnColor = pen->lopnColor;
+    CONV_POINT16TO32( &pen->lopnWidth, &penPtr->logpen.lopnWidth );
     return hpen;
 }
 
 
 /***********************************************************************
- *           PEN_GetObject
+ *           CreatePenIndirect32    (GDI32.56)
  */
-int PEN_GetObject( PENOBJ * pen, int count, LPSTR buffer )
+HPEN32 CreatePenIndirect32( const LOGPEN32 * pen )
+{
+    PENOBJ * penPtr;
+    HPEN32 hpen;
+
+    if (pen->lopnStyle > PS_INSIDEFRAME) return 0;
+    hpen = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC );
+    if (!hpen) return 0;
+    penPtr = (PENOBJ *)GDI_HEAP_LIN_ADDR( hpen );
+    penPtr->logpen.lopnStyle = pen->lopnStyle;
+    penPtr->logpen.lopnWidth = pen->lopnWidth;
+    penPtr->logpen.lopnColor = pen->lopnColor;
+    return hpen;
+}
+
+
+/***********************************************************************
+ *           PEN_GetObject16
+ */
+INT16 PEN_GetObject16( PENOBJ * pen, INT16 count, LPSTR buffer )
+{
+    LOGPEN16 logpen;
+    logpen.lopnStyle = pen->logpen.lopnStyle;
+    logpen.lopnColor = pen->logpen.lopnColor;
+    CONV_POINT32TO16( &pen->logpen.lopnWidth, &logpen.lopnWidth );
+    if (count > sizeof(logpen)) count = sizeof(logpen);
+    memcpy( buffer, &logpen, count );
+    return count;
+}
+
+
+/***********************************************************************
+ *           PEN_GetObject32
+ */
+INT32 PEN_GetObject32( PENOBJ * pen, INT32 count, LPSTR buffer )
 {
     if (count > sizeof(pen->logpen)) count = sizeof(pen->logpen);
     memcpy( buffer, &pen->logpen, count );
@@ -52,19 +106,19 @@ int PEN_GetObject( PENOBJ * pen, int count, LPSTR buffer )
 /***********************************************************************
  *           PEN_SelectObject
  */
-HPEN16 PEN_SelectObject( DC * dc, HPEN16 hpen, PENOBJ * pen )
+HPEN32 PEN_SelectObject( DC * dc, HPEN32 hpen, PENOBJ * pen )
 {
-    static char dash_dash[]       = { 5, 3 };      /* -----   -----   -----  */
-    static char dash_dot[]        = { 2, 2 };      /* --  --  --  --  --  -- */
-    static char dash_dashdot[]    = { 4,3,2,3 };   /* ----   --   ----   --  */
-    static char dash_dashdotdot[] = { 4,2,2,2,2,2 };  /* ----  --  --  ----  */
-    HPEN16 prevHandle = dc->w.hPen;
+    HPEN32 prevHandle = dc->w.hPen;
 
     if (dc->header.wMagic == METAFILE_DC_MAGIC)
-      if (MF_CreatePenIndirect(dc, hpen, &(pen->logpen)))
-	return prevHandle;
-      else
-	return 0;
+    {
+        LOGPEN16 logpen = { pen->logpen.lopnStyle,
+                            { pen->logpen.lopnWidth.x,
+                              pen->logpen.lopnWidth.y },
+                            pen->logpen.lopnColor };
+        if (MF_CreatePenIndirect( dc, hpen, &logpen )) return prevHandle;
+        else return 0;
+    }
 
     dc->w.hPen = hpen;
 
@@ -77,19 +131,19 @@ HPEN16 PEN_SelectObject( DC * dc, HPEN16 hpen, PENOBJ * pen )
     switch(pen->logpen.lopnStyle)
     {
       case PS_DASH:
-	dc->u.x.pen.dashes = dash_dash;
+	dc->u.x.pen.dashes = (char *)PEN_dash;
 	dc->u.x.pen.dash_len = 2;
 	break;
       case PS_DOT:
-	dc->u.x.pen.dashes = dash_dot;
+	dc->u.x.pen.dashes = (char *)PEN_dot;
 	dc->u.x.pen.dash_len = 2;
 	break;
       case PS_DASHDOT:
-	dc->u.x.pen.dashes = dash_dashdot;
+	dc->u.x.pen.dashes = (char *)PEN_dashdot;
 	dc->u.x.pen.dash_len = 4;
 	break;
       case PS_DASHDOTDOT:
-	dc->u.x.pen.dashes = dash_dashdotdot;
+	dc->u.x.pen.dashes = (char *)PEN_dashdotdot;
 	dc->u.x.pen.dash_len = 6;
 	break;
     }
diff --git a/objects/region.c b/objects/region.c
index a5e5cd6a0b0059c071fb17f5e197d3976d50aaa2..4404062c011a368dbd653d91ff1c3ffa04065194 100644
--- a/objects/region.c
+++ b/objects/region.c
@@ -15,7 +15,7 @@
 /***********************************************************************
  *           REGION_DeleteObject
  */
-BOOL16 REGION_DeleteObject( HRGN32 hrgn, RGNOBJ * obj )
+BOOL32 REGION_DeleteObject( HRGN32 hrgn, RGNOBJ * obj )
 {
     dprintf_region(stddeb, "DeleteRegion: %04x\n", hrgn );
     if (obj->xrgn) XDestroyRegion( obj->xrgn );
@@ -24,9 +24,18 @@ BOOL16 REGION_DeleteObject( HRGN32 hrgn, RGNOBJ * obj )
 
 
 /***********************************************************************
- *           OffsetRgn    (GDI.101) (GDI32.256)
+ *           OffsetRgn16    (GDI.101)
  */
-INT16 OffsetRgn( HRGN32 hrgn, INT32 x, INT32 y )
+INT16 OffsetRgn16( HRGN16 hrgn, INT16 x, INT16 y )
+{
+    return OffsetRgn32( hrgn, x, y );
+}
+
+
+/***********************************************************************
+ *           OffsetRgn32   (GDI32.256)
+ */
+INT32 OffsetRgn32( HRGN32 hrgn, INT32 x, INT32 y )
 {
     RGNOBJ * obj = (RGNOBJ *) GDI_GetObjPtr( hrgn, REGION_MAGIC );
     if (!obj) return ERROR;
@@ -74,11 +83,20 @@ INT32 GetRgnBox32( HRGN32 hrgn, LPRECT32 rect )
 
 
 /***********************************************************************
- *           CreateRectRgn    (GDI.64) (GDI32.59)
+ *           CreateRectRgn16    (GDI.64)
  */
-HRGN16 CreateRectRgn( INT32 left, INT32 top, INT32 right, INT32 bottom )
+HRGN16 CreateRectRgn16( INT16 left, INT16 top, INT16 right, INT16 bottom )
 {
-    HRGN16 hrgn;
+    return (HRGN16)CreateRectRgn32( left, top, right, bottom );
+}
+
+
+/***********************************************************************
+ *           CreateRectRgn32   (GDI32.59)
+ */
+HRGN32 CreateRectRgn32( INT32 left, INT32 top, INT32 right, INT32 bottom )
+{
+    HRGN32 hrgn;
     RGNOBJ *obj;
 
     if (!(hrgn = GDI_AllocObject( sizeof(RGNOBJ), REGION_MAGIC ))) return 0;
@@ -105,7 +123,7 @@ HRGN16 CreateRectRgn( INT32 left, INT32 top, INT32 right, INT32 bottom )
  */
 HRGN16 CreateRectRgnIndirect16( const RECT16* rect )
 {
-    return CreateRectRgn( rect->left, rect->top, rect->right, rect->bottom );
+    return CreateRectRgn32( rect->left, rect->top, rect->right, rect->bottom );
 }
 
 
@@ -114,7 +132,7 @@ HRGN16 CreateRectRgnIndirect16( const RECT16* rect )
  */
 HRGN32 CreateRectRgnIndirect32( const RECT32* rect )
 {
-    return CreateRectRgn( rect->left, rect->top, rect->right, rect->bottom );
+    return CreateRectRgn32( rect->left, rect->top, rect->right, rect->bottom );
 }
 
 
@@ -141,13 +159,24 @@ VOID SetRectRgn( HRGN32 hrgn, INT32 left, INT32 top, INT32 right, INT32 bottom)
 
 
 /***********************************************************************
- *           CreateRoundRectRgn    (GDI.444) (GDI32.61)
+ *           CreateRoundRectRgn16    (GDI.444)
  */
-HRGN16 CreateRoundRectRgn( INT32 left, INT32 top, INT32 right, INT32 bottom,
-                           INT32 ellipse_width, INT32 ellipse_height )
+HRGN16 CreateRoundRectRgn16( INT16 left, INT16 top, INT16 right, INT16 bottom,
+                             INT16 ellipse_width, INT16 ellipse_height )
+{
+    return (HRGN16)CreateRoundRectRgn32( left, top, right, bottom,
+                                         ellipse_width, ellipse_height );
+}
+
+
+/***********************************************************************
+ *           CreateRoundRectRgn32    (GDI32.61)
+ */
+HRGN32 CreateRoundRectRgn32( INT32 left, INT32 top, INT32 right, INT32 bottom,
+                             INT32 ellipse_width, INT32 ellipse_height )
 {
     RGNOBJ * obj;
-    HRGN16 hrgn;
+    HRGN32 hrgn;
     XRectangle rect;
     int asq, bsq, d, xd, yd;
 
@@ -155,7 +184,7 @@ HRGN16 CreateRoundRectRgn( INT32 left, INT32 top, INT32 right, INT32 bottom,
 
     if ((right <= left) || (bottom <= top) ||
         (ellipse_width <= 0) || (ellipse_height <= 0))
-        return CreateRectRgn( left, top, right, bottom );
+        return CreateRectRgn32( left, top, right, bottom );
 
       /* Create region */
 
@@ -237,12 +266,22 @@ HRGN16 CreateRoundRectRgn( INT32 left, INT32 top, INT32 right, INT32 bottom,
 
 
 /***********************************************************************
- *           CreateEllipticRgn    (GDI.54) (GDI32.39)
+ *           CreateEllipticRgn16    (GDI.54)
+ */
+HRGN16 CreateEllipticRgn16( INT16 left, INT16 top, INT16 right, INT16 bottom )
+{
+    return (HRGN16)CreateRoundRectRgn32( left, top, right, bottom,
+                                         right-left, bottom-top );
+}
+
+
+/***********************************************************************
+ *           CreateEllipticRgn32    (GDI32.39)
  */
-HRGN16 CreateEllipticRgn( INT32 left, INT32 top, INT32 right, INT32 bottom )
+HRGN32 CreateEllipticRgn32( INT32 left, INT32 top, INT32 right, INT32 bottom )
 {
-    return CreateRoundRectRgn( left, top, right, bottom,
-                               right-left, bottom-top );
+    return CreateRoundRectRgn32( left, top, right, bottom,
+                                 right-left, bottom-top );
 }
 
 
@@ -251,8 +290,9 @@ HRGN16 CreateEllipticRgn( INT32 left, INT32 top, INT32 right, INT32 bottom )
  */
 HRGN16 CreateEllipticRgnIndirect16( const RECT16 *rect )
 {
-    return CreateRoundRectRgn(rect->left, rect->top, rect->right, rect->bottom,
-                              rect->right-rect->left, rect->bottom-rect->top );
+    return CreateRoundRectRgn32( rect->left, rect->top, rect->right,
+                                 rect->bottom, rect->right - rect->left,
+                                 rect->bottom - rect->top );
 }
 
 
@@ -261,8 +301,9 @@ HRGN16 CreateEllipticRgnIndirect16( const RECT16 *rect )
  */
 HRGN32 CreateEllipticRgnIndirect32( const RECT32 *rect )
 {
-    return CreateRoundRectRgn(rect->left, rect->top, rect->right, rect->bottom,
-                              rect->right-rect->left, rect->bottom-rect->top );
+    return CreateRoundRectRgn32( rect->left, rect->top, rect->right,
+                                 rect->bottom, rect->right - rect->left,
+                                 rect->bottom - rect->top );
 }
 
 
@@ -343,9 +384,18 @@ HRGN16 CreatePolyPolygonRgn16( const POINT16 * points, const INT16 * count,
 
 
 /***********************************************************************
- *           PtInRegion    (GDI.161) (GDI32.278)
+ *           PtInRegion16    (GDI.161)
+ */
+BOOL16 PtInRegion16( HRGN16 hrgn, INT16 x, INT16 y )
+{
+    return PtInRegion32( hrgn, x, y );
+}
+
+
+/***********************************************************************
+ *           PtInRegion32    (GDI32.278)
  */
-BOOL16 PtInRegion( HRGN32 hrgn, INT32 x, INT32 y )
+BOOL32 PtInRegion32( HRGN32 hrgn, INT32 x, INT32 y )
 {
     RGNOBJ * obj;
     
@@ -386,9 +436,18 @@ BOOL32 RectInRegion32( HRGN32 hrgn, const RECT32 *rect )
 
 
 /***********************************************************************
- *           EqualRgn    (GDI.72) (GDI32.90)
+ *           EqualRgn16    (GDI.72)
  */
-BOOL16 EqualRgn( HRGN32 rgn1, HRGN32 rgn2 )
+BOOL16 EqualRgn16( HRGN16 rgn1, HRGN16 rgn2 )
+{
+    return EqualRgn32( rgn1, rgn2 );
+}
+
+
+/***********************************************************************
+ *           EqualRgn32    (GDI32.90)
+ */
+BOOL32 EqualRgn32( HRGN32 rgn1, HRGN32 rgn2 )
 {
     RGNOBJ *obj1, *obj2;
     if (!(obj1 = (RGNOBJ *) GDI_GetObjPtr( rgn1, REGION_MAGIC ))) return FALSE;
@@ -403,7 +462,7 @@ BOOL16 EqualRgn( HRGN32 rgn1, HRGN32 rgn2 )
  *
  * Copy region src into dest.
  */
-static int REGION_CopyRegion( RGNOBJ *src, RGNOBJ *dest )
+static INT32 REGION_CopyRegion( RGNOBJ *src, RGNOBJ *dest )
 {
     Region tmprgn;
     if (src->xrgn)
@@ -428,11 +487,11 @@ static int REGION_CopyRegion( RGNOBJ *src, RGNOBJ *dest )
  *
  * Add rectangle to region
  */
-BOOL16 REGION_UnionRectWithRgn( HRGN32 hRgn, LPRECT16 rc )
+BOOL32 REGION_UnionRectWithRgn( HRGN32 hRgn, LPRECT16 rc )
 {
   RGNOBJ 	*rgnObj = (RGNOBJ*) GDI_GetObjPtr( hRgn, REGION_MAGIC );
   XRectangle     rect = { rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top };
-  BOOL16	 ret = 0; 
+  BOOL32 ret = FALSE;
 
   if( rgnObj )
   {
@@ -452,34 +511,45 @@ BOOL16 REGION_UnionRectWithRgn( HRGN32 hRgn, LPRECT16 rc )
   return ret;
 }
 
+
 /***********************************************************************
  *           REGION_CreateFrameRgn
  *
  * Create a region that is a frame around another region
  */
-BOOL16 REGION_FrameRgn( HRGN32 hDest, HRGN32 hSrc, INT32 x, INT32 y )
+BOOL32 REGION_FrameRgn( HRGN32 hDest, HRGN32 hSrc, INT32 x, INT32 y )
 {
     RGNOBJ *destObj,*srcObj;
     Region result;
 
     destObj = (RGNOBJ*) GDI_GetObjPtr( hDest, REGION_MAGIC );
     srcObj  = (RGNOBJ*) GDI_GetObjPtr( hSrc, REGION_MAGIC );
-    if (!srcObj->xrgn) return 0;
+    if (!srcObj->xrgn) return FALSE;
     REGION_CopyRegion( srcObj, destObj );
     XShrinkRegion( destObj->xrgn, -x, -y );
     result = XCreateRegion();
     XSubtractRegion( destObj->xrgn, srcObj->xrgn, result );
     XDestroyRegion( destObj->xrgn );
     destObj->xrgn = result;
-    return 1;
+    return TRUE;
 }
 
+
+/***********************************************************************
+ *           CombineRgn16    (GDI.451)
+ */
+INT16 CombineRgn16( HRGN16 hDest, HRGN16 hSrc1, HRGN16 hSrc2, INT16 mode )
+{
+    return (INT16)CombineRgn32( hDest, hSrc1, hSrc2, mode );
+}
+
+
 /***********************************************************************
- *           CombineRgn    (GDI.451) (GDI32.19)
+ *           CombineRgn32   (GDI32.19)
  *
- * The behavior is correct even if src and dest regions are the same.
+ * Note: The behavior is correct even if src and dest regions are the same.
  */
-INT16 CombineRgn( HRGN32 hDest, HRGN32 hSrc1, HRGN32 hSrc2, INT32 mode )
+INT32 CombineRgn32( HRGN32 hDest, HRGN32 hSrc1, HRGN32 hSrc2, INT32 mode )
 {
     RGNOBJ *destObj, *src1Obj, *src2Obj;
     Region destrgn;
diff --git a/objects/text.c b/objects/text.c
index c714e7bbb924ff295e8f52f6cd707e49f0476db1..1862afef58f8862549676bb521e0d16d1ad104ea 100644
--- a/objects/text.c
+++ b/objects/text.c
@@ -256,12 +256,12 @@ INT16 DrawText16( HDC16 hdc, LPCSTR str, INT16 i_count,
                               rect, line, len, NULL )) return 0;
             if (prefix_offset != -1)
             {
-                HPEN16 hpen = CreatePen( PS_SOLID, 1, GetTextColor(hdc) );
-                HPEN16 oldPen = SelectObject( hdc, hpen );
+                HPEN32 hpen = CreatePen32( PS_SOLID, 1, GetTextColor(hdc) );
+                HPEN32 oldPen = SelectObject32( hdc, hpen );
                 MoveTo(hdc, x + prefix_x, y + tm.tmAscent + 1 );
-                LineTo(hdc, x + prefix_end, y + tm.tmAscent + 1 );
-                SelectObject( hdc, oldPen );
-                DeleteObject( hpen );
+                LineTo32(hdc, x + prefix_end, y + tm.tmAscent + 1 );
+                SelectObject32( hdc, oldPen );
+                DeleteObject32( hpen );
             }
 	}
 	else if (size.cx > max_width)
@@ -567,8 +567,7 @@ BOOL16 ExtTextOut16( HDC16 hdc, INT16 x, INT16 y, UINT16 flags,
 
     if (flags & ETO_CLIPPED) 
     {
-	if( dc->w.flags & DC_MEMORY )
-	     SelectClipRgn( hdc, hRgnClip );
+	if (dc->w.flags & DC_MEMORY) SelectClipRgn16( hdc, hRgnClip );
 	else RestoreVisRgn( hdc );
     }
     return TRUE;
diff --git a/rc/parser.l b/rc/parser.l
index ed39e54a9f19e672ffca4f30cb3600a3090248e9..baec1b8e758101f13072274831e6a9a2ae87946c 100644
--- a/rc/parser.l
+++ b/rc/parser.l
@@ -1,9 +1,9 @@
-%{
-/*
+/* -*-C-*-
  *
  * Copyright  Martin von Loewis, 1994
  *
  */
+%{
 
 #include <string.h>
 #include <stdio.h>
@@ -11,6 +11,8 @@
 #include "parser.h"
 #include "y.tab.h"
 
+#define YY_NO_UNPUT
+
 int line_number=1;
 %}
 %%
diff --git a/rc/parser.y b/rc/parser.y
index 3cbd0398c55092eac2a643eef113c4bd29e80f6a..17781ec6cf8893ca572ad1f40d445ec33a01e753 100644
--- a/rc/parser.y
+++ b/rc/parser.y
@@ -8,6 +8,10 @@
 #include <stdlib.h>
 #include "parser.h"
 #include "windows.h"
+
+int yylex(void);
+int yyerror(const char *s);
+
 %}
 %union{
 	gen_res *res;
@@ -214,7 +218,7 @@ style_elm:      NUMBER {$$=new_style();$$->or=$1;}
 extern int line_number;
 extern char* yytext;
 
-int yyerror(char *s)
+int yyerror( const char *s )
 {
 	fprintf(stderr,"stdin:%d: %s before '%s'\n",line_number,s,yytext);
 	return 0;
diff --git a/rc/winerc.c b/rc/winerc.c
index 2ea2d72d5c005cb19e6704766d570f8e720c8c1b..43a27f3be7783fe97a2626260884f5c87554304b 100644
--- a/rc/winerc.c
+++ b/rc/winerc.c
@@ -14,7 +14,6 @@
 #include <string.h>
 #include "windows.h"
 #include "parser.h"
-#include "y.tab.h"
 
 char usage[]="winerc -bdvc -p prefix -o outfile < infile \n"
 	"   -b            Create a C array from a binary .res file\n"
diff --git a/tools/makedep.c b/tools/makedep.c
index 1d1bf3adddb4f5737916ba4fa0fdeb60372c4001..16389878b5808d8c1f7d932dceb4649b15968c28 100644
--- a/tools/makedep.c
+++ b/tools/makedep.c
@@ -229,6 +229,7 @@ static void parse_file( INCL_FILE *pFile, int src )
         *p = 0;
         add_include( pFile, include );
     }
+    fclose(file);
 }
 
 
@@ -293,6 +294,7 @@ static void output_dependencies(void)
                                                  pFile, &column );
         fprintf( file, "\n" );
     }
+    fclose(file);
 }
 
 
diff --git a/win32/cursoricon32.c b/win32/cursoricon32.c
index 0fa03169f971965b3f573616d4b068eea24aaf11..c87a784678c03f1462964fe1be667add2eb1e554 100644
--- a/win32/cursoricon32.c
+++ b/win32/cursoricon32.c
@@ -372,8 +372,8 @@ static HGLOBAL32 CURSORICON32_LoadHandler( HANDLE32 handle,
     if (!(hRes = GlobalAlloc16( GMEM_MOVEABLE,
                                 sizeof(CURSORICONINFO) + sizeXor + sizeAnd)))
     {
-        DeleteObject( hXorBits );
-        DeleteObject( hAndBits );
+        DeleteObject32( hXorBits );
+        DeleteObject32( hAndBits );
         return 0;
     }
 
@@ -393,8 +393,8 @@ static HGLOBAL32 CURSORICON32_LoadHandler( HANDLE32 handle,
 
     GetBitmapBits( hAndBits, sizeAnd, (char *)(info + 1) );
     GetBitmapBits( hXorBits, sizeXor, (char *)(info + 1) + sizeAnd );
-    DeleteObject( hXorBits );
-    DeleteObject( hAndBits );
+    DeleteObject32( hXorBits );
+    DeleteObject32( hAndBits );
     GlobalUnlock16( hRes );
     return hRes;
 }
diff --git a/windows/caret.c b/windows/caret.c
index 86acfa3722c8865779b0faf8fd13f6114093710a..041eff0c2f38ab5a6131c69af9c4439ad0c75543 100644
--- a/windows/caret.c
+++ b/windows/caret.c
@@ -59,9 +59,9 @@ static void CARET_DisplayCaret( DISPLAY_CARET status )
 
     Caret.on = !Caret.on;
     if (!(hdc = GetDCEx32( Caret.hwnd, 0, DCX_USESTYLE | DCX_CACHE ))) return;
-    hPrevBrush = SelectObject( hdc, Caret.hBrush );
+    hPrevBrush = SelectObject32( hdc, Caret.hBrush );
     PatBlt( hdc, Caret.x, Caret.y, Caret.width, Caret.height, PATINVERT );
-    SelectObject( hdc, hPrevBrush );
+    SelectObject32( hdc, hPrevBrush );
     ReleaseDC32( Caret.hwnd, hdc );
 }
 
@@ -134,14 +134,14 @@ BOOL16 CreateCaret( HWND32 hwnd, HBITMAP32 bitmap, INT32 width, INT32 height )
         Caret.width = bmp.bmWidth;
         Caret.height = bmp.bmHeight;
         /* FIXME: we should make a copy of the bitmap instead of a brush */
-        Caret.hBrush = CreatePatternBrush( bitmap );
+        Caret.hBrush = CreatePatternBrush32( bitmap );
     }
     else
     {
         Caret.width = width ? width : GetSystemMetrics(SM_CXBORDER);
         Caret.height = height ? height : GetSystemMetrics(SM_CYBORDER);
-        Caret.hBrush = CreateSolidBrush( bitmap ? GetSysColor(COLOR_GRAYTEXT) :
-                                         GetSysColor(COLOR_WINDOW) );
+        Caret.hBrush = CreateSolidBrush32(bitmap ? GetSysColor(COLOR_GRAYTEXT):
+                                          GetSysColor(COLOR_WINDOW) );
     }
 
     Caret.hwnd = hwnd;
@@ -165,7 +165,7 @@ BOOL16 DestroyCaret(void)
     dprintf_caret(stddeb,"DestroyCaret: hwnd=%04x, timerid=%d\n",
 		Caret.hwnd, Caret.timerid);
 
-    DeleteObject( Caret.hBrush );
+    DeleteObject32( Caret.hBrush );
     CARET_KillTimer();
     CARET_DisplayCaret(CARET_OFF);
     Caret.hwnd = 0;
diff --git a/windows/class.c b/windows/class.c
index c89e96f90b89bc635e96a63b76435fce979a59a9..d5c3f642cdc27762d42a00ad049b64e65fe294e5 100644
--- a/windows/class.c
+++ b/windows/class.c
@@ -182,7 +182,7 @@ static BOOL CLASS_FreeClass( CLASS *classPtr )
     /* Delete the class */
 
     if (classPtr->dce) DCE_FreeDCE( classPtr->dce );
-    if (classPtr->hbrBackground) DeleteObject( classPtr->hbrBackground );
+    if (classPtr->hbrBackground) DeleteObject32( classPtr->hbrBackground );
     GlobalDeleteAtom( classPtr->atomName );
     CLASS_SetMenuNameA( classPtr, NULL );
     WINPROC_FreeProc( classPtr->winproc );
diff --git a/windows/dce.c b/windows/dce.c
index 0af441d24c964a8bcf07bd0de9fbffdd5fa8194a..d83b8bb022de3d392929a91d3e761940e3ddeb4b 100644
--- a/windows/dce.c
+++ b/windows/dce.c
@@ -87,7 +87,7 @@ void DCE_FreeDCE( DCE *dce )
 
     DeleteDC( dce->hDC );
     if( dce->hClipRgn && !(dce->DCXflags & DCX_KEEPCLIPRGN) )
-	DeleteObject(dce->hClipRgn);
+	DeleteObject32(dce->hClipRgn);
     HeapFree( SystemHeap, 0, dce );
 }
 
@@ -242,9 +242,9 @@ static HRGN32 DCE_ClipWindows( WND *pWndStart, WND *pWndEnd,
     HRGN32 hrgnNew;
 
     if (!pWndStart) return hrgn;
-    if (!(hrgnNew = CreateRectRgn( 0, 0, 0, 0 )))
+    if (!(hrgnNew = CreateRectRgn32( 0, 0, 0, 0 )))
     {
-        DeleteObject( hrgn );
+        DeleteObject32( hrgn );
         return 0;
     }
     for (; pWndStart != pWndEnd; pWndStart = pWndStart->next)
@@ -254,12 +254,12 @@ static HRGN32 DCE_ClipWindows( WND *pWndStart, WND *pWndEnd,
                     pWndStart->rectWindow.top + yoffset,
                     pWndStart->rectWindow.right + xoffset,
                     pWndStart->rectWindow.bottom + yoffset );
-        if (!CombineRgn( hrgn, hrgn, hrgnNew, RGN_DIFF )) break;
+        if (!CombineRgn32( hrgn, hrgn, hrgnNew, RGN_DIFF )) break;
     }
-    DeleteObject( hrgnNew );
+    DeleteObject32( hrgnNew );
     if (pWndStart != pWndEnd)  /* something went wrong */
     {
-        DeleteObject( hrgn );
+        DeleteObject32( hrgn );
         return 0;
     }
     return hrgn;
@@ -287,7 +287,7 @@ HRGN32 DCE_GetVisRgn( HWND hwnd, WORD flags )
 
     if (!wndPtr || !DCE_GetVisRect( wndPtr, !(flags & DCX_WINDOW), &rect ))
     {
-        return CreateRectRgn( 0, 0, 0, 0 );  /* Visible region is empty */
+        return CreateRectRgn32( 0, 0, 0, 0 );  /* Visible region is empty */
     }
     if (!(hrgn = CreateRectRgnIndirect16( &rect ))) return 0;
 
@@ -407,6 +407,8 @@ HDC32 GetDCEx32( HWND32 hwnd, HRGN32 hrgnClip, DWORD flags )
     
     if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
 
+    if (!(wndPtr->class->style & (CS_OWNDC | CS_CLASSDC))) flags |= DCX_CACHE;
+
     if (flags & DCX_USESTYLE)
     {
 	flags &= ~( DCX_CLIPCHILDREN | DCX_CLIPSIBLINGS | DCX_PARENTCLIP);
@@ -416,9 +418,6 @@ HDC32 GetDCEx32( HWND32 hwnd, HRGN32 hrgnClip, DWORD flags )
 
 	if ( !(flags & DCX_WINDOW) )
 	{
-            if (!(wndPtr->class->style & (CS_OWNDC | CS_CLASSDC)))
-		flags |= DCX_CACHE;
-
             if (wndPtr->class->style & CS_PARENTDC) flags |= DCX_PARENTCLIP;
 
 	    if (wndPtr->dwStyle & WS_CLIPCHILDREN &&
@@ -469,7 +468,7 @@ HDC32 GetDCEx32( HWND32 hwnd, HRGN32 hrgnClip, DWORD flags )
 	if( hrgnClip && dce->hClipRgn && !(dce->DCXflags & DCX_KEEPCLIPRGN))
 	  {
 	    fprintf(stdnimp,"GetDCEx: hClipRgn collision!\n");
-            DeleteObject(dce->hClipRgn); 
+            DeleteObject32( dce->hClipRgn ); 
 	    need_update = TRUE;
 	  }
     }
@@ -498,17 +497,17 @@ HDC32 GetDCEx32( HWND32 hwnd, HRGN32 hrgnClip, DWORD flags )
                 dcx_flags |= DCX_CLIPSIBLINGS;
             hrgnVisible = DCE_GetVisRgn( parentPtr->hwndSelf, dcx_flags );
             if (flags & DCX_WINDOW)
-                OffsetRgn( hrgnVisible, -wndPtr->rectWindow.left,
-                                        -wndPtr->rectWindow.top );
-            else OffsetRgn( hrgnVisible, -wndPtr->rectClient.left,
-                                         -wndPtr->rectClient.top );
+                OffsetRgn32( hrgnVisible, -wndPtr->rectWindow.left,
+                                          -wndPtr->rectWindow.top );
+            else OffsetRgn32( hrgnVisible, -wndPtr->rectClient.left,
+                                           -wndPtr->rectClient.top );
         }
            /* optimize away GetVisRgn for desktop if it isn't there */
 
       else if ((hwnd == GetDesktopWindow32()) &&
                (rootWindow == DefaultRootWindow(display)))
-	       hrgnVisible = CreateRectRgn( 0, 0, SYSMETRICS_CXSCREEN,
-                                                  SYSMETRICS_CYSCREEN);
+	       hrgnVisible = CreateRectRgn32( 0, 0, SYSMETRICS_CXSCREEN,
+                                                    SYSMETRICS_CYSCREEN );
       else hrgnVisible = DCE_GetVisRgn( hwnd, flags );
 
       if( wndPtr->parent && wndPtr->window )
@@ -526,7 +525,7 @@ HDC32 GetDCEx32( HWND32 hwnd, HRGN32 hrgnClip, DWORD flags )
       dc->w.flags &= ~DC_DIRTY;
       SelectVisRgn( hdc, hrgnVisible );
     }
-    else hrgnVisible = CreateRectRgn(0,0,0,0);
+    else hrgnVisible = CreateRectRgn32( 0, 0, 0, 0 );
 
     if ((flags & DCX_INTERSECTRGN) || (flags & DCX_EXCLUDERGN))
     {
@@ -536,11 +535,11 @@ HDC32 GetDCEx32( HWND32 hwnd, HRGN32 hrgnClip, DWORD flags )
 	dprintf_dc(stddeb, "\tsaved VisRgn, clipRgn = %04x\n", hrgnClip);
 
 	SaveVisRgn( hdc );
-        CombineRgn( hrgnVisible, InquireVisRgn( hdc ), hrgnClip,
-                    (flags & DCX_INTERSECTRGN) ? RGN_AND : RGN_DIFF );
+        CombineRgn32( hrgnVisible, InquireVisRgn( hdc ), hrgnClip,
+                      (flags & DCX_INTERSECTRGN) ? RGN_AND : RGN_DIFF );
 	SelectVisRgn( hdc, hrgnVisible );
     }
-    DeleteObject( hrgnVisible );
+    DeleteObject32( hrgnVisible );
 
     dprintf_dc(stddeb, "GetDCEx(%04x,%04x,0x%lx): returning %04x\n", 
 	       hwnd, hrgnClip, flags, hdc);
@@ -622,7 +621,7 @@ INT32 ReleaseDC32( HWND32 hwnd, HDC32 hdc )
 	    dce->DCXflags &= ~DCX_KEEPCLIPRGN;
 	else
 	    if( dce->hClipRgn > 1 )
-	        DeleteObject( dce->hClipRgn );
+	        DeleteObject32( dce->hClipRgn );
 
         dce->hClipRgn = 0;
 	RestoreVisRgn(dce->hDC);
@@ -673,11 +672,11 @@ BOOL16 DCHook( HDC16 hDC, WORD code, DWORD data, LPARAM lParam )
                          (dce->hClipRgn == 1 && dce->DCXflags & DCX_EXCLUDERGN) )            
                          SetRectRgn(hVisRgn,0,0,0,0);
                     else
-                         CombineRgn(hVisRgn, hVisRgn, dce->hClipRgn, 
+                         CombineRgn32(hVisRgn, hVisRgn, dce->hClipRgn, 
                                       (dce->DCXflags & DCX_EXCLUDERGN)? RGN_DIFF:RGN_AND);
 	          }  
 	       SelectVisRgn(hDC, hVisRgn);
-	       DeleteObject(hVisRgn);
+	       DeleteObject32( hVisRgn );
 	     }
            else
 	     dprintf_dc(stddeb,"DCHook: DC is not in use!\n");
diff --git a/windows/defdlg.c b/windows/defdlg.c
index 1b0e8531447082beb0b1796728cb830e6d3d9454..03a2d2214a72c5e3bbed3446c2e752cb6057dcdb 100644
--- a/windows/defdlg.c
+++ b/windows/defdlg.c
@@ -17,7 +17,7 @@
  * Set the focus to a control of the dialog, selecting the text if
  * the control is an edit dialog.
  */
-static void DEFDLG_SetFocus( HWND hwndDlg, HWND hwndCtrl )
+static void DEFDLG_SetFocus( HWND32 hwndDlg, HWND32 hwndCtrl )
 {
     HWND32 hwndPrev = GetFocus32();
 
@@ -35,7 +35,7 @@ static void DEFDLG_SetFocus( HWND hwndDlg, HWND hwndCtrl )
 /***********************************************************************
  *           DEFDLG_SaveFocus
  */
-static BOOL DEFDLG_SaveFocus( HWND hwnd, DIALOGINFO *infoPtr )
+static BOOL32 DEFDLG_SaveFocus( HWND32 hwnd, DIALOGINFO *infoPtr )
 {
     HWND32 hwndFocus = GetFocus32();
 
@@ -49,7 +49,7 @@ static BOOL DEFDLG_SaveFocus( HWND hwnd, DIALOGINFO *infoPtr )
 /***********************************************************************
  *           DEFDLG_RestoreFocus
  */
-static BOOL DEFDLG_RestoreFocus( HWND hwnd, DIALOGINFO *infoPtr )
+static BOOL32 DEFDLG_RestoreFocus( HWND32 hwnd, DIALOGINFO *infoPtr )
 {
     if (!infoPtr->hwndFocus || IsIconic(hwnd)) return FALSE;
     if (!IsWindow( infoPtr->hwndFocus )) return FALSE;
@@ -64,9 +64,9 @@ static BOOL DEFDLG_RestoreFocus( HWND hwnd, DIALOGINFO *infoPtr )
  *
  * Find the current default push-button.
  */
-static HWND DEFDLG_FindDefButton( HWND hwndDlg )
+static HWND32 DEFDLG_FindDefButton( HWND32 hwndDlg )
 {
-    HWND hwndChild = GetWindow( hwndDlg, GW_CHILD );
+    HWND32 hwndChild = GetWindow( hwndDlg, GW_CHILD );
     while (hwndChild)
     {
         if (SendMessage16( hwndChild, WM_GETDLGCODE, 0, 0 ) & DLGC_DEFPUSHBUTTON)
@@ -82,8 +82,8 @@ static HWND DEFDLG_FindDefButton( HWND hwndDlg )
  *
  * Set the new default button to be hwndNew.
  */
-static BOOL DEFDLG_SetDefButton( HWND hwndDlg, DIALOGINFO *dlgInfo,
-                                 HWND hwndNew )
+static BOOL32 DEFDLG_SetDefButton( HWND32 hwndDlg, DIALOGINFO *dlgInfo,
+                                   HWND32 hwndNew )
 {
     if (hwndNew &&
         !(SendMessage16(hwndNew, WM_GETDLGCODE, 0, 0 ) & DLGC_UNDEFPUSHBUTTON))
@@ -91,7 +91,7 @@ static BOOL DEFDLG_SetDefButton( HWND hwndDlg, DIALOGINFO *dlgInfo,
     
     if (dlgInfo->msgResult)  /* There's already a default pushbutton */
     {
-        HWND hwndOld = GetDlgItem( hwndDlg, dlgInfo->msgResult );
+        HWND32 hwndOld = GetDlgItem( hwndDlg, dlgInfo->msgResult );
         if (SendMessage32A( hwndOld, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON)
             SendMessage32A( hwndOld, BM_SETSTYLE32, BS_PUSHBUTTON, TRUE );
     }
@@ -114,7 +114,7 @@ static BOOL DEFDLG_SetDefButton( HWND hwndDlg, DIALOGINFO *dlgInfo,
 static LRESULT DEFDLG_Proc( HWND32 hwnd, UINT32 msg, WPARAM32 wParam,
                             LPARAM lParam, DIALOGINFO *dlgInfo )
 {
-    HWND hwndDefId;
+    HWND32 hwndDefId;
 
     switch(msg)
     {
@@ -138,7 +138,7 @@ static LRESULT DEFDLG_Proc( HWND32 hwnd, UINT32 msg, WPARAM32 wParam,
 	      /* Delete font */
 	    if (dlgInfo->hUserFont)
 	    {
-		DeleteObject( dlgInfo->hUserFont );
+		DeleteObject32( dlgInfo->hUserFont );
 		dlgInfo->hUserFont = 0;
 	    }
 
@@ -186,7 +186,7 @@ static LRESULT DEFDLG_Proc( HWND32 hwnd, UINT32 msg, WPARAM32 wParam,
 
 	case WM_NEXTDLGCTL:
 	    {
-                HWND hwndDest = (HWND)wParam;
+                HWND32 hwndDest = (HWND32)wParam;
                 if (!lParam)
                     hwndDest = GetNextDlgTabItem32(hwnd, GetFocus32(), wParam);
                 if (hwndDest) DEFDLG_SetFocus( hwnd, hwndDest );
diff --git a/windows/defwnd.c b/windows/defwnd.c
index 1d3adc3cd17956b75136afd9004459871875c659..03b82c3020f1f0d13f157dc7644ebd3c1f58bbf3 100644
--- a/windows/defwnd.c
+++ b/windows/defwnd.c
@@ -172,11 +172,11 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT32 msg, WPARAM32 wParam,
 
 	    if (wndPtr->class->hbrBackground <= (HBRUSH16)(COLOR_MAX+1))
             {
-                HBRUSH16 hbrush = CreateSolidBrush( 
+                HBRUSH32 hbrush = CreateSolidBrush32( 
 			 GetSysColor(((DWORD)wndPtr->class->hbrBackground)-1));
                  FillWindow( GetParent16(wndPtr->hwndSelf), wndPtr->hwndSelf,
                              (HDC16)wParam, hbrush);
-                 DeleteObject (hbrush);
+                 DeleteObject32( hbrush );
             }
             else FillWindow( GetParent16(wndPtr->hwndSelf), wndPtr->hwndSelf,
                              (HDC16)wParam, wndPtr->class->hbrBackground );
@@ -199,7 +199,7 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT32 msg, WPARAM32 wParam,
     case WM_CTLCOLORSCROLLBAR:
         SetBkColor( (HDC32)wParam, RGB(255, 255, 255) );
         SetTextColor( (HDC32)wParam, RGB(0, 0, 0) );
-        UnrealizeObject( sysColorObjects.hbrushScrollbar );
+        UnrealizeObject32( sysColorObjects.hbrushScrollbar );
         return (LRESULT)sysColorObjects.hbrushScrollbar;
 
     case WM_CTLCOLOR:
@@ -208,7 +208,7 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT32 msg, WPARAM32 wParam,
 	    {
 		SetBkColor( (HDC32)wParam, RGB(255, 255, 255) );
 		SetTextColor( (HDC32)wParam, RGB(0, 0, 0) );
-		UnrealizeObject( sysColorObjects.hbrushScrollbar );
+		UnrealizeObject32( sysColorObjects.hbrushScrollbar );
 		return (LRESULT)sysColorObjects.hbrushScrollbar;
 	    }
 	    else
diff --git a/windows/dialog.c b/windows/dialog.c
index 0fa7fb1e996989eb2fe9ce97af408bf887b3eac8..17a349a990dec95be057aadc9344b02321212623 100644
--- a/windows/dialog.c
+++ b/windows/dialog.c
@@ -237,7 +237,7 @@ static BOOL32 DIALOG_CreateControls( WND *pWnd, LPCSTR template, INT32 items,
             HINSTANCE16 instance;
             template = DIALOG_GetControl16( template, &info );
             if (HIWORD(info.className) && !strcmp( info.className, "EDIT") &&
-                ((info.style & DS_LOCALEDIT) != DS_LOCALEDIT))
+                ((pWnd->dwStyle & DS_LOCALEDIT) != DS_LOCALEDIT))
             {
                 if (!dlgInfo->hDialogHeap)
                 {
@@ -502,9 +502,9 @@ static HWND DIALOG_CreateIndirect( HINSTANCE32 hInst, LPCSTR dlgTemplate,
 	    HFONT16 oldFont;
 
 	    HDC32 hdc = GetDC32(0);
-	    oldFont = SelectObject( hdc, hFont );
+	    oldFont = SelectObject32( hdc, hFont );
 	    GetTextMetrics16( hdc, &tm );
-	    SelectObject( hdc, oldFont );
+	    SelectObject32( hdc, oldFont );
 	    ReleaseDC32( 0, hdc );
 	    xUnit = tm.tmAveCharWidth;
 	    yUnit = tm.tmHeight;
@@ -551,7 +551,7 @@ static HWND DIALOG_CreateIndirect( HINSTANCE32 hInst, LPCSTR dlgTemplate,
                                 owner, hMenu, hInst, NULL );
     if (!hwnd)
     {
-	if (hFont) DeleteObject( hFont );
+	if (hFont) DeleteObject32( hFont );
 	if (hMenu) DestroyMenu( hMenu );
 	return 0;
     }
diff --git a/windows/event.c b/windows/event.c
index e45582c0ea4bb35229562dc91a5cd27ef9a3e980..24ec312f9d8d96bc40bf6a946227aa5d081144ee 100644
--- a/windows/event.c
+++ b/windows/event.c
@@ -771,7 +771,7 @@ static void EVENT_ConfigureNotify( HWND hwnd, XConfigureEvent *event )
 
         hrgnOldPos = CreateRectRgnIndirect16( &wndPtr->rectWindow );
         hrgnNewPos = CreateRectRgnIndirect16( &newWindowRect );
-        CombineRgn( hrgnOldPos, hrgnOldPos, hrgnNewPos, RGN_DIFF );
+        CombineRgn32( hrgnOldPos, hrgnOldPos, hrgnNewPos, RGN_DIFF );
  
 	/* Set new size and position */
 	wndPtr->rectWindow = newWindowRect;
@@ -783,8 +783,8 @@ static void EVENT_ConfigureNotify( HWND hwnd, XConfigureEvent *event )
         PAINT_RedrawWindow( 0, NULL, hrgnOldPos, RDW_INVALIDATE |
                             RDW_ALLCHILDREN | RDW_ERASE | RDW_ERASENOW,
                             RDW_C_USEHRGN );
-        DeleteObject(hrgnOldPos);
-        DeleteObject(hrgnNewPos);
+        DeleteObject32(hrgnOldPos);
+        DeleteObject32(hrgnNewPos);
     }
 }
 
diff --git a/windows/graphics.c b/windows/graphics.c
index 06644ad2cf4b1ebf04856d854f5e81c892c1bdd2..78abec27d06100c618bda6156aa90f7dca643b1a 100644
--- a/windows/graphics.c
+++ b/windows/graphics.c
@@ -4,6 +4,7 @@
  * Copyright 1993, 1994 Alexandre Julliard
  */
 
+#define NO_TRANSITION_TYPES  /* This file is Win32-clean */
 #include <math.h>
 #include <stdlib.h>
 #include <X11/Xlib.h>
@@ -26,9 +27,18 @@
 #include "xmalloc.h"
 
 /***********************************************************************
- *           LineTo    (GDI.19)
+ *           LineTo16    (GDI.19)
  */
-BOOL LineTo( HDC16 hdc, short x, short y )
+BOOL16 LineTo16( HDC16 hdc, INT16 x, INT16 y )
+{
+    return LineTo32( hdc, x, y );
+}
+
+
+/***********************************************************************
+ *           LineTo32    (GDI32.249)
+ */
+BOOL32 LineTo32( HDC32 hdc, INT32 x, INT32 y )
 {
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc) 
@@ -54,9 +64,9 @@ BOOL LineTo( HDC16 hdc, short x, short y )
 /***********************************************************************
  *           MoveTo    (GDI.20)
  */
-DWORD MoveTo( HDC16 hdc, short x, short y )
+DWORD MoveTo( HDC16 hdc, INT16 x, INT16 y )
 {
-    short oldx, oldy;
+    DWORD ret;
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc) 
     {
@@ -65,12 +75,10 @@ DWORD MoveTo( HDC16 hdc, short x, short y )
 	MF_MetaParam2(dc, META_MOVETO, x, y);
 	return 0;
     }
-
-    oldx = dc->w.CursPosX;
-    oldy = dc->w.CursPosY;
+    ret = MAKELONG( dc->w.CursPosX, dc->w.CursPosY );
     dc->w.CursPosX = x;
     dc->w.CursPosY = y;
-    return oldx | (oldy << 16);
+    return ret;
 }
 
 
@@ -110,10 +118,11 @@ BOOL32 MoveToEx32( HDC32 hdc, INT32 x, INT32 y, LPPOINT32 pt )
  * Helper functions for Arc(), Chord() and Pie().
  * 'lines' is the number of lines to draw: 0 for Arc, 1 for Chord, 2 for Pie.
  */
-static BOOL GRAPH_DrawArc( HDC16 hdc, int left, int top, int right, int bottom,
-		    int xstart, int ystart, int xend, int yend, int lines )
+static BOOL32 GRAPH_DrawArc( HDC32 hdc, INT32 left, INT32 top, INT32 right,
+                             INT32 bottom, INT32 xstart, INT32 ystart,
+                             INT32 xend, INT32 yend, INT32 lines )
 {
-    int xcenter, ycenter, istart_angle, idiff_angle, tmp;
+    INT32 xcenter, ycenter, istart_angle, idiff_angle, tmp;
     double start_angle, end_angle;
     XPoint points[3];
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
@@ -157,8 +166,8 @@ static BOOL GRAPH_DrawArc( HDC16 hdc, int left, int top, int right, int bottom,
 			 (double)(xstart-xcenter)*(bottom-top) );
     end_angle   = atan2( (double)(ycenter-yend)*(right-left),
 			 (double)(xend-xcenter)*(bottom-top) );
-    istart_angle = (int)(start_angle * 180 * 64 / PI);
-    idiff_angle  = (int)((end_angle - start_angle) * 180 * 64 / PI );
+    istart_angle = (INT32)(start_angle * 180 * 64 / PI);
+    idiff_angle  = (INT32)((end_angle - start_angle) * 180 * 64 / PI );
     if (idiff_angle <= 0) idiff_angle += 360 * 64;
     if (left > right) { tmp=left; left=right; right=tmp; }
     if (top > bottom) { tmp=top; top=bottom; bottom=tmp; }
@@ -198,10 +207,21 @@ static BOOL GRAPH_DrawArc( HDC16 hdc, int left, int top, int right, int bottom,
 
 
 /***********************************************************************
- *           Arc    (GDI.23)
+ *           Arc16    (GDI.23)
+ */
+BOOL16 Arc16( HDC16 hdc, INT16 left, INT16 top, INT16 right, INT16 bottom,
+              INT16 xstart, INT16 ystart, INT16 xend, INT16 yend )
+{
+    return GRAPH_DrawArc( hdc, left, top, right, bottom,
+			  xstart, ystart, xend, yend, 0 );
+}
+
+
+/***********************************************************************
+ *           Arc32    (GDI32.7)
  */
-BOOL Arc( HDC16 hdc, INT left, INT top, INT right, INT bottom,
-	  INT xstart, INT ystart, INT xend, INT yend )
+BOOL32 Arc32( HDC32 hdc, INT32 left, INT32 top, INT32 right, INT32 bottom,
+              INT32 xstart, INT32 ystart, INT32 xend, INT32 yend )
 {
     return GRAPH_DrawArc( hdc, left, top, right, bottom,
 			  xstart, ystart, xend, yend, 0 );
@@ -209,10 +229,10 @@ BOOL Arc( HDC16 hdc, INT left, INT top, INT right, INT bottom,
 
 
 /***********************************************************************
- *           Pie    (GDI.26)
+ *           Pie16    (GDI.26)
  */
-BOOL Pie( HDC16 hdc, INT left, INT top, INT right, INT bottom,
-	  INT xstart, INT ystart, INT xend, INT yend )
+BOOL16 Pie16( HDC16 hdc, INT16 left, INT16 top, INT16 right, INT16 bottom,
+              INT16 xstart, INT16 ystart, INT16 xend, INT16 yend )
 {
     return GRAPH_DrawArc( hdc, left, top, right, bottom,
 			  xstart, ystart, xend, yend, 2 );
@@ -220,10 +240,32 @@ BOOL Pie( HDC16 hdc, INT left, INT top, INT right, INT bottom,
 
 
 /***********************************************************************
- *           Chord    (GDI.348)
+ *           Pie32   (GDI32.262)
+ */
+BOOL32 Pie32( HDC32 hdc, INT32 left, INT32 top, INT32 right, INT32 bottom,
+              INT32 xstart, INT32 ystart, INT32 xend, INT32 yend )
+{
+    return GRAPH_DrawArc( hdc, left, top, right, bottom,
+			  xstart, ystart, xend, yend, 2 );
+}
+
+
+/***********************************************************************
+ *           Chord16    (GDI.348)
+ */
+BOOL16 Chord16( HDC16 hdc, INT16 left, INT16 top, INT16 right, INT16 bottom,
+                INT16 xstart, INT16 ystart, INT16 xend, INT16 yend )
+{
+    return GRAPH_DrawArc( hdc, left, top, right, bottom,
+			  xstart, ystart, xend, yend, 1 );
+}
+
+
+/***********************************************************************
+ *           Chord32    (GDI32.14)
  */
-BOOL Chord( HDC16 hdc, INT left, INT top, INT right, INT bottom,
-	    INT xstart, INT ystart, INT xend, INT yend )
+BOOL32 Chord32( HDC32 hdc, INT32 left, INT32 top, INT32 right, INT32 bottom,
+                INT32 xstart, INT32 ystart, INT32 xend, INT32 yend )
 {
     return GRAPH_DrawArc( hdc, left, top, right, bottom,
 			  xstart, ystart, xend, yend, 1 );
@@ -231,9 +273,18 @@ BOOL Chord( HDC16 hdc, INT left, INT top, INT right, INT bottom,
 
 
 /***********************************************************************
- *           Ellipse    (GDI.24)
+ *           Ellipse16    (GDI.24)
+ */
+BOOL16 Ellipse16( HDC16 hdc, INT16 left, INT16 top, INT16 right, INT16 bottom )
+{
+    return Ellipse32( hdc, left, top, right, bottom );
+}
+
+
+/***********************************************************************
+ *           Ellipse32    (GDI32.75)
  */
-BOOL Ellipse( HDC16 hdc, INT left, INT top, INT right, INT bottom )
+BOOL32 Ellipse32( HDC32 hdc, INT32 left, INT32 top, INT32 right, INT32 bottom )
 {
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc) 
@@ -250,8 +301,8 @@ BOOL Ellipse( HDC16 hdc, INT left, INT top, INT right, INT bottom )
     bottom = YLPTODP( dc, bottom );
     if ((left == right) || (top == bottom)) return FALSE;
 
-    if (right < left) { INT tmp = right; right = left; left = tmp; }
-    if (bottom < top) { INT tmp = bottom; bottom = top; top = tmp; }
+    if (right < left) { INT32 tmp = right; right = left; left = tmp; }
+    if (bottom < top) { INT32 tmp = bottom; bottom = top; top = tmp; }
     
     if ((dc->u.x.pen.style == PS_INSIDEFRAME) &&
         (dc->u.x.pen.width < right-left-1) &&
@@ -276,9 +327,18 @@ BOOL Ellipse( HDC16 hdc, INT left, INT top, INT right, INT bottom )
 
 
 /***********************************************************************
- *           Rectangle    (GDI.27)
+ *           Rectangle16    (GDI.27)
+ */
+BOOL16 Rectangle16(HDC16 hdc, INT16 left, INT16 top, INT16 right, INT16 bottom)
+{
+    return Rectangle32( hdc, left, top, right, bottom );
+}
+
+
+/***********************************************************************
+ *           Rectangle32    (GDI32.283)
  */
-BOOL Rectangle( HDC16 hdc, INT left, INT top, INT right, INT bottom )
+BOOL32 Rectangle32(HDC32 hdc, INT32 left, INT32 top, INT32 right, INT32 bottom)
 {
     INT32 width;
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
@@ -294,8 +354,8 @@ BOOL Rectangle( HDC16 hdc, INT left, INT top, INT right, INT bottom )
     right  = XLPTODP( dc, right );
     bottom = YLPTODP( dc, bottom );
 
-    if (right < left) { INT tmp = right; right = left; left = tmp; }
-    if (bottom < top) { INT tmp = bottom; bottom = top; top = tmp; }
+    if (right < left) { INT32 tmp = right; right = left; left = tmp; }
+    if (bottom < top) { INT32 tmp = bottom; bottom = top; top = tmp; }
 
     if ((left == right) || (top == bottom))
     {
@@ -334,15 +394,25 @@ BOOL Rectangle( HDC16 hdc, INT left, INT top, INT right, INT bottom )
 
 
 /***********************************************************************
- *           RoundRect    (GDI.28)
+ *           RoundRect16    (GDI.28)
  */
-BOOL RoundRect( HDC16 hDC, INT left, INT top, INT right, INT bottom,
-                INT ell_width, INT ell_height )
+BOOL16 RoundRect16( HDC16 hdc, INT16 left, INT16 top, INT16 right,
+                    INT16 bottom, INT16 ell_width, INT16 ell_height )
 {
-    DC * dc = (DC *) GDI_GetObjPtr(hDC, DC_MAGIC);
+    return RoundRect32( hdc, left, top, right, bottom, ell_width, ell_height );
+}
+
+
+/***********************************************************************
+ *           RoundRect32    (GDI32.291)
+ */
+BOOL32 RoundRect32( HDC32 hdc, INT32 left, INT32 top, INT32 right,
+                    INT32 bottom, INT32 ell_width, INT32 ell_height )
+{
+    DC * dc = (DC *) GDI_GetObjPtr(hdc, DC_MAGIC);
     if (!dc) 
     {
-	dc = (DC *)GDI_GetObjPtr(hDC, METAFILE_DC_MAGIC);
+	dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
 	if (!dc) return FALSE;
 	MF_MetaParam6(dc, META_ROUNDRECT, left, top, right, bottom,
 		      ell_width, ell_height);
@@ -360,8 +430,8 @@ BOOL RoundRect( HDC16 hDC, INT left, INT top, INT right, INT bottom,
 
     /* Fix the coordinates */
 
-    if (right < left) { INT tmp = right; right = left; left = tmp; }
-    if (bottom < top) { INT tmp = bottom; bottom = top; top = tmp; }
+    if (right < left) { INT32 tmp = right; right = left; left = tmp; }
+    if (bottom < top) { INT32 tmp = bottom; bottom = top; top = tmp; }
     if (ell_width > right - left) ell_width = right - left;
     if (ell_height > bottom - top) ell_height = bottom - top;
 
@@ -462,10 +532,10 @@ INT16 FillRect16( HDC16 hdc, const RECT16 *rect, HBRUSH16 hbrush )
      * - do it in PatBlt() after LPtoDP().
      */
 
-    if (!(prevBrush = SelectObject( hdc, hbrush ))) return 0;
+    if (!(prevBrush = SelectObject16( hdc, hbrush ))) return 0;
     PatBlt( hdc, rect->left, rect->top,
 	    rect->right - rect->left, rect->bottom - rect->top, PATCOPY );
-    SelectObject( hdc, prevBrush );
+    SelectObject16( hdc, prevBrush );
     return 1;
 }
 
@@ -475,12 +545,12 @@ INT16 FillRect16( HDC16 hdc, const RECT16 *rect, HBRUSH16 hbrush )
  */
 INT32 FillRect32( HDC32 hdc, const RECT32 *rect, HBRUSH32 hbrush )
 {
-    HBRUSH16 prevBrush;
+    HBRUSH32 prevBrush;
 
-    if (!(prevBrush = SelectObject( hdc, (HBRUSH16)hbrush ))) return 0;
+    if (!(prevBrush = SelectObject32( hdc, hbrush ))) return 0;
     PatBlt( hdc, rect->left, rect->top,
 	    rect->right - rect->left, rect->bottom - rect->top, PATCOPY );
-    SelectObject( hdc, prevBrush );
+    SelectObject32( hdc, prevBrush );
     return 1;
 }
 
@@ -522,7 +592,7 @@ INT16 FrameRect16( HDC16 hdc, const RECT16 *rect, HBRUSH16 hbrush )
     bottom = YLPTODP( dc, rect->bottom );
 
     if ( (right <= left) || (bottom <= top) ) return 0;
-    if (!(prevBrush = SelectObject( hdc, hbrush ))) return 0;
+    if (!(prevBrush = SelectObject16( hdc, hbrush ))) return 0;
     
     if (DC_SetupGCForBrush( dc ))
     {
@@ -535,7 +605,7 @@ INT16 FrameRect16( HDC16 hdc, const RECT16 *rect, HBRUSH16 hbrush )
 	PatBlt( hdc, rect->left, rect->bottom - 1,
 	    rect->right - rect->left, 1, PATCOPY );
 	}    
-    SelectObject( hdc, prevBrush );
+    SelectObject16( hdc, prevBrush );
     return 1;
 }
 
@@ -552,9 +622,18 @@ INT32 FrameRect32( HDC32 hdc, const RECT32 *rect, HBRUSH32 hbrush )
 
 
 /***********************************************************************
- *           SetPixel    (GDI.31)
+ *           SetPixel16    (GDI.31)
  */
-COLORREF SetPixel( HDC16 hdc, short x, short y, COLORREF color )
+COLORREF SetPixel16( HDC16 hdc, INT16 x, INT16 y, COLORREF color )
+{
+    return SetPixel32( hdc, x, y, color );
+}
+
+
+/***********************************************************************
+ *           SetPixel32    (GDI32.327)
+ */
+COLORREF SetPixel32( HDC32 hdc, INT32 x, INT32 y, COLORREF color )
 {
     Pixel pixel;
     
@@ -582,9 +661,18 @@ COLORREF SetPixel( HDC16 hdc, short x, short y, COLORREF color )
 
 
 /***********************************************************************
- *           GetPixel    (GDI.83)
+ *           GetPixel16    (GDI.83)
+ */
+COLORREF GetPixel16( HDC16 hdc, INT16 x, INT16 y )
+{
+    return GetPixel32( hdc, x, y );
+}
+
+
+/***********************************************************************
+ *           GetPixel32    (GDI32.211)
  */
-COLORREF GetPixel( HDC16 hdc, short x, short y )
+COLORREF GetPixel32( HDC32 hdc, INT32 x, INT32 y )
 {
     static Pixmap pixmap = 0;
     XImage * image;
@@ -597,7 +685,7 @@ COLORREF GetPixel( HDC16 hdc, short x, short y )
     return 0;
 #endif
 
-    if (!PtVisible( hdc, x, y )) return 0;
+    if (!PtVisible32( hdc, x, y )) return 0;
 
     x = dc->w.DCOrgX + XLPTODP( dc, x );
     y = dc->w.DCOrgY + YLPTODP( dc, y );
@@ -624,11 +712,20 @@ COLORREF GetPixel( HDC16 hdc, short x, short y )
 
 
 /***********************************************************************
- *           PaintRgn    (GDI.43)
+ *           PaintRgn16    (GDI.43)
+ */
+BOOL16 PaintRgn16( HDC16 hdc, HRGN16 hrgn )
+{
+    return PaintRgn32( hdc, hrgn );
+}
+
+
+/***********************************************************************
+ *           PaintRgn32    (GDI32.259)
  */
-BOOL PaintRgn( HDC16 hdc, HRGN32 hrgn )
+BOOL32 PaintRgn32( HDC32 hdc, HRGN32 hrgn )
 {
-    RECT16 box;
+    RECT32 box;
     HRGN32 tmpVisRgn, prevVisRgn;
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc) return FALSE;
@@ -636,18 +733,18 @@ BOOL PaintRgn( HDC16 hdc, HRGN32 hrgn )
       /* Modify visible region */
 
     if (!(prevVisRgn = SaveVisRgn( hdc ))) return FALSE;
-    if (!(tmpVisRgn = CreateRectRgn( 0, 0, 0, 0 )))
+    if (!(tmpVisRgn = CreateRectRgn32( 0, 0, 0, 0 )))
     {
         RestoreVisRgn( hdc );
         return FALSE;
     }
-    CombineRgn( tmpVisRgn, prevVisRgn, hrgn, RGN_AND );
+    CombineRgn32( tmpVisRgn, prevVisRgn, hrgn, RGN_AND );
     SelectVisRgn( hdc, tmpVisRgn );
-    DeleteObject( tmpVisRgn );
+    DeleteObject32( tmpVisRgn );
 
       /* Fill the region */
 
-    GetRgnBox16( dc->w.hGCClipRgn, &box );
+    GetRgnBox32( dc->w.hGCClipRgn, &box );
     if (DC_SetupGCForBrush( dc ))
 	XFillRectangle( display, dc->u.x.drawable, dc->u.x.gc,
 		        dc->w.DCOrgX + box.left, dc->w.DCOrgY + box.top,
@@ -661,39 +758,70 @@ BOOL PaintRgn( HDC16 hdc, HRGN32 hrgn )
 
 
 /***********************************************************************
- *           FillRgn    (GDI.40)
+ *           FillRgn16    (GDI.40)
  */
-BOOL FillRgn( HDC16 hdc, HRGN32 hrgn, HBRUSH16 hbrush )
+BOOL16 FillRgn16( HDC16 hdc, HRGN16 hrgn, HBRUSH16 hbrush )
 {
-    BOOL retval;
-    HBRUSH16 prevBrush = SelectObject( hdc, hbrush );
+    return FillRgn32( hdc, hrgn, hbrush );
+}
+
+    
+/***********************************************************************
+ *           FillRgn32    (GDI32.101)
+ */
+BOOL32 FillRgn32( HDC32 hdc, HRGN32 hrgn, HBRUSH32 hbrush )
+{
+    BOOL32 retval;
+    HBRUSH32 prevBrush = SelectObject32( hdc, hbrush );
     if (!prevBrush) return FALSE;
-    retval = PaintRgn( hdc, hrgn );
-    SelectObject( hdc, prevBrush );
+    retval = PaintRgn32( hdc, hrgn );
+    SelectObject32( hdc, prevBrush );
     return retval;
 }
 
+
 /***********************************************************************
- *           FrameRgn     (GDI.41)
+ *           FrameRgn16     (GDI.41)
  */
-BOOL FrameRgn( HDC16 hdc, HRGN32 hrgn, HBRUSH16 hbrush, int nWidth, int nHeight )
+BOOL16 FrameRgn16( HDC16 hdc, HRGN16 hrgn, HBRUSH16 hbrush,
+                   INT16 nWidth, INT16 nHeight )
 {
-    HRGN32 tmp = CreateRectRgn( 0, 0, 0, 0 );
-    if(!REGION_FrameRgn( tmp, hrgn, nWidth, nHeight )) return 0;
-    FillRgn( hdc, tmp, hbrush );
-    DeleteObject( tmp );
-    return 1;
+    return FrameRgn32( hdc, hrgn, hbrush, nWidth, nHeight );
 }
 
+
+/***********************************************************************
+ *           FrameRgn32     (GDI32.105)
+ */
+BOOL32 FrameRgn32( HDC32 hdc, HRGN32 hrgn, HBRUSH32 hbrush,
+                   INT32 nWidth, INT32 nHeight )
+{
+    HRGN32 tmp = CreateRectRgn32( 0, 0, 0, 0 );
+    if(!REGION_FrameRgn( tmp, hrgn, nWidth, nHeight )) return FALSE;
+    FillRgn32( hdc, tmp, hbrush );
+    DeleteObject32( tmp );
+    return TRUE;
+}
+
+
 /***********************************************************************
- *           InvertRgn    (GDI.42)
+ *           InvertRgn16    (GDI.42)
  */
-BOOL InvertRgn( HDC16 hdc, HRGN32 hrgn )
+BOOL16 InvertRgn16( HDC16 hdc, HRGN16 hrgn )
 {
-    HBRUSH16 prevBrush = SelectObject( hdc, GetStockObject(BLACK_BRUSH) );
+    return InvertRgn32( hdc, hrgn );
+}
+
+
+/***********************************************************************
+ *           InvertRgn32    (GDI32.246)
+ */
+BOOL32 InvertRgn32( HDC32 hdc, HRGN32 hrgn )
+{
+    HBRUSH32 prevBrush = SelectObject32( hdc, GetStockObject32(BLACK_BRUSH) );
     WORD prevROP = SetROP2( hdc, R2_NOT );
-    BOOL retval = PaintRgn( hdc, hrgn );
-    SelectObject( hdc, prevBrush );
+    BOOL32 retval = PaintRgn32( hdc, hrgn );
+    SelectObject32( hdc, prevBrush );
     SetROP2( hdc, prevROP );
     return retval;
 }
@@ -704,9 +832,21 @@ BOOL InvertRgn( HDC16 hdc, HRGN32 hrgn )
  */
 void DrawFocusRect16( HDC16 hdc, const RECT16* rc )
 {
-    HPEN16 hOldPen;
-    int oldDrawMode, oldBkMode;
-    int left, top, right, bottom;
+    RECT32 rect32;
+    CONV_RECT16TO32( rc, &rect32 );
+    return DrawFocusRect32( hdc, &rect32 );
+}
+
+
+/***********************************************************************
+ *           DrawFocusRect32    (USER32.155)
+ */
+void DrawFocusRect32( HDC32 hdc, const RECT32* rc )
+{
+    HPEN32 hOldPen;
+    INT32 oldDrawMode, oldBkMode;
+    INT32 left, top, right, bottom;
+
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc) return;
 
@@ -715,7 +855,7 @@ void DrawFocusRect16( HDC16 hdc, const RECT16* rc )
     right  = XLPTODP( dc, rc->right );
     bottom = YLPTODP( dc, rc->bottom );
     
-    hOldPen = (HPEN16)SelectObject(hdc, sysColorObjects.hpenWindowText );
+    hOldPen = SelectObject32( hdc, sysColorObjects.hpenWindowText );
     oldDrawMode = SetROP2(hdc, R2_XORPEN);
     oldBkMode = SetBkMode(hdc, TRANSPARENT);
 
@@ -729,18 +869,7 @@ void DrawFocusRect16( HDC16 hdc, const RECT16* rc )
 
     SetBkMode(hdc, oldBkMode);
     SetROP2(hdc, oldDrawMode);
-    SelectObject(hdc, hOldPen);
-}
-
-
-/***********************************************************************
- *           DrawFocusRect32    (USER32.155)
- */
-void DrawFocusRect32( HDC32 hdc, const RECT32* rect )
-{
-    RECT16 rect16;
-    CONV_RECT32TO16( rect, &rect16 );
-    return DrawFocusRect16( (HDC16)hdc, &rect16 );
+    SelectObject32(hdc, hOldPen);
 }
 
 
@@ -786,10 +915,10 @@ BOOL32 GRAPH_DrawBitmap( HDC32 hdc, HBITMAP32 hbitmap, int xdest, int ydest,
 void GRAPH_DrawReliefRect( HDC32 hdc, const RECT32 *rect, INT32 highlight_size,
                            INT32 shadow_size, BOOL32 pressed )
 {
-    HBRUSH16 hbrushOld;
-    int i;
+    HBRUSH32 hbrushOld;
+    INT32 i;
 
-    hbrushOld = SelectObject( hdc, pressed ? sysColorObjects.hbrushBtnShadow :
+    hbrushOld = SelectObject32(hdc, pressed ? sysColorObjects.hbrushBtnShadow :
 			                  sysColorObjects.hbrushBtnHighlight );
     for (i = 0; i < highlight_size; i++)
     {
@@ -799,8 +928,8 @@ void GRAPH_DrawReliefRect( HDC32 hdc, const RECT32 *rect, INT32 highlight_size,
 	        rect->right - rect->left - i, 1, PATCOPY );
     }
 
-    SelectObject( hdc, pressed ? sysColorObjects.hbrushBtnHighlight :
-		                 sysColorObjects.hbrushBtnShadow );
+    SelectObject32( hdc, pressed ? sysColorObjects.hbrushBtnHighlight :
+		                   sysColorObjects.hbrushBtnShadow );
     for (i = 0; i < shadow_size; i++)
     {
 	PatBlt( hdc, rect->right - i - 1, rect->top + i,
@@ -809,7 +938,7 @@ void GRAPH_DrawReliefRect( HDC32 hdc, const RECT32 *rect, INT32 highlight_size,
 	        rect->right - rect->left - i, 1, PATCOPY );
     }
 
-    SelectObject( hdc, hbrushOld );
+    SelectObject32( hdc, hbrushOld );
 }
 
 
@@ -896,8 +1025,8 @@ BOOL16 PolyPolygon16( HDC16 hdc, LPPOINT16 pt, LPINT16 counts, UINT16 polygons)
       /* really correct either, it doesn't matter much... */
       /* At least the outline will be correct :-) */
     hrgn = CreatePolyPolygonRgn16( pt, counts, polygons, dc->w.polyFillMode );
-    PaintRgn( hdc, hrgn );
-    DeleteObject( hrgn );
+    PaintRgn32( hdc, hrgn );
+    DeleteObject32( hrgn );
 
       /* Draw the outline of the polygons */
 
@@ -1001,7 +1130,7 @@ static void GRAPH_InternalFloodFill( XImage *image, DC *dc,
  *
  * Main flood-fill routine.
  */
-static BOOL16 GRAPH_DoFloodFill( DC *dc, RECT16 *rect, INT32 x, INT32 y,
+static BOOL32 GRAPH_DoFloodFill( DC *dc, RECT32 *rect, INT32 x, INT32 y,
                                  COLORREF color, UINT32 fillType )
 {
     XImage *image;
@@ -1031,12 +1160,22 @@ static BOOL16 GRAPH_DoFloodFill( DC *dc, RECT16 *rect, INT32 x, INT32 y,
 
 
 /**********************************************************************
- *          ExtFloodFill  (GDI.372) (GDI32.96)
+ *          ExtFloodFill16   (GDI.372)
  */
-BOOL16 ExtFloodFill( HDC32 hdc, INT32 x, INT32 y, COLORREF color,
-                     UINT32 fillType )
+BOOL16 ExtFloodFill16( HDC16 hdc, INT16 x, INT16 y, COLORREF color,
+                       UINT16 fillType )
 {
-    RECT16 rect;
+    return ExtFloodFill32( hdc, x, y, color, fillType );
+}
+
+
+/**********************************************************************
+ *          ExtFloodFill32   (GDI32.96)
+ */
+BOOL32 ExtFloodFill32( HDC32 hdc, INT32 x, INT32 y, COLORREF color,
+                       UINT32 fillType )
+{
+    RECT32 rect;
     DC *dc;
 
     dprintf_graphics( stddeb, "ExtFloodFill %04x %d,%d %06lx %d\n",
@@ -1051,8 +1190,8 @@ BOOL16 ExtFloodFill( HDC32 hdc, INT32 x, INT32 y, COLORREF color,
 	return TRUE;
     }
 
-    if (!PtVisible( hdc, x, y )) return FALSE;
-    if (GetRgnBox16( dc->w.hGCClipRgn, &rect ) == ERROR) return FALSE;
+    if (!PtVisible32( hdc, x, y )) return FALSE;
+    if (GetRgnBox32( dc->w.hGCClipRgn, &rect ) == ERROR) return FALSE;
 
     return CallTo32_LargeStack( (int(*)())GRAPH_DoFloodFill, 6,
                                 dc, &rect, x, y, color, fillType );
@@ -1060,11 +1199,20 @@ BOOL16 ExtFloodFill( HDC32 hdc, INT32 x, INT32 y, COLORREF color,
 
 
 /**********************************************************************
- *          FloodFill  (GDI.25) (GDI32.104)
+ *          FloodFill16   (GDI.25)
+ */
+BOOL16 FloodFill16( HDC16 hdc, INT16 x, INT16 y, COLORREF color )
+{
+    return ExtFloodFill32( hdc, x, y, color, FLOODFILLBORDER );
+}
+
+
+/**********************************************************************
+ *          FloodFill32   (GDI32.104)
  */
-BOOL16 FloodFill( HDC32 hdc, INT32 x, INT32 y, COLORREF color )
+BOOL32 FloodFill32( HDC32 hdc, INT32 x, INT32 y, COLORREF color )
 {
-    return ExtFloodFill( hdc, x, y, color, FLOODFILLBORDER );
+    return ExtFloodFill32( hdc, x, y, color, FLOODFILLBORDER );
 }
 
 
@@ -1088,7 +1236,7 @@ BOOL16 DrawEdge16( HDC16 hdc, LPRECT16 rc, UINT16 edge, UINT16 flags )
  */
 BOOL32 DrawEdge32( HDC32 hdc, LPRECT32 rc, UINT32 edge, UINT32 flags )
 {
-    HBRUSH16 hbrushOld;
+    HBRUSH32 hbrushOld;
 
     if (flags >= BF_DIAGONAL)
         fprintf( stderr, "DrawEdge: unsupported flags %04x\n", flags );
@@ -1099,7 +1247,7 @@ BOOL32 DrawEdge32( HDC32 hdc, LPRECT32 rc, UINT32 edge, UINT32 flags )
 
     /* First do all the raised edges */
 
-    SelectObject( hdc, sysColorObjects.hbrushBtnHighlight );
+    hbrushOld = SelectObject32( hdc, sysColorObjects.hbrushBtnHighlight );
     if (edge & BDR_RAISEDOUTER)
     {
         if (flags & BF_LEFT) PatBlt( hdc, rc->left, rc->top,
@@ -1131,7 +1279,7 @@ BOOL32 DrawEdge32( HDC32 hdc, LPRECT32 rc, UINT32 edge, UINT32 flags )
 
     /* Then do all the sunken edges */
 
-    hbrushOld = SelectObject( hdc, sysColorObjects.hbrushBtnShadow );
+    SelectObject32( hdc, sysColorObjects.hbrushBtnShadow );
     if (edge & BDR_SUNKENOUTER)
     {
         if (flags & BF_LEFT) PatBlt( hdc, rc->left, rc->top,
@@ -1161,7 +1309,7 @@ BOOL32 DrawEdge32( HDC32 hdc, LPRECT32 rc, UINT32 edge, UINT32 flags )
                                        rc->right - rc->left - 2, 1, PATCOPY );
     }
 
-    SelectObject( hdc, hbrushOld );
+    SelectObject32( hdc, hbrushOld );
     return TRUE;
 }
 
diff --git a/windows/hook.c b/windows/hook.c
index bf32483450c54aa3579563d84b7625c4b7fda1e1..dcc5fdfe3c3f5abe887201477127c348442a72b0 100644
--- a/windows/hook.c
+++ b/windows/hook.c
@@ -326,7 +326,7 @@ FARPROC16 SetWindowsHook16( INT16 id, HOOKPROC16 proc )
  */
 BOOL16 UnhookWindowsHook16( INT16 id, HOOKPROC16 proc )
 {
-    HANDLE16 hook = HOOK_GetHook( id , 0 );
+    HANDLE16 hook = HOOK_GetHook( id, GetTaskQueue(0) );
 
     dprintf_hook( stddeb, "UnhookWindowsHook: %d %08lx\n", id, (DWORD)proc );
 
@@ -380,7 +380,7 @@ HHOOK SetWindowsHookEx16( INT16 id, HOOKPROC16 proc, HINSTANCE16 hInst,
 
 
 /***********************************************************************
- *           UnhookWindowHookEx16   (USER.292)
+ *           UnhookWindowsHookEx16   (USER.292)
  */
 BOOL16 UnhookWindowsHookEx16( HHOOK hhook )
 {
diff --git a/windows/mdi.c b/windows/mdi.c
index 2e73cf4fd2aaa52e822fa5ee92d2e94ad648584c..1e6b45f2acbe63e0231fb3d26efa811d95592040 100644
--- a/windows/mdi.c
+++ b/windows/mdi.c
@@ -668,17 +668,17 @@ HBITMAP16 CreateMDIMenuBitmap(void)
  HBITMAP16	hbClose = LoadBitmap16(0, MAKEINTRESOURCE(OBM_CLOSE) );
  HBITMAP16	hbCopy,hb_src,hb_dest;
 
- hb_src = SelectObject(hDCSrc,hbClose);
+ hb_src = SelectObject32(hDCSrc,hbClose);
  hbCopy = CreateCompatibleBitmap(hDCSrc,SYSMETRICS_CXSIZE, SYSMETRICS_CYSIZE);
- hb_dest = SelectObject(hDCDest,hbCopy);
+ hb_dest = SelectObject32(hDCDest,hbCopy);
 
  BitBlt(hDCDest, 0, 0, SYSMETRICS_CXSIZE, SYSMETRICS_CYSIZE,
 	hDCSrc, SYSMETRICS_CXSIZE, 0, SRCCOPY);
  
- SelectObject(hDCSrc,hb_src);
- SelectObject(hDCDest,hb_dest);
+ SelectObject32(hDCSrc,hb_src);
+ SelectObject32(hDCDest,hb_dest);
 
- DeleteObject(hbClose);
+ DeleteObject32(hbClose);
 
  DeleteDC(hDCDest);
  DeleteDC(hDCSrc);
diff --git a/windows/nonclient.c b/windows/nonclient.c
index 0527dd62731d9f7d9ae7906c6a25ad4b4f37bd40..ec0c986dd7c9ec641f09189cf40ddf6c5bc9e90f 100644
--- a/windows/nonclient.c
+++ b/windows/nonclient.c
@@ -152,12 +152,11 @@ BOOL32 AdjustWindowRectEx32( LPRECT32 rect, DWORD style,
  *
  * Get the minimized and maximized information for a window.
  */
-void NC_GetMinMaxInfo( HWND hwnd, POINT16 *maxSize, POINT16 *maxPos,
+void NC_GetMinMaxInfo( WND *wndPtr, POINT16 *maxSize, POINT16 *maxPos,
                        POINT16 *minTrack, POINT16 *maxTrack )
 {
     MINMAXINFO16 *MinMax;
     short xinc, yinc;
-    WND *wndPtr = WIN_FindWndPtr( hwnd );
 
     if (!(MinMax = SEGPTR_NEW(MINMAXINFO16))) return;
 
@@ -204,7 +203,8 @@ void NC_GetMinMaxInfo( HWND hwnd, POINT16 *maxSize, POINT16 *maxPos,
         MinMax->ptMaxPosition.y = -yinc;
     }
 
-    SendMessage16( hwnd, WM_GETMINMAXINFO, 0, (LPARAM)SEGPTR_GET(MinMax) );
+    SendMessage16( wndPtr->hwndSelf, WM_GETMINMAXINFO, 0,
+                   (LPARAM)SEGPTR_GET(MinMax) );
 
       /* Some sanity checks */
 
@@ -299,7 +299,7 @@ static void NC_GetInsideRect( HWND hwnd, RECT16 *rect )
  *
  * Handle a WM_NCHITTEST message. Called from DefWindowProc().
  */
-LONG NC_HandleNCHitTest( HWND hwnd, POINT16 pt )
+LONG NC_HandleNCHitTest( HWND32 hwnd, POINT16 pt )
 {
     RECT16 rect;
     WND *wndPtr = WIN_FindWndPtr( hwnd );
@@ -442,11 +442,11 @@ void NC_DrawSysButton( HWND hwnd, HDC16 hdc, BOOL down )
     {
       NC_GetInsideRect( hwnd, &rect );
       hdcMem = CreateCompatibleDC( hdc );
-      hbitmap = SelectObject( hdcMem, hbitmapClose );
+      hbitmap = SelectObject32( hdcMem, hbitmapClose );
       BitBlt( hdc, rect.left, rect.top, SYSMETRICS_CXSIZE, SYSMETRICS_CYSIZE,
               hdcMem, (wndPtr->dwStyle & WS_CHILD) ? SYSMETRICS_CXSIZE : 0, 0,
               down ? NOTSRCCOPY : SRCCOPY );
-      SelectObject( hdcMem, hbitmap );
+      SelectObject32( hdcMem, hbitmap );
       DeleteDC( hdcMem );
     }
 }
@@ -505,15 +505,15 @@ static void NC_DrawFrame( HDC16 hdc, RECT16 *rect, BOOL dlgFrame, BOOL active )
     {
 	width = SYSMETRICS_CXDLGFRAME - 1;
 	height = SYSMETRICS_CYDLGFRAME - 1;
-        SelectObject( hdc, active ? sysColorObjects.hbrushActiveCaption :
-                                    sysColorObjects.hbrushInactiveCaption );
+        SelectObject32( hdc, active ? sysColorObjects.hbrushActiveCaption :
+                                      sysColorObjects.hbrushInactiveCaption );
     }
     else
     {
 	width = SYSMETRICS_CXFRAME - 1;
 	height = SYSMETRICS_CYFRAME - 1;
-        SelectObject( hdc, active ? sysColorObjects.hbrushActiveBorder :
-                                    sysColorObjects.hbrushInactiveBorder );
+        SelectObject32( hdc, active ? sysColorObjects.hbrushActiveBorder :
+                                      sysColorObjects.hbrushInactiveBorder );
     }
 
       /* Draw frame */
@@ -534,35 +534,35 @@ static void NC_DrawFrame( HDC16 hdc, RECT16 *rect, BOOL dlgFrame, BOOL active )
     
       /* Draw inner rectangle */
     MoveTo( hdc, rect->left+width, rect->top+height );
-    LineTo( hdc, rect->right-width-1, rect->top+height );
-    LineTo( hdc, rect->right-width-1, rect->bottom-height-1 );
-    LineTo( hdc, rect->left+width, rect->bottom-height-1 );
-    LineTo( hdc, rect->left+width, rect->top+height );
+    LineTo32( hdc, rect->right-width-1, rect->top+height );
+    LineTo32( hdc, rect->right-width-1, rect->bottom-height-1 );
+    LineTo32( hdc, rect->left+width, rect->bottom-height-1 );
+    LineTo32( hdc, rect->left+width, rect->top+height );
 
       /* Draw the decorations */
     tmp = rect->top + SYSMETRICS_CYFRAME + SYSMETRICS_CYSIZE;
     MoveTo( hdc, rect->left, tmp);
-    LineTo( hdc, rect->left+width, tmp );
+    LineTo32( hdc, rect->left+width, tmp );
     MoveTo( hdc, rect->right-width-1, tmp );
-    LineTo( hdc, rect->right-1, tmp );
+    LineTo32( hdc, rect->right-1, tmp );
 
     tmp = rect->bottom - 1 - SYSMETRICS_CYFRAME - SYSMETRICS_CYSIZE;
     MoveTo( hdc, rect->left, tmp );
-    LineTo( hdc, rect->left+width, tmp );
+    LineTo32( hdc, rect->left+width, tmp );
     MoveTo( hdc, rect->right-width-1, tmp );
-    LineTo( hdc, rect->right-1, tmp );
+    LineTo32( hdc, rect->right-1, tmp );
 
     tmp = rect->left + SYSMETRICS_CXFRAME + SYSMETRICS_CXSIZE;
     MoveTo( hdc, tmp, rect->top );
-    LineTo( hdc, tmp, rect->top+height );
+    LineTo32( hdc, tmp, rect->top+height );
     MoveTo( hdc, tmp, rect->bottom-height-1 );
-    LineTo( hdc, tmp, rect->bottom-1 );
+    LineTo32( hdc, tmp, rect->bottom-1 );
 
     tmp = rect->right - 1 - SYSMETRICS_CXFRAME - SYSMETRICS_CYSIZE;
     MoveTo( hdc, tmp, rect->top );
-    LineTo( hdc, tmp, rect->top+height );
+    LineTo32( hdc, tmp, rect->top+height );
     MoveTo( hdc, tmp, rect->bottom-height-1 );
-    LineTo( hdc, tmp, rect->bottom-1 );
+    LineTo32( hdc, tmp, rect->bottom-1 );
 
     InflateRect16( rect, -width-1, -height-1 );
 }
@@ -577,7 +577,7 @@ static void NC_DrawMovingFrame( HDC16 hdc, RECT16 *rect, BOOL thickframe )
 {
     if (thickframe)
     {
-	SelectObject( hdc, GetStockObject( GRAY_BRUSH ) );
+	SelectObject32( hdc, GetStockObject32( GRAY_BRUSH ) );
 	PatBlt( hdc, rect->left, rect->top,
 	        rect->right - rect->left - SYSMETRICS_CXFRAME,
 	        SYSMETRICS_CYFRAME, PATINVERT );
@@ -623,24 +623,24 @@ static void NC_DrawCaption( HDC16 hdc, RECT16 *rect, HWND hwnd,
     
     if (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME)
     {
-	HBRUSH16 hbrushOld = SelectObject( hdc, sysColorObjects.hbrushWindow );
+	HBRUSH32 hbrushOld = SelectObject32(hdc, sysColorObjects.hbrushWindow);
 	PatBlt( hdc, r.left, r.top, 1, r.bottom-r.top+1,PATCOPY );
 	PatBlt( hdc, r.right-1, r.top, 1, r.bottom-r.top+1, PATCOPY );
 	PatBlt( hdc, r.left, r.top-1, r.right-r.left, 1, PATCOPY );
 	r.left++;
 	r.right--;
-	SelectObject( hdc, hbrushOld );
+	SelectObject32( hdc, hbrushOld );
     }
 
     MoveTo( hdc, r.left, r.bottom );
-    LineTo( hdc, r.right-1, r.bottom );
+    LineTo32( hdc, r.right-1, r.bottom );
 
     if (style & WS_SYSMENU)
     {
 	NC_DrawSysButton( hwnd, hdc, FALSE );
 	r.left += SYSMETRICS_CXSIZE + 1;
 	MoveTo( hdc, r.left - 1, r.top );
-	LineTo( hdc, r.left - 1, r.bottom );
+	LineTo32( hdc, r.left - 1, r.bottom );
     }
     if (style & WS_MAXIMIZEBOX)
     {
@@ -672,11 +672,11 @@ static void NC_DrawCaption( HDC16 hdc, RECT16 *rect, HWND hwnd,
  *
  * Paint the non-client area. clip is currently unused.
  */
-void NC_DoNCPaint( HWND hwnd, HRGN32 clip, BOOL suppress_menupaint )
+void NC_DoNCPaint( HWND32 hwnd, HRGN32 clip, BOOL32 suppress_menupaint )
 {
     HDC32 hdc;
     RECT16 rect;
-    BOOL	active;
+    BOOL32 active;
 
     WND *wndPtr = WIN_FindWndPtr( hwnd );
 
@@ -703,7 +703,7 @@ void NC_DoNCPaint( HWND hwnd, HRGN32 clip, BOOL suppress_menupaint )
     rect.right  = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
     rect.bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
 
-    SelectObject( hdc, sysColorObjects.hpenWindowFrame );
+    SelectObject32( hdc, sysColorObjects.hpenWindowFrame );
 
     if (!(wndPtr->flags & WIN_MANAGED))
     {
@@ -711,10 +711,10 @@ void NC_DoNCPaint( HWND hwnd, HRGN32 clip, BOOL suppress_menupaint )
             (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME))
         {
             MoveTo( hdc, 0, 0 );
-            LineTo( hdc, rect.right-1, 0 );
-            LineTo( hdc, rect.right-1, rect.bottom-1 );
-            LineTo( hdc, 0, rect.bottom-1 );
-            LineTo( hdc, 0, 0 );
+            LineTo32( hdc, rect.right-1, 0 );
+            LineTo32( hdc, rect.right-1, rect.bottom-1 );
+            LineTo32( hdc, 0, rect.bottom-1 );
+            LineTo32( hdc, 0, 0 );
             InflateRect16( &rect, -1, -1 );
         }
 
@@ -766,7 +766,7 @@ void NC_DoNCPaint( HWND hwnd, HRGN32 clip, BOOL suppress_menupaint )
  *
  * Handle a WM_NCPAINT message. Called from DefWindowProc().
  */
-LONG NC_HandleNCPaint( HWND hwnd , HRGN32 clip)
+LONG NC_HandleNCPaint( HWND32 hwnd , HRGN32 clip)
 {
     NC_DoNCPaint( hwnd, clip, FALSE );
     return 0;
@@ -804,9 +804,9 @@ LONG NC_HandleNCActivate( WND *wndPtr, WPARAM16 wParam )
  *
  * Handle a WM_SETCURSOR message. Called from DefWindowProc().
  */
-LONG NC_HandleSetCursor( HWND hwnd, WPARAM16 wParam, LPARAM lParam )
+LONG NC_HandleSetCursor( HWND32 hwnd, WPARAM16 wParam, LPARAM lParam )
 {
-    if (hwnd != (HWND)wParam) return 0;  /* Don't set the cursor for child windows */
+    if (hwnd != (HWND32)wParam) return 0;  /* Don't set the cursor for child windows */
 
     switch(LOWORD(lParam))
     {
@@ -1029,7 +1029,7 @@ static void NC_DoSizeMove( HWND hwnd, WORD wParam, POINT16 pt )
 
       /* Get min/max info */
 
-    NC_GetMinMaxInfo( hwnd, NULL, NULL, &minTrack, &maxTrack );
+    NC_GetMinMaxInfo( wndPtr, NULL, NULL, &minTrack, &maxTrack );
     sizingRect = wndPtr->rectWindow;
     if (wndPtr->dwStyle & WS_CHILD)
 	GetClientRect16( wndPtr->parent->hwndSelf, &mouseRect );
@@ -1278,7 +1278,7 @@ static void NC_TrackScrollBar( HWND32 hwnd, WPARAM32 wParam, POINT32 pt )
  *
  * Handle a WM_NCLBUTTONDOWN message. Called from DefWindowProc().
  */
-LONG NC_HandleNCLButtonDown( HWND hwnd, WPARAM16 wParam, LPARAM lParam )
+LONG NC_HandleNCLButtonDown( HWND32 hwnd, WPARAM16 wParam, LPARAM lParam )
 {
     HDC32 hdc;
 
@@ -1370,7 +1370,7 @@ LONG NC_HandleNCLButtonDblClk( WND *pWnd, WPARAM16 wParam, LPARAM lParam )
  *
  * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
  */
-LONG NC_HandleSysCommand( HWND hwnd, WPARAM16 wParam, POINT16 pt )
+LONG NC_HandleSysCommand( HWND32 hwnd, WPARAM16 wParam, POINT16 pt )
 {
     WND *wndPtr = WIN_FindWndPtr( hwnd );
     POINT32 pt32;
diff --git a/windows/painting.c b/windows/painting.c
index bce51e0ee5cbfc35f8aade279473261eb5880b97..3edfe8a3165e5af7f44cae04f66b694767f01057 100644
--- a/windows/painting.c
+++ b/windows/painting.c
@@ -41,29 +41,30 @@ void WIN_UpdateNCArea(WND* wnd, BOOL bUpdate)
     {
 	ClientToScreen16(wnd->hwndSelf, &pt);
 
-        hClip = CreateRectRgn( 0, 0, 0, 0 );
-        if (!CombineRgn(hClip, wnd->hrgnUpdate, 0, RGN_COPY) )
+        hClip = CreateRectRgn32( 0, 0, 0, 0 );
+        if (!CombineRgn32( hClip, wnd->hrgnUpdate, 0, RGN_COPY ))
         {
-            DeleteObject(hClip);
+            DeleteObject32(hClip);
             hClip = 1;
         }
 	else
-	    OffsetRgn(hClip, pt.x, pt.y);
+	    OffsetRgn32( hClip, pt.x, pt.y );
 
         if (bUpdate)
         {
 	    /* exclude non-client area from update region */
-            HRGN32 hrgn = CreateRectRgn(0, 0, wnd->rectClient.right - wnd->rectClient.left,
-					    wnd->rectClient.bottom - wnd->rectClient.top);
+            HRGN32 hrgn = CreateRectRgn32( 0, 0,
+                                 wnd->rectClient.right - wnd->rectClient.left,
+                                 wnd->rectClient.bottom - wnd->rectClient.top);
 
-            if (hrgn && (CombineRgn(wnd->hrgnUpdate, wnd->hrgnUpdate,
-                                    hrgn, RGN_AND) == NULLREGION))
+            if (hrgn && (CombineRgn32( wnd->hrgnUpdate, wnd->hrgnUpdate,
+                                       hrgn, RGN_AND) == NULLREGION))
             {
-                DeleteObject(wnd->hrgnUpdate);
+                DeleteObject32( wnd->hrgnUpdate );
                 wnd->hrgnUpdate = 1;
             }
 
-            DeleteObject( hrgn );
+            DeleteObject32( hrgn );
         }
     }
 
@@ -73,13 +74,13 @@ void WIN_UpdateNCArea(WND* wnd, BOOL bUpdate)
         !(wnd->flags & WIN_NCACTIVATED))
     {
         wnd->flags |= WIN_NCACTIVATED;
-        if( hClip > 1) DeleteObject(hClip);
+        if( hClip > 1) DeleteObject32( hClip );
         hClip = 1;
     }
 
     if (hClip) SendMessage16( wnd->hwndSelf, WM_NCPAINT, hClip, 0L );
 
-    if (hClip > 1) DeleteObject( hClip );
+    if (hClip > 1) DeleteObject32( hClip );
 }
 
 
@@ -280,8 +281,9 @@ BOOL32 PAINT_RedrawWindow( HWND32 hwnd, const RECT32 *rectUpdate,
             if ((hrgn = hrgnUpdate) == 0)
                 hrgn = CreateRectRgnIndirect32( rectUpdate ? rectUpdate :
                                                 &rectClient );
-            rgnNotEmpty = CombineRgn( wndPtr->hrgnUpdate, wndPtr->hrgnUpdate, hrgn, RGN_OR );
-            if (!hrgnUpdate) DeleteObject( hrgn );
+            rgnNotEmpty = CombineRgn32( wndPtr->hrgnUpdate, wndPtr->hrgnUpdate,
+                                        hrgn, RGN_OR );
+            if (!hrgnUpdate) DeleteObject32( hrgn );
         }
         else  /* No update region yet */
         {
@@ -289,8 +291,9 @@ BOOL32 PAINT_RedrawWindow( HWND32 hwnd, const RECT32 *rectUpdate,
                 QUEUE_IncPaintCount( wndPtr->hmemTaskQ );
             if (hrgnUpdate)
             {
-                wndPtr->hrgnUpdate = CreateRectRgn( 0, 0, 0, 0 );
-                rgnNotEmpty = CombineRgn( wndPtr->hrgnUpdate, hrgnUpdate, 0, RGN_COPY );
+                wndPtr->hrgnUpdate = CreateRectRgn32( 0, 0, 0, 0 );
+                rgnNotEmpty = CombineRgn32( wndPtr->hrgnUpdate, hrgnUpdate,
+                                            0, RGN_COPY );
             }
             else wndPtr->hrgnUpdate = CreateRectRgnIndirect32( rectUpdate ?
                                                     rectUpdate : &rectClient );
@@ -302,7 +305,7 @@ BOOL32 PAINT_RedrawWindow( HWND32 hwnd, const RECT32 *rectUpdate,
 	if ( rgnNotEmpty == NULLREGION )
 	   {
 	     wndPtr->flags &= ~WIN_NEEDS_ERASEBKGND;
-	     DeleteObject(wndPtr->hrgnUpdate);
+	     DeleteObject32( wndPtr->hrgnUpdate );
 	     wndPtr->hrgnUpdate=0;
              if (!(wndPtr->flags & WIN_INTERNAL_PAINT))
                    QUEUE_DecPaintCount( wndPtr->hmemTaskQ );
@@ -319,20 +322,20 @@ BOOL32 PAINT_RedrawWindow( HWND32 hwnd, const RECT32 *rectUpdate,
             if (!hrgnUpdate && !rectUpdate)
             {
                   /* Special case: validate everything */
-                DeleteObject( wndPtr->hrgnUpdate );
+                DeleteObject32( wndPtr->hrgnUpdate );
                 wndPtr->hrgnUpdate = 0;
             }
             else
             {
                 if ((hrgn = hrgnUpdate) == 0)
                     hrgn = CreateRectRgnIndirect32( rectUpdate );
-                if (CombineRgn( wndPtr->hrgnUpdate, wndPtr->hrgnUpdate,
-                                hrgn, RGN_DIFF ) == NULLREGION)
+                if (CombineRgn32( wndPtr->hrgnUpdate, wndPtr->hrgnUpdate,
+                                  hrgn, RGN_DIFF ) == NULLREGION)
                 {
-                    DeleteObject( wndPtr->hrgnUpdate );
+                    DeleteObject32( wndPtr->hrgnUpdate );
                     wndPtr->hrgnUpdate = 0;
                 }
-                if (!hrgnUpdate) DeleteObject( hrgn );
+                if (!hrgnUpdate) DeleteObject32( hrgn );
             }
             if (!wndPtr->hrgnUpdate)  /* No more update region */
 		if (!(wndPtr->flags & WIN_INTERNAL_PAINT))
@@ -394,13 +397,13 @@ BOOL32 PAINT_RedrawWindow( HWND32 hwnd, const RECT32 *rectUpdate,
     {
         if ( hrgnUpdate || rectUpdate )
 	{
-	   if( !(hrgn = CreateRectRgn( 0, 0, 0, 0 )) ) return TRUE;
+	   if (!(hrgn = CreateRectRgn32( 0, 0, 0, 0 ))) return TRUE;
 	   if( !hrgnUpdate )
 	     {
 	        control |= (RDW_C_DELETEHRGN | RDW_C_USEHRGN);
  	        if( !(hrgnUpdate = CreateRectRgnIndirect32( rectUpdate )) )
                 {
-                    DeleteObject( hrgn );
+                    DeleteObject32( hrgn );
                     return TRUE;
                 }
 	     }
@@ -409,7 +412,7 @@ BOOL32 PAINT_RedrawWindow( HWND32 hwnd, const RECT32 *rectUpdate,
 	       {
                    if (wndPtr->class->style & CS_PARENTDC)
                    {
-                       if (!CombineRgn( hrgn, hrgnUpdate, 0, RGN_COPY ))
+                       if (!CombineRgn32( hrgn, hrgnUpdate, 0, RGN_COPY ))
                            continue;
                    }
                    else
@@ -417,22 +420,16 @@ BOOL32 PAINT_RedrawWindow( HWND32 hwnd, const RECT32 *rectUpdate,
                        SetRectRgn( hrgn, wndPtr->rectWindow.left,
                                    wndPtr->rectWindow.top,
                                    wndPtr->rectWindow.right,
-                                   wndPtr->rectWindow.bottom);
-                       if (!CombineRgn( hrgn, hrgn, hrgnUpdate, RGN_AND ))
+                                   wndPtr->rectWindow.bottom );
+                       if (!CombineRgn32( hrgn, hrgn, hrgnUpdate, RGN_AND ))
                            continue;
                    }
-#if 0
-                   if( control & RDW_C_USEHRGN &&
-                       wndPtr->dwStyle & WS_CLIPSIBLINGS ) 
-                       CombineRgn( hrgnUpdate, hrgnUpdate, hrgn, RGN_DIFF );
-#endif
-
-                   OffsetRgn( hrgn, -wndPtr->rectClient.left,
-                                 -wndPtr->rectClient.top );
+                   OffsetRgn32( hrgn, -wndPtr->rectClient.left,
+                                      -wndPtr->rectClient.top );
                    PAINT_RedrawWindow( wndPtr->hwndSelf, NULL, hrgn, flags, RDW_C_USEHRGN );
                }
-	   DeleteObject( hrgn );
-	   if( control & RDW_C_DELETEHRGN ) DeleteObject( hrgnUpdate );
+	   DeleteObject32( hrgn );
+	   if (control & RDW_C_DELETEHRGN) DeleteObject32( hrgnUpdate );
 	}
 	else for (wndPtr = wndPtr->child; wndPtr; wndPtr = wndPtr->next)
 		  PAINT_RedrawWindow( wndPtr->hwndSelf, NULL, 0, flags, 0 );
@@ -564,10 +561,10 @@ BOOL32 GetUpdateRect32( HWND32 hwnd, LPRECT32 rect, BOOL32 erase )
     {
 	if (wndPtr->hrgnUpdate > 1)
 	{
-	    HRGN32 hrgn = CreateRectRgn( 0, 0, 0, 0 );
+	    HRGN32 hrgn = CreateRectRgn32( 0, 0, 0, 0 );
 	    if (GetUpdateRgn( hwnd, hrgn, erase ) == ERROR) return FALSE;
 	    GetRgnBox32( hrgn, rect );
-	    DeleteObject( hrgn );
+	    DeleteObject32( hrgn );
 	}
 	else SetRectEmpty32( rect );
     }
@@ -580,7 +577,7 @@ BOOL32 GetUpdateRect32( HWND32 hwnd, LPRECT32 rect, BOOL32 erase )
  */
 INT16 GetUpdateRgn( HWND32 hwnd, HRGN32 hrgn, BOOL32 erase )
 {
-    INT16 retval;
+    INT32 retval;
     WND * wndPtr = WIN_FindWndPtr( hwnd );
     if (!wndPtr) return ERROR;
 
@@ -589,7 +586,7 @@ INT16 GetUpdateRgn( HWND32 hwnd, HRGN32 hrgn, BOOL32 erase )
         SetRectRgn( hrgn, 0, 0, 0, 0 );
         return NULLREGION;
     }
-    retval = CombineRgn( hrgn, wndPtr->hrgnUpdate, 0, RGN_COPY );
+    retval = CombineRgn32( hrgn, wndPtr->hrgnUpdate, 0, RGN_COPY );
     if (erase) RedrawWindow32( hwnd, NULL, 0, RDW_ERASENOW | RDW_NOCHILDREN );
     return retval;
 }
@@ -600,18 +597,18 @@ INT16 GetUpdateRgn( HWND32 hwnd, HRGN32 hrgn, BOOL32 erase )
  */
 INT16 ExcludeUpdateRgn( HDC32 hdc, HWND32 hwnd )
 {
-    INT16 retval = ERROR;
+    INT32 retval = ERROR;
     HRGN32 hrgn;
     WND * wndPtr;
 
     if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return ERROR;
-    if ((hrgn = CreateRectRgn( 0, 0, 0, 0 )) != 0)
+    if ((hrgn = CreateRectRgn32( 0, 0, 0, 0 )) != 0)
     {
-	retval = CombineRgn( hrgn, InquireVisRgn(hdc),
-			     (wndPtr->hrgnUpdate>1)?wndPtr->hrgnUpdate:0,
-			     (wndPtr->hrgnUpdate>1)?RGN_DIFF:RGN_COPY);
+	retval = CombineRgn32( hrgn, InquireVisRgn(hdc),
+			       (wndPtr->hrgnUpdate>1) ? wndPtr->hrgnUpdate : 0,
+			       (wndPtr->hrgnUpdate>1) ? RGN_DIFF : RGN_COPY );
 	if (retval) SelectVisRgn( hdc, hrgn );
-	DeleteObject( hrgn );
+	DeleteObject32( hrgn );
     }
     return retval;
 }
diff --git a/windows/scroll.c b/windows/scroll.c
index d06015f0ac919ac63588397ac6ce3f086a6690bd..b26ba1503845f45e2839829f783d7b2e493163d5 100644
--- a/windows/scroll.c
+++ b/windows/scroll.c
@@ -53,7 +53,7 @@ void ScrollWindow(HWND hwnd, short dx, short dy, LPRECT16 rect, LPRECT16 clipRec
           else hCaretWnd = 0;
  
 	  hdc = GetDCEx32(hwnd, hrgnClip, DCX_CACHE | DCX_CLIPSIBLINGS);
-          DeleteObject(hrgnClip);
+          DeleteObject32( hrgnClip );
        }
     else	/* clip children */
        {
@@ -71,7 +71,7 @@ void ScrollWindow(HWND hwnd, short dx, short dy, LPRECT16 rect, LPRECT16 clipRec
     else
 	CopyRect16(&cliprc, clipRect);
 
-    hrgnUpdate = CreateRectRgn(0, 0, 0, 0);
+    hrgnUpdate = CreateRectRgn32( 0, 0, 0, 0 );
     ScrollDC(hdc, dx, dy, &rc, &cliprc, hrgnUpdate, NULL);
     ReleaseDC32(hwnd, hdc);
 
@@ -80,7 +80,7 @@ void ScrollWindow(HWND hwnd, short dx, short dy, LPRECT16 rect, LPRECT16 clipRec
       WND*	wndPtr;
 
       if( wndScroll->hrgnUpdate > 1 )
-	OffsetRgn( wndScroll->hrgnUpdate, dx, dy );
+	OffsetRgn32( wndScroll->hrgnUpdate, dx, dy );
 
       for (wndPtr = wndScroll->child; wndPtr; wndPtr = wndPtr->next)
         SetWindowPos(wndPtr->hwndSelf, 0, wndPtr->rectWindow.left + dx,
@@ -92,7 +92,7 @@ void ScrollWindow(HWND hwnd, short dx, short dy, LPRECT16 rect, LPRECT16 clipRec
     PAINT_RedrawWindow( hwnd, NULL, hrgnUpdate, RDW_ALLCHILDREN |
 			    RDW_INVALIDATE | RDW_ERASE | RDW_ERASENOW, RDW_C_USEHRGN );
 
-    DeleteObject(hrgnUpdate);
+    DeleteObject32( hrgnUpdate );
     if( hCaretWnd ) ShowCaret(hCaretWnd);
 }
 
@@ -135,13 +135,14 @@ BOOL ScrollDC(HDC16 hdc, short dx, short dy, LPRECT16 rc, LPRECT16 cliprc,
       {
         /* save a copy and change cliprgn directly */
 
-        CombineRgn( hrgnScrollClip, hrgnClip, 0, RGN_COPY );
-        SetRectRgn( hrgnClip, rectClip.left, rectClip.top, rectClip.right, rectClip.bottom );
+        CombineRgn32( hrgnScrollClip, hrgnClip, 0, RGN_COPY );
+        SetRectRgn( hrgnClip, rectClip.left, rectClip.top,
+                    rectClip.right, rectClip.bottom );
 
 	CLIPPING_UpdateGCRegion( dc );
       }
     else
-        SelectClipRgn( hdc, hrgnScrollClip );
+        SelectClipRgn16( hdc, hrgnScrollClip );
 
     /* translate coordinates */
 
@@ -179,15 +180,18 @@ BOOL ScrollDC(HDC16 hdc, short dx, short dy, LPRECT16 rc, LPRECT16 cliprc,
 
     if (hrgnUpdate || rcUpdate)
     {
-	HRGN32 hrgn1 = (hrgnUpdate)?hrgnUpdate:CreateRectRgn( 0,0,0,0 );
+	HRGN32 hrgn1 = (hrgnUpdate) ? hrgnUpdate : CreateRectRgn32( 0,0,0,0 );
 
 	if( dc->w.hVisRgn )
 	{
-	  CombineRgn( hrgn1, dc->w.hVisRgn, 0, RGN_COPY);
-	  CombineRgn( hrgn1, hrgn1, (hrgnClip)?hrgnClip:hrgnScrollClip, RGN_AND);
-	  OffsetRgn( hrgn1, dx, dy );
-	  CombineRgn( hrgn1, dc->w.hVisRgn, hrgn1, RGN_DIFF);
-	  RgnType = CombineRgn( hrgn1, hrgn1, (hrgnClip)?hrgnClip:hrgnScrollClip, RGN_AND);
+	  CombineRgn32( hrgn1, dc->w.hVisRgn, 0, RGN_COPY );
+	  CombineRgn32( hrgn1, hrgn1, hrgnClip ? hrgnClip : hrgnScrollClip,
+                        RGN_AND );
+	  OffsetRgn32( hrgn1, dx, dy );
+	  CombineRgn32( hrgn1, dc->w.hVisRgn, hrgn1, RGN_DIFF );
+	  RgnType = CombineRgn32( hrgn1, hrgn1,
+                                  hrgnClip ? hrgnClip : hrgnScrollClip,
+                                  RGN_AND );
 	}
 	else
 	{
@@ -208,13 +212,13 @@ BOOL ScrollDC(HDC16 hdc, short dx, short dy, LPRECT16 rc, LPRECT16 cliprc,
 	}
 
 	if (rcUpdate) GetRgnBox16( hrgn1, rcUpdate );
-	if (!hrgnUpdate) DeleteObject( hrgn1 );
+	if (!hrgnUpdate) DeleteObject32( hrgn1 );
     }
 
     /* restore clipping region */
 
-    SelectClipRgn( hdc, (hrgnClip)?hrgnScrollClip:0 );
-    DeleteObject( hrgnScrollClip );     
+    SelectClipRgn32( hdc, hrgnClip ? hrgnScrollClip : 0 );
+    DeleteObject32( hrgnScrollClip );     
 
     return TRUE;
 }
diff --git a/windows/syscolor.c b/windows/syscolor.c
index 11f1ccdb443afc12b55998a80386586d810f7a00..7441be1631710725a9f58baee31d6eb5780d6a0c 100644
--- a/windows/syscolor.c
+++ b/windows/syscolor.c
@@ -57,70 +57,70 @@ static void SYSCOLOR_SetColor( int index, COLORREF color )
     switch(index)
     {
     case COLOR_SCROLLBAR:
-	DeleteObject( sysColorObjects.hbrushScrollbar );
-	sysColorObjects.hbrushScrollbar = CreateSolidBrush( color );
+	DeleteObject32( sysColorObjects.hbrushScrollbar );
+	sysColorObjects.hbrushScrollbar = CreateSolidBrush32( color );
 	break;
     case COLOR_BACKGROUND:
 	break;
     case COLOR_ACTIVECAPTION:
-	DeleteObject( sysColorObjects.hbrushActiveCaption );
-	sysColorObjects.hbrushActiveCaption = CreateSolidBrush( color );
+	DeleteObject32( sysColorObjects.hbrushActiveCaption );
+	sysColorObjects.hbrushActiveCaption = CreateSolidBrush32( color );
 	break;
     case COLOR_INACTIVECAPTION:
-	DeleteObject( sysColorObjects.hbrushInactiveCaption );
-	sysColorObjects.hbrushInactiveCaption = CreateSolidBrush( color );
+	DeleteObject32( sysColorObjects.hbrushInactiveCaption );
+	sysColorObjects.hbrushInactiveCaption = CreateSolidBrush32( color );
 	break;
     case COLOR_MENU:
-	DeleteObject( sysColorObjects.hbrushMenu );
-	sysColorObjects.hbrushMenu = CreateSolidBrush( MAKE_SOLID(color) );
+	DeleteObject32( sysColorObjects.hbrushMenu );
+	sysColorObjects.hbrushMenu = CreateSolidBrush32( MAKE_SOLID(color) );
 	break;
     case COLOR_WINDOW:
-	DeleteObject( sysColorObjects.hbrushWindow );
-	sysColorObjects.hbrushWindow = CreateSolidBrush( color );
+	DeleteObject32( sysColorObjects.hbrushWindow );
+	sysColorObjects.hbrushWindow = CreateSolidBrush32( color );
 	break;
     case COLOR_WINDOWFRAME:
-	DeleteObject( sysColorObjects.hpenWindowFrame );
-	sysColorObjects.hpenWindowFrame = CreatePen( PS_SOLID, 1, color );
+	DeleteObject32( sysColorObjects.hpenWindowFrame );
+	sysColorObjects.hpenWindowFrame = CreatePen32( PS_SOLID, 1, color );
 	break;
     case COLOR_MENUTEXT:
 	break;
     case COLOR_WINDOWTEXT:
-	DeleteObject( sysColorObjects.hpenWindowText );
-	sysColorObjects.hpenWindowText = CreatePen( PS_DOT, 1, color );
+	DeleteObject32( sysColorObjects.hpenWindowText );
+	sysColorObjects.hpenWindowText = CreatePen32( PS_DOT, 1, color );
 	break;
     case COLOR_CAPTIONTEXT:
 	break;
     case COLOR_ACTIVEBORDER:
-	DeleteObject( sysColorObjects.hbrushActiveBorder );
-	sysColorObjects.hbrushActiveBorder = CreateSolidBrush( color );
+	DeleteObject32( sysColorObjects.hbrushActiveBorder );
+	sysColorObjects.hbrushActiveBorder = CreateSolidBrush32( color );
 	break;
     case COLOR_INACTIVEBORDER:
-	DeleteObject( sysColorObjects.hbrushInactiveBorder );
-	sysColorObjects.hbrushInactiveBorder = CreateSolidBrush( color );
+	DeleteObject32( sysColorObjects.hbrushInactiveBorder );
+	sysColorObjects.hbrushInactiveBorder = CreateSolidBrush32( color );
 	break;
     case COLOR_APPWORKSPACE:
 	break;
     case COLOR_HIGHLIGHT:
-	DeleteObject( sysColorObjects.hbrushHighlight );
-	sysColorObjects.hbrushHighlight = CreateSolidBrush( MAKE_SOLID(color));
+	DeleteObject32( sysColorObjects.hbrushHighlight );
+	sysColorObjects.hbrushHighlight = CreateSolidBrush32(MAKE_SOLID(color));
 	break;
     case COLOR_HIGHLIGHTTEXT:
 	break;
     case COLOR_BTNFACE:
-	DeleteObject( sysColorObjects.hbrushBtnFace );
-	sysColorObjects.hbrushBtnFace = CreateSolidBrush( color );
+	DeleteObject32( sysColorObjects.hbrushBtnFace );
+	sysColorObjects.hbrushBtnFace = CreateSolidBrush32( color );
 	break;
     case COLOR_BTNSHADOW:
-	DeleteObject( sysColorObjects.hbrushBtnShadow );
-	sysColorObjects.hbrushBtnShadow = CreateSolidBrush( color );
+	DeleteObject32( sysColorObjects.hbrushBtnShadow );
+	sysColorObjects.hbrushBtnShadow = CreateSolidBrush32( color );
 	break;
     case COLOR_GRAYTEXT:
     case COLOR_BTNTEXT:
     case COLOR_INACTIVECAPTIONTEXT:
 	break;
     case COLOR_BTNHIGHLIGHT:
-	DeleteObject( sysColorObjects.hbrushBtnHighlight );
-	sysColorObjects.hbrushBtnHighlight = CreateSolidBrush( color );
+	DeleteObject32( sysColorObjects.hbrushBtnHighlight );
+	sysColorObjects.hbrushBtnHighlight = CreateSolidBrush32( color );
 	break;
     }
 }
diff --git a/windows/win.c b/windows/win.c
index 4b8e12e2c0f6624c574b33ccdb89fbd5305a1c24..02216273b4ff86dd032b62b74e44923f94662dc9 100644
--- a/windows/win.c
+++ b/windows/win.c
@@ -342,7 +342,7 @@ static void WIN_DestroyWindow( WND* wndPtr )
 
     if ((wndPtr->hrgnUpdate) || (wndPtr->flags & WIN_INTERNAL_PAINT))
     {
-        if (wndPtr->hrgnUpdate) DeleteObject( wndPtr->hrgnUpdate );
+        if (wndPtr->hrgnUpdate) DeleteObject32( wndPtr->hrgnUpdate );
         QUEUE_DecPaintCount( wndPtr->hmemTaskQ );
     }
 
@@ -637,7 +637,7 @@ static HWND WIN_CreateWindowEx( CREATESTRUCT32A *cs, ATOM classAtom,
 
     if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
     {
-        NC_GetMinMaxInfo( hwnd, &maxSize, &maxPos, &minTrack, &maxTrack );
+        NC_GetMinMaxInfo( wndPtr, &maxSize, &maxPos, &minTrack, &maxTrack );
         if (maxSize.x < cs->cx) cs->cx = maxSize.x;
         if (maxSize.y < cs->cy) cs->cy = maxSize.y;
         if (cs->cx < minTrack.x ) cs->cx = minTrack.x;
@@ -802,7 +802,7 @@ static HWND WIN_CreateWindowEx( CREATESTRUCT32A *cs, ATOM classAtom,
 	/* MinMaximize(hwnd, SW_SHOWMAXIMIZED, 1) */
 
         POINT16 maxSize, maxPos, minTrack, maxTrack;
-        NC_GetMinMaxInfo( hwnd, &maxSize, &maxPos, &minTrack, &maxTrack );
+        NC_GetMinMaxInfo( wndPtr, &maxSize, &maxPos, &minTrack, &maxTrack );
         SetWindowPos( hwnd, 0, maxPos.x, maxPos.y, maxSize.x, maxSize.y,
             ((GetActiveWindow())? SWP_NOACTIVATE : 0) | SWP_FRAMECHANGED );
     }
diff --git a/windows/winpos.c b/windows/winpos.c
index 407e824c0328f91ee15fd9917b296fc28a2c5121..7d0dd30ba53b95b0cd72c2fc598d1c628ed8cb52 100644
--- a/windows/winpos.c
+++ b/windows/winpos.c
@@ -621,7 +621,7 @@ BOOL ShowWindow( HWND hwnd, int cmd )
                 if (!(wndPtr->dwStyle & WS_MINIMIZE))
                     wndPtr->rectNormal = wndPtr->rectWindow; 
 
-                NC_GetMinMaxInfo( hwnd, &maxSize,
+                NC_GetMinMaxInfo( wndPtr, &maxSize,
                                   &wndPtr->ptMaxPos, NULL, NULL );
                 x  = wndPtr->ptMaxPos.x;
                 y  = wndPtr->ptMaxPos.y;
@@ -674,7 +674,7 @@ BOOL ShowWindow( HWND hwnd, int cmd )
                 if (wndPtr->flags & WIN_RESTORE_MAX)
                 {
                     /* Restore to maximized position */
-                    NC_GetMinMaxInfo( hwnd, &maxSize, &wndPtr->ptMaxPos,
+                    NC_GetMinMaxInfo( wndPtr, &maxSize, &wndPtr->ptMaxPos,
                                       NULL, NULL );
                     x  = wndPtr->ptMaxPos.x;
                     y  = wndPtr->ptMaxPos.y;
@@ -891,44 +891,35 @@ BOOL32 SetWindowPlacement32( HWND32 hwnd, const WINDOWPLACEMENT32 *wndpl )
     return TRUE;
 }
 
+
 /***********************************************************************
  *           WINPOS_ForceXWindowRaise
+ *
+ * Raise a window on top of the X stacking order, while preserving 
+ * the correct Windows Z order.
  */
-void WINPOS_ForceXWindowRaise( WND* pWnd )
+static void WINPOS_ForceXWindowRaise( WND* pWnd )
 {
     XWindowChanges winChanges;
-    WND *wndStop, *wndLast;
-
-    if (!pWnd->window) return;
+    WND *wndPrev;
 
-    wndLast = wndStop = pWnd;
-    winChanges.stack_mode = Above;
-    XReconfigureWMWindow( display, pWnd->window, 0, CWStackMode, &winChanges );
-
-    /* Recursively raise owned popups according to their z-order
+    /* Raise all windows up to pWnd according to their Z order.
      * (it would be easier with sibling-related Below but it doesn't
      * work very well with SGI mwm for instance)
      */
-    while (wndLast)
+    winChanges.stack_mode = Above;
+    while (pWnd)
     {
-        WND *wnd = WIN_GetDesktop()->child;
-        wndLast = NULL;
-        while (wnd != wndStop)
-        {
-            if (wnd->owner == pWnd &&
-                (wnd->dwStyle & WS_POPUP) &&
-                (wnd->dwStyle & WS_VISIBLE))
-                wndLast = wnd;
-            wnd = wnd->next;
-        }
-        if (wndLast)
-        {
-            WINPOS_ForceXWindowRaise( wndLast );
-            wndStop = wndLast;
-        }
+        if (pWnd->window) XReconfigureWMWindow( display, pWnd->window, 0,
+                                                CWStackMode, &winChanges );
+        wndPrev = WIN_GetDesktop()->child;
+        if (wndPrev == pWnd) break;
+        while (wndPrev && (wndPrev->next != pWnd)) wndPrev = wndPrev->next;
+        pWnd = wndPrev;
     }
 }
 
+
 /*******************************************************************
  *	   WINPOS_SetActiveWindow
  *
@@ -1199,9 +1190,9 @@ LONG WINPOS_SendNCCalcSize( HWND32 hwnd, BOOL32 calcValidRect,
     }
     result = SendMessage16( hwnd, WM_NCCALCSIZE, calcValidRect,
                           (LPARAM)SEGPTR_GET( params ) );
-    dprintf_win(stddeb, "WINPOS_SendNCCalcSize: %d %d %d %d\n",
-		(int)params->rgrc[0].top,    (int)params->rgrc[0].left,
-		(int)params->rgrc[0].bottom, (int)params->rgrc[0].right);
+    dprintf_win( stddeb, "WINPOS_SendNCCalcSize: %d,%d-%d,%d\n",
+                 params->rgrc[0].left, params->rgrc[0].top,
+                 params->rgrc[0].right, params->rgrc[0].bottom );
     *newClientRect = params->rgrc[0];
     SEGPTR_FREE(params);
     return result;
@@ -1220,7 +1211,7 @@ LONG WINPOS_HandleWindowPosChanging16( WND *wndPtr, WINDOWPOS16 *winpos )
     if ((wndPtr->dwStyle & WS_THICKFRAME) ||
 	((wndPtr->dwStyle & (WS_POPUP | WS_CHILD)) == 0))
     {
-	NC_GetMinMaxInfo( winpos->hwnd, &maxSize, NULL, NULL, NULL );
+	NC_GetMinMaxInfo( wndPtr, &maxSize, NULL, NULL, NULL );
 	winpos->cx = MIN( winpos->cx, maxSize.x );
 	winpos->cy = MIN( winpos->cy, maxSize.y );
     }
@@ -1240,7 +1231,7 @@ LONG WINPOS_HandleWindowPosChanging32( WND *wndPtr, WINDOWPOS32 *winpos )
     if ((wndPtr->dwStyle & WS_THICKFRAME) ||
 	((wndPtr->dwStyle & (WS_POPUP | WS_CHILD)) == 0))
     {
-	NC_GetMinMaxInfo( winpos->hwnd, &maxSize, NULL, NULL, NULL );
+	NC_GetMinMaxInfo( wndPtr, &maxSize, NULL, NULL, NULL );
 	winpos->cx = MIN( winpos->cx, maxSize.x );
 	winpos->cy = MIN( winpos->cy, maxSize.y );
     }
@@ -1387,7 +1378,7 @@ HWND WINPOS_ReorderOwnedPopups(HWND hwndInsertAfter, WND* wndPtr, WORD flags)
 static UINT WINPOS_SizeMoveClean(WND* Wnd, HRGN32 oldVisRgn, LPRECT16 lpOldWndRect, LPRECT16 lpOldClientRect, UINT uFlags )
 {
  HRGN32 newVisRgn = DCE_GetVisRgn(Wnd->hwndSelf,DCX_WINDOW | DCX_CLIPSIBLINGS);
- HRGN32 dirtyRgn = CreateRectRgn(0,0,0,0);
+ HRGN32 dirtyRgn = CreateRectRgn32(0,0,0,0);
  int  other, my;
 
  dprintf_win(stddeb,"cleaning up...new wnd=(%i %i-%i %i) old wnd=(%i %i-%i %i)\n\
@@ -1401,29 +1392,30 @@ static UINT WINPOS_SizeMoveClean(WND* Wnd, HRGN32 oldVisRgn, LPRECT16 lpOldWndRe
      (lpOldWndRect->bottom - lpOldWndRect->top) != (Wnd->rectWindow.bottom - Wnd->rectWindow.top) )
      uFlags |= SMC_DRAWFRAME;
 
- CombineRgn( dirtyRgn, newVisRgn, 0, RGN_COPY);
+ CombineRgn32( dirtyRgn, newVisRgn, 0, RGN_COPY);
 
  if( !(uFlags & SMC_NOCOPY) )
-   CombineRgn( newVisRgn, newVisRgn, oldVisRgn, RGN_AND ); 
+   CombineRgn32( newVisRgn, newVisRgn, oldVisRgn, RGN_AND ); 
 
  /* map regions to the parent client area */
  
- OffsetRgn(dirtyRgn, Wnd->rectWindow.left, Wnd->rectWindow.top);
- OffsetRgn(oldVisRgn, lpOldWndRect->left, lpOldWndRect->top);
+ OffsetRgn32( dirtyRgn, Wnd->rectWindow.left, Wnd->rectWindow.top );
+ OffsetRgn32( oldVisRgn, lpOldWndRect->left, lpOldWndRect->top );
 
  /* compute invalidated region outside Wnd - (in client coordinates of the parent window) */
 
- other = CombineRgn(dirtyRgn, oldVisRgn, dirtyRgn, RGN_DIFF);
+ other = CombineRgn32(dirtyRgn, oldVisRgn, dirtyRgn, RGN_DIFF);
 
  /* map visible region to the Wnd client area */
 
- OffsetRgn( newVisRgn, Wnd->rectWindow.left - Wnd->rectClient.left,
-                       Wnd->rectWindow.top - Wnd->rectClient.top );
+ OffsetRgn32( newVisRgn, Wnd->rectWindow.left - Wnd->rectClient.left,
+                         Wnd->rectWindow.top - Wnd->rectClient.top );
 
  /* substract previously invalidated region from the Wnd visible region */
 
- my =  (Wnd->hrgnUpdate > 1)? CombineRgn( newVisRgn, newVisRgn, Wnd->hrgnUpdate, RGN_DIFF)
-                            : COMPLEXREGION;
+ my =  (Wnd->hrgnUpdate > 1) ? CombineRgn32( newVisRgn, newVisRgn,
+                                             Wnd->hrgnUpdate, RGN_DIFF)
+                             : COMPLEXREGION;
 
  if( uFlags & SMC_NOCOPY )	/* invalidate Wnd visible region */
    {
@@ -1444,8 +1436,8 @@ static UINT WINPOS_SizeMoveClean(WND* Wnd, HRGN32 oldVisRgn, LPRECT16 lpOldWndRe
          xfrom = lpOldClientRect->left; yfrom = lpOldClientRect->top;
          xto = Wnd->rectClient.left; yto = Wnd->rectClient.top;
          width = lpOldClientRect->right - xfrom; height = lpOldClientRect->bottom - yfrom;
-	 updateRgn = CreateRectRgn( 0, 0, width, height );
-	 CombineRgn( newVisRgn, newVisRgn, updateRgn, RGN_AND );
+	 updateRgn = CreateRectRgn32( 0, 0, width, height );
+	 CombineRgn32( newVisRgn, newVisRgn, updateRgn, RGN_AND );
 	 SetRectRgn( updateRgn, 0, 0, Wnd->rectClient.right - xto, Wnd->rectClient.bottom - yto );
        }
      else
@@ -1453,17 +1445,17 @@ static UINT WINPOS_SizeMoveClean(WND* Wnd, HRGN32 oldVisRgn, LPRECT16 lpOldWndRe
          xfrom = lpOldWndRect->left; yfrom = lpOldWndRect->top;
          xto = Wnd->rectWindow.left; yto = Wnd->rectWindow.top;
          width = lpOldWndRect->right - xfrom; height = lpOldWndRect->bottom - yfrom;
-	 updateRgn = CreateRectRgn( xto - Wnd->rectClient.left,
-				    yto - Wnd->rectClient.top,
-				    Wnd->rectWindow.right - Wnd->rectClient.left,
-				    Wnd->rectWindow.bottom - Wnd->rectClient.top );
+	 updateRgn = CreateRectRgn32( xto - Wnd->rectClient.left,
+				      yto - Wnd->rectClient.top,
+				Wnd->rectWindow.right - Wnd->rectClient.left,
+			        Wnd->rectWindow.bottom - Wnd->rectClient.top );
        }
 
-     CombineRgn( newVisRgn, newVisRgn, updateRgn, RGN_AND );
+     CombineRgn32( newVisRgn, newVisRgn, updateRgn, RGN_AND );
 
      /* substract new visRgn from target rect to get a region that won't be copied */
 
-     update = CombineRgn( updateRgn, updateRgn, newVisRgn, RGN_DIFF );
+     update = CombineRgn32( updateRgn, updateRgn, newVisRgn, RGN_DIFF );
 
      /* Blt valid bits using parent window DC */
 
@@ -1472,8 +1464,8 @@ static UINT WINPOS_SizeMoveClean(WND* Wnd, HRGN32 oldVisRgn, LPRECT16 lpOldWndRe
 	 
 	 /* compute clipping region in parent client coordinates */
 
-	 OffsetRgn( newVisRgn, Wnd->rectClient.left, Wnd->rectClient.top);
-	 CombineRgn( oldVisRgn, oldVisRgn, newVisRgn, RGN_OR );
+	 OffsetRgn32( newVisRgn, Wnd->rectClient.left, Wnd->rectClient.top );
+	 CombineRgn32( oldVisRgn, oldVisRgn, newVisRgn, RGN_OR );
 
          hDC = GetDCEx32( Wnd->parent->hwndSelf, oldVisRgn,
                           DCX_KEEPCLIPRGN | DCX_INTERSECTRGN |
@@ -1488,7 +1480,7 @@ static UINT WINPOS_SizeMoveClean(WND* Wnd, HRGN32 oldVisRgn, LPRECT16 lpOldWndRe
          PAINT_RedrawWindow( Wnd->hwndSelf, NULL, updateRgn, RDW_INVALIDATE |
                          RDW_FRAME | RDW_ALLCHILDREN | RDW_ERASE, RDW_C_USEHRGN );
      else if( uFlags & SMC_DRAWFRAME ) Wnd->flags |= WIN_NEEDS_NCPAINT;
-     DeleteObject( updateRgn );
+     DeleteObject32( updateRgn );
    }
 
  /* erase uncovered areas */
@@ -1496,8 +1488,8 @@ static UINT WINPOS_SizeMoveClean(WND* Wnd, HRGN32 oldVisRgn, LPRECT16 lpOldWndRe
  if( !(uFlags & SMC_NOPARENTERASE) && (other != NULLREGION ) )
       PAINT_RedrawWindow( Wnd->parent->hwndSelf, NULL, dirtyRgn,
                         RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_ERASE, RDW_C_USEHRGN );
- DeleteObject(dirtyRgn);
- DeleteObject(newVisRgn);
+ DeleteObject32(dirtyRgn);
+ DeleteObject32(newVisRgn);
  return uFlags;
 }
 
@@ -1835,7 +1827,7 @@ BOOL SetWindowPos( HWND hwnd, HWND hwndInsertAfter, INT x, INT y,
 		if( winpos->flags & SWP_NOZORDER ) uFlags |= SMC_NOPARENTERASE;
 	      }
 	  }
-        DeleteObject(visRgn);
+        DeleteObject32(visRgn);
     }
 
     if (flags & SWP_SHOWWINDOW)
diff --git a/windows/winproc.c b/windows/winproc.c
index b1107e8b964e977fbcce72f11aa75078fe8f0834..aa212e77f48ef20816dd14128ddd34937197c82b 100644
--- a/windows/winproc.c
+++ b/windows/winproc.c
@@ -1203,7 +1203,7 @@ void WINPROC_UnmapMsg32ATo16( UINT16 msg, WPARAM16 wParam, LPARAM lParam )
         {
             LPSTR str = (LPSTR)PTR_SEG_TO_LIN(lParam);
             lParam = *((LPARAM *)str - 1);
-            strcpy( (LPSTR)lParam, str );
+            lstrcpyn32A( (LPSTR)lParam, str, wParam );
             SEGPTR_FREE( (LPARAM *)str - 1 );
         }
         break;