ReactOS 0.4.15-dev-5669-g09dde2c
SetFocus.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS API tests
3 * LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
4 * PURPOSE: Test for SetFocus/GetFocus/GetGUIThreadInfo
5 * COPYRIGHT: Copyright 2021 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6 */
7
8#include "precomp.h"
9#include <dlgs.h> // psh1, ...
10#include <process.h>
11
12#define INTERVAL 80
13
15
17{
18 GUITHREADINFO gui = { sizeof(gui) };
20 return gui.hwndFocus;
21}
22
23static unsigned __stdcall thread_proc_0(void *arg)
24{
25 HWND hwnd = arg;
26
27 ok_int(GetFocus() == NULL, TRUE);
30
31 ok_int(GetFocus() == NULL, TRUE);
34
35 ok_int(GetFocus() == NULL, TRUE);
38
39 ok_int(GetFocus() == NULL, TRUE);
42
43 ok_int(GetFocus() == NULL, TRUE);
47
48 ok_int(GetFocus() == NULL, TRUE);
52
53 ok_int(GetFocus() == NULL, TRUE);
57
58 ok_int(GetFocus() == NULL, TRUE);
62
63 ok_int(GetFocus() == NULL, TRUE);
65
67 return 0;
68}
69
70static unsigned __stdcall thread_proc_1(void *arg)
71{
72 HWND hwnd = arg;
73
74 ok_int(GetFocus() == NULL, TRUE);
78
79 ok_int(GetFocus() == NULL, TRUE);
83
84 ok_int(GetFocus() == NULL, TRUE);
86
88 return 0;
89}
90
91static unsigned __stdcall thread_proc_2(void *arg)
92{
93 HWND hwnd = arg;
94
95 ok_int(GetFocus() == NULL, TRUE);
99
100 ok_int(GetFocus() == NULL, TRUE);
104
105 ok_int(GetFocus() == NULL, TRUE);
109
111 return 0;
112}
113
114static INT_PTR CALLBACK
116{
118 switch (uMsg)
119 {
120 case WM_INITDIALOG:
121 ok_int(GetFocus() == NULL, TRUE);
125
128
131
134
137
141 return TRUE;
142
143 case WM_COMMAND:
144 switch (LOWORD(wParam))
145 {
146 case psh2:
150 break;
151
152 case psh3:
154 EndDialog(hwnd, IDCLOSE);
155 break;
156 }
157 break;
158 }
159 return 0;
160}
161
162static INT_PTR CALLBACK
164{
166 switch (uMsg)
167 {
168 case WM_INITDIALOG:
171 return FALSE;
172
173 case WM_COMMAND:
174 switch (LOWORD(wParam))
175 {
176 case psh2:
179 ok_int(GetFocus() == NULL, TRUE);
180
183 break;
184
185 case psh3:
186 ok_int(GetFocus() == NULL, TRUE);
188
189 ok_int(GetFocus() == NULL, TRUE);
192
195 break;
196
197 case psh4:
200
203
205 EndDialog(hwnd, IDCLOSE);
206 break;
207 }
208 break;
209 }
210 return 0;
211}
212
214{
217 ok_int((INT)DialogBoxA(GetModuleHandleA(NULL), "SETFOCUS", NULL, DialogProc_0), IDCLOSE);
218 ok_int((INT)DialogBoxA(GetModuleHandleA(NULL), "SETFOCUS", NULL, DialogProc_1), IDCLOSE);
219}
static unsigned __stdcall thread_proc_0(void *arg)
Definition: SetFocus.c:23
static unsigned __stdcall thread_proc_2(void *arg)
Definition: SetFocus.c:91
static HWND GetMainThreadFocus(void)
Definition: SetFocus.c:16
#define INTERVAL
Definition: SetFocus.c:12
static INT_PTR CALLBACK DialogProc_0(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: SetFocus.c:115
static unsigned __stdcall thread_proc_1(void *arg)
Definition: SetFocus.c:70
static DWORD s_dwMainThreadID
Definition: SetFocus.c:14
static INT_PTR CALLBACK DialogProc_1(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: SetFocus.c:163
#define START_TEST(x)
Definition: atltest.h:75
#define ok_int(expression, result)
Definition: atltest.h:134
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define psh1
Definition: dlgs.h:112
#define psh2
Definition: dlgs.h:113
#define psh3
Definition: dlgs.h:114
#define psh4
Definition: dlgs.h:115
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define CALLBACK
Definition: compat.h:35
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
unsigned long DWORD
Definition: ntddk_ex.h:95
int gui
Definition: mkisofs.c:130
unsigned int UINT
Definition: ndis.h:50
HANDLE hThread
Definition: wizard.c:28
#define LOWORD(l)
Definition: pedump.c:82
_CRTIMP uintptr_t __cdecl _beginthreadex(_In_opt_ void *_Security, _In_ unsigned _StackSize, _In_ unsigned(__stdcall *_StartAddress)(void *), _In_opt_ void *_ArgList, _In_ unsigned _InitFlag, _Out_opt_ unsigned *_ThrdAddr)
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
int32_t INT_PTR
Definition: typedefs.h:64
PVOID HANDLE
Definition: typedefs.h:73
int32_t INT
Definition: typedefs.h:58
#define __stdcall
Definition: typedefs.h:25
BOOL WINAPI GetGUIThreadInfo(DWORD, LPGUITHREADINFO)
Definition: ntwrapper.h:398
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
void * arg
Definition: msvc.h:10
HWND WINAPI GetFocus(void)
Definition: window.c:1894
#define SW_HIDE
Definition: winuser.h:762
#define VK_TAB
Definition: winuser.h:2189
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define IDCANCEL
Definition: winuser.h:825
#define WM_COMMAND
Definition: winuser.h:1730
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_INITDIALOG
Definition: winuser.h:1729
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:824
#define WM_NEXTDLGCTL
Definition: winuser.h:1633
#define DialogBoxA(i, t, p, f)
Definition: winuser.h:4388
HWND WINAPI SetFocus(_In_opt_ HWND)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
VOID WINAPI keybd_event(_In_ BYTE, _In_ BYTE, _In_ DWORD, _In_ ULONG_PTR)
#define SW_SHOW
Definition: winuser.h:769
BOOL WINAPI PostMessageA(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define KEYEVENTF_KEYUP
Definition: winuser.h:1096
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)