Added patch to pass correct itemData to WM_MEASUREITEM when inserting an item to an owner-drawn listbox.

This commit is contained in:
Sebastian Lackner 2016-06-12 18:23:49 +02:00
parent 5924752fd9
commit 2dd175172b
4 changed files with 221 additions and 0 deletions

View File

@ -342,6 +342,7 @@ patch_enable_all ()
enable_user32_PNG_Support="$1"
enable_user32_Refresh_MDI_Menus="$1"
enable_user32_ScrollWindowEx="$1"
enable_user32_WM_MEASUREITEM="$1"
enable_user32_lpCreateParams="$1"
enable_uxtheme_GTK_Theming="$1"
enable_version_GetFileVersionInfoSizeExW="$1"
@ -1208,6 +1209,9 @@ patch_enable ()
user32-ScrollWindowEx)
enable_user32_ScrollWindowEx="$2"
;;
user32-WM_MEASUREITEM)
enable_user32_WM_MEASUREITEM="$2"
;;
user32-lpCreateParams)
enable_user32_lpCreateParams="$2"
;;
@ -7004,6 +7008,20 @@ if test "$enable_user32_ScrollWindowEx" -eq 1; then
) >> "$patchlist"
fi
# Patchset user32-WM_MEASUREITEM
# |
# | Modified files:
# | * dlls/user32/listbox.c, dlls/user32/tests/msg.c
# |
if test "$enable_user32_WM_MEASUREITEM" -eq 1; then
patch_apply user32-WM_MEASUREITEM/0001-user32-tests-Add-a-test-for-WM_MEASUREITEM-when-inse.patch
patch_apply user32-WM_MEASUREITEM/0002-user32-Pass-correct-itemData-to-WM_MEASUREITEM-when-.patch
(
echo '+ { "Dmitry Timoshkov", "user32/tests: Add a test for WM_MEASUREITEM when inserting an item to an owner-drawn listbox.", 2 },';
echo '+ { "Dmitry Timoshkov", "user32: Pass correct itemData to WM_MEASUREITEM when inserting an item to an owner-drawn listbox.", 1 },';
) >> "$patchlist"
fi
# Patchset uxtheme-GTK_Theming
# |
# | This patchset has the following (direct or indirect) dependencies:

View File

@ -0,0 +1,159 @@
From aaee88ae49b34874f485590818efba7eadd7edb4 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Sun, 12 Jun 2016 16:16:48 +0800
Subject: user32/tests: Add a test for WM_MEASUREITEM when inserting an item to
an owner-drawn listbox (v2).
---
dlls/user32/tests/msg.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 75 insertions(+), 4 deletions(-)
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index 5ab639b..6580721 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -3,7 +3,7 @@
*
* Copyright 1999 Ove Kaaven
* Copyright 2003 Dimitrie O. Paun
- * Copyright 2004, 2005 Dmitry Timoshkov
+ * Copyright 2004,2005,2016 Dmitry Timoshkov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -98,6 +98,22 @@ typedef struct
} u;
} DRAW_ITEM_STRUCT;
+/* encoded MEASUREITEMSTRUCT into a WPARAM */
+typedef struct
+{
+ union
+ {
+ struct
+ {
+ UINT CtlType : 4;
+ UINT CtlID : 4;
+ UINT itemID : 4;
+ UINT wParam : 20;
+ } item;
+ WPARAM wp;
+ } u;
+} MEASURE_ITEM_STRUCT;
+
static BOOL test_DestroyWindow_flag;
static HWINEVENTHOOK hEvent_hook;
static HHOOK hKBD_hook;
@@ -1815,6 +1831,25 @@ static BOOL ignore_message( UINT message )
message == WM_DWMNCRENDERINGCHANGED);
}
+static unsigned hash_Ly_W(const WCHAR *str)
+{
+ unsigned hash = 0;
+
+ for (; *str; str++)
+ hash = hash * 1664525u + (unsigned char)(*str) + 1013904223u;
+
+ return hash;
+}
+
+static unsigned hash_Ly(const char *str)
+{
+ unsigned hash = 0;
+
+ for (; *str; str++)
+ hash = hash * 1664525u + (unsigned char)(*str) + 1013904223u;
+
+ return hash;
+}
#define add_message(msg) add_message_(__LINE__,msg);
static void add_message_(int line, const struct recvd_message *msg)
@@ -1919,6 +1954,26 @@ static void add_message_(int line, const struct recvd_message *msg)
seq->lParam = di.u.lp;
break;
}
+
+ case WM_MEASUREITEM:
+ {
+ MEASURE_ITEM_STRUCT mi;
+ MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *)msg->lParam;
+
+ sprintf( seq->output, "%s: %p WM_MEASUREITEM: CtlType %#x, CtlID %#x, itemID %#x, itemData %#lx",
+ msg->descr, msg->hwnd, mis->CtlType, mis->CtlID,
+ mis->itemID, mis->itemData);
+
+ mi.u.wp = 0;
+ mi.u.item.CtlType = mis->CtlType;
+ mi.u.item.CtlID = mis->CtlID;
+ mi.u.item.itemID = mis->itemID;
+ mi.u.item.wParam = msg->wParam;
+ seq->wParam = mi.u.wp;
+ seq->lParam = mis->itemData ? hash_Ly_W((const WCHAR *)mis->itemData) : 0;
+ break;
+ }
+
default:
if (msg->message >= 0xc000) return; /* ignore registered messages */
sprintf( seq->output, "%s: %p %04x wp %08lx lp %08lx",
@@ -8270,8 +8325,8 @@ static LRESULT WINAPI ParentMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam
message == WM_PARENTNOTIFY || message == WM_CANCELMODE ||
message == WM_SETFOCUS || message == WM_KILLFOCUS ||
message == WM_ENABLE || message == WM_ENTERIDLE ||
- message == WM_DRAWITEM || message == WM_COMMAND ||
- message == WM_IME_SETCONTEXT)
+ message == WM_DRAWITEM || message == WM_MEASUREITEM ||
+ message == WM_COMMAND || message == WM_IME_SETCONTEXT)
{
switch (message)
{
@@ -13387,6 +13442,16 @@ static const struct message wm_lb_deletestring_reset[] =
{ WM_DRAWITEM, sent|wparam|parent|optional, ID_LISTBOX },
{ 0 }
};
+static const struct message wm_lb_addstring[] =
+{
+ { LB_ADDSTRING, sent|wparam|lparam, 0, 0xf30604ed },
+ { WM_MEASUREITEM, sent|wparam|lparam|parent, 0xf0f2, 0xf30604ed },
+ { LB_ADDSTRING, sent|wparam|lparam, 0, 0xf30604ee },
+ { WM_MEASUREITEM, sent|wparam|lparam|parent, 0xf1f2, 0xf30604ee },
+ { LB_ADDSTRING, sent|wparam|lparam, 0, 0xf30604ef },
+ { WM_MEASUREITEM, sent|wparam|lparam|parent, 0xf2f2, 0xf30604ef },
+ { 0 }
+};
#define check_lb_state(a1, a2, a3, a4, a5) check_lb_state_dbg(a1, a2, a3, a4, a5, __LINE__)
@@ -13412,7 +13477,10 @@ static LRESULT WINAPI listbox_hook_proc(HWND hwnd, UINT message, WPARAM wp, LPAR
msg.flags = sent|wparam|lparam;
if (defwndproc_counter) msg.flags |= defwinproc;
msg.wParam = wp;
- msg.lParam = lp;
+ if (message == LB_ADDSTRING)
+ msg.lParam = lp ? hash_Ly((const char *)lp) : 0;
+ else
+ msg.lParam = lp;
msg.descr = "listbox";
add_message(&msg);
}
@@ -13456,6 +13524,8 @@ static void test_listbox_messages(void)
check_lb_state(listbox, 0, LB_ERR, 0, 0);
+ flush_sequence();
+
ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 0");
ok(ret == 0, "expected 0, got %ld\n", ret);
ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 1");
@@ -13463,6 +13533,7 @@ static void test_listbox_messages(void)
ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 2");
ok(ret == 2, "expected 2, got %ld\n", ret);
+ ok_sequence(wm_lb_addstring, "LB_ADDSTRING", TRUE);
check_lb_state(listbox, 3, LB_ERR, 0, 0);
flush_sequence();
--
2.8.0

View File

@ -0,0 +1,43 @@
From ed64f216fbfa33dcabf5e33b207d856491a0d360 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Thu, 9 Jun 2016 17:43:19 +0800
Subject: user32: Pass correct itemData to WM_MEASUREITEM when inserting an
item to an owner-drawn listbox.
---
dlls/user32/listbox.c | 4 +++-
dlls/user32/tests/msg.c | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/dlls/user32/listbox.c b/dlls/user32/listbox.c
index b73aa79..1776624 100644
--- a/dlls/user32/listbox.c
+++ b/dlls/user32/listbox.c
@@ -1566,8 +1566,10 @@ static LRESULT LISTBOX_InsertItem( LB_DESCR *descr, INT index,
mis.CtlType = ODT_LISTBOX;
mis.CtlID = id;
mis.itemID = index;
- mis.itemData = descr->items[index].data;
+ mis.itemData = (ULONG_PTR)str;
mis.itemHeight = descr->item_height;
+ TRACE("owner=%p CtlID=%08x, itemID=%08x, itemData=%08lx\n",
+ descr->owner, mis.CtlID, mis.itemID, mis.itemData);
SendMessageW( descr->owner, WM_MEASUREITEM, id, (LPARAM)&mis );
item->height = mis.itemHeight ? mis.itemHeight : 1;
TRACE("[%p]: measure item %d (%s) = %d\n",
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index 6580721..9b853a4 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -13533,7 +13533,7 @@ static void test_listbox_messages(void)
ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 2");
ok(ret == 2, "expected 2, got %ld\n", ret);
- ok_sequence(wm_lb_addstring, "LB_ADDSTRING", TRUE);
+ ok_sequence(wm_lb_addstring, "LB_ADDSTRING", FALSE);
check_lb_state(listbox, 3, LB_ERR, 0, 0);
flush_sequence();
--
2.8.0

View File

@ -0,0 +1 @@
Fixes: Pass correct itemData to WM_MEASUREITEM when inserting an item to an owner-drawn listbox