From: Esme Povirk esme@codeweavers.com
--- dlls/comctl32/tests/listbox.c | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
diff --git a/dlls/comctl32/tests/listbox.c b/dlls/comctl32/tests/listbox.c index 9993031fb5f..b707b540aa5 100644 --- a/dlls/comctl32/tests/listbox.c +++ b/dlls/comctl32/tests/listbox.c @@ -40,6 +40,47 @@ enum seq_index
static struct msg_sequence *sequences[NUM_MSG_SEQUENCES];
+static void CALLBACK msg_winevent_proc(HWINEVENTHOOK hevent, + DWORD event, + HWND hwnd, + LONG object_id, + LONG child_id, + DWORD thread_id, + DWORD event_time) +{ + struct message msg = {0}; + char class_name[256]; + + /* ignore window and other system events */ + if (object_id != OBJID_CLIENT) return; + + /* ignore events not from a listbox control */ + if (!GetClassNameA(hwnd, class_name, ARRAY_SIZE(class_name)) || + strcmp(class_name, WC_LISTBOXA) != 0) + return; + + msg.message = event; + msg.flags = winevent_hook|wparam|lparam; + msg.wParam = object_id; + msg.lParam = child_id; + add_message(sequences, LB_SEQ_INDEX, &msg); +} + +static void init_winevent_hook(void) { + hwineventhook = SetWinEventHook(EVENT_MIN, EVENT_MAX, GetModuleHandleA(0), msg_winevent_proc, + 0, GetCurrentThreadId(), WINEVENT_INCONTEXT); + if (!hwineventhook) + win_skip( "no win event hook support\n" ); +} + +static void uninit_winevent_hook(void) { + if (!hwineventhook) + return; + + UnhookWinEvent(hwineventhook); + hwineventhook = 0; +} + /* encoded MEASUREITEMSTRUCT into a WPARAM */ typedef struct { @@ -227,9 +268,13 @@ static void run_test(DWORD style, const struct listbox_test test) static const struct message delete_seq[] = { { LB_DELETESTRING, sent|wparam|lparam, 0, 0 }, + { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 }, { LB_DELETESTRING, sent|wparam|lparam, 0, 0 }, + { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 }, { LB_DELETESTRING, sent|wparam|lparam, 0, 0 }, + { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 }, { LB_DELETESTRING, sent|wparam|lparam, 0, 0 }, + { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 }, { LB_RESETCONTENT, sent|wparam|lparam|defwinproc, 0, 0 }, { 0 } }; @@ -2900,6 +2945,8 @@ START_TEST(listbox)
init_msg_sequences(sequences, NUM_MSG_SEQUENCES);
+ init_winevent_hook(); + test_listbox(); test_item_height(); test_ownerdraw(); @@ -2922,5 +2969,7 @@ START_TEST(listbox) test_LB_FINDSTRING(); test_keypresses();
+ uninit_winevent_hook(); + unload_v6_module(ctx_cookie, hCtx); }