[COMCTL32_WINETEST]
authorAmine Khaldi <amine.khaldi@reactos.org>
Sat, 27 Sep 2014 00:19:59 +0000 (00:19 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Sat, 27 Sep 2014 00:19:59 +0000 (00:19 +0000)
* Sync with Wine 1.7.27.
CORE-8540

svn path=/trunk/; revision=64323

rostests/winetests/comctl32/button.c
rostests/winetests/comctl32/imagelist.c
rostests/winetests/comctl32/listview.c
rostests/winetests/comctl32/msg.h
rostests/winetests/comctl32/syslink.c
rostests/winetests/comctl32/tab.c
rostests/winetests/comctl32/toolbar.c
rostests/winetests/comctl32/tooltips.c
rostests/winetests/comctl32/trackbar.c
rostests/winetests/comctl32/treeview.c
rostests/winetests/comctl32/updown.c

index 82cd3c0..5c19d43 100644 (file)
@@ -748,10 +748,10 @@ todo_wine
     ok(lstrcmpW(nameW, WC_BUTTONW), "got %s\n", wine_dbgstr_w(nameW));
 
     ret = GetClassInfoExW(NULL, nameW, &ex2W);
-todo_wine {
+todo_wine
     ok(ret, "got %d\n", ret);
+if (ret) /* TODO: remove once Wine is fixed */
     ok(ex2W.lpfnWndProc == exW.lpfnWndProc, "got %p, %p\n", exW.lpfnWndProc, ex2W.lpfnWndProc);
-}
 
     /* Check reported class name */
     hwnd = create_button(BS_CHECKBOX, NULL);
index d6ee25f..f0fc5e4 100644 (file)
@@ -1481,6 +1481,7 @@ cleanup:
 static void test_iimagelist(void)
 {
     IImageList *imgl, *imgl2;
+    IImageList2 *imagelist;
     HIMAGELIST himl;
     HRESULT hr;
     ULONG ret;
@@ -1545,6 +1546,16 @@ static void test_iimagelist(void)
         IImageList_Release(imgl);
 
     ImageList_Destroy(himl);
+
+    /* IImageList2 */
+    hr = pImageList_CoCreateInstance(&CLSID_ImageList, NULL, &IID_IImageList2, (void**)&imagelist);
+    if (hr != S_OK)
+    {
+        win_skip("IImageList2 is not supported.\n");
+        return;
+    }
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+    IImageList2_Release(imagelist);
 }
 
 static void test_hotspot_v6(void)
index 9acc505..468da56 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright 2006 Mike McCormack for CodeWeavers
  * Copyright 2007 George Gov
- * Copyright 2009-2013 Nikolay Sivov
+ * Copyright 2009-2014 Nikolay Sivov
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
 #include "v6util.h"
 #include "msg.h"
 
-#define PARENT_SEQ_INDEX       0
-#define PARENT_FULL_SEQ_INDEX  1
-#define LISTVIEW_SEQ_INDEX     2
-#define EDITBOX_SEQ_INDEX      3
-#define COMBINED_SEQ_INDEX     4
-#define NUM_MSG_SEQUENCES      5
+enum seq_index {
+    PARENT_SEQ_INDEX,
+    PARENT_FULL_SEQ_INDEX,
+    PARENT_CD_SEQ_INDEX,
+    LISTVIEW_SEQ_INDEX,
+    EDITBOX_SEQ_INDEX,
+    COMBINED_SEQ_INDEX,
+    NUM_MSG_SEQUENCES
+};
 
 #define LISTVIEW_ID 0
 #define HEADER_ID   1
@@ -392,6 +395,26 @@ static const struct message parent_insert_focused_seq[] = {
     { 0 }
 };
 
+static const struct message parent_report_cd_seq[] = {
+    { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_PREPAINT },
+    { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_ITEMPREPAINT },
+    { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_ITEMPREPAINT|CDDS_SUBITEM },
+    { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_ITEMPOSTPAINT|CDDS_SUBITEM },
+    { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_ITEMPREPAINT|CDDS_SUBITEM },
+    { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_ITEMPOSTPAINT|CDDS_SUBITEM },
+    { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_ITEMPOSTPAINT },
+    { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_POSTPAINT },
+    { 0 }
+};
+
+static const struct message parent_list_cd_seq[] = {
+    { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_PREPAINT },
+    { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_ITEMPREPAINT },
+    { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_ITEMPOSTPAINT },
+    { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_POSTPAINT },
+    { 0 }
+};
+
 static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 {
     static LONG defwndproc_counter = 0;
@@ -1761,24 +1784,36 @@ static void test_redraw(void)
     DestroyWindow(hwnd);
 }
 
-static LRESULT WINAPI cd_wndproc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
+static LRESULT WINAPI cd_wndproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 {
     COLORREF clr, c0ffee = RGB(0xc0, 0xff, 0xee);
 
-    if(msg == WM_NOTIFY) {
-        NMHDR *nmhdr = (PVOID)lp;
+    if(message == WM_NOTIFY) {
+        NMHDR *nmhdr = (NMHDR*)lParam;
         if(nmhdr->code == NM_CUSTOMDRAW) {
             NMLVCUSTOMDRAW *nmlvcd = (NMLVCUSTOMDRAW*)nmhdr;
+            struct message msg;
+
+            msg.message = message;
+            msg.flags = sent|wparam|lparam|custdraw;
+            msg.wParam = wParam;
+            msg.lParam = lParam;
+            msg.id = nmhdr->code;
+            msg.stage = nmlvcd->nmcd.dwDrawStage;
+            add_message(sequences, PARENT_CD_SEQ_INDEX, &msg);
 
             switch(nmlvcd->nmcd.dwDrawStage) {
             case CDDS_PREPAINT:
                 SetBkColor(nmlvcd->nmcd.hdc, c0ffee);
-                return CDRF_NOTIFYITEMDRAW;
+                return CDRF_NOTIFYITEMDRAW|CDRF_NOTIFYPOSTPAINT;
             case CDDS_ITEMPREPAINT:
                 nmlvcd->clrTextBk = CLR_DEFAULT;
-                return CDRF_NOTIFYSUBITEMDRAW;
+                nmlvcd->clrText = RGB(0, 255, 0);
+                return CDRF_NOTIFYSUBITEMDRAW|CDRF_NOTIFYPOSTPAINT;
             case CDDS_ITEMPREPAINT | CDDS_SUBITEM:
                 clr = GetBkColor(nmlvcd->nmcd.hdc);
+                ok(nmlvcd->clrTextBk == CLR_DEFAULT, "got 0x%x\n", nmlvcd->clrTextBk);
+                ok(nmlvcd->clrText == RGB(0, 255, 0), "got 0x%x\n", nmlvcd->clrText);
                 if (nmlvcd->iSubItem)
                     todo_wine ok(clr == c0ffee, "clr=%.8x\n", clr);
                 else
@@ -1787,13 +1822,15 @@ static LRESULT WINAPI cd_wndproc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
             case CDDS_ITEMPOSTPAINT | CDDS_SUBITEM:
                 clr = GetBkColor(nmlvcd->nmcd.hdc);
                 todo_wine ok(clr == c0ffee, "clr=%.8x\n", clr);
+                ok(nmlvcd->clrTextBk == CLR_DEFAULT, "got 0x%x\n", nmlvcd->clrTextBk);
+                ok(nmlvcd->clrText == RGB(0, 255, 0), "got 0x%x\n", nmlvcd->clrText);
                 return CDRF_DODEFAULT;
             }
             return CDRF_DODEFAULT;
         }
     }
 
-    return DefWindowProcA(hwnd, msg, wp, lp);
+    return DefWindowProcA(hwnd, message, wParam, lParam);
 }
 
 static void test_customdraw(void)
@@ -1813,9 +1850,27 @@ static void test_customdraw(void)
     InvalidateRect(hwnd, NULL, TRUE);
     UpdateWindow(hwnd);
 
-    SetWindowLongPtrA(hwndparent, GWLP_WNDPROC, (LONG_PTR)oldwndproc);
+    /* message tests */
+    flush_sequences(sequences, NUM_MSG_SEQUENCES);
+    InvalidateRect(hwnd, NULL, TRUE);
+    UpdateWindow(hwnd);
+    ok_sequence(sequences, PARENT_CD_SEQ_INDEX, parent_report_cd_seq, "parent customdraw, LVS_REPORT", FALSE);
 
     DestroyWindow(hwnd);
+
+    hwnd = create_listview_control(LVS_LIST);
+
+    insert_column(hwnd, 0);
+    insert_column(hwnd, 1);
+    insert_item(hwnd, 0);
+
+    flush_sequences(sequences, NUM_MSG_SEQUENCES);
+    InvalidateRect(hwnd, NULL, TRUE);
+    UpdateWindow(hwnd);
+    ok_sequence(sequences, PARENT_CD_SEQ_INDEX, parent_list_cd_seq, "parent customdraw, LVS_LIST", FALSE);
+
+    SetWindowLongPtrA(hwndparent, GWLP_WNDPROC, (LONG_PTR)oldwndproc);
+    DestroyWindow(hwnd);
 }
 
 static void test_icon_spacing(void)
index 71f96e9..2a2ee92 100644 (file)
@@ -38,7 +38,8 @@ typedef enum
     optional = 0x80,
     hook = 0x100,
     winevent_hook =0x200,
-    id = 0x400
+    id = 0x400,
+    custdraw = 0x800
 } msg_flags_t;
 
 struct message
@@ -49,6 +50,7 @@ struct message
     LPARAM lParam;      /* expected value of lParam */
     UINT id;            /* extra message data: id of the window,
                            notify code etc. */
+    DWORD stage;        /* custom draw stage */
 };
 
 struct msg_sequence
@@ -80,12 +82,7 @@ static void add_message(struct msg_sequence **seq, int sequence_index,
 
     assert(msg_seq->sequence);
 
-    msg_seq->sequence[msg_seq->count].message = msg->message;
-    msg_seq->sequence[msg_seq->count].flags = msg->flags;
-    msg_seq->sequence[msg_seq->count].wParam = msg->wParam;
-    msg_seq->sequence[msg_seq->count].lParam = msg->lParam;
-    msg_seq->sequence[msg_seq->count].id = msg->id;
-
+    msg_seq->sequence[msg_seq->count] = *msg;
     msg_seq->count++;
 }
 
@@ -105,6 +102,68 @@ static inline void flush_sequences(struct msg_sequence **seq, int n)
         flush_sequence(seq, i);
 }
 
+static void dump_sequence( struct msg_sequence **seq, int sequence_index,
+                           const struct message *expected, const char *context,
+                           const char *file, int line )
+{
+    struct msg_sequence *msg_seq = seq[sequence_index];
+    const struct message *actual, *sequence;
+    unsigned int count = 0;
+
+    sequence = msg_seq->sequence;
+    actual = sequence;
+
+    trace_(file, line)("Failed sequence %s:\n", context );
+    while (expected->message && actual->message)
+    {
+        trace_(file, line)( "  %u: expected: %04x - actual: %04x wp %08lx lp %08lx\n",
+                            count, expected->message, actual->message, actual->wParam, actual->lParam );
+
+       if (expected->message == actual->message)
+       {
+           if ((expected->flags & defwinproc) != (actual->flags & defwinproc) &&
+                (expected->flags & optional))
+            {
+                /* don't match messages if their defwinproc status differs */
+                expected++;
+            }
+            else
+            {
+                expected++;
+                actual++;
+            }
+       }
+        else
+        {
+            expected++;
+            actual++;
+        }
+        count++;
+    }
+
+    /* optional trailing messages */
+    while (expected->message && expected->flags & optional)
+    {
+        trace_(file, line)( "  %u: expected: msg %04x - actual: nothing\n", count, expected->message );
+       expected++;
+        count++;
+    }
+
+    if (expected->message)
+    {
+        trace_(file, line)( "  %u: expected: msg %04x - actual: nothing\n", count, expected->message );
+        return;
+    }
+
+    while (actual->message)
+    {
+        trace_(file, line)( "  %u: expected: nothing - actual: %04x wp %08lx lp %08lx\n",
+                            count, actual->message, actual->wParam, actual->lParam );
+        actual++;
+        count++;
+    }
+}
+
 static void ok_sequence_(struct msg_sequence **seq, int sequence_index,
     const struct message *expected, const char *context, BOOL todo,
     const char *file, int line)
@@ -112,7 +171,7 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index,
     struct msg_sequence *msg_seq = seq[sequence_index];
     static const struct message end_of_sequence = {0, 0, 0, 0};
     const struct message *actual, *sequence;
-    int failcount = 0;
+    int failcount = 0, dump = 0;
 
     add_message(seq, sequence_index, &end_of_sequence);
 
@@ -121,8 +180,6 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index,
 
     while (expected->message && actual->message)
     {
-        trace_( file, line)("expected %04x - actual %04x\n", expected->message, actual->message);
-
         if (expected->message == actual->message)
         {
             if (expected->flags & wparam)
@@ -132,6 +189,7 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index,
                     todo_wine
                     {
                         failcount++;
+                        dump++;
                         ok_(file, line) (FALSE,
                             "%s: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
                             context, expected->message, expected->wParam, actual->wParam);
@@ -142,6 +200,7 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index,
                     ok_(file, line) (expected->wParam == actual->wParam,
                         "%s: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
                         context, expected->message, expected->wParam, actual->wParam);
+                    if (expected->wParam != actual->wParam) dump++;
                 }
             }
 
@@ -152,6 +211,7 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index,
                     todo_wine
                     {
                         failcount++;
+                        dump++;
                         ok_(file, line) (FALSE,
                             "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
                             context, expected->message, expected->lParam, actual->lParam);
@@ -162,6 +222,29 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index,
                     ok_(file, line) (expected->lParam == actual->lParam,
                         "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
                         context, expected->message, expected->lParam, actual->lParam);
+                    if (expected->lParam != actual->lParam) dump++;
+                }
+            }
+
+            if (expected->flags & custdraw)
+            {
+                if (expected->stage != actual->stage && todo)
+                {
+                    todo_wine
+                    {
+                        failcount++;
+                        dump++;
+                        ok_(file, line) (FALSE,
+                            "%s: in msg 0x%04x expecting cd stage 0x%08x got 0x%08x\n",
+                            context, expected->message, expected->stage, actual->stage);
+                    }
+                }
+                else
+                {
+                    ok_(file, line) (expected->stage == actual->stage,
+                        "%s: in msg 0x%04x expecting cd stage 0x%08x got 0x%08x\n",
+                        context, expected->message, expected->stage, actual->stage);
+                    if (expected->stage != actual->stage) dump++;
                 }
             }
 
@@ -177,6 +260,7 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index,
                     todo_wine
                     {
                         failcount++;
+                        dump++;
                         ok_(file, line) (FALSE,
                             "%s: in msg 0x%04x expecting id 0x%x got 0x%x\n",
                             context, expected->message, expected->id, actual->id);
@@ -187,6 +271,7 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index,
                     ok_(file, line) (expected->id == actual->id,
                         "%s: in msg 0x%04x expecting id 0x%x got 0x%x\n",
                         context, expected->message, expected->id, actual->id);
+                    if (expected->id != actual->id) dump++;
                 }
             }
 
@@ -195,6 +280,7 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index,
                 todo_wine
                 {
                     failcount++;
+                    dump++;
                     ok_(file, line) (FALSE,
                         "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
                         context, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
@@ -205,23 +291,34 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index,
                 ok_(file, line) ((expected->flags & defwinproc) == (actual->flags & defwinproc),
                     "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
                     context, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
+                if ((expected->flags & defwinproc) != (actual->flags & defwinproc)) dump++;
             }
 
             ok_(file, line) ((expected->flags & beginpaint) == (actual->flags & beginpaint),
                 "%s: the msg 0x%04x should %shave been sent by BeginPaint\n",
                 context, expected->message, (expected->flags & beginpaint) ? "" : "NOT ");
+            if ((expected->flags & beginpaint) != (actual->flags & beginpaint)) dump++;
+
             ok_(file, line) ((expected->flags & (sent|posted)) == (actual->flags & (sent|posted)),
                 "%s: the msg 0x%04x should have been %s\n",
                 context, expected->message, (expected->flags & posted) ? "posted" : "sent");
+            if ((expected->flags & (sent|posted)) != (actual->flags & (sent|posted))) dump++;
+
             ok_(file, line) ((expected->flags & parent) == (actual->flags & parent),
                 "%s: the msg 0x%04x was expected in %s\n",
                 context, expected->message, (expected->flags & parent) ? "parent" : "child");
+            if ((expected->flags & parent) != (actual->flags & parent)) dump++;
+
             ok_(file, line) ((expected->flags & hook) == (actual->flags & hook),
                 "%s: the msg 0x%04x should have been sent by a hook\n",
                 context, expected->message);
+            if ((expected->flags & hook) != (actual->flags & hook)) dump++;
+
             ok_(file, line) ((expected->flags & winevent_hook) == (actual->flags & winevent_hook),
                 "%s: the msg 0x%04x should have been sent by a winevent hook\n",
                 context, expected->message);
+            if ((expected->flags & winevent_hook) != (actual->flags & winevent_hook)) dump++;
+
             expected++;
             actual++;
         }
@@ -230,19 +327,19 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index,
         else if (todo)
         {
             failcount++;
+            dump++;
             todo_wine
             {
                 ok_(file, line) (FALSE, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
                     context, expected->message, actual->message);
             }
-
-            flush_sequence(seq, sequence_index);
-            return;
+            goto done;
         }
         else
         {
             ok_(file, line) (FALSE, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
                 context, expected->message, actual->message);
+            dump++;
             expected++;
             actual++;
         }
@@ -259,6 +356,7 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index,
             if (expected->message || actual->message)
             {
                 failcount++;
+                dump++;
                 ok_(file, line) (FALSE, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
                     context, expected->message, actual->message);
             }
@@ -266,18 +364,22 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index,
     }
     else if (expected->message || actual->message)
     {
+        dump++;
         ok_(file, line) (FALSE, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
             context, expected->message, actual->message);
     }
 
     if(todo && !failcount) /* succeeded yet marked todo */
     {
+        dump++;
         todo_wine
         {
             ok_(file, line)(TRUE, "%s: marked \"todo_wine\" but succeeds\n", context);
         }
     }
 
+done:
+    if (dump) dump_sequence( seq, sequence_index, expected, context, file, line );
     flush_sequence(seq, sequence_index);
 }
 
index 0516a1d..a65283a 100644 (file)
@@ -94,8 +94,6 @@ static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LP
         message != WM_GETICON &&
         message != WM_DEVICECHANGE)
     {
-        trace("parent: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
-
         msg.message = message;
         msg.flags = sent|wparam|lparam;
         if (defwndproc_counter) msg.flags |= defwinproc;
@@ -151,8 +149,6 @@ static LRESULT WINAPI syslink_subclass_proc(HWND hwnd, UINT message, WPARAM wPar
     LRESULT ret;
     struct message msg;
 
-    trace("syslink: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
-
     msg.message = message;
     msg.flags = sent|wparam|lparam;
     if (defwndproc_counter) msg.flags |= defwinproc;
index eb36579..6484c9a 100644 (file)
@@ -344,8 +344,6 @@ static LRESULT WINAPI parentWindowProcess(HWND hwnd, UINT message, WPARAM wParam
         message != WM_GETICON &&
         message != WM_DEVICECHANGE)
     {
-        trace("parent: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
-
         msg.message = message;
         msg.flags = sent|wparam|lparam;
         if (defwndproc_counter) msg.flags |= defwinproc;
@@ -409,8 +407,6 @@ static LRESULT WINAPI tabSubclassProcess(HWND hwnd, UINT message, WPARAM wParam,
         message != WM_GETICON &&
         message != WM_DEVICECHANGE)
     {
-        trace("tab: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
-
         msg.message = message;
         msg.flags = sent|wparam|lparam;
         if (defwndproc_counter) msg.flags |= defwinproc;
index c492763..da21924 100644 (file)
@@ -160,7 +160,6 @@ static LRESULT CALLBACK parent_wnd_proc(HWND hWnd, UINT message, WPARAM wParam,
         message != WM_GETICON &&
         message != WM_DEVICECHANGE)
     {
-        trace("parent: %p, %04x, %08lx, %08lx\n", hWnd, message, wParam, lParam);
         add_message(sequences, PARENT_SEQ_INDEX, &msg);
     }
 
index 10d7b3f..272c2e4 100644 (file)
@@ -470,6 +470,7 @@ static void test_ttm_gettoolinfo(void)
     tiW.hwnd = NULL;
     tiW.uId = 0x1234ABCD;
     tiW.lParam = 0xaaaaaaaa;
+    tiW.lpszText = NULL;
     r = SendMessageA(hwnd, TTM_GETTOOLINFOW, 0, (LPARAM)&tiW);
     ok(r, "Getting tooltip info failed\n");
     ok(0x1abe11ed == tiW.lParam ||
index 0583e5f..f49c27d 100644 (file)
@@ -387,8 +387,6 @@ static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LP
         message != WM_GETICON &&
         message != WM_DEVICECHANGE)
     {
-        trace("parent: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
-
         msg.message = message;
         msg.flags = sent|wparam|lparam;
         if (defwndproc_counter) msg.flags |= defwinproc;
@@ -436,8 +434,6 @@ static LRESULT WINAPI trackbar_subclass_proc(HWND hwnd, UINT message, WPARAM wPa
     LRESULT ret;
     struct message msg;
 
-    trace("trackbar: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
-
     msg.message = message;
     msg.flags = sent|wparam|lparam;
     if (defwndproc_counter) msg.flags |= defwinproc;
index 684543c..aae3e9b 100644 (file)
@@ -40,10 +40,12 @@ static BOOL g_get_rect_in_expand;
 static BOOL g_disp_A_to_W;
 static BOOL g_disp_set_stateimage;
 static BOOL g_beginedit_alter_text;
+static HFONT g_customdraw_font;
 
-#define NUM_MSG_SEQUENCES   2
+#define NUM_MSG_SEQUENCES   3
 #define TREEVIEW_SEQ_INDEX  0
 #define PARENT_SEQ_INDEX    1
+#define PARENT_CD_SEQ_INDEX 2
 
 #define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
 
@@ -204,7 +206,7 @@ static const struct message parent_expand_seq[] = {
 };
 
 static const struct message parent_expand_kb_seq[] = {
-    { WM_NOTIFY, sent|id|optional, 0, 0, TVN_KEYDOWN },
+    { WM_NOTIFY, sent|id, 0, 0, TVN_KEYDOWN },
     { WM_NOTIFY, sent|id, 0, 0, TVN_ITEMEXPANDINGA },
     { WM_NOTIFY, sent|id, 0, 0, TVN_ITEMEXPANDEDA },
     { WM_CHANGEUISTATE, sent|optional },
@@ -219,7 +221,7 @@ static const struct message parent_collapse_2nd_kb_seq[] = {
 };
 
 static const struct message parent_expand_empty_kb_seq[] = {
-    { WM_NOTIFY, sent|id|optional, 0, 0, TVN_KEYDOWN },
+    { WM_NOTIFY, sent|id, 0, 0, TVN_KEYDOWN },
     { WM_CHANGEUISTATE, sent|optional },
     { 0 }
 };
@@ -242,6 +244,21 @@ static const struct message empty_seq[] = {
     { 0 }
 };
 
+static const struct message parent_cd_seq[] = {
+    { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_PREPAINT },
+    { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_ITEMPREPAINT },
+    { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_ITEMPOSTPAINT },
+    { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_POSTPAINT },
+    { 0 }
+};
+
+static const struct message parent_vk_return_seq[] = {
+    { WM_NOTIFY, sent|id, 0, 0, TVN_KEYDOWN },
+    { WM_NOTIFY, sent|id, 0, 0, NM_RETURN },
+    { WM_CHANGEUISTATE, sent|optional },
+    { 0 }
+};
+
 static HWND hMainWnd;
 
 static HTREEITEM hRoot, hChild;
@@ -1017,7 +1034,6 @@ static LRESULT CALLBACK parent_wnd_proc(HWND hWnd, UINT message, WPARAM wParam,
         message != WM_GETICON &&
         message != WM_DEVICECHANGE)
     {
-        trace("parent: %p, %04x, %08lx, %08lx\n", hWnd, message, wParam, lParam);
         add_message(sequences, PARENT_SEQ_INDEX, &msg);
     }
 
@@ -1149,6 +1165,38 @@ static LRESULT CALLBACK parent_wnd_proc(HWND hWnd, UINT message, WPARAM wParam,
 
                 break;
             }
+            case NM_CUSTOMDRAW:
+            {
+                NMTVCUSTOMDRAW *nmcd = (NMTVCUSTOMDRAW*)lParam;
+                COLORREF c0ffee = RGB(0xc0,0xff,0xee), cafe = RGB(0xca,0xfe,0x00);
+
+                msg.flags |= custdraw;
+                msg.stage = nmcd->nmcd.dwDrawStage;
+                add_message(sequences, PARENT_CD_SEQ_INDEX, &msg);
+
+                switch (msg.stage)
+                {
+                case CDDS_PREPAINT:
+                    return CDRF_NOTIFYITEMDRAW|CDRF_NOTIFYITEMERASE|CDRF_NOTIFYPOSTPAINT;
+                case CDDS_ITEMPREPAINT:
+                    nmcd->clrTextBk = c0ffee;
+                    nmcd->clrText = cafe;
+                    if (g_customdraw_font)
+                        SelectObject(nmcd->nmcd.hdc, g_customdraw_font);
+                    return CDRF_NOTIFYPOSTPAINT|CDRF_NEWFONT;
+                case CDDS_ITEMPOSTPAINT:
+                    /* at the point of post paint notification colors are already restored */
+                    ok(GetTextColor(nmcd->nmcd.hdc) != cafe, "got 0%x\n", GetTextColor(nmcd->nmcd.hdc));
+                    ok(GetBkColor(nmcd->nmcd.hdc) != c0ffee, "got 0%x\n", GetBkColor(nmcd->nmcd.hdc));
+                    if (g_customdraw_font)
+                        ok(GetCurrentObject(nmcd->nmcd.hdc, OBJ_FONT) != g_customdraw_font, "got %p\n",
+                           GetCurrentObject(nmcd->nmcd.hdc, OBJ_FONT));
+                    break;
+                default:
+                    ;
+                }
+                break;
+            }
             }
         }
         break;
@@ -2053,6 +2101,60 @@ static void test_WM_GETDLGCODE(void)
     DestroyWindow(hTree);
 }
 
+static void test_customdraw(void)
+{
+    static const char *rootA = "root";
+    TVINSERTSTRUCTA ins;
+    HTREEITEM hRoot;
+    LOGFONTA lf;
+    HWND hwnd;
+
+    hwnd = create_treeview_control(0);
+
+    ins.hParent = TVI_ROOT;
+    ins.hInsertAfter = TVI_ROOT;
+    U(ins).item.mask = TVIF_TEXT;
+    U(ins).item.pszText = (char*)rootA;
+    hRoot = TreeView_InsertItemA(hwnd, &ins);
+    ok(hRoot != NULL, "got %p\n", hRoot);
+
+    /* create additional font, custom draw handler will select it */
+    SystemParametersInfoA(SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0);
+    lf.lfHeight *= 2;
+    g_customdraw_font = CreateFontIndirectA(&lf);
+    flush_sequences(sequences, NUM_MSG_SEQUENCES);
+    InvalidateRect(hwnd, NULL, TRUE);
+    UpdateWindow(hwnd);
+    ok_sequence(sequences, PARENT_CD_SEQ_INDEX, parent_cd_seq, "custom draw notifications", FALSE);
+    DeleteObject(g_customdraw_font);
+    g_customdraw_font = NULL;
+
+    DestroyWindow(hwnd);
+}
+
+static void test_WM_KEYDOWN(void)
+{
+    static const char *rootA = "root";
+    TVINSERTSTRUCTA ins;
+    HTREEITEM hRoot;
+    HWND hwnd;
+
+    hwnd = create_treeview_control(0);
+
+    ins.hParent = TVI_ROOT;
+    ins.hInsertAfter = TVI_ROOT;
+    U(ins).item.mask = TVIF_TEXT;
+    U(ins).item.pszText = (char*)rootA;
+    hRoot = TreeView_InsertItemA(hwnd, &ins);
+    ok(hRoot != NULL, "got %p\n", hRoot);
+
+    flush_sequences(sequences, NUM_MSG_SEQUENCES);
+    SendMessageA(hwnd, WM_KEYDOWN, VK_RETURN, 0);
+    ok_sequence(sequences, PARENT_SEQ_INDEX, parent_vk_return_seq, "WM_KEYDOWN/VK_RETURN parent notification", TRUE);
+
+    DestroyWindow(hwnd);
+}
+
 START_TEST(treeview)
 {
     HMODULE hComctl32;
@@ -2126,6 +2228,8 @@ START_TEST(treeview)
     test_TVM_GETNEXTITEM();
     test_TVM_HITTEST();
     test_WM_GETDLGCODE();
+    test_customdraw();
+    test_WM_KEYDOWN();
 
     if (!load_v6_module(&ctx_cookie, &hCtx))
     {
index ed7d95b..8a963d9 100644 (file)
@@ -182,8 +182,6 @@ static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LP
         message != WM_GETICON &&
         message != WM_DEVICECHANGE)
     {
-        trace("parent: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
-
         msg.message = message;
         msg.flags = sent|wparam|lparam;
         if (defwndproc_counter) msg.flags |= defwinproc;
@@ -237,8 +235,6 @@ static LRESULT WINAPI edit_subclass_proc(HWND hwnd, UINT message, WPARAM wParam,
     LRESULT ret;
     struct message msg;
 
-    trace("edit: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
-
     msg.message = message;
     msg.flags = sent|wparam|lparam;
     if (defwndproc_counter) msg.flags |= defwinproc;
@@ -279,8 +275,6 @@ static LRESULT WINAPI updown_subclass_proc(HWND hwnd, UINT message, WPARAM wPara
     LRESULT ret;
     struct message msg;
 
-    trace("updown: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
-
     msg.message = message;
     msg.flags = sent|wparam|lparam;
     if (defwndproc_counter) msg.flags |= defwinproc;