I have two puzzles about these code:
> index = 0xdeadbeef;
> PostMessageA(hWnd, WM_DDE_FIRST, 0, 0);
> PostQuitMessage(44);
> thread = CreateThread(NULL, 0, post_message_thread, hWnd, 0, &tid);
> ok(thread != NULL, "CreateThread failed, error %u\n", GetLastError());
> hr = CoWaitForMultipleHandles(0, 100, 2, handles, &index);
> ok(hr == RPC_S_CALLPENDING, "expected RPC_S_CALLPENDING, got 0x%08x\n", hr);
> ok(index == 0 || broken(index == 0xdeadbeef) /* Win 8 */, "expected index 0, got %u\n", index);
> success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE);
> ok(success, "PeekMessageA failed, error %u\n", GetLastError());
The first, why use the PeekMessage to check if received a WM_DDE_FIRST message?
Is there an real application do like that way?
In fact CoWaitForMultipleHandles has a message loop, the WM_DDE_FIRST message has been
dispatched to the window's WNDPROC. So the PeekMessageA certainly failed.
I think the correct test should be this:
1, Define a custom WNDPROC function named cowait_test_wnd_proc .
2, Define a global int variable named g_count_of_wm_dde_first.
3, Set the value of g_count_of_wm_dde_first to zero before call CoWaitForMultipleHandles.
4, Increase the value of g_count_of_wm_dde_first by one, once received a WM_DDE_FIRST message in cowait_test_wnd_proc.
5, Check if the value of g_count_of_wm_dde_first is equal to 2 after CoWaitForMultipleHandles returned.
The second is why use todo_wine ?
todo_wine
ok(!success, "PeekMessageA succeeded\n");
why not just write?
ok(!success, "PeekMessageA succeeded\n");
Thank you.