From 95591a6e9096756bcaf3786d28e79e0698e79598 Mon Sep 17 00:00:00 2001
From: Michael Stefaniuc <mstefani@redhat.de>
Date: Mon, 28 Oct 2002 20:11:40 +0000
Subject: [PATCH] Some fixes for the compilation of the user dll with -DSTRICT.

---
 controls/button.c   | 37 +++++++++++++++++++++----------------
 controls/listbox.c  | 14 +++++++-------
 dlls/user/exticon.c |  2 +-
 dlls/user/message.c |  2 +-
 dlls/user/wnd16.c   | 11 ++++++-----
 windows/defdlg.c    |  6 +++---
 windows/mdi.c       |  6 +++---
 7 files changed, 42 insertions(+), 36 deletions(-)

diff --git a/controls/button.c b/controls/button.c
index 5d87b8036fd..c0e7790c556 100644
--- a/controls/button.c
+++ b/controls/button.c
@@ -124,12 +124,12 @@ inline static void set_button_state( HWND hwnd, LONG state )
 
 inline static HFONT get_button_font( HWND hwnd )
 {
-    return GetWindowLongA( hwnd, HFONT_GWL_OFFSET );
+    return (HFONT)GetWindowLongA( hwnd, HFONT_GWL_OFFSET );
 }
 
 inline static void set_button_font( HWND hwnd, HFONT font )
 {
-    SetWindowLongA( hwnd, HFONT_GWL_OFFSET, font );
+    SetWindowLongA( hwnd, HFONT_GWL_OFFSET, (LONG)font );
 }
 
 inline static UINT get_button_type( LONG window_style )
@@ -308,9 +308,11 @@ static LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
         HBRUSH hbrush;
         RECT client, rc;
 
-        hbrush = SendMessageW(GetParent(hWnd), WM_CTLCOLORSTATIC, hdc, (LPARAM)hWnd);
+        hbrush = (HBRUSH)SendMessageW(GetParent(hWnd), WM_CTLCOLORSTATIC,
+				      (WPARAM)hdc, (LPARAM)hWnd);
         if (!hbrush) /* did the app forget to call DefWindowProc ? */
-            hbrush = DefWindowProcW(GetParent(hWnd), WM_CTLCOLORSTATIC, hdc, (LPARAM)hWnd);
+            hbrush = (HBRUSH)DefWindowProcW(GetParent(hWnd), WM_CTLCOLORSTATIC,
+					    (WPARAM)hdc, (LPARAM)hWnd);
 
         GetClientRect(hWnd, &client);
         rc = client;
@@ -331,12 +333,12 @@ static LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
     }
 
     case WM_SETFONT:
-        set_button_font( hWnd, wParam );
+        set_button_font( hWnd, (HFONT)wParam );
         if (lParam) paint_button( hWnd, btn_type, ODA_DRAWENTIRE );
         break;
 
     case WM_GETFONT:
-        return get_button_font( hWnd );
+        return (LRESULT)get_button_font( hWnd );
 
     case WM_SETFOCUS:
         if ((btn_type == BS_RADIOBUTTON || btn_type == BS_AUTORADIOBUTTON) && (GetCapture() != hWnd) &&
@@ -394,9 +396,9 @@ static LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
         default:
             return 0;
         }
-        oldHbitmap = SetWindowLongA( hWnd, HIMAGE_GWL_OFFSET, lParam );
+        oldHbitmap = (HBITMAP)SetWindowLongA( hWnd, HIMAGE_GWL_OFFSET, lParam );
 	InvalidateRect( hWnd, NULL, FALSE );
-	return oldHbitmap;
+	return (LRESULT)oldHbitmap;
 
     case BM_GETIMAGE:
         return GetWindowLongA( hWnd, HIMAGE_GWL_OFFSET );
@@ -716,7 +718,7 @@ static void PB_Paint( HWND hwnd, HDC hDC, UINT action )
 
     /* Send WM_CTLCOLOR to allow changing the font (the colors are fixed) */
     if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont );
-    SendMessageW( GetParent(hwnd), WM_CTLCOLORBTN, hDC, (LPARAM)hwnd );
+    SendMessageW( GetParent(hwnd), WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd );
     hOldPen = (HPEN)SelectObject(hDC, SYSCOLOR_GetPen(COLOR_WINDOWFRAME));
     hOldBrush =(HBRUSH)SelectObject(hDC,GetSysColorBrush(COLOR_BTNFACE));
     oldBkMode = SetBkMode(hDC, TRANSPARENT);
@@ -841,9 +843,11 @@ static void CB_Paint( HWND hwnd, HDC hDC, UINT action )
 
     if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont );
 
-    hBrush = SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC, hDC, (LPARAM)hwnd );
+    hBrush = (HBRUSH)SendMessageW(GetParent(hwnd), WM_CTLCOLORSTATIC,
+				  (WPARAM)hDC, (LPARAM)hwnd);
     if (!hBrush) /* did the app forget to call defwindowproc ? */
-        hBrush = DefWindowProcW( GetParent(hwnd), WM_CTLCOLORSTATIC, hDC, (LPARAM)hwnd );
+        hBrush = (HBRUSH)DefWindowProcW(GetParent(hwnd), WM_CTLCOLORSTATIC,
+					(WPARAM)hDC, (LPARAM)hwnd );
 
     if (style & BS_LEFTTEXT)
     {
@@ -989,9 +993,10 @@ static void GB_Paint( HWND hwnd, HDC hDC, UINT action )
 
     if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont );
     /* GroupBox acts like static control, so it sends CTLCOLORSTATIC */
-    hbr = SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC, hDC, (LPARAM)hwnd );
+    hbr = (HBRUSH)SendMessageW(GetParent(hwnd), WM_CTLCOLORSTATIC, (WPARAM)hDC, (LPARAM)hwnd);
     if (!hbr) /* did the app forget to call defwindowproc ? */
-        hbr = DefWindowProcW( GetParent(hwnd), WM_CTLCOLORSTATIC, hDC, (LPARAM)hwnd );
+        hbr = (HBRUSH)DefWindowProcW(GetParent(hwnd), WM_CTLCOLORSTATIC,
+				     (WPARAM)hDC, (LPARAM)hwnd);
 
     GetClientRect( hwnd, &rc);
     if (TWEAK_WineLook == WIN31_LOOK) {
@@ -1049,9 +1054,10 @@ static void UB_Paint( HWND hwnd, HDC hDC, UINT action )
 
     if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont );
 
-    hBrush = SendMessageW( GetParent(hwnd), WM_CTLCOLORBTN, hDC, (LPARAM)hwnd );
+    hBrush = (HBRUSH)SendMessageW(GetParent(hwnd), WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd);
     if (!hBrush) /* did the app forget to call defwindowproc ? */
-        hBrush = DefWindowProcW( GetParent(hwnd), WM_CTLCOLORBTN, hDC, (LPARAM)hwnd );
+        hBrush = (HBRUSH)DefWindowProcW(GetParent(hwnd), WM_CTLCOLORBTN,
+					(WPARAM)hDC, (LPARAM)hwnd);
 
     FillRect( hDC, &rc, hBrush );
     if ((action == ODA_FOCUS) ||
@@ -1098,4 +1104,3 @@ static void OB_Paint( HWND hwnd, HDC hDC, UINT action )
     SendMessageW( GetParent(hwnd), WM_DRAWITEM, id, (LPARAM)&dis );
     SelectClipRgn(hDC, clipRegion);
 }
-
diff --git a/controls/listbox.c b/controls/listbox.c
index fd221950b18..23d70da82d4 100644
--- a/controls/listbox.c
+++ b/controls/listbox.c
@@ -691,8 +691,8 @@ static void LISTBOX_RepaintItem( HWND hwnd, LB_DESCR *descr, INT index,
     if (LISTBOX_GetItemRect( descr, index, &rect ) != 1) return;
     if (!(hdc = GetDCEx( hwnd, 0, DCX_CACHE ))) return;
     if (descr->font) oldFont = SelectObject( hdc, descr->font );
-    hbrush = SendMessageW( descr->owner, WM_CTLCOLORLISTBOX,
-                             hdc, (LPARAM)hwnd );
+    hbrush = (HBRUSH)SendMessageW( descr->owner, WM_CTLCOLORLISTBOX,
+				   (WPARAM)hdc, (LPARAM)hwnd );
     if (hbrush) oldBrush = SelectObject( hdc, hbrush );
     if (!IsWindowEnabled(hwnd))
         SetTextColor( hdc, GetSysColor( COLOR_GRAYTEXT ) );
@@ -1012,8 +1012,8 @@ static LRESULT LISTBOX_Paint( HWND hwnd, LB_DESCR *descr, HDC hdc )
     }
 
     if (descr->font) oldFont = SelectObject( hdc, descr->font );
-    hbrush = SendMessageW( descr->owner, WM_CTLCOLORLISTBOX,
-                             hdc, (LPARAM)hwnd );
+    hbrush = (HBRUSH)SendMessageW( descr->owner, WM_CTLCOLORLISTBOX,
+			   	   (WPARAM)hdc, (LPARAM)hwnd );
     if (hbrush) oldBrush = SelectObject( hdc, hbrush );
     if (!IsWindowEnabled(hwnd)) SetTextColor( hdc, GetSysColor( COLOR_GRAYTEXT ) );
 
@@ -2245,7 +2245,7 @@ static LRESULT LISTBOX_HandleKeyDown( HWND hwnd, LB_DESCR *descr, WPARAM wParam
     {
         caret = SendMessageW( descr->owner, WM_VKEYTOITEM,
                                 MAKEWPARAM(LOWORD(wParam), descr->focus_item),
-                                hwnd );
+                                (LPARAM)hwnd );
         if (caret == -2) return 0;
     }
     if (caret == -1) switch(wParam)
@@ -2926,7 +2926,7 @@ static LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg,
         LISTBOX_UpdateSize( hwnd, descr );
         return 0;
     case WM_GETFONT:
-        return descr->font;
+        return (LRESULT)descr->font;
     case WM_SETFONT:
         LISTBOX_SetFont( hwnd, descr, (HFONT)wParam );
         if (lParam) InvalidateRect( hwnd, 0, TRUE );
@@ -2987,7 +2987,7 @@ static LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg,
         if ((IS_OWNERDRAW(descr)) && !(descr->style & LBS_DISPLAYCHANGED))
         {
             RECT rect;
-            HBRUSH hbrush = SendMessageW( descr->owner, WM_CTLCOLORLISTBOX,
+            HBRUSH hbrush = (HBRUSH)SendMessageW( descr->owner, WM_CTLCOLORLISTBOX,
                                               wParam, (LPARAM)hwnd );
 	    TRACE("hbrush = %04x\n", hbrush);
 	    if(!hbrush)
diff --git a/dlls/user/exticon.c b/dlls/user/exticon.c
index 647729d9605..5564e28c9c7 100644
--- a/dlls/user/exticon.c
+++ b/dlls/user/exticon.c
@@ -250,7 +250,7 @@ static HRESULT ICO_ExtractIconExW(
 	UINT cxDesired,
 	UINT cyDesired )
 {
-	HGLOBAL		hRet = E_FAIL;
+	HRESULT		hRet = E_FAIL;
 	LPBYTE		pData;
 	DWORD		sig;
 	HANDLE		hFile;
diff --git a/dlls/user/message.c b/dlls/user/message.c
index 1b433265344..1bcaf07fd17 100644
--- a/dlls/user/message.c
+++ b/dlls/user/message.c
@@ -1061,7 +1061,7 @@ static LRESULT handle_internal_message( HWND hwnd, UINT msg, WPARAM wparam, LPAR
     case WM_WINE_ENABLEWINDOW:
         return EnableWindow( hwnd, wparam );
     case WM_WINE_SETACTIVEWINDOW:
-        return SetActiveWindow( (HWND)wparam );
+        return (LRESULT)SetActiveWindow( (HWND)wparam );
     default:
         FIXME( "unknown internal message %x\n", msg );
         return 0;
diff --git a/dlls/user/wnd16.c b/dlls/user/wnd16.c
index 7ff45a247fe..e0659975123 100644
--- a/dlls/user/wnd16.c
+++ b/dlls/user/wnd16.c
@@ -24,8 +24,9 @@
 #include "win.h"
 #include "stackframe.h"
 
-/* handle --> handle16 conversions */
+/* handle <--> handle16 conversions */
 #define HANDLE_16(h32)		(LOWORD(h32))
+#define HANDLE_32(h16)		((HANDLE)(ULONG_PTR)(h16))
 
 static HWND16 hwndSysModal;
 
@@ -131,7 +132,7 @@ HANDLE16 WINAPI GetProp16( HWND16 hwnd, LPCSTR str )
  */
 BOOL16 WINAPI SetProp16( HWND16 hwnd, LPCSTR str, HANDLE16 handle )
 {
-    return SetPropA( WIN_Handle32(hwnd), str, handle );
+    return SetPropA( WIN_Handle32(hwnd), str, HANDLE_32(handle) );
 }
 
 
@@ -257,7 +258,7 @@ HDC16 WINAPI BeginPaint16( HWND16 hwnd, LPPAINTSTRUCT16 lps )
     PAINTSTRUCT ps;
 
     BeginPaint( WIN_Handle32(hwnd), &ps );
-    lps->hdc            = ps.hdc;
+    lps->hdc            = HDC_16(ps.hdc);
     lps->fErase         = ps.fErase;
     lps->rcPaint.top    = ps.rcPaint.top;
     lps->rcPaint.left   = ps.rcPaint.left;
@@ -276,7 +277,7 @@ BOOL16 WINAPI EndPaint16( HWND16 hwnd, const PAINTSTRUCT16* lps )
 {
     PAINTSTRUCT ps;
 
-    ps.hdc = lps->hdc;
+    ps.hdc = HDC_32(lps->hdc);
     return EndPaint( WIN_Handle32(hwnd), &ps );
 }
 
@@ -1153,7 +1154,7 @@ HWND16 WINAPI GetOpenClipboardWindow16(void)
  */
 HDWP16 WINAPI BeginDeferWindowPos16( INT16 count )
 {
-    return BeginDeferWindowPos( count );
+    return HDWP_16(BeginDeferWindowPos( count ));
 }
 
 
diff --git a/windows/defdlg.c b/windows/defdlg.c
index a10f6495a72..e1a7865865b 100644
--- a/windows/defdlg.c
+++ b/windows/defdlg.c
@@ -168,8 +168,8 @@ static LRESULT DEFDLG_Proc( HWND hwnd, UINT msg, WPARAM wParam,
     {
         case WM_ERASEBKGND:
         {
-            HBRUSH brush = SendMessageW( hwnd, WM_CTLCOLORDLG, wParam, (LPARAM)hwnd );
-            if (!brush) brush = DefWindowProcW( hwnd, WM_CTLCOLORDLG, wParam, (LPARAM)hwnd );
+            HBRUSH brush = (HBRUSH)SendMessageW( hwnd, WM_CTLCOLORDLG, wParam, (LPARAM)hwnd );
+            if (!brush) brush = (HBRUSH)DefWindowProcW( hwnd, WM_CTLCOLORDLG, wParam, (LPARAM)hwnd );
             if (brush)
             {
                 RECT rect;
@@ -252,7 +252,7 @@ static LRESULT DEFDLG_Proc( HWND hwnd, UINT msg, WPARAM wParam,
 	    return DefWindowProcA( hwnd, msg, wParam, lParam );
 
 	case WM_GETFONT:
-            return dlgInfo ? dlgInfo->hUserFont : 0;
+            return dlgInfo ? (LRESULT)dlgInfo->hUserFont : 0;
 
         case WM_CLOSE:
             PostMessageA( hwnd, WM_COMMAND, IDCANCEL,
diff --git a/windows/mdi.c b/windows/mdi.c
index ad9d058627d..eb713af424d 100644
--- a/windows/mdi.c
+++ b/windows/mdi.c
@@ -186,7 +186,7 @@ const struct builtin_class_descr MDICLIENT_builtin_class =
     MDIClientWndProcW,      /* procW */
     sizeof(MDICLIENTINFO),  /* extra */
     IDC_ARROWA,             /* cursor */
-    COLOR_APPWORKSPACE+1    /* brush */
+    (HBRUSH)(COLOR_APPWORKSPACE+1)    /* brush */
 };
 
 
@@ -439,7 +439,7 @@ static LRESULT MDISetMenu( HWND hwnd, HMENU hmenuFrame,
         {
             if( ci->hwndChildMaximized )
                 MDI_AugmentFrameMenu( GetParent(hwnd), ci->hwndChildMaximized );
-            return oldFrameMenu;
+            return (LRESULT)oldFrameMenu;
         }
     }
     else
@@ -477,7 +477,7 @@ static LRESULT MDIRefreshMenu( HWND hwnd, HMENU hmenuFrame,
 
     FIXME("partially function stub\n");
 
-    return oldFrameMenu;
+    return (LRESULT)oldFrameMenu;
 }
 
 
-- 
GitLab