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/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;