Alexandre Julliard : user32: Move handling of listbox sizes for Win 3. 1 apps to the 16-bit code.

Alexandre Julliard julliard at winehq.org
Mon Dec 28 09:16:02 CST 2009


Module: wine
Branch: master
Commit: 537877adaee0199e2f28d89c1f69c5a4fc1aeb70
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=537877adaee0199e2f28d89c1f69c5a4fc1aeb70

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Dec 24 21:09:17 2009 +0100

user32: Move handling of listbox sizes for Win 3.1 apps to the 16-bit code.

---

 dlls/user.exe16/message.c |   39 +++++++++++++++++++++++++++++++++++++++
 dlls/user32/listbox.c     |   26 --------------------------
 2 files changed, 39 insertions(+), 26 deletions(-)

diff --git a/dlls/user.exe16/message.c b/dlls/user.exe16/message.c
index ee7fa46..b8a5190 100644
--- a/dlls/user.exe16/message.c
+++ b/dlls/user.exe16/message.c
@@ -584,6 +584,12 @@ static HANDLE16 convert_handle_32_to_16(UINT_PTR src, unsigned int flags)
     return dst;
 }
 
+static BOOL is_old_app( HWND hwnd )
+{
+    HINSTANCE inst = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
+    return inst && !((ULONG_PTR)inst >> 16) && (GetExpWinVer16(LOWORD(inst)) & 0xFF00) == 0x0300;
+}
+
 static int find_sub_menu( HMENU *hmenu, HMENU16 target )
 {
     int i, pos, count = GetMenuItemCount( *hmenu );
@@ -2382,6 +2388,39 @@ static LRESULT listbox_proc16( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam
 
     switch (msg)
     {
+    case WM_SIZE:
+        if (is_old_app( hwnd ))
+        {
+            DWORD style = GetWindowLongW( hwnd, GWL_STYLE );
+            int width, height, remaining, item_height;
+            RECT rect;
+
+            /* give a margin for error to old 16 bits programs - if we need
+               less than the height of the nonclient area, round to the
+               *next* number of items */
+
+            if (!(style & LBS_NOINTEGRALHEIGHT) && !(style & LBS_OWNERDRAWVARIABLE))
+            {
+                GetClientRect( hwnd, &rect );
+                width  = rect.right - rect.left;
+                height = rect.bottom - rect.top;
+                item_height = wow_handlers32.listbox_proc( hwnd, LB_GETITEMHEIGHT, 0, 0, FALSE );
+                remaining = item_height ? (height % item_height) : 0;
+                if ((height > item_height) && remaining)
+                {
+                    GetWindowRect( hwnd, &rect );
+                    if ((item_height - remaining) <= rect.bottom - rect.top - height)
+                        remaining = remaining - item_height;
+                    TRACE( "[%p]: changing height %d -> %d\n", hwnd, height, height - remaining );
+                    SetWindowPos( hwnd, 0, 0, 0, rect.right - rect.left,
+                                  rect.bottom - rect.top - remaining,
+                                  SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE );
+                    return 0;
+                }
+            }
+        }
+        return wow_handlers32.listbox_proc( hwnd, msg, wParam, lParam, unicode );
+
     case LB_RESETCONTENT16:
     case LB_DELETESTRING16:
     case LB_GETITEMDATA16:
diff --git a/dlls/user32/listbox.c b/dlls/user32/listbox.c
index 983eee6..059be04 100644
--- a/dlls/user32/listbox.c
+++ b/dlls/user32/listbox.c
@@ -39,7 +39,6 @@
 #include "windef.h"
 #include "winbase.h"
 #include "wingdi.h"
-#include "wine/winbase16.h"
 #include "wine/unicode.h"
 #include "user_private.h"
 #include "controls.h"
@@ -161,13 +160,6 @@ const struct builtin_class_descr COMBOLBOX_builtin_class =
 };
 
 
-/* check whether app is a Win 3.1 app */
-static inline BOOL is_old_app( LB_DESCR *descr )
-{
-    return (GetExpWinVer16( GetWindowLongPtrW(descr->self, GWLP_HINSTANCE) ) & 0xFF00 ) == 0x0300;
-}
-
-
 /***********************************************************************
  *           LISTBOX_GetCurrentPageSize
  *
@@ -394,14 +386,6 @@ static void LISTBOX_UpdateSize( LB_DESCR *descr )
             remaining = 0;
         if ((descr->height > descr->item_height) && remaining)
         {
-            if (is_old_app(descr))
-            { /* give a margin for error to 16 bits programs - if we need
-                 less than the height of the nonclient area, round to the
-                 *next* number of items */
-                int ncheight = rect.bottom - rect.top - descr->height;
-                if ((descr->item_height - remaining) <= ncheight)
-                    remaining = remaining - descr->item_height;
-            }
             TRACE("[%p]: changing height %d -> %d\n",
                   descr->self, descr->height, descr->height - remaining );
             SetWindowPos( descr->self, 0, 0, 0, rect.right - rect.left,
@@ -2517,16 +2501,6 @@ static BOOL LISTBOX_Create( HWND hwnd, LPHEADCOMBO lphc )
     descr->locale        = GetUserDefaultLCID();
     descr->lphc		 = lphc;
 
-    if (is_old_app(descr) && ( descr->style & ( WS_VSCROLL | WS_HSCROLL ) ) )
-    {
-	/* Win95 document "List Box Differences" from MSDN:
-	   If a list box in a version 3.x application has either the
-	   WS_HSCROLL or WS_VSCROLL style, the list box receives both
-	   horizontal and vertical scroll bars.
-	*/
-	descr->style |= WS_VSCROLL | WS_HSCROLL;
-    }
-
     if( lphc )
     {
         TRACE("[%p]: resetting owner %p -> %p\n", descr->self, descr->owner, lphc->self );




More information about the wine-cvs mailing list