Commit 537877ad authored by Alexandre Julliard's avatar Alexandre Julliard

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

parent 21ddb9f4
......@@ -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:
......
......@@ -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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment