1 /* 2 * PROJECT: ReactOS API tests 3 * LICENSE: GPL - See COPYING in the top level directory 4 * PURPOSE: Test for DeferWindowPos function family 5 * PROGRAMMERS: Thomas Faber <thomas.faber@reactos.org> 6 */ 7 8 #include "precomp.h" 9 10 HWND hWnd1, hWnd2, hWnd3, hWnd4; 11 12 /* FIXME: test for HWND_TOP, etc...*/ 13 static int get_iwnd(HWND hWnd) 14 { 15 if(hWnd == hWnd1) return 1; 16 else if(hWnd == hWnd2) return 2; 17 else if(hWnd == hWnd3) return 3; 18 else if(hWnd == hWnd4) return 4; 19 else return 0; 20 } 21 22 LRESULT CALLBACK DWPTestProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 23 { 24 int iwnd = get_iwnd(hWnd); 25 26 if(message > WM_USER || !iwnd || IsDWmMsg(message) || IseKeyMsg(message)) 27 return DefWindowProc(hWnd, message, wParam, lParam); 28 29 switch(message) 30 { 31 case WM_IME_SETCONTEXT: 32 case WM_IME_NOTIFY : 33 case WM_GETICON : 34 case WM_GETTEXT: 35 break; 36 case WM_WINDOWPOSCHANGING: 37 case WM_WINDOWPOSCHANGED: 38 { 39 WINDOWPOS* pwp = (WINDOWPOS*)lParam; 40 ok(wParam==0,"expected wParam=0\n"); 41 RECORD_MESSAGE(iwnd, message, SENT, get_iwnd(pwp->hwndInsertAfter), pwp->flags); 42 break; 43 } 44 default: 45 RECORD_MESSAGE(iwnd, message, SENT, 0,0); 46 } 47 return DefWindowProc(hWnd, message, wParam, lParam); 48 } 49 50 static void FlushMessages() 51 { 52 MSG msg; 53 54 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) 55 { 56 int iwnd = get_iwnd(msg.hwnd); 57 if(!(msg.message > WM_USER || !iwnd || IsDWmMsg(msg.message) || IseKeyMsg(msg.message))) 58 RECORD_MESSAGE(iwnd, msg.message, POST,0,0); 59 DispatchMessageA( &msg ); 60 } 61 } 62 63 /* unfortunately sometimes MSCTF windows get between the expected chain of windows 64 so just checking the next window does not work*/ 65 static BOOL IsNext(HWND hWnd1, HWND hWnd2) 66 { 67 HWND hWndNext; 68 69 hWndNext=hWnd1; 70 while((hWndNext = GetWindow(hWndNext,GW_HWNDNEXT))) 71 { 72 if(hWndNext == hWnd2) 73 { 74 return TRUE; 75 } 76 } 77 return FALSE; 78 } 79 80 #define EXPECT_NEXT(hWnd1, hWnd2) \ 81 ok(IsNext(hWnd1, hWnd2), \ 82 "After hwnd%d, expected hwnd%d not hwnd%d\n", \ 83 get_iwnd(hWnd1), get_iwnd(hWnd2),get_iwnd(GetWindow(hWnd1,GW_HWNDNEXT)) ) 84 85 #define EXPECT_CHAIN(A,B,C,D) \ 86 EXPECT_NEXT(hWnd##A, hWnd##B); \ 87 EXPECT_NEXT(hWnd##B, hWnd##C); \ 88 EXPECT_NEXT(hWnd##C, hWnd##D); 89 90 #define ok_windowpos(hwnd, x, y, w, h, wnd) do { RECT rt; GetWindowRect(hwnd, &rt); \ 91 ok(rt.left == (x) && rt.top == (y) && rt.right == (x)+(w) && rt.bottom == (y)+(h), \ 92 "Unexpected %s position: (%ld, %ld) - (%ld, %ld)\n", wnd, rt.left, rt.top, rt.right, rt.bottom); } while (0) 93 94 #define ok_lasterr(err, s) ok(GetLastError() == (err), "%s error = %lu\n", s, GetLastError()) 95 96 static void set_default_pos() 97 { 98 SetWindowPos(hWnd1, 0, 10,20,200,210, SWP_NOOWNERZORDER|SWP_SHOWWINDOW|SWP_NOACTIVATE); 99 SetWindowPos(hWnd2, 0, 30,40,220,230, SWP_NOOWNERZORDER|SWP_SHOWWINDOW|SWP_NOACTIVATE); 100 SetWindowPos(hWnd3, 0, 20,350,300,300, SWP_NOOWNERZORDER|SWP_SHOWWINDOW|SWP_NOACTIVATE); 101 SetWindowPos(hWnd4, 0, 250,250,200,200, SWP_NOOWNERZORDER|SWP_SHOWWINDOW|SWP_NOACTIVATE); 102 SetActiveWindow(hWnd4); 103 FlushMessages(); 104 EMPTY_CACHE(); 105 } 106 107 static void Test_DWP_Error(HWND hWnd, HWND hWnd2) 108 { 109 HDWP hDwp; 110 BOOL ret; 111 112 ok_windowpos(hWnd1, 10, 20, 200, 210, "Window 1"); 113 ok_windowpos(hWnd2, 30, 40, 220, 230, "Window 2"); 114 115 /* close invalid handles */ 116 SetLastError(DNS_ERROR_RCODE_NXRRSET); 117 ret = EndDeferWindowPos(NULL); 118 ok(ret == 0, "EndDeferWindowPos succeeded with invalid handle\n"); 119 ok_lasterr(ERROR_INVALID_DWP_HANDLE, "EndDeferWindowPos"); 120 121 SetLastError(DNS_ERROR_RCODE_NXRRSET); 122 ret = EndDeferWindowPos((HDWP)-1); 123 ok(ret == 0, "EndDeferWindowPos succeeded with invalid handle\n"); 124 ok_lasterr(ERROR_INVALID_DWP_HANDLE, "EndDeferWindowPos"); 125 126 /* negative window count */ 127 SetLastError(DNS_ERROR_RCODE_NXRRSET); 128 hDwp = BeginDeferWindowPos(-1); 129 ok(hDwp == NULL, "BeginDeferWindowPos failed\n"); 130 ok_lasterr(ERROR_INVALID_PARAMETER, "BeginDeferWindowPos"); 131 132 /* zero windows */ 133 SetLastError(DNS_ERROR_RCODE_NXRRSET); 134 hDwp = BeginDeferWindowPos(0); 135 ok(hDwp != NULL, "BeginDeferWindowPos failed\n"); 136 ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "BeginDeferWindowPos"); 137 ret = EndDeferWindowPos(hDwp); 138 ok(ret != 0, "EndDeferWindowPos failed\n"); 139 ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "EndDeferWindowPos"); 140 141 /* more windows than expected */ 142 SetLastError(DNS_ERROR_RCODE_NXRRSET); 143 hDwp = BeginDeferWindowPos(0); 144 ok(hDwp != NULL, "BeginDeferWindowPos failed\n"); 145 ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "BeginDeferWindowPos"); 146 hDwp = DeferWindowPos(hDwp, hWnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER); 147 ok(hDwp != NULL, "DeferWindowPos failed\n"); 148 ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "DeferWindowPos"); 149 ret = EndDeferWindowPos(hDwp); 150 ok(ret != 0, "EndDeferWindowPos failed\n"); 151 ok(GetLastError() == ERROR_SUCCESS /* win7 sp1/x64 */ 152 || GetLastError() == ERROR_INVALID_WINDOW_HANDLE /* 2k3 sp1/x86 */, 153 "EndDeferWindowPos error = %lu\n", GetLastError()); 154 ok_windowpos(hWnd, 10, 20, 200, 210, "Window 1"); 155 156 /* more windows than expected 2 */ 157 SetLastError(DNS_ERROR_RCODE_NXRRSET); 158 hDwp = BeginDeferWindowPos(1); 159 ok(hDwp != NULL, "BeginDeferWindowPos failed\n"); 160 ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "BeginDeferWindowPos"); 161 hDwp = DeferWindowPos(hDwp, hWnd, NULL, 30, 20, 190, 195, SWP_NOZORDER); 162 ok(hDwp != NULL, "DeferWindowPos failed\n"); 163 ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "DeferWindowPos"); 164 hDwp = DeferWindowPos(hDwp, hWnd2, NULL, 20, 30, 195, 190, SWP_NOZORDER); 165 ok(hDwp != NULL, "DeferWindowPos failed\n"); 166 ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "DeferWindowPos"); 167 ret = EndDeferWindowPos(hDwp); 168 ok(ret != 0, "EndDeferWindowPos failed\n"); 169 ok_lasterr(ERROR_SUCCESS, "EndDeferWindowPos"); 170 ok_windowpos(hWnd, 30, 20, 190, 195, "Window 1"); 171 ok_windowpos(hWnd2, 20, 30, 195, 190, "Window 2"); 172 173 /* fewer windows than expected */ 174 MoveWindow(hWnd, 10, 20, 200, 210, FALSE); 175 SetLastError(DNS_ERROR_RCODE_NXRRSET); 176 hDwp = BeginDeferWindowPos(2); 177 ok(hDwp != NULL, "BeginDeferWindowPos failed\n"); 178 ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "BeginDeferWindowPos"); 179 hDwp = DeferWindowPos(hDwp, hWnd, NULL, 20, 10, 210, 200, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER); 180 ok(hDwp != NULL, "DeferWindowPos failed\n"); 181 ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "DeferWindowPos"); 182 ret = EndDeferWindowPos(hDwp); 183 ok(ret != 0, "EndDeferWindowPos failed\n"); 184 ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "EndDeferWindowPos"); 185 ok_windowpos(hWnd, 10, 20, 200, 210, "Window 1"); 186 187 /* no operation, 1 window */ 188 SetLastError(DNS_ERROR_RCODE_NXRRSET); 189 hDwp = BeginDeferWindowPos(1); 190 ok(hDwp != NULL, "BeginDeferWindowPos failed\n"); 191 ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "BeginDeferWindowPos"); 192 hDwp = DeferWindowPos(hDwp, hWnd, NULL, 20, 10, 210, 200, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER); 193 ok(hDwp != NULL, "DeferWindowPos failed\n"); 194 ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "DeferWindowPos"); 195 ret = EndDeferWindowPos(hDwp); 196 ok(ret != 0, "EndDeferWindowPos failed\n"); 197 ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "EndDeferWindowPos"); 198 ok_windowpos(hWnd, 10, 20, 200, 210, "Window 1"); 199 200 /* same window twice */ 201 SetLastError(DNS_ERROR_RCODE_NXRRSET); 202 hDwp = BeginDeferWindowPos(2); 203 ok(hDwp != NULL, "BeginDeferWindowPos failed\n"); 204 ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "BeginDeferWindowPos"); 205 hDwp = DeferWindowPos(hDwp, hWnd, NULL, 80, 90, 220, 210, SWP_NOZORDER); 206 ok(hDwp != NULL, "DeferWindowPos failed\n"); 207 ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "DeferWindowPos"); 208 hDwp = DeferWindowPos(hDwp, hWnd, NULL, 100, 110, 230, 250, SWP_NOZORDER); 209 ok(hDwp != NULL, "DeferWindowPos failed\n"); 210 ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "DeferWindowPos"); 211 ret = EndDeferWindowPos(hDwp); 212 ok(ret != 0, "EndDeferWindowPos failed\n"); 213 ok_lasterr(ERROR_SUCCESS, "EndDeferWindowPos"); 214 ok_windowpos(hWnd, 100, 110, 230, 250, "Window 1"); 215 216 /* move & resize operation, 1 window */ 217 SetLastError(DNS_ERROR_RCODE_NXRRSET); 218 hDwp = BeginDeferWindowPos(1); 219 ok(hDwp != NULL, "BeginDeferWindowPos failed\n"); 220 ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "BeginDeferWindowPos"); 221 hDwp = DeferWindowPos(hDwp, hWnd, NULL, 20, 10, 210, 200, SWP_NOZORDER); 222 ok(hDwp != NULL, "DeferWindowPos failed\n"); 223 ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "DeferWindowPos"); 224 ret = EndDeferWindowPos(hDwp); 225 ok(ret != 0, "EndDeferWindowPos failed\n"); 226 ok_lasterr(ERROR_SUCCESS, "EndDeferWindowPos"); 227 ok_windowpos(hWnd, 20, 10, 210, 200, "Window 1"); 228 229 /* move & resize operation, 2 windows */ 230 SetLastError(DNS_ERROR_RCODE_NXRRSET); 231 hDwp = BeginDeferWindowPos(2); 232 ok(hDwp != NULL, "BeginDeferWindowPos failed\n"); 233 ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "BeginDeferWindowPos"); 234 hDwp = DeferWindowPos(hDwp, hWnd, NULL, 50, 60, 230, 240, SWP_NOZORDER); 235 ok(hDwp != NULL, "DeferWindowPos failed\n"); 236 ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "DeferWindowPos"); 237 hDwp = DeferWindowPos(hDwp, hWnd2, NULL, 70, 80, 250, 260, SWP_NOZORDER); 238 ok(hDwp != NULL, "DeferWindowPos failed\n"); 239 ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "DeferWindowPos"); 240 ret = EndDeferWindowPos(hDwp); 241 ok(ret != 0, "EndDeferWindowPos failed\n"); 242 ok_lasterr(ERROR_SUCCESS, "EndDeferWindowPos"); 243 ok_windowpos(hWnd, 50, 60, 230, 240, "Window 1"); 244 ok_windowpos(hWnd2, 70, 80, 250, 260, "Window 2"); 245 246 FlushMessages(); 247 EMPTY_CACHE(); 248 } 249 250 MSG_ENTRY move1_chain[]={ 251 {1,WM_WINDOWPOSCHANGING, SENT, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER}, 252 {1,WM_GETMINMAXINFO}, 253 {1,WM_WINDOWPOSCHANGED, SENT, 0, SWP_NOSIZE | SWP_NOACTIVATE|SWP_NOOWNERZORDER | SWP_NOCLIENTSIZE}, 254 {1,WM_MOVE}, 255 {0,0}}; 256 257 MSG_ENTRY resize1_chain[]={ 258 {1,WM_WINDOWPOSCHANGING, SENT, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER}, 259 {1,WM_GETMINMAXINFO}, 260 {1,WM_NCCALCSIZE}, 261 {1,WM_WINDOWPOSCHANGED, SENT, 0, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE|SWP_NOOWNERZORDER | SWP_NOCLIENTMOVE}, 262 {1,WM_SIZE}, 263 // {1,WM_NCCALCSIZE}, // This doesn't occur on either WHS testbot or Windows 10 264 {0,0}}; 265 266 MSG_ENTRY move1_2_chain[]={ 267 {1,WM_WINDOWPOSCHANGING, SENT, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER}, 268 {1,WM_GETMINMAXINFO}, 269 {2,WM_WINDOWPOSCHANGING, SENT, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER}, 270 {2,WM_GETMINMAXINFO}, 271 {1,WM_WINDOWPOSCHANGED, SENT, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE|SWP_NOOWNERZORDER | SWP_NOCLIENTSIZE}, 272 {1,WM_MOVE}, 273 {2,WM_WINDOWPOSCHANGED, SENT, 0, SWP_NOSIZE | SWP_NOACTIVATE|SWP_NOOWNERZORDER | SWP_NOCLIENTSIZE}, 274 {2,WM_MOVE}, 275 {0,0}}; 276 277 278 MSG_ENTRY ZOrder1_chain[]={ 279 {1,WM_WINDOWPOSCHANGING, SENT, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOSIZE}, 280 {1,WM_WINDOWPOSCHANGED, SENT, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOSIZE | SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE}, 281 {0,0}}; 282 283 MSG_ENTRY ZOrder1and2_chain[]={ 284 {1,WM_WINDOWPOSCHANGING, SENT, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOSIZE}, 285 {2,WM_WINDOWPOSCHANGING, SENT, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOSIZE}, 286 {1,WM_WINDOWPOSCHANGED, SENT, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOSIZE | SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE}, 287 {2,WM_WINDOWPOSCHANGED, SENT, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOSIZE | SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE}, 288 {0,0}}; 289 290 static void Test_DWP_SimpleMsg(HWND hWnd1, HWND hWnd2) 291 { 292 HDWP hdwp; 293 BOOL ret; 294 295 SetWindowPos(hWnd1, 0, 10,20,100,100,0); 296 SetWindowPos(hWnd2, 0, 10,20,100,100,0); 297 FlushMessages(); 298 EMPTY_CACHE(); 299 300 /* move hWnd1 */ 301 hdwp = BeginDeferWindowPos(1); 302 ok(hdwp != NULL, "BeginDeferWindowPos failed\n"); 303 hdwp = DeferWindowPos(hdwp, hWnd1, HWND_TOP, 20, 30, 100, 100, SWP_NOACTIVATE|SWP_NOOWNERZORDER); 304 ok(hdwp != NULL, "DeferWindowPos failed\n"); 305 FlushMessages(); 306 COMPARE_CACHE(empty_chain); 307 ret = EndDeferWindowPos(hdwp); 308 ok(ret != 0, "EndDeferWindowPos failed\n"); 309 FlushMessages(); 310 COMPARE_CACHE(move1_chain); 311 312 /* resize hWnd1 */ 313 hdwp = BeginDeferWindowPos(1); 314 ok(hdwp != NULL, "BeginDeferWindowPos failed\n"); 315 hdwp = DeferWindowPos(hdwp, hWnd1, HWND_TOP, 20, 30, 110, 110, SWP_NOACTIVATE|SWP_NOOWNERZORDER); 316 ok(hdwp != NULL, "DeferWindowPos failed\n"); 317 FlushMessages(); 318 COMPARE_CACHE(empty_chain); 319 ret = EndDeferWindowPos(hdwp); 320 ok(ret != 0, "EndDeferWindowPos failed\n"); 321 FlushMessages(); 322 COMPARE_CACHE(resize1_chain); 323 324 /* move both windows */ 325 hdwp = BeginDeferWindowPos(1); 326 ok(hdwp != NULL, "BeginDeferWindowPos failed\n"); 327 hdwp = DeferWindowPos(hdwp, hWnd1, HWND_TOP, 30, 40, 110, 110, SWP_NOACTIVATE|SWP_NOOWNERZORDER); 328 ok(hdwp != NULL, "DeferWindowPos failed\n"); 329 hdwp = DeferWindowPos(hdwp, hWnd2, HWND_TOP, 30, 40, 100, 100, SWP_NOACTIVATE|SWP_NOOWNERZORDER); 330 ok(hdwp != NULL, "DeferWindowPos failed\n"); 331 FlushMessages(); 332 COMPARE_CACHE(empty_chain); 333 ret = EndDeferWindowPos(hdwp); 334 ok(ret != 0, "EndDeferWindowPos failed\n"); 335 FlushMessages(); 336 COMPARE_CACHE(move1_2_chain); 337 338 /* change the z-order of the first window */ 339 hdwp = BeginDeferWindowPos(1); 340 ok(hdwp != NULL, "BeginDeferWindowPos failed\n"); 341 hdwp = DeferWindowPos(hdwp, hWnd1, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOSIZE); 342 ok(hdwp != NULL, "DeferWindowPos failed\n"); 343 FlushMessages(); 344 COMPARE_CACHE(empty_chain); 345 ret = EndDeferWindowPos(hdwp); 346 ok(ret != 0, "EndDeferWindowPos failed\n"); 347 FlushMessages(); 348 COMPARE_CACHE(ZOrder1_chain); 349 350 /* change the z-order of both windows */ 351 hdwp = BeginDeferWindowPos(2); 352 ok(hdwp != NULL, "BeginDeferWindowPos failed\n"); 353 hdwp = DeferWindowPos(hdwp, hWnd1, HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOSIZE); 354 ok(hdwp != NULL, "DeferWindowPos failed\n"); 355 hdwp = DeferWindowPos(hdwp, hWnd2, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOSIZE); 356 ok(hdwp != NULL, "DeferWindowPos failed\n"); 357 FlushMessages(); 358 COMPARE_CACHE(empty_chain); 359 ret = EndDeferWindowPos(hdwp); 360 ok(ret != 0, "EndDeferWindowPos failed\n"); 361 FlushMessages(); 362 COMPARE_CACHE(ZOrder1and2_chain); 363 364 } 365 366 #define OwnerZOrderAParams SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOSIZE 367 368 MSG_ENTRY OwnerZOrder1A_chain[]={ 369 {4,WM_WINDOWPOSCHANGING, SENT,0, OwnerZOrderAParams}, 370 {3,WM_WINDOWPOSCHANGING, SENT,4, OwnerZOrderAParams}, 371 {1,WM_WINDOWPOSCHANGING, SENT,3, OwnerZOrderAParams}, 372 {0,0}}; 373 374 MSG_ENTRY OwnerZOrder2A_chain[]={ 375 {2,WM_WINDOWPOSCHANGING, SENT, 0, OwnerZOrderAParams}, 376 {2,WM_WINDOWPOSCHANGED , SENT, 0, OwnerZOrderAParams | SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE}, 377 {0,0}}; 378 379 MSG_ENTRY OwnerZOrder3A_chain[]={ 380 {3,WM_WINDOWPOSCHANGING, SENT, 0, OwnerZOrderAParams}, 381 {4,WM_WINDOWPOSCHANGING, SENT, 0, OwnerZOrderAParams}, 382 {1,WM_WINDOWPOSCHANGING, SENT, 4, OwnerZOrderAParams}, 383 {3,WM_WINDOWPOSCHANGED, SENT, 0, OwnerZOrderAParams |SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE}, 384 {4,WM_WINDOWPOSCHANGED, SENT, 0, OwnerZOrderAParams |SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE}, 385 {1,WM_WINDOWPOSCHANGED, SENT, 4, OwnerZOrderAParams |SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE}, 386 {0,0}}; 387 388 MSG_ENTRY OwnerZOrder4A_chain[]={ 389 {3,WM_WINDOWPOSCHANGING, SENT, 0 ,OwnerZOrderAParams}, 390 {4,WM_WINDOWPOSCHANGING, SENT, 0, OwnerZOrderAParams} , 391 {1,WM_WINDOWPOSCHANGING, SENT, 4, OwnerZOrderAParams}, 392 {0,0}}; 393 394 MSG_ENTRY OwnerZOrder5A_chain[]={ 395 {4,WM_WINDOWPOSCHANGING, SENT, 0, OwnerZOrderAParams}, 396 {3,WM_WINDOWPOSCHANGING, SENT, 4, OwnerZOrderAParams}, 397 {1,WM_WINDOWPOSCHANGING, SENT, 3, OwnerZOrderAParams}, 398 {4,WM_WINDOWPOSCHANGED, SENT, 0, OwnerZOrderAParams|SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE}, 399 {0,0}}; 400 401 #define OwnerZOrderBParams SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOOWNERZORDER 402 403 MSG_ENTRY OwnerZOrder1B_chain[]={ 404 {1,WM_WINDOWPOSCHANGING, SENT, 0, OwnerZOrderBParams}, 405 {1,WM_WINDOWPOSCHANGED, SENT, 0, OwnerZOrderBParams | SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE}, 406 {0,0}}; 407 408 MSG_ENTRY OwnerZOrder2B_chain[]={ 409 {2,WM_WINDOWPOSCHANGING, SENT, 0, OwnerZOrderBParams}, 410 {2,WM_WINDOWPOSCHANGED, SENT, 0, OwnerZOrderBParams | SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE}, 411 {0,0}}; 412 413 MSG_ENTRY OwnerZOrder3B_chain[]={ 414 {3,WM_WINDOWPOSCHANGING, SENT, 0, OwnerZOrderBParams}, 415 {3,WM_WINDOWPOSCHANGED, SENT, 0, OwnerZOrderBParams | SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE}, 416 {0,0}}; 417 418 MSG_ENTRY OwnerZOrder4B_chain[]={ 419 {1,WM_WINDOWPOSCHANGING, SENT, 0, OwnerZOrderBParams}, 420 {1,WM_WINDOWPOSCHANGED, SENT, 0, OwnerZOrderBParams | SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE}, 421 {0,0}}; 422 423 MSG_ENTRY OwnerZOrder5B_chain[]={ 424 {4,WM_WINDOWPOSCHANGING, SENT, 0, OwnerZOrderBParams}, 425 {4,WM_WINDOWPOSCHANGED, SENT, 0, OwnerZOrderBParams | SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE}, 426 {0,0}}; 427 428 static void Test_DWP_OwnerZOrder() 429 { 430 EXPECT_CHAIN(4,3,1,2); 431 432 /* test how SetWindowPos can change the z order of owner windows */ 433 /* note that SWP_NOACTIVATE must be used because otherwise 434 SetWindowPos will call SetWindowPos again with different parameters */ 435 SetWindowPos(hWnd1, 0, 0,0,0,0, OwnerZOrderAParams); 436 FlushMessages(); 437 COMPARE_CACHE(OwnerZOrder1A_chain); 438 EXPECT_CHAIN(4,3,1,2); 439 440 SetWindowPos(hWnd2, 0, 0,0,0,0, OwnerZOrderAParams); 441 FlushMessages(); 442 COMPARE_CACHE(OwnerZOrder2A_chain); 443 EXPECT_CHAIN(2,4,3,1); 444 445 SetWindowPos(hWnd3, 0, 0,0,0,0, OwnerZOrderAParams); 446 FlushMessages(); 447 COMPARE_CACHE(OwnerZOrder3A_chain); 448 EXPECT_CHAIN(3,4,1,2); 449 450 SetWindowPos(hWnd1, 0, 0,0,0,0, OwnerZOrderAParams); 451 FlushMessages(); 452 COMPARE_CACHE(OwnerZOrder4A_chain); 453 EXPECT_CHAIN(3,4,1,2); 454 455 SetWindowPos(hWnd4, 0, 0,0,0,0, OwnerZOrderAParams); 456 FlushMessages(); 457 COMPARE_CACHE(OwnerZOrder5A_chain); 458 EXPECT_CHAIN(4,3,1,2); 459 460 /* now do the same thing one more time with SWP_NOOWNERZORDER */ 461 /* SWP_NOACTIVATE is needed because without it SetActiveWindow 462 will be calledit and it will call SetWindowPos again 463 WITHOUT SWP_NOOWNERZORDER. that means that 464 in order for SWP_NOOWNERZORDER to have effect we have to use 465 SWP_NOACTIVATE as well */ 466 set_default_pos(); 467 EXPECT_CHAIN(4,3,2,1); 468 469 SetWindowPos(hWnd1, 0, 0,0,0,0, OwnerZOrderBParams); 470 FlushMessages(); 471 COMPARE_CACHE(OwnerZOrder1B_chain); 472 EXPECT_CHAIN(1,4,3,2); 473 474 SetWindowPos(hWnd2, 0, 0,0,0,0, OwnerZOrderBParams); 475 FlushMessages(); 476 COMPARE_CACHE(OwnerZOrder2B_chain); 477 EXPECT_CHAIN(2,1,4,3); 478 479 SetWindowPos(hWnd3, 0, 0,0,0,0, OwnerZOrderBParams); 480 FlushMessages(); 481 COMPARE_CACHE(OwnerZOrder3B_chain); 482 EXPECT_CHAIN(3,2,1,4); 483 484 SetWindowPos(hWnd1, 0, 0,0,0,0, OwnerZOrderBParams); 485 FlushMessages(); 486 COMPARE_CACHE(OwnerZOrder4B_chain); 487 EXPECT_CHAIN(1,3,2,4); 488 489 SetWindowPos(hWnd4, 0, 0,0,0,0, OwnerZOrderBParams); 490 FlushMessages(); 491 COMPARE_CACHE(OwnerZOrder5B_chain); 492 EXPECT_CHAIN(4,1,3,2); 493 494 } 495 496 START_TEST(DeferWindowPos) 497 { 498 SetCursorPos(0,0); 499 500 RegisterSimpleClass(DWPTestProc, L"ownertest"); 501 hWnd1 = CreateWindowExW(0, L"ownertest", L"abc", 0, 10, 20, 502 200, 210, NULL, NULL, 0, NULL); 503 hWnd2 = CreateWindowExW(0, L"ownertest", L"def", 0, 30, 40, 504 220, 230, NULL, NULL, 0, NULL); 505 hWnd3 = CreateWindowW(L"ownertest", L"ownertest", WS_OVERLAPPEDWINDOW, 506 20, 350, 300, 300, hWnd1, NULL, 0, NULL); 507 hWnd4 = CreateWindowW(L"ownertest", L"ownertest", WS_OVERLAPPEDWINDOW, 508 250, 250, 200, 200, hWnd1, NULL, 0, NULL); 509 510 ok(hWnd1 != NULL, "CreateWindow failed\n"); 511 ok(hWnd2 != NULL, "CreateWindow failed\n"); 512 ok(hWnd3 != NULL, "CreateWindow failed\n"); 513 ok(hWnd4 != NULL, "CreateWindow failed\n"); 514 515 set_default_pos(); 516 Test_DWP_Error(hWnd1, hWnd2); 517 518 set_default_pos(); 519 Test_DWP_SimpleMsg(hWnd1, hWnd2); 520 521 set_default_pos(); 522 Test_DWP_OwnerZOrder(); 523 524 DestroyWindow(hWnd4); 525 DestroyWindow(hWnd3); 526 DestroyWindow(hWnd2); 527 DestroyWindow(hWnd1); 528 } 529