1 /*
2  * PROJECT:         ReactOS api tests
3  * LICENSE:         GPL - See COPYING in the top level directory
4  * PURPOSE:         Test for GetMessage/PeekMessage
5  * PROGRAMMERS:     Thomas Faber <thomas.faber@reactos.org>
6  */
7 
8 #include "precomp.h"
9 
10 void Test_GetMessage(HWND hWnd)
11 {
12     MSG msg;
13 
14     SetLastError(DNS_ERROR_RCODE_NXRRSET);
15 
16     ok(GetMessage(&msg, hWnd, 0, 0) == -1, "\n");
17     ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "GetLastError() = %lu\n", GetLastError());
18 }
19 
20 void Test_PeekMessage(HWND hWnd)
21 {
22     MSG msg;
23 
24     SetLastError(DNS_ERROR_RCODE_NXRRSET);
25 
26     ok(PeekMessage(&msg, hWnd, 0, 0, PM_NOREMOVE) == 0, "\n");
27     ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "GetLastError() = %lu\n", GetLastError());
28 }
29 
30 START_TEST(GetPeekMessage)
31 {
32     HWND hWnd = CreateWindowExW(0, L"EDIT", L"miau", 0, CW_USEDEFAULT, CW_USEDEFAULT,
33         CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, GetModuleHandle(NULL), NULL);
34     ok(hWnd != INVALID_HANDLE_VALUE, "\n");
35     /* make sure we pass an invalid handle to GetMessage/PeekMessage */
36     ok(DestroyWindow(hWnd), "\n");
37 
38     Test_GetMessage(hWnd);
39     Test_PeekMessage(hWnd);
40 }
41