Release 961102

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.
diff --git a/ANNOUNCE b/ANNOUNCE
index 1d05e42..d5d35fe 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 @@
 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 e9787ad..fec97dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,52 @@
 ----------------------------------------------------------------------
+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>
 
 	* [*/Makefile.in] [tools/makedep.c]
diff --git a/Make.rules.in b/Make.rules.in
index 4e7b95b..43d024a 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 @@
 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 fcf591b..8d92822 100644
--- a/controls/button.c
+++ b/controls/button.c
@@ -252,38 +252,38 @@
 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 @@
         }   
     }
 
-    SelectObject( hDC, hOldPen );
-    SelectObject( hDC, hOldBrush );
+    SelectObject32( hDC, hOldPen );
+    SelectObject32( hDC, hOldBrush );
 }
 
 
@@ -349,17 +349,17 @@
     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 @@
 
     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 @@
 /**********************************************************************
  *       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 @@
     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 @@
 
     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 @@
 
     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 1f540f4..c3f429e 100644
--- a/controls/combo.c
+++ b/controls/combo.c
@@ -224,8 +224,8 @@
   LPHEADCOMBO lphc = ComboGetStorageHeader(hwnd);
   LPLISTSTRUCT lpls;
   PAINTSTRUCT16  ps;
-  HBRUSH16 hBrush;
-  HFONT16  hOldFont;
+  HBRUSH32 hBrush;
+  HFONT32 hOldFont;
   HDC16 hdc;
   RECT16 rect;
   
@@ -238,8 +238,8 @@
 
   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 @@
     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 @@
     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 @@
   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 @@
   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 @@
     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 @@
   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 f7529e8..87cde85 100644
--- a/controls/desktop.c
+++ b/controls/desktop.c
@@ -80,7 +80,7 @@
     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 @@
     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 @@
     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 @@
 
 	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 f37c058..e86af14 100644
--- a/controls/edit.c
+++ b/controls/edit.c
@@ -119,6 +119,7 @@
 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 @@
 	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 @@
 
 	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 @@
 			}
 		} while (*start || (ending == END_SOFT) || (ending == END_HARD));
 	}
-	if (hFont)
-		SelectObject(hdc, oldFont);
+	if (hFont) SelectObject32(hdc, oldFont);
 	ReleaseDC32(wndPtr->hwndSelf, hdc);
 
 	free(text);
@@ -821,6 +820,22 @@
 
 /*********************************************************************
  *
+ *	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 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_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_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_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_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_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_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_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_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_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 @@
 	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 @@
 	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 @@
 	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 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 @@
 	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 @@
 
 	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 @@
  *
  *	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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_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_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_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_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 @@
 
 	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_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 @@
 	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 @@
 		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 @@
 	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 @@
 
 	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 @@
 		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_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 @@
 {
 	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 d3c4a94..1fe77b2 100644
--- a/controls/listbox.c
+++ b/controls/listbox.c
@@ -74,7 +74,7 @@
   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 @@
 
       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 @@
 
     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 @@
   HDC32 hdc;
 
   if (wParam == 0)
-    lphl->hFont = GetStockObject(SYSTEM_FONT);
+    lphl->hFont = GetStockObject32(SYSTEM_FONT);
   else
     lphl->hFont = (HFONT16)wParam;
 
@@ -1436,7 +1437,7 @@
   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 @@
   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 @@
     lpls = lpls->lpNext;
   }
   ListBoxUpdateWindow(hwnd,lphl,FALSE);
-  SelectObject(hdc,hOldFont);
+  SelectObject32(hdc,hOldFont);
   EndPaint16( hwnd, &ps );
   return 0;
 }
@@ -1537,14 +1538,14 @@
        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 @@
            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 ce9a146..8443376 100644
--- a/controls/menu.c
+++ b/controls/menu.c
@@ -591,15 +591,15 @@
 
     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 @@
     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 1364fc1..481f6cb 100644
--- a/controls/scroll.c
+++ b/controls/scroll.c
@@ -312,7 +312,7 @@
                                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 @@
                 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 @@
                    hdcMem, 0, 0,
                    SYSMETRICS_CXVSCROLL + 1, SYSMETRICS_CYHSCROLL + 1,
                    SRCCOPY );
-    SelectObject( hdcMem, hbmpPrev );
+    SelectObject32( hdcMem, hbmpPrev );
     DeleteDC( hdcMem );
 }
 
@@ -389,11 +389,11 @@
 
       /* 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 @@
         {
             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 @@
       /* 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 @@
 
       /* 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 09441ac..289b0a5 100644
--- a/controls/static.c
+++ b/controls/static.c
@@ -220,10 +220,10 @@
     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_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 7996a26..971651a 100644
--- a/controls/status.c
+++ b/controls/status.c
@@ -49,19 +49,19 @@
     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 @@
 
     /* 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 71b2215..7b8d278 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 @@
 
 #endif  /* DONT_USE_READLINE */
 
+#define YY_NO_UNPUT
+
 static int syntax_error;
 %}
 
diff --git a/files/directory.c b/files/directory.c
index 5d12ef2..f83d81b 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 4ed1544..3e3c8dc 100644
--- a/files/dos_fs.c
+++ b/files/dos_fs.c
@@ -244,11 +244,11 @@
 
 
 /***********************************************************************
- *           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++)
@@ -258,6 +258,40 @@
 
 
 /***********************************************************************
+ *           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
  *
  * Convert a Unix time in the DOS date/time format.
@@ -274,6 +308,31 @@
 
 
 /***********************************************************************
+ *           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
  *
  * Transform a Unix file name into a hashed DOS name. If the name is a valid
@@ -665,9 +724,12 @@
  *
  * 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 @@
     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 @@
             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 @@
     return strlen(dostruename);
 }
 
+
 /***********************************************************************
  *           GetFullPathNameA   (KERNEL32.272)
  */
diff --git a/graphics/win16drv/init.c b/graphics/win16drv/init.c
index 7b285fe..4b0d8b7 100644
--- a/graphics/win16drv/init.c
+++ b/graphics/win16drv/init.c
@@ -658,7 +658,7 @@
 
     /* 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 bcfe298..5d43e8d 100644
--- a/graphics/x11drv/init.c
+++ b/graphics/x11drv/init.c
@@ -114,15 +114,15 @@
         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 e131b6c..2f0433c 100644
--- a/if1632/gdi.spec
+++ b/if1632/gdi.spec
@@ -20,24 +20,23 @@
 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 @@
 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 @@
 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 @@
              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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 7c00df7..aad949c 100644
--- a/if1632/gdi32.spec
+++ b/if1632/gdi32.spec
@@ -9,19 +9,19 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 19694ce..8441542 100644
--- a/if1632/thunk.c
+++ b/if1632/thunk.c
@@ -95,7 +95,18 @@
                            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 @@
  */
 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 3b40231..77c3c62 100644
--- a/if1632/user.spec
+++ b/if1632/user.spec
@@ -284,7 +284,7 @@
 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 5969794..0c12313 100644
--- a/if1632/user32.spec
+++ b/if1632/user32.spec
@@ -293,7 +293,7 @@
 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 3f33bbc..07d63e7 100644
--- a/if1632/wprocs.spec
+++ b/if1632/wprocs.spec
@@ -21,7 +21,6 @@
 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 @@
 
 # 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 25803e6..f03ad8f 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 8a2631e..303cbbb 100644
--- a/include/dos_fs.h
+++ b/include/dos_fs.h
@@ -32,8 +32,9 @@
 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 764f081..e8a5980 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 0a43406..ab4f5b2 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 5aecf71..eb44f4f 100644
--- a/include/region.h
+++ b/include/region.h
@@ -17,8 +17,8 @@
 } 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 a7b5809..c8fa8c9 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 3210170..7359e0b 100644
--- a/include/windows.h
+++ b/include/windows.h
@@ -805,16 +805,16 @@
 
 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 @@
 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       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       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 @@
 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 @@
 
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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       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 @@
 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     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     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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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       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 @@
 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       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 @@
 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 @@
 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 @@
 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 6dadc3f..5707003 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 @@
         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 @@
     /* 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 5168949..370b926 100644
--- a/loader/pe_image.c
+++ b/loader/pe_image.c
@@ -153,8 +153,9 @@
 			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 @@
 		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 @@
 		    }
 		} 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 @@
 		    /* 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 @@
 		} 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 @@
 {
     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 @@
 	   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 @@
 		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 @@
 	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 @@
     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 @@
     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 @@
     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 @@
         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 @@
 /* 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 @@
 
     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 87b1e37..97b2ac3 100644
--- a/loader/task.c
+++ b/loader/task.c
@@ -349,38 +349,59 @@
 #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 @@
     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 @@
 #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 32b89c6..ad09ada 100644
--- a/misc/clipboard.c
+++ b/misc/clipboard.c
@@ -144,7 +144,7 @@
 {
   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 ec93f7c..0133f88 100644
--- a/misc/commdlg.c
+++ b/misc/commdlg.c
@@ -218,7 +218,7 @@
 {
     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 @@
     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 @@
     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 @@
 	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 @@
     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 @@
 	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 @@
 {
  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 @@
    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 @@
  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 @@
    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 @@
  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 @@
  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 @@
    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 @@
  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 @@
    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 @@
  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 @@
  {
   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 @@
  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 @@
   {
    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 @@
 	                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 @@
      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 @@
   {
    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 @@
 		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 @@
 		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 @@
    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 ae853fc..b9113a7 100644
--- a/misc/main.c
+++ b/misc/main.c
@@ -1030,7 +1030,7 @@
 		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 a0606ff..b5ba088 100644
--- a/misc/registry.c
+++ b/misc/registry.c
@@ -1204,7 +1204,8 @@
 	}
 	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 90f89ca..3bec8c7 100644
--- a/misc/shell.c
+++ b/misc/shell.c
@@ -395,9 +395,9 @@
     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 d3043ca..c53ba85 100644
--- a/misc/ver.c
+++ b/misc/ver.c
@@ -408,31 +408,37 @@
 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;
+	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(*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;
+    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 @@
 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 fb5aff4..d701a8b 100644
--- a/miscemu/int21.c
+++ b/miscemu/int21.c
@@ -592,7 +592,7 @@
     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 @@
     }
 
     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 0a5a188..92bf08e 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 @@
     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 @@
     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 @@
     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 @@
     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 926f176..8d3d57c 100644
--- a/objects/bitmap.c
+++ b/objects/bitmap.c
@@ -430,7 +430,7 @@
        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 3816170..ecb71cc 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 @@
  *
  * 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 @@
 
 
 /***********************************************************************
- *           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 );
-    if ((style < 0) || (style >= NB_HATCH_STYLES)) return 0;
-    return CreateBrushIndirect( &logbrush );
+    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;
 }
 
 
 /***********************************************************************
- *           CreatePatternBrush    (GDI.60)
+ *           CreateHatchBrush16    (GDI.58)
  */
-HBRUSH16 CreatePatternBrush( HBITMAP16 hbitmap )
+HBRUSH16 CreateHatchBrush16( INT16 style, COLORREF color )
 {
-    LOGBRUSH16 logbrush = { BS_PATTERN, 0, 0 };
+    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 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 );
+}
+
+
+/***********************************************************************
+ *           CreatePatternBrush32    (GDI32.54)
+ */
+HBRUSH32 CreatePatternBrush32( HBITMAP32 hbitmap )
+{
+    LOGBRUSH32 logbrush = { BS_PATTERN, 0, 0 };
     BITMAPOBJ *bmp, *newbmp;
 
     dprintf_gdi(stddeb, "CreatePatternBrush: %04x\n", hbitmap );
@@ -178,29 +218,30 @@
 
     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 );
 }
 
 
 /***********************************************************************
- *           CreateDIBPatternBrush    (GDI.445)
+ *           CreateDIBPatternBrush16    (GDI.445)
  */
-HBRUSH16 CreateDIBPatternBrush( HGLOBAL16 hbitmap, UINT coloruse )
+HBRUSH16 CreateDIBPatternBrush16( HGLOBAL16 hbitmap, UINT16 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 *)GlobalLock16( hbitmap ))) return 0;
 
     if (info->bmiHeader.biCompression)
         size = info->bmiHeader.biSizeImage;
@@ -209,7 +250,7 @@
 	         * 8 * info->bmiHeader.biHeight;
     size += DIB_BitmapInfoSize( info, coloruse );
 
-    if (!(logbrush.lbHatch = (INT)GlobalAlloc16( GMEM_MOVEABLE, size )))
+    if (!(logbrush.lbHatch = (INT16)GlobalAlloc16( GMEM_MOVEABLE, size )))
     {
 	GlobalUnlock16( hbitmap );
 	return 0;
@@ -218,18 +259,64 @@
     memcpy( newInfo, info, size );
     GlobalUnlock16( (HGLOBAL16)logbrush.lbHatch );
     GlobalUnlock16( hbitmap );
-    return CreateBrushIndirect( &logbrush );
+    return CreateBrushIndirect32( &logbrush );
+}
+
+
+/***********************************************************************
+ *           CreateDIBPatternBrush32    (GDI32.34)
+ */
+HBRUSH32 CreateDIBPatternBrush32( HGLOBAL32 hbitmap, UINT32 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 *)GlobalLock32( 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 = (INT32)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 );
 }
 
 
 /***********************************************************************
  *           CreateSolidBrush    (GDI.66)
  */
-HBRUSH16 CreateSolidBrush( COLORREF color )
+HBRUSH16 CreateSolidBrush16( 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, "CreateSolidBrush16: %06lx\n", color );
+    return CreateBrushIndirect32( &logbrush );
+}
+
+
+/***********************************************************************
+ *           CreateSolidBrush32    (GDI32.64)
+ */
+HBRUSH32 CreateSolidBrush32( COLORREF color )
+{
+    LOGBRUSH32 logbrush = { BS_SOLID, color, 0 };
+    dprintf_gdi(stddeb, "CreateSolidBrush32: %06lx\n", color );
+    return CreateBrushIndirect32( &logbrush );
 }
 
 
@@ -268,12 +355,22 @@
 
 
 /***********************************************************************
- *           GetSysColorBrush    (USER.281)
+ *           GetSysColorBrush16    (USER.281)
  */
-HBRUSH16 GetSysColorBrush(WORD x)
+HBRUSH16 GetSysColorBrush16( INT16 index )
 {
-    fprintf( stderr, "Unimplemented stub: GetSysColorBrush(%d)\n", x );
-    return GetStockObject(LTGRAY_BRUSH);
+    fprintf( stderr, "Unimplemented stub: GetSysColorBrush16(%d)\n", index );
+    return GetStockObject32(LTGRAY_BRUSH);
+}
+
+
+/***********************************************************************
+ *           GetSysColorBrush32    (USER32.289)
+ */
+HBRUSH32 GetSysColorBrush32( INT32 index)
+{
+    fprintf( stderr, "Unimplemented stub: GetSysColorBrush32(%d)\n", index );
+    return GetStockObject32(LTGRAY_BRUSH);
 }
 
 
@@ -285,7 +382,7 @@
     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 @@
 
 
 /***********************************************************************
- *           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 @@
 /***********************************************************************
  *           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 @@
 /***********************************************************************
  *           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 @@
                 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 @@
 				      ((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 f5a7c27..c7f55fc 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 @@
     }
 
     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 @@
 
     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 @@
 /***********************************************************************
  *           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 @@
 
     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)
  */
-int OffsetClipRgn( HDC16 hdc, short x, short y )
+INT16 OffsetClipRgn16( HDC16 hdc, INT16 x, INT16 y )
+{
+    return (INT16)OffsetClipRgn32( hdc, x, y );
+}
+
+
+/***********************************************************************
+ *           OffsetClipRgn32    (GDI32.255)
+ */
+INT32 OffsetClipRgn32( HDC32 hdc, INT32 x, INT32 y )
 {
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc) 
@@ -114,9 +132,9 @@
 
     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 @@
 /***********************************************************************
  *           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 @@
  * 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 @@
        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)
  */
-int ExcludeClipRect( HDC16 hdc, short left, short top,
-		     short right, short bottom )
+INT16 ExcludeClipRect16( HDC16 hdc, INT16 left, INT16 top,
+                         INT16 right, INT16 bottom )
+{
+    return (INT16)ExcludeClipRect32( hdc, left, top, right, bottom );
+}
+
+
+/***********************************************************************
+ *           ExcludeClipRect32    (GDI32.92)
+ */
+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 @@
 
 
 /***********************************************************************
- *           IntersectClipRect    (GDI.22)
+ *           IntersectClipRect16    (GDI.22)
  */
-int IntersectClipRect( HDC16 hdc, short left, short top,
-		       short right, short bottom )
+INT16 IntersectClipRect16( HDC16 hdc, INT16 left, INT16 top,
+                           INT16 right, INT16 bottom )
+{
+    return (INT16)IntersectClipRect32( hdc, left, top, right, bottom );
+}
+
+
+/***********************************************************************
+ *           IntersectClipRect32    (GDI32.245)
+ */
+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 @@
  *
  * 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 @@
 /***********************************************************************
  *           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 @@
 /***********************************************************************
  *           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 @@
 
 
 /***********************************************************************
- *           PtVisible    (GDI.103)
+ *           PtVisible16    (GDI.103)
  */
-BOOL PtVisible( HDC16 hdc, short x, short y )
+BOOL16 PtVisible16( HDC16 hdc, INT16 x, INT16 y )
+{
+    return PtVisible32( hdc, x, y );
+}
+
+
+/***********************************************************************
+ *           PtVisible32    (GDI32.279)
+ */
+BOOL32 PtVisible32( HDC32 hdc, INT32 x, INT32 y )
 {
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc) return ERROR;    
@@ -310,7 +358,7 @@
     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 @@
 /***********************************************************************
  *           SaveVisRgn    (GDI.129)
  */
-HRGN32 SaveVisRgn( HDC16 hdc )
+HRGN16 SaveVisRgn( HDC16 hdc )
 {
     HRGN32 copy;
     RGNOBJ *obj, *copyObj;
@@ -391,8 +439,8 @@
 
     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 @@
 /***********************************************************************
  *           RestoreVisRgn    (GDI.130)
  */
-int RestoreVisRgn( HDC16 hdc )
+INT16 RestoreVisRgn( HDC16 hdc )
 {
     HRGN32 saved;
     RGNOBJ *obj, *savedObj;
@@ -416,7 +464,7 @@
     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 57875c4..a3388af 100644
--- a/objects/cursoricon.c
+++ b/objects/cursoricon.c
@@ -335,8 +335,8 @@
     if (!(handle = GlobalAlloc16( GMEM_MOVEABLE,
                                   sizeof(CURSORICONINFO) + sizeXor + sizeAnd)))
     {
-        DeleteObject( hXorBits );
-        DeleteObject( hAndBits );
+        DeleteObject32( hXorBits );
+        DeleteObject32( hAndBits );
         return 0;
     }
 
@@ -356,8 +356,8 @@
 
     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 @@
 
     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 215bc50..834e0f8 100644
--- a/objects/dc.c
+++ b/objects/dc.c
@@ -185,9 +185,9 @@
     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 @@
 
     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 @@
  */
 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;
+    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;
 
-      /* 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 );
+    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 @@
         !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 @@
     
     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 556e89f..8ec1ce1 100644
--- a/objects/dib.c
+++ b/objects/dib.c
@@ -632,12 +632,12 @@
     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 d41a6e1..0c4f2fe 100644
--- a/objects/font.c
+++ b/objects/font.c
@@ -1203,10 +1203,10 @@
     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 @@
     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 9392bd9..0502c69 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 @@
 
 
 /***********************************************************************
- *           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 @@
 
 
 /***********************************************************************
- *           GetStockObject    (GDI.87)
+ *           GetStockObject16    (GDI.87)
  */
-HGDIOBJ16 GetStockObject( INT16 obj )
+HGDIOBJ16 GetStockObject16( INT16 obj )
+{
+    return (HGDIOBJ16)GetStockObject32( obj );
+}
+
+
+/***********************************************************************
+ *           GetStockObject32    (GDI32.220)
+ */
+HGDIOBJ32 GetStockObject32( INT32 obj )
 {
     if ((obj < 0) || (obj >= NB_STOCK_OBJECTS)) return 0;
     if (!StockObjects[obj]) return 0;
@@ -299,9 +318,9 @@
     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 @@
     
     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 @@
 
 
 /***********************************************************************
- *           SelectObject    (GDI.45)
+ *           SelectObject16    (GDI.45)
  */
-HGDIOBJ16 SelectObject( HDC16 hdc, HGDIOBJ16 handle )
+HGDIOBJ16 SelectObject16( HDC16 hdc, HGDIOBJ16 handle )
+{
+    return (HGDIOBJ16)SelectObject32( hdc, handle );
+}
+
+
+/***********************************************************************
+ *           SelectObject32    (GDI32.299)
+ */
+HGDIOBJ32 SelectObject32( HDC32 hdc, HGDIOBJ32 handle )
 {
     GDIOBJHDR * ptr = NULL;
     DC * dc;
@@ -387,16 +417,25 @@
       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)
  */
-BOOL UnrealizeObject( HGDIOBJ16 obj )
+BOOL16 UnrealizeObject16( HGDIOBJ16 obj )
+{
+    return UnrealizeObject32( obj );
+}
+
+
+/***********************************************************************
+ *           UnrealizeObject    (GDI32.358)
+ */
+BOOL32 UnrealizeObject32( HGDIOBJ32 obj )
 {
       /* Check if object is valid */
 
@@ -421,10 +460,10 @@
 
 
 /***********************************************************************
- *           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 @@
       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 @@
             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 @@
             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 @@
             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 @@
         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 6b2ccd6..ad885d6 100644
--- a/objects/metafile.c
+++ b/objects/metafile.c
@@ -284,7 +284,7 @@
     /* 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 @@
       break;
 
     case META_DELETEOBJECT:
-      DeleteObject(*(ht->objectHandle + *(mr->rdParam)));
+      DeleteObject32(*(ht->objectHandle + *(mr->rdParam)));
       *(ht->objectHandle + *(mr->rdParam)) = 0;
       break;
 
@@ -471,7 +471,7 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	    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 @@
 
     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 @@
                                       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 @@
        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_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_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 774d264..87929bc 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 @@
 /***********************************************************************
  *           OBM_InitColorSymbols
  */
-static BOOL OBM_InitColorSymbols()
+static BOOL32 OBM_InitColorSymbols()
 {
     int i;
 
@@ -328,8 +329,8 @@
  *
  * 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 @@
     CURSORICONINFO *pInfo;
     BITMAPOBJ *bmpXor, *bmpAnd;
     HBITMAP16 hXorBits, hAndBits;
-    POINT16 hotspot;
+    POINT32 hotspot;
     int sizeXor, sizeAnd;
 
     if (fCursor)
@@ -443,8 +444,8 @@
     if (!(handle = GlobalAlloc16( GMEM_MOVEABLE,
                                   sizeof(CURSORICONINFO) + sizeXor + sizeAnd)))
     {
-        DeleteObject( hXorBits );
-        DeleteObject( hAndBits );
+        DeleteObject32( hXorBits );
+        DeleteObject32( hAndBits );
         return 0;
     }
 
@@ -485,8 +486,8 @@
     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 c32ca20..bb14791 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 }; /* ----  --  --  ----  */
+
 /***********************************************************************
- *           CreatePen    (GDI.61)
+ *           CreatePen16    (GDI.61)
  */
-HPEN16 CreatePen( INT style, INT width, COLORREF color )
+HPEN16 CreatePen16( INT16 style, INT16 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, "CreatePen16: %d %d %06lx\n", style, width, color );
+    return CreatePenIndirect32( &logpen );
 }
 
 
 /***********************************************************************
- *           CreatePenIndirect    (GDI.62)
+ *           CreatePen32    (GDI32.55)
  */
-HPEN16 CreatePenIndirect( const LOGPEN16 * pen )
+HPEN32 CreatePen32( INT32 style, INT32 width, COLORREF color )
+{
+    LOGPEN32 logpen = { style, { width, 0 }, color };
+    dprintf_gdi(stddeb, "CreatePen32: %d %d %06lx\n", style, width, color );
+    return CreatePenIndirect32( &logpen );
+}
+
+
+/***********************************************************************
+ *           CreatePenIndirect16    (GDI.62)
+ */
+HPEN16 CreatePenIndirect16( const LOGPEN16 * pen )
 {
     PENOBJ * penPtr;
     HPEN16 hpen;
@@ -32,16 +50,52 @@
     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 @@
 /***********************************************************************
  *           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 @@
     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 a5e5cd6..4404062 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 @@
 
 
 /***********************************************************************
- *           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 @@
 
 
 /***********************************************************************
- *           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 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 @@
  */
 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 @@
 
 
 /***********************************************************************
- *           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 @@
 
     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 @@
 
 
 /***********************************************************************
- *           CreateEllipticRgn    (GDI.54) (GDI32.39)
+ *           CreateEllipticRgn16    (GDI.54)
  */
-HRGN16 CreateEllipticRgn( INT32 left, INT32 top, INT32 right, INT32 bottom )
+HRGN16 CreateEllipticRgn16( INT16 left, INT16 top, INT16 right, INT16 bottom )
 {
-    return CreateRoundRectRgn( left, top, right, bottom,
-                               right-left, bottom-top );
+    return (HRGN16)CreateRoundRectRgn32( left, top, right, bottom,
+                                         right-left, bottom-top );
+}
+
+
+/***********************************************************************
+ *           CreateEllipticRgn32    (GDI32.39)
+ */
+HRGN32 CreateEllipticRgn32( INT32 left, INT32 top, INT32 right, INT32 bottom )
+{
+    return CreateRoundRectRgn32( left, top, right, bottom,
+                                 right-left, bottom-top );
 }
 
 
@@ -251,8 +290,9 @@
  */
 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 @@
  */
 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 @@
 
 
 /***********************************************************************
- *           PtInRegion    (GDI.161) (GDI32.278)
+ *           PtInRegion16    (GDI.161)
  */
-BOOL16 PtInRegion( HRGN32 hrgn, INT32 x, INT32 y )
+BOOL16 PtInRegion16( HRGN16 hrgn, INT16 x, INT16 y )
+{
+    return PtInRegion32( hrgn, x, y );
+}
+
+
+/***********************************************************************
+ *           PtInRegion32    (GDI32.278)
+ */
+BOOL32 PtInRegion32( HRGN32 hrgn, INT32 x, INT32 y )
 {
     RGNOBJ * obj;
     
@@ -386,9 +436,18 @@
 
 
 /***********************************************************************
- *           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 @@
  *
  * 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 @@
  *
  * 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 @@
   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;
 }
 
+
 /***********************************************************************
- *           CombineRgn    (GDI.451) (GDI32.19)
- *
- * The behavior is correct even if src and dest regions are the same.
+ *           CombineRgn16    (GDI.451)
  */
-INT16 CombineRgn( HRGN32 hDest, HRGN32 hSrc1, HRGN32 hSrc2, INT32 mode )
+INT16 CombineRgn16( HRGN16 hDest, HRGN16 hSrc1, HRGN16 hSrc2, INT16 mode )
+{
+    return (INT16)CombineRgn32( hDest, hSrc1, hSrc2, mode );
+}
+
+
+/***********************************************************************
+ *           CombineRgn32   (GDI32.19)
+ *
+ * Note: The behavior is correct even if src and dest regions are the same.
+ */
+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 c714e7b..1862afe 100644
--- a/objects/text.c
+++ b/objects/text.c
@@ -256,12 +256,12 @@
                               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 @@
 
     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 ed39e54..baec1b8 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 3cbd039..17781ec 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 @@
 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 2ea2d72..43a27f3 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 1d1bf3a..1638987 100644
--- a/tools/makedep.c
+++ b/tools/makedep.c
@@ -229,6 +229,7 @@
         *p = 0;
         add_include( pFile, include );
     }
+    fclose(file);
 }
 
 
@@ -293,6 +294,7 @@
                                                  pFile, &column );
         fprintf( file, "\n" );
     }
+    fclose(file);
 }
 
 
diff --git a/win32/cursoricon32.c b/win32/cursoricon32.c
index 0fa0316..c87a784 100644
--- a/win32/cursoricon32.c
+++ b/win32/cursoricon32.c
@@ -372,8 +372,8 @@
     if (!(hRes = GlobalAlloc16( GMEM_MOVEABLE,
                                 sizeof(CURSORICONINFO) + sizeXor + sizeAnd)))
     {
-        DeleteObject( hXorBits );
-        DeleteObject( hAndBits );
+        DeleteObject32( hXorBits );
+        DeleteObject32( hAndBits );
         return 0;
     }
 
@@ -393,8 +393,8 @@
 
     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 86acfa3..041eff0 100644
--- a/windows/caret.c
+++ b/windows/caret.c
@@ -59,9 +59,9 @@
 
     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 @@
         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 @@
     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 c89e96f..d5c3f64 100644
--- a/windows/class.c
+++ b/windows/class.c
@@ -182,7 +182,7 @@
     /* 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 0af441d..d83b8bb 100644
--- a/windows/dce.c
+++ b/windows/dce.c
@@ -87,7 +87,7 @@
 
     DeleteDC( dce->hDC );
     if( dce->hClipRgn && !(dce->DCXflags & DCX_KEEPCLIPRGN) )
-	DeleteObject(dce->hClipRgn);
+	DeleteObject32(dce->hClipRgn);
     HeapFree( SystemHeap, 0, dce );
 }
 
@@ -242,9 +242,9 @@
     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 @@
                     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 @@
 
     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 @@
     
     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 @@
 
 	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 @@
 	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 @@
                 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 @@
       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 @@
 	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 @@
 	    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 @@
                          (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 1b0e853..03a2d22 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 @@
 /***********************************************************************
  *           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 @@
 /***********************************************************************
  *           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 @@
  *
  * 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 @@
  *
  * 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 @@
     
     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 LRESULT DEFDLG_Proc( HWND32 hwnd, UINT32 msg, WPARAM32 wParam,
                             LPARAM lParam, DIALOGINFO *dlgInfo )
 {
-    HWND hwndDefId;
+    HWND32 hwndDefId;
 
     switch(msg)
     {
@@ -138,7 +138,7 @@
 	      /* Delete font */
 	    if (dlgInfo->hUserFont)
 	    {
-		DeleteObject( dlgInfo->hUserFont );
+		DeleteObject32( dlgInfo->hUserFont );
 		dlgInfo->hUserFont = 0;
 	    }
 
@@ -186,7 +186,7 @@
 
 	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 1d3adc3..03b82c3 100644
--- a/windows/defwnd.c
+++ b/windows/defwnd.c
@@ -172,11 +172,11 @@
 
 	    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 @@
     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 @@
 	    {
 		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 0fa7fb1..17a349a 100644
--- a/windows/dialog.c
+++ b/windows/dialog.c
@@ -237,7 +237,7 @@
             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 @@
 	    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 @@
                                 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 e45582c..24ec312 100644
--- a/windows/event.c
+++ b/windows/event.c
@@ -771,7 +771,7 @@
 
         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 @@
         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 06644ad..78abec2 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 @@
 /***********************************************************************
  *           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 @@
 	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 @@
  * 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 @@
 			 (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,10 @@
 
 
 /***********************************************************************
- *           Arc    (GDI.23)
+ *           Arc16    (GDI.23)
  */
-BOOL Arc( HDC16 hdc, INT left, INT top, INT right, INT bottom,
-	  INT xstart, INT ystart, INT xend, INT yend )
+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 );
@@ -209,10 +218,21 @@
 
 
 /***********************************************************************
- *           Pie    (GDI.26)
+ *           Arc32    (GDI32.7)
  */
-BOOL Pie( 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 );
+}
+
+
+/***********************************************************************
+ *           Pie16    (GDI.26)
+ */
+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,21 @@
 
 
 /***********************************************************************
- *           Chord    (GDI.348)
+ *           Pie32   (GDI32.262)
  */
-BOOL Chord( HDC16 hdc, INT left, INT top, INT right, INT bottom,
-	    INT xstart, INT ystart, INT xend, INT yend )
+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 );
@@ -231,9 +262,29 @@
 
 
 /***********************************************************************
- *           Ellipse    (GDI.24)
+ *           Chord32    (GDI32.14)
  */
-BOOL Ellipse( HDC16 hdc, INT left, INT top, INT right, INT bottom )
+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 );
+}
+
+
+/***********************************************************************
+ *           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)
+ */
+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 @@
     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 @@
 
 
 /***********************************************************************
- *           Rectangle    (GDI.27)
+ *           Rectangle16    (GDI.27)
  */
-BOOL Rectangle( HDC16 hdc, INT left, INT top, INT right, INT bottom )
+BOOL16 Rectangle16(HDC16 hdc, INT16 left, INT16 top, INT16 right, INT16 bottom)
+{
+    return Rectangle32( hdc, left, top, right, bottom );
+}
+
+
+/***********************************************************************
+ *           Rectangle32    (GDI32.283)
+ */
+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 @@
     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 @@
 
 
 /***********************************************************************
- *           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 @@
 
     /* 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 @@
      * - 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 @@
  */
 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 @@
     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 @@
 	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 @@
 
 
 /***********************************************************************
- *           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 @@
 
 
 /***********************************************************************
- *           GetPixel    (GDI.83)
+ *           GetPixel16    (GDI.83)
  */
-COLORREF GetPixel( HDC16 hdc, short x, short y )
+COLORREF GetPixel16( HDC16 hdc, INT16 x, INT16 y )
+{
+    return GetPixel32( hdc, x, y );
+}
+
+
+/***********************************************************************
+ *           GetPixel32    (GDI32.211)
+ */
+COLORREF GetPixel32( HDC32 hdc, INT32 x, INT32 y )
 {
     static Pixmap pixmap = 0;
     XImage * image;
@@ -597,7 +685,7 @@
     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 @@
 
 
 /***********************************************************************
- *           PaintRgn    (GDI.43)
+ *           PaintRgn16    (GDI.43)
  */
-BOOL PaintRgn( HDC16 hdc, HRGN32 hrgn )
+BOOL16 PaintRgn16( HDC16 hdc, HRGN16 hrgn )
 {
-    RECT16 box;
+    return PaintRgn32( hdc, hrgn );
+}
+
+
+/***********************************************************************
+ *           PaintRgn32    (GDI32.259)
+ */
+BOOL32 PaintRgn32( HDC32 hdc, HRGN32 hrgn )
+{
+    RECT32 box;
     HRGN32 tmpVisRgn, prevVisRgn;
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc) return FALSE;
@@ -636,18 +733,18 @@
       /* 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 @@
 
 
 /***********************************************************************
- *           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)
- */
-BOOL FrameRgn( HDC16 hdc, HRGN32 hrgn, HBRUSH16 hbrush, int nWidth, int 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;
-}
 
 /***********************************************************************
- *           InvertRgn    (GDI.42)
+ *           FrameRgn16     (GDI.41)
  */
-BOOL InvertRgn( HDC16 hdc, HRGN32 hrgn )
+BOOL16 FrameRgn16( HDC16 hdc, HRGN16 hrgn, HBRUSH16 hbrush,
+                   INT16 nWidth, INT16 nHeight )
 {
-    HBRUSH16 prevBrush = SelectObject( hdc, GetStockObject(BLACK_BRUSH) );
+    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;
+}
+
+
+/***********************************************************************
+ *           InvertRgn16    (GDI.42)
+ */
+BOOL16 InvertRgn16( HDC16 hdc, HRGN16 hrgn )
+{
+    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 @@
  */
 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 @@
     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 @@
 
     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 @@
 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 @@
 	        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 @@
 	        rect->right - rect->left - i, 1, PATCOPY );
     }
 
-    SelectObject( hdc, hbrushOld );
+    SelectObject32( hdc, hbrushOld );
 }
 
 
@@ -896,8 +1025,8 @@
       /* 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 @@
  *
  * 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 @@
 
 
 /**********************************************************************
- *          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 @@
 	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 @@
 
 
 /**********************************************************************
- *          FloodFill  (GDI.25) (GDI32.104)
+ *          FloodFill16   (GDI.25)
  */
-BOOL16 FloodFill( HDC32 hdc, INT32 x, INT32 y, COLORREF color )
+BOOL16 FloodFill16( HDC16 hdc, INT16 x, INT16 y, COLORREF color )
 {
-    return ExtFloodFill( hdc, x, y, color, FLOODFILLBORDER );
+    return ExtFloodFill32( hdc, x, y, color, FLOODFILLBORDER );
+}
+
+
+/**********************************************************************
+ *          FloodFill32   (GDI32.104)
+ */
+BOOL32 FloodFill32( HDC32 hdc, INT32 x, INT32 y, COLORREF color )
+{
+    return ExtFloodFill32( hdc, x, y, color, FLOODFILLBORDER );
 }
 
 
@@ -1088,7 +1236,7 @@
  */
 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 @@
 
     /* 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 @@
 
     /* 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 @@
                                        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 bf32483..dcc5fdf 100644
--- a/windows/hook.c
+++ b/windows/hook.c
@@ -326,7 +326,7 @@
  */
 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 @@
 
 
 /***********************************************************************
- *           UnhookWindowHookEx16   (USER.292)
+ *           UnhookWindowsHookEx16   (USER.292)
  */
 BOOL16 UnhookWindowsHookEx16( HHOOK hhook )
 {
diff --git a/windows/mdi.c b/windows/mdi.c
index 2e73cf4..1e6b45f 100644
--- a/windows/mdi.c
+++ b/windows/mdi.c
@@ -668,17 +668,17 @@
  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 0527dd6..ec0c986 100644
--- a/windows/nonclient.c
+++ b/windows/nonclient.c
@@ -152,12 +152,11 @@
  *
  * 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 @@
         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 @@
  *
  * 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 @@
     {
       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 @@
     {
 	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 @@
     
       /* 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 @@
 {
     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 @@
     
     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 @@
  *
  * 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 @@
     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 @@
             (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 @@
  *
  * 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 @@
  *
  * 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 @@
 
       /* 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 @@
  *
  * 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 @@
  *
  * 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 bce51e0..3edfe8a 100644
--- a/windows/painting.c
+++ b/windows/painting.c
@@ -41,29 +41,30 @@
     {
 	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 @@
         !(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 @@
             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 @@
                 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 @@
 	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 @@
             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 @@
     {
         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 @@
 	       {
                    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 @@
                        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 @@
     {
 	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 @@
  */
 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 @@
         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 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 d06015f..b26ba15 100644
--- a/windows/scroll.c
+++ b/windows/scroll.c
@@ -53,7 +53,7 @@
           else hCaretWnd = 0;
  
 	  hdc = GetDCEx32(hwnd, hrgnClip, DCX_CACHE | DCX_CLIPSIBLINGS);
-          DeleteObject(hrgnClip);
+          DeleteObject32( hrgnClip );
        }
     else	/* clip children */
        {
@@ -71,7 +71,7 @@
     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 @@
       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 @@
     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 @@
       {
         /* 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 @@
 
     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 @@
 	}
 
 	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 11f1ccd..7441be1 100644
--- a/windows/syscolor.c
+++ b/windows/syscolor.c
@@ -57,70 +57,70 @@
     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 4b8e12e..0221627 100644
--- a/windows/win.c
+++ b/windows/win.c
@@ -342,7 +342,7 @@
 
     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 @@
 
     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 @@
 	/* 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 407e824..7d0dd30 100644
--- a/windows/winpos.c
+++ b/windows/winpos.c
@@ -621,7 +621,7 @@
                 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 @@
                 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 @@
     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;
+    WND *wndPrev;
 
-    if (!pWnd->window) return;
-
-    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 @@
     }
     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 @@
     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 @@
     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 @@
 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 @@
      (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 @@
          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 @@
          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 @@
 	 
 	 /* 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 @@
          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 @@
  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 @@
 		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 b1107e8..aa212e7 100644
--- a/windows/winproc.c
+++ b/windows/winproc.c
@@ -1203,7 +1203,7 @@
         {
             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;