listbox: Fix WM_DRAWITEM call

Francois Gouget fgouget at codeweavers.com
Thu Aug 4 17:31:47 CDT 2005


 > Log message:
 >         Dmitry Timoshkov <dmitry at codeweavers.com>
 >         - Add an ownerdrawn listbox test, which confirms that on
 > WM_DRAWITEM
 >         parent receives a clipbox equal to a listbox's client area.
 >         - WM_DRAWITEM message contains 0 in wparam (at least on
 > win2k).

The second part of the above patch is incorrect as Dmitry noticed 
already I believe.

I ran the listbox test on Windows and first had to get it past the 
CreateWindow(): Windows will not allow a control with no parent to have 
an id. See my other patch to dlls/user/tests/win.c.

Then it became clear that WM_DRAWITEM does store the control id in 
WPARAM. This is confirmed by running the test on Windows 98, NT4 and 
Windows 2003, although on some runs we never get into main_window_proc().

So I fixed the test and LISTBOX_PaintItem() accordingly and this also 
fixed a display glitch in an installer I worked on.


Changelog:

  * dlls/user/listbox.c
    dlls/user/tests/listbox.c

    Francois Gouget <fgouget at codeweavers.com>
    The listbox test shows that the control id must be stored in WPARAM 
for the WM_DRAWITEM message.
    Fix the listbox test so CreateWindow() does not fail on Windows.


-- 
Francois Gouget
fgouget at codeweavers.com

-------------- next part --------------
Index: dlls/user/listbox.c
===================================================================
RCS file: /var/cvs/wine/dlls/user/listbox.c,v
retrieving revision 1.18
diff -u -p -r1.18 listbox.c
--- dlls/user/listbox.c	29 Jul 2005 14:42:19 -0000	1.18
+++ dlls/user/listbox.c	4 Aug 2005 04:23:28 -0000
@@ -578,7 +578,7 @@ static void LISTBOX_PaintItem( LB_DESCR 
         TRACE("[%p]: drawitem %d (%s) action=%02x state=%02x rect=%ld,%ld-%ld,%ld\n",
               descr->self, index, item ? debugstr_w(item->str) : "", action,
               dis.itemState, rect->left, rect->top, rect->right, rect->bottom );
-        SendMessageW(descr->owner, WM_DRAWITEM, 0, (LPARAM)&dis);
+        SendMessageW(descr->owner, WM_DRAWITEM, dis.CtlID, (LPARAM)&dis);
     }
     else
     {
Index: dlls/user/tests/listbox.c
===================================================================
RCS file: /var/cvs/wine/dlls/user/tests/listbox.c,v
retrieving revision 1.9
diff -u -p -r1.9 listbox.c
--- dlls/user/tests/listbox.c	29 Jul 2005 14:42:19 -0000	1.9
+++ dlls/user/tests/listbox.c	3 Aug 2005 22:37:11 -0000
@@ -47,10 +47,14 @@ static const char * const strings[4] = {
 static HWND
 create_listbox (DWORD add_style, HWND parent)
 {
-  HWND handle=CreateWindow ("LISTBOX", "TestList",
+  HWND handle;
+  int ctl_id=0;
+  if (parent)
+    ctl_id=1;
+  handle=CreateWindow ("LISTBOX", "TestList",
                             (LBS_STANDARD & ~LBS_SORT) | add_style,
                             0, 0, 100, 100,
-                            parent, (HMENU)1, NULL, 0);
+                            parent, (HMENU)ctl_id, NULL, 0);
 
   assert (handle);
   SendMessage (handle, LB_ADDSTRING, 0, (LPARAM) (LPCTSTR) strings[0]);
@@ -212,7 +216,8 @@ static LRESULT WINAPI main_window_proc(H
 
         trace("%p WM_DRAWITEM %08x %08lx\n", hwnd, wparam, lparam);
 
-        ok(wparam == 0, "wrong wparam %04x\n", wparam);
+        ok(wparam == dis->CtlID, "got wParam=%08x instead of %08x\n",
+			wparam, dis->CtlID);
         ok(dis->CtlType == ODT_LISTBOX, "wrong CtlType %04x\n", dis->CtlType);
 
         GetClientRect(dis->hwndItem, &rc_client);


More information about the wine-patches mailing list