ReactOS 0.4.16-dev-1405-gc14a14e
MenuUI.c File Reference
#include "precomp.h"
#include <shellapi.h>
Include dependency graph for MenuUI.c:

Go to the source code of this file.

Classes

struct  tagCOUNTMENUWND
 

Macros

#define SUB_PROGRAM   L"user32_apitest_menuui.exe"
 
#define CLASSNAME   L"MenuUITest"
 
#define MENUCLASS   L"#32768"
 
#define MENUID_100   100
 
#define MENUID_101   101
 
#define MENUID_200   200
 
#define MENUID_201   201
 
#define DELAY   100
 
#define INTERVAL   300
 

Typedefs

typedef BOOL(WINAPIFN_ShellExecuteExW) (SHELLEXECUTEINFOW *)
 
typedef HRESULT(WINAPIFN_DwmGetWindowAttribute) (HWND, DWORD, PVOID, DWORD)
 
typedef enum tagAUTO_CLICK AUTO_CLICK
 
typedef enum tagAUTO_KEY AUTO_KEY
 
typedef struct tagCOUNTMENUWND COUNTMENUWND
 
typedef struct tagCOUNTMENUWNDPCOUNTMENUWND
 

Enumerations

enum  tagAUTO_CLICK {
  AUTO_LEFT_CLICK , AUTO_RIGHT_CLICK , AUTO_LEFT_DOUBLE_CLICK , AUTO_RIGHT_DOUBLE_CLICK ,
  AUTO_LEFT_CLICK , AUTO_RIGHT_CLICK , AUTO_LEFT_DOUBLE_CLICK , AUTO_RIGHT_DOUBLE_CLICK
}
 
enum  tagAUTO_KEY {
  AUTO_KEY_DOWN , AUTO_KEY_UP , AUTO_KEY_DOWN_UP , AUTO_KEY_DOWN ,
  AUTO_KEY_UP , AUTO_KEY_DOWN_UP
}
 

Functions

static VOID AutoKey (AUTO_KEY type, UINT vKey)
 
static VOID AutoClick (AUTO_CLICK type, INT x, INT y)
 
static POINT CenterPoint (const RECT *prc)
 
static INT GetHitID (HWND hwndTarget)
 
static BOOL CALLBACK CountMenuWndProc (HWND hwnd, LPARAM lParam)
 
static INT CountMenuWnds (VOID)
 
static VOID CloseSubPrograms (VOID)
 
static HWND GetThreadActiveWnd (DWORD dwThreadID)
 
static HWND GetThreadFocus (DWORD dwThreadID)
 
static HWND GetThreadCapture (DWORD dwThreadID)
 
static DWORD WINAPI ThreadFunc (LPVOID arg)
 
static INT OnCreate (HWND hwnd)
 
static VOID OnDestroy (HWND hwnd)
 
static LRESULT CALLBACK WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static VOID TEST_MenuUI (VOID)
 
 START_TEST (MenuUI)
 

Variables

static FN_ShellExecuteExW s_pShellExecuteExW = NULL
 
static HANDLE s_hThread = NULL
 

Macro Definition Documentation

◆ CLASSNAME

#define CLASSNAME   L"MenuUITest"

Definition at line 12 of file MenuUI.c.

◆ DELAY

#define DELAY   100

Definition at line 25 of file MenuUI.c.

◆ INTERVAL

#define INTERVAL   300

Definition at line 26 of file MenuUI.c.

◆ MENUCLASS

#define MENUCLASS   L"#32768"

Definition at line 13 of file MenuUI.c.

◆ MENUID_100

#define MENUID_100   100

Definition at line 15 of file MenuUI.c.

◆ MENUID_101

#define MENUID_101   101

Definition at line 16 of file MenuUI.c.

◆ MENUID_200

#define MENUID_200   200

Definition at line 17 of file MenuUI.c.

◆ MENUID_201

#define MENUID_201   201

Definition at line 18 of file MenuUI.c.

◆ SUB_PROGRAM

#define SUB_PROGRAM   L"user32_apitest_menuui.exe"

Definition at line 11 of file MenuUI.c.

Typedef Documentation

◆ AUTO_CLICK

◆ AUTO_KEY

◆ COUNTMENUWND

◆ FN_DwmGetWindowAttribute

typedef HRESULT(WINAPI * FN_DwmGetWindowAttribute) (HWND, DWORD, PVOID, DWORD)

Definition at line 23 of file MenuUI.c.

◆ FN_ShellExecuteExW

typedef BOOL(WINAPI * FN_ShellExecuteExW) (SHELLEXECUTEINFOW *)

Definition at line 20 of file MenuUI.c.

◆ PCOUNTMENUWND

Enumeration Type Documentation

◆ tagAUTO_CLICK

Enumerator
AUTO_LEFT_CLICK 
AUTO_RIGHT_CLICK 
AUTO_LEFT_DOUBLE_CLICK 
AUTO_RIGHT_DOUBLE_CLICK 
AUTO_LEFT_CLICK 
AUTO_RIGHT_CLICK 
AUTO_LEFT_DOUBLE_CLICK 
AUTO_RIGHT_DOUBLE_CLICK 

Definition at line 29 of file MenuUI.c.

30{
@ AUTO_RIGHT_CLICK
Definition: MenuUI.c:32
@ AUTO_LEFT_DOUBLE_CLICK
Definition: MenuUI.c:33
@ AUTO_RIGHT_DOUBLE_CLICK
Definition: MenuUI.c:34
@ AUTO_LEFT_CLICK
Definition: MenuUI.c:31
enum tagAUTO_CLICK AUTO_CLICK

◆ tagAUTO_KEY

Enumerator
AUTO_KEY_DOWN 
AUTO_KEY_UP 
AUTO_KEY_DOWN_UP 
AUTO_KEY_DOWN 
AUTO_KEY_UP 
AUTO_KEY_DOWN_UP 

Definition at line 37 of file MenuUI.c.

38{
42} AUTO_KEY;
enum tagAUTO_KEY AUTO_KEY
@ AUTO_KEY_DOWN_UP
Definition: MenuUI.c:41
@ AUTO_KEY_DOWN
Definition: MenuUI.c:39
@ AUTO_KEY_UP
Definition: MenuUI.c:40

Function Documentation

◆ AutoClick()

static VOID AutoClick ( AUTO_CLICK  type,
INT  x,
INT  y 
)
static

Definition at line 65 of file MenuUI.c.

66{
68 ZeroMemory(&input, sizeof(input));
69
70 INT nScreenWidth = GetSystemMetrics(SM_CXSCREEN) - 1;
71 INT nScreenHeight = GetSystemMetrics(SM_CYSCREEN) - 1;
72
73 input.type = INPUT_MOUSE;
74 input.mi.dx = (LONG)(x * (65535.0f / nScreenWidth));
75 input.mi.dy = (LONG)(y * (65535.0f / nScreenHeight));
77 SendInput(1, &input, sizeof(INPUT));
78 Sleep(DELAY);
79
80 input.mi.dx = input.mi.dy = 0;
81
82 INT i, count = 1;
83 switch (type)
84 {
86 count = 2;
87 // FALL THROUGH
88 case AUTO_LEFT_CLICK:
89 {
90 for (i = 0; i < count; ++i)
91 {
92 input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
93 SendInput(1, &input, sizeof(INPUT));
94 Sleep(DELAY);
95
96 input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
97 SendInput(1, &input, sizeof(INPUT));
98 Sleep(DELAY);
99 }
100 break;
101 }
103 count = 2;
104 // FALL THROUGH
105 case AUTO_RIGHT_CLICK:
106 {
107 for (i = 0; i < count; ++i)
108 {
109 input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
110 SendInput(1, &input, sizeof(INPUT));
111 Sleep(DELAY);
112
113 input.mi.dwFlags = MOUSEEVENTF_RIGHTUP;
114 SendInput(1, &input, sizeof(INPUT));
115 Sleep(DELAY);
116 }
117 break;
118 }
119 }
120}
#define DELAY
Definition: MenuUI.c:25
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLenum GLenum GLenum input
Definition: glext.h:9031
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
long LONG
Definition: pedump.c:60
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
int32_t INT
Definition: typedefs.h:58
UINT WINAPI SendInput(UINT, LPINPUT, int)
Definition: ntwrapper.h:344
#define INPUT_MOUSE
Definition: winable.h:9
#define ZeroMemory
Definition: winbase.h:1753
#define MOUSEEVENTF_ABSOLUTE
Definition: winuser.h:1205
#define SM_CYSCREEN
Definition: winuser.h:971
#define MOUSEEVENTF_LEFTUP
Definition: winuser.h:1196
#define MOUSEEVENTF_RIGHTUP
Definition: winuser.h:1198
#define MOUSEEVENTF_MOVE
Definition: winuser.h:1194
#define MOUSEEVENTF_LEFTDOWN
Definition: winuser.h:1195
#define MOUSEEVENTF_RIGHTDOWN
Definition: winuser.h:1197
#define SM_CXSCREEN
Definition: winuser.h:970
int WINAPI GetSystemMetrics(_In_ int)

Referenced by ThreadFunc().

◆ AutoKey()

static VOID AutoKey ( AUTO_KEY  type,
UINT  vKey 
)
static

Definition at line 45 of file MenuUI.c.

46{
48 {
50 AutoKey(AUTO_KEY_UP, vKey);
51 return;
52 }
53
55 ZeroMemory(&input, sizeof(input));
56
57 input.type = INPUT_KEYBOARD;
58 input.ki.wVk = vKey;
59 input.ki.dwFlags = ((type == AUTO_KEY_UP) ? KEYEVENTF_KEYUP : 0);
60 SendInput(1, &input, sizeof(INPUT));
61 Sleep(DELAY);
62}
static VOID AutoKey(AUTO_KEY type, UINT vKey)
Definition: MenuUI.c:45
#define INPUT_KEYBOARD
Definition: winable.h:10
#define KEYEVENTF_KEYUP
Definition: winuser.h:1113

Referenced by AutoKey(), and ThreadFunc().

◆ CenterPoint()

static POINT CenterPoint ( const RECT prc)
static

Definition at line 123 of file MenuUI.c.

124{
125 POINT pt = { (prc->left + prc->right) / 2, (prc->top + prc->bottom) / 2 };
126 return pt;
127}
#define pt(x, y)
Definition: drawing.c:79
_Out_ LPRECT prc
Definition: ntgdi.h:1658
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306

Referenced by ThreadFunc().

◆ CloseSubPrograms()

static VOID CloseSubPrograms ( VOID  )
static

Definition at line 165 of file MenuUI.c.

166{
167 for (INT i = 0; i < 10; ++i)
168 {
169 HWND hwnd1 = FindWindowW(L"user32_apitest_menuui", L"#1");
170 if (!hwnd1)
171 break;
172 PostMessage(hwnd1, WM_CLOSE, 0, 0);
174 }
175 for (INT i = 0; i < 10; ++i)
176 {
177 HWND hwnd2 = FindWindowW(L"user32_apitest_menuui", L"#2");
178 if (!hwnd2)
179 break;
180 PostMessage(hwnd2, WM_CLOSE, 0, 0);
182 }
183}
#define INTERVAL
Definition: MenuUI.c:26
#define L(x)
Definition: resources.c:13
#define WM_CLOSE
Definition: winuser.h:1640
#define PostMessage
Definition: winuser.h:5917
HWND WINAPI FindWindowW(_In_opt_ LPCWSTR, _In_opt_ LPCWSTR)

Referenced by START_TEST(), and ThreadFunc().

◆ CountMenuWndProc()

static BOOL CALLBACK CountMenuWndProc ( HWND  hwnd,
LPARAM  lParam 
)
static

Definition at line 141 of file MenuUI.c.

142{
143 if (!IsWindowVisible(hwnd))
144 return TRUE;
145
146 WCHAR szClass[64];
147 GetClassNameW(hwnd, szClass, _countof(szClass));
148 if (lstrcmpiW(szClass, MENUCLASS) != 0)
149 return TRUE;
150
152 pData->nMenuCount += 1;
153 return TRUE;
154}
struct tagCOUNTMENUWND * PCOUNTMENUWND
#define MENUCLASS
Definition: MenuUI.c:13
LPARAM lParam
Definition: combotst.c:139
#define TRUE
Definition: types.h:120
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4265
#define _countof(array)
Definition: sndvol32.h:70
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
int WINAPI GetClassNameW(_In_ HWND hWnd, _Out_writes_to_(nMaxCount, return) LPWSTR lpClassName, _In_ int nMaxCount)
BOOL WINAPI IsWindowVisible(_In_ HWND)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CountMenuWnds().

◆ CountMenuWnds()

static INT CountMenuWnds ( VOID  )
static

Definition at line 157 of file MenuUI.c.

158{
159 COUNTMENUWND data = { 0 };
161 return data.nMenuCount;
162}
static BOOL CALLBACK CountMenuWndProc(HWND hwnd, LPARAM lParam)
Definition: MenuUI.c:141
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC lpEnumFunc, _In_ LPARAM lParam)

Referenced by ThreadFunc().

◆ GetHitID()

static INT GetHitID ( HWND  hwndTarget)
static

Definition at line 130 of file MenuUI.c.

131{
132 return HandleToUlong(GetPropW(hwndTarget, L"Hit"));
133}
#define HandleToUlong(h)
Definition: basetsd.h:79
HANDLE WINAPI GetPropW(_In_ HWND, _In_ LPCWSTR)

Referenced by ThreadFunc().

◆ GetThreadActiveWnd()

static HWND GetThreadActiveWnd ( DWORD  dwThreadID)
static

Definition at line 186 of file MenuUI.c.

187{
188 GUITHREADINFO info = { sizeof(info) };
189 GetGUIThreadInfo(dwThreadID, &info);
190 return info.hwndActive;
191}
BOOL WINAPI GetGUIThreadInfo(DWORD, LPGUITHREADINFO)
Definition: ntwrapper.h:398

Referenced by ThreadFunc().

◆ GetThreadCapture()

static HWND GetThreadCapture ( DWORD  dwThreadID)
static

Definition at line 202 of file MenuUI.c.

203{
204 GUITHREADINFO info = { sizeof(info) };
205 GetGUIThreadInfo(dwThreadID, &info);
206 return info.hwndCapture;
207}

Referenced by ThreadFunc().

◆ GetThreadFocus()

static HWND GetThreadFocus ( DWORD  dwThreadID)
static

Definition at line 194 of file MenuUI.c.

195{
196 GUITHREADINFO info = { sizeof(info) };
197 GetGUIThreadInfo(dwThreadID, &info);
198 return info.hwndFocus;
199}

Referenced by ThreadFunc().

◆ OnCreate()

static INT OnCreate ( HWND  hwnd)
static

Definition at line 745 of file MenuUI.c.

746{
748 if (!s_hThread)
749 return -1;
750 return 0;
751}
static DWORD WINAPI ThreadFunc(LPVOID arg)
Definition: MenuUI.c:210
static HANDLE s_hThread
Definition: MenuUI.c:27
#define NULL
Definition: types.h:112
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137

Referenced by WindowProc().

◆ OnDestroy()

static VOID OnDestroy ( HWND  hwnd)
static

Definition at line 754 of file MenuUI.c.

755{
756 if (s_hThread)
757 {
759 s_hThread = NULL;
760 }
761
763}
#define CloseHandle
Definition: compat.h:739
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)

Referenced by WindowProc().

◆ START_TEST()

START_TEST ( MenuUI  )

Definition at line 819 of file MenuUI.c.

820{
822 {
823 skip("'%ls' not found\n", SUB_PROGRAM);
824 return;
825 }
826
827 HINSTANCE hShell32 = LoadLibraryW(L"shell32.dll");
830 {
831 skip("ShellExecuteExW not found\n");
833 return;
834 }
835
836 TEST_MenuUI();
837
839
841}
BOOL(WINAPI * FN_ShellExecuteExW)(SHELLEXECUTEINFOW *)
Definition: MenuUI.c:20
static VOID TEST_MenuUI(VOID)
Definition: MenuUI.c:783
#define SUB_PROGRAM
Definition: MenuUI.c:11
static VOID CloseSubPrograms(VOID)
Definition: MenuUI.c:165
static FN_ShellExecuteExW s_pShellExecuteExW
Definition: MenuUI.c:21
#define skip(...)
Definition: atltest.h:64
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define LoadLibraryW(x)
Definition: compat.h:747
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
static HMODULE hShell32
Definition: string.c:34
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23

◆ TEST_MenuUI()

static VOID TEST_MenuUI ( VOID  )
static

Definition at line 783 of file MenuUI.c.

784{
786
788 wc.hInstance = hInstance;
791 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
793 if (!RegisterClassW(&wc))
794 {
795 skip("RegisterClassW failed\n");
796 return;
797 }
798
800 CW_USEDEFAULT, CW_USEDEFAULT, 400, 300,
802 if (!hwnd)
803 {
804 skip("CreateWindowW failed\n");
805 return;
806 }
807
810
811 MSG msg;
812 while (GetMessageW(&msg, NULL, 0, 0))
813 {
816 }
817}
#define CLASSNAME
Definition: MenuUI.c:12
static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: MenuUI.c:767
#define msg(x)
Definition: auth_time.c:54
HINSTANCE hInstance
Definition: charmap.c:19
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
LPCWSTR lpszClassName
Definition: winuser.h:3261
HBRUSH hbrBackground
Definition: winuser.h:3259
HICON hIcon
Definition: winuser.h:3257
HINSTANCE hInstance
Definition: winuser.h:3256
HCURSOR hCursor
Definition: winuser.h:3258
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define SW_SHOWNORMAL
Definition: winuser.h:781
#define CS_VREDRAW
Definition: winuser.h:666
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define COLOR_WINDOW
Definition: winuser.h:929
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
#define CS_HREDRAW
Definition: winuser.h:661
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define IDC_ARROW
Definition: winuser.h:695
#define CS_DBLCLKS
Definition: winuser.h:659
#define IDI_APPLICATION
Definition: winuser.h:712
#define LoadIcon
Definition: winuser.h:5898
BOOL WINAPI UpdateWindow(_In_ HWND)
#define LoadCursor
Definition: winuser.h:5897
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4392
#define CW_USEDEFAULT
Definition: winuser.h:225
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)

Referenced by START_TEST().

◆ ThreadFunc()

static DWORD WINAPI ThreadFunc ( LPVOID  arg)
static

Definition at line 210 of file MenuUI.c.

211{
212 HWND hwnd = FindWindowW(L"MenuUITest", L"MenuUITest");
214 trace("hwnd: %p\n", hwnd);
215
217
219
220 sei.lpFile = SUB_PROGRAM;
221 sei.nShow = SW_SHOWNORMAL;
222
223 // Start up sub program #1
224 sei.lpParameters = L"#1";
225 if (!s_pShellExecuteExW(&sei))
226 {
227 skip("ShellExecuteExW failed\n");
228 return -1;
229 }
232
233 // Start up sub program #2
234 sei.lpParameters = L"#2";
235 if (!s_pShellExecuteExW(&sei))
236 {
237 skip("ShellExecuteExW failed\n");
238 return -1;
239 }
242
244 HWND hwnd1 = FindWindowW(L"user32_apitest_menuui", L"#1");
245 HWND hwnd2 = FindWindowW(L"user32_apitest_menuui", L"#2");
246 trace("hwnd1: %p\n", hwnd1);
247 trace("hwnd2: %p\n", hwnd2);
248 ok(hwnd != NULL, "hwnd was NULL\n");
249 ok(hwnd1 != NULL, "hwnd1 was NULL\n");
250 ok(hwnd2 != NULL, "hwnd2 was NULL\n");
251 ok(hwnd1 != hwnd2, "hwnd1 == hwnd2\n");
252
253 DWORD dwTID1 = GetWindowThreadProcessId(hwnd1, NULL);
254 DWORD dwTID2 = GetWindowThreadProcessId(hwnd2, NULL);
255
256 RECT rcWork;
257 SystemParametersInfoW(SPI_GETWORKAREA, 0, &rcWork, 0);
258 INT cxWork = (rcWork.right - rcWork.left);
259
260 RECT rc1 = { rcWork.left, rcWork.top, rcWork.left + cxWork / 2, rcWork.bottom };
261 RECT rc2 = { rcWork.left + cxWork / 2, rcWork.top, rcWork.right, rcWork.bottom };
262 MoveWindow(hwnd1, rc1.left, rc1.top, rc1.right - rc1.left, rc1.bottom - rc1.top, TRUE);
263 MoveWindow(hwnd2, rc2.left, rc2.top, rc2.right - rc2.left, rc2.bottom - rc2.top, TRUE);
264
265 POINT pt1 = CenterPoint(&rc1);
266 POINT pt2 = CenterPoint(&rc2);
267
268 // Right click on hwnd1
269 AutoClick(AUTO_RIGHT_CLICK, pt1.x, pt1.y);
271
272 HWND hwndMenu1 = FindWindowW(MENUCLASS, L"");
273 trace("hwndMenu1: %p\n", hwndMenu1);
274 ok(IsWindowVisible(hwndMenu1), "hwndMenu1 not visible\n");
275
276 HWND hwndFore, hwndActive, hwndFocus, hwndCapture;
277
278 hwndFore = GetForegroundWindow();
279 ok(hwndFore == hwnd1, "hwndFore was %p\n", hwndFore);
280
281 hwndActive = GetThreadActiveWnd(dwTID1);
282 hwndFocus = GetThreadFocus(dwTID1);
283 hwndCapture = GetThreadCapture(dwTID1);
284 ok(hwndActive == hwnd1, "hwndActive was %p\n", hwndActive);
285 ok(hwndFocus == hwnd1, "hwndFocus was %p\n", hwndFocus);
286 ok(hwndCapture == hwnd1, "hwndCapture was %p\n", hwndCapture);
287
288 // Right click on hwnd2
289 AutoClick(AUTO_RIGHT_CLICK, pt2.x, pt2.y);
291
292 HWND hwndMenu2 = FindWindowW(MENUCLASS, L"");
293 trace("hwndMenu2: %p\n", hwndMenu2);
294 ok(IsWindowVisible(hwndMenu2), "hwndMenu2 not visible\n");
295 ok(hwndMenu1 != hwndMenu2, "hwndMenu1 == hwndMenu2\n");
296
297 hwndFore = GetForegroundWindow();
298 ok(hwndFore == hwnd2, "hwndFore was %p\n", hwndFore);
299
300 hwndActive = GetThreadActiveWnd(dwTID2);
301 hwndFocus = GetThreadFocus(dwTID2);
302 hwndCapture = GetThreadCapture(dwTID2);
303 ok(hwndActive == hwnd2, "hwndActive was %p\n", hwndActive);
304 ok(hwndFocus == hwnd2, "hwndFocus was %p\n", hwndFocus);
305 ok(hwndCapture == hwnd2, "hwndCapture was %p\n", hwndCapture);
306
307 // Type Esc key
310
311 hwndFore = GetForegroundWindow();
312 ok(hwndFore == hwnd2, "hwndFore was %p\n", hwndFore);
313
314 hwndActive = GetThreadActiveWnd(dwTID1);
315 hwndFocus = GetThreadFocus(dwTID1);
316 hwndCapture = GetThreadCapture(dwTID1);
317 ok(!hwndActive, "hwndActive was %p\n", hwndActive);
318 ok(!hwndFocus, "hwndFocus was %p\n", hwndFocus);
319 ok(!hwndCapture, "hwndCapture was %p\n", hwndCapture);
320
321 hwndActive = GetThreadActiveWnd(dwTID2);
322 hwndFocus = GetThreadFocus(dwTID2);
323 hwndCapture = GetThreadCapture(dwTID2);
324 ok(hwndActive == hwnd2, "hwndActive was %p\n", hwndActive);
325 ok(hwndFocus == hwnd2, "hwndFocus was %p\n", hwndFocus);
326 ok(!hwndCapture, "hwndCapture was %p\n", hwndCapture);
327
328 ok(GetHitID(hwnd2) == 0, "GetHitID(hwnd2) was %d\n", GetHitID(hwnd2));
329 HWND hwndMenu0 = FindWindowW(MENUCLASS, L"");
330 trace("hwndMenu0: %p\n", hwndMenu0);
331 ok(!IsWindowVisible(hwndMenu0), "hwndMenu0 was visible\n");
332
333 // Click on hwnd1
334 AutoClick(AUTO_RIGHT_CLICK, pt1.x, pt1.y);
335 hwndMenu1 = FindWindowW(MENUCLASS, L"");
336 trace("hwndMenu1: %p\n", hwndMenu1);
337 ok(IsWindowVisible(hwndMenu1), "hwndMenu1 not visible");
338
339 RECT rcMenu1;
340 GetWindowRect(hwndMenu1, &rcMenu1);
341 POINT ptMenu1 = CenterPoint(&rcMenu1); // Separator
342
343 // Clicking on separator is not effective
344 AutoClick(AUTO_LEFT_CLICK, ptMenu1.x, ptMenu1.y);
345 hwndMenu1 = FindWindowW(MENUCLASS, L"");
346 trace("hwndMenu1: %p\n", hwndMenu1);
347 ok(IsWindowVisible(hwndMenu1), "hwndMenu1 not visible\n");
348
349 AutoClick(AUTO_LEFT_DOUBLE_CLICK, ptMenu1.x, ptMenu1.y);
350 hwndMenu1 = FindWindowW(MENUCLASS, L"");
351 trace("hwndMenu1: %p\n", hwndMenu1);
352 ok(IsWindowVisible(hwndMenu1), "hwndMenu1 not visible\n");
353
354 AutoClick(AUTO_RIGHT_CLICK, ptMenu1.x, ptMenu1.y);
355 hwndMenu1 = FindWindowW(MENUCLASS, L"");
356 trace("hwndMenu1: %p\n", hwndMenu1);
357 ok(IsWindowVisible(hwndMenu1), "hwndMenu1 not visible\n");
358
359 AutoClick(AUTO_RIGHT_DOUBLE_CLICK, ptMenu1.x, ptMenu1.y);
360 hwndMenu1 = FindWindowW(MENUCLASS, L"");
361 trace("hwndMenu1: %p\n", hwndMenu1);
362 ok(IsWindowVisible(hwndMenu1), "hwndMenu1 not visible\n");
363
364 // Click on first item of hwnd1 context menu
365 POINT pt1_3 = { ptMenu1.x, (2 * rcMenu1.top + 1 * rcMenu1.bottom) / (1 + 2) }; // First item
366 AutoClick(AUTO_LEFT_CLICK, pt1_3.x, pt1_3.y);
368
369 hwndMenu1 = FindWindowW(MENUCLASS, L"");
370 ok(!IsWindowVisible(hwndMenu1), "hwndMenu1 was visible\n");
371 ok(GetHitID(hwnd1) == MENUID_100, "GetHitID(hwnd1) was %d\n", GetHitID(hwnd1));
372
373 // Click on hwnd2
374 AutoClick(AUTO_RIGHT_CLICK, pt2.x, pt2.y);
375 hwndMenu2 = FindWindowW(MENUCLASS, L"");
376 ok(IsWindowVisible(hwndMenu2), "hwndMenu2 not visible\n");
377
378 AutoKey(AUTO_KEY_DOWN_UP, VK_DOWN); // Down key
379 hwndMenu2 = FindWindowW(MENUCLASS, L"");
380 ok(IsWindowVisible(hwndMenu2), "hwndMenu2 not visible\n");
381
382 AutoKey(AUTO_KEY_DOWN_UP, VK_RETURN); // Enter key
384
385 hwndMenu2 = FindWindowW(MENUCLASS, L"");
386 ok(!IsWindowVisible(hwndMenu2), "hwndMenu2 was visible");
387 ok(GetHitID(hwnd2) == MENUID_100, "GetHitID(hwnd2) was %d\n", GetHitID(hwnd2));
388
389 // Click on hwnd2
390 AutoClick(AUTO_RIGHT_CLICK, pt2.x, pt2.y);
391 hwndMenu2 = FindWindowW(MENUCLASS, L"");
392 ok(IsWindowVisible(hwndMenu2), "hwndMenu2 not visible\n");
393
394 AutoKey(AUTO_KEY_DOWN_UP, VK_UP); // Up key
395 hwndMenu2 = FindWindowW(MENUCLASS, L"");
396 ok(IsWindowVisible(hwndMenu2), "hwndMenu2 not visible\n");
397
398 AutoKey(AUTO_KEY_DOWN_UP, VK_RETURN); // Enter key
400
401 hwndMenu2 = FindWindowW(MENUCLASS, L"");
402 ok(!IsWindowVisible(hwndMenu2), "hwndMenu2 was visible");
403 ok(GetHitID(hwnd2) == 101, "GetHitID(hwnd2) was %d\n", GetHitID(hwnd2));
404
405 INT nMenuCount;
406
407 // Shift + Right click on hwnd2
409 AutoClick(AUTO_RIGHT_CLICK, pt2.x, pt2.y);
411 hwndMenu2 = FindWindowW(MENUCLASS, L"");
412 ok(IsWindowVisible(hwndMenu2), "hwndMenu2 not visible\n");
413 nMenuCount = CountMenuWnds();
414 ok(nMenuCount == 1, "nMenuCount was %d\n", nMenuCount);
415
416 AutoKey(AUTO_KEY_DOWN_UP, VK_UP); // Up key
417 hwndMenu2 = FindWindowW(MENUCLASS, L"");
418 ok(IsWindowVisible(hwndMenu2), "hwndMenu2 not visible\n");
419
420 AutoKey(AUTO_KEY_DOWN_UP, VK_RETURN); // Enter key
421 hwndMenu2 = FindWindowW(MENUCLASS, L"");
422 ok(IsWindowVisible(hwndMenu2), "hwndMenu2 not visible\n");
423 nMenuCount = CountMenuWnds();
424 ok(nMenuCount == 2, "nMenuCount was %d\n", nMenuCount);
425
426 // Right click on hwnd1
427 AutoClick(AUTO_RIGHT_CLICK, pt1.x, pt1.y);
428 nMenuCount = CountMenuWnds();
429 ok(nMenuCount == 1, "nMenuCount was %d\n", nMenuCount);
430
431 AutoKey(AUTO_KEY_DOWN_UP, VK_DOWN); // Down key
432 AutoKey(AUTO_KEY_DOWN_UP, VK_RETURN); // Enter key
434
435 hwndMenu1 = FindWindowW(MENUCLASS, L"");
436 ok(!IsWindowVisible(hwndMenu1), "hwndMenu1 was visible\n");
437
438 // Getting menu bar info
439 MENUBARINFO mbi = { sizeof(mbi) };
440 GetMenuBarInfo(hwnd1, OBJID_MENU, 0, &mbi);
441 INT xMenuBar1 = mbi.rcBar.left + 16;
442 INT yMenuBar1 = (mbi.rcBar.top + mbi.rcBar.bottom) / 2;
443 GetMenuBarInfo(hwnd2, OBJID_MENU, 0, &mbi);
444 INT xMenuBar2 = mbi.rcBar.left + 16;
445 INT yMenuBar2 = (mbi.rcBar.top + mbi.rcBar.bottom) / 2;
446
447 // Click on menu bar
448 AutoClick(AUTO_LEFT_CLICK, xMenuBar1, yMenuBar1);
450
451 hwndMenu1 = FindWindowW(MENUCLASS, L"");
452 ok(IsWindowVisible(hwndMenu1), "hwndMenu1 not visible\n");
453
454 hwndFore = GetForegroundWindow();
455 ok(hwndFore == hwnd1, "hwndFore was %p\n", hwndFore);
456
457 hwndActive = GetThreadActiveWnd(dwTID1);
458 hwndFocus = GetThreadFocus(dwTID1);
459 hwndCapture = GetThreadCapture(dwTID1);
460 ok(hwndActive == hwnd1, "hwndActive was %p\n", hwndActive);
461 ok(hwndFocus == hwnd1, "hwndFocus was %p\n", hwndFocus);
462 ok(hwndCapture == hwnd1, "hwndCapture was %p\n", hwndCapture);
463
464 // Right click on hwnd2
465 AutoClick(AUTO_RIGHT_CLICK, pt2.x, pt2.y);
467
468 ok(!IsWindowVisible(hwndMenu1), "hwndMenu1 was visible\n");
469 hwndMenu2 = FindWindowW(MENUCLASS, L"");
470 ok(IsWindowVisible(hwndMenu2), "hwndMenu2 not visible\n");
471 ok(hwndMenu1 != hwndMenu2, "hwndMenu1 == hwndMenu2\n");
472
473 hwndFore = GetForegroundWindow();
474 ok(hwndFore == hwnd2, "hwndFore was %p\n", hwndFore);
475
476 hwndActive = GetThreadActiveWnd(dwTID1);
477 hwndFocus = GetThreadFocus(dwTID1);
478 hwndCapture = GetThreadCapture(dwTID1);
479 ok(!hwndActive, "hwndActive was %p\n", hwndActive);
480 ok(!hwndFocus, "hwndFocus was %p\n", hwndFocus);
481 ok(!hwndCapture, "hwndFocus was %p\n", hwndCapture);
482
483 hwndActive = GetThreadActiveWnd(dwTID2);
484 hwndFocus = GetThreadFocus(dwTID2);
485 hwndCapture = GetThreadCapture(dwTID2);
486 ok(hwndActive == hwnd2, "hwndActive was %p\n", hwndActive);
487 ok(hwndFocus == hwnd2, "hwndFocus was %p\n", hwndFocus);
488 ok(hwndCapture == hwnd2, "hwndFocus was %p\n", hwndCapture);
489
490 // Click on hwnd1 menu bar
491 AutoClick(AUTO_LEFT_CLICK, xMenuBar1, yMenuBar1);
493
494 ok(!IsWindowVisible(hwndMenu2), "hwndMenu2 was visible\n");
495 hwndMenu1 = FindWindowW(MENUCLASS, L"");
496
497 hwndFore = GetForegroundWindow();
498 ok(hwndFore == hwnd1, "hwndFore was %p\n", hwndFore);
499
500 hwndActive = GetThreadActiveWnd(dwTID1);
501 hwndFocus = GetThreadFocus(dwTID1);
502 hwndCapture = GetThreadCapture(dwTID1);
503 ok(hwndActive == hwnd1, "hwndActive was %p\n", hwndActive);
504 ok(hwndFocus == hwnd1, "hwndFocus was %p\n", hwndFocus);
505 ok(hwndCapture == hwnd1, "hwndCapture was %p\n", hwndCapture);
506
507 hwndActive = GetThreadActiveWnd(dwTID2);
508 hwndFocus = GetThreadFocus(dwTID2);
509 hwndCapture = GetThreadCapture(dwTID2);
510 ok(!hwndActive, "hwndActive was %p\n", hwndActive);
511 ok(!hwndFocus, "hwndFocus was %p\n", hwndFocus);
512 ok(!hwndCapture, "hwndFocus was %p\n", hwndCapture);
513
514 // Shift + Right click on hwnd2
516 AutoClick(AUTO_RIGHT_CLICK, pt2.x, pt2.y);
518
519 hwndFore = GetForegroundWindow();
520 ok(hwndFore == hwnd2, "hwndFore was %p\n", hwndFore);
521
522 hwndActive = GetThreadActiveWnd(dwTID1);
523 hwndFocus = GetThreadFocus(dwTID1);
524 hwndCapture = GetThreadCapture(dwTID1);
525 ok(!hwndActive, "hwndActive was %p\n", hwndActive);
526 ok(!hwndFocus, "hwndFocus was %p\n", hwndFocus);
527 ok(!hwndCapture, "hwndFocus was %p\n", hwndCapture);
528
529 hwndActive = GetThreadActiveWnd(dwTID2);
530 hwndFocus = GetThreadFocus(dwTID2);
531 hwndCapture = GetThreadCapture(dwTID2);
532 ok(hwndActive == hwnd2, "hwndActive was %p\n", hwndActive);
533 ok(hwndFocus == hwnd2, "hwndFocus was %p\n", hwndFocus);
534 ok(hwndCapture == hwnd2, "hwndFocus was %p\n", hwndCapture);
535
536 ok(!IsWindowVisible(hwndMenu1), "hwndMenu1 was visible\n");
539 ok(GetHitID(hwnd2) == 0, "GetHitID(hwnd2) was %d\n", GetHitID(hwnd2));
543 ok(GetHitID(hwnd2) == MENUID_101, "GetHitID(hwnd2) was %d\n", GetHitID(hwnd2));
544
545 // Shift + Right click on hwnd2
547 AutoClick(AUTO_RIGHT_CLICK, pt2.x, pt2.y);
550
551 nMenuCount = CountMenuWnds();
552 ok(nMenuCount == 1, "nMenuCount was %d\n", nMenuCount);
553
554 AutoKey(AUTO_KEY_DOWN_UP, VK_UP); // Up key
555 AutoKey(AUTO_KEY_DOWN_UP, VK_RETURN); // Enter key
557
558 nMenuCount = CountMenuWnds();
559 ok(nMenuCount == 2, "nMenuCount was %d\n", nMenuCount);
560
561 AutoKey(AUTO_KEY_DOWN_UP, VK_LEFT); // Left key
563
564 nMenuCount = CountMenuWnds();
565 ok(nMenuCount == 1, "nMenuCount was %d\n", nMenuCount);
566
567 AutoKey(AUTO_KEY_DOWN_UP, VK_RIGHT); // Right key
569
570 nMenuCount = CountMenuWnds();
571 ok(nMenuCount == 2, "nMenuCount was %d\n", nMenuCount);
572
573 // Left click on hwnd1 menu bar
574 AutoClick(AUTO_LEFT_CLICK, xMenuBar1, yMenuBar1);
576
577 nMenuCount = CountMenuWnds();
578 ok(nMenuCount == 1, "nMenuCount was %d\n", nMenuCount);
579
580 AutoKey(AUTO_KEY_DOWN_UP, VK_DOWN); // Down key
581 AutoKey(AUTO_KEY_DOWN_UP, VK_RETURN); // Enter key
583
584 ok(GetHitID(hwnd1) == MENUID_200, "GetHitID(hwnd1) was %d\n", GetHitID(hwnd1));
585
586 // Left click on hwnd1 menu bar
587 AutoClick(AUTO_LEFT_CLICK, xMenuBar1, yMenuBar1);
590
591 hwndFore = GetForegroundWindow();
592 ok(hwndFore == hwnd1, "hwndFore was %p\n", hwndFore);
593
594 hwndActive = GetThreadActiveWnd(dwTID1);
595 hwndFocus = GetThreadFocus(dwTID1);
596 hwndCapture = GetThreadCapture(dwTID1);
597 ok(hwndActive == hwnd1, "hwndActive was %p\n", hwndActive);
598 ok(hwndFocus == hwnd1, "hwndFocus was %p\n", hwndFocus);
599 ok(hwndCapture == hwnd1, "hwndCapture was %p\n", hwndCapture);
600
601 hwndActive = GetThreadActiveWnd(dwTID2);
602 hwndFocus = GetThreadFocus(dwTID2);
603 hwndCapture = GetThreadCapture(dwTID2);
604 ok(!hwndActive, "hwndActive was %p\n", hwndActive);
605 ok(!hwndFocus, "hwndFocus was %p\n", hwndFocus);
606 ok(!hwndCapture, "hwndFocus was %p\n", hwndCapture);
607
609 ok(GetHitID(hwnd1) == 0, "GetHitID(hwnd1) was %d\n", GetHitID(hwnd1));
610
611 // Left click on hwnd1 menu bar
612 AutoClick(AUTO_LEFT_CLICK, xMenuBar1, yMenuBar1);
614
615 hwndFore = GetForegroundWindow();
616 ok(hwndFore == hwnd1, "hwndFore was %p\n", hwndFore);
617
618 hwndActive = GetThreadActiveWnd(dwTID1);
619 hwndFocus = GetThreadFocus(dwTID1);
620 hwndCapture = GetThreadCapture(dwTID1);
621 ok(hwndActive == hwnd1, "hwndActive was %p\n", hwndActive);
622 ok(hwndFocus == hwnd1, "hwndFocus was %p\n", hwndFocus);
623 ok(hwndCapture == hwnd1, "hwndCapture was %p\n", hwndCapture);
624
625 hwndActive = GetThreadActiveWnd(dwTID2);
626 hwndFocus = GetThreadFocus(dwTID2);
627 hwndCapture = GetThreadCapture(dwTID2);
628 ok(!hwndActive, "hwndActive was %p\n", hwndActive);
629 ok(!hwndFocus, "hwndFocus was %p\n", hwndFocus);
630 ok(!hwndCapture, "hwndFocus was %p\n", hwndCapture);
631
632 // Left click on hwnd2 menu bar
633 AutoClick(AUTO_LEFT_CLICK, xMenuBar2, yMenuBar2);
635
636 hwndFore = GetForegroundWindow();
637 ok(hwndFore == hwnd2, "hwndFore was %p\n", hwndFore);
638
639 hwndActive = GetThreadActiveWnd(dwTID1);
640 hwndFocus = GetThreadFocus(dwTID1);
641 hwndCapture = GetThreadCapture(dwTID1);
642 ok(!hwndActive, "hwndActive was %p\n", hwndActive);
643 ok(!hwndFocus, "hwndFocus was %p\n", hwndFocus);
644 ok(!hwndCapture, "hwndFocus was %p\n", hwndCapture);
645
646 hwndActive = GetThreadActiveWnd(dwTID2);
647 hwndFocus = GetThreadFocus(dwTID2);
648 hwndCapture = GetThreadCapture(dwTID2);
649 ok(hwndActive == hwnd2, "hwndActive was %p\n", hwndActive);
650 ok(hwndFocus == hwnd2, "hwndFocus was %p\n", hwndFocus);
651 ok(hwndCapture == hwnd2, "hwndFocus was %p\n", hwndCapture);
652
653 // Left click on hwnd1 menu bar
654 AutoClick(AUTO_LEFT_CLICK, xMenuBar1, yMenuBar1);
656
657 hwndFore = GetForegroundWindow();
658 ok(hwndFore == hwnd1, "hwndFore was %p\n", hwndFore);
659
660 hwndActive = GetThreadActiveWnd(dwTID1);
661 hwndFocus = GetThreadFocus(dwTID1);
662 hwndCapture = GetThreadCapture(dwTID1);
663 ok(hwndActive == hwnd1, "hwndActive was %p\n", hwndActive);
664 ok(hwndFocus == hwnd1, "hwndFocus was %p\n", hwndFocus);
665 ok(hwndCapture == hwnd1, "hwndCapture was %p\n", hwndCapture);
666
667 hwndActive = GetThreadActiveWnd(dwTID2);
668 hwndFocus = GetThreadFocus(dwTID2);
669 hwndCapture = GetThreadCapture(dwTID2);
670 ok(!hwndActive, "hwndActive was %p\n", hwndActive);
671 ok(!hwndFocus, "hwndFocus was %p\n", hwndFocus);
672 ok(!hwndCapture, "hwndFocus was %p\n", hwndCapture);
673
674 // Get title bar info
675 TITLEBARINFO titleInfo = { sizeof(titleInfo) };
676 RECT rcTitleBar1, rcTitleBar2;
677 GetTitleBarInfo(hwnd1, &titleInfo);
678 rcTitleBar1 = titleInfo.rcTitleBar;
679 GetTitleBarInfo(hwnd2, &titleInfo);
680 rcTitleBar2 = titleInfo.rcTitleBar;
681 POINT ptTitleBar1 = CenterPoint(&rcTitleBar1);
682 POINT ptTitleBar2 = CenterPoint(&rcTitleBar2);
683
684 // Right click on hwnd2 title bar
685 AutoClick(AUTO_RIGHT_CLICK, ptTitleBar2.x, ptTitleBar2.y);
687
688 hwndActive = GetThreadActiveWnd(dwTID1);
689 hwndFocus = GetThreadFocus(dwTID1);
690 hwndCapture = GetThreadCapture(dwTID1);
691 ok(!hwndActive, "hwndActive was %p\n", hwndActive);
692 ok(!hwndFocus, "hwndFocus was %p\n", hwndFocus);
693 ok(!hwndCapture, "hwndFocus was %p\n", hwndCapture);
694
695 hwndActive = GetThreadActiveWnd(dwTID2);
696 hwndFocus = GetThreadFocus(dwTID2);
697 hwndCapture = GetThreadCapture(dwTID2);
698 ok(hwndActive == hwnd2, "hwndActive was %p\n", hwndActive);
699 ok(hwndFocus == hwnd2, "hwndFocus was %p\n", hwndFocus);
700 ok(hwndCapture == hwnd2, "hwndFocus was %p\n", hwndCapture);
701
702 nMenuCount = CountMenuWnds();
703 ok(nMenuCount == 1, "nMenuCount was %d\n", nMenuCount);
704
705 // Right click on hwnd1 title bar
706 AutoClick(AUTO_RIGHT_CLICK, ptTitleBar1.x, ptTitleBar1.y);
708
709 hwndActive = GetThreadActiveWnd(dwTID1);
710 hwndFocus = GetThreadFocus(dwTID1);
711 hwndCapture = GetThreadCapture(dwTID1);
712 ok(hwndActive == hwnd1, "hwndActive was %p\n", hwndActive);
713 ok(hwndFocus == hwnd1, "hwndFocus was %p\n", hwndFocus);
714 ok(hwndCapture == hwnd1, "hwndFocus was %p\n", hwndCapture);
715
716 hwndActive = GetThreadActiveWnd(dwTID2);
717 hwndFocus = GetThreadFocus(dwTID2);
718 hwndCapture = GetThreadCapture(dwTID2);
719 ok(!hwndActive, "hwndActive was %p\n", hwndActive);
720 ok(!hwndFocus, "hwndFocus was %p\n", hwndFocus);
721 ok(!hwndCapture, "hwndFocus was %p\n", hwndCapture);
722
723 nMenuCount = CountMenuWnds();
724 ok(nMenuCount == 1, "nMenuCount was %d\n", nMenuCount);
725
726 // Left double click on hwnd1 system menu icon (it will close hwnd1)
727 POINT ptSysMenu = { rcTitleBar1.left - GetSystemMetrics(SM_CXSMICON) / 2, ptTitleBar1.y };
728 ok(IsWindowVisible(hwnd1), "hwnd1 not visible\n");
729 AutoClick(AUTO_LEFT_DOUBLE_CLICK, ptSysMenu.x, ptSysMenu.y);
731
732 ok(!IsWindowVisible(hwnd1), "hwnd1 was visible\n");
733 nMenuCount = CountMenuWnds();
734 ok(nMenuCount == 0, "nMenuCount was %d\n", nMenuCount);
735
736 PostMessageW(hwnd1, WM_CLOSE, 0, 0);
737 PostMessageW(hwnd2, WM_CLOSE, 0, 0);
738
740 PostMessage(hwnd, WM_CLOSE, 0, 0);
741 return 0;
742}
#define MENUID_100
Definition: MenuUI.c:15
#define MENUID_101
Definition: MenuUI.c:16
#define MENUID_200
Definition: MenuUI.c:17
static HWND GetThreadFocus(DWORD dwThreadID)
Definition: MenuUI.c:194
static HWND GetThreadCapture(DWORD dwThreadID)
Definition: MenuUI.c:202
static INT CountMenuWnds(VOID)
Definition: MenuUI.c:157
static VOID AutoClick(AUTO_CLICK type, INT x, INT y)
Definition: MenuUI.c:65
static INT GetHitID(HWND hwndTarget)
Definition: MenuUI.c:130
static POINT CenterPoint(const RECT *prc)
Definition: MenuUI.c:123
static HWND GetThreadActiveWnd(DWORD dwThreadID)
Definition: MenuUI.c:186
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
static const WCHAR rc2[]
Definition: oid.c:1216
#define INFINITE
Definition: serial.h:102
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SEE_MASK_NOCLOSEPROCESS
Definition: shellapi.h:33
#define SEE_MASK_FLAG_NO_UI
Definition: shellapi.h:38
LPCWSTR lpParameters
Definition: shellapi.h:339
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
#define OBJID_MENU
Definition: winable.h:18
DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
BOOL WINAPI GetTitleBarInfo(_In_ HWND, _Inout_ PTITLEBARINFO)
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define SW_MINIMIZE
Definition: winuser.h:787
#define VK_UP
Definition: winuser.h:2244
#define SM_CXSMICON
Definition: winuser.h:1023
#define VK_RETURN
Definition: winuser.h:2220
DWORD WINAPI WaitForInputIdle(_In_ HANDLE, _In_ DWORD)
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
#define VK_LEFT
Definition: winuser.h:2243
#define VK_RIGHT
Definition: winuser.h:2245
#define VK_DOWN
Definition: winuser.h:2246
#define SW_RESTORE
Definition: winuser.h:790
#define VK_SHIFT
Definition: winuser.h:2221
#define VK_ESCAPE
Definition: winuser.h:2233
BOOL WINAPI GetMenuBarInfo(_In_ HWND, _In_ LONG, _In_ LONG, _Inout_ PMENUBARINFO)
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)

Referenced by OnCreate().

◆ WindowProc()

static LRESULT CALLBACK WindowProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 767 of file MenuUI.c.

768{
769 switch (uMsg)
770 {
771 case WM_CREATE:
772 return OnCreate(hwnd);
773 case WM_DESTROY:
775 break;
776 default:
777 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
778 }
779 return 0;
780}
static VOID OnDestroy(HWND hwnd)
Definition: MenuUI.c:754
static INT OnCreate(HWND hwnd)
Definition: MenuUI.c:745
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_CREATE
Definition: winuser.h:1627
#define WM_DESTROY
Definition: winuser.h:1628

Referenced by TEST_MenuUI().

Variable Documentation

◆ s_hThread

HANDLE s_hThread = NULL
static

Definition at line 27 of file MenuUI.c.

Referenced by OnCreate(), and OnDestroy().

◆ s_pShellExecuteExW

FN_ShellExecuteExW s_pShellExecuteExW = NULL
static

Definition at line 21 of file MenuUI.c.

Referenced by START_TEST(), and ThreadFunc().