Reactos

[USER32_WINETEST] Sync with Wine Staging 4.18 except win.c (PR #1980). CORE-16441

+4137 -908
+2 -1
modules/rostests/winetests/user32/CMakeLists.txt
··· 1 1 2 2 remove_definitions(-DWINVER=0x502 -D_WIN32_WINNT=0x502) 3 - add_definitions(-DWINVER=0x600 -D_WIN32_WINNT=0x600) 3 + add_definitions(-DWINVER=0x602 -D_WIN32_WINNT=0x602) 4 4 5 5 if(MSVC) 6 6 # Disable warning C4477 (printf format warnings) ··· 25 25 menu.c 26 26 monitor.c 27 27 msg.c 28 + rawinput.c 28 29 resource.c 29 30 scroll.c 30 31 static.c
+4 -116
modules/rostests/winetests/user32/broadcast.c
··· 130 130 ok(0, "Returned: %d\n", ret); 131 131 } 132 132 133 - recips = BSM_APPLICATIONS; 134 - ResetEvent(hevent); 135 - ret = broadcast( BSF_POSTMESSAGE|BSF_QUERY, &recips, WM_NULL, 100, 0 ); 136 - ok(ret==1, "Returned: %d\n", ret); 137 - ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n"); 138 - PulseEvent(hevent); 139 - 140 133 SetLastError( 0xdeadbeef ); 141 134 recips = BSM_APPLICATIONS; 142 135 ret = broadcast( BSF_POSTMESSAGE|BSF_SENDNOTIFYMESSAGE, &recips, WM_NULL, 100, 0 ); 143 - if (ret) 144 - { 145 - ok(ret==1, "Returned: %d\n", ret); 146 - ok(WaitForSingleObject(hevent, 0) != WAIT_OBJECT_0, "Synchronous message sent instead\n"); 147 - PulseEvent(hevent); 148 - 149 - recips = BSM_APPLICATIONS; 150 - ret = broadcast( BSF_SENDNOTIFYMESSAGE, &recips, WM_NULL, 100, BROADCAST_QUERY_DENY ); 151 - ok(ret==1, "Returned: %d\n", ret); 152 - ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n"); 153 - PulseEvent(hevent); 154 - 155 - recips = BSM_APPLICATIONS; 156 - ret = broadcast( BSF_SENDNOTIFYMESSAGE|BSF_QUERY, &recips, WM_NULL, 100, BROADCAST_QUERY_DENY ); 157 - ok(!ret, "Returned: %d\n", ret); 158 - ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n"); 159 - PulseEvent(hevent); 160 - } 161 - else /* BSF_SENDNOTIFYMESSAGE not supported on NT4 */ 162 - ok( GetLastError() == ERROR_INVALID_PARAMETER, "failed with err %u\n", GetLastError() ); 136 + ok(ret==1, "Returned: %d\n", ret); 137 + ok(WaitForSingleObject(hevent, 0) != WAIT_OBJECT_0, "Synchronous message sent instead\n"); 138 + PulseEvent(hevent); 163 139 164 140 recips = BSM_APPLICATIONS; 165 - ret = broadcast( 0, &recips, WM_NULL, 100, 0 ); 141 + ret = broadcast( BSF_SENDNOTIFYMESSAGE, &recips, WM_NULL, 100, BROADCAST_QUERY_DENY ); 166 142 ok(ret==1, "Returned: %d\n", ret); 167 143 ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n"); 168 144 PulseEvent(hevent); ··· 217 193 } 218 194 219 195 recips = BSM_APPLICATIONS; 220 - ResetEvent(hevent); 221 - ret = broadcastex( BSF_POSTMESSAGE|BSF_QUERY, &recips, WM_NULL, 100, 0, NULL ); 222 - ok(ret==1, "Returned: %d\n", ret); 223 - ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n"); 224 - PulseEvent(hevent); 225 - 226 - recips = BSM_APPLICATIONS; 227 196 ret = broadcastex( BSF_POSTMESSAGE|BSF_SENDNOTIFYMESSAGE, &recips, WM_NULL, 100, 0, NULL ); 228 197 ok(ret==1, "Returned: %d\n", ret); 229 198 ok(WaitForSingleObject(hevent, 0) != WAIT_OBJECT_0, "Synchronous message sent instead\n"); ··· 234 203 ok(ret==1, "Returned: %d\n", ret); 235 204 ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n"); 236 205 PulseEvent(hevent); 237 - 238 - recips = BSM_APPLICATIONS; 239 - ret = broadcastex( BSF_SENDNOTIFYMESSAGE|BSF_QUERY, &recips, WM_NULL, 100, BROADCAST_QUERY_DENY, NULL ); 240 - ok(!ret, "Returned: %d\n", ret); 241 - ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n"); 242 - PulseEvent(hevent); 243 - 244 - recips = BSM_APPLICATIONS; 245 - ret = broadcastex( 0, &recips, WM_NULL, 100, 0, NULL ); 246 - ok(ret==1, "Returned: %d\n", ret); 247 - ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n"); 248 - PulseEvent(hevent); 249 - } 250 - 251 - static void test_noprivileges(void) 252 - { 253 - HANDLE token; 254 - DWORD recips; 255 - BOOL ret; 256 - 257 - static const DWORD BSM_ALL_RECIPS = BSM_VXDS | BSM_NETDRIVER | 258 - BSM_INSTALLABLEDRIVERS | BSM_APPLICATIONS; 259 - 260 - if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token)) 261 - { 262 - skip("Can't open security token for process\n"); 263 - return; 264 - } 265 - if (!AdjustTokenPrivileges(token, TRUE, NULL, 0, NULL, NULL)) 266 - { 267 - skip("Can't adjust security token for process\n"); 268 - return; 269 - } 270 - 271 - trace("Trying privileged edition!\n"); 272 - SetLastError(0xcafebabe); 273 - recips = BSM_ALLDESKTOPS; 274 - ResetEvent(hevent); 275 - ret = BroadcastSystemMessageExW( BSF_QUERY, &recips, WM_NULL, 100, 0, NULL ); 276 - ok(ret==1, "Returned: %d error %u\n", ret, GetLastError()); 277 - ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n"); 278 - ok(recips == BSM_ALLDESKTOPS || 279 - recips == BSM_ALL_RECIPS, /* win2k3 */ 280 - "Received by: %08x\n", recips); 281 - PulseEvent(hevent); 282 - 283 - SetLastError(0xcafebabe); 284 - recips = BSM_ALLCOMPONENTS; 285 - ResetEvent(hevent); 286 - ret = BroadcastSystemMessageExW( BSF_QUERY, &recips, WM_NULL, 100, 0, NULL ); 287 - ok(ret==1, "Returned: %d error %u\n", ret, GetLastError()); 288 - ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n"); 289 - ok(recips == BSM_ALLCOMPONENTS || 290 - recips == BSM_ALL_RECIPS, /* win2k3 */ 291 - "Received by: %08x\n", recips); 292 - PulseEvent(hevent); 293 - 294 - SetLastError(0xcafebabe); 295 - recips = BSM_ALLDESKTOPS|BSM_APPLICATIONS; 296 - ResetEvent(hevent); 297 - ret = BroadcastSystemMessageExW( BSF_QUERY, &recips, WM_NULL, 100, 0, NULL ); 298 - ok(ret==1, "Returned: %d error %u\n", ret, GetLastError()); 299 - ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n"); 300 - ok(recips == (BSM_ALLDESKTOPS|BSM_APPLICATIONS) || 301 - recips == BSM_APPLICATIONS, /* win2k3 */ 302 - "Received by: %08x\n", recips); 303 - PulseEvent(hevent); 304 - 305 - SetLastError(0xcafebabe); 306 - recips = BSM_ALLDESKTOPS|BSM_APPLICATIONS; 307 - ResetEvent(hevent); 308 - ret = BroadcastSystemMessageExW( BSF_QUERY, &recips, WM_NULL, 100, BROADCAST_QUERY_DENY, NULL ); 309 - ok(!ret, "Returned: %d\n", ret); 310 - ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n"); 311 - ok(recips == (BSM_ALLDESKTOPS|BSM_APPLICATIONS) || 312 - recips == BSM_APPLICATIONS, /* win2k3 */ 313 - "Received by: %08x\n", recips); 314 - PulseEvent(hevent); 315 206 } 316 207 317 208 START_TEST(broadcast) ··· 330 221 331 222 trace("Running BroadcastSystemMessageExW tests\n"); 332 223 test_parametersEx(BroadcastSystemMessageExW); 333 - 334 - trace("Attempting privileges checking tests\n"); 335 - test_noprivileges(); 336 224 }
+34 -13
modules/rostests/winetests/user32/class.c
··· 117 117 return; 118 118 ok(classatom, "failed to register class\n"); 119 119 120 + ok(GetClipboardFormatNameW(classatom, str, ARRAY_SIZE(str)) != 0, "atom not found\n"); 121 + 120 122 ok(!RegisterClassW (&cls), 121 123 "RegisterClass of the same class should fail for the second time\n"); 122 124 ··· 171 173 } 172 174 173 175 /* check GetClassName */ 174 - i = GetClassNameW(hTestWnd, str, sizeof(str)/sizeof(str[0])); 176 + i = GetClassNameW(hTestWnd, str, ARRAY_SIZE(str)); 175 177 ok(i == lstrlenW(className), 176 178 "GetClassName returned incorrect length\n"); 177 179 ok(!lstrcmpW(className,str), ··· 232 234 ok(UnregisterClassW(className, hInstance), 233 235 "UnregisterClass() failed\n"); 234 236 237 + ok(GetClipboardFormatNameW(classatom, str, ARRAY_SIZE(str)) == 0, 238 + "atom still found\n"); 235 239 return; 236 240 } 237 241 ··· 647 651 "ScrollBar", 648 652 "#32770", /* dialog */ 649 653 }; 650 - static const int NUM_NORMAL_CLASSES = (sizeof(NORMAL_CLASSES)/sizeof(NORMAL_CLASSES[0])); 651 654 static const char classA[] = "deftest"; 652 655 static const WCHAR classW[] = {'d','e','f','t','e','s','t',0}; 653 656 WCHAR unistring[] = {0x142, 0x40e, 0x3b4, 0}; /* a string that would be destroyed by a W->A->W conversion */ ··· 658 661 WCHAR buf[128]; 659 662 ATOM atom; 660 663 HWND hwnd; 661 - int i; 664 + unsigned int i; 662 665 663 666 pDefWindowProcA = (void *)GetProcAddress(GetModuleHandleA("user32.dll"), "DefWindowProcA"); 664 667 pDefWindowProcW = (void *)GetProcAddress(GetModuleHandleA("user32.dll"), "DefWindowProcW"); ··· 728 731 ok(IsWindowUnicode(hwnd) || 729 732 broken(!IsWindowUnicode(hwnd)) /* Windows 8 and 10 */, 730 733 "Windows should be Unicode\n"); 731 - SendMessageW(hwnd, WM_GETTEXT, sizeof(buf) / sizeof(buf[0]), (LPARAM)buf); 734 + SendMessageW(hwnd, WM_GETTEXT, ARRAY_SIZE(buf), (LPARAM)buf); 732 735 if (IsWindowUnicode(hwnd)) 733 736 ok(memcmp(buf, unistring, sizeof(unistring)) == 0, "WM_GETTEXT invalid return\n"); 734 737 else ··· 773 776 774 777 /* For most of the builtin controls both GetWindowLongPtrA and W returns a pointer that is executed directly 775 778 * by CallWindowProcA/W */ 776 - for (i = 0; i < NUM_NORMAL_CLASSES; i++) 779 + for (i = 0; i < ARRAY_SIZE(NORMAL_CLASSES); i++) 777 780 { 778 781 WNDPROC procA, procW; 779 782 hwnd = CreateWindowExA(0, NORMAL_CLASSES[i], classA, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 680, 260, ··· 880 883 881 884 static LRESULT WINAPI TestDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 882 885 { 883 - return DefWindowProcA(hWnd, uMsg, wParam, lParam); 886 + return DefDlgProcA(hWnd, uMsg, wParam, lParam); 884 887 } 885 888 886 889 static BOOL RegisterTestDialog(HINSTANCE hInstance) ··· 942 945 static void test_extra_values(void) 943 946 { 944 947 int i; 945 - for(i=0; i< sizeof(extra_values)/sizeof(extra_values[0]); i++) 948 + for(i = 0; i < ARRAY_SIZE(extra_values); i++) 946 949 { 947 950 WNDCLASSEXA wcx; 948 951 BOOL ret = GetClassInfoExA(NULL,extra_values[i].name,&wcx); ··· 1000 1003 SetLastError(0xdeadbeef); 1001 1004 ret = GetClassInfoExA(0, "static", &wcx); 1002 1005 ok(ret, "GetClassInfoExA() error %d\n", GetLastError()); 1006 + ok(GetLastError() == 0xdeadbeef, "Unexpected error code %d\n", GetLastError()); 1003 1007 ok(wcx.cbSize == 0, "expected 0, got %u\n", wcx.cbSize); 1004 1008 ok(wcx.lpfnWndProc != NULL, "got null proc\n"); 1005 1009 ··· 1135 1139 1136 1140 name++; 1137 1141 1138 - GetTempPathA(sizeof(path)/sizeof(path[0]), path); 1142 + GetTempPathA(ARRAY_SIZE(path), path); 1139 1143 strcat(path, "comctl32_class.manifest"); 1140 1144 1141 1145 create_manifest_file(path, comctl32_manifest); ··· 1163 1167 if (!ret) 1164 1168 goto skiptest; 1165 1169 1166 - MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, sizeof(nameW)/sizeof(WCHAR) ); 1170 + MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, ARRAY_SIZE(nameW)); 1167 1171 ret = GetClassInfoW( 0, nameW, &wcW ); 1168 1172 ok( ret, "GetClassInfoW failed for %s\n", name ); 1169 1173 module = GetModuleHandleA( "comctl32" ); ··· 1189 1193 ret = GetClassInfoA( 0, name, &wcA ); 1190 1194 ok( ret || broken(!ret) /* <= winxp */, "GetClassInfoA failed for %s\n", name ); 1191 1195 if (!ret) return; 1192 - MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, sizeof(nameW)/sizeof(WCHAR) ); 1196 + MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, ARRAY_SIZE(nameW)); 1193 1197 ret = GetClassInfoW( 0, nameW, &wcW ); 1194 1198 ok( ret, "GetClassInfoW failed for %s\n", name ); 1195 1199 module = GetModuleHandleA( "comctl32" ); ··· 1245 1249 }; 1246 1250 1247 1251 winetest_get_mainargs( &argv ); 1248 - for (i = 0; i < sizeof(classes) / sizeof(classes[0]); i++) 1252 + for (i = 0; i < ARRAY_SIZE(classes); i++) 1249 1253 { 1250 1254 memset( &startup, 0, sizeof(startup) ); 1251 1255 startup.cb = sizeof( startup ); ··· 1321 1325 ATOM class; 1322 1326 HINSTANCE hinst; 1323 1327 char buff[64]; 1324 - HWND hwnd; 1328 + HWND hwnd, hwnd2; 1325 1329 char path[MAX_PATH]; 1326 1330 1327 - GetTempPathA(sizeof(path)/sizeof(path[0]), path); 1331 + GetTempPathA(ARRAY_SIZE(path), path); 1328 1332 strcat(path, "actctx_classes.manifest"); 1329 1333 1330 1334 create_manifest_file(path, main_manifest); ··· 1355 1359 hwnd = CreateWindowExA(0, testclass, "test", 0, 0, 0, 0, 0, 0, 0, hinst, 0); 1356 1360 ok(hwnd != NULL, "Failed to create a window.\n"); 1357 1361 1362 + hwnd2 = FindWindowExA(NULL, NULL, "MyTestClass", NULL); 1363 + ok(hwnd2 == hwnd, "Failed to find test window.\n"); 1364 + 1365 + hwnd2 = FindWindowExA(NULL, NULL, "4.3.2.1!MyTestClass", NULL); 1366 + ok(hwnd2 == NULL, "Unexpected find result %p.\n", hwnd2); 1367 + 1358 1368 ret = GetClassNameA(hwnd, buff, sizeof(buff)); 1359 1369 ok(ret, "Failed to get class name.\n"); 1360 1370 ok(!strcmp(buff, testclass), "Unexpected class name.\n"); ··· 1377 1387 ret = GetClassNameA(hwnd, buff, sizeof(buff)); 1378 1388 ok(ret, "Failed to get class name.\n"); 1379 1389 ok(!strcmp(buff, testclass), "Unexpected class name.\n"); 1390 + 1391 + DestroyWindow(hwnd); 1392 + 1393 + hwnd = CreateWindowExA(0, "4.3.2.1!MyTestClass", "test", 0, 0, 0, 0, 0, 0, 0, hinst, 0); 1394 + ok(hwnd != NULL, "Failed to create a window.\n"); 1395 + 1396 + hwnd2 = FindWindowExA(NULL, NULL, "MyTestClass", NULL); 1397 + ok(hwnd2 == hwnd, "Failed to find test window.\n"); 1398 + 1399 + hwnd2 = FindWindowExA(NULL, NULL, "4.3.2.1!MyTestClass", NULL); 1400 + ok(hwnd2 == NULL, "Unexpected find result %p.\n", hwnd2); 1380 1401 1381 1402 DestroyWindow(hwnd); 1382 1403
+2 -2
modules/rostests/winetests/user32/clipboard.c
··· 715 715 r = CloseClipboard(); 716 716 ok(r, "gle %d\n", GetLastError()); 717 717 718 - for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) 718 + for (i = 0; i < ARRAY_SIZE(tests); i++) 719 719 { 720 720 r = OpenClipboard(NULL); 721 721 ok(r, "%u: gle %d\n", i, GetLastError()); ··· 2054 2054 char bufferA[12]; 2055 2055 WCHAR bufferW[12]; 2056 2056 2057 - for (i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++) 2057 + for (i = 0; i < ARRAY_SIZE(test_data); i++) 2058 2058 { 2059 2059 /* 1-byte Unicode strings crash on Win64 */ 2060 2060 #ifdef _WIN64
+324 -7
modules/rostests/winetests/user32/cursoricon.c
··· 1053 1053 0xffffffff 1054 1054 }; 1055 1055 1056 - #ifndef __REACTOS__ 1057 - #define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0])) 1058 - #endif 1059 - 1060 1056 static void test_LoadImageBitmap(const char * test_desc, HBITMAP hbm) 1061 1057 { 1062 1058 BITMAP bm; ··· 1207 1203 HeapFree(GetProcessHeap(), 0, buf); 1208 1204 } 1209 1205 1206 + static void create_bitmap_file(const char *filename, const BITMAPINFO *bmi, const unsigned char *bits) 1207 + { 1208 + unsigned int clr_used, bmi_size, bits_size, stride; 1209 + const BITMAPINFOHEADER *h = &bmi->bmiHeader; 1210 + BITMAPFILEHEADER hdr; 1211 + DWORD bytes_written; 1212 + HANDLE file; 1213 + BOOL ret; 1214 + 1215 + clr_used = h->biBitCount <= 8 ? 1u << h->biBitCount : 0; 1216 + stride = ((h->biBitCount * h->biWidth + 7) / 8 + 3) & ~3; 1217 + bits_size = h->biHeight * stride; 1218 + bmi_size = h->biSize + clr_used * sizeof(RGBQUAD); 1219 + 1220 + hdr.bfType = 0x4d42; 1221 + hdr.bfOffBits = (DWORD)sizeof(BITMAPFILEHEADER) + bmi_size; 1222 + hdr.bfSize = hdr.bfOffBits + bits_size; 1223 + hdr.bfReserved1 = 0; 1224 + hdr.bfReserved2 = 0; 1225 + 1226 + file = CreateFileA(filename, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); 1227 + ok(file != INVALID_HANDLE_VALUE, "CreateFileA failed, result %u.\n", GetLastError()); 1228 + ret = WriteFile(file, &hdr, sizeof(hdr), &bytes_written, NULL); 1229 + ok(ret && bytes_written == sizeof(hdr), "Unexpected WriteFile() result, ret %#x, bytes_written %u.\n", 1230 + ret, bytes_written); 1231 + ret = WriteFile(file, bmi, bmi_size, &bytes_written, NULL); 1232 + ok(ret && bytes_written == bmi_size, "Unexpected WriteFile() result, ret %#x, bytes_written %u.\n", 1233 + ret, bytes_written); 1234 + ret = WriteFile(file, bits, bits_size, &bytes_written, NULL); 1235 + ok(ret && bytes_written == bits_size, "Unexpected WriteFile() result, ret %#x, bytes_written %u.\n", 1236 + ret, bytes_written); 1237 + CloseHandle(file); 1238 + } 1239 + 1240 + static void test_LoadImage_working_directory_run(char *path) 1241 + { 1242 + DWORD bytes_written; 1243 + HANDLE handle; 1244 + BOOL ret; 1245 + char path_icon[MAX_PATH]; 1246 + char path_image[MAX_PATH]; 1247 + static const test_icon_entries_t icon_desc = {32, 32}; 1248 + 1249 + sprintf(path_icon, "%s\\icon.ico", path); 1250 + sprintf(path_image, "%s\\test.bmp", path); 1251 + 1252 + /* Create Files */ 1253 + create_ico_file(path_icon, &icon_desc, 1); 1254 + 1255 + handle = CreateFileA(path_image, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); 1256 + ok(handle != INVALID_HANDLE_VALUE, "run %s: CreateFileA failed. %u\n", path, GetLastError()); 1257 + ret = WriteFile(handle, bmpimage, sizeof(bmpimage), &bytes_written, NULL); 1258 + ok(ret && bytes_written == sizeof(bmpimage), "run %s: Test file created improperly.\n", path); 1259 + CloseHandle(handle); 1260 + 1261 + /* Test cursor */ 1262 + handle = LoadImageA(NULL, "icon.ico", IMAGE_CURSOR, 0, 0, LR_LOADFROMFILE); 1263 + ok(handle != NULL, "run %s: LoadImage() failed.\n", path); 1264 + 1265 + ret = DestroyIcon(handle); 1266 + ok(ret, "run %s: DestroyIcon failed: %d\n", path, GetLastError()); 1267 + 1268 + /* Test image */ 1269 + handle = LoadImageA(NULL, "test.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); 1270 + ok(handle != NULL, "run %s: LoadImageA failed.\n", path); 1271 + 1272 + ret = DeleteObject(handle); 1273 + ok(ret, "run %s: DeleteObject failed: %d\n", path, GetLastError()); 1274 + 1275 + /* Cleanup */ 1276 + ret = DeleteFileA(path_image); 1277 + ok(ret, "run %s: DeleteFileA failed: %d\n", path, GetLastError()); 1278 + ret = DeleteFileA(path_icon); 1279 + ok(ret, "run %s: DeleteFileA failed: %d\n", path, GetLastError()); 1280 + } 1281 + 1282 + static void test_LoadImage_working_directory(void) 1283 + { 1284 + char old_working_dir[MAX_PATH]; 1285 + char temp_dir_current[MAX_PATH]; 1286 + char temp_dir_PATH[MAX_PATH]; 1287 + char executable_path[MAX_PATH]; 1288 + int pos_slash; 1289 + char old_PATH[10000]; 1290 + char new_PATH[10000]; 1291 + BOOL ret; 1292 + 1293 + GetCurrentDirectoryA(ARRAY_SIZE(old_working_dir), old_working_dir); 1294 + 1295 + GetTempPathA(ARRAY_SIZE(temp_dir_current), temp_dir_current); 1296 + strcat(temp_dir_current, "wine-test-dir-current\\"); 1297 + GetTempPathA(ARRAY_SIZE(temp_dir_PATH), temp_dir_PATH); 1298 + strcat(temp_dir_PATH, "wine-test-dir-path\\"); 1299 + 1300 + GetModuleFileNameA(NULL, executable_path, ARRAY_SIZE(executable_path)); 1301 + pos_slash = strrchr(executable_path, '\\') - executable_path; 1302 + executable_path[pos_slash + 1] = 0; 1303 + 1304 + CreateDirectoryA(temp_dir_current, NULL); 1305 + CreateDirectoryA(temp_dir_PATH, NULL); 1306 + 1307 + SetCurrentDirectoryA(temp_dir_current); 1308 + 1309 + GetEnvironmentVariableA("PATH", old_PATH, ARRAY_SIZE(old_PATH)); 1310 + sprintf(new_PATH, "%s;%s", old_PATH, temp_dir_PATH); 1311 + SetEnvironmentVariableA("PATH", new_PATH); 1312 + 1313 + test_LoadImage_working_directory_run(temp_dir_current); 1314 + test_LoadImage_working_directory_run(executable_path); 1315 + test_LoadImage_working_directory_run(temp_dir_PATH); 1316 + 1317 + SetCurrentDirectoryA(old_working_dir); 1318 + SetEnvironmentVariableA("PATH", old_PATH); 1319 + 1320 + ret = RemoveDirectoryA(temp_dir_current); 1321 + ok(ret, "RemoveDirectoryA failed: %d\n", GetLastError()); 1322 + ret = RemoveDirectoryA(temp_dir_PATH); 1323 + ok(ret, "RemoveDirectoryA failed: %d\n", GetLastError()); 1324 + } 1325 + 1210 1326 static void test_LoadImage(void) 1211 1327 { 1212 1328 HANDLE handle; ··· 1330 1446 bitmap_header->biSize = sizeof(BITMAPINFOHEADER); 1331 1447 1332 1448 test_LoadImageFile("Cursor (invalid dwDIBOffset)", invalid_dwDIBOffset, sizeof(invalid_dwDIBOffset), "cur", 0); 1449 + 1450 + /* Test in which paths images with a relative path can be found */ 1451 + test_LoadImage_working_directory(); 1333 1452 } 1334 - 1335 - #undef ARRAY_SIZE 1336 1453 1337 1454 static void test_CreateIconFromResource(void) 1338 1455 { ··· 2539 2656 2540 2657 static const test_icon_entries_t icon_desc[] = {{0,0,TRUE}, {16,16,TRUE}, {32,32}, {64,64,TRUE}}; 2541 2658 2542 - create_ico_file("extract.ico", icon_desc, sizeof(icon_desc)/sizeof(*icon_desc)); 2659 + create_ico_file("extract.ico", icon_desc, ARRAY_SIZE(icon_desc)); 2543 2660 2544 2661 ret = PrivateExtractIconsA("extract.ico", 0, 32, 32, &icon, NULL, 1, 0); 2545 2662 ok(ret == 1, "PrivateExtractIconsA returned %u\n", ret); ··· 2668 2785 HeapFree(GetProcessHeap(), 0, icon_data); 2669 2786 } 2670 2787 2788 + static COLORREF get_color_from_bits(const unsigned char *bits, const BITMAPINFO *bmi, 2789 + unsigned int row, unsigned int column) 2790 + { 2791 + const BITMAPINFOHEADER *h = &bmi->bmiHeader; 2792 + unsigned int stride, shift, mask; 2793 + const unsigned char *data; 2794 + RGBQUAD color; 2795 + WORD color16; 2796 + 2797 + stride = ((h->biBitCount * h->biWidth + 7) / 8 + 3) & ~3; 2798 + data = bits + row * stride + column * h->biBitCount / 8; 2799 + if (h->biBitCount >= 24) 2800 + return RGB(data[2], data[1], data[0]); 2801 + 2802 + if (h->biBitCount == 16) 2803 + { 2804 + color16 = ((WORD)data[1] << 8) | data[0]; 2805 + return RGB(((color16 >> 10) & 0x1f) << 3, ((color16 >> 5) & 0x1f) << 3, 2806 + (color16 & 0x1f) << 3); 2807 + } 2808 + shift = 8 - h->biBitCount - (column * h->biBitCount) % 8; 2809 + mask = ~(~0u << h->biBitCount); 2810 + color = bmi->bmiColors[(data[0] >> shift) & mask]; 2811 + return RGB(color.rgbRed, color.rgbGreen, color.rgbBlue); 2812 + } 2813 + 2814 + #define compare_bitmap_bits(a, b, c, d, e, f, g) compare_bitmap_bits_(__LINE__, a, b, c, d, e, f, g) 2815 + static void compare_bitmap_bits_(unsigned int line, HDC hdc, HBITMAP bitmap, BITMAPINFO *bmi, 2816 + size_t result_bits_size, const unsigned char *expected_bits, unsigned int test_index, BOOL todo) 2817 + { 2818 + unsigned char *result_bits; 2819 + unsigned int row, column; 2820 + int ret; 2821 + 2822 + result_bits = HeapAlloc(GetProcessHeap(), 0, result_bits_size); 2823 + ret = GetDIBits(hdc, bitmap, 0, bmi->bmiHeader.biHeight, 2824 + result_bits, bmi, DIB_RGB_COLORS); 2825 + ok(ret == bmi->bmiHeader.biHeight, "Unexpected GetDIBits result %d, GetLastError() %u.\n", 2826 + ret, GetLastError()); 2827 + for (row = 0; row < bmi->bmiHeader.biHeight; ++row) 2828 + for (column = 0; column < bmi->bmiHeader.biWidth; ++column) 2829 + { 2830 + COLORREF result, expected; 2831 + 2832 + result = get_color_from_bits(result_bits, bmi, row, column); 2833 + expected = get_color_from_bits(expected_bits, bmi, row, column); 2834 + 2835 + todo_wine_if(todo) 2836 + ok_(__FILE__, line)(result == expected, "Colors do not match, " 2837 + "got 0x%06x, expected 0x%06x, test_index %u, row %u, column %u.\n", 2838 + result, expected, test_index, row, column); 2839 + } 2840 + HeapFree(GetProcessHeap(), 0, result_bits); 2841 + } 2842 + 2843 + static void test_Image_StretchMode(void) 2844 + { 2845 + static const unsigned char test_bits_24[] = 2846 + { 2847 + 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 2848 + 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0x00, 2849 + 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 2850 + 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 2851 + }; 2852 + static const unsigned char expected_bits_24[] = 2853 + { 2854 + 0x3f, 0xff, 0x00, 0x3f, 0xff, 0x3f, 0x00, 0x00, 2855 + 0x3f, 0xff, 0x7f, 0x00, 0xff, 0x3f, 0x00, 0x00, 2856 + }; 2857 + #define rgb16(r, g, b) ((WORD)(((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3))) 2858 + static const WORD test_bits_16[] = 2859 + { 2860 + rgb16(0x00, 0x20, 0x00), rgb16(0x00, 0x40, 0x00), rgb16(0x00, 0x40, 0xff), rgb16(0x00, 0x20, 0x00), 2861 + rgb16(0x00, 0x60, 0x00), rgb16(0xff, 0x80, 0x00), rgb16(0xff, 0x60, 0x00), rgb16(0x00, 0x80, 0x00), 2862 + rgb16(0x00, 0x20, 0xff), rgb16(0x00, 0x40, 0x00), rgb16(0x00, 0x40, 0xff), rgb16(0x00, 0x20, 0x00), 2863 + rgb16(0xff, 0x80, 0x00), rgb16(0x00, 0x60, 0xff), rgb16(0x00, 0x80, 0x00), rgb16(0x00, 0x60, 0x00), 2864 + }; 2865 + static const WORD expected_bits_16[] = 2866 + { 2867 + rgb16(0x00, 0x40, 0x00), rgb16(0x00, 0x20, 0x00), 2868 + rgb16(0x00, 0x40, 0x00), rgb16(0x00, 0x20, 0x00), 2869 + }; 2870 + #undef rgb16 2871 + static const unsigned char test_bits_8[] = 2872 + { 2873 + 0x00, 0xff, 0x00, 0xff, 2874 + 0x00, 0x00, 0x00, 0x00, 2875 + 0xff, 0x55, 0x00, 0xff, 2876 + 0x00, 0xff, 0xff, 0x00, 2877 + }; 2878 + static const unsigned char expected_bits_8[] = 2879 + { 2880 + 0xff, 0xff, 0x00, 0x00, 2881 + 0x55, 0xff, 0x00, 0x00, 2882 + }; 2883 + static const unsigned char test_bits_1[] = 2884 + { 2885 + 0x30, 0x0, 0x0, 0x0, 2886 + 0x30, 0x0, 0x0, 0x0, 2887 + 0x40, 0x0, 0x0, 0x0, 2888 + 0xc0, 0x0, 0x0, 0x0, 2889 + }; 2890 + static const unsigned char expected_bits_1[] = 2891 + { 2892 + 0x40, 0x0, 0x0, 0x0, 2893 + 0x0, 0x0, 0x0, 0x0, 2894 + }; 2895 + static const RGBQUAD colors_bits_1[] = 2896 + { 2897 + {0, 0, 0}, 2898 + {0xff, 0xff, 0xff}, 2899 + }; 2900 + static RGBQUAD colors_bits_8[256]; 2901 + 2902 + static const struct 2903 + { 2904 + LONG width, height, output_width, output_height; 2905 + WORD bit_count; 2906 + const unsigned char *test_bits, *expected_bits; 2907 + size_t test_bits_size, result_bits_size; 2908 + const RGBQUAD *bmi_colors; 2909 + size_t bmi_colors_size; 2910 + BOOL todo; 2911 + } 2912 + tests[] = 2913 + { 2914 + {4, 4, 2, 2, 24, test_bits_24, expected_bits_24, 2915 + sizeof(test_bits_24), sizeof(expected_bits_24), NULL, 0, TRUE}, 2916 + {4, 4, 2, 2, 1, test_bits_1, expected_bits_1, 2917 + sizeof(test_bits_1), sizeof(expected_bits_1), colors_bits_1, 2918 + sizeof(colors_bits_1), FALSE}, 2919 + {4, 4, 2, 2, 8, test_bits_8, expected_bits_8, 2920 + sizeof(test_bits_8), sizeof(expected_bits_8), colors_bits_8, 2921 + sizeof(colors_bits_8), FALSE}, 2922 + {4, 4, 2, 2, 16, (const unsigned char *)test_bits_16, (const unsigned char *)expected_bits_16, 2923 + sizeof(test_bits_16), sizeof(expected_bits_16), NULL, 0, FALSE}, 2924 + }; 2925 + static const char filename[] = "test.bmp"; 2926 + BITMAPINFO *bmi, *bmi_output; 2927 + HBITMAP bitmap, bitmap_copy; 2928 + unsigned int test_index; 2929 + unsigned char *bits; 2930 + size_t bmi_size; 2931 + unsigned int i; 2932 + HDC hdc; 2933 + 2934 + bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD); 2935 + bmi = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, bmi_size); 2936 + bmi_output = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, bmi_size); 2937 + bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); 2938 + bmi->bmiHeader.biPlanes = 1; 2939 + bmi->bmiHeader.biCompression = BI_RGB; 2940 + 2941 + for (i = 0; i < 256; ++i) 2942 + colors_bits_8[i].rgbRed = colors_bits_8[i].rgbGreen = colors_bits_8[i].rgbBlue = i; 2943 + 2944 + hdc = GetDC(NULL); 2945 + 2946 + for (test_index = 0; test_index < ARRAY_SIZE(tests); ++test_index) 2947 + { 2948 + if (tests[test_index].bmi_colors) 2949 + memcpy(bmi->bmiColors, tests[test_index].bmi_colors, tests[test_index].bmi_colors_size); 2950 + else 2951 + memset(bmi->bmiColors, 0, 256 * sizeof(RGBQUAD)); 2952 + 2953 + bmi->bmiHeader.biWidth = tests[test_index].width; 2954 + bmi->bmiHeader.biHeight = tests[test_index].height; 2955 + bmi->bmiHeader.biBitCount = tests[test_index].bit_count; 2956 + memcpy(bmi_output, bmi, bmi_size); 2957 + bmi_output->bmiHeader.biWidth = tests[test_index].output_width; 2958 + bmi_output->bmiHeader.biHeight = tests[test_index].output_height; 2959 + 2960 + bitmap = CreateDIBSection(hdc, bmi, DIB_RGB_COLORS, (void **)&bits, NULL, 0); 2961 + ok(bitmap && bits, "CreateDIBSection() failed, result %u.\n", GetLastError()); 2962 + memcpy(bits, tests[test_index].test_bits, tests[test_index].test_bits_size); 2963 + 2964 + bitmap_copy = CopyImage(bitmap, IMAGE_BITMAP, tests[test_index].output_width, 2965 + tests[test_index].output_height, LR_CREATEDIBSECTION); 2966 + ok(!!bitmap_copy, "CopyImage() failed, result %u.\n", GetLastError()); 2967 + 2968 + compare_bitmap_bits(hdc, bitmap_copy, bmi_output, tests[test_index].result_bits_size, 2969 + tests[test_index].expected_bits, test_index, tests[test_index].todo); 2970 + DeleteObject(bitmap); 2971 + DeleteObject(bitmap_copy); 2972 + 2973 + create_bitmap_file(filename, bmi, tests[test_index].test_bits); 2974 + bitmap = LoadImageA(NULL, filename, IMAGE_BITMAP, tests[test_index].output_width, 2975 + tests[test_index].output_height, LR_CREATEDIBSECTION | LR_LOADFROMFILE); 2976 + ok(!!bitmap, "LoadImageA() failed, result %u.\n", GetLastError()); 2977 + DeleteFileA(filename); 2978 + compare_bitmap_bits(hdc, bitmap, bmi_output, tests[test_index].result_bits_size, 2979 + tests[test_index].expected_bits, test_index, tests[test_index].todo); 2980 + DeleteObject(bitmap); 2981 + } 2982 + ReleaseDC(0, hdc); 2983 + HeapFree(GetProcessHeap(), 0, bmi_output); 2984 + HeapFree(GetProcessHeap(), 0, bmi); 2985 + } 2986 + 2671 2987 START_TEST(cursoricon) 2672 2988 { 2673 2989 pGetCursorInfo = (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetCursorInfo" ); ··· 2695 3011 test_CopyImage_Bitmap(16); 2696 3012 test_CopyImage_Bitmap(24); 2697 3013 test_CopyImage_Bitmap(32); 3014 + test_Image_StretchMode(); 2698 3015 test_initial_cursor(); 2699 3016 test_CreateIcon(); 2700 3017 test_LoadImage();
+6 -6
modules/rostests/winetests/user32/dde.c
··· 2396 2396 { 0x4efa, 0x4efc, 0x0061, 0x4efe, 0 }, /* some Chinese chars */ 2397 2397 { 0x0061, 0x0062, 0x0063, 0x9152, 0 }, /* Chinese with latin characters begin */ 2398 2398 }; 2399 - static const int nb_callbacks = 5 + sizeof(test_cmd_w_to_w)/sizeof(test_cmd_w_to_w[0]); 2399 + static const int nb_callbacks = 5 + ARRAY_SIZE(test_cmd_w_to_w); 2400 2400 2401 2401 static HDDEDATA CALLBACK server_end_to_end_callback(UINT uType, UINT uFmt, HCONV hconv, 2402 2402 HSZ hsz1, HSZ hsz2, HDDEDATA hdata, ··· 2480 2480 size_a = strlen(test_cmd_a_to_a) + 1; 2481 2481 size_w = (lstrlenW(cmd_w) + 1) * sizeof(WCHAR); 2482 2482 size_a_to_w = MultiByteToWideChar( CP_ACP, 0, test_cmd_a_to_a, -1, test_cmd_a_to_w, 2483 - sizeof(test_cmd_a_to_w)/sizeof(WCHAR) ) * sizeof(WCHAR); 2483 + ARRAY_SIZE(test_cmd_a_to_w)) * sizeof(WCHAR); 2484 2484 size_w_to_a = WideCharToMultiByte( CP_ACP, 0, cmd_w, -1, 2485 2485 test_cmd_w_to_a, sizeof(test_cmd_w_to_a), NULL, NULL ); 2486 2486 switch (str_index) ··· 2528 2528 /* double A->W mapping */ 2529 2529 /* NT uses the full size, XP+ only until the first null */ 2530 2530 DWORD nt_size = MultiByteToWideChar( CP_ACP, 0, (char *)cmd_w, size_w, test_cmd_a_to_w, 2531 - sizeof(test_cmd_a_to_w)/sizeof(WCHAR) ) * sizeof(WCHAR); 2531 + ARRAY_SIZE(test_cmd_a_to_w)) * sizeof(WCHAR); 2532 2532 DWORD xp_size = MultiByteToWideChar( CP_ACP, 0, (char *)cmd_w, -1, NULL, 0 ) * sizeof(WCHAR); 2533 2533 ok(size == xp_size || broken(size == nt_size) || 2534 2534 broken(str_index == 4 && IsDBCSLeadByte(cmd_w[0])) /* East Asian */, ··· 2554 2554 { 2555 2555 todo_wine ok(size == size_w, "Wrong size %d expected %d, msg_index=%d\n", size, size_w, msg_index); 2556 2556 MultiByteToWideChar(CP_ACP, 0, test_cmd_w_to_a, size_w, test_cmd_a_to_w, 2557 - sizeof(test_cmd_a_to_w)/sizeof(WCHAR)); 2557 + ARRAY_SIZE(test_cmd_a_to_w)); 2558 2558 todo_wine ok(!lstrcmpW((WCHAR*)buffer, cmd_w), 2559 2559 "Expected %s got %s, msg_index=%d\n", wine_dbgstr_w(cmd_w), wine_dbgstr_w((WCHAR *)buffer), msg_index); 2560 2560 } ··· 2562 2562 { 2563 2563 todo_wine ok(size == size_w, "Wrong size %d expected %d, msg_index=%d\n", size, size_w, msg_index); 2564 2564 MultiByteToWideChar(CP_ACP, 0, test_cmd_w_to_a, size_w, test_cmd_a_to_w, 2565 - sizeof(test_cmd_a_to_w)/sizeof(WCHAR)); 2565 + ARRAY_SIZE(test_cmd_a_to_w)); 2566 2566 if (!is_cjk()) 2567 2567 todo_wine ok(!lstrcmpW((WCHAR*)buffer, test_cmd_a_to_w), "Expected %s, got %s, msg_index=%d\n", 2568 2568 wine_dbgstr_w(test_cmd_a_to_w), wine_dbgstr_w((WCHAR*)buffer), msg_index); ··· 2663 2663 err = DdeGetLastError(client_pid); 2664 2664 ok(err == DMLERR_NO_ERROR, "wrong dde error %x\n", err); 2665 2665 2666 - for (i = 0; i < sizeof(test_cmd_w_to_w)/sizeof(test_cmd_w_to_w[0]); i++) 2666 + for (i = 0; i < ARRAY_SIZE(test_cmd_w_to_w); i++) 2667 2667 { 2668 2668 hdata = DdeClientTransaction((LPBYTE)test_cmd_w_to_w[i], 2669 2669 (lstrlenW(test_cmd_w_to_w[i]) + 1) * sizeof(WCHAR),
+373 -67
modules/rostests/winetests/user32/dialog.c
··· 42 42 #include "winbase.h" 43 43 #include "wingdi.h" 44 44 #include "winuser.h" 45 + #include "winnls.h" 45 46 46 47 #define MAXHWNDS 1024 47 48 static HWND hwnd [MAXHWNDS]; ··· 57 58 static BOOL g_bInitialFocusInitDlgResult, g_bReceivedCommand; 58 59 59 60 static BOOL g_terminated; 61 + static BOOL g_button1Clicked; 60 62 61 63 typedef struct { 62 64 INT_PTR id; ··· 149 151 {0, 0, 0, 0} 150 152 }; 151 153 154 + static DWORD get_button_style(HWND button) 155 + { 156 + return GetWindowLongW(button, GWL_STYLE) & BS_TYPEMASK; 157 + } 158 + 152 159 static BOOL CreateWindows (HINSTANCE hinst) 153 160 { 154 161 const h_entry *p = hierarchy; ··· 156 163 while (p->id != 0) 157 164 { 158 165 DWORD style, exstyle; 159 - char ctrlname[9]; 166 + char ctrlname[16]; 160 167 161 168 /* Basically assert that the hierarchy is valid and track the 162 169 * maximum control number 163 170 */ 164 171 if (p->id >= numwnds) 165 172 { 166 - if (p->id >= sizeof(hwnd)/sizeof(hwnd[0])) 173 + if (p->id >= ARRAY_SIZE(hwnd)) 167 174 { 168 175 trace ("Control %ld is out of range\n", p->id); 169 176 return FALSE; ··· 476 483 g_terminated = TRUE; 477 484 return 0; 478 485 } 486 + else if ((wParam == 100 || wParam == 0xFFFF) && lParam) 487 + { 488 + g_button1Clicked = TRUE; 489 + } 479 490 break; 480 491 } 481 492 ··· 630 641 * BS_DEFPUSHBUTTON with out making it default. 631 642 */ 632 643 633 - /* 634 - * Keep the focus on Edit control. 635 - */ 636 - 637 - if ( SetFocus( g_hwndTestDlgEdit ) ) 638 - { 639 - ok ((GetFocus() == g_hwndTestDlgEdit), "Focus didn't set on Edit control\n"); 640 - 641 - /* 642 - * Test message WM_NEXTDLGCTL 643 - */ 644 - DefDlgProcA( g_hwndTestDlg, WM_NEXTDLGCTL, 0, 0 ); 645 - ok ((GetFocus() == g_hwndTestDlgBut1), "Focus didn't move to first button\n"); 646 - 647 - /* 648 - * Check whether the default button ID got changed by sending message "WM_NEXTDLGCTL" 649 - */ 650 - dwVal = DefDlgProcA(g_hwndTestDlg, DM_GETDEFID, 0, 0); 651 - ok ( IDCANCEL == (LOWORD(dwVal)), "WM_NEXTDLGCTL changed default button\n"); 644 + /* Keep the focus on Edit control. */ 645 + SetFocus(g_hwndTestDlgEdit); 646 + ok((GetFocus() == g_hwndTestDlgEdit), "Focus didn't set on Edit control\n"); 652 647 653 - /* 654 - * Check whether the style of the button which got the focus, changed to BS_DEFPUSHBUTTON and 655 - * the style of default button changed to BS_PUSHBUTTON. 656 - */ 657 - if ( IDCANCEL == (LOWORD(dwVal)) ) 658 - { 659 - ok ( ((GetWindowLongA( g_hwndTestDlgBut1, GWL_STYLE)) & BS_DEFPUSHBUTTON), 660 - "Button1 style not set to BS_DEFPUSHBUTTON\n" ); 648 + /* Test message WM_NEXTDLGCTL */ 649 + DefDlgProcA(g_hwndTestDlg, WM_NEXTDLGCTL, 0, 0); 650 + ok((GetFocus() == g_hwndTestDlgBut1), "Focus didn't move to first button\n"); 661 651 662 - ok ( !((GetWindowLongA( g_hwndTestDlgBut2, GWL_STYLE)) & BS_DEFPUSHBUTTON), 663 - "Button2's style not changed to BS_PUSHBUTTON\n" ); 664 - } 652 + /* Check whether the default button ID got changed by sending message "WM_NEXTDLGCTL" */ 653 + dwVal = DefDlgProcA(g_hwndTestDlg, DM_GETDEFID, 0, 0); 654 + ok(IDCANCEL == (LOWORD(dwVal)), "WM_NEXTDLGCTL changed default button\n"); 665 655 666 - /* 667 - * Move focus to Button2 using "WM_NEXTDLGCTL" 668 - */ 669 - DefDlgProcA( g_hwndTestDlg, WM_NEXTDLGCTL, 0, 0 ); 670 - ok ((GetFocus() == g_hwndTestDlgBut2), "Focus didn't move to second button\n"); 656 + /* 657 + * Check whether the style of the button which got the focus, changed to BS_DEFPUSHBUTTON and 658 + * the style of default button changed to BS_PUSHBUTTON. 659 + */ 660 + ok(get_button_style(g_hwndTestDlgBut1) == BS_DEFPUSHBUTTON, "Button1's style not set to BS_DEFPUSHBUTTON"); 661 + ok(get_button_style(g_hwndTestDlgBut2) == BS_PUSHBUTTON, "Button2's style not set to BS_PUSHBUTTON"); 671 662 672 - /* 673 - * Check whether the default button ID got changed by sending message "WM_NEXTDLGCTL" 674 - */ 675 - dwVal = DefDlgProcA(g_hwndTestDlg, DM_GETDEFID, 0, 0); 676 - ok ( IDCANCEL == (LOWORD(dwVal)), "WM_NEXTDLGCTL changed default button\n"); 663 + /* Move focus to Button2 using "WM_NEXTDLGCTL" */ 664 + DefDlgProcA(g_hwndTestDlg, WM_NEXTDLGCTL, 0, 0); 665 + ok((GetFocus() == g_hwndTestDlgBut2), "Focus didn't move to second button\n"); 677 666 678 - /* 679 - * Check whether the style of the button which got the focus, changed to BS_DEFPUSHBUTTON and 680 - * the style of button which lost the focus changed to BS_PUSHBUTTON. 681 - */ 682 - if ( IDCANCEL == (LOWORD(dwVal)) ) 683 - { 684 - ok ( ((GetWindowLongA( g_hwndTestDlgBut2, GWL_STYLE)) & BS_DEFPUSHBUTTON), 685 - "Button2 style not set to BS_DEFPUSHBUTTON\n" ); 667 + /* Check whether the default button ID got changed by sending message "WM_NEXTDLGCTL" */ 668 + dwVal = DefDlgProcA(g_hwndTestDlg, DM_GETDEFID, 0, 0); 669 + ok(IDCANCEL == (LOWORD(dwVal)), "WM_NEXTDLGCTL changed default button\n"); 686 670 687 - ok ( !((GetWindowLongA( g_hwndTestDlgBut1, GWL_STYLE)) & BS_DEFPUSHBUTTON), 688 - "Button1's style not changed to BS_PUSHBUTTON\n" ); 689 - } 671 + /* 672 + * Check whether the style of the button which got the focus, changed to BS_DEFPUSHBUTTON and 673 + * the style of button which lost the focus changed to BS_PUSHBUTTON. 674 + */ 675 + ok(get_button_style(g_hwndTestDlgBut1) == BS_PUSHBUTTON, "Button1's style not set to BS_PUSHBUTTON"); 676 + ok(get_button_style(g_hwndTestDlgBut2) == BS_DEFPUSHBUTTON, "Button2's style not set to BS_DEFPUSHBUTTON"); 690 677 691 - /* 692 - * Move focus to Edit control using "WM_NEXTDLGCTL" 693 - */ 694 - DefDlgProcA( g_hwndTestDlg, WM_NEXTDLGCTL, 0, 0 ); 695 - ok ((GetFocus() == g_hwndTestDlgEdit), "Focus didn't move to Edit control\n"); 678 + /* Move focus to Edit control using "WM_NEXTDLGCTL" */ 679 + DefDlgProcA(g_hwndTestDlg, WM_NEXTDLGCTL, 0, 0); 680 + ok((GetFocus() == g_hwndTestDlgEdit), "Focus didn't move to Edit control\n"); 696 681 697 - /* 698 - * Check whether the default button ID got changed by sending message "WM_NEXTDLGCTL" 699 - */ 700 - dwVal = DefDlgProcA(g_hwndTestDlg, DM_GETDEFID, 0, 0); 701 - ok ( IDCANCEL == (LOWORD(dwVal)), "WM_NEXTDLGCTL changed default button\n"); 702 - } 682 + /* Check whether the default button ID got changed by sending message "WM_NEXTDLGCTL" */ 683 + dwVal = DefDlgProcA(g_hwndTestDlg, DM_GETDEFID, 0, 0); 684 + ok(IDCANCEL == (LOWORD(dwVal)), "WM_NEXTDLGCTL changed default button\n"); 703 685 704 686 /* test nested default buttons */ 705 687 ··· 812 794 ok (!IsDialogMessageA(msg.hwnd, &msg), "expected failure\n"); 813 795 814 796 UnhookWindowsHookEx(hook); 797 + DestroyWindow(g_hwndMain); 798 + 799 + g_hwndMain = CreateWindowA("IsDialogMessageWindowClass", "IsDialogMessageWindowClass", WS_OVERLAPPEDWINDOW, 800 + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, g_hinst, 0); 801 + SetFocus(g_hwndButton1); 802 + g_button1Clicked = FALSE; 803 + FormEnterMsg(&msg, g_hwndButton1); 804 + ok(IsDialogMessageA(g_hwndMain, &msg), "Did not handle the ENTER\n"); 805 + ok(g_button1Clicked, "Did not receive button 1 click notification\n"); 806 + 807 + g_button1Clicked = FALSE; 808 + FormEnterMsg(&msg, g_hwndMain); 809 + ok(IsDialogMessageA(g_hwndMain, &msg), "Did not handle the ENTER\n"); 810 + ok(g_button1Clicked, "Did not receive button 1 click notification\n"); 811 + 812 + g_button1Clicked = FALSE; 813 + FormEnterMsg(&msg, g_hwndButton2); 814 + ok(IsDialogMessageA(g_hwndMain, &msg), "Did not handle the ENTER\n"); 815 + ok(g_button1Clicked, "Did not receive button 1 click notification\n"); 816 + 817 + /* Button with id larger than 0xFFFF should also work */ 818 + g_button1Clicked = FALSE; 819 + FormEnterMsg(&msg, g_hwndMain); 820 + SetWindowLongPtrW(g_hwndButton1, GWLP_ID, 0x1FFFF); 821 + ok(IsDialogMessageA(g_hwndMain, &msg), "Did not handle the ENTER\n"); 822 + ok(g_button1Clicked, "Did not receive button 1 click notification\n"); 823 + 824 + DestroyWindow(g_hwndMain); 815 825 } 816 826 817 827 ··· 871 881 g_hwndInitialFocusT1 = (HWND)lParam; 872 882 } 873 883 return FALSE; 884 + } 885 + 886 + return FALSE; 887 + } 888 + 889 + static INT_PTR CALLBACK EmptyProcUserTemplate(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 890 + { 891 + switch(uMsg) { 892 + case WM_INITDIALOG: 893 + return TRUE; 894 + } 895 + return FALSE; 896 + } 897 + 898 + static INT_PTR CALLBACK focusChildDlgWinProc (HWND hwnd, UINT uiMsg, WPARAM wParam, 899 + LPARAM lParam) 900 + { 901 + static HWND hChildDlg; 902 + 903 + switch (uiMsg) 904 + { 905 + case WM_INITDIALOG: 906 + { 907 + RECT rectHwnd; 908 + struct { 909 + DLGTEMPLATE tmplate; 910 + WORD menu,class,title; 911 + } temp; 912 + 913 + SetFocus( GetDlgItem(hwnd, 200) ); 914 + 915 + GetClientRect(hwnd,&rectHwnd); 916 + temp.tmplate.style = WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | DS_CONTROL | DS_3DLOOK; 917 + temp.tmplate.dwExtendedStyle = 0; 918 + temp.tmplate.cdit = 0; 919 + temp.tmplate.x = 0; 920 + temp.tmplate.y = 0; 921 + temp.tmplate.cx = 0; 922 + temp.tmplate.cy = 0; 923 + temp.menu = temp.class = temp.title = 0; 924 + 925 + hChildDlg = CreateDialogIndirectParamA(g_hinst, &temp.tmplate, 926 + hwnd, (DLGPROC)EmptyProcUserTemplate, 0); 927 + ok(hChildDlg != 0, "Failed to create test dialog.\n"); 928 + 929 + return FALSE; 930 + } 931 + case WM_CLOSE: 932 + DestroyWindow(hChildDlg); 933 + return TRUE; 874 934 } 875 935 876 936 return FALSE; ··· 1062 1122 1063 1123 DestroyWindow(hDlg); 1064 1124 } 1125 + 1126 + /* Test 6: 1127 + * Select textbox's text on creation when WM_INITDIALOG creates a child dialog. */ 1128 + { 1129 + HWND hDlg; 1130 + HRSRC hResource; 1131 + HANDLE hTemplate; 1132 + DLGTEMPLATE* pTemplate; 1133 + HWND edit; 1134 + 1135 + hResource = FindResourceA(g_hinst,"FOCUS_TEST_DIALOG_3", (LPCSTR)RT_DIALOG); 1136 + hTemplate = LoadResource(g_hinst, hResource); 1137 + pTemplate = LockResource(hTemplate); 1138 + 1139 + hDlg = CreateDialogIndirectParamA(g_hinst, pTemplate, NULL, focusChildDlgWinProc, 0); 1140 + ok(hDlg != 0, "Failed to create test dialog.\n"); 1141 + edit = GetDlgItem(hDlg, 200); 1142 + 1143 + ok(GetFocus() == edit, "Focus not set to edit, focus=%p, dialog=%p, edit=%p\n", 1144 + GetFocus(), hDlg, edit); 1145 + 1146 + DestroyWindow(hDlg); 1147 + } 1065 1148 } 1066 1149 1067 1150 static void test_GetDlgItemText(void) ··· 1070 1153 BOOL ret; 1071 1154 1072 1155 strcpy(string, "Overwrite Me"); 1073 - ret = GetDlgItemTextA(NULL, 0, string, sizeof(string)/sizeof(string[0])); 1156 + ret = GetDlgItemTextA(NULL, 0, string, ARRAY_SIZE(string)); 1074 1157 ok(!ret, "GetDlgItemText(NULL) shouldn't have succeeded\n"); 1075 1158 1076 1159 ok(string[0] == '\0' || broken(!strcmp(string, "Overwrite Me")), 1077 1160 "string retrieved using GetDlgItemText should have been NULL terminated\n"); 1078 1161 } 1079 1162 1163 + static INT_PTR CALLBACK getdlgitem_test_dialog_proc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) 1164 + { 1165 + if (msg == WM_INITDIALOG) 1166 + { 1167 + char text[64]; 1168 + LONG_PTR val; 1169 + HWND hwnd; 1170 + BOOL ret; 1171 + 1172 + hwnd = GetDlgItem(hdlg, -1); 1173 + ok(hwnd != NULL, "Expected dialog item.\n"); 1174 + 1175 + *text = 0; 1176 + ret = GetDlgItemTextA(hdlg, -1, text, ARRAY_SIZE(text)); 1177 + ok(ret && !strcmp(text, "Text1"), "Unexpected item text.\n"); 1178 + 1179 + val = GetWindowLongA(hwnd, GWLP_ID); 1180 + ok(val == -1, "Unexpected id.\n"); 1181 + 1182 + val = GetWindowLongPtrA(hwnd, GWLP_ID); 1183 + ok(val == -1, "Unexpected id %ld.\n", val); 1184 + 1185 + hwnd = GetDlgItem(hdlg, -2); 1186 + ok(hwnd != NULL, "Expected dialog item.\n"); 1187 + 1188 + val = GetWindowLongA(hwnd, GWLP_ID); 1189 + ok(val == -2, "Unexpected id.\n"); 1190 + 1191 + val = GetWindowLongPtrA(hwnd, GWLP_ID); 1192 + ok(val == -2, "Unexpected id %ld.\n", val); 1193 + 1194 + EndDialog(hdlg, 0xdead); 1195 + } 1196 + 1197 + return FALSE; 1198 + } 1199 + 1080 1200 static void test_GetDlgItem(void) 1081 1201 { 1082 1202 HWND hwnd, child1, child2, hwnd2; 1203 + INT_PTR retval; 1083 1204 BOOL ret; 1084 1205 1085 1206 hwnd = CreateWindowA("button", "parent", WS_VISIBLE, 0, 0, 100, 100, NULL, 0, g_hinst, NULL); ··· 1126 1247 DestroyWindow(child1); 1127 1248 DestroyWindow(child2); 1128 1249 DestroyWindow(hwnd); 1250 + 1251 + retval = DialogBoxParamA(g_hinst, "GETDLGITEM_TEST_DIALOG", NULL, getdlgitem_test_dialog_proc, 0); 1252 + ok(retval == 0xdead, "Unexpected return value.\n"); 1129 1253 } 1130 1254 1131 1255 static INT_PTR CALLBACK DestroyDlgWinProc (HWND hDlg, UINT uiMsg, ··· 1486 1610 (BYTE)buff[0], (BYTE)buff[1], len); 1487 1611 1488 1612 memset(buffW, 0xff, sizeof(buffW)); 1489 - len = GetWindowTextW(hdlg, buffW, sizeof(buffW)/sizeof(buffW[0])); 1613 + len = GetWindowTextW(hdlg, buffW, ARRAY_SIZE(buffW)); 1490 1614 ok(buffW[0] == 'W' && buffW[1] == 0xffff && len == 0, "Unexpected window text %#x, %#x, len %d\n", 1491 1615 buffW[0], buffW[1], len); 1492 1616 ··· 1592 1716 ok(!strcmp(buff, testtext) && len == 0, "Unexpected window text %s, len %d\n", buff, len); 1593 1717 1594 1718 memset(buffW, 0xff, sizeof(buffW)); 1595 - len = GetWindowTextW(hdlg, buffW, sizeof(buffW)/sizeof(buffW[0])); 1719 + len = GetWindowTextW(hdlg, buffW, ARRAY_SIZE(buffW)); 1596 1720 ok(buffW[0] == 0 && buffW[1] == 0xffff && len == 0, "Unexpected window text %#x, %#x, len %d\n", 1597 1721 buffW[0], buffW[1], len); 1598 1722 ··· 1869 1993 DestroyWindow(hDlg); 1870 1994 } 1871 1995 1996 + static const char msgbox_title[] = "%5!z9ZXw*ia;57n/FGl.bCH,Su\"mfKN;foCqAU\'j6AmoJgAc_D:Z0A\'E6PF_O/w"; 1997 + static WCHAR expectedOK[] = 1998 + { 1999 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 2000 + '%','5','!','z','9','Z','X','w','*','i','a',';','5','7','n','/','F','G','l','.','b','C','H',',','S','u','"','m','f', 2001 + 'K','N',';','f','o','C','q','A','U','\'','j','6','A','m','o','J','g','A','c','_','D',':','Z','0','A','\'','E','6','P', 2002 + 'F','_','O','/','w','\r','\n', 2003 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 2004 + 'M','e','s','s','a','g','e','\r','\n', 2005 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 2006 + 'O','K',' ',' ',' ','\r','\n', 2007 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 0 2008 + }; 2009 + static WCHAR expectedOkCancel[] = 2010 + { 2011 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 2012 + '%','5','!','z','9','Z','X','w','*','i','a',';','5','7','n','/','F','G','l','.','b','C','H',',','S','u','"','m','f', 2013 + 'K','N',';','f','o','C','q','A','U','\'','j','6','A','m','o','J','g','A','c','_','D',':','Z','0','A','\'','E','6','P', 2014 + 'F','_','O','/','w','\r','\n', 2015 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 2016 + 'M','e','s','s','a','g','e','\r','\n', 2017 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 2018 + 'O','K',' ',' ',' ','C','a','n','c','e','l',' ',' ',' ','\r','\n', 2019 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 0 2020 + }; 2021 + static WCHAR expectedAbortRetryIgnore[] = 2022 + { 2023 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 2024 + '%','5','!','z','9','Z','X','w','*','i','a',';','5','7','n','/','F','G','l','.','b','C','H',',','S','u','"','m','f', 2025 + 'K','N',';','f','o','C','q','A','U','\'','j','6','A','m','o','J','g','A','c','_','D',':','Z','0','A','\'','E','6','P', 2026 + 'F','_','O','/','w','\r','\n', 2027 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 2028 + 'M','e','s','s','a','g','e','\r','\n', 2029 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 2030 + 'A','b','o','r','t',' ',' ',' ','R','e','t','r','y',' ',' ',' ','I','g','n','o','r','e',' ',' ',' ','\r','\n', 2031 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 0 2032 + }; 2033 + 2034 + static WCHAR expectedYesNo[] = 2035 + { 2036 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 2037 + '%','5','!','z','9','Z','X','w','*','i','a',';','5','7','n','/','F','G','l','.','b','C','H',',','S','u','"','m','f', 2038 + 'K','N',';','f','o','C','q','A','U','\'','j','6','A','m','o','J','g','A','c','_','D',':','Z','0','A','\'','E','6','P', 2039 + 'F','_','O','/','w','\r','\n', 2040 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 2041 + 'M','e','s','s','a','g','e','\r','\n', 2042 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 2043 + 'Y','e','s',' ',' ',' ','N','o',' ',' ',' ','\r','\n', 2044 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 0 2045 + }; 2046 + static WCHAR expectedYesNoCancel[] = 2047 + { 2048 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 2049 + '%','5','!','z','9','Z','X','w','*','i','a',';','5','7','n','/','F','G','l','.','b','C','H',',','S','u','"','m','f', 2050 + 'K','N',';','f','o','C','q','A','U','\'','j','6','A','m','o','J','g','A','c','_','D',':','Z','0','A','\'','E','6','P', 2051 + 'F','_','O','/','w','\r','\n', 2052 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 2053 + 'M','e','s','s','a','g','e','\r','\n', 2054 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 2055 + 'Y','e','s',' ',' ',' ','N','o',' ',' ',' ','C','a','n','c','e','l',' ',' ',' ','\r','\n', 2056 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 0 2057 + }; 2058 + static WCHAR expectedRetryCancel[] = 2059 + { 2060 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 2061 + '%','5','!','z','9','Z','X','w','*','i','a',';','5','7','n','/','F','G','l','.','b','C','H',',','S','u','"','m','f', 2062 + 'K','N',';','f','o','C','q','A','U','\'','j','6','A','m','o','J','g','A','c','_','D',':','Z','0','A','\'','E','6','P', 2063 + 'F','_','O','/','w','\r','\n', 2064 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 2065 + 'M','e','s','s','a','g','e','\r','\n', 2066 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 2067 + 'R','e','t','r','y',' ',' ',' ','C','a','n','c','e','l',' ',' ',' ','\r','\n', 2068 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 0 2069 + }; 2070 + static WCHAR expectedCancelTryContinue[] = 2071 + { 2072 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 2073 + '%','5','!','z','9','Z','X','w','*','i','a',';','5','7','n','/','F','G','l','.','b','C','H',',','S','u','"','m','f', 2074 + 'K','N',';','f','o','C','q','A','U','\'','j','6','A','m','o','J','g','A','c','_','D',':','Z','0','A','\'','E','6','P', 2075 + 'F','_','O','/','w','\r','\n', 2076 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 2077 + 'M','e','s','s','a','g','e','\r','\n', 2078 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 2079 + 'C','a','n','c','e','l',' ',' ',' ','T','r','y',' ','A','g','a','i','n',' ',' ',' ','C','o','n','t','i','n','u','e',' ',' ',' ','\r','\n', 2080 + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\r','\n', 0 2081 + }; 2082 + 2083 + BOOL non_english = FALSE; 2084 + 2085 + DWORD WINAPI WorkerThread(void *param) 2086 + { 2087 + WCHAR *expected = param; 2088 + char windowTitle[sizeof(msgbox_title)]; 2089 + HWND hwndMbox; 2090 + BOOL succeeded = FALSE; 2091 + 2092 + Sleep(200); 2093 + 2094 + hwndMbox = GetForegroundWindow(); 2095 + 2096 + /* Find the Window, if it doesn't have focus */ 2097 + if (!(IsWindow(hwndMbox) && 2098 + GetWindowTextA(hwndMbox, windowTitle, sizeof(msgbox_title)) && 2099 + lstrcmpA(msgbox_title, windowTitle) == 0)) 2100 + { 2101 + hwndMbox = FindWindowA(NULL, msgbox_title); 2102 + 2103 + if (!IsWindow(hwndMbox)) 2104 + goto cleanup; 2105 + } 2106 + 2107 + SendMessageA(hwndMbox, WM_COPY, 0, 0); 2108 + 2109 + if (IsClipboardFormatAvailable(CF_UNICODETEXT) && OpenClipboard(NULL)) 2110 + { 2111 + HANDLE textHandle = GetClipboardData(CF_UNICODETEXT); 2112 + WCHAR *text = GlobalLock(textHandle); 2113 + 2114 + if (text != NULL) 2115 + { 2116 + if(non_english) 2117 + ok(lstrlenW(text) > 0, "Empty string on clipboard\n"); 2118 + else 2119 + { 2120 + succeeded = lstrcmpW(expected, text) == 0; 2121 + if(!succeeded) 2122 + { 2123 + ok(0, "%s\n", wine_dbgstr_w(text)); 2124 + ok(0, "%s\n", wine_dbgstr_w(expected)); 2125 + } 2126 + } 2127 + 2128 + GlobalUnlock(textHandle); 2129 + } 2130 + else 2131 + ok(0, "No text on clipboard.\n"); 2132 + 2133 + CloseClipboard(); 2134 + 2135 + } 2136 + else 2137 + trace("Clipboard error\n"); 2138 + 2139 + PostMessageA(hwndMbox, WM_COMMAND, IDIGNORE, 0); /* For MB_ABORTRETRYIGNORE dialog. */ 2140 + PostMessageA(hwndMbox, WM_CLOSE, 0, 0); 2141 + 2142 + cleanup: 2143 + ok(succeeded || non_english, "Failed to get string.\n"); 2144 + 2145 + return 0; 2146 + } 2147 + 2148 + static void test_MessageBox_WM_COPY_Test(void) 2149 + { 2150 + DWORD tid = 0; 2151 + 2152 + non_english = (PRIMARYLANGID(GetUserDefaultLangID()) != LANG_ENGLISH); 2153 + trace("non_english %d\n", non_english); 2154 + 2155 + CreateThread(NULL, 0, WorkerThread, &expectedOK, 0, &tid); 2156 + MessageBoxA(NULL, "Message", msgbox_title, MB_OK); 2157 + 2158 + CreateThread(NULL, 0, WorkerThread, &expectedOkCancel, 0, &tid); 2159 + MessageBoxA(NULL, "Message", msgbox_title, MB_OKCANCEL); 2160 + 2161 + CreateThread(NULL, 0, WorkerThread, &expectedAbortRetryIgnore, 0, &tid); 2162 + MessageBoxA(NULL, "Message", msgbox_title, MB_ABORTRETRYIGNORE); 2163 + 2164 + CreateThread(NULL, 0, WorkerThread, &expectedYesNo, 0, &tid); 2165 + MessageBoxA(NULL, "Message", msgbox_title, MB_YESNO); 2166 + 2167 + CreateThread(NULL, 0, WorkerThread, &expectedYesNoCancel, 0, &tid); 2168 + MessageBoxA(NULL, "Message", msgbox_title, MB_YESNOCANCEL); 2169 + 2170 + CreateThread(NULL, 0, WorkerThread, &expectedRetryCancel, 0, &tid); 2171 + MessageBoxA(NULL, "Message", msgbox_title, MB_RETRYCANCEL); 2172 + 2173 + CreateThread(NULL, 0, WorkerThread, &expectedCancelTryContinue, 0, &tid); 2174 + MessageBoxA(NULL, "Message", msgbox_title, MB_CANCELTRYCONTINUE); 2175 + } 2176 + 1872 2177 static void test_SaveRestoreFocus(void) 1873 2178 { 1874 2179 HWND hDlg; ··· 2178 2483 test_SaveRestoreFocus(); 2179 2484 test_timer_message(); 2180 2485 test_MessageBox(); 2486 + test_MessageBox_WM_COPY_Test(); 2181 2487 }
+253 -52
modules/rostests/winetests/user32/edit.c
··· 1435 1435 DestroyWindow (hwEdit); 1436 1436 } 1437 1437 1438 + static BOOL is_cjk_charset(HDC dc) 1439 + { 1440 + switch (GdiGetCodePage(dc)) { 1441 + case 932: case 936: case 949: case 950: case 1361: 1442 + return TRUE; 1443 + default: 1444 + return FALSE; 1445 + } 1446 + } 1447 + 1438 1448 static void test_margins_usefontinfo(UINT charset) 1439 1449 { 1440 1450 HWND hwnd; 1441 1451 HDC hdc; 1452 + TEXTMETRICW tm; 1442 1453 SIZE size; 1443 - BOOL cjk = FALSE; 1444 1454 LOGFONTA lf; 1445 1455 HFONT hfont; 1446 1456 RECT rect; 1447 - INT margins, threshold, expect, empty_expect, small_expect; 1457 + INT margins, threshold, expect, empty_expect; 1458 + const UINT small_margins = MAKELONG(1, 5); 1448 1459 1449 1460 memset(&lf, 0, sizeof(lf)); 1450 1461 lf.lfHeight = -11; ··· 1463 1474 1464 1475 hdc = GetDC(hwnd); 1465 1476 hfont = SelectObject(hdc, hfont); 1466 - size.cx = GdiGetCharDimensions( hdc, NULL, &size.cy ); 1467 - expect = MAKELONG(size.cx / 2, size.cx / 2); 1468 - small_expect = 0; 1469 - empty_expect = size.cx >= 28 ? small_expect : expect; 1470 - 1471 - charset = GetTextCharset(hdc); 1472 - switch (charset) 1473 - { 1474 - case SHIFTJIS_CHARSET: 1475 - case HANGUL_CHARSET: 1476 - case GB2312_CHARSET: 1477 - case CHINESEBIG5_CHARSET: 1478 - cjk = TRUE; 1477 + size.cx = GdiGetCharDimensions( hdc, &tm, &size.cy ); 1478 + if ((charset != tm.tmCharSet && charset != DEFAULT_CHARSET) || 1479 + !(tm.tmPitchAndFamily & (TMPF_TRUETYPE | TMPF_VECTOR))) { 1480 + skip("%s for charset %d isn't available\n", lf.lfFaceName, charset); 1481 + hfont = SelectObject(hdc, hfont); 1482 + ReleaseDC(hwnd, hdc); 1483 + DestroyWindow(hwnd); 1484 + DeleteObject(hfont); 1485 + return; 1479 1486 } 1480 - 1487 + expect = MAKELONG(size.cx / 2, size.cx / 2); 1481 1488 hfont = SelectObject(hdc, hfont); 1482 1489 ReleaseDC(hwnd, hdc); 1483 1490 1484 1491 margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0); 1485 1492 ok(margins == 0, "got %x\n", margins); 1486 1493 SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0)); 1487 - margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0); 1488 - if (!cjk) 1489 - ok(margins == expect, "%d: got %d, %d\n", charset, HIWORD(margins), LOWORD(margins)); 1490 - else 1491 - { 1492 - ok(HIWORD(margins) > 0 && LOWORD(margins) > 0, "%d: got %d, %d\n", charset, HIWORD(margins), LOWORD(margins)); 1493 - expect = empty_expect = small_expect = margins; 1494 - } 1494 + SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO, EC_USEFONTINFO)); 1495 + expect = SendMessageA(hwnd, EM_GETMARGINS, 0, 0); 1495 1496 DestroyWindow(hwnd); 1496 1497 1497 - threshold = (size.cx / 2 + size.cx) * 2; 1498 + threshold = HIWORD(expect) + LOWORD(expect) + size.cx * 2; 1499 + empty_expect = threshold > 80 ? small_margins : expect; 1498 1500 1499 - /* Size below which non-cjk margins are zero */ 1501 + /* Size below the threshold, margins remain unchanged */ 1500 1502 hwnd = CreateWindowExA(0, "Edit", "A", WS_POPUP, 0, 0, threshold - 1, 100, NULL, NULL, NULL, NULL); 1501 1503 ok(hwnd != NULL, "got %p\n", hwnd); 1502 1504 GetClientRect(hwnd, &rect); ··· 1506 1508 ok(margins == 0, "got %x\n", margins); 1507 1509 1508 1510 SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0)); 1511 + SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, small_margins); 1512 + SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO, EC_USEFONTINFO)); 1509 1513 margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0); 1510 - ok(margins == small_expect, "%d: got %d, %d\n", charset, HIWORD(margins), LOWORD(margins)); 1514 + ok(margins == small_margins, "%d: got %d, %d\n", charset, HIWORD(margins), LOWORD(margins)); 1511 1515 DestroyWindow(hwnd); 1512 1516 1513 - /* Size at which non-cjk margins become non-zero */ 1517 + /* Size at the threshold, margins become non-zero */ 1514 1518 hwnd = CreateWindowExA(0, "Edit", "A", WS_POPUP, 0, 0, threshold, 100, NULL, NULL, NULL, NULL); 1515 1519 ok(hwnd != NULL, "got %p\n", hwnd); 1516 1520 GetClientRect(hwnd, &rect); ··· 1520 1524 ok(margins == 0, "got %x\n", margins); 1521 1525 1522 1526 SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0)); 1527 + SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, small_margins); 1528 + SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO, EC_USEFONTINFO)); 1523 1529 margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0); 1524 1530 ok(margins == expect, "%d: got %d, %d\n", charset, HIWORD(margins), LOWORD(margins)); 1525 1531 DestroyWindow(hwnd); ··· 1534 1540 ok(margins == 0, "got %x\n", margins); 1535 1541 1536 1542 SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0)); 1543 + SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, small_margins); 1544 + SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO, EC_USEFONTINFO)); 1537 1545 margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0); 1538 1546 ok(margins == empty_expect, "%d: got %d, %d\n", charset, HIWORD(margins), LOWORD(margins)); 1539 1547 DestroyWindow(hwnd); ··· 1541 1549 DeleteObject(hfont); 1542 1550 } 1543 1551 1552 + static BOOL is_cjk_font(HDC dc) 1553 + { 1554 + const DWORD FS_DBCS_MASK = FS_JISJAPAN|FS_CHINESESIMP|FS_WANSUNG|FS_CHINESETRAD|FS_JOHAB; 1555 + FONTSIGNATURE fs; 1556 + return (GetTextCharsetInfo(dc, &fs, 0) != DEFAULT_CHARSET && 1557 + (fs.fsCsb[0] & FS_DBCS_MASK)); 1558 + } 1559 + 1560 + static INT get_cjk_fontinfo_margin(INT width, INT side_bearing) 1561 + { 1562 + INT margin; 1563 + if (side_bearing < 0) 1564 + margin = min(-side_bearing, width/2); 1565 + else 1566 + margin = 0; 1567 + return margin; 1568 + } 1569 + 1570 + static DWORD get_cjk_font_margins(HDC hdc, BOOL unicode) 1571 + { 1572 + ABC abc[256]; 1573 + SHORT left, right; 1574 + UINT i; 1575 + 1576 + left = right = 0; 1577 + if (unicode) { 1578 + if (!GetCharABCWidthsW(hdc, 0, 255, abc)) 1579 + return 0; 1580 + } 1581 + else { 1582 + if (!GetCharABCWidthsA(hdc, 0, 255, abc)) 1583 + return 0; 1584 + } 1585 + for (i = 0; i < ARRAY_SIZE(abc); i++) { 1586 + if (-abc[i].abcA > right) right = -abc[i].abcA; 1587 + if (-abc[i].abcC > left) left = -abc[i].abcC; 1588 + } 1589 + return MAKELONG(left, right); 1590 + } 1591 + 1592 + static void test_margins_default(const char* facename, UINT charset) 1593 + { 1594 + HWND hwnd; 1595 + HDC hdc; 1596 + TEXTMETRICW tm; 1597 + SIZE size; 1598 + BOOL cjk_charset, cjk_font; 1599 + LOGFONTA lf; 1600 + HFONT hfont; 1601 + RECT rect; 1602 + INT margins, expect, font_expect; 1603 + const UINT small_margins = MAKELONG(1, 5); 1604 + const WCHAR EditW[] = {'E','d','i','t',0}, strW[] = {'W',0}; 1605 + struct char_width_info { 1606 + INT lsb, rsb, unknown; 1607 + } info; 1608 + HMODULE hgdi32; 1609 + BOOL (WINAPI *pGetCharWidthInfo)(HDC, struct char_width_info *); 1610 + 1611 + hgdi32 = GetModuleHandleA("gdi32.dll"); 1612 + pGetCharWidthInfo = (void *)GetProcAddress(hgdi32, "GetCharWidthInfo"); 1613 + 1614 + memset(&lf, 0, sizeof(lf)); 1615 + lf.lfHeight = -11; 1616 + lf.lfWeight = FW_NORMAL; 1617 + lf.lfCharSet = charset; 1618 + strcpy(lf.lfFaceName, facename); 1619 + 1620 + hfont = CreateFontIndirectA(&lf); 1621 + ok(hfont != NULL, "got %p\n", hfont); 1622 + 1623 + /* Unicode version */ 1624 + hwnd = CreateWindowExW(0, EditW, strW, WS_POPUP, 0, 0, 5000, 1000, NULL, NULL, NULL, NULL); 1625 + ok(hwnd != NULL, "got %p\n", hwnd); 1626 + GetClientRect(hwnd, &rect); 1627 + ok(!IsRectEmpty(&rect), "got rect %s\n", wine_dbgstr_rect(&rect)); 1628 + 1629 + hdc = GetDC(hwnd); 1630 + hfont = SelectObject(hdc, hfont); 1631 + size.cx = GdiGetCharDimensions( hdc, &tm, &size.cy ); 1632 + if ((charset != tm.tmCharSet && charset != DEFAULT_CHARSET) || 1633 + !(tm.tmPitchAndFamily & (TMPF_TRUETYPE | TMPF_VECTOR))) { 1634 + skip("%s for charset %d isn't available\n", lf.lfFaceName, charset); 1635 + hfont = SelectObject(hdc, hfont); 1636 + ReleaseDC(hwnd, hdc); 1637 + DestroyWindow(hwnd); 1638 + DeleteObject(hfont); 1639 + return; 1640 + } 1641 + cjk_charset = is_cjk_charset(hdc); 1642 + cjk_font = is_cjk_font(hdc); 1643 + if ((cjk_charset || cjk_font) && 1644 + pGetCharWidthInfo && pGetCharWidthInfo(hdc, &info)) { 1645 + short left, right; 1646 + 1647 + left = get_cjk_fontinfo_margin(size.cx, info.lsb); 1648 + right = get_cjk_fontinfo_margin(size.cx, info.rsb); 1649 + expect = MAKELONG(left, right); 1650 + 1651 + font_expect = get_cjk_font_margins(hdc, TRUE); 1652 + if (!font_expect) 1653 + /* In this case, margins aren't updated */ 1654 + font_expect = small_margins; 1655 + } 1656 + else 1657 + font_expect = expect = MAKELONG(size.cx / 2, size.cx / 2); 1658 + 1659 + hfont = SelectObject(hdc, hfont); 1660 + ReleaseDC(hwnd, hdc); 1661 + 1662 + margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0); 1663 + ok(margins == 0, "got %x\n", margins); 1664 + SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, small_margins); 1665 + SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0)); 1666 + margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0); 1667 + ok(margins == font_expect, "%s:%d: expected %d, %d, got %d, %d\n", facename, charset, HIWORD(font_expect), LOWORD(font_expect), HIWORD(margins), LOWORD(margins)); 1668 + SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, small_margins); 1669 + SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO, EC_USEFONTINFO)); 1670 + margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0); 1671 + ok(margins == expect, "%s:%d: expected %d, %d, got %d, %d\n", facename, charset, HIWORD(expect), LOWORD(expect), HIWORD(margins), LOWORD(margins)); 1672 + DestroyWindow(hwnd); 1673 + 1674 + /* ANSI version */ 1675 + hwnd = CreateWindowExA(0, "Edit", "A", WS_POPUP, 0, 0, 5000, 1000, NULL, NULL, NULL, NULL); 1676 + ok(hwnd != NULL, "got %p\n", hwnd); 1677 + GetClientRect(hwnd, &rect); 1678 + ok(!IsRectEmpty(&rect), "got rect %s\n", wine_dbgstr_rect(&rect)); 1679 + 1680 + if (cjk_charset) { 1681 + hdc = GetDC(hwnd); 1682 + hfont = SelectObject(hdc, hfont); 1683 + font_expect = get_cjk_font_margins(hdc, FALSE); 1684 + if (!font_expect) 1685 + /* In this case, margins aren't updated */ 1686 + font_expect = small_margins; 1687 + hfont = SelectObject(hdc, hfont); 1688 + ReleaseDC(hwnd, hdc); 1689 + } 1690 + else 1691 + /* we expect EC_USEFONTINFO size */ 1692 + font_expect = expect; 1693 + 1694 + margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0); 1695 + ok(margins == 0, "got %x\n", margins); 1696 + SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, small_margins); 1697 + SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0)); 1698 + margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0); 1699 + ok(margins == font_expect, "%s:%d: expected %d, %d, got %d, %d\n", facename, charset, HIWORD(font_expect), LOWORD(font_expect), HIWORD(margins), LOWORD(margins)); 1700 + SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, small_margins); 1701 + SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO, EC_USEFONTINFO)); 1702 + margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0); 1703 + ok(margins == expect, "%s:%d: expected %d, %d, got %d, %d\n", facename, charset, HIWORD(expect), LOWORD(expect), HIWORD(margins), LOWORD(margins)); 1704 + DestroyWindow(hwnd); 1705 + 1706 + DeleteObject(hfont); 1707 + } 1708 + 1709 + static INT CALLBACK find_font_proc(const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam) 1710 + { 1711 + return 0; 1712 + } 1713 + 1714 + static BOOL is_font_installed(const char*name) 1715 + { 1716 + HDC hdc = GetDC(NULL); 1717 + BOOL ret = FALSE; 1718 + 1719 + if (!EnumFontFamiliesA(hdc, name, find_font_proc, 0)) 1720 + ret = TRUE; 1721 + 1722 + ReleaseDC(NULL, hdc); 1723 + return ret; 1724 + } 1725 + 1544 1726 static void test_margins(void) 1545 1727 { 1546 1728 HWND hwEdit; ··· 1615 1797 but not by < Win 8 and Win 10. */ 1616 1798 1617 1799 test_margins_usefontinfo(DEFAULT_CHARSET); 1618 - } 1619 1800 1620 - static INT CALLBACK find_font_proc(const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam) 1621 - { 1622 - return 0; 1801 + test_margins_default("Tahoma", ANSI_CHARSET); 1802 + test_margins_default("Tahoma", EASTEUROPE_CHARSET); 1803 + 1804 + test_margins_default("Tahoma", HANGUL_CHARSET); 1805 + test_margins_default("Tahoma", CHINESEBIG5_CHARSET); 1806 + 1807 + if (is_font_installed("MS PGothic")) { 1808 + test_margins_default("MS PGothic", SHIFTJIS_CHARSET); 1809 + test_margins_default("MS PGothic", GREEK_CHARSET); 1810 + } 1811 + else 1812 + skip("MS PGothic is not available, skipping some margin tests\n"); 1813 + 1814 + if (is_font_installed("Ume P Gothic")) { 1815 + test_margins_default("Ume P Gothic", SHIFTJIS_CHARSET); 1816 + test_margins_default("Ume P Gothic", GREEK_CHARSET); 1817 + } 1818 + else 1819 + skip("Ume P Gothic is not available, skipping some margin tests\n"); 1820 + 1821 + if (is_font_installed("SimSun")) { 1822 + test_margins_default("SimSun", GB2312_CHARSET); 1823 + test_margins_default("SimSun", ANSI_CHARSET); 1824 + } 1825 + else 1826 + skip("SimSun is not available, skipping some margin tests\n"); 1623 1827 } 1624 1828 1625 1829 static void test_margins_font_change(void) ··· 1628 1832 DWORD margins, font_margins; 1629 1833 LOGFONTA lf; 1630 1834 HFONT hfont, hfont2; 1631 - HDC hdc = GetDC(0); 1632 1835 1633 - if(EnumFontFamiliesA(hdc, "Arial", find_font_proc, 0)) 1836 + if (!is_font_installed("Arial")) 1634 1837 { 1635 - trace("Arial not found - skipping font change margin tests\n"); 1636 - ReleaseDC(0, hdc); 1838 + skip("Arial not found - skipping font change margin tests\n"); 1637 1839 return; 1638 1840 } 1639 - ReleaseDC(0, hdc); 1640 1841 1641 1842 hwEdit = create_child_editcontrol(0, 0); 1642 1843 ··· 1645 1846 memset(&lf, 0, sizeof(lf)); 1646 1847 strcpy(lf.lfFaceName, "Arial"); 1647 1848 lf.lfHeight = 16; 1648 - lf.lfCharSet = DEFAULT_CHARSET; 1849 + lf.lfCharSet = GREEK_CHARSET; /* to avoid associated charset feature */ 1649 1850 hfont = CreateFontIndirectA(&lf); 1650 1851 lf.lfHeight = 30; 1651 1852 hfont2 = CreateFontIndirectA(&lf); ··· 1660 1861 SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(0,0)); 1661 1862 SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, 0); 1662 1863 margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0); 1663 - ok(LOWORD(margins) == 0 || broken(LOWORD(margins) == LOWORD(font_margins)), /* win95 */ 1864 + ok(LOWORD(margins) == 0, 1664 1865 "got %d\n", LOWORD(margins)); 1665 - ok(HIWORD(margins) == 0 || broken(HIWORD(margins) == HIWORD(font_margins)), /* win95 */ 1866 + ok(HIWORD(margins) == 0, 1666 1867 "got %d\n", HIWORD(margins)); 1667 1868 1668 1869 SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(1,0)); 1669 1870 SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, 0); 1670 1871 margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0); 1671 - ok(LOWORD(margins) == 1 || broken(LOWORD(margins) == LOWORD(font_margins)), /* win95 */ 1872 + ok(LOWORD(margins) == 1, 1672 1873 "got %d\n", LOWORD(margins)); 1673 - ok(HIWORD(margins) == 0 || broken(HIWORD(margins) == HIWORD(font_margins)), /* win95 */ 1874 + ok(HIWORD(margins) == 0, 1674 1875 "got %d\n", HIWORD(margins)); 1675 1876 1676 1877 SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(1,1)); 1677 1878 SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, 0); 1678 1879 margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0); 1679 - ok(LOWORD(margins) == 1 || broken(LOWORD(margins) == LOWORD(font_margins)), /* win95 */ 1880 + ok(LOWORD(margins) == 1, 1680 1881 "got %d\n", LOWORD(margins)); 1681 - ok(HIWORD(margins) == 1 || broken(HIWORD(margins) == HIWORD(font_margins)), /* win95 */ 1882 + ok(HIWORD(margins) == 1, 1682 1883 "got %d\n", HIWORD(margins)); 1683 1884 1684 1885 SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO,EC_USEFONTINFO)); 1685 1886 margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0); 1686 - ok(LOWORD(margins) == 1 || broken(LOWORD(margins) == LOWORD(font_margins)), /* win95 */ 1887 + ok(LOWORD(margins) == 1, 1687 1888 "got %d\n", LOWORD(margins)); 1688 - ok(HIWORD(margins) == 1 || broken(HIWORD(margins) == HIWORD(font_margins)), /* win95 */ 1889 + ok(HIWORD(margins) == 1, 1689 1890 "got %d\n", HIWORD(margins)); 1690 1891 1691 1892 SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont2, 0); 1692 1893 margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0); 1693 - ok(LOWORD(margins) == 1 || broken(LOWORD(margins) != 1 && LOWORD(margins) != LOWORD(font_margins)), /* win95 */ 1894 + ok(LOWORD(margins) == 1, 1694 1895 "got %d\n", LOWORD(margins)); 1695 - ok(HIWORD(margins) == 1 || broken(HIWORD(margins) != 1 && HIWORD(margins) != HIWORD(font_margins)), /* win95 */ 1896 + ok(HIWORD(margins) == 1, 1696 1897 "got %d\n", HIWORD(margins)); 1697 1898 1698 1899 /* Above a certain size threshold then the margin is updated */ ··· 1716 1917 ok(HIWORD(margins) == HIWORD(font_margins), "got %d\n", HIWORD(margins)); 1717 1918 SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont2, 0); 1718 1919 margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0); 1719 - ok(LOWORD(margins) != LOWORD(font_margins) || broken(LOWORD(margins) == LOWORD(font_margins)), /* win98 */ 1920 + ok(LOWORD(margins) != LOWORD(font_margins), 1720 1921 "got %d\n", LOWORD(margins)); 1721 1922 ok(HIWORD(margins) != HIWORD(font_margins), "got %d\n", HIWORD(margins)); 1722 1923 ··· 2956 3157 hwnd[0] = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); 2957 3158 hwnd[1] = create_editcontrolW(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); 2958 3159 2959 - for (i = 0; i < sizeof(hwnd)/sizeof(hwnd[0]); i++) 3160 + for (i = 0; i < ARRAY_SIZE(hwnd); i++) 2960 3161 { 2961 3162 static const WCHAR strW[] = {'t','e','x','t',0}; 2962 3163 static const char *str = "text"; ··· 2984 3185 ok(!strcmp(buff, str), "Unexpected line data %s.\n", buff); 2985 3186 2986 3187 memset(buffW, 0, sizeof(buffW)); 2987 - *(WORD *)buffW = sizeof(buffW)/sizeof(buffW[0]); 3188 + *(WORD *)buffW = ARRAY_SIZE(buffW); 2988 3189 r = SendMessageW(hwnd[i], EM_GETLINE, 0, (LPARAM)buffW); 2989 3190 ok(r == lstrlenW(strW), "Failed to get a line %d.\n", r); 2990 3191 ok(!lstrcmpW(buffW, strW), "Unexpected line data %s.\n", wine_dbgstr_w(buffW)); 2991 3192 2992 3193 memset(buffW, 0, sizeof(buffW)); 2993 - *(WORD *)buffW = sizeof(buffW)/sizeof(buffW[0]); 3194 + *(WORD *)buffW = ARRAY_SIZE(buffW); 2994 3195 r = SendMessageW(hwnd[i], EM_GETLINE, 1, (LPARAM)buffW); 2995 3196 ok(r == lstrlenW(strW), "Failed to get a line %d.\n", r); 2996 3197 ok(!lstrcmpW(buffW, strW), "Unexpected line data %s.\n", wine_dbgstr_w(buffW));
+389 -95
modules/rostests/winetests/user32/input.c
··· 79 79 LONG last_hook_up; 80 80 LONG last_hook_syskey_down; 81 81 LONG last_hook_syskey_up; 82 + WORD vk; 82 83 BOOL expect_alt; 83 84 BOOL sendinput_broken; 84 85 } key_status; 85 86 86 - static UINT (WINAPI *pSendInput) (UINT, INPUT*, size_t); 87 + static BOOL (WINAPI *pGetCurrentInputMessageSource)( INPUT_MESSAGE_SOURCE *source ); 88 + static BOOL (WINAPI *pGetPointerType)(UINT32, POINTER_INPUT_TYPE*); 87 89 static int (WINAPI *pGetMouseMovePointsEx) (UINT, LPMOUSEMOVEPOINT, LPMOUSEMOVEPOINT, int, DWORD); 88 90 static UINT (WINAPI *pGetRawInputDeviceList) (PRAWINPUTDEVICELIST, PUINT, UINT); 91 + static UINT (WINAPI *pGetRawInputDeviceInfoW) (HANDLE, UINT, void *, UINT *); 92 + static UINT (WINAPI *pGetRawInputDeviceInfoA) (HANDLE, UINT, void *, UINT *); 89 93 static int (WINAPI *pGetWindowRgnBox)(HWND, LPRECT); 90 94 91 95 #define MAXKEYEVENTS 12 ··· 120 124 } u; 121 125 } TEST_INPUT; 122 126 123 - #define ADDTOINPUTS(kev) \ 124 - inputs[evtctr].type = INPUT_KEYBOARD; \ 125 - ((TEST_INPUT*)inputs)[evtctr].u.ki.wVk = GETVKEY[ kev]; \ 126 - ((TEST_INPUT*)inputs)[evtctr].u.ki.wScan = GETSCAN[ kev]; \ 127 - ((TEST_INPUT*)inputs)[evtctr].u.ki.dwFlags = GETFLAGS[ kev]; \ 128 - ((TEST_INPUT*)inputs)[evtctr].u.ki.dwExtraInfo = 0; \ 129 - ((TEST_INPUT*)inputs)[evtctr].u.ki.time = ++timetag; \ 130 - if( kev) evtctr++; 131 - 132 127 typedef struct { 133 128 UINT message; 134 129 WPARAM wParam; ··· 164 159 HMODULE hdll = GetModuleHandleA("user32"); 165 160 166 161 #define GET_PROC(func) \ 167 - p ## func = (void*)GetProcAddress(hdll, #func); \ 168 - if(!p ## func) \ 169 - trace("GetProcAddress(%s) failed\n", #func); 162 + if (!(p ## func = (void*)GetProcAddress(hdll, #func))) \ 163 + trace("GetProcAddress(%s) failed\n", #func) 170 164 171 - GET_PROC(SendInput) 172 - GET_PROC(GetMouseMovePointsEx) 173 - GET_PROC(GetRawInputDeviceList) 174 - GET_PROC(GetWindowRgnBox) 175 - 165 + GET_PROC(GetCurrentInputMessageSource); 166 + GET_PROC(GetMouseMovePointsEx); 167 + GET_PROC(GetPointerType); 168 + GET_PROC(GetRawInputDeviceList); 169 + GET_PROC(GetRawInputDeviceInfoW); 170 + GET_PROC(GetRawInputDeviceInfoA); 171 + GET_PROC(GetWindowRgnBox); 176 172 #undef GET_PROC 177 173 } 178 174 ··· 232 228 */ 233 229 static BOOL do_test( HWND hwnd, int seqnr, const KEV td[] ) 234 230 { 235 - INPUT inputs[MAXKEYEVENTS]; 231 + TEST_INPUT inputs[MAXKEYEVENTS]; 236 232 KMSG expmsg[MAXKEYEVENTS]; 237 233 MSG msg; 238 234 char buf[100]; 239 - UINT evtctr=0; 235 + UINT evtctr=0, ret; 240 236 int kmctr, i; 241 237 242 238 buf[0]='\0'; 243 239 TrackSysKey=0; /* see input.c */ 244 - for( i = 0; i < MAXKEYEVENTS; i++) { 245 - ADDTOINPUTS(td[i]) 240 + for (i = 0; i < MAXKEYEVENTS; i++) 241 + { 242 + inputs[evtctr].type = INPUT_KEYBOARD; 243 + inputs[evtctr].u.ki.wVk = GETVKEY[td[i]]; 244 + inputs[evtctr].u.ki.wScan = GETSCAN[td[i]]; 245 + inputs[evtctr].u.ki.dwFlags = GETFLAGS[td[i]]; 246 + inputs[evtctr].u.ki.dwExtraInfo = 0; 247 + inputs[evtctr].u.ki.time = ++timetag; 248 + if (td[i]) evtctr++; 249 + 246 250 strcat(buf, getdesc[td[i]]); 247 251 if(td[i]) 248 252 expmsg[i].message = KbdMessage(td[i], &(expmsg[i].wParam), &(expmsg[i].lParam)); ··· 252 256 for( kmctr = 0; kmctr < MAXKEYEVENTS && expmsg[kmctr].message; kmctr++) 253 257 ; 254 258 ok( evtctr <= MAXKEYEVENTS, "evtctr is above MAXKEYEVENTS\n" ); 255 - if( evtctr != pSendInput(evtctr, &inputs[0], sizeof(INPUT))) 256 - ok (FALSE, "SendInput failed to send some events\n"); 259 + ret = SendInput(evtctr, (INPUT *)inputs, sizeof(INPUT)); 260 + ok(ret == evtctr, "SendInput failed to send some events\n"); 257 261 i = 0; 258 262 if (winetest_debug > 1) 259 263 trace("======== key stroke sequence #%d: %s =============\n", ··· 700 704 static UINT sent_messages_cnt; 701 705 702 706 /* Verify that only specified key state transitions occur */ 703 - static void compare_and_check(int id, BYTE *ks1, BYTE *ks2, const struct sendinput_test_s *test) 707 + static void compare_and_check(int id, BYTE *ks1, BYTE *ks2, 708 + const struct sendinput_test_s *test, BOOL foreground) 704 709 { 705 710 int i, failcount = 0; 706 711 const struct transition_s *t = test->expected_transitions; 707 712 UINT actual_cnt = 0; 708 713 const struct message *expected = test->expected_messages; 709 714 710 - while (t->wVk) { 715 + while (t->wVk && foreground) { 716 + /* We won't receive any information from GetKeyboardState() if we're 717 + * not the foreground window. */ 711 718 BOOL matched = ((ks1[t->wVk]&0x80) == (t->before_state&0x80) 712 719 && (ks2[t->wVk]&0x80) == (~t->before_state&0x80)); 713 720 ··· 790 797 expected++; 791 798 continue; 792 799 } 800 + else if (!(expected->flags & hook) && !foreground) 801 + { 802 + /* If we weren't able to receive foreground status, we won't get 803 + * any window messages. */ 804 + expected++; 805 + continue; 806 + } 793 807 /* NT4 doesn't send SYSKEYDOWN/UP to hooks, only KEYDOWN/UP */ 794 808 else if ((expected->flags & hook) && 795 809 (expected->message == WM_SYSKEYDOWN || expected->message == WM_SYSKEYUP) && ··· 826 840 expected++; 827 841 } 828 842 /* skip all optional trailing messages */ 829 - while (expected->message && (expected->flags & optional)) 843 + while (expected->message && ((expected->flags & optional) || (!(expected->flags & hook) && !foreground))) 830 844 expected++; 831 845 832 846 ··· 857 871 { 858 872 if (winetest_debug > 1) trace("MSG: %8x W:%8lx L:%8lx\n", Msg, wParam, lParam); 859 873 860 - if (Msg != WM_PAINT && 861 - Msg != WM_NCPAINT && 862 - Msg != WM_SYNCPAINT && 863 - Msg != WM_ERASEBKGND && 864 - Msg != WM_NCHITTEST && 865 - Msg != WM_GETTEXT && 866 - Msg != WM_GETICON && 867 - Msg != WM_IME_SELECT && 868 - Msg != WM_DEVICECHANGE && 869 - Msg != WM_TIMECHANGE) 874 + if ((Msg >= WM_KEYFIRST && Msg <= WM_KEYLAST) || Msg == WM_SYSCOMMAND) 870 875 { 871 876 ok(sent_messages_cnt < MAXKEYMESSAGES, "Too many messages\n"); 872 877 if (sent_messages_cnt < MAXKEYMESSAGES) ··· 915 920 int ii; 916 921 BYTE ks1[256], ks2[256]; 917 922 LONG_PTR prevWndProc; 923 + BOOL foreground; 918 924 HWND window; 919 925 HHOOK hook; 920 926 ··· 928 934 NULL, NULL); 929 935 ok(window != NULL, "error: %d\n", (int) GetLastError()); 930 936 SetWindowPos( window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE ); 931 - SetForegroundWindow( window ); 937 + foreground = SetForegroundWindow( window ); 938 + if (!foreground) 939 + skip("Failed to set foreground window; some tests will be skipped.\n"); 932 940 933 941 if (!(hook = SetWindowsHookExA(WH_KEYBOARD_LL, hook_proc, GetModuleHandleA( NULL ), 0))) 934 942 { ··· 948 956 i.u.ki.time = 0; 949 957 i.u.ki.dwExtraInfo = 0; 950 958 951 - for (ii = 0; ii < sizeof(sendinput_test)/sizeof(struct sendinput_test_s)-1; 952 - ii++) { 959 + for (ii = 0; ii < ARRAY_SIZE(sendinput_test)-1; ii++) { 953 960 GetKeyboardState(ks1); 954 961 i.u.ki.wScan = ii+1 /* useful for debugging */; 955 962 i.u.ki.dwFlags = sendinput_test[ii].dwFlags; 956 963 i.u.ki.wVk = sendinput_test[ii].wVk; 957 - pSendInput(1, (INPUT*)&i, sizeof(TEST_INPUT)); 964 + SendInput(1, (INPUT*)&i, sizeof(TEST_INPUT)); 958 965 empty_message_queue(); 959 966 GetKeyboardState(ks2); 960 - if (!ii && sent_messages_cnt <= 1 && !memcmp( ks1, ks2, sizeof(ks1) )) 961 - { 962 - win_skip( "window doesn't receive the queued input\n" ); 963 - /* release the key */ 964 - i.u.ki.dwFlags |= KEYEVENTF_KEYUP; 965 - pSendInput(1, (INPUT*)&i, sizeof(TEST_INPUT)); 966 - break; 967 - } 968 - compare_and_check(ii, ks1, ks2, &sendinput_test[ii]); 967 + compare_and_check(ii, ks1, ks2, &sendinput_test[ii], foreground); 969 968 } 970 969 971 970 empty_message_queue(); ··· 973 972 UnhookWindowsHookEx(hook); 974 973 } 975 974 976 - static void reset_key_status(void) 975 + static void reset_key_status(WORD vk) 977 976 { 978 977 key_status.last_key_down = -1; 979 978 key_status.last_key_up = -1; ··· 985 984 key_status.last_hook_up = -1; 986 985 key_status.last_hook_syskey_down = -1; 987 986 key_status.last_hook_syskey_up = -1; 987 + key_status.vk = vk; 988 988 key_status.expect_alt = FALSE; 989 989 key_status.sendinput_broken = FALSE; 990 990 } ··· 1004 1004 inputs[0].u.ki.wScan = 0x3c0; 1005 1005 inputs[0].u.ki.dwFlags = KEYEVENTF_UNICODE; 1006 1006 1007 - reset_key_status(); 1008 - pSendInput(1, (INPUT*)inputs, sizeof(INPUT)); 1007 + reset_key_status(VK_PACKET); 1008 + SendInput(1, (INPUT*)inputs, sizeof(INPUT)); 1009 1009 while(PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE)){ 1010 1010 if(msg.message == WM_KEYDOWN && msg.wParam == VK_PACKET){ 1011 1011 TranslateMessage(&msg); ··· 1026 1026 inputs[1].u.ki.wScan = 0x3c0; 1027 1027 inputs[1].u.ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP; 1028 1028 1029 - reset_key_status(); 1030 - pSendInput(1, (INPUT*)(inputs+1), sizeof(INPUT)); 1029 + reset_key_status(VK_PACKET); 1030 + SendInput(1, (INPUT*)(inputs+1), sizeof(INPUT)); 1031 1031 while(PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE)){ 1032 1032 if(msg.message == WM_KEYDOWN && msg.wParam == VK_PACKET){ 1033 1033 TranslateMessage(&msg); ··· 1051 1051 inputs[1].u.ki.wScan = 0x3041; 1052 1052 inputs[1].u.ki.dwFlags = KEYEVENTF_UNICODE; 1053 1053 1054 - reset_key_status(); 1054 + reset_key_status(VK_PACKET); 1055 1055 key_status.expect_alt = TRUE; 1056 - pSendInput(2, (INPUT*)inputs, sizeof(INPUT)); 1056 + SendInput(2, (INPUT*)inputs, sizeof(INPUT)); 1057 1057 while(PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE)){ 1058 1058 if(msg.message == WM_SYSKEYDOWN && msg.wParam == VK_PACKET){ 1059 1059 TranslateMessage(&msg); ··· 1078 1078 inputs[0].u.ki.wScan = 0; 1079 1079 inputs[0].u.ki.dwFlags = KEYEVENTF_KEYUP; 1080 1080 1081 - reset_key_status(); 1081 + reset_key_status(VK_PACKET); 1082 1082 key_status.expect_alt = TRUE; 1083 - pSendInput(2, (INPUT*)inputs, sizeof(INPUT)); 1083 + SendInput(2, (INPUT*)inputs, sizeof(INPUT)); 1084 1084 while(PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE)){ 1085 1085 if(msg.message == WM_SYSKEYDOWN && msg.wParam == VK_PACKET){ 1086 1086 TranslateMessage(&msg); ··· 1094 1094 ok(key_status.last_hook_up == 0x3041, 1095 1095 "Last hook up msg should have been 0x3041, was: 0x%x\n", key_status.last_hook_up); 1096 1096 } 1097 + 1098 + /* Press and release, non-zero key code. */ 1099 + inputs[0].u.ki.wVk = 0x51; 1100 + inputs[0].u.ki.wScan = 0x123; 1101 + inputs[0].u.ki.dwFlags = KEYEVENTF_UNICODE; 1102 + 1103 + inputs[1].u.ki.wVk = 0x51; 1104 + inputs[1].u.ki.wScan = 0x123; 1105 + inputs[1].u.ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP; 1106 + 1107 + reset_key_status(inputs[0].u.ki.wVk); 1108 + SendInput(2, (INPUT*)inputs, sizeof(INPUT)); 1109 + while (PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE)) 1110 + { 1111 + TranslateMessage(&msg); 1112 + DispatchMessageW(&msg); 1113 + } 1114 + 1115 + if (!key_status.sendinput_broken) 1116 + { 1117 + ok(key_status.last_key_down == 0x51, "Unexpected key down %#x.\n", key_status.last_key_down); 1118 + ok(key_status.last_key_up == 0x51, "Unexpected key up %#x.\n", key_status.last_key_up); 1119 + if (hook) 1120 + todo_wine 1121 + ok(key_status.last_hook_up == 0x23, "Unexpected hook message %#x.\n", key_status.last_hook_up); 1122 + } 1097 1123 } 1098 1124 1099 1125 static LRESULT CALLBACK unicode_wnd_proc( HWND hWnd, UINT msg, WPARAM wParam, ··· 1134 1160 ok(info->vkCode == VK_LMENU, "vkCode should have been VK_LMENU[0x%04x], was: 0x%x\n", VK_LMENU, info->vkCode); 1135 1161 key_status.expect_alt = FALSE; 1136 1162 }else 1137 - ok(info->vkCode == VK_PACKET, "vkCode should have been VK_PACKET[0x%04x], was: 0x%x\n", VK_PACKET, info->vkCode); 1163 + todo_wine_if(key_status.vk != VK_PACKET) 1164 + ok(info->vkCode == key_status.vk, "Unexpected vkCode %#x, expected %#x.\n", info->vkCode, key_status.vk); 1138 1165 } 1139 1166 switch(wParam){ 1140 1167 case WM_KEYDOWN: ··· 1569 1596 static void test_GetRawInputDeviceList(void) 1570 1597 { 1571 1598 RAWINPUTDEVICELIST devices[32]; 1572 - UINT ret, oret, devcount, odevcount; 1599 + UINT ret, oret, devcount, odevcount, i; 1573 1600 DWORD err; 1574 1601 1575 1602 SetLastError(0xdeadbeef); ··· 1601 1628 ret = pGetRawInputDeviceList(devices, &devcount, sizeof(devices[0])); 1602 1629 ok(ret > 0, "expected non-zero\n"); 1603 1630 1631 + for(i = 0; i < devcount; ++i) 1632 + { 1633 + WCHAR name[128]; 1634 + char nameA[128]; 1635 + UINT sz, len; 1636 + RID_DEVICE_INFO info; 1637 + HANDLE file; 1638 + 1639 + /* get required buffer size */ 1640 + name[0] = '\0'; 1641 + sz = 5; 1642 + ret = pGetRawInputDeviceInfoW(devices[i].hDevice, RIDI_DEVICENAME, name, &sz); 1643 + ok(ret == -1, "GetRawInputDeviceInfo gave wrong failure: %d\n", err); 1644 + ok(sz > 5 && sz < ARRAY_SIZE(name), "Size should have been set and not too large (got: %u)\n", sz); 1645 + 1646 + /* buffer size for RIDI_DEVICENAME is in CHARs, not BYTEs */ 1647 + ret = pGetRawInputDeviceInfoW(devices[i].hDevice, RIDI_DEVICENAME, name, &sz); 1648 + ok(ret == sz, "GetRawInputDeviceInfo gave wrong return: %d\n", err); 1649 + len = lstrlenW(name); 1650 + ok(len + 1 == ret, "GetRawInputDeviceInfo returned wrong length (name: %u, ret: %u)\n", len + 1, ret); 1651 + 1652 + /* test A variant with same size */ 1653 + ret = pGetRawInputDeviceInfoA(devices[i].hDevice, RIDI_DEVICENAME, nameA, &sz); 1654 + ok(ret == sz, "GetRawInputDeviceInfoA gave wrong return: %d\n", err); 1655 + len = strlen(nameA); 1656 + ok(len + 1 == ret, "GetRawInputDeviceInfoA returned wrong length (name: %u, ret: %u)\n", len + 1, ret); 1657 + 1658 + /* buffer size for RIDI_DEVICEINFO is in BYTEs */ 1659 + memset(&info, 0, sizeof(info)); 1660 + info.cbSize = sizeof(info); 1661 + sz = sizeof(info) - 1; 1662 + ret = pGetRawInputDeviceInfoW(devices[i].hDevice, RIDI_DEVICEINFO, &info, &sz); 1663 + ok(ret == -1, "GetRawInputDeviceInfo gave wrong failure: %d\n", err); 1664 + ok(sz == sizeof(info), "GetRawInputDeviceInfo set wrong size\n"); 1665 + 1666 + ret = pGetRawInputDeviceInfoW(devices[i].hDevice, RIDI_DEVICEINFO, &info, &sz); 1667 + ok(ret == sizeof(info), "GetRawInputDeviceInfo gave wrong return: %d\n", err); 1668 + ok(sz == sizeof(info), "GetRawInputDeviceInfo set wrong size\n"); 1669 + ok(info.dwType == devices[i].dwType, "GetRawInputDeviceInfo set wrong type: 0x%x\n", info.dwType); 1670 + 1671 + memset(&info, 0, sizeof(info)); 1672 + info.cbSize = sizeof(info); 1673 + ret = pGetRawInputDeviceInfoA(devices[i].hDevice, RIDI_DEVICEINFO, &info, &sz); 1674 + ok(ret == sizeof(info), "GetRawInputDeviceInfo gave wrong return: %d\n", err); 1675 + ok(sz == sizeof(info), "GetRawInputDeviceInfo set wrong size\n"); 1676 + ok(info.dwType == devices[i].dwType, "GetRawInputDeviceInfo set wrong type: 0x%x\n", info.dwType); 1677 + 1678 + /* setupapi returns an NT device path, but CreateFile() < Vista can't 1679 + * understand that; so use the \\?\ prefix instead */ 1680 + name[1] = '\\'; 1681 + file = CreateFileW(name, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); 1682 + todo_wine_if(info.dwType != RIM_TYPEHID) 1683 + ok(file != INVALID_HANDLE_VALUE, "Failed to open %s, error %u\n", wine_dbgstr_w(name), GetLastError()); 1684 + CloseHandle(file); 1685 + } 1686 + 1604 1687 /* check if variable changes from larger to smaller value */ 1605 - devcount = odevcount = sizeof(devices) / sizeof(devices[0]); 1688 + devcount = odevcount = ARRAY_SIZE(devices); 1606 1689 oret = ret = pGetRawInputDeviceList(devices, &odevcount, sizeof(devices[0])); 1607 1690 ok(ret > 0, "expected non-zero\n"); 1608 1691 ok(devcount == odevcount, "expected %d, got %d\n", devcount, odevcount); 1609 1692 devcount = odevcount; 1610 - odevcount = sizeof(devices) / sizeof(devices[0]); 1693 + odevcount = ARRAY_SIZE(devices); 1611 1694 ret = pGetRawInputDeviceList(NULL, &odevcount, sizeof(devices[0])); 1612 1695 ok(ret == 0, "expected 0, got %d\n", ret); 1613 1696 ok(odevcount == oret, "expected %d, got %d\n", oret, odevcount); 1614 1697 } 1615 1698 1699 + static void test_GetRawInputData(void) 1700 + { 1701 + UINT size; 1702 + UINT ret; 1703 + 1704 + /* Null raw input handle */ 1705 + ret = GetRawInputData(NULL, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER)); 1706 + ok(ret == ~0U, "Expect ret %u, got %u\n", ~0U, ret); 1707 + } 1708 + 1616 1709 static void test_key_map(void) 1617 1710 { 1618 1711 HKL kl = GetKeyboardLayout(0); ··· 1649 1742 "Scan code -> vKey = %x (not VK_RSHIFT)\n", kR); 1650 1743 1651 1744 /* test that MAPVK_VSC_TO_VK prefers the non-numpad vkey if there's ambiguity */ 1652 - for (i = 0; i < sizeof(numpad_collisions)/sizeof(numpad_collisions[0]); i++) 1745 + for (i = 0; i < ARRAY_SIZE(numpad_collisions); i++) 1653 1746 { 1654 1747 UINT numpad_scan = MapVirtualKeyExA(numpad_collisions[i][0], MAPVK_VK_TO_VSC, kl); 1655 1748 UINT other_scan = MapVirtualKeyExA(numpad_collisions[i][1], MAPVK_VK_TO_VSC, kl); ··· 1747 1840 "ToUnicode didn't null-terminate the buffer when there was room.\n"); 1748 1841 } 1749 1842 1750 - for (i = 0; i < sizeof(utests) / sizeof(utests[0]); i++) 1843 + for (i = 0; i < ARRAY_SIZE(utests); i++) 1751 1844 { 1752 1845 UINT vk = utests[i].vk, mod = utests[i].modifiers, scan; 1753 1846 ··· 1890 1983 ok( buffer[0] == 0, "wrong string '%s'\n", buffer ); 1891 1984 1892 1985 memset( bufferW, 0xcc, sizeof(bufferW) ); 1893 - ret = GetKeyNameTextW( lparam, bufferW, sizeof(bufferW)/sizeof(WCHAR) ); 1986 + ret = GetKeyNameTextW( lparam, bufferW, ARRAY_SIZE(bufferW)); 1894 1987 ok( ret > 0, "wrong len %u for %s\n", ret, wine_dbgstr_w(bufferW) ); 1895 1988 ok( ret == lstrlenW(bufferW), "wrong len %u for %s\n", ret, wine_dbgstr_w(bufferW) ); 1896 1989 ··· 2274 2367 ok(region_type == ERROR, "expected ERROR, got %d\n", region_type); 2275 2368 } 2276 2369 2370 + get_dc_region(&region, hwnd, DCX_PARENTCLIP); 2371 + ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200, 2372 + "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(&region)); 2373 + get_dc_region(&region, hwnd, DCX_WINDOW | DCX_USESTYLE); 2374 + ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200, 2375 + "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(&region)); 2376 + get_dc_region(&region, hwnd, DCX_USESTYLE); 2377 + ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200, 2378 + "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(&region)); 2379 + get_dc_region(&region, static_win, DCX_PARENTCLIP); 2380 + ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200, 2381 + "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(&region)); 2382 + get_dc_region(&region, static_win, DCX_WINDOW | DCX_USESTYLE); 2383 + ok(region.left == 110 && region.top == 110 && region.right == 130 && region.bottom == 130, 2384 + "expected region (110,110)-(130,130), got %s\n", wine_dbgstr_rect(&region)); 2385 + get_dc_region(&region, static_win, DCX_USESTYLE); 2386 + ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200, 2387 + "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(&region)); 2388 + 2277 2389 got_button_down = got_button_up = FALSE; 2278 2390 simulate_click(TRUE, 150, 150); 2279 2391 while (wait_for_message(&msg)) ··· 2314 2426 2315 2427 if (msg.message == WM_LBUTTONDOWN) 2316 2428 { 2317 - todo_wine 2318 2429 ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd); 2319 2430 got_button_down = TRUE; 2320 2431 } 2321 2432 else if (msg.message == WM_LBUTTONUP) 2322 2433 { 2323 - todo_wine 2324 2434 ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd); 2325 2435 got_button_up = TRUE; 2326 2436 break; ··· 2372 2482 ok(region_type == ERROR, "expected ERROR, got %d\n", region_type); 2373 2483 } 2374 2484 2375 - get_dc_region(&region, hwnd, DCX_PARENTCLIP); 2376 - ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200, 2377 - "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(&region)); 2378 - get_dc_region(&region, hwnd, DCX_WINDOW | DCX_USESTYLE); 2379 - ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200, 2380 - "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(&region)); 2381 - get_dc_region(&region, hwnd, DCX_USESTYLE); 2382 - ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200, 2383 - "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(&region)); 2384 - get_dc_region(&region, static_win, DCX_PARENTCLIP); 2385 - ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200, 2386 - "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(&region)); 2387 - get_dc_region(&region, static_win, DCX_WINDOW | DCX_USESTYLE); 2388 - ok(region.left == 110 && region.top == 110 && region.right == 130 && region.bottom == 130, 2389 - "expected region (110,110)-(130,130), got %s\n", wine_dbgstr_rect(&region)); 2390 - get_dc_region(&region, static_win, DCX_USESTYLE); 2391 - ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200, 2392 - "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(&region)); 2393 - 2394 2485 got_button_down = got_button_up = FALSE; 2395 2486 simulate_click(TRUE, 150, 150); 2396 2487 while (wait_for_message(&msg)) ··· 2399 2490 2400 2491 if (msg.message == WM_LBUTTONDOWN) 2401 2492 { 2493 + todo_wine 2402 2494 ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd); 2403 2495 got_button_down = TRUE; 2404 2496 } 2405 2497 else if (msg.message == WM_LBUTTONUP) 2406 2498 { 2499 + todo_wine 2407 2500 ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd); 2408 2501 got_button_up = TRUE; 2409 2502 break; ··· 2832 2925 result = WaitForSingleObject(semaphores[0], 1000); 2833 2926 ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result); 2834 2927 2928 + SetForegroundWindow(hwnd); 2835 2929 SetFocus(hwnd); 2836 2930 keybd_event('X', 0, 0, 0); 2837 2931 ··· 2885 2979 } 2886 2980 } 2887 2981 2888 - START_TEST(input) 2982 + static INPUT_MESSAGE_SOURCE expect_src; 2983 + 2984 + static LRESULT WINAPI msg_source_proc( HWND hwnd, UINT message, WPARAM wp, LPARAM lp ) 2985 + { 2986 + INPUT_MESSAGE_SOURCE source; 2987 + MSG msg; 2988 + 2989 + ok( pGetCurrentInputMessageSource( &source ), "GetCurrentInputMessageSource failed\n" ); 2990 + switch (message) 2991 + { 2992 + case WM_KEYDOWN: 2993 + case WM_KEYUP: 2994 + case WM_SYSKEYDOWN: 2995 + case WM_SYSKEYUP: 2996 + case WM_MOUSEMOVE: 2997 + case WM_LBUTTONDOWN: 2998 + case WM_LBUTTONUP: 2999 + case WM_RBUTTONDOWN: 3000 + case WM_RBUTTONUP: 3001 + ok( source.deviceType == expect_src.deviceType || /* also accept system-generated WM_MOUSEMOVE */ 3002 + (message == WM_MOUSEMOVE && source.deviceType == IMDT_UNAVAILABLE), 3003 + "%x: wrong deviceType %x/%x\n", message, source.deviceType, expect_src.deviceType ); 3004 + ok( source.originId == expect_src.originId || 3005 + (message == WM_MOUSEMOVE && source.originId == IMO_SYSTEM), 3006 + "%x: wrong originId %x/%x\n", message, source.originId, expect_src.originId ); 3007 + SendMessageA( hwnd, WM_USER, 0, 0 ); 3008 + PostMessageA( hwnd, WM_USER, 0, 0 ); 3009 + if (PeekMessageW( &msg, hwnd, WM_USER, WM_USER, PM_REMOVE )) DispatchMessageW( &msg ); 3010 + ok( source.deviceType == expect_src.deviceType || /* also accept system-generated WM_MOUSEMOVE */ 3011 + (message == WM_MOUSEMOVE && source.deviceType == IMDT_UNAVAILABLE), 3012 + "%x: wrong deviceType %x/%x\n", message, source.deviceType, expect_src.deviceType ); 3013 + ok( source.originId == expect_src.originId || 3014 + (message == WM_MOUSEMOVE && source.originId == IMO_SYSTEM), 3015 + "%x: wrong originId %x/%x\n", message, source.originId, expect_src.originId ); 3016 + break; 3017 + default: 3018 + ok( source.deviceType == IMDT_UNAVAILABLE, "%x: wrong deviceType %x\n", 3019 + message, source.deviceType ); 3020 + ok( source.originId == 0, "%x: wrong originId %x\n", message, source.originId ); 3021 + break; 3022 + } 3023 + 3024 + return DefWindowProcA( hwnd, message, wp, lp ); 3025 + } 3026 + 3027 + static void test_input_message_source(void) 3028 + { 3029 + WNDCLASSA cls; 3030 + TEST_INPUT inputs[2]; 3031 + HWND hwnd; 3032 + RECT rc; 3033 + MSG msg; 3034 + 3035 + cls.style = 0; 3036 + cls.lpfnWndProc = msg_source_proc; 3037 + cls.cbClsExtra = 0; 3038 + cls.cbWndExtra = 0; 3039 + cls.hInstance = GetModuleHandleA(0); 3040 + cls.hIcon = 0; 3041 + cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); 3042 + cls.hbrBackground = 0; 3043 + cls.lpszMenuName = NULL; 3044 + cls.lpszClassName = "message source class"; 3045 + RegisterClassA(&cls); 3046 + hwnd = CreateWindowA( cls.lpszClassName, "test", WS_OVERLAPPED, 0, 0, 100, 100, 3047 + 0, 0, 0, 0 ); 3048 + ShowWindow( hwnd, SW_SHOWNORMAL ); 3049 + UpdateWindow( hwnd ); 3050 + SetForegroundWindow( hwnd ); 3051 + SetFocus( hwnd ); 3052 + 3053 + inputs[0].type = INPUT_KEYBOARD; 3054 + inputs[0].u.ki.dwExtraInfo = 0; 3055 + inputs[0].u.ki.time = 0; 3056 + inputs[0].u.ki.wVk = 0; 3057 + inputs[0].u.ki.wScan = 0x3c0; 3058 + inputs[0].u.ki.dwFlags = KEYEVENTF_UNICODE; 3059 + inputs[1] = inputs[0]; 3060 + inputs[1].u.ki.dwFlags |= KEYEVENTF_KEYUP; 3061 + 3062 + expect_src.deviceType = IMDT_UNAVAILABLE; 3063 + expect_src.originId = IMO_UNAVAILABLE; 3064 + SendMessageA( hwnd, WM_KEYDOWN, 0, 0 ); 3065 + SendMessageA( hwnd, WM_MOUSEMOVE, 0, 0 ); 3066 + 3067 + SendInput( 2, (INPUT *)inputs, sizeof(INPUT) ); 3068 + while (PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE )) 3069 + { 3070 + expect_src.deviceType = IMDT_KEYBOARD; 3071 + expect_src.originId = IMO_INJECTED; 3072 + TranslateMessage( &msg ); 3073 + DispatchMessageW( &msg ); 3074 + } 3075 + GetWindowRect( hwnd, &rc ); 3076 + simulate_click( TRUE, (rc.left + rc.right) / 2, (rc.top + rc.bottom) / 2 ); 3077 + simulate_click( FALSE, (rc.left + rc.right) / 2 + 1, (rc.top + rc.bottom) / 2 + 1 ); 3078 + while (PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE )) 3079 + { 3080 + expect_src.deviceType = IMDT_MOUSE; 3081 + expect_src.originId = IMO_INJECTED; 3082 + TranslateMessage( &msg ); 3083 + DispatchMessageW( &msg ); 3084 + } 3085 + 3086 + expect_src.deviceType = IMDT_UNAVAILABLE; 3087 + expect_src.originId = IMO_UNAVAILABLE; 3088 + SendMessageA( hwnd, WM_KEYDOWN, 0, 0 ); 3089 + SendMessageA( hwnd, WM_LBUTTONDOWN, 0, 0 ); 3090 + PostMessageA( hwnd, WM_KEYUP, 0, 0 ); 3091 + PostMessageA( hwnd, WM_LBUTTONUP, 0, 0 ); 3092 + while (PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE )) 3093 + { 3094 + TranslateMessage( &msg ); 3095 + DispatchMessageW( &msg ); 3096 + } 3097 + 3098 + expect_src.deviceType = IMDT_UNAVAILABLE; 3099 + expect_src.originId = IMO_SYSTEM; 3100 + SetCursorPos( (rc.left + rc.right) / 2 - 1, (rc.top + rc.bottom) / 2 - 1 ); 3101 + while (PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE )) 3102 + { 3103 + TranslateMessage( &msg ); 3104 + DispatchMessageW( &msg ); 3105 + } 3106 + 3107 + DestroyWindow( hwnd ); 3108 + UnregisterClassA( cls.lpszClassName, GetModuleHandleA(0) ); 3109 + } 3110 + 3111 + static void test_GetPointerType(void) 2889 3112 { 2890 - init_function_pointers(); 3113 + BOOL ret; 3114 + POINTER_INPUT_TYPE type = -1; 3115 + UINT id = 0; 2891 3116 2892 - if (pSendInput) 3117 + SetLastError(0xdeadbeef); 3118 + ret = pGetPointerType(id, NULL); 3119 + ok(!ret, "GetPointerType should have failed.\n"); 3120 + ok(GetLastError() == ERROR_INVALID_PARAMETER, 3121 + "expected error ERROR_INVALID_PARAMETER, got %u.\n", GetLastError()); 3122 + 3123 + SetLastError(0xdeadbeef); 3124 + ret = pGetPointerType(id, &type); 3125 + ok(GetLastError() == ERROR_INVALID_PARAMETER, 3126 + "expected error ERROR_INVALID_PARAMETER, got %u.\n", GetLastError()); 3127 + ok(!ret, "GetPointerType failed, got type %d for %u.\n", type, id ); 3128 + ok(type == -1, " type %d\n", type ); 3129 + 3130 + id = 1; 3131 + ret = pGetPointerType(id, &type); 3132 + ok(ret, "GetPointerType failed, got type %d for %u.\n", type, id ); 3133 + ok(type == PT_MOUSE, " type %d\n", type ); 3134 + } 3135 + 3136 + static void test_GetKeyboardLayoutList(void) 3137 + { 3138 + int cnt, cnt2; 3139 + HKL *layouts; 3140 + ULONG_PTR baselayout; 3141 + LANGID langid; 3142 + 3143 + baselayout = GetUserDefaultLCID(); 3144 + langid = PRIMARYLANGID(LANGIDFROMLCID(baselayout)); 3145 + if (langid == LANG_CHINESE || langid == LANG_JAPANESE || langid == LANG_KOREAN) 3146 + baselayout = MAKELONG( baselayout, 0xe001 ); /* IME */ 3147 + else 3148 + baselayout |= baselayout << 16; 3149 + 3150 + cnt = GetKeyboardLayoutList(0, NULL); 3151 + /* Most users will not have more than a few keyboard layouts installed at a time. */ 3152 + ok(cnt > 0 && cnt < 10, "Layout count %d\n", cnt); 3153 + if (cnt > 0) 2893 3154 { 2894 - test_Input_blackbox(); 2895 - test_Input_whitebox(); 2896 - test_Input_unicode(); 2897 - test_Input_mouse(); 3155 + layouts = HeapAlloc(GetProcessHeap(), 0, sizeof(*layouts) * cnt ); 3156 + 3157 + cnt2 = GetKeyboardLayoutList(cnt, layouts); 3158 + ok(cnt == cnt2, "wrong value %d!=%d\n", cnt, cnt2); 3159 + for(cnt = 0; cnt < cnt2; cnt++) 3160 + { 3161 + if(layouts[cnt] == (HKL)baselayout) 3162 + break; 3163 + } 3164 + ok(cnt < cnt2, "Didnt find current keyboard\n"); 3165 + 3166 + HeapFree(GetProcessHeap(), 0, layouts); 2898 3167 } 2899 - else win_skip("SendInput is not available\n"); 3168 + } 3169 + 3170 + START_TEST(input) 3171 + { 3172 + POINT pos; 2900 3173 3174 + init_function_pointers(); 3175 + GetCursorPos( &pos ); 3176 + 3177 + test_Input_blackbox(); 3178 + test_Input_whitebox(); 3179 + test_Input_unicode(); 3180 + test_Input_mouse(); 2901 3181 test_keynames(); 2902 3182 test_mouse_ll_hook(); 2903 3183 test_key_map(); ··· 2909 3189 test_attach_input(); 2910 3190 test_GetKeyState(); 2911 3191 test_OemKeyScan(); 3192 + test_GetRawInputData(); 3193 + test_GetKeyboardLayoutList(); 2912 3194 2913 3195 if(pGetMouseMovePointsEx) 2914 3196 test_GetMouseMovePointsEx(); ··· 2919 3201 test_GetRawInputDeviceList(); 2920 3202 else 2921 3203 win_skip("GetRawInputDeviceList is not available\n"); 3204 + 3205 + if (pGetCurrentInputMessageSource) 3206 + test_input_message_source(); 3207 + else 3208 + win_skip("GetCurrentInputMessageSource is not available\n"); 3209 + 3210 + SetCursorPos( pos.x, pos.y ); 3211 + 3212 + if(pGetPointerType) 3213 + test_GetPointerType(); 3214 + else 3215 + win_skip("GetPointerType is not available\n"); 2922 3216 }
+557 -61
modules/rostests/winetests/user32/listbox.c
··· 51 51 WCHAR buf[1024]; 52 52 53 53 if (!stra) return 1; 54 - MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, sizeof(buf)/sizeof(WCHAR)); 54 + MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, ARRAY_SIZE(buf)); 55 55 return lstrcmpW(strw, buf); 56 56 } 57 57 ··· 90 90 }; 91 91 92 92 struct listbox_test { 93 - struct listbox_prop prop; 94 93 struct listbox_stat init, init_todo; 95 94 struct listbox_stat click, click_todo; 96 95 struct listbox_stat step, step_todo; ··· 130 129 131 130 #define listbox_field_ok(t, s, f, got) \ 132 131 ok (t.s.f==got.f, "style %#x, step " #s ", field " #f \ 133 - ": expected %d, got %d\n", (unsigned int)t.prop.add_style, \ 134 - t.s.f, got.f) 132 + ": expected %d, got %d\n", style, t.s.f, got.f) 135 133 136 134 #define listbox_todo_field_ok(t, s, f, got) \ 137 135 todo_wine_if (t.s##_todo.f) { listbox_field_ok(t, s, f, got); } ··· 143 141 listbox_todo_field_ok(t, s, selcount, got) 144 142 145 143 static void 146 - check (const struct listbox_test test) 144 + check (DWORD style, const struct listbox_test test) 147 145 { 148 146 struct listbox_stat answer; 149 - HWND hLB=create_listbox (test.prop.add_style, 0); 150 147 RECT second_item; 151 148 int i; 152 149 int res; 150 + HWND hLB; 151 + 152 + hLB = create_listbox (style, 0); 153 153 154 154 listbox_query (hLB, &answer); 155 155 listbox_ok (test, init, answer); ··· 166 166 listbox_ok (test, step, answer); 167 167 168 168 DestroyWindow (hLB); 169 - hLB=create_listbox (test.prop.add_style, 0); 169 + hLB = create_listbox(style, 0); 170 170 171 171 SendMessageA(hLB, LB_SELITEMRANGE, TRUE, MAKELPARAM(1, 2)); 172 172 listbox_query (hLB, &answer); 173 173 listbox_ok (test, sel, answer); 174 174 175 - for (i=0;i<4;i++) { 175 + for (i = 0; i < 4 && !(style & LBS_NODATA); i++) { 176 176 DWORD size = SendMessageA(hLB, LB_GETTEXTLEN, i, 0); 177 177 CHAR *txt; 178 178 WCHAR *txtw; ··· 184 184 185 185 txtw = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, 2*size+2); 186 186 resW=SendMessageW(hLB, LB_GETTEXT, i, (LPARAM)txtw); 187 - if (resA != resW) { 188 - trace("SendMessageW(LB_GETTEXT) not supported on this platform (resA=%d resW=%d), skipping...\n", 189 - resA, resW); 190 - } else { 191 - WideCharToMultiByte( CP_ACP, 0, txtw, -1, txt, size, NULL, NULL ); 192 - ok(!strcmp (txt, strings[i]), "returned string for item %d does not match %s vs %s\n", i, txt, strings[i]); 193 - } 187 + ok(resA == resW, "Unexpected text length.\n"); 188 + WideCharToMultiByte( CP_ACP, 0, txtw, -1, txt, size, NULL, NULL ); 189 + ok(!strcmp (txt, strings[i]), "returned string for item %d does not match %s vs %s\n", i, txt, strings[i]); 194 190 195 191 HeapFree (GetProcessHeap(), 0, txtw); 196 192 HeapFree (GetProcessHeap(), 0, txt); ··· 342 338 343 339 static void test_ownerdraw(void) 344 340 { 341 + static const DWORD styles[] = 342 + { 343 + 0, 344 + LBS_NODATA 345 + }; 345 346 HWND parent, hLB; 346 347 INT ret; 347 348 RECT rc; 349 + UINT i; 348 350 349 351 parent = create_parent(); 350 352 assert(parent); 351 353 352 - hLB = create_listbox(LBS_OWNERDRAWFIXED | WS_CHILD | WS_VISIBLE, parent); 353 - assert(hLB); 354 + for (i = 0; i < ARRAY_SIZE(styles); i++) 355 + { 356 + hLB = create_listbox(LBS_OWNERDRAWFIXED | WS_CHILD | WS_VISIBLE | styles[i], parent); 357 + assert(hLB); 354 358 355 - SetForegroundWindow(hLB); 356 - UpdateWindow(hLB); 359 + SetForegroundWindow(hLB); 360 + UpdateWindow(hLB); 361 + 362 + /* make height short enough */ 363 + SendMessageA(hLB, LB_GETITEMRECT, 0, (LPARAM)&rc); 364 + SetWindowPos(hLB, 0, 0, 0, 100, rc.bottom - rc.top + 1, 365 + SWP_NOZORDER | SWP_NOMOVE); 366 + 367 + /* make 0 item invisible */ 368 + SendMessageA(hLB, LB_SETTOPINDEX, 1, 0); 369 + ret = SendMessageA(hLB, LB_GETTOPINDEX, 0, 0); 370 + ok(ret == 1, "wrong top index %d\n", ret); 371 + 372 + SendMessageA(hLB, LB_GETITEMRECT, 0, (LPARAM)&rc); 373 + trace("item 0 rect %s\n", wine_dbgstr_rect(&rc)); 374 + ok(!IsRectEmpty(&rc), "empty item rect\n"); 375 + ok(rc.top < 0, "rc.top is not negative (%d)\n", rc.top); 376 + 377 + DestroyWindow(hLB); 378 + 379 + /* Both FIXED and VARIABLE, FIXED should override VARIABLE. */ 380 + hLB = CreateWindowA("listbox", "TestList", LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE | styles[i], 381 + 0, 0, 100, 100, NULL, NULL, NULL, 0); 382 + ok(hLB != NULL, "last error 0x%08x\n", GetLastError()); 383 + 384 + ok(GetWindowLongA(hLB, GWL_STYLE) & LBS_OWNERDRAWVARIABLE, "Unexpected window style.\n"); 385 + 386 + ret = SendMessageA(hLB, LB_INSERTSTRING, -1, 0); 387 + ok(ret == 0, "Unexpected return value %d.\n", ret); 388 + ret = SendMessageA(hLB, LB_INSERTSTRING, -1, 0); 389 + ok(ret == 1, "Unexpected return value %d.\n", ret); 390 + 391 + ret = SendMessageA(hLB, LB_SETITEMHEIGHT, 0, 13); 392 + ok(ret == LB_OKAY, "Failed to set item height, %d.\n", ret); 393 + 394 + ret = SendMessageA(hLB, LB_GETITEMHEIGHT, 0, 0); 395 + ok(ret == 13, "Unexpected item height %d.\n", ret); 357 396 358 - /* make height short enough */ 359 - SendMessageA(hLB, LB_GETITEMRECT, 0, (LPARAM)&rc); 360 - SetWindowPos(hLB, 0, 0, 0, 100, rc.bottom - rc.top + 1, 361 - SWP_NOZORDER | SWP_NOMOVE); 397 + ret = SendMessageA(hLB, LB_SETITEMHEIGHT, 1, 42); 398 + ok(ret == LB_OKAY, "Failed to set item height, %d.\n", ret); 362 399 363 - /* make 0 item invisible */ 364 - SendMessageA(hLB, LB_SETTOPINDEX, 1, 0); 365 - ret = SendMessageA(hLB, LB_GETTOPINDEX, 0, 0); 366 - ok(ret == 1, "wrong top index %d\n", ret); 400 + ret = SendMessageA(hLB, LB_GETITEMHEIGHT, 0, 0); 401 + ok(ret == 42, "Unexpected item height %d.\n", ret); 367 402 368 - SendMessageA(hLB, LB_GETITEMRECT, 0, (LPARAM)&rc); 369 - trace("item 0 rect %s\n", wine_dbgstr_rect(&rc)); 370 - ok(!IsRectEmpty(&rc), "empty item rect\n"); 371 - ok(rc.top < 0, "rc.top is not negative (%d)\n", rc.top); 403 + ret = SendMessageA(hLB, LB_GETITEMHEIGHT, 1, 0); 404 + ok(ret == 42, "Unexpected item height %d.\n", ret); 372 405 373 - DestroyWindow(hLB); 406 + DestroyWindow (hLB); 407 + } 374 408 DestroyWindow(parent); 375 409 } 376 410 ··· 475 509 476 510 SendMessageA(hLB, LB_SETITEMHEIGHT, 0, 32); 477 511 512 + ret = SendMessageA(hLB, LB_GETANCHORINDEX, 0, 0); 513 + ok(ret == -1, "Unexpected anchor index %d.\n", ret); 514 + 478 515 ret = SendMessageA(hLB, LB_SETCURSEL, 2, 0); 479 516 ok(ret == 2, "LB_SETCURSEL returned %d instead of 2\n", ret); 480 517 ret = GetScrollPos(hLB, SB_VERT); 481 518 ok(ret == 0, "expected vscroll 0, got %d\n", ret); 482 519 520 + ret = SendMessageA(hLB, LB_GETANCHORINDEX, 0, 0); 521 + ok(ret == -1, "Unexpected anchor index %d.\n", ret); 522 + 483 523 ret = SendMessageA(hLB, LB_SETCURSEL, 3, 0); 484 524 ok(ret == 3, "LB_SETCURSEL returned %d instead of 3\n", ret); 485 525 ret = GetScrollPos(hLB, SB_VERT); 486 526 ok(ret == 1, "expected vscroll 1, got %d\n", ret); 487 527 528 + ret = SendMessageA(hLB, LB_GETANCHORINDEX, 0, 0); 529 + ok(ret == -1, "Unexpected anchor index %d.\n", ret); 530 + 531 + DestroyWindow(hLB); 532 + 533 + hLB = create_listbox(0, 0); 534 + ok(hLB != NULL, "Failed to create ListBox window.\n"); 535 + 536 + ret = SendMessageA(hLB, LB_SETCURSEL, 1, 0); 537 + ok(ret == 1, "Unexpected return value %d.\n", ret); 538 + 539 + ret = SendMessageA(hLB, LB_GETANCHORINDEX, 0, 0); 540 + ok(ret == -1, "Unexpected anchor index %d.\n", ret); 541 + 542 + DestroyWindow(hLB); 543 + 544 + /* LBS_EXTENDEDSEL */ 545 + hLB = create_listbox(LBS_EXTENDEDSEL, 0); 546 + ok(hLB != NULL, "Failed to create ListBox window.\n"); 547 + 548 + ret = SendMessageA(hLB, LB_GETANCHORINDEX, 0, 0); 549 + ok(ret == -1, "Unexpected anchor index %d.\n", ret); 550 + 551 + ret = SendMessageA(hLB, LB_SETCURSEL, 2, 0); 552 + ok(ret == -1, "Unexpected return value %d.\n", ret); 553 + 554 + ret = SendMessageA(hLB, LB_GETANCHORINDEX, 0, 0); 555 + ok(ret == -1, "Unexpected anchor index %d.\n", ret); 556 + 557 + DestroyWindow(hLB); 558 + 559 + /* LBS_MULTIPLESEL */ 560 + hLB = create_listbox(LBS_MULTIPLESEL, 0); 561 + ok(hLB != NULL, "Failed to create ListBox window.\n"); 562 + 563 + ret = SendMessageA(hLB, LB_GETANCHORINDEX, 0, 0); 564 + ok(ret == -1, "Unexpected anchor index %d.\n", ret); 565 + 566 + ret = SendMessageA(hLB, LB_SETCURSEL, 2, 0); 567 + ok(ret == -1, "Unexpected return value %d.\n", ret); 568 + 569 + ret = SendMessageA(hLB, LB_GETANCHORINDEX, 0, 0); 570 + ok(ret == -1, "Unexpected anchor index %d.\n", ret); 571 + 488 572 DestroyWindow(hLB); 489 573 } 490 574 575 + static void test_LB_SETSEL(void) 576 + { 577 + HWND list; 578 + int ret; 579 + 580 + /* LBS_EXTENDEDSEL */ 581 + list = create_listbox(LBS_EXTENDEDSEL, 0); 582 + ok(list != NULL, "Failed to create ListBox window.\n"); 583 + 584 + ret = SendMessageA(list, LB_GETANCHORINDEX, 0, 0); 585 + ok(ret == -1, "Unexpected anchor index %d.\n", ret); 586 + 587 + ret = SendMessageA(list, LB_SETSEL, TRUE, 0); 588 + ok(ret == 0, "Unexpected return value %d.\n", ret); 589 + ret = SendMessageA(list, LB_GETANCHORINDEX, 0, 0); 590 + ok(ret == 0, "Unexpected anchor index %d.\n", ret); 591 + 592 + ret = SendMessageA(list, LB_SETSEL, TRUE, 1); 593 + ok(ret == 0, "Unexpected return value %d.\n", ret); 594 + ret = SendMessageA(list, LB_GETANCHORINDEX, 0, 0); 595 + ok(ret == 1, "Unexpected anchor index %d.\n", ret); 596 + 597 + ret = SendMessageA(list, LB_SETSEL, FALSE, 1); 598 + ok(ret == 0, "Unexpected return value %d.\n", ret); 599 + ret = SendMessageA(list, LB_GETANCHORINDEX, 0, 0); 600 + ok(ret == 1, "Unexpected anchor index %d.\n", ret); 601 + 602 + DestroyWindow(list); 603 + 604 + /* LBS_MULTIPLESEL */ 605 + list = create_listbox(LBS_MULTIPLESEL, 0); 606 + ok(list != NULL, "Failed to create ListBox window.\n"); 607 + 608 + ret = SendMessageA(list, LB_GETANCHORINDEX, 0, 0); 609 + ok(ret == -1, "Unexpected anchor index %d.\n", ret); 610 + 611 + ret = SendMessageA(list, LB_SETSEL, TRUE, 0); 612 + ok(ret == 0, "Unexpected return value %d.\n", ret); 613 + ret = SendMessageA(list, LB_GETANCHORINDEX, 0, 0); 614 + ok(ret == 0, "Unexpected anchor index %d.\n", ret); 615 + 616 + ret = SendMessageA(list, LB_SETSEL, TRUE, 1); 617 + ok(ret == 0, "Unexpected return value %d.\n", ret); 618 + ret = SendMessageA(list, LB_GETANCHORINDEX, 0, 0); 619 + ok(ret == 1, "Unexpected anchor index %d.\n", ret); 620 + 621 + ret = SendMessageA(list, LB_SETSEL, FALSE, 1); 622 + ok(ret == 0, "Unexpected return value %d.\n", ret); 623 + ret = SendMessageA(list, LB_GETANCHORINDEX, 0, 0); 624 + ok(ret == 1, "Unexpected anchor index %d.\n", ret); 625 + 626 + DestroyWindow(list); 627 + } 628 + 491 629 static void test_listbox_height(void) 492 630 { 493 631 HWND hList; ··· 527 665 DestroyWindow( hList ); 528 666 } 529 667 668 + static void test_changing_selection_styles(void) 669 + { 670 + static const DWORD styles[] = 671 + { 672 + 0, 673 + LBS_NODATA | LBS_OWNERDRAWFIXED 674 + }; 675 + static const DWORD selstyles[] = 676 + { 677 + 0, 678 + LBS_MULTIPLESEL, 679 + LBS_EXTENDEDSEL, 680 + LBS_MULTIPLESEL | LBS_EXTENDEDSEL 681 + }; 682 + static const LONG selexpect_single[] = { 0, 0, 1 }; 683 + static const LONG selexpect_single2[] = { 1, 0, 0 }; 684 + static const LONG selexpect_multi[] = { 1, 0, 1 }; 685 + static const LONG selexpect_multi2[] = { 1, 1, 0 }; 686 + 687 + HWND parent, listbox; 688 + DWORD style; 689 + LONG ret; 690 + UINT i, j, k; 691 + 692 + parent = create_parent(); 693 + ok(parent != NULL, "Failed to create parent window.\n"); 694 + for (i = 0; i < ARRAY_SIZE(styles); i++) 695 + { 696 + /* Test if changing selection styles affects selection storage */ 697 + for (j = 0; j < ARRAY_SIZE(selstyles); j++) 698 + { 699 + LONG setcursel_expect, selitemrange_expect, getselcount_expect; 700 + const LONG *selexpect; 701 + 702 + listbox = CreateWindowA("listbox", "TestList", styles[i] | selstyles[j] | WS_CHILD | WS_VISIBLE, 703 + 0, 0, 100, 100, parent, (HMENU)1, NULL, 0); 704 + ok(listbox != NULL, "%u: Failed to create ListBox window.\n", j); 705 + 706 + if (selstyles[j] & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) 707 + { 708 + setcursel_expect = LB_ERR; 709 + selitemrange_expect = LB_OKAY; 710 + getselcount_expect = 2; 711 + selexpect = selexpect_multi; 712 + } 713 + else 714 + { 715 + setcursel_expect = 2; 716 + selitemrange_expect = LB_ERR; 717 + getselcount_expect = LB_ERR; 718 + selexpect = selexpect_single; 719 + } 720 + 721 + for (k = 0; k < ARRAY_SIZE(selexpect_multi); k++) 722 + { 723 + ret = SendMessageA(listbox, LB_INSERTSTRING, -1, (LPARAM)"x"); 724 + ok(ret == k, "%u: Unexpected return value %d, expected %d.\n", j, ret, k); 725 + } 726 + ret = SendMessageA(listbox, LB_GETCOUNT, 0, 0); 727 + ok(ret == ARRAY_SIZE(selexpect_multi), "%u: Unexpected count %d.\n", j, ret); 728 + 729 + /* Select items with different methods */ 730 + ret = SendMessageA(listbox, LB_SETCURSEL, 2, 0); 731 + ok(ret == setcursel_expect, "%u: Unexpected return value %d.\n", j, ret); 732 + ret = SendMessageA(listbox, LB_SELITEMRANGE, TRUE, MAKELPARAM(0, 0)); 733 + ok(ret == selitemrange_expect, "%u: Unexpected return value %d.\n", j, ret); 734 + ret = SendMessageA(listbox, LB_SELITEMRANGE, TRUE, MAKELPARAM(2, 2)); 735 + ok(ret == selitemrange_expect, "%u: Unexpected return value %d.\n", j, ret); 736 + 737 + /* Verify that the proper items are selected */ 738 + for (k = 0; k < ARRAY_SIZE(selexpect_multi); k++) 739 + { 740 + ret = SendMessageA(listbox, LB_GETSEL, k, 0); 741 + ok(ret == selexpect[k], "%u: Unexpected selection state %d, expected %d.\n", 742 + j, ret, selexpect[k]); 743 + } 744 + 745 + /* Now change the selection style */ 746 + style = GetWindowLongA(listbox, GWL_STYLE); 747 + ok((style & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) == selstyles[j], 748 + "%u: unexpected window styles %#x.\n", j, style); 749 + if (selstyles[j] & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) 750 + style &= ~selstyles[j]; 751 + else 752 + style |= LBS_MULTIPLESEL | LBS_EXTENDEDSEL; 753 + SetWindowLongA(listbox, GWL_STYLE, style); 754 + style = GetWindowLongA(listbox, GWL_STYLE); 755 + ok(!(style & selstyles[j]), "%u: unexpected window styles %#x.\n", j, style); 756 + 757 + /* Verify that the same items are selected */ 758 + ret = SendMessageA(listbox, LB_GETSELCOUNT, 0, 0); 759 + ok(ret == getselcount_expect, "%u: expected %d from LB_GETSELCOUNT, got %d\n", 760 + j, getselcount_expect, ret); 761 + 762 + for (k = 0; k < ARRAY_SIZE(selexpect_multi); k++) 763 + { 764 + ret = SendMessageA(listbox, LB_GETSEL, k, 0); 765 + ok(ret == selexpect[k], "%u: Unexpected selection state %d, expected %d.\n", 766 + j, ret, selexpect[k]); 767 + } 768 + 769 + /* Lastly see if we can still change the selection as before with old style */ 770 + if (setcursel_expect != LB_ERR) setcursel_expect = 0; 771 + ret = SendMessageA(listbox, LB_SETCURSEL, 0, 0); 772 + ok(ret == setcursel_expect, "%u: Unexpected return value %d.\n", j, ret); 773 + ret = SendMessageA(listbox, LB_SELITEMRANGE, TRUE, MAKELPARAM(1, 1)); 774 + ok(ret == selitemrange_expect, "%u: Unexpected return value %d.\n", j, ret); 775 + ret = SendMessageA(listbox, LB_SELITEMRANGE, FALSE, MAKELPARAM(2, 2)); 776 + ok(ret == selitemrange_expect, "%u: Unexpected return value %d.\n", j, ret); 777 + 778 + /* And verify the selections */ 779 + selexpect = (selstyles[j] & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) ? selexpect_multi2 : selexpect_single2; 780 + ret = SendMessageA(listbox, LB_GETSELCOUNT, 0, 0); 781 + ok(ret == getselcount_expect, "%u: expected %d from LB_GETSELCOUNT, got %d\n", 782 + j, getselcount_expect, ret); 783 + 784 + for (k = 0; k < ARRAY_SIZE(selexpect_multi); k++) 785 + { 786 + ret = SendMessageA(listbox, LB_GETSEL, k, 0); 787 + ok(ret == selexpect[k], "%u: Unexpected selection state %d, expected %d.\n", 788 + j, ret, selexpect[k]); 789 + } 790 + 791 + DestroyWindow(listbox); 792 + } 793 + } 794 + DestroyWindow(parent); 795 + } 796 + 530 797 static void test_itemfrompoint(void) 531 798 { 532 799 /* WS_POPUP is required in order to have a more accurate size calculation ( ··· 637 904 638 905 static void test_listbox_LB_DIR(void) 639 906 { 907 + char path[MAX_PATH], curdir[MAX_PATH]; 640 908 HWND hList; 641 909 int res, itemCount; 642 910 int itemCount_justFiles; ··· 649 917 char driveletter; 650 918 const char *wildcard = "*"; 651 919 HANDLE file; 920 + BOOL ret; 921 + 922 + GetCurrentDirectoryA(ARRAY_SIZE(curdir), curdir); 923 + 924 + GetTempPathA(ARRAY_SIZE(path), path); 925 + ret = SetCurrentDirectoryA(path); 926 + ok(ret, "Failed to set current directory.\n"); 927 + 928 + ret = CreateDirectoryA("lb_dir_test", NULL); 929 + ok(ret, "Failed to create test directory.\n"); 652 930 653 931 file = CreateFileA( "wtest1.tmp.c", GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL ); 654 932 ok(file != INVALID_HANDLE_VALUE, "Error creating the test file: %d\n", GetLastError()); ··· 980 1258 itemCount, itemCount_allDirs); 981 1259 ok(res + 1 == itemCount, "SendMessage(LB_DIR, DDL_DIRECTORY|DDL_EXCLUSIVE, *) returned incorrect index!\n"); 982 1260 983 - if (itemCount && GetCurrentDirectoryA( MAX_PATH, pathBuffer ) > 3) /* there's no [..] in drive root */ 1261 + if (itemCount) 984 1262 { 985 1263 memset(pathBuffer, 0, MAX_PATH); 986 1264 SendMessageA(hList, LB_GETTEXT, 0, (LPARAM)pathBuffer); 987 - ok( !strcmp(pathBuffer, "[..]"), "First element is not [..]\n"); 1265 + ok( !strcmp(pathBuffer, "[..]"), "First element is %s, not [..]\n", pathBuffer); 988 1266 } 989 1267 990 1268 /* This tests behavior when no files match the wildcard */ ··· 1068 1346 DestroyWindow(hList); 1069 1347 1070 1348 DeleteFileA( "wtest1.tmp.c" ); 1349 + RemoveDirectoryA("lb_dir_test"); 1350 + 1351 + SetCurrentDirectoryA(curdir); 1071 1352 } 1072 1353 1073 1354 static HWND g_listBox; ··· 1555 1836 strcpy(pathBuffer, "C:\\"); 1556 1837 res = DlgDirListA(hWnd, pathBuffer, ID_TEST_LISTBOX, 0, DDL_DIRECTORY | DDL_EXCLUSIVE); 1557 1838 ok(res || broken(!res) /* NT4/W2K */, "DlgDirList failed to list C:\\ folders\n"); 1558 - todo_wine ok(!strcmp(pathBuffer, "*") || broken(!res) /* NT4/W2K */, 1839 + ok(!strcmp(pathBuffer, "*") || broken(!res) /* NT4/W2K */, 1559 1840 "DlgDirList set the invalid path spec '%s', expected '*'\n", pathBuffer); 1560 1841 1561 1842 strcpy(pathBuffer, "C:\\*"); ··· 1568 1849 SetLastError(0xdeadbeef); 1569 1850 strcpy(pathBuffer, "C:\\INVALID$$DIR"); 1570 1851 res = DlgDirListA(hWnd, pathBuffer, ID_TEST_LISTBOX, 0, DDL_DIRECTORY | DDL_EXCLUSIVE); 1571 - todo_wine ok(!res, "DlgDirList should have failed with 0 but %d was returned\n", res); 1572 - todo_wine ok(GetLastError() == ERROR_NO_WILDCARD_CHARACTERS, 1852 + ok(!res, "DlgDirList should have failed with 0 but %d was returned\n", res); 1853 + ok(GetLastError() == ERROR_NO_WILDCARD_CHARACTERS, 1573 1854 "GetLastError should return 0x589, got 0x%X\n",GetLastError()); 1574 1855 1575 1856 DestroyWindow(hWnd); ··· 1577 1858 1578 1859 static void test_set_count( void ) 1579 1860 { 1861 + static const DWORD styles[] = 1862 + { 1863 + LBS_OWNERDRAWFIXED, 1864 + LBS_HASSTRINGS, 1865 + }; 1580 1866 HWND parent, listbox; 1867 + unsigned int i; 1581 1868 LONG ret; 1582 1869 RECT r; 1583 1870 ··· 1606 1893 GetUpdateRect( listbox, &r, TRUE ); 1607 1894 ok( !IsRectEmpty( &r ), "got empty rect\n"); 1608 1895 1896 + ret = SendMessageA( listbox, LB_SETCOUNT, -5, 0 ); 1897 + ok( ret == 0, "got %d\n", ret ); 1898 + ret = SendMessageA( listbox, LB_GETCOUNT, 0, 0 ); 1899 + ok( ret == -5, "got %d\n", ret ); 1900 + 1609 1901 DestroyWindow( listbox ); 1902 + 1903 + for (i = 0; i < ARRAY_SIZE(styles); ++i) 1904 + { 1905 + listbox = create_listbox( styles[i] | WS_CHILD | WS_VISIBLE, parent ); 1906 + 1907 + SetLastError( 0xdeadbeef ); 1908 + ret = SendMessageA( listbox, LB_SETCOUNT, 100, 0 ); 1909 + ok( ret == LB_ERR, "expected %d, got %d\n", LB_ERR, ret ); 1910 + ok( GetLastError() == ERROR_SETCOUNT_ON_BAD_LB, "Unexpected error %d.\n", GetLastError() ); 1911 + 1912 + DestroyWindow( listbox ); 1913 + } 1914 + 1610 1915 DestroyWindow( parent ); 1611 1916 } 1612 1917 ··· 1653 1958 DestroyWindow(parent); 1654 1959 } 1655 1960 1961 + static void test_init_storage( void ) 1962 + { 1963 + static const DWORD styles[] = 1964 + { 1965 + LBS_HASSTRINGS, 1966 + LBS_NODATA | LBS_OWNERDRAWFIXED, 1967 + }; 1968 + HWND parent, listbox; 1969 + LONG ret, items_size; 1970 + int i, j; 1971 + 1972 + parent = create_parent(); 1973 + for (i = 0; i < ARRAY_SIZE(styles); i++) 1974 + { 1975 + listbox = CreateWindowA("listbox", "TestList", styles[i] | WS_CHILD, 1976 + 0, 0, 100, 100, parent, (HMENU)1, NULL, 0); 1977 + 1978 + items_size = SendMessageA(listbox, LB_INITSTORAGE, 100, 0); 1979 + ok(items_size >= 100, "expected at least 100, got %d\n", items_size); 1980 + 1981 + ret = SendMessageA(listbox, LB_INITSTORAGE, 0, 0); 1982 + ok(ret == items_size, "expected %d, got %d\n", items_size, ret); 1983 + 1984 + /* it doesn't grow since the space was already reserved */ 1985 + ret = SendMessageA(listbox, LB_INITSTORAGE, items_size, 0); 1986 + ok(ret == items_size, "expected %d, got %d\n", items_size, ret); 1987 + 1988 + /* it doesn't shrink the reserved space */ 1989 + ret = SendMessageA(listbox, LB_INITSTORAGE, 42, 0); 1990 + ok(ret == items_size, "expected %d, got %d\n", items_size, ret); 1991 + 1992 + /* now populate almost all of it so it's not reserved anymore */ 1993 + if (styles[i] & LBS_NODATA) 1994 + { 1995 + ret = SendMessageA(listbox, LB_SETCOUNT, items_size - 1, 0); 1996 + ok(ret == 0, "unexpected return value %d\n", ret); 1997 + } 1998 + else 1999 + { 2000 + for (j = 0; j < items_size - 1; j++) 2001 + { 2002 + ret = SendMessageA(listbox, LB_INSERTSTRING, -1, (LPARAM)""); 2003 + ok(ret == j, "expected %d, got %d\n", j, ret); 2004 + } 2005 + } 2006 + 2007 + /* we still have one more reserved slot, so it doesn't grow yet */ 2008 + ret = SendMessageA(listbox, LB_INITSTORAGE, 1, 0); 2009 + ok(ret == items_size, "expected %d, got %d\n", items_size, ret); 2010 + 2011 + /* fill the slot and check again, it should grow this time */ 2012 + ret = SendMessageA(listbox, LB_INSERTSTRING, -1, (LPARAM)""); 2013 + ok(ret == items_size - 1, "expected %d, got %d\n", items_size - 1, ret); 2014 + ret = SendMessageA(listbox, LB_INITSTORAGE, 0, 0); 2015 + ok(ret == items_size, "expected %d, got %d\n", items_size, ret); 2016 + ret = SendMessageA(listbox, LB_INITSTORAGE, 1, 0); 2017 + ok(ret > items_size, "expected it to grow past %d, got %d\n", items_size, ret); 2018 + 2019 + DestroyWindow(listbox); 2020 + } 2021 + DestroyWindow(parent); 2022 + } 2023 + 1656 2024 static void test_missing_lbuttonup( void ) 1657 2025 { 1658 2026 HWND listbox, parent, capture; ··· 1876 2244 DestroyWindow(parent); 1877 2245 } 1878 2246 2247 + static void test_LBS_NODATA(void) 2248 + { 2249 + static const DWORD invalid_styles[] = 2250 + { 2251 + 0, 2252 + LBS_OWNERDRAWVARIABLE, 2253 + LBS_SORT, 2254 + LBS_HASSTRINGS, 2255 + LBS_OWNERDRAWFIXED | LBS_SORT, 2256 + LBS_OWNERDRAWFIXED | LBS_HASSTRINGS, 2257 + }; 2258 + static const UINT invalid_idx[] = { -2, 2 }; 2259 + static const UINT valid_idx[] = { 0, 1 }; 2260 + static const ULONG_PTR zero_data; 2261 + HWND listbox, parent; 2262 + unsigned int i; 2263 + ULONG_PTR data; 2264 + INT ret; 2265 + 2266 + listbox = CreateWindowA("listbox", "TestList", LBS_NODATA | LBS_OWNERDRAWFIXED | WS_VISIBLE, 2267 + 0, 0, 100, 100, NULL, NULL, NULL, 0); 2268 + ok(listbox != NULL, "Failed to create ListBox window.\n"); 2269 + 2270 + ret = SendMessageA(listbox, LB_INSERTSTRING, -1, 0); 2271 + ok(ret == 0, "Unexpected return value %d.\n", ret); 2272 + ret = SendMessageA(listbox, LB_INSERTSTRING, -1, 0); 2273 + ok(ret == 1, "Unexpected return value %d.\n", ret); 2274 + ret = SendMessageA(listbox, LB_GETCOUNT, 0, 0); 2275 + ok(ret == 2, "Unexpected return value %d.\n", ret); 2276 + 2277 + /* Invalid indices. */ 2278 + for (i = 0; i < ARRAY_SIZE(invalid_idx); ++i) 2279 + { 2280 + ret = SendMessageA(listbox, LB_SETITEMDATA, invalid_idx[i], 42); 2281 + ok(ret == LB_ERR, "Unexpected return value %d.\n", ret); 2282 + ret = SendMessageA(listbox, LB_GETTEXTLEN, invalid_idx[i], 0); 2283 + ok(ret == LB_ERR, "Unexpected return value %d.\n", ret); 2284 + if (ret == LB_ERR) 2285 + { 2286 + ret = SendMessageA(listbox, LB_GETTEXT, invalid_idx[i], (LPARAM)&data); 2287 + ok(ret == LB_ERR, "Unexpected return value %d.\n", ret); 2288 + } 2289 + ret = SendMessageA(listbox, LB_GETITEMDATA, invalid_idx[i], 0); 2290 + ok(ret == LB_ERR, "Unexpected return value %d.\n", ret); 2291 + } 2292 + 2293 + /* Valid indices. */ 2294 + for (i = 0; i < ARRAY_SIZE(valid_idx); ++i) 2295 + { 2296 + ret = SendMessageA(listbox, LB_SETITEMDATA, valid_idx[i], 42); 2297 + ok(ret == TRUE, "Unexpected return value %d.\n", ret); 2298 + ret = SendMessageA(listbox, LB_GETTEXTLEN, valid_idx[i], 0); 2299 + ok(ret == sizeof(data), "Unexpected return value %d.\n", ret); 2300 + 2301 + memset(&data, 0xee, sizeof(data)); 2302 + ret = SendMessageA(listbox, LB_GETTEXT, valid_idx[i], (LPARAM)&data); 2303 + ok(ret == sizeof(data), "Unexpected return value %d.\n", ret); 2304 + ok(!memcmp(&data, &zero_data, sizeof(data)), "Unexpected item data.\n"); 2305 + 2306 + ret = SendMessageA(listbox, LB_GETITEMDATA, valid_idx[i], 0); 2307 + ok(ret == 0, "Unexpected return value %d.\n", ret); 2308 + } 2309 + 2310 + /* More messages that don't work with LBS_NODATA. */ 2311 + SetLastError(0xdeadbeef); 2312 + ret = SendMessageA(listbox, LB_FINDSTRING, 1, 0); 2313 + ok(ret == LB_ERR, "Unexpected return value %d.\n", ret); 2314 + ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should return 0x57, got 0x%X\n", GetLastError()); 2315 + SetLastError(0xdeadbeef); 2316 + ret = SendMessageA(listbox, LB_FINDSTRING, 1, 42); 2317 + ok(ret == LB_ERR, "Unexpected return value %d.\n", ret); 2318 + ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should return 0x57, got 0x%X\n", GetLastError()); 2319 + SetLastError(0xdeadbeef); 2320 + ret = SendMessageA(listbox, LB_FINDSTRINGEXACT, 1, 0); 2321 + ok(ret == LB_ERR, "Unexpected return value %d.\n", ret); 2322 + ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should return 0x57, got 0x%X\n", GetLastError()); 2323 + SetLastError(0xdeadbeef); 2324 + ret = SendMessageA(listbox, LB_FINDSTRINGEXACT, 1, 42); 2325 + ok(ret == LB_ERR, "Unexpected return value %d.\n", ret); 2326 + ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should return 0x57, got 0x%X\n", GetLastError()); 2327 + SetLastError(0xdeadbeef); 2328 + ret = SendMessageA(listbox, LB_SELECTSTRING, 1, 0); 2329 + ok(ret == LB_ERR, "Unexpected return value %d.\n", ret); 2330 + ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should return 0x57, got 0x%X\n", GetLastError()); 2331 + SetLastError(0xdeadbeef); 2332 + ret = SendMessageA(listbox, LB_SELECTSTRING, 1, 42); 2333 + ok(ret == LB_ERR, "Unexpected return value %d.\n", ret); 2334 + ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should return 0x57, got 0x%X\n", GetLastError()); 2335 + 2336 + DestroyWindow(listbox); 2337 + 2338 + /* Invalid window style combinations. */ 2339 + parent = create_parent(); 2340 + ok(parent != NULL, "Failed to create parent window.\n"); 2341 + 2342 + for (i = 0; i < ARRAY_SIZE(invalid_styles); ++i) 2343 + { 2344 + DWORD style; 2345 + 2346 + listbox = CreateWindowA("listbox", "TestList", LBS_NODATA | WS_CHILD | invalid_styles[i], 2347 + 0, 0, 100, 100, parent, (HMENU)1, NULL, 0); 2348 + ok(listbox != NULL, "Failed to create a listbox.\n"); 2349 + 2350 + style = GetWindowLongA(listbox, GWL_STYLE); 2351 + ok((style & invalid_styles[i]) == invalid_styles[i], "%u: unexpected window styles %#x.\n", i, style); 2352 + ret = SendMessageA(listbox, LB_SETCOUNT, 100, 0); 2353 + ok(ret == LB_ERR, "%u: unexpected return value %d.\n", i, ret); 2354 + DestroyWindow(listbox); 2355 + } 2356 + 2357 + DestroyWindow(parent); 2358 + } 2359 + 1879 2360 START_TEST(listbox) 1880 2361 { 1881 2362 const struct listbox_test SS = 1882 2363 /* {add_style} */ 1883 - {{0}, 1884 - {LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}, 2364 + {{LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}, 1885 2365 { 1, 1, 1, LB_ERR}, {0,0,0,0}, 1886 2366 { 2, 2, 2, LB_ERR}, {0,0,0,0}, 1887 2367 {LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}}; 1888 2368 /* {selected, anchor, caret, selcount}{TODO fields} */ 1889 2369 const struct listbox_test SS_NS = 1890 - {{LBS_NOSEL}, 1891 - {LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}, 2370 + {{LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}, 1892 2371 { 1, 1, 1, LB_ERR}, {0,0,0,0}, 1893 2372 { 2, 2, 2, LB_ERR}, {0,0,0,0}, 1894 2373 {LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}}; 1895 2374 const struct listbox_test MS = 1896 - {{LBS_MULTIPLESEL}, 1897 - { 0, LB_ERR, 0, 0}, {0,0,0,0}, 2375 + {{ 0, LB_ERR, 0, 0}, {0,0,0,0}, 1898 2376 { 1, 1, 1, 1}, {0,0,0,0}, 1899 2377 { 2, 1, 2, 1}, {0,0,0,0}, 1900 2378 { 0, LB_ERR, 0, 2}, {0,0,0,0}}; 1901 2379 const struct listbox_test MS_NS = 1902 - {{LBS_MULTIPLESEL | LBS_NOSEL}, 1903 - {LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}, 2380 + {{LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}, 1904 2381 { 1, 1, 1, LB_ERR}, {0,0,0,0}, 1905 2382 { 2, 2, 2, LB_ERR}, {0,0,0,0}, 1906 2383 {LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}}; 1907 2384 const struct listbox_test ES = 1908 - {{LBS_EXTENDEDSEL}, 1909 - { 0, LB_ERR, 0, 0}, {0,0,0,0}, 2385 + {{ 0, LB_ERR, 0, 0}, {0,0,0,0}, 1910 2386 { 1, 1, 1, 1}, {0,0,0,0}, 1911 2387 { 2, 2, 2, 1}, {0,0,0,0}, 1912 2388 { 0, LB_ERR, 0, 2}, {0,0,0,0}}; 1913 2389 const struct listbox_test ES_NS = 1914 - {{LBS_EXTENDEDSEL | LBS_NOSEL}, 1915 - {LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}, 2390 + {{LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}, 1916 2391 { 1, 1, 1, LB_ERR}, {0,0,0,0}, 1917 2392 { 2, 2, 2, LB_ERR}, {0,0,0,0}, 1918 2393 {LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}}; 1919 2394 const struct listbox_test EMS = 1920 - {{LBS_EXTENDEDSEL | LBS_MULTIPLESEL}, 1921 - { 0, LB_ERR, 0, 0}, {0,0,0,0}, 2395 + {{ 0, LB_ERR, 0, 0}, {0,0,0,0}, 1922 2396 { 1, 1, 1, 1}, {0,0,0,0}, 1923 2397 { 2, 2, 2, 1}, {0,0,0,0}, 1924 2398 { 0, LB_ERR, 0, 2}, {0,0,0,0}}; 1925 2399 const struct listbox_test EMS_NS = 1926 - {{LBS_EXTENDEDSEL | LBS_MULTIPLESEL | LBS_NOSEL}, 1927 - {LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}, 2400 + {{LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}, 1928 2401 { 1, 1, 1, LB_ERR}, {0,0,0,0}, 1929 2402 { 2, 2, 2, LB_ERR}, {0,0,0,0}, 1930 2403 {LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}}; 1931 2404 1932 2405 trace (" Testing single selection...\n"); 1933 - check (SS); 2406 + check (0, SS); 1934 2407 trace (" ... with NOSEL\n"); 1935 - check (SS_NS); 2408 + check (LBS_NOSEL, SS_NS); 2409 + trace (" ... LBS_NODATA variant ...\n"); 2410 + check (LBS_NODATA | LBS_OWNERDRAWFIXED, SS); 2411 + trace (" ... with NOSEL\n"); 2412 + check (LBS_NODATA | LBS_OWNERDRAWFIXED | LBS_NOSEL, SS_NS); 2413 + 1936 2414 trace (" Testing multiple selection...\n"); 1937 - check (MS); 2415 + check (LBS_MULTIPLESEL, MS); 2416 + trace (" ... with NOSEL\n"); 2417 + check (LBS_MULTIPLESEL | LBS_NOSEL, MS_NS); 2418 + trace (" ... LBS_NODATA variant ...\n"); 2419 + check (LBS_NODATA | LBS_OWNERDRAWFIXED | LBS_MULTIPLESEL, MS); 1938 2420 trace (" ... with NOSEL\n"); 1939 - check (MS_NS); 2421 + check (LBS_NODATA | LBS_OWNERDRAWFIXED | LBS_MULTIPLESEL | LBS_NOSEL, MS_NS); 2422 + 1940 2423 trace (" Testing extended selection...\n"); 1941 - check (ES); 2424 + check (LBS_EXTENDEDSEL, ES); 1942 2425 trace (" ... with NOSEL\n"); 1943 - check (ES_NS); 2426 + check (LBS_EXTENDEDSEL | LBS_NOSEL, ES_NS); 2427 + trace (" ... LBS_NODATA variant ...\n"); 2428 + check (LBS_NODATA | LBS_OWNERDRAWFIXED | LBS_EXTENDEDSEL, ES); 2429 + trace (" ... with NOSEL\n"); 2430 + check (LBS_NODATA | LBS_OWNERDRAWFIXED | LBS_EXTENDEDSEL | LBS_NOSEL, ES_NS); 2431 + 1944 2432 trace (" Testing extended and multiple selection...\n"); 1945 - check (EMS); 2433 + check (LBS_EXTENDEDSEL | LBS_MULTIPLESEL, EMS); 2434 + trace (" ... with NOSEL\n"); 2435 + check (LBS_EXTENDEDSEL | LBS_MULTIPLESEL | LBS_NOSEL, EMS_NS); 2436 + trace (" ... LBS_NODATA variant ...\n"); 2437 + check (LBS_NODATA | LBS_OWNERDRAWFIXED | LBS_EXTENDEDSEL | LBS_MULTIPLESEL, EMS); 1946 2438 trace (" ... with NOSEL\n"); 1947 - check (EMS_NS); 2439 + check (LBS_NODATA | LBS_OWNERDRAWFIXED | LBS_EXTENDEDSEL | LBS_MULTIPLESEL | LBS_NOSEL, EMS_NS); 1948 2440 1949 2441 check_item_height(); 1950 2442 test_ownerdraw(); 1951 2443 test_LB_SELITEMRANGE(); 1952 2444 test_LB_SETCURSEL(); 1953 2445 test_listbox_height(); 2446 + test_changing_selection_styles(); 1954 2447 test_itemfrompoint(); 1955 2448 test_listbox_item_data(); 1956 2449 test_listbox_LB_DIR(); 1957 2450 test_listbox_dlgdir(); 1958 2451 test_set_count(); 2452 + test_init_storage(); 1959 2453 test_GetListBoxInfo(); 1960 2454 test_missing_lbuttonup(); 1961 2455 test_extents(); 1962 2456 test_WM_MEASUREITEM(); 2457 + test_LB_SETSEL(); 2458 + test_LBS_NODATA(); 1963 2459 }
+200 -251
modules/rostests/winetests/user32/menu.c
··· 39 39 40 40 static ATOM atomMenuCheckClass; 41 41 42 - static BOOL (WINAPI *pGetMenuInfo)(HMENU,LPCMENUINFO); 43 - static BOOL (WINAPI *pGetMenuBarInfo)(HWND,LONG,LONG,PMENUBARINFO); 44 - static UINT (WINAPI *pSendInput)(UINT, INPUT*, size_t); 45 - static BOOL (WINAPI *pSetMenuInfo)(HMENU,LPCMENUINFO); 46 - 47 - static void init_function_pointers(void) 48 - { 49 - HMODULE hdll = GetModuleHandleA("user32"); 50 - 51 - #define GET_PROC(func) \ 52 - p ## func = (void*)GetProcAddress(hdll, #func); \ 53 - if(!p ## func) \ 54 - trace("GetProcAddress(%s) failed\n", #func); 55 - 56 - GET_PROC(GetMenuInfo) 57 - GET_PROC(GetMenuBarInfo) 58 - GET_PROC(SendInput) 59 - GET_PROC(SetMenuInfo) 60 - 61 - #undef GET_PROC 62 - } 63 - 64 - static BOOL correct_behavior(void) 65 - { 66 - HMENU hmenu; 67 - MENUITEMINFOA info; 68 - BOOL rc; 69 - 70 - hmenu = CreateMenu(); 71 - 72 - memset(&info, 0, sizeof(MENUITEMINFOA)); 73 - info.cbSize= sizeof(MENUITEMINFOA); 74 - SetLastError(0xdeadbeef); 75 - rc = GetMenuItemInfoA(hmenu, 0, TRUE, &info); 76 - /* Win9x : 0xdeadbeef 77 - * NT4 : ERROR_INVALID_PARAMETER 78 - * >= W2K : ERROR_MENU_ITEM_NOT_FOUND 79 - */ 80 - if (!rc && GetLastError() != ERROR_MENU_ITEM_NOT_FOUND) 81 - { 82 - win_skip("NT4 and below can't handle a bigger MENUITEMINFO struct\n"); 83 - DestroyMenu(hmenu); 84 - return FALSE; 85 - } 86 - 87 - DestroyMenu(hmenu); 88 - return TRUE; 89 - } 90 - 91 42 static LRESULT WINAPI menu_check_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) 92 43 { 93 44 switch (msg) ··· 284 235 HWND hwnd; 285 236 INT err; 286 237 287 - if (!pGetMenuBarInfo) { 288 - win_skip("GetMenuBarInfo is not available\n"); 289 - return; 290 - } 291 - 292 238 mbi.cbSize = sizeof(MENUBARINFO); 293 239 294 240 hwnd = CreateWindowExA(0, (LPCSTR)MAKEINTATOM(atomMenuCheckClass), NULL, ··· 298 244 299 245 /* no menu: getmenubarinfo should fail */ 300 246 SetLastError(0xdeadbeef); 301 - ret = pGetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi); 247 + ret = GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi); 302 248 err = GetLastError(); 303 249 ok(ret == FALSE, "GetMenuBarInfo should not have been successful\n"); 304 250 ok(err == 0xdeadbeef, "err = %d\n", err); ··· 311 257 ok(ret, "SetMenu failed with error %d\n", GetLastError()); 312 258 313 259 SetLastError(0xdeadbeef); 314 - ret = pGetMenuBarInfo(NULL, OBJID_CLIENT, 0, &mbi); 260 + ret = GetMenuBarInfo(NULL, OBJID_CLIENT, 0, &mbi); 315 261 err = GetLastError(); 316 262 ok(!ret, "GetMenuBarInfo succeeded\n"); 317 263 ok(err == ERROR_INVALID_WINDOW_HANDLE, "err = %d\n", err); 318 264 319 265 SetLastError(0xdeadbeef); 320 - ret = pGetMenuBarInfo(hwnd, OBJID_CLIENT, 0, &mbi); 266 + ret = GetMenuBarInfo(hwnd, OBJID_CLIENT, 0, &mbi); 321 267 err = GetLastError(); 322 268 ok(!ret, "GetMenuBarInfo succeeded\n"); 323 269 ok(err==ERROR_INVALID_MENU_HANDLE || broken(err==0xdeadbeef) /* NT, W2K, XP */, "err = %d\n", err); 324 270 325 271 SetLastError(0xdeadbeef); 326 - ret = pGetMenuBarInfo(hwnd, OBJID_MENU, -1, &mbi); 272 + ret = GetMenuBarInfo(hwnd, OBJID_MENU, -1, &mbi); 327 273 err = GetLastError(); 328 274 ok(ret == FALSE, "GetMenuBarInfo should have failed\n"); 329 275 ok(err == 0xdeadbeef, "err = %d\n", err); 330 276 331 277 mbi.cbSize = 1000; 332 278 SetLastError(0xdeadbeef); 333 - ret = pGetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi); 279 + ret = GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi); 334 280 err = GetLastError(); 335 281 ok(ret == FALSE, "GetMenuBarInfo should have failed\n"); 336 282 ok(err == ERROR_INVALID_PARAMETER, "err = %d\n", err); 337 283 mbi.cbSize = sizeof(MENUBARINFO); 338 284 339 285 SetLastError(0xdeadbeef); 340 - ret = pGetMenuBarInfo(hwnd, 123, 0, &mbi); 286 + ret = GetMenuBarInfo(hwnd, 123, 0, &mbi); 341 287 err = GetLastError(); 342 288 ok(ret == FALSE, "GetMenuBarInfo should have failed\n"); 343 289 ok(err == 0xdeadbeef, "err = %d\n", err); 344 290 345 - ret = pGetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi); 291 + ret = GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi); 346 292 ok(ret, "GetMenuBarInfo failed with error %d\n", GetLastError()); 347 293 348 294 ok(mbi.rcBar.left == 0 && mbi.rcBar.top == 0 && mbi.rcBar.bottom == 0 && mbi.rcBar.right == 0, ··· 361 307 ok(ret, "SetMenu failed with error %d\n", GetLastError()); 362 308 363 309 SetLastError(0xdeadbeef); 364 - ret = pGetMenuBarInfo(hwnd, OBJID_MENU, 200, &mbi); 310 + ret = GetMenuBarInfo(hwnd, OBJID_MENU, 200, &mbi); 365 311 err = GetLastError(); 366 312 ok(ret == FALSE, "GetMenuBarInfo should have failed\n"); 367 313 ok(err == 0xdeadbeef, "err = %d\n", err); 368 314 369 315 /* get info for the whole menu */ 370 - ret = pGetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi); 316 + ret = GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi); 371 317 ok(ret, "GetMenuBarInfo failed with error %d\n", GetLastError()); 372 318 373 319 /* calculate menu rectangle, from window rectangle and the position of the first item */ ··· 384 330 ok(mbi.fFocused == 0, "fFocused: got %d instead of 0\n", mbi.fFocused); 385 331 386 332 /* get info for item nr.2 */ 387 - ret = pGetMenuBarInfo(hwnd, OBJID_MENU, 2, &mbi); 333 + ret = GetMenuBarInfo(hwnd, OBJID_MENU, 2, &mbi); 388 334 ok(ret, "GetMenuBarInfo failed with error %d\n", GetLastError()); 389 335 ret = GetMenuItemRect(hwnd, hmenu, 1, &rci); 390 336 ok(ret, "GetMenuItemRect failed.\n"); ··· 397 343 DestroyWindow(hwnd); 398 344 } 399 345 346 + static void test_GetMenuItemRect(void) 347 + { 348 + HWND hwnd; 349 + HMENU hmenu; 350 + HMENU popup_hmenu; 351 + RECT window_rect; 352 + RECT item_rect; 353 + POINT client_top_left; 354 + INT caption_height; 355 + BOOL ret; 356 + 357 + hwnd = CreateWindowW((LPCWSTR)MAKEINTATOM(atomMenuCheckClass), NULL, WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, NULL, 358 + NULL, NULL, NULL); 359 + ok(hwnd != NULL, "CreateWindow failed with error %d\n", GetLastError()); 360 + hmenu = CreateMenu(); 361 + ok(hmenu != NULL, "CreateMenu failed with error %d\n", GetLastError()); 362 + popup_hmenu = CreatePopupMenu(); 363 + ok(popup_hmenu != NULL, "CreatePopupMenu failed with error %d\n", GetLastError()); 364 + ret = AppendMenuA(popup_hmenu, MF_STRING, 0, "Popup"); 365 + ok(ret, "AppendMenu failed with error %d\n", GetLastError()); 366 + ret = AppendMenuA(hmenu, MF_STRING | MF_POPUP, (UINT_PTR)popup_hmenu, "Menu"); 367 + ok(ret, "AppendMenu failed with error %d\n", GetLastError()); 368 + ret = SetMenu(hwnd, hmenu); 369 + ok(ret, "SetMenu failed with error %d\n", GetLastError()); 370 + 371 + /* Get the menu item rectangle of the displayed sysmenu item */ 372 + ret = GetMenuItemRect(hwnd, hmenu, 0, &item_rect); 373 + ok(ret, "GetMenuItemRect failed with error %d\n", GetLastError()); 374 + GetWindowRect(hwnd, &window_rect); 375 + /* Get the screen coordinate of the left top corner of the client rectangle */ 376 + client_top_left.x = 0; 377 + client_top_left.y = 0; 378 + MapWindowPoints(hwnd, 0, &client_top_left, 1); 379 + caption_height = GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYCAPTION); 380 + 381 + ok(item_rect.left == client_top_left.x, "Expect item_rect.left %d == %d\n", item_rect.left, client_top_left.x); 382 + ok(item_rect.right <= window_rect.right, "Expect item_rect.right %d <= %d\n", item_rect.right, window_rect.right); 383 + /* A gap of 1 pixel is added deliberately in commit 75f9e64, so using equal operator would fail on Wine. 384 + * Check that top and bottom are correct with 1 pixel margin tolerance */ 385 + ok(item_rect.top - (window_rect.top + caption_height) <= 1, "Expect item_rect.top %d - %d <= 1\n", item_rect.top, 386 + window_rect.top + caption_height); 387 + ok(item_rect.bottom - (client_top_left.y - 1) <= 1, "Expect item_rect.bottom %d - %d <= 1\n", item_rect.bottom, 388 + client_top_left.y - 1); 389 + 390 + /* Get the item rectangle of the not yet displayed popup menu item. */ 391 + ret = GetMenuItemRect(hwnd, popup_hmenu, 0, &item_rect); 392 + ok(ret, "GetMenuItemRect failed with error %d\n", GetLastError()); 393 + ok(item_rect.left == client_top_left.x, "Expect item_rect.left %d == %d\n", item_rect.left, client_top_left.x); 394 + ok(item_rect.right == client_top_left.x, "Expect item_rect.right %d == %d\n", item_rect.right, client_top_left.x); 395 + ok(item_rect.top == client_top_left.y, "Expect item_rect.top %d == %d\n", item_rect.top, client_top_left.y); 396 + ok(item_rect.bottom == client_top_left.y, "Expect item_rect.bottom %d == %d\n", item_rect.bottom, 397 + client_top_left.y); 398 + 399 + DestroyWindow(hwnd); 400 + } 401 + 400 402 static void test_system_menu(void) 401 403 { 402 404 WCHAR testW[] = {'t','e','s','t',0}; ··· 636 638 637 639 static void test_subpopup_locked_by_menu(void) 638 640 { 639 - DWORD gle; 640 641 BOOL ret; 641 642 HMENU hmenu, hsubmenu; 642 643 MENUINFO mi = { sizeof( MENUINFO)}; 643 644 MENUITEMINFOA mii = { sizeof( MENUITEMINFOA)}; 644 645 HWND hwnd; 645 646 const int itemid = 0x1234567; 646 - if( !pGetMenuInfo) 647 - { 648 - win_skip("GetMenuInfo is not available\n"); 649 - return; 650 - } 647 + 651 648 /* create window, popupmenu with one subpopup */ 652 649 hwnd = CreateWindowExA(0, (LPCSTR)MAKEINTATOM(atomMenuCheckClass), NULL, 653 650 WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 200, 200, ··· 669 666 ok( ret, "GetMenuItemInfo failed error %d\n", GetLastError()); 670 667 ok( mii.hSubMenu == hsubmenu, "submenu is %p\n", mii.hSubMenu); 671 668 mi.fMask |= MIM_STYLE; 672 - ret = pGetMenuInfo( hsubmenu, &mi); 669 + ret = GetMenuInfo( hsubmenu, &mi); 673 670 ok( ret , "GetMenuInfo returned 0 with error %d\n", GetLastError()); 674 671 ret = IsMenu( hsubmenu); 675 672 ok( ret , "Menu handle is not valid\n"); 676 - SetLastError( 0xdeadbeef); 673 + 677 674 ret = TrackPopupMenu( hmenu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL); 678 - if( ret == (itemid & 0xffff)) { 679 - win_skip("not on 16 bit menu subsystem\n"); 680 - DestroyMenu( hsubmenu); 681 - } else { 682 - gle = GetLastError(); 683 - ok( ret == itemid , "TrackPopupMenu returned %d error is %d\n", ret, gle); 684 - ok( gle == 0 || 685 - broken( gle == 0xdeadbeef), /* win2k0 */ 686 - "Last error is %d\n", gle); 687 - /* then destroy the sub-popup */ 688 - ret = DestroyMenu( hsubmenu); 689 - ok(ret, "DestroyMenu failed with error %d\n", GetLastError()); 690 - /* and repeat the tests */ 691 - mii.fMask = MIIM_SUBMENU; 692 - ret = GetMenuItemInfoA( hmenu, 0, TRUE, &mii); 693 - ok( ret, "GetMenuItemInfo failed error %d\n", GetLastError()); 694 - /* GetMenuInfo fails now */ 695 - ok( mii.hSubMenu == hsubmenu, "submenu is %p\n", mii.hSubMenu); 696 - mi.fMask |= MIM_STYLE; 697 - ret = pGetMenuInfo( hsubmenu, &mi); 698 - ok( !ret , "GetMenuInfo should have failed\n"); 699 - /* IsMenu says it is not */ 700 - ret = IsMenu( hsubmenu); 701 - ok( !ret , "Menu handle should be invalid\n"); 702 - /* but TrackPopupMenu still works! */ 703 - SetLastError( 0xdeadbeef); 704 - ret = TrackPopupMenu( hmenu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL); 705 - gle = GetLastError(); 706 - todo_wine { 707 - ok( ret == itemid , "TrackPopupMenu returned %d error is %d\n", ret, gle); 708 - } 709 - ok( gle == 0 || 710 - broken(gle == 0xdeadbeef) || /* wow64 */ 711 - broken(gle == ERROR_INVALID_PARAMETER), /* win2k0 */ 712 - "Last error is %d\n", gle); 675 + ok( ret == itemid , "TrackPopupMenu returned %d error is %d\n", ret, GetLastError()); 676 + 677 + /* then destroy the sub-popup */ 678 + ret = DestroyMenu( hsubmenu); 679 + ok(ret, "DestroyMenu failed with error %d\n", GetLastError()); 680 + /* and repeat the tests */ 681 + mii.fMask = MIIM_SUBMENU; 682 + ret = GetMenuItemInfoA( hmenu, 0, TRUE, &mii); 683 + ok( ret, "GetMenuItemInfo failed error %d\n", GetLastError()); 684 + /* GetMenuInfo fails now */ 685 + ok( mii.hSubMenu == hsubmenu, "submenu is %p\n", mii.hSubMenu); 686 + mi.fMask |= MIM_STYLE; 687 + ret = GetMenuInfo( hsubmenu, &mi); 688 + ok( !ret , "GetMenuInfo should have failed\n"); 689 + /* IsMenu says it is not */ 690 + ret = IsMenu( hsubmenu); 691 + ok( !ret , "Menu handle should be invalid\n"); 692 + 693 + /* but TrackPopupMenu still works! */ 694 + ret = TrackPopupMenu( hmenu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL); 695 + todo_wine { 696 + ok( ret == itemid , "TrackPopupMenu returned %d error is %d\n", ret, GetLastError()); 713 697 } 698 + 714 699 /* clean up */ 715 700 DestroyMenu( hmenu); 716 701 DestroyWindow(hwnd); ··· 741 726 ok( ret, "AppendMenu failed for %d\n", k-1); 742 727 } 743 728 MOD_maxid = k-1; 744 - assert( k <= sizeof(MOD_rc)/sizeof(RECT)); 729 + assert( k <= ARRAY_SIZE(MOD_rc)); 745 730 /* display the menu */ 746 731 TrackPopupMenu( hmenu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL); 747 732 ··· 873 858 if( mnuopt) { 874 859 mi.cbSize = sizeof(mi); 875 860 mi.fMask = MIM_STYLE; 876 - pGetMenuInfo( hmenu, &mi); 861 + GetMenuInfo( hmenu, &mi); 877 862 if( mnuopt) mi.dwStyle |= mnuopt == 1 ? MNS_NOCHECK : MNS_CHECKORBMP; 878 - ret = pSetMenuInfo( hmenu, &mi); 863 + ret = SetMenuInfo( hmenu, &mi); 879 864 ok( ret, "SetMenuInfo failed with error %d\n", GetLastError()); 880 865 } 881 866 ret = InsertMenuItemA( hmenu, 0, FALSE, &mii); ··· 992 977 int count, szidx, txtidx, bmpidx, hassub, mnuopt, ispop; 993 978 BOOL got; 994 979 995 - if( !pGetMenuInfo) 996 - { 997 - win_skip("GetMenuInfo is not available\n"); 998 - return; 999 - } 1000 - 1001 980 memset( bmfill, 0xcc, sizeof( bmfill)); 1002 981 hwnd = CreateWindowExA(0, (LPCSTR)MAKEINTATOM(atomMenuCheckClass), NULL, WS_SYSMENU | 1003 982 WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 200, 200, ··· 1012 991 ok( hsysmenu != NULL, "GetSystemMenu failed with error %d\n", GetLastError()); 1013 992 mi.fMask = MIM_STYLE; 1014 993 mi.dwStyle = 0; 1015 - got = pGetMenuInfo( hsysmenu, &mi); 994 + got = GetMenuInfo( hsysmenu, &mi); 1016 995 ok( got, "GetMenuInfo failed gle=%d\n", GetLastError()); 1017 996 ok( MNS_CHECKORBMP == mi.dwStyle, "System Menu Style is %08x, without the bit %08x\n", 1018 997 mi.dwStyle, MNS_CHECKORBMP); ··· 1065 1044 for( ispop=1; ispop >= 0; ispop--){ 1066 1045 static SIZE bmsizes[]= { 1067 1046 {10,10},{38,38},{1,30},{55,5}}; 1068 - for( szidx=0; szidx < sizeof( bmsizes) / sizeof( SIZE); szidx++) { 1047 + for( szidx=0; szidx < ARRAY_SIZE(bmsizes); szidx++) { 1069 1048 HBITMAP hbm = CreateBitmap( bmsizes[szidx].cx, bmsizes[szidx].cy,1,1,bmfill); 1070 1049 HBITMAP bitmaps[] = { HBMMENU_CALLBACK, hbm, HBMMENU_POPUP_CLOSE, NULL }; 1071 1050 ok( hbm != 0, "CreateBitmap failed err %d\n", GetLastError()); 1072 - for( txtidx = 0; txtidx < sizeof(MOD_txtsizes)/sizeof(MOD_txtsizes[0]); txtidx++) { 1051 + for( txtidx = 0; txtidx < ARRAY_SIZE(MOD_txtsizes); txtidx++) { 1073 1052 for( hassub = 0; hassub < 2 ; hassub++) { /* add submenu item */ 1074 1053 for( mnuopt = 0; mnuopt < 3 ; mnuopt++){ /* test MNS_NOCHECK/MNS_CHECKORBMP */ 1075 - for( bmpidx = 0; bmpidx <sizeof(bitmaps)/sizeof(HBITMAP); bmpidx++) { 1054 + for( bmpidx = 0; bmpidx <ARRAY_SIZE(bitmaps); bmpidx++) { 1076 1055 /* no need to test NULL bitmaps of several sizes */ 1077 1056 if( !bitmaps[bmpidx] && szidx > 0) continue; 1078 1057 /* the HBMMENU_POPUP not to test for menu bars */ ··· 1149 1128 ok (GetMenuStringA( hmenu, 0, strback, 99, MF_BYPOSITION), "GetMenuString on ownerdraw entry failed\n"); 1150 1129 ok (!strcmp( strback, "Dummy string" ), "Menu text from Ansi version incorrect\n"); 1151 1130 1152 - SetLastError(0xdeadbeef); 1153 1131 ret = GetMenuStringW( hmenu, 0, strbackW, 99, MF_BYPOSITION ); 1154 - if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) 1155 - win_skip("GetMenuStringW is not implemented\n"); 1156 - else 1157 - { 1158 - ok (ret, "GetMenuStringW on ownerdraw entry failed\n"); 1159 - ok (!lstrcmpW( strbackW, expectedString ), "Menu text from Unicode version incorrect\n"); 1160 - } 1132 + ok (ret, "GetMenuStringW on ownerdraw entry failed\n"); 1133 + ok (!lstrcmpW( strbackW, expectedString ), "Menu text from Unicode version incorrect\n"); 1161 1134 1162 1135 /* Just try some invalid parameter tests */ 1163 1136 SetLastError(0xdeadbeef); ··· 1225 1198 ok (rc, "InsertMenuItem failed\n"); 1226 1199 ok (!GetMenuStringA( hmenu, 0, NULL, 0, MF_BYPOSITION), 1227 1200 "GetMenuString on ownerdraw entry succeeded.\n"); 1228 - SetLastError(0xdeadbeef); 1229 1201 ret = GetMenuStringW( hmenu, 0, NULL, 0, MF_BYPOSITION); 1230 - if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) 1231 - win_skip("GetMenuStringW is not implemented\n"); 1232 - else 1233 - ok (!ret, "GetMenuStringW on ownerdraw entry succeeded.\n"); 1202 + ok (!ret, "GetMenuStringW on ownerdraw entry succeeded.\n"); 1234 1203 1235 1204 DestroyMenu( hmenu ); 1236 1205 } ··· 1823 1792 Only the low word of the dwTypeData is used. 1824 1793 Use a magic bitmap here (Word 95 uses this to create its MDI menu buttons) */ 1825 1794 TMII_INSMI( MIIM_TYPE, MFT_BITMAP | MFT_RIGHTJUSTIFY, -1, -1, 0, 0, 0, -1, 1826 - (HMENU)MAKELONG(HBMMENU_MBAR_CLOSE, 0x1234), -1, 0, OK ); 1795 + (HMENU)MAKELPARAM(HBMMENU_MBAR_CLOSE, 0x1234), -1, 0, OK ); 1827 1796 TMII_GMII ( MIIM_TYPE, 80, 1828 1797 MFT_BITMAP | MFT_RIGHTJUSTIFY, 0, 0, 0, 0, 0, 0, HBMMENU_MBAR_CLOSE, 0, HBMMENU_MBAR_CLOSE, 1829 1798 NULL, OK, OK ); ··· 1869 1838 Only the low word of the dwTypeData is used. 1870 1839 Use a magic bitmap here (Word 95 uses this to create its MDI menu buttons) */ 1871 1840 TMII_INSMI( MIIM_TYPE, MFT_BITMAP | MFT_RIGHTJUSTIFY, -1, -1, 0, 0, 0, -1, 1872 - (HMENU)MAKELONG(HBMMENU_MBAR_CLOSE, 0x1234), -1, 0, OK ); 1841 + (HMENU)MAKELPARAM(HBMMENU_MBAR_CLOSE, 0x1234), -1, 0, OK ); 1873 1842 TMII_GMII ( MIIM_TYPE, 80, 1874 1843 MFT_BITMAP | MFT_RIGHTJUSTIFY, 0, 0, 0, 0, 0, 0, HBMMENU_MBAR_CLOSE, 0, HBMMENU_MBAR_CLOSE, 1875 1844 NULL, OK, OK ); ··· 2277 2246 { INPUT_KEYBOARD, {{0}}, {VK_F10, 0}, TRUE, FALSE }, 2278 2247 { INPUT_KEYBOARD, {{0}}, {VK_F10, 0}, FALSE, FALSE }, 2279 2248 2280 - { INPUT_MOUSE, {{1, 2}, {0}}, {0}, TRUE, TRUE }, /* test 20 */ 2249 + { INPUT_MOUSE, {{1, 2}, {0}}, {0}, TRUE, FALSE }, /* test 20 */ 2281 2250 { INPUT_MOUSE, {{1, 1}, {0}}, {0}, FALSE, FALSE }, 2282 - { INPUT_MOUSE, {{1, 0}, {0}}, {0}, TRUE, TRUE }, 2251 + { INPUT_MOUSE, {{1, 0}, {0}}, {0}, TRUE, FALSE }, 2283 2252 { INPUT_MOUSE, {{1, 1}, {0}}, {0}, FALSE, FALSE }, 2284 - { INPUT_MOUSE, {{1, 0}, {2, 2}, {0}}, {0}, TRUE, TRUE }, 2253 + { INPUT_MOUSE, {{1, 0}, {2, 2}, {0}}, {0}, TRUE, FALSE }, 2285 2254 { INPUT_MOUSE, {{2, 1}, {0}}, {0}, FALSE, FALSE }, 2286 - { INPUT_MOUSE, {{1, 0}, {2, 0}, {0}}, {0}, TRUE, TRUE }, 2255 + { INPUT_MOUSE, {{1, 0}, {2, 0}, {0}}, {0}, TRUE, FALSE }, 2287 2256 { INPUT_MOUSE, {{3, 0}, {0}}, {0}, FALSE, FALSE }, 2288 - { INPUT_MOUSE, {{1, 0}, {2, 0}, {0}}, {0}, TRUE, TRUE }, 2289 - { INPUT_MOUSE, {{3, 1}, {0}}, {0}, TRUE, TRUE }, 2257 + { INPUT_MOUSE, {{1, 0}, {2, 0}, {0}}, {0}, TRUE, FALSE }, 2258 + { INPUT_MOUSE, {{3, 1}, {0}}, {0}, TRUE, FALSE }, 2290 2259 { INPUT_MOUSE, {{1, 1}, {0}}, {0}, FALSE, FALSE }, 2291 2260 { -1 } 2292 2261 }; ··· 2298 2267 i[0].type = i[1].type = INPUT_KEYBOARD; 2299 2268 i[0].u.ki.wVk = i[1].u.ki.wVk = wVk; 2300 2269 i[1].u.ki.dwFlags = KEYEVENTF_KEYUP; 2301 - pSendInput(2, (INPUT *) i, sizeof(INPUT)); 2270 + SendInput(2, (INPUT *) i, sizeof(INPUT)); 2302 2271 } 2303 2272 2304 2273 static BOOL click_menu(HANDLE hWnd, struct menu_item_pair_s *mi) ··· 2323 2292 i[0].u.mi.dwFlags |= MOUSEEVENTF_MOVE; 2324 2293 i[1].u.mi.dwFlags |= MOUSEEVENTF_LEFTDOWN; 2325 2294 i[2].u.mi.dwFlags |= MOUSEEVENTF_LEFTUP; 2326 - ret = pSendInput(3, (INPUT *) i, sizeof(INPUT)); 2295 + ret = SendInput(3, (INPUT *) i, sizeof(INPUT)); 2327 2296 2328 2297 /* hack to prevent mouse message buildup in Wine */ 2329 2298 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg ); ··· 2340 2309 for (i = 0; menu_tests[i].type != -1; i++) 2341 2310 { 2342 2311 BOOL ret = TRUE; 2343 - int elapsed = 0; 2312 + int elapsed; 2344 2313 2345 2314 got_input = i && menu_tests[i-1].bMenuVisible; 2346 2315 ··· 2349 2318 send_key(menu_tests[i].wVk[j]); 2350 2319 else 2351 2320 for (j = 0; menu_tests[i].menu_item_pairs[j].uMenu != 0; j++) 2352 - if (!(ret = click_menu(hWnd, &menu_tests[i].menu_item_pairs[j]))) break; 2321 + { 2322 + /* Maybe clicking too fast before menu is initialized. Sleep 100 ms and retry */ 2323 + elapsed = 0; 2324 + while (!(ret = click_menu(hWnd, &menu_tests[i].menu_item_pairs[j]))) 2325 + { 2326 + if (elapsed > 1000) break; 2327 + elapsed += 100; 2328 + Sleep(100); 2329 + } 2330 + } 2353 2331 2354 2332 if (!ret) 2355 2333 { ··· 2357 2335 PostMessageA( hWnd, WM_CANCELMODE, 0, 0 ); 2358 2336 return 0; 2359 2337 } 2338 + 2339 + elapsed = 0; 2360 2340 while (menu_tests[i].bMenuVisible != bMenuVisible) 2361 2341 { 2362 2342 if (elapsed > 200) ··· 2381 2361 static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, 2382 2362 LPARAM lParam) 2383 2363 { 2364 + MENUBARINFO mbi; 2365 + HMENU hmenu; 2366 + UINT state; 2367 + BOOL br; 2368 + 2384 2369 switch (msg) { 2385 2370 case WM_ENTERMENULOOP: 2386 2371 bMenuVisible = TRUE; ··· 2405 2390 return( DefWindowProcA( hWnd, msg, wParam, lParam ) ); 2406 2391 } 2407 2392 2408 - if(pGetMenuBarInfo) 2409 - { 2410 - MENUBARINFO mbi; 2411 - HMENU hmenu; 2412 - UINT state; 2413 - BOOL br; 2393 + mbi.cbSize = sizeof(MENUBARINFO); 2414 2394 2415 - mbi.cbSize = sizeof(MENUBARINFO); 2395 + /* get info for the menu */ 2396 + br = GetMenuBarInfo(hWnd, OBJID_MENU, 0, &mbi); 2397 + ok(br, "msg %x: GetMenuBarInfo failed\n", msg); 2398 + hmenu = GetMenu(hWnd); 2399 + ok(!mbi.hwndMenu, "msg %x: GetMenuBarInfo.hwndMenu wrong: %p expected NULL\n", 2400 + msg, mbi.hwndMenu); 2401 + ok(mbi.hMenu == hmenu, "msg %x: GetMenuBarInfo got wrong menu: %p expected %p\n", 2402 + msg, mbi.hMenu, hmenu); 2403 + ok(!bMenuVisible == !mbi.fBarFocused, "msg %x: GetMenuBarInfo.fBarFocused (%d) is wrong\n", 2404 + msg, mbi.fBarFocused != 0); 2405 + ok(!bMenuVisible == !mbi.fFocused, "msg %x: GetMenuBarInfo.fFocused (%d) is wrong\n", 2406 + msg, mbi.fFocused != 0); 2416 2407 2417 - /* get info for the menu */ 2418 - br = pGetMenuBarInfo(hWnd, OBJID_MENU, 0, &mbi); 2419 - ok(br, "msg %x: GetMenuBarInfo failed\n", msg); 2420 - hmenu = GetMenu(hWnd); 2421 - ok(!mbi.hwndMenu, "msg %x: GetMenuBarInfo.hwndMenu wrong: %p expected NULL\n", 2422 - msg, mbi.hwndMenu); 2423 - ok(mbi.hMenu == hmenu, "msg %x: GetMenuBarInfo got wrong menu: %p expected %p\n", 2424 - msg, mbi.hMenu, hmenu); 2425 - ok(!bMenuVisible == !mbi.fBarFocused, "msg %x: GetMenuBarInfo.fBarFocused (%d) is wrong\n", 2426 - msg, mbi.fBarFocused != 0); 2427 - ok(!bMenuVisible == !mbi.fFocused, "msg %x: GetMenuBarInfo.fFocused (%d) is wrong\n", 2428 - msg, mbi.fFocused != 0); 2429 - 2430 - /* get info for the menu's first item */ 2431 - br = pGetMenuBarInfo(hWnd, OBJID_MENU, 1, &mbi); 2432 - ok(br, "msg %x: GetMenuBarInfo failed\n", msg); 2433 - state = GetMenuState(hmenu, 0, MF_BYPOSITION); 2434 - if (pGetMenuInfo) /* Skip on NT */ 2435 - { 2436 - /* Native returns handle to destroyed window */ 2437 - todo_wine_if (msg==WM_UNINITMENUPOPUP && popmenu==1) 2438 - ok(!mbi.hwndMenu == !popmenu, 2439 - "msg %x: GetMenuBarInfo.hwndMenu wrong: %p expected %sNULL\n", 2440 - msg, mbi.hwndMenu, popmenu ? "not " : ""); 2441 - } 2442 - ok(mbi.hMenu == hmenu, "msg %x: GetMenuBarInfo got wrong menu: %p expected %p\n", 2443 - msg, mbi.hMenu, hmenu); 2444 - ok(!bMenuVisible == !mbi.fBarFocused, "nsg %x: GetMenuBarInfo.fBarFocused (%d) is wrong\n", 2445 - msg, mbi.fBarFocused != 0); 2446 - ok(!(bMenuVisible && (state & MF_HILITE)) == !mbi.fFocused, 2447 - "msg %x: GetMenuBarInfo.fFocused (%d) is wrong\n", msg, mbi.fFocused != 0); 2448 - } 2408 + /* get info for the menu's first item */ 2409 + br = GetMenuBarInfo(hWnd, OBJID_MENU, 1, &mbi); 2410 + ok(br, "msg %x: GetMenuBarInfo failed\n", msg); 2411 + state = GetMenuState(hmenu, 0, MF_BYPOSITION); 2412 + /* Native returns handle to destroyed window */ 2413 + todo_wine_if (msg==WM_UNINITMENUPOPUP && popmenu==1) 2414 + ok(!mbi.hwndMenu == !popmenu, 2415 + "msg %x: GetMenuBarInfo.hwndMenu wrong: %p expected %sNULL\n", 2416 + msg, mbi.hwndMenu, popmenu ? "not " : ""); 2417 + ok(mbi.hMenu == hmenu, "msg %x: GetMenuBarInfo got wrong menu: %p expected %p\n", 2418 + msg, mbi.hMenu, hmenu); 2419 + ok(!bMenuVisible == !mbi.fBarFocused, "nsg %x: GetMenuBarInfo.fBarFocused (%d) is wrong\n", 2420 + msg, mbi.fBarFocused != 0); 2421 + ok(!(bMenuVisible && (state & MF_HILITE)) == !mbi.fFocused, 2422 + "msg %x: GetMenuBarInfo.fFocused (%d) is wrong\n", msg, mbi.fFocused != 0); 2449 2423 2450 2424 if (msg == WM_EXITMENULOOP) 2451 2425 bMenuVisible = FALSE; ··· 2464 2438 DWORD tid; 2465 2439 ATOM aclass; 2466 2440 POINT orig_pos; 2467 - 2468 - if (!pSendInput) 2469 - { 2470 - win_skip("SendInput is not available\n"); 2471 - return; 2472 - } 2473 2441 2474 2442 wclass.lpszClassName = "MenuTestClass"; 2475 2443 wclass.style = CS_HREDRAW | CS_VREDRAW; ··· 2858 2826 ok(ret, "AppendMenu failed\n"); 2859 2827 2860 2828 count = GetMenuItemCount(hmenu); 2861 - ok(count == sizeof(menu_data)/sizeof(menu_data[0]), 2862 - "expected %u menu items, got %u\n", 2863 - (UINT)(sizeof(menu_data)/sizeof(menu_data[0])), count); 2829 + ok(count == ARRAY_SIZE(menu_data), "expected %u menu items, got %u\n", 2830 + (UINT) ARRAY_SIZE(menu_data), count); 2864 2831 2865 2832 for (i = 0; i < count; i++) 2866 2833 { ··· 3079 3046 }; 3080 3047 HMENU hmenu; 3081 3048 3082 - #define create_menu(a) create_menu_from_data((a), sizeof(a)/sizeof((a)[0])) 3083 - #define create_menuitem(a) create_menuitem_from_data((a), sizeof(a)/sizeof((a)[0])) 3084 - #define compare_menu(h, a) compare_menu_data((h), (a), sizeof(a)/sizeof((a)[0])) 3049 + #define create_menu(a) create_menu_from_data((a), ARRAY_SIZE(a)) 3050 + #define create_menuitem(a) create_menuitem_from_data((a), ARRAY_SIZE(a)) 3051 + #define compare_menu(h, a) compare_menu_data((h), (a), ARRAY_SIZE(a)) 3085 3052 3086 3053 hmenu = create_menu(in1); 3087 3054 compare_menu(hmenu, out1); ··· 3128 3095 BOOL ret; 3129 3096 DWORD gle; 3130 3097 3131 - if (!pGetMenuInfo) 3132 - { 3133 - win_skip("GetMenuInfo is not available\n"); 3134 - return; 3135 - } 3136 - 3137 3098 /* create a menu */ 3138 3099 hmenu = CreateMenu(); 3139 3100 assert( hmenu); 3140 3101 /* test some parameter errors */ 3141 3102 SetLastError(0xdeadbeef); 3142 - ret = pGetMenuInfo( hmenu, NULL); 3103 + ret = GetMenuInfo( hmenu, NULL); 3143 3104 gle= GetLastError(); 3144 3105 ok( !ret, "GetMenuInfo() should have failed\n"); 3145 3106 ok( gle == ERROR_INVALID_PARAMETER || ··· 3147 3108 "GetMenuInfo() error got %u expected %u\n", gle, ERROR_INVALID_PARAMETER); 3148 3109 SetLastError(0xdeadbeef); 3149 3110 mi.cbSize = 0; 3150 - ret = pGetMenuInfo( hmenu, &mi); 3111 + ret = GetMenuInfo( hmenu, &mi); 3151 3112 gle= GetLastError(); 3152 3113 ok( !ret, "GetMenuInfo() should have failed\n"); 3153 3114 ok( gle == ERROR_INVALID_PARAMETER || ··· 3155 3116 "GetMenuInfo() error got %u expected %u\n", gle, ERROR_INVALID_PARAMETER); 3156 3117 SetLastError(0xdeadbeef); 3157 3118 mi.cbSize = sizeof( MENUINFO); 3158 - ret = pGetMenuInfo( hmenu, &mi); 3119 + ret = GetMenuInfo( hmenu, &mi); 3159 3120 gle= GetLastError(); 3160 3121 ok( ret, "GetMenuInfo() should have succeeded\n"); 3161 3122 ok( gle == 0xdeadbeef, "GetMenuInfo() error got %u\n", gle); 3162 3123 SetLastError(0xdeadbeef); 3163 3124 mi.cbSize = 0; 3164 - ret = pGetMenuInfo( NULL, &mi); 3125 + ret = GetMenuInfo( NULL, &mi); 3165 3126 gle= GetLastError(); 3166 3127 ok( !ret, "GetMenuInfo() should have failed\n"); 3167 3128 ok( gle == ERROR_INVALID_PARAMETER || ··· 3181 3142 DWORD gle; 3182 3143 HBRUSH brush; 3183 3144 3184 - if (!pGetMenuInfo || !pSetMenuInfo) 3185 - { 3186 - win_skip("Get/SetMenuInfo are not available\n"); 3187 - return; 3188 - } 3189 - 3190 3145 /* create a menu with a submenu */ 3191 3146 hmenu = CreateMenu(); 3192 3147 hsubmenu = CreateMenu(); ··· 3197 3152 ok( ret, "InsertMenuItem failed with error %d\n", GetLastError()); 3198 3153 /* test some parameter errors */ 3199 3154 SetLastError(0xdeadbeef); 3200 - ret = pSetMenuInfo( hmenu, NULL); 3155 + ret = SetMenuInfo( hmenu, NULL); 3201 3156 gle= GetLastError(); 3202 3157 ok( !ret, "SetMenuInfo() should have failed\n"); 3203 3158 ok( gle == ERROR_INVALID_PARAMETER || ··· 3205 3160 "SetMenuInfo() error got %u expected %u\n", gle, ERROR_INVALID_PARAMETER); 3206 3161 SetLastError(0xdeadbeef); 3207 3162 mi.cbSize = 0; 3208 - ret = pSetMenuInfo( hmenu, &mi); 3163 + ret = SetMenuInfo( hmenu, &mi); 3209 3164 gle= GetLastError(); 3210 3165 ok( !ret, "SetMenuInfo() should have failed\n"); 3211 3166 ok( gle == ERROR_INVALID_PARAMETER || ··· 3213 3168 "SetMenuInfo() error got %u expected %u\n", gle, ERROR_INVALID_PARAMETER); 3214 3169 SetLastError(0xdeadbeef); 3215 3170 mi.cbSize = sizeof( MENUINFO); 3216 - ret = pSetMenuInfo( hmenu, &mi); 3171 + ret = SetMenuInfo( hmenu, &mi); 3217 3172 gle= GetLastError(); 3218 3173 ok( ret, "SetMenuInfo() should have succeeded\n"); 3219 3174 ok( gle == 0xdeadbeef, "SetMenuInfo() error got %u\n", gle); 3220 3175 SetLastError(0xdeadbeef); 3221 3176 mi.cbSize = 0; 3222 - ret = pSetMenuInfo( NULL, &mi); 3177 + ret = SetMenuInfo( NULL, &mi); 3223 3178 gle= GetLastError(); 3224 3179 ok( !ret, "SetMenuInfo() should have failed\n"); 3225 3180 ok( gle == ERROR_INVALID_PARAMETER || ··· 3230 3185 SetLastError(0xdeadbeef); 3231 3186 mi.cbSize = sizeof( MENUINFO); 3232 3187 mi.fMask = MIM_STYLE; 3233 - ret = pGetMenuInfo( hmenu, &mi); 3188 + ret = GetMenuInfo( hmenu, &mi); 3234 3189 gle= GetLastError(); 3235 3190 ok( ret, "GetMenuInfo() should have succeeded\n"); 3236 3191 ok( gle == 0xdeadbeef, "GetMenuInfo() error got %u\n", gle); ··· 3238 3193 SetLastError(0xdeadbeef); 3239 3194 mi.cbSize = sizeof( MENUINFO); 3240 3195 mi.fMask = MIM_STYLE; 3241 - ret = pGetMenuInfo( hsubmenu, &mi); 3196 + ret = GetMenuInfo( hsubmenu, &mi); 3242 3197 gle= GetLastError(); 3243 3198 ok( ret, "GetMenuInfo() should have succeeded\n"); 3244 3199 ok( gle == 0xdeadbeef, "GetMenuInfo() error got %u\n", gle); ··· 3248 3203 mi.cbSize = sizeof( MENUINFO); 3249 3204 mi.fMask = MIM_STYLE | MIM_APPLYTOSUBMENUS; 3250 3205 mi.dwStyle = MNS_CHECKORBMP; 3251 - ret = pSetMenuInfo( hmenu, &mi); 3206 + ret = SetMenuInfo( hmenu, &mi); 3252 3207 gle= GetLastError(); 3253 3208 ok( ret, "SetMenuInfo() should have succeeded\n"); 3254 3209 ok( gle == 0xdeadbeef, "SetMenuInfo() error got %u\n", gle); ··· 3256 3211 SetLastError(0xdeadbeef); 3257 3212 mi.cbSize = sizeof( MENUINFO); 3258 3213 mi.fMask = MIM_STYLE; 3259 - ret = pGetMenuInfo( hmenu, &mi); 3214 + ret = GetMenuInfo( hmenu, &mi); 3260 3215 gle= GetLastError(); 3261 3216 ok( ret, "GetMenuInfo() should have succeeded\n"); 3262 3217 ok( gle == 0xdeadbeef, "GetMenuInfo() error got %u\n", gle); ··· 3264 3219 SetLastError(0xdeadbeef); 3265 3220 mi.cbSize = sizeof( MENUINFO); 3266 3221 mi.fMask = MIM_STYLE; 3267 - ret = pGetMenuInfo( hsubmenu, &mi); 3222 + ret = GetMenuInfo( hsubmenu, &mi); 3268 3223 gle= GetLastError(); 3269 3224 ok( ret, "GetMenuInfo() should have succeeded\n"); 3270 3225 ok( gle == 0xdeadbeef, "GetMenuInfo() error got %u\n", gle); ··· 3274 3229 mi.cbSize = sizeof( MENUINFO); 3275 3230 mi.fMask = MIM_STYLE ; 3276 3231 mi.dwStyle = MNS_NOCHECK; 3277 - ret = pSetMenuInfo( hmenu, &mi); 3232 + ret = SetMenuInfo( hmenu, &mi); 3278 3233 gle= GetLastError(); 3279 3234 ok( ret, "SetMenuInfo() should have succeeded\n"); 3280 3235 ok( gle == 0xdeadbeef, "SetMenuInfo() error got %u\n", gle); ··· 3282 3237 SetLastError(0xdeadbeef); 3283 3238 mi.cbSize = sizeof( MENUINFO); 3284 3239 mi.fMask = MIM_STYLE; 3285 - ret = pGetMenuInfo( hmenu, &mi); 3240 + ret = GetMenuInfo( hmenu, &mi); 3286 3241 gle= GetLastError(); 3287 3242 ok( ret, "GetMenuInfo() should have succeeded\n"); 3288 3243 ok( gle == 0xdeadbeef, "GetMenuInfo() error got %u\n", gle); ··· 3290 3245 SetLastError(0xdeadbeef); 3291 3246 mi.cbSize = sizeof( MENUINFO); 3292 3247 mi.fMask = MIM_STYLE; 3293 - ret = pGetMenuInfo( hsubmenu, &mi); 3248 + ret = GetMenuInfo( hsubmenu, &mi); 3294 3249 gle= GetLastError(); 3295 3250 ok( ret, "GetMenuInfo() should have succeeded\n"); 3296 3251 ok( gle == 0xdeadbeef, "GetMenuInfo() error got %u\n", gle); ··· 3299 3254 /* test background brush */ 3300 3255 mi.cbSize = sizeof(mi); 3301 3256 mi.fMask = MIM_BACKGROUND; 3302 - ret = pGetMenuInfo( hmenu, &mi ); 3257 + ret = GetMenuInfo( hmenu, &mi ); 3303 3258 ok( ret, "GetMenuInfo() should have succeeded\n" ); 3304 3259 ok( mi.hbrBack == NULL, "got %p\n", mi.hbrBack ); 3305 3260 3306 3261 brush = CreateSolidBrush( RGB(0xff, 0, 0) ); 3307 3262 mi.hbrBack = brush; 3308 - ret = pSetMenuInfo( hmenu, &mi ); 3263 + ret = SetMenuInfo( hmenu, &mi ); 3309 3264 ok( ret, "SetMenuInfo() should have succeeded\n" ); 3310 3265 mi.hbrBack = NULL; 3311 - ret = pGetMenuInfo( hmenu, &mi ); 3266 + ret = GetMenuInfo( hmenu, &mi ); 3312 3267 ok( ret, "GetMenuInfo() should have succeeded\n" ); 3313 3268 ok( mi.hbrBack == brush, "got %p original %p\n", mi.hbrBack, brush ); 3314 3269 3315 3270 mi.hbrBack = NULL; 3316 - ret = pSetMenuInfo( hmenu, &mi ); 3271 + ret = SetMenuInfo( hmenu, &mi ); 3317 3272 ok( ret, "SetMenuInfo() should have succeeded\n" ); 3318 - ret = pGetMenuInfo( hmenu, &mi ); 3273 + ret = GetMenuInfo( hmenu, &mi ); 3319 3274 ok( ret, "GetMenuInfo() should have succeeded\n" ); 3320 3275 ok( mi.hbrBack == NULL, "got %p\n", mi.hbrBack ); 3321 3276 DeleteObject( brush ); ··· 3682 3637 ok( hbm1 && hbm2 && hbm3, "Creating bitmaps failed\n"); 3683 3638 menu = CreatePopupMenu(); 3684 3639 ok( menu != NULL, "CreatePopupMenu() failed\n"); 3685 - if( pGetMenuInfo) { 3686 - mi.fMask = MIM_STYLE; 3687 - ret = pGetMenuInfo( menu, &mi); 3688 - ok( ret, "GetMenuInfo failed: %d\n", GetLastError()); 3689 - ok( menu != NULL, "GetMenuInfo() failed\n"); 3690 - ok( 0 == mi.dwStyle, "menuinfo style is %x\n", mi.dwStyle); 3691 - } 3640 + 3641 + mi.fMask = MIM_STYLE; 3642 + ret = GetMenuInfo( menu, &mi); 3643 + ok( ret, "GetMenuInfo failed: %d\n", GetLastError()); 3644 + ok( menu != NULL, "GetMenuInfo() failed\n"); 3645 + ok( 0 == mi.dwStyle, "menuinfo style is %x\n", mi.dwStyle); 3646 + 3692 3647 /* test 1 */ 3693 3648 mii.fMask = MIIM_BITMAP | MIIM_STRING | MIIM_ID; 3694 3649 mii.wID = 1; ··· 4298 4253 4299 4254 START_TEST(menu) 4300 4255 { 4301 - init_function_pointers(); 4302 4256 register_menu_check_class(); 4303 4257 4304 - /* Wine defines MENUITEMINFO for W2K and above. NT4 and below can't 4305 - * handle that. 4306 - */ 4307 - if (correct_behavior()) 4308 - { 4309 - test_menu_add_string(); 4310 - test_menu_iteminfo(); 4311 - test_menu_search_bycommand(); 4312 - test_CheckMenuRadioItem(); 4313 - test_menu_resource_layout(); 4314 - test_InsertMenu(); 4315 - test_menualign(); 4316 - test_system_menu(); 4317 - } 4258 + test_menu_add_string(); 4259 + test_menu_iteminfo(); 4260 + test_menu_search_bycommand(); 4261 + test_CheckMenuRadioItem(); 4262 + test_menu_resource_layout(); 4263 + test_InsertMenu(); 4264 + test_menualign(); 4265 + test_system_menu(); 4318 4266 4319 4267 test_menu_locked_by_window(); 4320 4268 test_subpopup_locked_by_menu(); 4321 4269 test_menu_ownerdraw(); 4322 4270 test_getmenubarinfo(); 4271 + test_GetMenuItemRect(); 4323 4272 test_menu_bmp_and_string(); 4324 4273 test_menu_getmenuinfo(); 4325 4274 test_menu_setmenuinfo();
+178 -35
modules/rostests/winetests/user32/monitor.c
··· 23 23 #include "winbase.h" 24 24 #include "wingdi.h" 25 25 #include "winuser.h" 26 + #include "winreg.h" 27 + #include <stdio.h> 26 28 27 29 static HMODULE hdll; 28 30 static LONG (WINAPI *pChangeDisplaySettingsExA)(LPCSTR, LPDEVMODEA, HWND, DWORD, LPVOID); ··· 74 76 return TRUE; 75 77 } 76 78 79 + static int adapter_count = 0; 80 + static int monitor_count = 0; 81 + 82 + static void test_enumdisplaydevices_adapter(int index, const DISPLAY_DEVICEA *device, DWORD flags) 83 + { 84 + char video_name[32]; 85 + char video_value[128]; 86 + char buffer[128]; 87 + int number; 88 + int vendor_id; 89 + int device_id; 90 + int subsys_id; 91 + int revision_id; 92 + size_t length; 93 + HKEY hkey; 94 + HDC hdc; 95 + DWORD size; 96 + LSTATUS ls; 97 + 98 + adapter_count++; 99 + 100 + /* DeviceName */ 101 + ok(sscanf(device->DeviceName, "\\\\.\\DISPLAY%d", &number) == 1, "#%d: wrong DeviceName %s\n", index, 102 + device->DeviceName); 103 + 104 + /* DeviceKey */ 105 + /* win7 is the only OS version where \Device\Video? value in HLKM\HARDWARE\DEVICEMAP\VIDEO are not in order with adapter index. */ 106 + if (GetVersion() != 0x1db10106 || !strcmp(winetest_platform, "wine")) 107 + { 108 + sprintf(video_name, "\\Device\\Video%d", index); 109 + ls = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "HARDWARE\\DEVICEMAP\\VIDEO", 0, KEY_READ, &hkey); 110 + ok(!ls, "#%d: failed to open registry, error: %#x\n", index, ls); 111 + if (!ls) 112 + { 113 + memset(video_value, 0, sizeof(video_value)); 114 + size = sizeof(video_value); 115 + ls = RegQueryValueExA(hkey, video_name, NULL, NULL, (unsigned char *)video_value, &size); 116 + ok(!ls, "#%d: failed to get registry value, error: %#x\n", index, ls); 117 + RegCloseKey(hkey); 118 + ok(!strcmp(video_value, device->DeviceKey), "#%d: wrong DeviceKey: %s\n", index, device->DeviceKey); 119 + } 120 + } 121 + else 122 + ok(sscanf(device->DeviceKey, "\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Video\\%[^\\]\\%04d", buffer, &number) == 2, 123 + "#%d: wrong DeviceKey %s\n", index, device->DeviceKey); 124 + 125 + /* DeviceString */ 126 + length = strlen(device->DeviceString); 127 + ok(broken(length == 0) || /* XP on Testbot will return an empty string, whereas XP on real machine doesn't. Probably a bug in virtual adapter driver */ 128 + length > 0, "#%d: expect DeviceString not empty\n", index); 129 + 130 + /* StateFlags */ 131 + if (index == 0) 132 + ok(device->StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE, "#%d: adapter should be primary\n", index); 133 + else 134 + ok(!(device->StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE), "#%d: adapter should not be primary\n", index); 135 + 136 + if (device->StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) 137 + { 138 + /* Test creating DC */ 139 + hdc = CreateDCA(device->DeviceName, NULL, NULL, NULL); 140 + ok(hdc != NULL, "#%d: failed to CreateDC(\"%s\") err=%d\n", index, device->DeviceName, GetLastError()); 141 + DeleteDC(hdc); 142 + } 143 + 144 + /* DeviceID */ 145 + /* DeviceID should equal to the first string of HardwareID value data in PCI GPU instance. You can verify this 146 + * by changing the data and rerun EnumDisplayDevices. But it's difficult to find corresponding PCI device on 147 + * userland. So here we check the expected format instead. */ 148 + if (flags & EDD_GET_DEVICE_INTERFACE_NAME) 149 + ok(strlen(device->DeviceID) == 0 || /* vista+ */ 150 + sscanf(device->DeviceID, "PCI\\VEN_%04X&DEV_%04X&SUBSYS_%08X&REV_%02X", 151 + &vendor_id, &device_id, &subsys_id, &revision_id) == 4, /* XP/2003 ignores EDD_GET_DEVICE_INTERFACE_NAME */ 152 + "#%d: got %s\n", index, device->DeviceID); 153 + else 154 + { 155 + ok(broken(strlen(device->DeviceID) == 0) || /* XP on Testbot returns an empty string, whereas real machine doesn't */ 156 + sscanf(device->DeviceID, "PCI\\VEN_%04X&DEV_%04X&SUBSYS_%08X&REV_%02X", &vendor_id, &device_id, &subsys_id, 157 + &revision_id) == 4, "#%d: wrong DeviceID %s\n", index, device->DeviceID); 158 + } 159 + } 160 + 161 + static void test_enumdisplaydevices_monitor(int adapter_index, int monitor_index, const char *adapter_name, 162 + const DISPLAY_DEVICEA *device, DWORD flags) 163 + { 164 + static const char device_id_prefix[] = "MONITOR\\Default_Monitor\\{4d36e96e-e325-11ce-bfc1-08002be10318}\\"; 165 + static const char device_key_prefix[] = "\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Class" 166 + "\\{4d36e96e-e325-11ce-bfc1-08002be10318}\\"; 167 + char monitor_name[32]; 168 + char buffer[128]; 169 + int number; 170 + 171 + monitor_count++; 172 + 173 + /* DeviceName */ 174 + lstrcpyA(monitor_name, adapter_name); 175 + sprintf(monitor_name + strlen(monitor_name), "\\Monitor%d", monitor_index); 176 + ok(!strcmp(monitor_name, device->DeviceName), "#%d: expect %s, got %s\n", monitor_index, monitor_name, device->DeviceName); 177 + 178 + /* DeviceString */ 179 + ok(strlen(device->DeviceString) > 0, "#%d: expect DeviceString not empty\n", monitor_index); 180 + 181 + /* StateFlags */ 182 + if (adapter_index == 0 && monitor_index == 0) 183 + ok(device->StateFlags & DISPLAY_DEVICE_ATTACHED, "#%d expect to have a primary monitor attached\n", monitor_index); 184 + else 185 + ok(device->StateFlags <= (DISPLAY_DEVICE_ATTACHED | DISPLAY_DEVICE_ACTIVE), "#%d wrong state %#x\n", monitor_index, 186 + device->StateFlags); 187 + 188 + /* DeviceID */ 189 + lstrcpynA(buffer, device->DeviceID, sizeof(device_id_prefix)); 190 + if (flags & EDD_GET_DEVICE_INTERFACE_NAME) 191 + { /* HKLM\SYSTEM\CurrentControlSet\Enum\DISPLAY\Default_Monitor\4&2abfaa30&0&UID0 GUID_DEVINTERFACE_MONITOR 192 + * ^ ^ ^ 193 + * Expect format \\?\DISPLAY#Default_Monitor#4&2abfaa30&0&UID0#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7} */ 194 + ok(strlen(device->DeviceID) == 0 || /* vista ~ win7 */ 195 + sscanf(device->DeviceID, "\\\\?\\DISPLAY#Default_Monitor#%[^#]#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}", buffer) == 1 || /* win8+ */ 196 + (!lstrcmpiA(buffer, device_id_prefix) && 197 + sscanf(device->DeviceID + sizeof(device_id_prefix) - 1, "%04d", &number) == 1), /* XP/2003 ignores EDD_GET_DEVICE_INTERFACE_NAME */ 198 + "#%d: wrong DeviceID : %s\n", monitor_index, device->DeviceID); 199 + } 200 + else 201 + { 202 + /* Expect HarewareID value data + Driver value data in HKLM\SYSTEM\CurrentControlSet\Enum\DISPLAY\Default_Monitor\{Instance} */ 203 + /* But we don't know which monitor instance this belongs to, so check format instead */ 204 + ok(!lstrcmpiA(buffer, device_id_prefix), "#%d wrong DeviceID : %s\n", monitor_index, device->DeviceID); 205 + ok(sscanf(device->DeviceID + sizeof(device_id_prefix) - 1, "%04d", &number) == 1, 206 + "#%d wrong DeviceID : %s\n", monitor_index, device->DeviceID); 207 + } 208 + 209 + /* DeviceKey */ 210 + lstrcpynA(buffer, device->DeviceKey, sizeof(device_key_prefix)); 211 + ok(!lstrcmpiA(buffer, device_key_prefix), "#%d: wrong DeviceKey : %s\n", monitor_index, device->DeviceKey); 212 + ok(sscanf(device->DeviceKey + sizeof(device_key_prefix) - 1, "%04d", &number) == 1, 213 + "#%d wrong DeviceKey : %s\n", monitor_index, device->DeviceKey); 214 + } 215 + 77 216 static void test_enumdisplaydevices(void) 78 217 { 218 + static const DWORD flags[] = {0, EDD_GET_DEVICE_INTERFACE_NAME}; 79 219 DISPLAY_DEVICEA dd; 80 220 char primary_device_name[32]; 81 221 char primary_monitor_device_name[32]; 82 - DWORD primary_num = -1, num = 0; 222 + char adapter_name[32]; 223 + int number; 224 + int flag_index; 225 + int adapter_index; 226 + int monitor_index; 83 227 BOOL ret; 84 228 85 229 if (!pEnumDisplayDevicesA) ··· 88 232 return; 89 233 } 90 234 235 + /* Doesn't accept \\.\DISPLAY */ 91 236 dd.cb = sizeof(dd); 92 - for (num = 0;; num++) 93 - { 94 - HDC dc; 95 - ret = pEnumDisplayDevicesA(NULL, num, &dd, 0); 96 - if(!ret) break; 237 + ret = pEnumDisplayDevicesA("\\\\.\\DISPLAY", 0, &dd, 0); 238 + ok(!ret, "Expect failure\n"); 97 239 98 - if(dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) 99 - { 100 - strcpy(primary_device_name, dd.DeviceName); 101 - primary_num = num; 102 - } 103 - if(dd.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) 240 + /* Enumeration */ 241 + for (flag_index = 0; flag_index < ARRAY_SIZE(flags); flag_index++) 242 + for (adapter_index = 0; pEnumDisplayDevicesA(NULL, adapter_index, &dd, flags[flag_index]); adapter_index++) 104 243 { 105 - /* test creating DC */ 106 - dc = CreateDCA(dd.DeviceName, NULL, NULL, NULL); 107 - ok(dc != NULL, "Failed to CreateDC(\"%s\") err=%d\n", dd.DeviceName, GetLastError()); 108 - DeleteDC(dc); 244 + lstrcpyA(adapter_name, dd.DeviceName); 245 + 246 + if (sscanf(adapter_name, "\\\\.\\DISPLAYV%d", &number) == 1) 247 + { 248 + skip("Skipping software devices %s:%s\n", adapter_name, dd.DeviceString); 249 + continue; 250 + } 251 + 252 + test_enumdisplaydevices_adapter(adapter_index, &dd, flags[flag_index]); 253 + 254 + for (monitor_index = 0; pEnumDisplayDevicesA(adapter_name, monitor_index, &dd, flags[flag_index]); 255 + monitor_index++) 256 + test_enumdisplaydevices_monitor(adapter_index, monitor_index, adapter_name, &dd, flags[flag_index]); 109 257 } 110 - } 258 + 259 + ok(adapter_count > 0, "Expect at least one adapter found\n"); 260 + /* XP on Testbot doesn't report a monitor, whereas XP on real machine does */ 261 + ok(broken(monitor_count == 0) || monitor_count > 0, "Expect at least one monitor found\n"); 111 262 112 - if (primary_num == -1 || !pEnumDisplayMonitors || !pGetMonitorInfoA) 263 + if (!pEnumDisplayMonitors || !pGetMonitorInfoA) 113 264 { 114 265 win_skip("EnumDisplayMonitors or GetMonitorInfoA are not available\n"); 115 266 return; 116 267 } 117 268 269 + ret = pEnumDisplayDevicesA(NULL, 0, &dd, 0); 270 + ok(ret, "Expect success\n"); 271 + lstrcpyA(primary_device_name, dd.DeviceName); 272 + 118 273 primary_monitor_device_name[0] = 0; 119 274 ret = pEnumDisplayMonitors(NULL, NULL, monitor_enum_proc, (LPARAM)primary_monitor_device_name); 120 275 ok(ret, "EnumDisplayMonitors failed\n"); 121 276 ok(!strcmp(primary_monitor_device_name, primary_device_name), 122 277 "monitor device name %s, device name %s\n", primary_monitor_device_name, 123 278 primary_device_name); 124 - 125 - dd.cb = sizeof(dd); 126 - for (num = 0;; num++) 127 - { 128 - ret = pEnumDisplayDevicesA(primary_device_name, num, &dd, 0); 129 - if (!ret) break; 130 - 131 - dd.DeviceID[63] = 0; 132 - ok(!strcasecmp(dd.DeviceID, "Monitor\\Default_Monitor\\{4D36E96E-E325-11CE-BFC1-08002BE10318}\\"), 133 - "DeviceID \"%s\" does not start with \"Monitor\\Default_Monitor\\...\" prefix\n", dd.DeviceID); 134 - } 135 279 } 136 280 137 281 struct vid_mode ··· 160 304 {0, 0, 0, 0, DM_DISPLAYFREQUENCY, 0} 161 305 */ 162 306 }; 163 - #define vid_modes_cnt (sizeof(vid_modes_test) / sizeof(vid_modes_test[0])) 164 307 165 308 static void test_ChangeDisplaySettingsEx(void) 166 309 { ··· 247 390 memset(&dm, 0, sizeof(dm)); 248 391 dm.dmSize = sizeof(dm); 249 392 250 - for (i = 0; i < vid_modes_cnt; i++) 393 + for (i = 0; i < ARRAY_SIZE(vid_modes_test); i++) 251 394 { 252 395 dm.dmPelsWidth = vid_modes_test[i].w; 253 396 dm.dmPelsHeight = vid_modes_test[i].h; ··· 409 552 410 553 /* tests for cbSize in MONITORINFO */ 411 554 monitor = pMonitorFromWindow( 0, MONITOR_DEFAULTTOPRIMARY ); 412 - for (i = 0; i < (sizeof(testdatami) / sizeof(testdatami[0])); i++) 555 + for (i = 0; i < ARRAY_SIZE(testdatami); i++) 413 556 { 414 557 memset( &mi, 0, sizeof(mi) ); 415 558 mi.cbSize = testdatami[i].cbSize; ··· 431 574 } 432 575 433 576 /* tests for cbSize in MONITORINFOEXA */ 434 - for (i = 0; i < (sizeof(testdatamiexa) / sizeof(testdatamiexa[0])); i++) 577 + for (i = 0; i < ARRAY_SIZE(testdatamiexa); i++) 435 578 { 436 579 memset( &miexa, 0, sizeof(miexa) ); 437 580 miexa.cbSize = testdatamiexa[i].cbSize; ··· 444 587 } 445 588 446 589 /* tests for cbSize in MONITORINFOEXW */ 447 - for (i = 0; i < (sizeof(testdatamiexw) / sizeof(testdatamiexw[0])); i++) 590 + for (i = 0; i < ARRAY_SIZE(testdatamiexw); i++) 448 591 { 449 592 memset( &miexw, 0, sizeof(miexw) ); 450 593 miexw.cbSize = testdatamiexw[i].cbSize; ··· 596 739 paths = modes = 100; 597 740 ret = pGetDisplayConfigBufferSizes(0, &paths, &modes); 598 741 ok(ret == ERROR_INVALID_PARAMETER || ret == ERROR_NOT_SUPPORTED, "got %d\n", ret); 599 - ok(modes == 0 && paths == 0, "got %u, %u\n", modes, paths); 742 + ok((modes == 0 || modes == 100) && paths == 0, "got %u, %u\n", modes, paths); 600 743 } 601 744 602 745 START_TEST(monitor)
+552 -79
modules/rostests/winetests/user32/msg.c
··· 569 569 { WM_GETTITLEBARINFOEX, sent|optional }, 570 570 { WM_NCPAINT, sent|beginpaint|optional }, 571 571 { WM_ERASEBKGND, sent|beginpaint|optional }, 572 + { WM_SYNCPAINT, sent|optional }, 572 573 { 0 } 573 574 }; 574 575 /* ShowWindow(SW_RESTORE) for a not visible minimized overlapped window */ ··· 778 779 { 0 } 779 780 }; 780 781 /* ShowWindow(SW_SHOWMAXIMIZED) for a resized not visible popup window */ 781 - static const struct message WmShowMaxPopupResizedSeq_todo[] = { 782 - { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE }, 783 - { WM_GETMINMAXINFO, sent }, 784 - { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED }, 785 - { WM_NCCALCSIZE, sent|wparam, TRUE }, 786 - { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 }, 787 - { HCBT_ACTIVATE, hook }, 788 - { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 }, 789 - { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 }, 790 - { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, 791 - { WM_NCPAINT, sent|wparam|optional, 1 }, 792 - { WM_ERASEBKGND, sent|optional }, 793 - { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, 794 - { WM_ACTIVATEAPP, sent|wparam, 1 }, 795 - { WM_NCACTIVATE, sent }, 796 - { WM_ACTIVATE, sent|wparam, 1 }, 797 - { HCBT_SETFOCUS, hook }, 798 - { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 }, 799 - { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 }, 800 - { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 }, 801 - { WM_SETFOCUS, sent|wparam|defwinproc, 0 }, 802 - { WM_GETTEXT, sent|optional }, 803 - { WM_NCPAINT, sent|wparam|optional, 1 }, 804 - { WM_ERASEBKGND, sent|optional }, 805 - { WM_WINDOWPOSCHANGED, sent }, 806 - /* WinNT4.0 sends WM_MOVE */ 807 - { WM_MOVE, sent|defwinproc|optional }, 808 - { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED }, 809 - { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, 810 - { 0 } 811 - }; 812 782 static const struct message WmShowMaxPopupResizedSeq[] = { 813 783 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE }, 814 784 { WM_GETMINMAXINFO, sent }, ··· 831 801 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 }, 832 802 { WM_SETFOCUS, sent|wparam|defwinproc, 0 }, 833 803 { WM_GETTEXT, sent|optional }, 834 - { WM_NCPAINT, sent|optional }, /* We'll check WM_NCPAINT behaviour in another test */ 804 + { WM_NCPAINT, sent|wparam|optional, 1 }, 835 805 { WM_ERASEBKGND, sent|optional }, 836 806 { WM_WINDOWPOSCHANGED, sent }, 837 807 /* WinNT4.0 sends WM_MOVE */ ··· 870 840 { WM_ERASEBKGND, sent|defwinproc|optional }, 871 841 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE }, 872 842 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, 843 + { WM_SIZE, sent|defwinproc|optional }, 873 844 { 0 } 874 845 }; 875 846 /* CreateWindow(WS_VISIBLE) for popup window */ ··· 3510 3481 { WM_MDIACTIVATE, sent|defwinproc|optional }, 3511 3482 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, 3512 3483 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */ 3484 + { WM_SIZE, sent|defwinproc|optional }, 3513 3485 { 0 } 3514 3486 }; 3515 3487 /* WM_MDIMAXIMIZE for an MDI child window with invisible parent */ ··· 4017 3989 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus()); 4018 3990 4019 3991 ShowWindow(mdi_child2, SW_MINIMIZE); 4020 - ok_sequence(WmMinimizeMDIchildVisibleSeq, "ShowWindow(SW_MINIMIZE):MDI child", TRUE); 3992 + ok_sequence(WmMinimizeMDIchildVisibleSeq, "ShowWindow(SW_MINIMIZE):MDI child", FALSE); 4021 3993 4022 3994 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow()); 4023 3995 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus()); ··· 4756 4728 DestroyWindow(hwnd); 4757 4729 flush_sequence(); 4758 4730 4759 - /* Test again, this time the NC_PAINT message */ 4760 - hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE, 4761 - 100, 100, 200, 200, 0, 0, 0, NULL); 4762 - ok (hwnd != 0, "Failed to create popup window\n"); 4763 - SetWindowPos(hwnd, 0, 10, 10, 200, 200, SWP_NOZORDER | SWP_NOACTIVATE); 4764 - flush_sequence(); 4765 - ShowWindow(hwnd, SW_SHOWMAXIMIZED); 4766 - ok_sequence(WmShowMaxPopupResizedSeq_todo, 4767 - "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized and resized popup TODO", TRUE); 4768 - DestroyWindow(hwnd); 4769 - flush_sequence(); 4770 - 4771 4731 /* Test 2: 4772 4732 * 1. Create invisible maximized popup window. 4773 4733 * 2. Show it maximized. ··· 4817 4777 flush_sequence(); 4818 4778 } 4819 4779 4780 + static void test_recursive_activation(void) 4781 + { 4782 + static const struct message seq[] = 4783 + { 4784 + { HCBT_ACTIVATE, hook }, 4785 + { WM_NCACTIVATE, sent|wparam, TRUE }, 4786 + { WM_ACTIVATE, sent|wparam, WA_ACTIVE }, 4787 + { HCBT_ACTIVATE, hook }, 4788 + { WM_NCACTIVATE, sent|wparam, FALSE }, 4789 + { WM_ACTIVATE, sent|wparam, WA_INACTIVE }, 4790 + { WM_SETFOCUS, sent|optional }, 4791 + { 0 } 4792 + }; 4793 + HWND hwnd, recursive; 4794 + 4795 + hwnd = CreateWindowExA(0, "SimpleWindowClass", NULL, WS_OVERLAPPED|WS_VISIBLE, 4796 + 100, 100, 200, 200, 0, 0, 0, NULL); 4797 + ok(hwnd != 0, "Failed to create simple window\n"); 4798 + 4799 + recursive = CreateWindowExA(0, "RecursiveActivationClass", NULL, WS_OVERLAPPED|WS_VISIBLE, 4800 + 10, 10, 50, 50, hwnd, 0, 0, NULL); 4801 + ok(recursive != 0, "Failed to create recursive activation window\n"); 4802 + SetActiveWindow(hwnd); 4803 + 4804 + flush_sequence(); 4805 + SetActiveWindow(recursive); 4806 + ok_sequence(seq, "Recursive Activation", FALSE); 4807 + 4808 + DestroyWindow(recursive); 4809 + DestroyWindow(hwnd); 4810 + flush_sequence(); 4811 + } 4812 + 4820 4813 static void test_sys_menu(void) 4821 4814 { 4822 4815 HWND hwnd; ··· 5066 5059 DBT_DEVICETYPESPECIFIC, 5067 5060 DBT_CUSTOMEVENT}; 5068 5061 5069 - for (i = 0; i < sizeof(wparams)/sizeof(wparams[0]); i++) 5062 + for (i = 0; i < ARRAY_SIZE(wparams); i++) 5070 5063 { 5071 5064 SetLastError(0xdeadbeef); 5072 5065 ret = PostMessageA(hwnd, WM_DEVICECHANGE, wparams[i], 0); ··· 5187 5180 5188 5181 ShowWindow(hwnd, SW_MINIMIZE); 5189 5182 flush_events(); 5190 - ok_sequence(WmShowMinOverlappedSeq, "ShowWindow(SW_SHOWMINIMIZED):overlapped", TRUE); 5183 + ok_sequence(WmShowMinOverlappedSeq, "ShowWindow(SW_SHOWMINIMIZED):overlapped", FALSE); 5191 5184 flush_sequence(); 5192 5185 5193 5186 if (GetWindowLongW( hwnd, GWL_STYLE ) & WS_MINIMIZE) ··· 5343 5336 hwnd = CreateWindowExA(0, "TestWindowClass", "Test Popup", WS_POPUP | WS_VISIBLE, 5344 5337 -10, -10, 10000, 10000, NULL, 0, 0, NULL ); 5345 5338 ok (hwnd != 0, "Failed to create popup window\n"); 5346 - ok_sequence(WmShowPopupExtremeLocationSeq, "RedrawWindow:show_popup_extreme_location", TRUE); 5339 + ok_sequence(WmShowPopupExtremeLocationSeq, "RedrawWindow:show_popup_extreme_location", FALSE); 5347 5340 DestroyWindow(hwnd); 5348 5341 5349 5342 ··· 6390 6383 hfont2 = CreateFontIndirectA(&logfont); 6391 6384 ok(hfont2 != NULL, "Failed to create Tahoma font\n"); 6392 6385 6393 - for (i = 0; i < sizeof(button)/sizeof(button[0]); i++) 6386 + for (i = 0; i < ARRAY_SIZE(button); i++) 6394 6387 { 6395 6388 MSG msg; 6396 6389 DWORD style, state; ··· 6619 6612 DestroyWindow(parent); 6620 6613 } 6621 6614 6615 + static void test_button_bm_get_set_image(void) 6616 + { 6617 + HWND hwnd; 6618 + HDC hdc; 6619 + HBITMAP hbmp1x1; 6620 + HBITMAP hbmp2x2; 6621 + HBITMAP hmask2x2; 6622 + ICONINFO icon_info2x2; 6623 + HICON hicon2x2; 6624 + HBITMAP hbmp; 6625 + HICON hicon; 6626 + ICONINFO icon_info; 6627 + BITMAP bm; 6628 + DWORD default_style = BS_PUSHBUTTON | WS_TABSTOP | WS_POPUP | WS_VISIBLE; 6629 + LRESULT ret; 6630 + 6631 + hdc = GetDC(0); 6632 + hbmp1x1 = CreateCompatibleBitmap(hdc, 1, 1); 6633 + hbmp2x2 = CreateCompatibleBitmap(hdc, 2, 2); 6634 + ZeroMemory(&bm, sizeof(bm)); 6635 + ok(GetObjectW(hbmp1x1, sizeof(bm), &bm), "Expect GetObjectW() success\n"); 6636 + ok(bm.bmWidth == 1 && bm.bmHeight == 1, "Expect bitmap size: %d,%d, got: %d,%d\n", 1, 1, 6637 + bm.bmWidth, bm.bmHeight); 6638 + ZeroMemory(&bm, sizeof(bm)); 6639 + ok(GetObjectW(hbmp2x2, sizeof(bm), &bm), "Expect GetObjectW() success\n"); 6640 + ok(bm.bmWidth == 2 && bm.bmHeight == 2, "Expect bitmap size: %d,%d, got: %d,%d\n", 2, 2, 6641 + bm.bmWidth, bm.bmHeight); 6642 + 6643 + hmask2x2 = CreateCompatibleBitmap(hdc, 2, 2); 6644 + ZeroMemory(&icon_info2x2, sizeof(icon_info2x2)); 6645 + icon_info2x2.fIcon = TRUE; 6646 + icon_info2x2.hbmMask = hmask2x2; 6647 + icon_info2x2.hbmColor = hbmp2x2; 6648 + hicon2x2 = CreateIconIndirect(&icon_info2x2); 6649 + 6650 + ZeroMemory(&icon_info, sizeof(icon_info)); 6651 + ok(GetIconInfo(hicon2x2, &icon_info), "Expect GetIconInfo() success\n"); 6652 + ZeroMemory(&bm, sizeof(bm)); 6653 + ok(GetObjectW(icon_info.hbmColor, sizeof(bm), &bm), "Expect GetObjectW() success\n"); 6654 + ok(bm.bmWidth == 2 && bm.bmHeight == 2, "Expect bitmap size: %d,%d, got: %d,%d\n", 2, 2, 6655 + bm.bmWidth, bm.bmHeight); 6656 + DeleteObject(icon_info.hbmColor); 6657 + DeleteObject(icon_info.hbmMask); 6658 + 6659 + /* Set bitmap with BS_BITMAP */ 6660 + hwnd = CreateWindowA("Button", "test", default_style | BS_BITMAP, 0, 0, 100, 100, 0, 0, 0, 0); 6661 + ok(hwnd != NULL, "Expect hwnd not NULL\n"); 6662 + SendMessageA(hwnd, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hbmp1x1); 6663 + hbmp = (HBITMAP)SendMessageA(hwnd, BM_GETIMAGE, (WPARAM)IMAGE_BITMAP, 0); 6664 + ok(hbmp != 0, "Expect hbmp not 0\n"); 6665 + ZeroMemory(&bm, sizeof(bm)); 6666 + ok(GetObjectW(hbmp, sizeof(bm), &bm), "Expect GetObjectW() success\n"); 6667 + ok(bm.bmWidth == 1 && bm.bmHeight == 1, "Expect bitmap size: %d,%d, got: %d,%d\n", 1, 1, 6668 + bm.bmWidth, bm.bmHeight); 6669 + DestroyWindow(hwnd); 6670 + 6671 + /* Set bitmap without BS_BITMAP */ 6672 + hwnd = CreateWindowA("Button", "test", default_style, 0, 0, 100, 100, 0, 0, 0, 0); 6673 + ok(hwnd != NULL, "Expect hwnd not NULL\n"); 6674 + ret = SendMessageA(hwnd, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hbmp1x1); 6675 + ok(ret == 0, "Expect ret to be 0\n"); 6676 + hbmp = (HBITMAP)SendMessageA(hwnd, BM_GETIMAGE, (WPARAM)IMAGE_BITMAP, 0); 6677 + ok(hbmp == NULL, "Expect hbmp to be NULL\n"); 6678 + DestroyWindow(hwnd); 6679 + 6680 + /* Set icon with BS_ICON */ 6681 + hwnd = CreateWindowA("Button", "test", default_style | BS_ICON, 0, 0, 100, 100, 0, 0, 0, 0); 6682 + ok(hwnd != NULL, "Expect hwnd not NULL\n"); 6683 + SendMessageA(hwnd, BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)hicon2x2); 6684 + hicon = (HICON)SendMessageA(hwnd, BM_GETIMAGE, (WPARAM)IMAGE_ICON, 0); 6685 + ok(hicon != NULL, "Expect hicon not NULL\n"); 6686 + ZeroMemory(&icon_info, sizeof(icon_info)); 6687 + ok(GetIconInfo(hicon, &icon_info), "Expect GetIconInfo() success\n"); 6688 + ZeroMemory(&bm, sizeof(bm)); 6689 + ok(GetObjectW(icon_info.hbmColor, sizeof(bm), &bm), "Expect GetObjectW() success\n"); 6690 + ok(bm.bmWidth == 2 && bm.bmHeight == 2, "Expect bitmap size: %d,%d, got: %d,%d\n", 2, 2, 6691 + bm.bmWidth, bm.bmHeight); 6692 + DeleteObject(icon_info.hbmColor); 6693 + DeleteObject(icon_info.hbmMask); 6694 + DestroyWindow(hwnd); 6695 + 6696 + /* Set icon without BS_ICON */ 6697 + hwnd = CreateWindowA("Button", "test", default_style, 0, 0, 100, 100, 0, 0, 0, 0); 6698 + ok(hwnd != NULL, "Expect hwnd not NULL\n"); 6699 + ret = SendMessageA(hwnd, BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)hicon2x2); 6700 + ok(ret == 0, "Expect ret to be 0\n"); 6701 + hicon = (HICON)SendMessageA(hwnd, BM_GETIMAGE, (WPARAM)IMAGE_ICON, 0); 6702 + ok(hicon == NULL, "Expect hicon to be NULL\n"); 6703 + DestroyWindow(hwnd); 6704 + 6705 + /* Set icon with BS_BITMAP */ 6706 + hwnd = CreateWindowA("Button", "test", default_style | BS_BITMAP, 0, 0, 100, 100, 0, 0, 0, 0); 6707 + ok(hwnd != NULL, "Expect hwnd to be not NULL\n"); 6708 + ret = SendMessageA(hwnd, BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)hicon2x2); 6709 + ok(ret == 0, "Expect ret to be 0\n"); 6710 + hicon = (HICON)SendMessageA(hwnd, BM_GETIMAGE, (WPARAM)IMAGE_ICON, 0); 6711 + ok(hicon == NULL, "Expect hicon to be NULL\n"); 6712 + DestroyWindow(hwnd); 6713 + 6714 + /* Set bitmap with BS_ICON */ 6715 + hwnd = CreateWindowA("Button", "test", default_style | BS_ICON, 0, 0, 100, 100, 0, 0, 0, 0); 6716 + ok(hwnd != NULL, "Expect hwnd to be not NULL\n"); 6717 + ret = SendMessageA(hwnd, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hbmp1x1); 6718 + ok(ret == 0, "Expect ret to be 0\n"); 6719 + hbmp = (HBITMAP)SendMessageA(hwnd, BM_GETIMAGE, (WPARAM)IMAGE_BITMAP, 0); 6720 + ok(hbmp == NULL, "Expect hbmp to be NULL\n"); 6721 + DestroyWindow(hwnd); 6722 + 6723 + DestroyIcon(hicon2x2); 6724 + DeleteObject(hmask2x2); 6725 + DeleteObject(hbmp2x2); 6726 + DeleteObject(hbmp1x1); 6727 + ReleaseDC(0, hdc); 6728 + } 6729 + 6622 6730 #define ID_RADIO1 501 6623 6731 #define ID_RADIO2 502 6624 6732 #define ID_RADIO3 503 ··· 7119 7227 7120 7228 subclass_static(); 7121 7229 7122 - for (i = 0; i < sizeof(static_ctrl)/sizeof(static_ctrl[0]); i++) 7230 + for (i = 0; i < ARRAY_SIZE(static_ctrl); i++) 7123 7231 { 7124 7232 hwnd = CreateWindowExA(0, "my_static_class", "test", static_ctrl[i].style | WS_POPUP, 7125 7233 0, 0, 50, 14, 0, 0, 0, NULL); ··· 7609 7717 HeapFree( GetProcessHeap(), 0, data ); 7610 7718 } 7611 7719 7612 - static void check_update_rgn( HWND hwnd, HRGN hrgn ) 7720 + #define check_update_rgn( hwnd, hrgn ) check_update_rgn_( __LINE__, hwnd, hrgn ) 7721 + static void check_update_rgn_( int line, HWND hwnd, HRGN hrgn ) 7613 7722 { 7614 7723 INT ret; 7615 7724 RECT r1, r2; ··· 7620 7729 ok( ret != ERROR, "GetUpdateRgn failed\n" ); 7621 7730 if (ret == NULLREGION) 7622 7731 { 7623 - ok( !hrgn, "Update region shouldn't be empty\n" ); 7732 + ok_(__FILE__,line)( !hrgn, "Update region shouldn't be empty\n" ); 7624 7733 } 7625 7734 else 7626 7735 { 7627 7736 if (CombineRgn( tmp, hrgn, update, RGN_XOR ) != NULLREGION) 7628 7737 { 7629 - ok( 0, "Regions are different\n" ); 7738 + ok_(__FILE__,line)( 0, "Regions are different\n" ); 7630 7739 if (winetest_debug > 0) 7631 7740 { 7632 7741 printf( "Update region: " ); ··· 7638 7747 } 7639 7748 GetRgnBox( update, &r1 ); 7640 7749 GetUpdateRect( hwnd, &r2, FALSE ); 7641 - ok( EqualRect( &r1, &r2 ), "Rectangles are different: %s / %s\n", wine_dbgstr_rect( &r1 ), 7642 - wine_dbgstr_rect( &r2 )); 7750 + ok_(__FILE__,line)( EqualRect( &r1, &r2 ), "Rectangles are different: %s / %s\n", 7751 + wine_dbgstr_rect( &r1 ), wine_dbgstr_rect( &r2 )); 7643 7752 7644 7753 DeleteObject( tmp ); 7645 7754 DeleteObject( update ); ··· 7835 7944 /* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws 7836 7945 * all windows and sends WM_ERASEBKGND and WM_NCPAINT. 7837 7946 */ 7838 - trace("testing InvalidateRect(0, NULL, FALSE)\n"); 7839 7947 SetRectEmpty( &rect ); 7840 - ok(InvalidateRect(0, &rect, FALSE), "InvalidateRect(0, &rc, FALSE) should fail\n"); 7948 + ok(InvalidateRect(0, &rect, FALSE), "InvalidateRect(0, &rc, FALSE) failed\n"); 7949 + check_update_rgn( hwnd, hrgn ); 7950 + ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE ); 7951 + flush_events(); 7952 + ok_sequence( WmPaint, "Paint", FALSE ); 7953 + RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE ); 7954 + check_update_rgn( hwnd, 0 ); 7955 + 7956 + SetRectEmpty( &rect ); 7957 + ok(RedrawWindow(0, &rect, 0, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW ), 7958 + "RedrawWindow failed\n"); 7959 + check_update_rgn( hwnd, 0 ); 7960 + 7961 + SetRectEmpty( &rect ); 7962 + ok(RedrawWindow(0, &rect, 0, RDW_ALLCHILDREN | RDW_VALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW ), 7963 + "RedrawWindow failed\n"); 7964 + check_update_rgn( hwnd, 0 ); 7965 + 7966 + GetWindowRect( hwnd, &rect ); 7967 + ok(RedrawWindow(0, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW ), 7968 + "RedrawWindow failed\n"); 7969 + check_update_rgn( hwnd, 0 ); 7970 + 7971 + flush_events(); 7972 + ok(RedrawWindow(0, &rect, 0, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW ), 7973 + "RedrawWindow failed\n"); 7974 + check_update_rgn( hwnd, hrgn ); 7975 + ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE ); 7976 + flush_events(); 7977 + ok_sequence( WmPaint, "Paint", FALSE ); 7978 + RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE ); 7979 + check_update_rgn( hwnd, 0 ); 7980 + 7981 + ok(RedrawWindow(GetDesktopWindow(), &rect, 0, 7982 + RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW ), 7983 + "RedrawWindow failed\n"); 7984 + ret = GetUpdateRgn( hwnd, hrgn2, FALSE ); 7985 + ok( ret == NULLREGION || broken(ret == SIMPLEREGION), /* <= win7 */ 7986 + "region should be null (%d)\n", ret ); 7987 + if (ret == SIMPLEREGION) ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE ); 7988 + RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE ); 7989 + flush_events(); 7990 + 7991 + ok(RedrawWindow(GetDesktopWindow(), NULL, 0, 7992 + RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW ), 7993 + "RedrawWindow failed\n"); 7994 + ret = GetUpdateRgn( hwnd, hrgn2, FALSE ); 7995 + ok( ret == NULLREGION || broken(ret == SIMPLEREGION), /* <= win7 */ 7996 + "region should be null (%d)\n", ret ); 7997 + if (ret == SIMPLEREGION) ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE ); 7998 + RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE ); 7999 + flush_events(); 8000 + 8001 + SetRectRgn( hrgn2, rect.left, rect.top, rect.right, rect.bottom ); 8002 + ok(RedrawWindow(0, NULL, hrgn2, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW ), 8003 + "RedrawWindow failed\n"); 8004 + check_update_rgn( hwnd, hrgn ); 8005 + ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE ); 8006 + flush_events(); 8007 + ok_sequence( WmPaint, "Paint", FALSE ); 8008 + RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE ); 8009 + check_update_rgn( hwnd, 0 ); 8010 + 8011 + ok(RedrawWindow(0, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_ERASENOW ), 8012 + "RedrawWindow failed\n"); 8013 + check_update_rgn( hwnd, 0 ); 8014 + 8015 + ok(RedrawWindow(0, NULL, 0, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_ERASE | RDW_ERASENOW ), 8016 + "RedrawWindow failed\n"); 7841 8017 check_update_rgn( hwnd, hrgn ); 7842 8018 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE ); 7843 8019 flush_events(); ··· 7848 8024 /* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws 7849 8025 * all windows and sends WM_ERASEBKGND and WM_NCPAINT. 7850 8026 */ 7851 - trace("testing ValidateRect(0, NULL)\n"); 7852 8027 SetRectEmpty( &rect ); 7853 8028 if (ValidateRect(0, &rect) && /* not supported on Win9x */ 7854 8029 GetUpdateRect(hwnd, NULL, FALSE)) /* or >= Win 8 */ ··· 7861 8036 check_update_rgn( hwnd, 0 ); 7862 8037 } 7863 8038 7864 - trace("testing InvalidateRgn(0, NULL, FALSE)\n"); 7865 8039 SetLastError(0xdeadbeef); 7866 8040 ok(!InvalidateRgn(0, NULL, FALSE), "InvalidateRgn(0, NULL, FALSE) should fail\n"); 7867 8041 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || GetLastError() == 0xdeadbeef, ··· 7870 8044 flush_events(); 7871 8045 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE ); 7872 8046 7873 - trace("testing ValidateRgn(0, NULL)\n"); 7874 8047 SetLastError(0xdeadbeef); 7875 8048 ok(!ValidateRgn(0, NULL), "ValidateRgn(0, NULL) should fail\n"); 7876 8049 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || ··· 7880 8053 flush_events(); 7881 8054 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE ); 7882 8055 7883 - trace("testing UpdateWindow(NULL)\n"); 7884 8056 SetLastError(0xdeadbeef); 7885 8057 ok(!UpdateWindow(NULL), "UpdateWindow(NULL) should fail\n"); 7886 8058 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || ··· 9565 9737 return ret; 9566 9738 } 9567 9739 9740 + static LRESULT WINAPI recursive_activation_wndprocA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 9741 + { 9742 + static LONG defwndproc_counter = 0; 9743 + struct recvd_message msg; 9744 + LRESULT ret; 9745 + 9746 + switch (message) 9747 + { 9748 + /* log only specific messages we are interested in */ 9749 + case WM_NCACTIVATE: 9750 + case WM_ACTIVATE: 9751 + case WM_SETFOCUS: 9752 + case WM_KILLFOCUS: 9753 + break; 9754 + default: 9755 + return DefWindowProcA(hwnd, message, wParam, lParam); 9756 + } 9757 + 9758 + msg.hwnd = hwnd; 9759 + msg.message = message; 9760 + msg.flags = sent|wparam|lparam; 9761 + if (defwndproc_counter) msg.flags |= defwinproc; 9762 + msg.wParam = wParam; 9763 + msg.lParam = lParam; 9764 + msg.descr = "recursive_activation"; 9765 + add_message(&msg); 9766 + 9767 + /* recursively activate ourselves by first losing activation and changing it back */ 9768 + if (message == WM_ACTIVATE && LOWORD(wParam) != WA_INACTIVE) 9769 + { 9770 + SetActiveWindow((HWND)lParam); 9771 + SetActiveWindow(hwnd); 9772 + return 0; 9773 + } 9774 + 9775 + defwndproc_counter++; 9776 + ret = DefWindowProcA(hwnd, message, wParam, lParam); 9777 + defwndproc_counter--; 9778 + 9779 + return ret; 9780 + } 9781 + 9568 9782 static LRESULT WINAPI PaintLoopProcA(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) 9569 9783 { 9570 9784 switch (msg) ··· 9660 9874 9661 9875 cls.lpfnWndProc = ShowWindowProcA; 9662 9876 cls.lpszClassName = "ShowWindowClass"; 9877 + if(!RegisterClassA(&cls)) return FALSE; 9878 + 9879 + cls.lpfnWndProc = recursive_activation_wndprocA; 9880 + cls.lpszClassName = "RecursiveActivationClass"; 9663 9881 if(!RegisterClassA(&cls)) return FALSE; 9664 9882 9665 9883 cls.lpfnWndProc = PopupMsgCheckProcA; ··· 9717 9935 { 9718 9936 if (!lstrcmpiA(buf, "TestWindowClass") || 9719 9937 !lstrcmpiA(buf, "ShowWindowClass") || 9938 + !lstrcmpiA(buf, "RecursiveActivationClass") || 9720 9939 !lstrcmpiA(buf, "TestParentClass") || 9721 9940 !lstrcmpiA(buf, "TestPopupClass") || 9722 9941 !lstrcmpiA(buf, "SimpleWindowClass") || ··· 10164 10383 win_skip("SetCoalescableTimer not available.\n"); 10165 10384 10166 10385 /* Check what happens when we're running out of timers */ 10167 - for (i=0; i<sizeof(ids)/sizeof(ids[0]); i++) 10386 + for (i = 0; i < ARRAY_SIZE(ids); i++) 10168 10387 { 10169 10388 SetLastError(0xdeadbeef); 10170 10389 ids[i] = SetTimer(NULL, 0, USER_TIMER_MAXIMUM, tfunc); 10171 10390 if (!ids[i]) break; 10172 10391 } 10173 - ok(i != sizeof(ids)/sizeof(ids[0]), "all timers were created successfully\n"); 10392 + ok(i != ARRAY_SIZE(ids), "all timers were created successfully\n"); 10174 10393 ok(GetLastError()==ERROR_NO_MORE_USER_HANDLES || broken(GetLastError()==0xdeadbeef), 10175 10394 "GetLastError() = %d\n", GetLastError()); 10176 10395 while (i > 0) KillTimer(NULL, ids[--i]); ··· 10548 10767 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE); 10549 10768 } 10550 10769 10551 - for (i = 0; i < sizeof(WmWinEventsSeq)/sizeof(WmWinEventsSeq[0]); i++) 10770 + for (i = 0; i < ARRAY_SIZE(WmWinEventsSeq); i++) 10552 10771 pNotifyWinEvent(events[i].message, hwnd, events[i].wParam, events[i].lParam); 10553 10772 10554 10773 ok_sequence(WmWinEventsSeq, "notify winevents", FALSE); ··· 12038 12257 qstatus = GetQueueStatus(qs_all_input); 12039 12258 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus); 12040 12259 } 12260 + 12261 + PostThreadMessageA(GetCurrentThreadId(), WM_USER, 0, 0); 12262 + ret = PeekMessageA(&msg, (HWND)-1, 0, 0, PM_NOREMOVE); 12263 + ok(ret == TRUE, "wrong ret %d\n", ret); 12264 + ok(msg.message == WM_USER, "wrong message %u\n", msg.message); 12265 + ret = GetMessageA(&msg, (HWND)-1, 0, 0); 12266 + ok(ret == TRUE, "wrong ret %d\n", ret); 12267 + ok(msg.message == WM_USER, "wrong message %u\n", msg.message); 12268 + 12269 + PostThreadMessageA(GetCurrentThreadId(), WM_USER, 0, 0); 12270 + ret = PeekMessageA(&msg, (HWND)1, 0, 0, PM_NOREMOVE); 12271 + ok(ret == TRUE, "wrong ret %d\n", ret); 12272 + ok(msg.message == WM_USER, "wrong message %u\n", msg.message); 12273 + ret = GetMessageA(&msg, (HWND)1, 0, 0); 12274 + ok(ret == TRUE, "wrong ret %d\n", ret); 12275 + ok(msg.message == WM_USER, "wrong message %u\n", msg.message); 12276 + 12277 + PostThreadMessageA(GetCurrentThreadId(), WM_USER, 0, 0); 12278 + ret = PeekMessageA(&msg, (HWND)0xffff, 0, 0, PM_NOREMOVE); 12279 + ok(ret == TRUE, "wrong ret %d\n", ret); 12280 + ok(msg.message == WM_USER, "wrong message %u\n", msg.message); 12281 + ret = GetMessageA(&msg, (HWND)0xffff, 0, 0); 12282 + ok(ret == TRUE, "wrong ret %d\n", ret); 12283 + ok(msg.message == WM_USER, "wrong message %u\n", msg.message); 12284 + 12041 12285 done: 12042 12286 trace("signalling to exit\n"); 12043 12287 SetEvent(info.hevent[EV_STOP]); ··· 13243 13487 ok(EqualRect(&win_rc, &wp.rcNormalPosition), "expected %s got %s\n", wine_dbgstr_rect(&win_rc), 13244 13488 wine_dbgstr_rect(&wp.rcNormalPosition)); 13245 13489 13246 - for (i = 0; i < sizeof(sw)/sizeof(sw[0]); i++) 13490 + for (i = 0; i < ARRAY_SIZE(sw); i++) 13247 13491 { 13248 13492 static const char * const sw_cmd_name[13] = 13249 13493 { ··· 13492 13736 { WM_QUERYNEWPALETTE, sent|parent|optional }, /* TODO: this message should not be sent */ 13493 13737 { WM_WINDOWPOSCHANGING, sent|parent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, 13494 13738 { WM_WINDOWPOSCHANGING, sent|parent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, 13739 + { WM_WINDOWPOSCHANGED, sent|parent|wparam|optional, SWP_NOREDRAW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, 13740 + { WM_WINDOWPOSCHANGED, sent|parent|wparam|optional, SWP_NOREDRAW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, 13495 13741 { WM_ACTIVATEAPP, sent|parent|wparam, 1 }, 13496 13742 { WM_NCACTIVATE, sent|parent }, 13497 13743 { WM_ACTIVATE, sent|parent|wparam, 1 }, ··· 15224 15470 { 0 } 15225 15471 }; 15226 15472 15473 + /* DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_RESTORE, 0) to minimized visible window */ 15474 + static const struct message WmRestoreMinimizedOverlappedSeq[] = 15475 + { 15476 + { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_RESTORE, 0 }, 15477 + { HCBT_MINMAX, hook }, 15478 + { WM_QUERYOPEN, sent }, 15479 + { WM_GETTEXT, sent|optional }, 15480 + { WM_NCACTIVATE, sent|optional }, 15481 + { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED }, 15482 + { WM_WINDOWPOSCHANGED, sent|optional }, 15483 + { WM_WINDOWPOSCHANGING, sent|optional }, 15484 + { WM_GETMINMAXINFO, sent|defwinproc }, 15485 + { WM_NCCALCSIZE, sent|optional }, 15486 + { WM_NCPAINT, sent|optional }, 15487 + { WM_GETTEXT, sent|defwinproc|optional }, 15488 + { WM_ERASEBKGND, sent|optional }, 15489 + { WM_WINDOWPOSCHANGED, sent|optional }, 15490 + { HCBT_ACTIVATE, hook }, 15491 + { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE }, 15492 + { WM_ACTIVATEAPP, sent|wparam, TRUE }, 15493 + { WM_NCACTIVATE, sent|wparam, TRUE }, 15494 + { WM_GETTEXT, sent|defwinproc|optional }, 15495 + { WM_ACTIVATE, sent|wparam, TRUE }, 15496 + { HCBT_SETFOCUS, hook }, 15497 + { WM_SETFOCUS, sent|defwinproc }, 15498 + { WM_NCPAINT, sent }, 15499 + { WM_GETTEXT, sent|defwinproc|optional }, 15500 + { WM_ERASEBKGND, sent }, 15501 + { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_FRAMECHANGED|SWP_STATECHANGED }, 15502 + { WM_MOVE, sent|defwinproc }, 15503 + { WM_SIZE, sent|defwinproc }, 15504 + { WM_NCCALCSIZE, sent|optional }, 15505 + { WM_NCPAINT, sent|optional }, 15506 + { WM_ERASEBKGND, sent|optional }, 15507 + { WM_ACTIVATE, sent|wparam, TRUE }, 15508 + { WM_SYNCPAINT, sent|optional }, 15509 + { WM_PAINT, sent }, 15510 + { 0 } 15511 + }; 15512 + 15227 15513 struct rbuttonup_thread_data 15228 15514 { 15229 15515 HWND hwnd; ··· 15262 15548 flush_events(); 15263 15549 15264 15550 buffA[0] = 0; 15265 - GetWindowTextA(hwnd, buffA, sizeof(buffA)/sizeof(*buffA)); 15551 + GetWindowTextA(hwnd, buffA, ARRAY_SIZE(buffA)); 15266 15552 ok(!strcmp(buffA, "test_defwndproc"), "unexpected window text, %s\n", buffA); 15267 15553 15268 15554 /* Zero high word of the lParam */ 15269 15555 res = DefWindowProcA(hwnd, WM_SETTEXT, 0, 0x1234); 15270 15556 ok(res == 0, "WM_SETTEXT was expected to fail, %ld\n", res); 15271 15557 15272 - GetWindowTextA(hwnd, buffA, sizeof(buffA)/sizeof(*buffA)); 15558 + GetWindowTextA(hwnd, buffA, ARRAY_SIZE(buffA)); 15273 15559 ok(!strcmp(buffA, "test_defwndproc"), "unexpected window text, %s\n", buffA); 15274 15560 15275 15561 res = DefWindowProcW(hwnd, WM_SETTEXT, 0, 0x1234); 15276 15562 ok(res == 0, "WM_SETTEXT was expected to fail, %ld\n", res); 15277 15563 15278 - GetWindowTextA(hwnd, buffA, sizeof(buffA)/sizeof(*buffA)); 15564 + GetWindowTextA(hwnd, buffA, ARRAY_SIZE(buffA)); 15279 15565 ok(!strcmp(buffA, "test_defwndproc"), "unexpected window text, %s\n", buffA); 15280 15566 15567 + ShowWindow(hwnd, SW_MINIMIZE); 15568 + flush_events(); 15569 + flush_sequence(); 15570 + 15571 + DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_RESTORE, 0); 15572 + flush_events(); 15573 + ok_sequence(WmRestoreMinimizedOverlappedSeq, "DefWindowProcA(SC_RESTORE):overlapped", TRUE); 15574 + flush_sequence(); 15575 + 15281 15576 GetCursorPos(&pos); 15282 15577 GetWindowRect(hwnd, &rect); 15283 15578 x = (rect.left+rect.right) / 2; ··· 15333 15628 DestroyWindow( hwnd); 15334 15629 } 15335 15630 15631 + static void test_desktop_winproc(void) 15632 + { 15633 + HINSTANCE instance = GetModuleHandleA(NULL); 15634 + RECT rect, default_rect; 15635 + WNDPROC desktop_proc; 15636 + char buffer[256]; 15637 + WNDCLASSA cls; 15638 + LRESULT res; 15639 + HWND hwnd; 15640 + BOOL ret; 15641 + 15642 + ret = GetClassInfoA(instance, (const CHAR *)MAKEINTATOM(32769), &cls); 15643 + ok(ret, "Failed to get desktop class.\n"); 15644 + desktop_proc = cls.lpfnWndProc; 15645 + 15646 + memset(&cls, 0, sizeof(cls)); 15647 + cls.lpfnWndProc = desktop_proc; 15648 + cls.hInstance = instance; 15649 + cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); 15650 + cls.hbrBackground = GetStockObject(WHITE_BRUSH); 15651 + cls.lpszClassName = "TestDesktopClass"; 15652 + ret = !!RegisterClassA(&cls); 15653 + ok(ret, "Failed to register class.\n"); 15654 + 15655 + hwnd = CreateWindowExA(0, cls.lpszClassName, "test_desktop_wndproc", 15656 + WS_VISIBLE | WS_CAPTION | WS_OVERLAPPEDWINDOW, 0, 0, 500, 100, 0, 0, 0, NULL); 15657 + if (!hwnd) /* win2003 */ 15658 + { 15659 + skip("Failed to create window with desktop window procedure.\n"); 15660 + goto out_unregister; 15661 + } 15662 + 15663 + memset(&cls, 0, sizeof(cls)); 15664 + ret = GetClassInfoA(instance, "TestDesktopClass", &cls); 15665 + ok(ret, "Failed to get class info.\n"); 15666 + ok(cls.lpfnWndProc == desktop_proc, "Got %p, expected %p.\n", cls.lpfnWndProc, desktop_proc); 15667 + 15668 + GetWindowTextA(hwnd, buffer, ARRAY_SIZE(buffer)); 15669 + todo_wine ok(!strcmp(buffer, "test_desktop_wndproc"), "Got unexpected window text: %s.\n", buffer); 15670 + 15671 + res = CallWindowProcA(desktop_proc, hwnd, WM_SETTEXT, 0, (LPARAM)"test"); 15672 + ok(res == TRUE, "Failed to set text, %ld.\n", res); 15673 + GetWindowTextA(hwnd, buffer, ARRAY_SIZE(buffer)); 15674 + ok(!strcmp(buffer, "test"), "Got unexpected window text: %s.\n", buffer); 15675 + 15676 + SetRect(&default_rect, 0, 0, 100, 100); 15677 + res = DefWindowProcW(hwnd, WM_NCCALCSIZE, FALSE, (LPARAM)&default_rect); 15678 + ok(!res, "Got unexpected result %ld.\n", res); 15679 + 15680 + SetRect(&rect, 0, 0, 100, 100); 15681 + res = CallWindowProcA(desktop_proc, hwnd, WM_NCCALCSIZE, FALSE, (LPARAM)&rect); 15682 + ok(!res, "Got unexpected result %ld.\n", res); 15683 + todo_wine ok(EqualRect(&rect, &default_rect), "rect Got %s, expected %s.\n", 15684 + wine_dbgstr_rect(&rect), wine_dbgstr_rect(&default_rect)); 15685 + 15686 + DestroyWindow(hwnd); 15687 + 15688 + out_unregister: 15689 + UnregisterClassA("TestDesktopClass", instance); 15690 + } 15691 + 15336 15692 #define clear_clipboard(hwnd) clear_clipboard_(__LINE__, (hwnd)) 15337 15693 static void clear_clipboard_(int line, HWND hWnd) 15338 15694 { ··· 15535 15891 PostMessageA(hwnd, WM_USER+1, 0x1234, 0x5678); 15536 15892 PostMessageA(0, WM_USER+2, 0x5678, 0x1234); 15537 15893 15538 - for (i = 0; i < sizeof(data)/sizeof(data[0]); i++) 15894 + for (i = 0; i < ARRAY_SIZE(data); i++) 15539 15895 { 15540 15896 memset(&msg, 0xab, sizeof(msg)); 15541 15897 ret = PeekMessageA(&msg, data[i].hwnd, 0, 0, PM_NOREMOVE); ··· 15593 15949 oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC, (LONG_PTR)broadcast_test_proc); 15594 15950 SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)oldproc); 15595 15951 15596 - for (i = 0; i < sizeof(messages)/sizeof(messages[0]); i++) 15952 + for (i = 0; i < ARRAY_SIZE(messages); i++) 15597 15953 { 15598 15954 BOOL ret; 15599 15955 MSG msg; ··· 15923 16279 15924 16280 thread = CreateThread( NULL, 0, wait_idle_thread, NULL, 0, &id ); 15925 16281 15926 - for (i = 0; i < sizeof(wait_idle_expect)/sizeof(wait_idle_expect[0]); i++) 16282 + for (i = 0; i < ARRAY_SIZE(wait_idle_expect); i++) 15927 16283 { 15928 16284 ResetEvent( start_event ); 15929 16285 ResetEvent( end_event ); 15930 - #ifndef __REACTOS__ 15931 - sprintf( path, "%s msg %u", argv0, i ); 15932 - #else 16286 + #ifdef __REACTOS__ 15933 16287 sprintf( path, "%s msg_queue %u", argv0, i ); 16288 + #else 16289 + sprintf( path, "%s msg %u", argv0, i ); 15934 16290 #endif 15935 16291 ret = CreateProcessA( NULL, path, NULL, NULL, TRUE, 0, NULL, NULL, &startup, &pi ); 15936 16292 ok( ret, "CreateProcess '%s' failed err %u.\n", path, GetLastError() ); ··· 16039 16395 16040 16396 SetParent(child, parent2); 16041 16397 flush_events(); 16042 - ok_sequence(WmSetParentSeq_1, "SetParent() visible WS_CHILD", TRUE); 16398 + ok_sequence(WmSetParentSeq_1, "SetParent() visible WS_CHILD", FALSE); 16043 16399 16044 16400 ok(GetWindowLongA(child, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n"); 16045 16401 ok(!IsWindowVisible(child), "IsWindowVisible() should return FALSE\n"); ··· 16314 16670 16315 16671 SetLastError(0xdeadbeef); 16316 16672 ret = UnregisterHotKey(NULL, 0); 16317 - ok(ret == FALSE, "expected FALSE, got %i\n", ret); 16318 - ok(GetLastError() == ERROR_HOTKEY_NOT_REGISTERED || broken(GetLastError() == 0xdeadbeef), 16319 - "unexpected error %d\n", GetLastError()); 16320 - 16321 16673 if (ret == TRUE) 16322 16674 { 16323 16675 skip("hotkeys not supported\n"); 16324 16676 return; 16325 16677 } 16678 + 16679 + ok(ret == FALSE, "expected FALSE, got %i\n", ret); 16680 + ok(GetLastError() == ERROR_HOTKEY_NOT_REGISTERED || broken(GetLastError() == 0xdeadbeef), 16681 + "unexpected error %d\n", GetLastError()); 16326 16682 16327 16683 test_window = CreateWindowExA(0, "HotkeyWindowClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE, 16328 16684 100, 100, 200, 200, 0, 0, 0, NULL); ··· 17344 17700 DestroyWindow(hwnd); 17345 17701 } 17346 17702 17703 + static const struct message WmRestoreMinimizedSeq[] = 17704 + { 17705 + { HCBT_ACTIVATE, hook }, 17706 + { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE }, 17707 + { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, 17708 + { WM_ACTIVATEAPP, sent|wparam, 1 }, 17709 + { WM_NCACTIVATE, sent|wparam, 0x200001 }, 17710 + { WM_GETTEXT, sent|defwinproc|optional }, 17711 + { WM_ACTIVATE, sent|wparam, 0x200001 }, /* Note that activate messages are after WM_WINDOWPOSCHANGED and before WM_SYSCOMMAND */ 17712 + { HCBT_KEYSKIPPED, hook|optional }, 17713 + { WM_SYSKEYUP, sent|optional }, 17714 + { WM_SYSCOMMAND, sent|wparam, SC_RESTORE }, 17715 + { HCBT_SYSCOMMAND, hook|wparam, SC_RESTORE }, 17716 + { HCBT_SYSCOMMAND, hook|wparam|optional, SC_RESTORE }, 17717 + { HCBT_MINMAX, hook }, 17718 + { HCBT_MINMAX, hook|optional }, 17719 + { WM_QUERYOPEN, sent|defwinproc }, 17720 + { WM_QUERYOPEN, sent|optional }, 17721 + { WM_GETTEXT, sent|defwinproc|optional }, 17722 + { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED }, 17723 + { WM_GETMINMAXINFO, sent|defwinproc }, 17724 + { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 }, 17725 + { WM_NCPAINT, sent|wparam|defwinproc|optional, 1 }, 17726 + { WM_GETTEXT, sent|defwinproc|optional }, 17727 + { WM_ERASEBKGND, sent|defwinproc }, 17728 + { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED }, 17729 + { WM_MOVE, sent|defwinproc }, 17730 + { WM_SIZE, sent|defwinproc }, 17731 + { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 }, 17732 + { WM_NCPAINT, sent|wparam|defwinproc|optional, 1 }, 17733 + { WM_ERASEBKGND, sent|defwinproc|optional }, 17734 + { HCBT_SETFOCUS, hook }, 17735 + { WM_SETFOCUS, sent|defwinproc }, 17736 + { WM_ACTIVATE, sent|wparam|defwinproc, 1 }, 17737 + { WM_PAINT, sent| optional }, 17738 + { WM_SETFOCUS, sent|defwinproc|optional }, 17739 + { HCBT_KEYSKIPPED, hook|optional }, 17740 + { WM_KEYUP, sent|optional }, 17741 + { HCBT_KEYSKIPPED, hook|optional }, 17742 + { WM_SYSKEYUP, sent|optional }, 17743 + { HCBT_KEYSKIPPED, hook|optional }, 17744 + { WM_KEYUP, sent|optional }, 17745 + { WM_PAINT, sent| optional }, 17746 + { 0 } 17747 + }; 17748 + 17749 + static void test_restore_messages(void) 17750 + { 17751 + INPUT ip = {0}; 17752 + HWND hwnd; 17753 + INT i; 17754 + 17755 + hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 17756 + 100, 200, 200, 0, 0, 0, NULL); 17757 + ok (hwnd != 0, "Failed to create overlapped window\n"); 17758 + SetForegroundWindow(hwnd); 17759 + ShowWindow(hwnd, SW_MINIMIZE); 17760 + flush_events(); 17761 + flush_sequence(); 17762 + 17763 + for (i = 0; i < 5; i++) 17764 + { 17765 + /* Send Alt+Tab to restore test window from minimized state */ 17766 + ip.type = INPUT_KEYBOARD; 17767 + ip.ki.wVk = VK_MENU; 17768 + SendInput(1, &ip, sizeof(INPUT)); 17769 + ip.ki.wVk = VK_TAB; 17770 + SendInput(1, &ip, sizeof(INPUT)); 17771 + ip.ki.wVk = VK_MENU; 17772 + ip.ki.dwFlags = KEYEVENTF_KEYUP; 17773 + SendInput(1, &ip, sizeof(INPUT)); 17774 + ip.ki.wVk = VK_TAB; 17775 + ip.ki.dwFlags = KEYEVENTF_KEYUP; 17776 + SendInput(1, &ip, sizeof(INPUT)); 17777 + flush_events(); 17778 + if (!IsIconic(hwnd)) 17779 + break; 17780 + } 17781 + 17782 + if (IsIconic(hwnd)) 17783 + { 17784 + skip("Alt+Tab failed to bring up test window.\n"); 17785 + goto done; 17786 + } 17787 + ok_sequence(WmRestoreMinimizedSeq, "Restore minimized window", TRUE); 17788 + 17789 + done: 17790 + DestroyWindow(hwnd); 17791 + } 17792 + 17793 + static void test_invalid_window(void) 17794 + { 17795 + MSG msg; 17796 + BOOL ret; 17797 + 17798 + SetLastError(0xdeadbeef); 17799 + ret = GetMessageA(&msg, (HWND)0xdeadbeef, 0, 0); 17800 + ok(ret == -1, "wrong ret %d\n", ret); 17801 + ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError()); 17802 + 17803 + SetLastError(0xdeadbeef); 17804 + ret = PeekMessageA(&msg, (HWND)0xdeadbeef, 0, 0, PM_REMOVE); 17805 + ok(!ret, "wrong ret %d\n", ret); 17806 + ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError()); 17807 + } 17808 + 17347 17809 static void init_funcs(void) 17348 17810 { 17349 17811 HMODULE hKernel32 = GetModuleHandleA("kernel32.dll"); ··· 17440 17902 test_messages(); 17441 17903 test_setwindowpos(); 17442 17904 test_showwindow(); 17905 + test_recursive_activation(); 17443 17906 invisible_parent_tests(); 17444 17907 test_mdi_messages(); 17445 17908 test_button_messages(); 17909 + test_button_bm_get_set_image(); 17446 17910 test_autoradio_BM_CLICK(); 17447 17911 test_autoradio_kbd_move(); 17448 17912 test_static_messages(); ··· 17468 17932 test_quit_message(); 17469 17933 test_notify_message(); 17470 17934 test_SetActiveWindow(); 17935 + test_restore_messages(); 17936 + test_invalid_window(); 17471 17937 17472 17938 if (!pTrackMouseEvent) 17473 17939 win_skip("TrackMouseEvent is not available\n"); ··· 17484 17950 test_menu_messages(); 17485 17951 test_paintingloop(); 17486 17952 test_defwinproc(); 17953 + test_desktop_winproc(); 17487 17954 test_clipboard_viewers(); 17488 17955 test_keyflags(); 17489 17956 test_hotkey(); ··· 17598 18065 test_dbcs_wm_char(); 17599 18066 test_unicode_wm_char(); 17600 18067 test_defwinproc(); 18068 + test_desktop_winproc(); 17601 18069 cleanup_tests(); 17602 18070 } 17603 18071 ··· 17619 18087 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0); 17620 18088 flush_events(); 17621 18089 18090 + test_restore_messages(); 18091 + test_invalid_window(); 18092 + 17622 18093 test_DoubleSetCapture(); 17623 18094 17624 18095 /* keep it the last test, under Windows it tends to break the tests ··· 17635 18106 test_ShowWindow(); 17636 18107 test_setwindowpos(); 17637 18108 test_showwindow(); 18109 + test_recursive_activation(); 17638 18110 test_SetWindowRgn(); 17639 18111 invisible_parent_tests(); 17640 18112 cleanup_tests(); ··· 17745 18217 { 17746 18218 init_tests(); 17747 18219 test_button_messages(); 18220 + test_button_bm_get_set_image(); 17748 18221 test_autoradio_BM_CLICK(); 17749 18222 test_autoradio_kbd_move(); 17750 18223 test_static_messages();
+101
modules/rostests/winetests/user32/rawinput.c
··· 1 + /* Unit test suite for rawinput. 2 + * 3 + * Copyright 2019 Remi Bernon for CodeWeavers 4 + * 5 + * This library is free software; you can redistribute it and/or 6 + * modify it under the terms of the GNU Lesser General Public 7 + * License as published by the Free Software Foundation; either 8 + * version 2.1 of the License, or (at your option) any later version. 9 + * 10 + * This library is distributed in the hope that it will be useful, 11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 + * Lesser General Public License for more details. 14 + * 15 + * You should have received a copy of the GNU Lesser General Public 16 + * License along with this library; if not, write to the Free Software 17 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 18 + */ 19 + 20 + #include <stdarg.h> 21 + #include <stdio.h> 22 + 23 + #define STRICT 24 + #define WIN32_LEAN_AND_MEAN 25 + #include <windows.h> 26 + 27 + #include "wine/test.h" 28 + 29 + static void test_RegisterRawInputDevices(void) 30 + { 31 + HWND hwnd; 32 + RAWINPUTDEVICE raw_devices[1]; 33 + BOOL res; 34 + 35 + raw_devices[0].usUsagePage = 0x01; 36 + raw_devices[0].usUsage = 0x05; 37 + 38 + hwnd = CreateWindowExA(WS_EX_TOPMOST, "static", "dinput", WS_POPUP | WS_VISIBLE, 0, 0, 100, 100, NULL, NULL, NULL, NULL); 39 + ok(hwnd != NULL, "CreateWindowExA failed\n"); 40 + 41 + 42 + res = RegisterRawInputDevices(NULL, 0, 0); 43 + ok(res == FALSE, "RegisterRawInputDevices succeeded\n"); 44 + 45 + 46 + raw_devices[0].dwFlags = 0; 47 + raw_devices[0].hwndTarget = 0; 48 + 49 + SetLastError(0xdeadbeef); 50 + res = RegisterRawInputDevices(raw_devices, ARRAY_SIZE(raw_devices), 0); 51 + ok(res == FALSE, "RegisterRawInputDevices succeeded\n"); 52 + ok(GetLastError() == ERROR_INVALID_PARAMETER, "RegisterRawInputDevices returned %08x\n", GetLastError()); 53 + 54 + SetLastError(0xdeadbeef); 55 + res = RegisterRawInputDevices(raw_devices, ARRAY_SIZE(raw_devices), sizeof(RAWINPUTDEVICE)); 56 + ok(res == TRUE, "RegisterRawInputDevices failed\n"); 57 + ok(GetLastError() == 0xdeadbeef, "RegisterRawInputDevices returned %08x\n", GetLastError()); 58 + 59 + 60 + /* RIDEV_REMOVE requires hwndTarget == NULL */ 61 + raw_devices[0].dwFlags = RIDEV_REMOVE; 62 + raw_devices[0].hwndTarget = hwnd; 63 + 64 + SetLastError(0xdeadbeef); 65 + res = RegisterRawInputDevices(raw_devices, ARRAY_SIZE(raw_devices), sizeof(RAWINPUTDEVICE)); 66 + ok(res == FALSE, "RegisterRawInputDevices succeeded\n"); 67 + ok(GetLastError() == ERROR_INVALID_PARAMETER, "RegisterRawInputDevices returned %08x\n", GetLastError()); 68 + 69 + raw_devices[0].hwndTarget = 0; 70 + 71 + SetLastError(0xdeadbeef); 72 + res = RegisterRawInputDevices(raw_devices, ARRAY_SIZE(raw_devices), sizeof(RAWINPUTDEVICE)); 73 + ok(res == TRUE, "RegisterRawInputDevices failed\n"); 74 + ok(GetLastError() == 0xdeadbeef, "RegisterRawInputDevices returned %08x\n", GetLastError()); 75 + 76 + 77 + /* RIDEV_INPUTSINK requires hwndTarget != NULL */ 78 + raw_devices[0].dwFlags = RIDEV_INPUTSINK; 79 + raw_devices[0].hwndTarget = 0; 80 + 81 + SetLastError(0xdeadbeef); 82 + res = RegisterRawInputDevices(raw_devices, ARRAY_SIZE(raw_devices), sizeof(RAWINPUTDEVICE)); 83 + todo_wine 84 + ok(res == FALSE, "RegisterRawInputDevices failed\n"); 85 + todo_wine 86 + ok(GetLastError() == ERROR_INVALID_PARAMETER, "RegisterRawInputDevices returned %08x\n", GetLastError()); 87 + 88 + raw_devices[0].hwndTarget = hwnd; 89 + 90 + SetLastError(0xdeadbeef); 91 + res = RegisterRawInputDevices(raw_devices, ARRAY_SIZE(raw_devices), sizeof(RAWINPUTDEVICE)); 92 + ok(res == TRUE, "RegisterRawInputDevices succeeded\n"); 93 + ok(GetLastError() == 0xdeadbeef, "RegisterRawInputDevices returned %08x\n", GetLastError()); 94 + 95 + DestroyWindow(hwnd); 96 + } 97 + 98 + START_TEST(rawinput) 99 + { 100 + test_RegisterRawInputDevices(); 101 + }
+2 -2
modules/rostests/winetests/user32/resource.c
··· 50 50 win_skip( "LoadStringW does not return a pointer to the resource\n" ); 51 51 return; 52 52 } 53 - length2 = LoadStringW(hInst, 2, returnedstringw, sizeof(returnedstringw) /sizeof(WCHAR)); /* get resource string */ 53 + length2 = LoadStringW(hInst, 2, returnedstringw, ARRAY_SIZE(returnedstringw)); /* get resource string */ 54 54 ok(length2 > 0, "LoadStringW failed to load resource 2, ret %d, err %d\n", length2, GetLastError()); 55 55 ok(length1 == length2, "LoadStringW returned different values dependent on buflen. ret1 %d, ret2 %d\n", 56 56 length1, length2); ··· 93 93 int ret, ret2; 94 94 95 95 assert (sizeof str < sizeof buf); 96 - for (i = 0; i < sizeof tests / sizeof tests[0]; i++) { 96 + for (i = 0; i < ARRAY_SIZE(tests); i++) { 97 97 const unsigned int bufsiz = tests[i].bufsiz; 98 98 const unsigned int expected = tests[i].expected; 99 99 const int len = LoadStringA (hInst, 0, buf, bufsiz);
+9
modules/rostests/winetests/user32/resource.rc
··· 237 237 CONTROL "oddlengthtext", -1, "TESTCONTROL", WS_CHILD|WS_VISIBLE|WS_BORDER|WS_TABSTOP, 10,60,100,50 { 1,2,3,4,5 } 238 238 } 239 239 240 + GETDLGITEM_TEST_DIALOG DIALOGEX 6, 15, 207, 111 241 + STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU 242 + CAPTION "Test Dialog" 243 + FONT 8, "MS Shell Dlg" 244 + { 245 + LTEXT "Text1",-1,10,10,100,50 246 + LTEXT "Text2",-2,10,10,100,50 247 + } 248 + 240 249 /* @makedep: test_mono.bmp */ 241 250 100 BITMAP test_mono.bmp 242 251
+122 -1
modules/rostests/winetests/user32/scroll.c
··· 114 114 ok( ret, "The scrollbar should be enabled.\n" ); 115 115 ok( IsWindowEnabled( hScroll ), "The scrollbar window should be enabled.\n" ); 116 116 117 + SetLastError( 0xdeadbeef ); 118 + ret = EnableScrollBar( mainwnd, SB_CTL, ESB_ENABLE_BOTH ); 119 + ok( !ret, "EnableScrollBar should fail.\n" ); 120 + todo_wine 121 + ok( GetLastError() == ERROR_INVALID_PARAMETER 122 + || broken(GetLastError() == 0xdeadbeef), /* winxp */ 123 + "GetLastError() = %u\n", GetLastError() ); 124 + 117 125 /* disable window, try to re-enable */ 118 126 ret = EnableWindow( hScroll, FALSE ); 119 127 ok( !ret, "got %d\n", ret ); ··· 170 178 ret = GetScrollPos( hScroll, SB_CTL); 171 179 ok( ret == 30, "The position should not be equal to zero\n"); 172 180 181 + SetLastError( 0xdeadbeef ); 182 + ret = SetScrollPos( mainwnd, SB_CTL, 30, TRUE ); 183 + ok( !ret, "The position should not be set.\n" ); 184 + ok( GetLastError() == 0xdeadbeef, "GetLastError() = %u\n", GetLastError() ); 185 + 186 + SetLastError( 0xdeadbeef ); 187 + ret = GetScrollPos( mainwnd, SB_CTL ); 188 + ok( !ret, "The position should be equal to zero\n"); 189 + ok( GetLastError() == 0xdeadbeef, "GetLastError() = %u\n", GetLastError() ); 190 + 173 191 DestroyWindow(hScroll); 174 192 DestroyWindow(mainwnd); 175 193 } ··· 191 209 192 210 ret = ShowScrollBar( NULL, SB_CTL, TRUE ); 193 211 ok( !ret, "The ShowScrollBar() should failed.\n" ); 212 + 213 + ret = ShowScrollBar( mainwnd, SB_CTL, TRUE ); 214 + ok( ret, "The ShowScrollBar() should not fail.\n" ); 194 215 195 216 DestroyWindow(hScroll); 196 217 DestroyWindow(mainwnd); ··· 514 535 wc.lpfnWndProc = scroll_init_proc; 515 536 RegisterClassExA(&wc); 516 537 517 - for(i = 0; i < sizeof style / sizeof style[0]; i++) 538 + for(i = 0; i < ARRAY_SIZE(style); i++) 518 539 { 519 540 /* need not to destroy these windows due creation abort */ 520 541 CreateWindowExA(0, cls_name, NULL, style[i], ··· 581 602 DestroyWindow(mainwnd); 582 603 } 583 604 605 + static WNDPROC scrollbar_wndproc; 606 + 607 + static SCROLLINFO set_scrollinfo; 608 + 609 + static LRESULT CALLBACK subclass_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) 610 + { 611 + if (msg == WM_CREATE && ((CREATESTRUCTA*)lparam)->lpCreateParams) 612 + return DefWindowProcA(hwnd, msg, wparam, lparam); 613 + 614 + if (msg == SBM_SETSCROLLINFO) 615 + set_scrollinfo = *(SCROLLINFO*)lparam; 616 + 617 + return CallWindowProcA(scrollbar_wndproc, hwnd, msg, wparam, lparam); 618 + } 619 + 620 + static void test_subclass(void) 621 + { 622 + SCROLLBARINFO scroll_info; 623 + WNDCLASSEXA class_info; 624 + WNDCLASSA wc; 625 + LRESULT res; 626 + HWND hwnd; 627 + BOOL r; 628 + 629 + r = GetClassInfoExA(GetModuleHandleA(NULL), "SCROLLBAR", &class_info); 630 + ok(r, "GetClassInfoEx failed: %u\n", GetLastError()); 631 + scrollbar_wndproc = class_info.lpfnWndProc; 632 + 633 + memset(&wc, 0, sizeof(wc)); 634 + wc.cbWndExtra = class_info.cbWndExtra + 3; /* more space than needed works */ 635 + wc.hInstance = GetModuleHandleA(NULL); 636 + wc.lpszClassName = "MyTestSubclass"; 637 + wc.lpfnWndProc = subclass_proc; 638 + r = RegisterClassA(&wc); 639 + ok(r, "RegisterClass failed: %u\n", GetLastError()); 640 + 641 + hwnd = CreateWindowExA( 0, "MyTestSubclass", "Scroll", WS_OVERLAPPEDWINDOW, 642 + CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, NULL, NULL, GetModuleHandleA(NULL), 0 ); 643 + ok(hwnd != NULL, "Failed to create window: %u\n", GetLastError()); 644 + 645 + r = SetScrollRange(hwnd, SB_CTL, 0, 100, TRUE); 646 + ok(r, "SetScrollRange failed: %u\n", GetLastError()); 647 + 648 + res = SetScrollPos(hwnd, SB_CTL, 2, FALSE); 649 + ok(!res, "SetScrollPos returned %lu\n", res); 650 + 651 + memset(&set_scrollinfo, 0xcc, sizeof(set_scrollinfo)); 652 + res = SetScrollPos(hwnd, SB_CTL, 1, FALSE); 653 + ok(res == 2, "SetScrollPos returned %lu\n", res); 654 + ok(set_scrollinfo.cbSize == sizeof(SCROLLINFO), "cbSize = %u\n", set_scrollinfo.cbSize); 655 + todo_wine 656 + ok(set_scrollinfo.fMask == (0x1000 | SIF_POS), "fMask = %x\n", set_scrollinfo.fMask); 657 + ok(set_scrollinfo.nPos == 1, "nPos = %x\n", set_scrollinfo.nPos); 658 + 659 + memset(&scroll_info, 0xcc, sizeof(scroll_info)); 660 + scroll_info.cbSize = sizeof(scroll_info); 661 + res = SendMessageA(hwnd, SBM_GETSCROLLBARINFO, 0, (LPARAM)&scroll_info); 662 + ok(res == 1, "SBM_GETSCROLLBARINFO returned %lu\n", res); 663 + 664 + DestroyWindow(hwnd); 665 + 666 + /* if we skip calling wndproc for WM_CREATE, window is not considered a scrollbar */ 667 + hwnd = CreateWindowExA( 0, "MyTestSubclass", "Scroll", WS_OVERLAPPEDWINDOW, 668 + CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, NULL, NULL, GetModuleHandleA(NULL), (void *)1 ); 669 + ok(hwnd != NULL, "Failed to create window: %u\n", GetLastError()); 670 + 671 + memset(&scroll_info, 0xcc, sizeof(scroll_info)); 672 + scroll_info.cbSize = sizeof(scroll_info); 673 + res = SendMessageA(hwnd, SBM_GETSCROLLBARINFO, 0, (LPARAM)&scroll_info); 674 + ok(!res, "SBM_GETSCROLLBARINFO returned %lu\n", res); 675 + 676 + DestroyWindow(hwnd); 677 + 678 + /* not enough space in extra data */ 679 + wc.cbWndExtra = class_info.cbWndExtra - 1; 680 + wc.lpszClassName = "MyTestSubclass2"; 681 + r = RegisterClassA(&wc); 682 + ok(r, "RegisterClass failed: %u\n", GetLastError()); 683 + 684 + hwnd = CreateWindowExA( 0, "MyTestSubclass2", "Scroll", WS_OVERLAPPEDWINDOW, 685 + CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, NULL, NULL, GetModuleHandleA(NULL), 0 ); 686 + ok(hwnd != NULL, "Failed to create window: %u\n", GetLastError()); 687 + 688 + memset(&scroll_info, 0xcc, sizeof(scroll_info)); 689 + scroll_info.cbSize = sizeof(scroll_info); 690 + res = SendMessageA(hwnd, SBM_GETSCROLLBARINFO, 0, (LPARAM)&scroll_info); 691 + ok(!res, "SBM_GETSCROLLBARINFO returned %lu\n", res); 692 + 693 + memset(&set_scrollinfo, 0xcc, sizeof(set_scrollinfo)); 694 + res = SetScrollPos(hwnd, SB_CTL, 1, FALSE); 695 + ok(res == 0, "SetScrollPos returned %lu\n", res); 696 + ok(set_scrollinfo.cbSize == sizeof(SCROLLINFO), "cbSize = %u\n", set_scrollinfo.cbSize); 697 + todo_wine 698 + ok(set_scrollinfo.fMask == (0x1000 | SIF_POS), "fMask = %x\n", set_scrollinfo.fMask); 699 + ok(set_scrollinfo.nPos == 1, "nPos = %x\n", set_scrollinfo.nPos); 700 + 701 + DestroyWindow(hwnd); 702 + } 703 + 584 704 START_TEST ( scroll ) 585 705 { 586 706 WNDCLASSA wc; ··· 605 725 test_GetScrollBarInfo(); 606 726 scrollbar_test_track(); 607 727 test_SetScrollInfo(); 728 + test_subclass(); 608 729 609 730 /* Some test results vary depending of theming being active or not */ 610 731 hUxtheme = LoadLibraryA("uxtheme.dll");
+1003 -111
modules/rostests/winetests/user32/sysparams.c
··· 43 43 static LONG (WINAPI *pChangeDisplaySettingsExA)(LPCSTR, LPDEVMODEA, HWND, DWORD, LPVOID); 44 44 static BOOL (WINAPI *pIsProcessDPIAware)(void); 45 45 static BOOL (WINAPI *pSetProcessDPIAware)(void); 46 + static BOOL (WINAPI *pSetProcessDpiAwarenessContext)(DPI_AWARENESS_CONTEXT); 47 + static BOOL (WINAPI *pGetProcessDpiAwarenessInternal)(HANDLE,DPI_AWARENESS*); 48 + static BOOL (WINAPI *pSetProcessDpiAwarenessInternal)(DPI_AWARENESS); 49 + static UINT (WINAPI *pGetDpiForSystem)(void); 50 + static UINT (WINAPI *pGetDpiForWindow)(HWND); 51 + static BOOL (WINAPI *pGetDpiForMonitorInternal)(HMONITOR,UINT,UINT*,UINT*); 52 + static DPI_AWARENESS_CONTEXT (WINAPI *pGetThreadDpiAwarenessContext)(void); 53 + static DPI_AWARENESS_CONTEXT (WINAPI *pSetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT); 54 + static DPI_AWARENESS_CONTEXT (WINAPI *pGetWindowDpiAwarenessContext)(HWND); 55 + static DPI_AWARENESS (WINAPI *pGetAwarenessFromDpiAwarenessContext)(DPI_AWARENESS_CONTEXT); 56 + static BOOL (WINAPI *pIsValidDpiAwarenessContext)(DPI_AWARENESS_CONTEXT); 57 + static INT (WINAPI *pGetSystemMetricsForDpi)(INT,UINT); 58 + static BOOL (WINAPI *pSystemParametersInfoForDpi)(UINT,UINT,void*,UINT,UINT); 59 + static BOOL (WINAPI *pAdjustWindowRectExForDpi)(LPRECT,DWORD,BOOL,DWORD,UINT); 60 + static BOOL (WINAPI *pLogicalToPhysicalPointForPerMonitorDPI)(HWND,POINT*); 61 + static BOOL (WINAPI *pPhysicalToLogicalPointForPerMonitorDPI)(HWND,POINT*); 46 62 static LONG (WINAPI *pGetAutoRotationState)(PAR_STATE); 47 63 48 64 static BOOL strict; 49 65 static int dpi, real_dpi; 50 - static BOOL iswin9x; 51 - static HDC hdc; 52 66 53 67 #define eq(received, expected, label, type) \ 54 68 ok((received) == (expected), "%s: got " type " instead of " type "\n", (label),(received),(expected)) ··· 193 207 { 194 208 DWORD dpi; 195 209 210 + if (pSetThreadDpiAwarenessContext) 211 + { 212 + DPI_AWARENESS_CONTEXT context = pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_SYSTEM_AWARE ); 213 + dpi = pGetDpiForSystem(); 214 + pSetThreadDpiAwarenessContext( context ); 215 + return dpi; 216 + } 196 217 if (get_reg_dword(HKEY_CURRENT_USER, "Control Panel\\Desktop", "LogPixels", &dpi)) 197 218 return dpi; 198 219 if (get_reg_dword(HKEY_CURRENT_CONFIG, "Software\\Fonts", "LogPixels", &dpi)) ··· 622 643 BOOL rc; 623 644 INT mi[3]; 624 645 static int aw_turn = 0; 625 - static BOOL w_implemented = TRUE; 626 646 627 647 char buf[20]; 628 648 int i; 629 649 630 650 aw_turn++; 631 651 rc = FALSE; 632 - if ((aw_turn % 2!=0) && (w_implemented)) 633 - { 634 - /* call unicode on odd (non even) calls */ 635 - SetLastError(0xdeadbeef); 652 + SetLastError(0xdeadbeef); 653 + if (aw_turn % 2) /* call unicode on odd (non even) calls */ 636 654 rc=SystemParametersInfoW( SPI_SETMOUSE, 0, curr_val, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE ); 637 - if (rc == FALSE && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) 638 - { 639 - w_implemented = FALSE; 640 - trace("SystemParametersInfoW not supported on this platform\n"); 641 - } 642 - } 643 - 644 - if ((aw_turn % 2==0) || (!w_implemented)) 645 - { 646 - /* call ascii version on even calls or if unicode is not available */ 655 + else 647 656 rc=SystemParametersInfoA( SPI_SETMOUSE, 0, curr_val, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE ); 648 - } 649 657 if (!test_error_msg(rc,"SPI_SETMOUSE")) return FALSE; 650 658 651 659 ok(rc, "SystemParametersInfo: rc=%d err=%d\n", rc, GetLastError()); ··· 664 672 "incorrect value for %d: %d != %d\n", i, mi[i], curr_val[i]); 665 673 } 666 674 667 - if (w_implemented) 668 - { 669 - rc=SystemParametersInfoW( SPI_GETMOUSE, 0, mi, 0 ); 670 - ok(rc, "SystemParametersInfoW: rc=%d err=%d\n", rc, GetLastError()); 671 - for (i = 0; i < 3; i++) 672 - { 673 - ok(mi[i] == curr_val[i], 674 - "incorrect value for %d: %d != %d\n", i, mi[i], curr_val[i]); 675 - } 675 + rc=SystemParametersInfoW( SPI_GETMOUSE, 0, mi, 0 ); 676 + ok(rc, "SystemParametersInfoW: rc=%d err=%d\n", rc, GetLastError()); 677 + for (i = 0; i < 3; i++) 678 + { 679 + ok(mi[i] == curr_val[i], 680 + "incorrect value for %d: %d != %d\n", i, mi[i], curr_val[i]); 676 681 } 677 682 678 683 if (0) ··· 710 715 POINT proj_change7[] = { {6, 6}, {14, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} }; 711 716 POINT proj_change8[] = { {6, 6}, {28, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} }; 712 717 713 - int nchange = sizeof( req_change ) / sizeof( POINT ); 718 + int nchange = ARRAY_SIZE(req_change); 714 719 715 720 trace("testing SPI_{GET,SET}MOUSE\n"); 716 721 SetLastError(0xdeadbeef); ··· 848 853 if ( old_border == 7 || old_border == 20 ) 849 854 old_border = 1; 850 855 851 - /* The SPI_SETBORDER seems to be buggy on Win9x/ME (looks like you need to 852 - * do it twice to make the intended change). So skip parts of the tests on 853 - * those platforms */ 854 - if( !iswin9x) { 855 - /* win2k3 fails if you set the same border twice, or if size is 0 */ 856 - if (!test_setborder(2, 1, dpi)) return; 857 - test_setborder(1, 1, dpi); 858 - test_setborder(3, 1, dpi); 859 - } 856 + /* win2k3 fails if you set the same border twice, or if size is 0 */ 857 + if (!test_setborder(2, 1, dpi)) return; 858 + test_setborder(1, 1, dpi); 859 + test_setborder(3, 1, dpi); 860 860 if (!test_setborder(1, 0, dpi)) return; 861 861 test_setborder(0, 0, dpi); 862 862 test_setborder(3, 0, dpi); ··· 880 880 if (!test_error_msg(rc,"SPI_{GET,SET}KEYBOARDSPEED")) 881 881 return; 882 882 883 - for (i=0;i<sizeof(vals)/sizeof(*vals);i++) 883 + for (i=0;i<ARRAY_SIZE(vals);i++) 884 884 { 885 885 UINT v; 886 886 char buf[10]; ··· 969 969 if (!test_error_msg(rc,"SPI_{GET,SET}SCREENSAVETIMEOUT")) 970 970 return; 971 971 972 - for (i=0;i<sizeof(vals)/sizeof(*vals);i++) 972 + for (i=0;i<ARRAY_SIZE(vals);i++) 973 973 { 974 974 UINT v; 975 975 char buf[10]; ··· 1006 1006 if (!test_error_msg(rc,"SPI_{GET,SET}SCREENSAVEACTIVE")) 1007 1007 return; 1008 1008 1009 - for (i=0;i<sizeof(vals)/sizeof(*vals);i++) 1009 + for (i=0;i<ARRAY_SIZE(vals);i++) 1010 1010 { 1011 1011 UINT v; 1012 1012 ··· 1047 1047 if (!test_error_msg(rc,"SPI_{GET,SET}KEYBOARDDELAY")) 1048 1048 return; 1049 1049 1050 - for (i=0;i<sizeof(vals)/sizeof(*vals);i++) 1050 + for (i=0;i<ARRAY_SIZE(vals);i++) 1051 1051 { 1052 1052 UINT delay; 1053 1053 char buf[10]; ··· 1148 1148 if (!test_error_msg(rc,"SPI_{GET,SET}ICONTITLEWRAP")) 1149 1149 return; 1150 1150 1151 - for (i=0;i<sizeof(vals)/sizeof(*vals);i++) 1151 + for (i=0;i<ARRAY_SIZE(vals);i++) 1152 1152 { 1153 1153 UINT v; 1154 1154 UINT regval; ··· 1163 1163 if( regval != vals[i]) 1164 1164 regval = metricfromreg( SPI_SETICONTITLEWRAP_REGKEY1, 1165 1165 SPI_SETICONTITLEWRAP_VALNAME, dpi); 1166 - ok( regval == vals[i] || broken(regval == -1), /* win9x */ 1167 - "wrong value in registry %d, expected %d\n", regval, vals[i] ); 1166 + ok( regval == vals[i], "wrong value in registry %d, expected %d\n", regval, vals[i] ); 1168 1167 1169 1168 rc=SystemParametersInfoA( SPI_GETICONTITLEWRAP, 0, &v, 0 ); 1170 1169 ok(rc, "%d: rc=%d err=%d\n", i, rc, GetLastError()); ··· 1193 1192 if (!test_error_msg(rc,"SPI_{GET,SET}MENUDROPALIGNMENT")) 1194 1193 return; 1195 1194 1196 - for (i=0;i<sizeof(vals)/sizeof(*vals);i++) 1195 + for (i=0;i<ARRAY_SIZE(vals);i++) 1197 1196 { 1198 1197 UINT v; 1199 1198 ··· 1229 1228 trace("testing SPI_{GET,SET}DOUBLECLKWIDTH\n"); 1230 1229 old_width = GetSystemMetrics( SM_CXDOUBLECLK ); 1231 1230 1232 - for (i=0;i<sizeof(vals)/sizeof(*vals);i++) 1231 + for (i=0;i<ARRAY_SIZE(vals);i++) 1233 1232 { 1234 1233 char buf[10]; 1235 1234 ··· 1263 1262 trace("testing SPI_{GET,SET}DOUBLECLKHEIGHT\n"); 1264 1263 old_height = GetSystemMetrics( SM_CYDOUBLECLK ); 1265 1264 1266 - for (i=0;i<sizeof(vals)/sizeof(*vals);i++) 1265 + for (i=0;i<ARRAY_SIZE(vals);i++) 1267 1266 { 1268 1267 char buf[10]; 1269 1268 ··· 1353 1352 trace("testing SPI_{GET,SET}MOUSEBUTTONSWAP\n"); 1354 1353 old_b = GetSystemMetrics( SM_SWAPBUTTON ); 1355 1354 1356 - for (i=0;i<sizeof(vals)/sizeof(*vals);i++) 1355 + for (i=0;i<ARRAY_SIZE(vals);i++) 1357 1356 { 1358 1357 SetLastError(0xdeadbeef); 1359 1358 rc=SystemParametersInfoA( SPI_SETMOUSEBUTTONSWAP, vals[i], 0, ··· 1408 1407 if (!test_error_msg(rc,"SPI_{GET,SET}DRAGFULLWINDOWS")) 1409 1408 return; 1410 1409 1411 - for (i=0;i<sizeof(vals)/sizeof(*vals);i++) 1410 + for (i=0;i<ARRAY_SIZE(vals);i++) 1412 1411 { 1413 1412 UINT v; 1414 1413 ··· 1430 1429 ok(rc, "***warning*** failed to restore the original value: rc=%d err=%d\n", rc, GetLastError()); 1431 1430 } 1432 1431 1433 - #define test_reg_metric( KEY, VAL, val) \ 1434 - { INT regval;\ 1432 + #define test_reg_metric( KEY, VAL, val) do { \ 1433 + INT regval;\ 1435 1434 regval = metricfromreg( KEY, VAL, dpi);\ 1436 1435 ok( regval==val, "wrong value \"%s\" in registry %d, expected %d\n", VAL, regval, val);\ 1437 - } 1438 - 1439 - #define test_reg_metric2( KEY1, KEY2, VAL, val) \ 1440 - { INT regval;\ 1436 + } while(0) 1437 + 1438 + #define test_reg_metric2( KEY1, KEY2, VAL, val) do { \ 1439 + INT regval;\ 1441 1440 regval = metricfromreg( KEY1, VAL, dpi);\ 1442 1441 if( regval != val) regval = metricfromreg( KEY2, VAL, dpi);\ 1443 1442 ok( regval==val, "wrong value \"%s\" in registry %d, expected %d\n", VAL, regval, val);\ 1444 - } 1443 + } while(0) 1445 1444 1446 - #define test_reg_font( KEY, VAL, LF) \ 1447 - { LOGFONTA lfreg;\ 1445 + #define test_reg_font( KEY, VAL, LF) do { \ 1446 + LOGFONTA lfreg;\ 1448 1447 lffromreg( KEY, VAL, &lfreg);\ 1449 1448 ok( (lfreg.lfHeight < 0 ? (LF).lfHeight == MulDiv( lfreg.lfHeight, dpi, real_dpi ) : \ 1450 1449 MulDiv( -(LF).lfHeight , 72, dpi) == lfreg.lfHeight )&&\ ··· 1452 1451 (LF).lfWeight == lfreg.lfWeight &&\ 1453 1452 !strcmp( (LF).lfFaceName, lfreg.lfFaceName)\ 1454 1453 , "wrong value \"%s\" in registry %d, %d\n", VAL, (LF).lfHeight, lfreg.lfHeight);\ 1455 - } 1454 + } while(0) 1456 1455 1457 - #define TEST_NONCLIENTMETRICS_REG( ncm) \ 1456 + #define TEST_NONCLIENTMETRICS_REG( ncm) do { \ 1458 1457 /*FIXME: test_reg_metric2( SPI_SETBORDER_REGKEY2, SPI_SETBORDER_REGKEY, SPI_SETBORDER_VALNAME, (ncm).iBorderWidth);*/\ 1459 1458 test_reg_metric( SPI_METRIC_REGKEY, SPI_SCROLLWIDTH_VALNAME, (ncm).iScrollWidth);\ 1460 1459 test_reg_metric( SPI_METRIC_REGKEY, SPI_SCROLLHEIGHT_VALNAME, (ncm).iScrollHeight);\ ··· 1468 1467 test_reg_font( SPI_METRIC_REGKEY, SPI_CAPTIONFONT_VALNAME, (ncm).lfCaptionFont);\ 1469 1468 test_reg_font( SPI_METRIC_REGKEY, SPI_SMCAPTIONFONT_VALNAME, (ncm).lfSmCaptionFont);\ 1470 1469 test_reg_font( SPI_METRIC_REGKEY, SPI_STATUSFONT_VALNAME, (ncm).lfStatusFont);\ 1471 - test_reg_font( SPI_METRIC_REGKEY, SPI_MESSAGEFONT_VALNAME, (ncm).lfMessageFont); 1470 + test_reg_font( SPI_METRIC_REGKEY, SPI_MESSAGEFONT_VALNAME, (ncm).lfMessageFont); } while(0) 1472 1471 1473 1472 /* get text metric height value for the specified logfont */ 1474 1473 static int get_tmheight( LOGFONTA *plf, int flag) 1475 1474 { 1476 1475 TEXTMETRICA tm; 1476 + HDC hdc = GetDC(0); 1477 1477 HFONT hfont = CreateFontIndirectA( plf); 1478 1478 hfont = SelectObject( hdc, hfont); 1479 1479 GetTextMetricsA( hdc, &tm); 1480 1480 hfont = SelectObject( hdc, hfont); 1481 + ReleaseDC( 0, hdc ); 1482 + return tm.tmHeight + (flag ? tm.tmExternalLeading : 0); 1483 + } 1484 + 1485 + static int get_tmheightW( LOGFONTW *plf, int flag) 1486 + { 1487 + TEXTMETRICW tm; 1488 + HDC hdc = GetDC(0); 1489 + HFONT hfont = CreateFontIndirectW( plf); 1490 + hfont = SelectObject( hdc, hfont); 1491 + GetTextMetricsW( hdc, &tm); 1492 + hfont = SelectObject( hdc, hfont); 1493 + ReleaseDC( 0, hdc ); 1481 1494 return tm.tmHeight + (flag ? tm.tmExternalLeading : 0); 1482 1495 } 1483 1496 ··· 1515 1528 Ncmorig.iSmCaptionHeight = metricfromreg( SPI_METRIC_REGKEY, SPI_SMCAPTIONHEIGHT_VALNAME, dpi); 1516 1529 Ncmorig.iMenuHeight = metricfromreg( SPI_METRIC_REGKEY, SPI_MENUHEIGHT_VALNAME, dpi); 1517 1530 /* test registry entries */ 1518 - TEST_NONCLIENTMETRICS_REG( Ncmorig) 1519 - Ncmorig.lfCaptionFont.lfHeight = MulDiv( Ncmorig.lfCaptionFont.lfHeight, real_dpi, dpi ); 1531 + TEST_NONCLIENTMETRICS_REG( Ncmorig); 1520 1532 1521 1533 /* make small changes */ 1522 1534 Ncmnew = Ncmstart; ··· 1554 1566 rc=SystemParametersInfoA( SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICSA), &Ncmcur, FALSE ); 1555 1567 ok(rc, "SystemParametersInfoA: rc=%d err=%d\n", rc, GetLastError()); 1556 1568 /* test registry entries */ 1557 - TEST_NONCLIENTMETRICS_REG( Ncmcur) 1569 + TEST_NONCLIENTMETRICS_REG( Ncmcur ); 1558 1570 /* test the system metrics with these settings */ 1559 1571 test_GetSystemMetrics(); 1560 1572 /* now for something invalid: increase the {menu|caption|smcaption} fonts ··· 1574 1586 ok(rc, "SystemParametersInfoA: rc=%d err=%d\n", rc, GetLastError()); 1575 1587 test_change_message( SPI_SETNONCLIENTMETRICS, 1 ); 1576 1588 /* raw values are in registry */ 1577 - TEST_NONCLIENTMETRICS_REG( Ncmnew) 1589 + TEST_NONCLIENTMETRICS_REG( Ncmnew ); 1578 1590 /* get them back */ 1579 1591 rc=SystemParametersInfoA( SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICSA), &Ncmcur, FALSE ); 1580 1592 ok(rc, "SystemParametersInfoA: rc=%d err=%d\n", rc, GetLastError()); ··· 1754 1766 return; 1755 1767 /* check some registry values */ 1756 1768 regval = metricfromreg( SPI_ICONHORIZONTALSPACING_REGKEY, SPI_ICONHORIZONTALSPACING_VALNAME, dpi); 1757 - ok( regval==im_orig.iHorzSpacing || broken(regval == -1), /* nt4 */ 1769 + ok( regval==im_orig.iHorzSpacing, 1758 1770 "wrong value in registry %d, expected %d\n", regval, im_orig.iHorzSpacing); 1759 1771 regval = metricfromreg( SPI_ICONVERTICALSPACING_REGKEY, SPI_ICONVERTICALSPACING_VALNAME, dpi); 1760 - ok( regval==im_orig.iVertSpacing || broken(regval == -1), /* nt4 */ 1772 + ok( regval==im_orig.iVertSpacing, 1761 1773 "wrong value in registry %d, expected %d\n", regval, im_orig.iVertSpacing); 1762 1774 regval = metricfromreg( SPI_SETICONTITLEWRAP_REGKEY2, SPI_SETICONTITLEWRAP_VALNAME, dpi); 1763 1775 if( regval != im_orig.iTitleWrap) ··· 1915 1927 trace("testing SPI_{GET,SET}SHOWSOUNDS\n"); 1916 1928 SetLastError(0xdeadbeef); 1917 1929 rc=SystemParametersInfoA( SPI_GETSHOWSOUNDS, 0, &old_b, 0 ); 1918 - /* SPI_{GET,SET}SHOWSOUNDS is completely broken on Win9x */ 1919 1930 if (!test_error_msg(rc,"SPI_{GET,SET}SHOWSOUNDS")) 1920 1931 return; 1921 1932 1922 - for (i=0;i<sizeof(vals)/sizeof(*vals);i++) 1933 + for (i=0;i<ARRAY_SIZE(vals);i++) 1923 1934 { 1924 1935 UINT v; 1925 1936 ··· 1956 1967 if (!test_error_msg(rc,"SPI_{GET,SET}KEYBOARDPREF")) 1957 1968 return; 1958 1969 1959 - for (i=0;i<sizeof(vals)/sizeof(*vals);i++) 1970 + for (i=0;i<ARRAY_SIZE(vals);i++) 1960 1971 { 1961 1972 BOOL v; 1962 1973 ··· 1991 2002 if (!test_error_msg(rc,"SPI_{GET,SET}SCREENREADER")) 1992 2003 return; 1993 2004 1994 - for (i=0;i<sizeof(vals)/sizeof(*vals);i++) 2005 + for (i=0;i<ARRAY_SIZE(vals);i++) 1995 2006 { 1996 2007 BOOL v; 1997 2008 ··· 2022 2033 unsigned int i; 2023 2034 2024 2035 trace("testing SPI_{GET,SET}FONTSMOOTHING\n"); 2025 - if( iswin9x) return; /* 95/98/ME don't seem to implement this fully */ 2026 2036 SetLastError(0xdeadbeef); 2027 2037 rc=SystemParametersInfoA( SPI_GETFONTSMOOTHING, 0, &old_b, 0 ); 2028 2038 if (!test_error_msg(rc,"SPI_{GET,SET}FONTSMOOTHING")) ··· 2031 2041 SystemParametersInfoA( SPI_GETFONTSMOOTHINGCONTRAST, 0, &old_contrast, 0 ); 2032 2042 SystemParametersInfoA( SPI_GETFONTSMOOTHINGORIENTATION, 0, &old_orient, 0 ); 2033 2043 2034 - for (i=0;i<sizeof(vals)/sizeof(*vals);i++) 2044 + for (i=0;i<ARRAY_SIZE(vals);i++) 2035 2045 { 2036 2046 UINT v; 2037 2047 ··· 2108 2118 if (!test_error_msg(rc,"SPI_{GET,SET}LOWPOWERACTIVE")) 2109 2119 return; 2110 2120 2111 - for (i=0;i<sizeof(vals)/sizeof(*vals);i++) 2121 + for (i=0;i<ARRAY_SIZE(vals);i++) 2112 2122 { 2113 2123 UINT v; 2114 2124 ··· 2125 2135 v = 0xdeadbeef; 2126 2136 rc=SystemParametersInfoA( SPI_GETLOWPOWERACTIVE, 0, &v, 0 ); 2127 2137 ok(rc, "%d: rc=%d err=%d\n", i, rc, GetLastError()); 2128 - ok(v == vals[i] || 2129 - broken(v == (0xdead0000 | vals[i])) || /* win98 only sets the low word */ 2130 - v == 0, /* win2k3 */ 2138 + ok(v == vals[i] || v == 0, /* win2k3 */ 2131 2139 "SPI_GETLOWPOWERACTIVE: got %d instead of 0 or %d\n", v, vals[i]); 2132 2140 } 2133 2141 ··· 2148 2156 if (!test_error_msg(rc,"SPI_{GET,SET}POWEROFFACTIVE")) 2149 2157 return; 2150 2158 2151 - for (i=0;i<sizeof(vals)/sizeof(*vals);i++) 2159 + for (i=0;i<ARRAY_SIZE(vals);i++) 2152 2160 { 2153 2161 UINT v; 2154 2162 ··· 2165 2173 v = 0xdeadbeef; 2166 2174 rc=SystemParametersInfoA( SPI_GETPOWEROFFACTIVE, 0, &v, 0 ); 2167 2175 ok(rc, "%d: rc=%d err=%d\n", i, rc, GetLastError()); 2168 - ok(v == vals[i] || 2169 - broken(v == (0xdead0000 | vals[i])) || /* win98 only sets the low word */ 2170 - v == 0, /* win2k3 */ 2176 + ok(v == vals[i] || v == 0, /* win2k3 */ 2171 2177 "SPI_GETPOWEROFFACTIVE: got %d instead of 0 or %d\n", v, vals[i]); 2172 2178 } 2173 2179 ··· 2188 2194 if (!test_error_msg(rc,"SPI_GETSNAPTODEFBUTTON")) 2189 2195 return; 2190 2196 2191 - for (i=0;i<sizeof(vals)/sizeof(*vals);i++) 2197 + for (i=0;i<ARRAY_SIZE(vals);i++) 2192 2198 { 2193 2199 UINT v; 2194 2200 ··· 2220 2226 trace("testing SPI_{GET,SET}MOUSEHOVERWIDTH\n"); 2221 2227 SetLastError(0xdeadbeef); 2222 2228 rc=SystemParametersInfoA( SPI_GETMOUSEHOVERWIDTH, 0, &old_width, 0 ); 2223 - /* SPI_{GET,SET}MOUSEHOVERWIDTH does not seem to be supported on Win9x despite 2224 - * what MSDN states (Verified on Win98SE) 2225 - */ 2226 2229 if (!test_error_msg(rc,"SPI_{GET,SET}MOUSEHOVERWIDTH")) 2227 2230 return; 2228 - 2229 - for (i=0;i<sizeof(vals)/sizeof(*vals);i++) 2231 + 2232 + for (i=0;i<ARRAY_SIZE(vals);i++) 2230 2233 { 2231 2234 UINT v; 2232 2235 char buf[10]; ··· 2260 2263 trace("testing SPI_{GET,SET}MOUSEHOVERHEIGHT\n"); 2261 2264 SetLastError(0xdeadbeef); 2262 2265 rc=SystemParametersInfoA( SPI_GETMOUSEHOVERHEIGHT, 0, &old_height, 0 ); 2263 - /* SPI_{GET,SET}MOUSEHOVERWIDTH does not seem to be supported on Win9x despite 2264 - * what MSDN states (Verified on Win98SE) 2265 - */ 2266 2266 if (!test_error_msg(rc,"SPI_{GET,SET}MOUSEHOVERHEIGHT")) 2267 2267 return; 2268 - 2269 - for (i=0;i<sizeof(vals)/sizeof(*vals);i++) 2268 + 2269 + for (i=0;i<ARRAY_SIZE(vals);i++) 2270 2270 { 2271 2271 UINT v; 2272 2272 char buf[10]; ··· 2304 2304 trace("testing SPI_{GET,SET}MOUSEHOVERTIME\n"); 2305 2305 SetLastError(0xdeadbeef); 2306 2306 rc=SystemParametersInfoA( SPI_GETMOUSEHOVERTIME, 0, &old_time, 0 ); 2307 - /* SPI_{GET,SET}MOUSEHOVERWIDTH does not seem to be supported on Win9x despite 2308 - * what MSDN states (Verified on Win98SE) 2309 - */ 2310 2307 if (!test_error_msg(rc,"SPI_{GET,SET}MOUSEHOVERTIME")) 2311 2308 return; 2312 - 2313 - for (i=0;i<sizeof(vals)/sizeof(*vals);i++) 2309 + 2310 + for (i=0;i<ARRAY_SIZE(vals);i++) 2314 2311 { 2315 2312 UINT v; 2316 2313 char buf[10]; ··· 2349 2346 if (!test_error_msg(rc,"SPI_{GET,SET}WHEELSCROLLLINES")) 2350 2347 return; 2351 2348 2352 - for (i=0;i<sizeof(vals)/sizeof(*vals);i++) 2349 + for (i=0;i<ARRAY_SIZE(vals);i++) 2353 2350 { 2354 2351 UINT v; 2355 2352 char buf[10]; ··· 2388 2385 if (!test_error_msg(rc,"SPI_{GET,SET}MENUSHOWDELAY")) 2389 2386 return; 2390 2387 2391 - for (i=0;i<sizeof(vals)/sizeof(*vals);i++) 2388 + for (i=0;i<ARRAY_SIZE(vals);i++) 2392 2389 { 2393 2390 UINT v; 2394 2391 char buf[10]; ··· 2427 2424 if (!test_error_msg(rc,"SPI_{GET,SET}WHEELSCROLLCHARS")) 2428 2425 return; 2429 2426 2430 - for (i=0;i<sizeof(vals)/sizeof(*vals);i++) 2427 + for (i=0;i<ARRAY_SIZE(vals);i++) 2431 2428 { 2432 2429 UINT v; 2433 2430 char buf[10]; ··· 2459 2456 trace("testing SPI_{GET,SET}DESKWALLPAPER\n"); 2460 2457 SetLastError(0xdeadbeef); 2461 2458 rc=SystemParametersInfoA(SPI_GETDESKWALLPAPER, 260, oldval, 0); 2462 - /* SPI_{GET,SET}DESKWALLPAPER is completely broken on Win9x and 2463 - * unimplemented on NT4 2464 - */ 2465 2459 if (!test_error_msg(rc,"SPI_{GET,SET}DESKWALLPAPER")) 2466 2460 return; 2467 2461 ··· 2500 2494 2501 2495 displaychange_sem = CreateSemaphoreW(NULL, 0, 1, NULL); 2502 2496 2503 - for(i = 0; i < sizeof(test_bpps)/sizeof(test_bpps[0]); i++) { 2497 + for(i = 0; i < ARRAY_SIZE(test_bpps); i++) { 2504 2498 last_bpp = -1; 2505 2499 2506 2500 memset(&mode, 0, sizeof(mode)); ··· 2737 2731 2738 2732 ncm.cbSize = sizeof(ncm); /* Vista added padding */ 2739 2733 SetLastError(0xdeadbeef); 2734 + ncm.iPaddedBorderWidth = 0xcccc; 2740 2735 rc = SystemParametersInfoA(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0); 2741 2736 ok(rc || broken(!rc) /* before Vista */, "SystemParametersInfoA failed\n"); 2737 + if (rc) ok( ncm.iPaddedBorderWidth == 0, "wrong iPaddedBorderWidth %u\n", ncm.iPaddedBorderWidth ); 2742 2738 2743 2739 minim.cbSize = sizeof( minim); 2744 2740 ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICSA, iPaddedBorderWidth); ··· 2925 2921 DeleteDC(hdc); 2926 2922 } 2927 2923 2924 + static void compare_font( const LOGFONTW *lf1, const LOGFONTW *lf2, int dpi, int custom_dpi, int line ) 2925 + { 2926 + ok_(__FILE__,line)( lf1->lfHeight == MulDiv( lf2->lfHeight, dpi, custom_dpi ), 2927 + "wrong lfHeight %d vs %d\n", lf1->lfHeight, lf2->lfHeight ); 2928 + ok_(__FILE__,line)( abs( lf1->lfWidth - MulDiv( lf2->lfWidth, dpi, custom_dpi )) <= 1, 2929 + "wrong lfWidth %d vs %d\n", lf1->lfWidth, lf2->lfWidth ); 2930 + ok_(__FILE__,line)( !memcmp( &lf1->lfEscapement, &lf2->lfEscapement, 2931 + offsetof( LOGFONTW, lfFaceName ) - offsetof( LOGFONTW, lfEscapement )), 2932 + "font differs\n" ); 2933 + ok_(__FILE__,line)( !lstrcmpW( lf1->lfFaceName, lf2->lfFaceName ), "wrong face name %s vs %s\n", 2934 + wine_dbgstr_w( lf1->lfFaceName ), wine_dbgstr_w( lf2->lfFaceName )); 2935 + } 2936 + 2937 + static void test_metrics_for_dpi( int custom_dpi ) 2938 + { 2939 + int i, val; 2940 + NONCLIENTMETRICSW ncm1, ncm2; 2941 + ICONMETRICSW im1, im2; 2942 + LOGFONTW lf1, lf2; 2943 + BOOL ret; 2944 + 2945 + if (!pSystemParametersInfoForDpi) 2946 + { 2947 + win_skip( "custom dpi metrics not supported\n" ); 2948 + return; 2949 + } 2950 + 2951 + ncm1.cbSize = sizeof(ncm1); 2952 + ret = SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, sizeof(ncm1), &ncm1, FALSE ); 2953 + ok( ret, "SystemParametersInfoW failed err %u\n", GetLastError() ); 2954 + ncm2.cbSize = sizeof(ncm2); 2955 + ret = pSystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, sizeof(ncm2), &ncm2, FALSE, custom_dpi ); 2956 + ok( ret, "SystemParametersInfoForDpi failed err %u\n", GetLastError() ); 2957 + 2958 + for (i = 0; i < 92; i++) 2959 + { 2960 + int ret1 = GetSystemMetrics( i ); 2961 + int ret2 = pGetSystemMetricsForDpi( i, custom_dpi ); 2962 + switch (i) 2963 + { 2964 + case SM_CXVSCROLL: 2965 + case SM_CYHSCROLL: 2966 + case SM_CYVTHUMB: 2967 + case SM_CXHTHUMB: 2968 + case SM_CXICON: 2969 + case SM_CYICON: 2970 + case SM_CYVSCROLL: 2971 + case SM_CXHSCROLL: 2972 + case SM_CYSIZE: 2973 + case SM_CXICONSPACING: 2974 + case SM_CYICONSPACING: 2975 + case SM_CXSMSIZE: 2976 + case SM_CYSMSIZE: 2977 + case SM_CYMENUSIZE: 2978 + ok( ret1 == MulDiv( ret2, dpi, custom_dpi ), "%u: wrong value %u vs %u\n", i, ret1, ret2 ); 2979 + break; 2980 + case SM_CXSIZE: 2981 + ok( ret1 == ncm1.iCaptionWidth && ret2 == ncm2.iCaptionWidth, 2982 + "%u: wrong value %u vs %u caption %u vs %u\n", 2983 + i, ret1, ret2, ncm1.iCaptionWidth, ncm2.iCaptionWidth ); 2984 + break; 2985 + case SM_CXCURSOR: 2986 + case SM_CYCURSOR: 2987 + val = MulDiv( 32, custom_dpi, USER_DEFAULT_SCREEN_DPI ); 2988 + if (val < 48) val = 32; 2989 + else if (val < 64) val = 48; 2990 + else val = 64; 2991 + ok( val == ret2, "%u: wrong value %u vs %u\n", i, ret1, ret2 ); 2992 + break; 2993 + case SM_CYCAPTION: 2994 + case SM_CYSMCAPTION: 2995 + case SM_CYMENU: 2996 + ok( ret1 - 1 == MulDiv( ret2 - 1, dpi, custom_dpi ), "%u: wrong value %u vs %u\n", i, ret1, ret2 ); 2997 + break; 2998 + case SM_CXMENUSIZE: 2999 + ok( ret1 / 8 == MulDiv( ret2, dpi, custom_dpi ) / 8, "%u: wrong value %u vs %u\n", i, ret1, ret2 ); 3000 + break; 3001 + case SM_CXFRAME: 3002 + case SM_CYFRAME: 3003 + ok( ret1 == ncm1.iBorderWidth + 3 && ret2 == ncm2.iBorderWidth + 3, 3004 + "%u: wrong value %u vs %u borders %u+%u vs %u+%u\n", i, ret1, ret2, 3005 + ncm1.iBorderWidth, ncm1.iPaddedBorderWidth, ncm2.iBorderWidth, ncm2.iPaddedBorderWidth ); 3006 + break; 3007 + case SM_CXSMICON: 3008 + case SM_CYSMICON: 3009 + ok( ret1 == (MulDiv( 16, dpi, USER_DEFAULT_SCREEN_DPI ) & ~1) && 3010 + ret2 == (MulDiv( 16, custom_dpi, USER_DEFAULT_SCREEN_DPI ) & ~1), 3011 + "%u: wrong value %u vs %u\n", i, ret1, ret2 ); 3012 + break; 3013 + case SM_CXMENUCHECK: 3014 + case SM_CYMENUCHECK: 3015 + ok( ret1 == ((get_tmheightW( &ncm1.lfMenuFont, 1 ) - 1) | 1) && 3016 + ret2 == ((get_tmheightW( &ncm2.lfMenuFont, 1 ) - 1) | 1), 3017 + "%u: wrong value %u vs %u font %u vs %u\n", i, ret1, ret2, 3018 + get_tmheightW( &ncm1.lfMenuFont, 1 ), get_tmheightW( &ncm2.lfMenuFont, 1 )); 3019 + break; 3020 + default: 3021 + ok( ret1 == ret2, "%u: wrong value %u vs %u\n", i, ret1, ret2 ); 3022 + break; 3023 + } 3024 + } 3025 + im1.cbSize = sizeof(im1); 3026 + ret = SystemParametersInfoW( SPI_GETICONMETRICS, sizeof(im1), &im1, FALSE ); 3027 + ok( ret, "SystemParametersInfoW failed err %u\n", GetLastError() ); 3028 + im2.cbSize = sizeof(im2); 3029 + ret = pSystemParametersInfoForDpi( SPI_GETICONMETRICS, sizeof(im2), &im2, FALSE, custom_dpi ); 3030 + ok( ret, "SystemParametersInfoForDpi failed err %u\n", GetLastError() ); 3031 + ok( im1.iHorzSpacing == MulDiv( im2.iHorzSpacing, dpi, custom_dpi ), "wrong iHorzSpacing %u vs %u\n", 3032 + im1.iHorzSpacing, im2.iHorzSpacing ); 3033 + ok( im1.iVertSpacing == MulDiv( im2.iVertSpacing, dpi, custom_dpi ), "wrong iVertSpacing %u vs %u\n", 3034 + im1.iVertSpacing, im2.iVertSpacing ); 3035 + ok( im1.iTitleWrap == im2.iTitleWrap, "wrong iTitleWrap %u vs %u\n", 3036 + im1.iTitleWrap, im2.iTitleWrap ); 3037 + compare_font( &im1.lfFont, &im2.lfFont, dpi, custom_dpi, __LINE__ ); 3038 + 3039 + ret = SystemParametersInfoW( SPI_GETICONTITLELOGFONT, sizeof(lf1), &lf1, FALSE ); 3040 + ok( ret, "SystemParametersInfoW failed err %u\n", GetLastError() ); 3041 + ret = pSystemParametersInfoForDpi( SPI_GETICONTITLELOGFONT, sizeof(lf2), &lf2, FALSE, custom_dpi ); 3042 + ok( ret, "SystemParametersInfoForDpi failed err %u\n", GetLastError() ); 3043 + compare_font( &lf1, &lf2, dpi, custom_dpi, __LINE__ ); 3044 + 3045 + /* on high-dpi iPaddedBorderWidth is used in addition to iBorderWidth */ 3046 + ok( ncm1.iBorderWidth + ncm1.iPaddedBorderWidth == MulDiv( ncm2.iBorderWidth + ncm2.iPaddedBorderWidth, dpi, custom_dpi ), 3047 + "wrong iBorderWidth %u+%u vs %u+%u\n", 3048 + ncm1.iBorderWidth, ncm1.iPaddedBorderWidth, ncm2.iBorderWidth, ncm2.iPaddedBorderWidth ); 3049 + ok( ncm1.iScrollWidth == MulDiv( ncm2.iScrollWidth, dpi, custom_dpi ), 3050 + "wrong iScrollWidth %u vs %u\n", ncm1.iScrollWidth, ncm2.iScrollWidth ); 3051 + ok( ncm1.iScrollHeight == MulDiv( ncm2.iScrollHeight, dpi, custom_dpi ), 3052 + "wrong iScrollHeight %u vs %u\n", ncm1.iScrollHeight, ncm2.iScrollHeight ); 3053 + ok( ((ncm1.iCaptionWidth + 1) & ~1) == ((MulDiv( ncm2.iCaptionWidth, dpi, custom_dpi ) + 1) & ~1), 3054 + "wrong iCaptionWidth %u vs %u\n", ncm1.iCaptionWidth, ncm2.iCaptionWidth ); 3055 + ok( ncm1.iCaptionHeight == MulDiv( ncm2.iCaptionHeight, dpi, custom_dpi ), 3056 + "wrong iCaptionHeight %u vs %u\n", ncm1.iCaptionHeight, ncm2.iCaptionHeight ); 3057 + compare_font( &ncm1.lfCaptionFont, &ncm2.lfCaptionFont, dpi, custom_dpi, __LINE__ ); 3058 + ok( ncm1.iSmCaptionHeight == MulDiv( ncm2.iSmCaptionHeight, dpi, custom_dpi ), 3059 + "wrong iSmCaptionHeight %u vs %u\n", ncm1.iSmCaptionHeight, ncm2.iSmCaptionHeight ); 3060 + compare_font( &ncm1.lfSmCaptionFont, &ncm2.lfSmCaptionFont, dpi, custom_dpi, __LINE__ ); 3061 + ok( ncm1.iMenuHeight == MulDiv( ncm2.iMenuHeight, dpi, custom_dpi ), 3062 + "wrong iMenuHeight %u vs %u\n", ncm1.iMenuHeight, ncm2.iMenuHeight ); 3063 + /* iSmCaptionWidth and iMenuWidth apparently need to be multiples of 8 */ 3064 + ok( ncm1.iSmCaptionWidth / 8 == MulDiv( ncm2.iSmCaptionWidth, dpi, custom_dpi ) / 8, 3065 + "wrong iSmCaptionWidth %u vs %u\n", ncm1.iSmCaptionWidth, ncm2.iSmCaptionWidth ); 3066 + ok( ncm1.iMenuWidth / 8 == MulDiv( ncm2.iMenuWidth, dpi, custom_dpi ) / 8, 3067 + "wrong iMenuWidth %u vs %u\n", ncm1.iMenuWidth, ncm2.iMenuWidth ); 3068 + compare_font( &ncm1.lfMenuFont, &ncm2.lfMenuFont, dpi, custom_dpi, __LINE__ ); 3069 + compare_font( &ncm1.lfStatusFont, &ncm2.lfStatusFont, dpi, custom_dpi, __LINE__ ); 3070 + compare_font( &ncm1.lfMessageFont, &ncm2.lfMessageFont, dpi, custom_dpi, __LINE__ ); 3071 + 3072 + for (i = 1; i < 120; i++) 3073 + { 3074 + if (i == SPI_GETICONTITLELOGFONT || i == SPI_GETNONCLIENTMETRICS || i == SPI_GETICONMETRICS) 3075 + continue; 3076 + SetLastError( 0xdeadbeef ); 3077 + ret = pSystemParametersInfoForDpi( i, 0, &val, 0, custom_dpi ); 3078 + ok( !ret, "%u: SystemParametersInfoForDpi succeeded\n", i ); 3079 + ok( GetLastError() == ERROR_INVALID_PARAMETER, "%u: wrong error %u\n", i, GetLastError() ); 3080 + } 3081 + } 3082 + 2928 3083 static void test_EnumDisplaySettings(void) 2929 3084 { 2930 3085 DEVMODEA devmode; ··· 2933 3088 DWORD num; 2934 3089 2935 3090 memset(&devmode, 0, sizeof(devmode)); 2936 - /* Win95 doesn't handle ENUM_CURRENT_SETTINGS correctly */ 2937 3091 EnumDisplaySettingsA(NULL, ENUM_CURRENT_SETTINGS, &devmode); 2938 3092 2939 3093 hdc = GetDC(0); 2940 3094 val = GetDeviceCaps(hdc, BITSPIXEL); 2941 - ok(devmode.dmBitsPerPel == val || 2942 - broken(devmode.dmDeviceName[0] == 0), /* Win95 */ 3095 + ok(devmode.dmBitsPerPel == val, 2943 3096 "GetDeviceCaps(BITSPIXEL) returned %d, EnumDisplaySettings returned %d\n", 2944 3097 val, devmode.dmBitsPerPel); 2945 3098 ··· 2988 3141 win_skip("COLOR_MENUBAR unsupported\n"); 2989 3142 } 2990 3143 3144 + static void test_dpi_stock_objects( HDC hdc ) 3145 + { 3146 + DPI_AWARENESS_CONTEXT context; 3147 + HGDIOBJ obj[STOCK_LAST + 1], obj2[STOCK_LAST + 1]; 3148 + LOGFONTW lf, lf2; 3149 + UINT i, dpi; 3150 + 3151 + context = pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_UNAWARE ); 3152 + dpi = GetDeviceCaps( hdc, LOGPIXELSX ); 3153 + ok( dpi == USER_DEFAULT_SCREEN_DPI, "wrong dpi %u\n", dpi ); 3154 + ok( !pIsProcessDPIAware(), "not aware\n" ); 3155 + for (i = 0; i <= STOCK_LAST; i++) obj[i] = GetStockObject( i ); 3156 + 3157 + pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_SYSTEM_AWARE ); 3158 + dpi = GetDeviceCaps( hdc, LOGPIXELSX ); 3159 + ok( dpi == real_dpi, "wrong dpi %u\n", dpi ); 3160 + ok( pIsProcessDPIAware(), "not aware\n" ); 3161 + for (i = 0; i <= STOCK_LAST; i++) obj2[i] = GetStockObject( i ); 3162 + 3163 + for (i = 0; i <= STOCK_LAST; i++) 3164 + { 3165 + switch (i) 3166 + { 3167 + case OEM_FIXED_FONT: 3168 + case SYSTEM_FIXED_FONT: 3169 + ok( obj[i] != obj2[i], "%u: same object\n", i ); 3170 + break; 3171 + case SYSTEM_FONT: 3172 + case DEFAULT_GUI_FONT: 3173 + ok( obj[i] != obj2[i], "%u: same object\n", i ); 3174 + GetObjectW( obj[i], sizeof(lf), &lf ); 3175 + GetObjectW( obj2[i], sizeof(lf2), &lf2 ); 3176 + ok( lf.lfHeight == MulDiv( lf2.lfHeight, USER_DEFAULT_SCREEN_DPI, real_dpi ), 3177 + "%u: wrong height %d / %d\n", i, lf.lfHeight, lf2.lfHeight ); 3178 + break; 3179 + default: 3180 + ok( obj[i] == obj2[i], "%u: different object\n", i ); 3181 + break; 3182 + } 3183 + } 3184 + 3185 + pSetThreadDpiAwarenessContext( context ); 3186 + } 3187 + 3188 + static void scale_point_dpi( POINT *pt, UINT src_dpi, UINT target_dpi ) 3189 + { 3190 + pt->x = MulDiv( pt->x, target_dpi, src_dpi ); 3191 + pt->y = MulDiv( pt->y, target_dpi, src_dpi ); 3192 + } 3193 + 3194 + static void scale_rect_dpi( RECT *rect, UINT src_dpi, UINT target_dpi ) 3195 + { 3196 + rect->left = MulDiv( rect->left, target_dpi, src_dpi ); 3197 + rect->top = MulDiv( rect->top, target_dpi, src_dpi ); 3198 + rect->right = MulDiv( rect->right, target_dpi, src_dpi ); 3199 + rect->bottom = MulDiv( rect->bottom, target_dpi, src_dpi ); 3200 + } 3201 + 3202 + static void scale_point_dpi_aware( POINT *pt, DPI_AWARENESS from, DPI_AWARENESS to ) 3203 + { 3204 + if (from == DPI_AWARENESS_UNAWARE && to != DPI_AWARENESS_UNAWARE) 3205 + scale_point_dpi( pt, USER_DEFAULT_SCREEN_DPI, real_dpi ); 3206 + else if (from != DPI_AWARENESS_UNAWARE && to == DPI_AWARENESS_UNAWARE) 3207 + scale_point_dpi( pt, real_dpi, USER_DEFAULT_SCREEN_DPI ); 3208 + } 3209 + 3210 + static void scale_rect_dpi_aware( RECT *rect, DPI_AWARENESS from, DPI_AWARENESS to ) 3211 + { 3212 + if (from == DPI_AWARENESS_UNAWARE && to != DPI_AWARENESS_UNAWARE) 3213 + scale_rect_dpi( rect, USER_DEFAULT_SCREEN_DPI, real_dpi ); 3214 + else if (from != DPI_AWARENESS_UNAWARE && to == DPI_AWARENESS_UNAWARE) 3215 + scale_rect_dpi( rect, real_dpi, USER_DEFAULT_SCREEN_DPI ); 3216 + } 3217 + 3218 + static void test_dpi_mapping(void) 3219 + { 3220 + HWND hwnd, child; 3221 + HDC hdc; 3222 + UINT win_dpi, units; 3223 + POINT point; 3224 + BOOL ret; 3225 + HRGN rgn, update; 3226 + RECT rect, orig, client, desktop, expect; 3227 + ULONG_PTR i, j, k; 3228 + WINDOWPLACEMENT wpl_orig, wpl; 3229 + HMONITOR monitor; 3230 + MONITORINFO mon_info; 3231 + DPI_AWARENESS_CONTEXT context; 3232 + 3233 + if (!pLogicalToPhysicalPointForPerMonitorDPI) 3234 + { 3235 + win_skip( "LogicalToPhysicalPointForPerMonitorDPI not supported\n" ); 3236 + return; 3237 + } 3238 + context = pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE ); 3239 + GetWindowRect( GetDesktopWindow(), &desktop ); 3240 + for (i = DPI_AWARENESS_UNAWARE; i <= DPI_AWARENESS_PER_MONITOR_AWARE; i++) 3241 + { 3242 + pSetThreadDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)~i ); 3243 + /* test desktop rect */ 3244 + GetWindowRect( GetDesktopWindow(), &rect ); 3245 + expect = desktop; 3246 + if (i == DPI_AWARENESS_UNAWARE) scale_rect_dpi( &expect, real_dpi, USER_DEFAULT_SCREEN_DPI ); 3247 + ok( EqualRect( &expect, &rect ), "%lu: wrong desktop rect %s expected %s\n", 3248 + i, wine_dbgstr_rect(&rect), wine_dbgstr_rect(&expect) ); 3249 + SetRect( &rect, 0, 0, GetSystemMetrics( SM_CXSCREEN ), GetSystemMetrics( SM_CYSCREEN )); 3250 + ok( EqualRect( &expect, &rect ), "%lu: wrong desktop rect %s expected %s\n", 3251 + i, wine_dbgstr_rect(&rect), wine_dbgstr_rect(&expect) ); 3252 + SetRect( &rect, 0, 0, GetSystemMetrics( SM_CXVIRTUALSCREEN ), GetSystemMetrics( SM_CYVIRTUALSCREEN )); 3253 + ok( EqualRect( &expect, &rect ), "%lu: wrong virt desktop rect %s expected %s\n", 3254 + i, wine_dbgstr_rect(&rect), wine_dbgstr_rect(&expect) ); 3255 + SetRect( &rect, 0, 0, 1, 1 ); 3256 + monitor = MonitorFromRect( &rect, MONITOR_DEFAULTTOPRIMARY ); 3257 + ok( monitor != 0, "failed to get monitor\n" ); 3258 + mon_info.cbSize = sizeof(mon_info); 3259 + ok( GetMonitorInfoW( monitor, &mon_info ), "GetMonitorInfoExW failed\n" ); 3260 + ok( EqualRect( &expect, &mon_info.rcMonitor ), "%lu: wrong monitor rect %s expected %s\n", 3261 + i, wine_dbgstr_rect(&mon_info.rcMonitor), wine_dbgstr_rect(&expect) ); 3262 + hdc = CreateDCA( "display", NULL, NULL, NULL ); 3263 + SetRect( &rect, 0, 0, GetDeviceCaps( hdc, HORZRES ), GetDeviceCaps( hdc, VERTRES )); 3264 + ok( EqualRect( &expect, &rect ), "%lu: wrong caps desktop rect %s expected %s\n", 3265 + i, wine_dbgstr_rect(&rect), wine_dbgstr_rect(&expect) ); 3266 + SetRect( &rect, 0, 0, GetDeviceCaps( hdc, DESKTOPHORZRES ), GetDeviceCaps( hdc, DESKTOPVERTRES )); 3267 + ok( EqualRect( &desktop, &rect ), "%lu: wrong caps virt desktop rect %s expected %s\n", 3268 + i, wine_dbgstr_rect(&rect), wine_dbgstr_rect(&desktop) ); 3269 + DeleteDC( hdc ); 3270 + /* test message window rect */ 3271 + hwnd = CreateWindowA( "SysParamsTestClass", "test", WS_CHILD, 3272 + 10, 10, 20, 20, HWND_MESSAGE, 0, GetModuleHandleA(0), NULL ); 3273 + GetWindowRect( GetAncestor( hwnd, GA_PARENT ), &rect ); 3274 + SetRect( &expect, 0, 0, 100, 100 ); 3275 + if (i == DPI_AWARENESS_UNAWARE) scale_rect_dpi( &expect, real_dpi, USER_DEFAULT_SCREEN_DPI ); 3276 + ok( EqualRect( &expect, &rect ), "%lu: wrong message rect %s expected %s\n", 3277 + i, wine_dbgstr_rect(&rect), wine_dbgstr_rect(&expect) ); 3278 + DestroyWindow( hwnd ); 3279 + } 3280 + for (i = DPI_AWARENESS_UNAWARE; i <= DPI_AWARENESS_PER_MONITOR_AWARE; i++) 3281 + { 3282 + pSetThreadDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)~i ); 3283 + hwnd = CreateWindowA( "SysParamsTestClass", "test", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 3284 + 193, 177, 295, 303, 0, 0, GetModuleHandleA(0), NULL ); 3285 + ok( hwnd != 0, "creating window failed err %u\n", GetLastError()); 3286 + child = CreateWindowA( "SysParamsTestClass", "child", WS_CHILD | WS_VISIBLE, 3287 + 50, 60, 70, 80, hwnd, 0, GetModuleHandleA(0), NULL ); 3288 + ok( child != 0, "creating child failed err %u\n", GetLastError()); 3289 + GetWindowRect( hwnd, &orig ); 3290 + SetRect( &rect, 0, 0, 0, 0 ); 3291 + pAdjustWindowRectExForDpi( &rect, WS_OVERLAPPEDWINDOW, FALSE, 0, pGetDpiForWindow( hwnd )); 3292 + SetRect( &client, orig.left - rect.left, orig.top - rect.top, 3293 + orig.right - rect.right, orig.bottom - rect.bottom ); 3294 + ShowWindow( hwnd, SW_MINIMIZE ); 3295 + ShowWindow( hwnd, SW_RESTORE ); 3296 + GetWindowPlacement( hwnd, &wpl_orig ); 3297 + units = GetDialogBaseUnits(); 3298 + 3299 + for (j = DPI_AWARENESS_UNAWARE; j <= DPI_AWARENESS_PER_MONITOR_AWARE; j++) 3300 + { 3301 + pSetThreadDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)~j ); 3302 + /* test window rect */ 3303 + GetWindowRect( hwnd, &rect ); 3304 + expect = orig; 3305 + scale_rect_dpi_aware( &expect, i, j ); 3306 + ok( EqualRect( &expect, &rect ), "%lu/%lu: wrong window rect %s expected %s\n", 3307 + i, j, wine_dbgstr_rect(&rect), wine_dbgstr_rect(&expect) ); 3308 + /* test client rect */ 3309 + GetClientRect( hwnd, &rect ); 3310 + expect = client; 3311 + OffsetRect( &expect, -expect.left, -expect.top ); 3312 + scale_rect_dpi_aware( &expect, i, j ); 3313 + ok( EqualRect( &expect, &rect ), "%lu/%lu: wrong client rect %s expected %s\n", 3314 + i, j, wine_dbgstr_rect(&rect), wine_dbgstr_rect(&expect) ); 3315 + /* test window placement */ 3316 + GetWindowPlacement( hwnd, &wpl ); 3317 + point = wpl_orig.ptMinPosition; 3318 + if (point.x != -1 || point.y != -1) scale_point_dpi_aware( &point, i, j ); 3319 + ok( wpl.ptMinPosition.x == point.x && wpl.ptMinPosition.y == point.y, 3320 + "%lu/%lu: wrong placement min pos %d,%d expected %d,%d\n", i, j, 3321 + wpl.ptMinPosition.x, wpl.ptMinPosition.y, point.x, point.y ); 3322 + point = wpl_orig.ptMaxPosition; 3323 + if (point.x != -1 || point.y != -1) scale_point_dpi_aware( &point, i, j ); 3324 + ok( wpl.ptMaxPosition.x == point.x && wpl.ptMaxPosition.y == point.y, 3325 + "%lu/%lu: wrong placement max pos %d,%d expected %d,%d\n", i, j, 3326 + wpl.ptMaxPosition.x, wpl.ptMaxPosition.y, point.x, point.y ); 3327 + expect = wpl_orig.rcNormalPosition; 3328 + scale_rect_dpi_aware( &expect, i, j ); 3329 + ok( EqualRect( &wpl.rcNormalPosition, &expect ), 3330 + "%lu/%lu: wrong placement rect %s expect %s\n", i, j, 3331 + wine_dbgstr_rect(&wpl.rcNormalPosition), wine_dbgstr_rect(&expect)); 3332 + /* test DC rect */ 3333 + hdc = GetDC( hwnd ); 3334 + GetClipBox( hdc, &rect ); 3335 + SetRect( &expect, 0, 0, client.right - client.left, client.bottom - client.top ); 3336 + ok( EqualRect( &expect, &rect ), "%lu/%lu: wrong clip box %s expected %s\n", 3337 + i, j, wine_dbgstr_rect(&rect), wine_dbgstr_rect(&expect) ); 3338 + /* test DC resolution */ 3339 + SetRect( &rect, 0, 0, GetDeviceCaps( hdc, HORZRES ), GetDeviceCaps( hdc, VERTRES )); 3340 + expect = desktop; 3341 + if (j == DPI_AWARENESS_UNAWARE) scale_rect_dpi( &expect, real_dpi, USER_DEFAULT_SCREEN_DPI ); 3342 + ok( EqualRect( &expect, &rect ), "%lu/%lu: wrong DC resolution %s expected %s\n", 3343 + i, j, wine_dbgstr_rect(&rect), wine_dbgstr_rect(&expect) ); 3344 + SetRect( &rect, 0, 0, GetDeviceCaps( hdc, DESKTOPHORZRES ), GetDeviceCaps( hdc, DESKTOPVERTRES )); 3345 + ok( EqualRect( &desktop, &rect ), "%lu/%lu: wrong desktop resolution %s expected %s\n", 3346 + i, j, wine_dbgstr_rect(&rect), wine_dbgstr_rect(&desktop) ); 3347 + ReleaseDC( hwnd, hdc ); 3348 + /* test DC win rect */ 3349 + hdc = GetWindowDC( hwnd ); 3350 + GetClipBox( hdc, &rect ); 3351 + SetRect( &expect, 0, 0, 295, 303 ); 3352 + todo_wine 3353 + ok( EqualRect( &expect, &rect ), "%lu/%lu: wrong clip box win DC %s expected %s\n", 3354 + i, j, wine_dbgstr_rect(&rect), wine_dbgstr_rect(&expect) ); 3355 + ReleaseDC( hwnd, hdc ); 3356 + /* test window invalidation */ 3357 + UpdateWindow( hwnd ); 3358 + update = CreateRectRgn( 0, 0, 0, 0 ); 3359 + ret = GetUpdateRgn( hwnd, update, FALSE ); 3360 + ok( ret == NULLREGION, "update region not empty\n" ); 3361 + rgn = CreateRectRgn( 20, 20, 25, 25 ); 3362 + for (k = DPI_AWARENESS_UNAWARE; k <= DPI_AWARENESS_PER_MONITOR_AWARE; k++) 3363 + { 3364 + pSetThreadDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)~k ); 3365 + RedrawWindow( hwnd, 0, rgn, RDW_INVALIDATE ); 3366 + pSetThreadDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)~j ); 3367 + GetUpdateRgn( hwnd, update, FALSE ); 3368 + GetRgnBox( update, &rect ); 3369 + SetRect( &expect, 20, 20, 25, 25 ); 3370 + ok( EqualRect( &expect, &rect ), "%lu/%lu/%lu: wrong update region %s expected %s\n", 3371 + i, j, k, wine_dbgstr_rect(&rect), wine_dbgstr_rect(&expect) ); 3372 + GetUpdateRect( hwnd, &rect, FALSE ); 3373 + scale_rect_dpi_aware( &expect, i, j ); 3374 + ok( EqualRect( &expect, &rect ), "%lu/%lu/%lu: wrong update rect %s expected %s\n", 3375 + i, j, k, wine_dbgstr_rect(&rect), wine_dbgstr_rect(&expect) ); 3376 + UpdateWindow( hwnd ); 3377 + } 3378 + for (k = DPI_AWARENESS_UNAWARE; k <= DPI_AWARENESS_PER_MONITOR_AWARE; k++) 3379 + { 3380 + RedrawWindow( hwnd, 0, rgn, RDW_INVALIDATE ); 3381 + pSetThreadDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)~k ); 3382 + GetUpdateRgn( hwnd, update, FALSE ); 3383 + pSetThreadDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)~j ); 3384 + GetRgnBox( update, &rect ); 3385 + SetRect( &expect, 20, 20, 25, 25 ); 3386 + ok( EqualRect( &expect, &rect ), "%lu/%lu/%lu: wrong update region %s expected %s\n", 3387 + i, j, k, wine_dbgstr_rect(&rect), wine_dbgstr_rect(&expect) ); 3388 + GetUpdateRect( hwnd, &rect, FALSE ); 3389 + scale_rect_dpi_aware( &expect, i, j ); 3390 + ok( EqualRect( &expect, &rect ), "%lu/%lu/%lu: wrong update rect %s expected %s\n", 3391 + i, j, k, wine_dbgstr_rect(&rect), wine_dbgstr_rect(&expect) ); 3392 + UpdateWindow( hwnd ); 3393 + } 3394 + /* test desktop window invalidation */ 3395 + pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE ); 3396 + GetClientRect( hwnd, &rect ); 3397 + InflateRect( &rect, -50, -50 ); 3398 + expect = rect; 3399 + MapWindowPoints( hwnd, 0, (POINT *)&rect, 2 ); 3400 + pSetThreadDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)~j ); 3401 + RedrawWindow( 0, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN ); 3402 + GetUpdateRgn( hwnd, update, TRUE ); 3403 + GetRgnBox( update, &rect ); 3404 + if (i == DPI_AWARENESS_UNAWARE) scale_rect_dpi( &expect, real_dpi, USER_DEFAULT_SCREEN_DPI ); 3405 + ok( EqualRect( &expect, &rect ), "%lu/%lu: wrong update region %s expected %s\n", 3406 + i, j, wine_dbgstr_rect(&rect), wine_dbgstr_rect(&expect) ); 3407 + GetUpdateRect( hwnd, &rect, FALSE ); 3408 + scale_rect_dpi_aware( &expect, i, j ); 3409 + ok( EqualRect( &expect, &rect ), "%lu/%lu: wrong update rect %s expected %s\n", 3410 + i, j, wine_dbgstr_rect(&rect), wine_dbgstr_rect(&expect) ); 3411 + UpdateWindow( hwnd ); 3412 + DeleteObject( update ); 3413 + /* test dialog units */ 3414 + ret = GetDialogBaseUnits(); 3415 + point.x = LOWORD( units ); 3416 + point.y = HIWORD( units ); 3417 + scale_point_dpi_aware( &point, i, j ); 3418 + ok( LOWORD(ret) == point.x && HIWORD(ret) == point.y, "%lu/%lu: wrong units %d,%d / %d,%d\n", 3419 + i, j, LOWORD(ret), HIWORD(ret), point.x, point.y ); 3420 + /* test window points mapping */ 3421 + SetRect( &rect, 0, 0, 100, 100 ); 3422 + rect.right = rect.left + 100; 3423 + rect.bottom = rect.top + 100; 3424 + MapWindowPoints( hwnd, 0, (POINT *)&rect, 2 ); 3425 + expect = client; 3426 + scale_rect_dpi_aware( &expect, i, j ); 3427 + expect.right = expect.left + 100; 3428 + expect.bottom = expect.top + 100; 3429 + ok( EqualRect( &expect, &rect ), "%lu/%lu: wrong MapWindowPoints rect %s expected %s\n", 3430 + i, j, wine_dbgstr_rect(&rect), wine_dbgstr_rect(&expect) ); 3431 + SetRect( &rect, 50, 60, 70, 80 ); 3432 + scale_rect_dpi_aware( &rect, i, j ); 3433 + SetRect( &expect, 40, 30, 60, 80 ); 3434 + OffsetRect( &expect, -rect.left, -rect.top ); 3435 + SetRect( &rect, 40, 30, 60, 80 ); 3436 + MapWindowPoints( hwnd, child, (POINT *)&rect, 2 ); 3437 + ok( EqualRect( &expect, &rect ), "%lu/%lu: wrong MapWindowPoints child rect %s expected %s\n", 3438 + i, j, wine_dbgstr_rect(&rect), wine_dbgstr_rect(&expect) ); 3439 + /* test logical<->physical coords mapping */ 3440 + win_dpi = pGetDpiForWindow( hwnd ); 3441 + if (i == DPI_AWARENESS_UNAWARE) 3442 + ok( win_dpi == USER_DEFAULT_SCREEN_DPI, "wrong dpi %u\n", win_dpi ); 3443 + else if (i == DPI_AWARENESS_SYSTEM_AWARE) 3444 + ok( win_dpi == real_dpi, "wrong dpi %u / %u\n", win_dpi, real_dpi ); 3445 + point.x = 373; 3446 + point.y = 377; 3447 + ret = pLogicalToPhysicalPointForPerMonitorDPI( hwnd, &point ); 3448 + ok( ret, "%lu/%lu: LogicalToPhysicalPointForPerMonitorDPI failed\n", i, j ); 3449 + ok( point.x == MulDiv( 373, real_dpi, win_dpi ) && 3450 + point.y == MulDiv( 377, real_dpi, win_dpi ), 3451 + "%lu/%lu: wrong pos %d,%d dpi %u\n", i, j, point.x, point.y, win_dpi ); 3452 + point.x = 405; 3453 + point.y = 423; 3454 + ret = pPhysicalToLogicalPointForPerMonitorDPI( hwnd, &point ); 3455 + ok( ret, "%lu/%lu: PhysicalToLogicalPointForPerMonitorDPI failed\n", i, j ); 3456 + ok( point.x == MulDiv( 405, win_dpi, real_dpi ) && 3457 + point.y == MulDiv( 423, win_dpi, real_dpi ), 3458 + "%lu/%lu: wrong pos %d,%d dpi %u\n", i, j, point.x, point.y, win_dpi ); 3459 + /* point outside the window fails, but note that Windows (wrongly) checks against the 3460 + * window rect transformed relative to the thread's awareness */ 3461 + GetWindowRect( hwnd, &rect ); 3462 + point.x = rect.left - 1; 3463 + point.y = rect.top; 3464 + ret = pLogicalToPhysicalPointForPerMonitorDPI( hwnd, &point ); 3465 + ok( !ret, "%lu/%lu: LogicalToPhysicalPointForPerMonitorDPI succeeded\n", i, j ); 3466 + point.x++; 3467 + point.y--; 3468 + ret = pLogicalToPhysicalPointForPerMonitorDPI( hwnd, &point ); 3469 + ok( !ret, "%lu/%lu: LogicalToPhysicalPointForPerMonitorDPI succeeded\n", i, j ); 3470 + point.y++; 3471 + ret = pLogicalToPhysicalPointForPerMonitorDPI( hwnd, &point ); 3472 + ok( ret, "%lu/%lu: LogicalToPhysicalPointForPerMonitorDPI failed\n", i, j ); 3473 + point.x = rect.right; 3474 + point.y = rect.bottom + 1; 3475 + ret = pLogicalToPhysicalPointForPerMonitorDPI( hwnd, &point ); 3476 + ok( !ret, "%lu/%lu: LogicalToPhysicalPointForPerMonitorDPI succeeded\n", i, j ); 3477 + point.x++; 3478 + point.y--; 3479 + ret = pLogicalToPhysicalPointForPerMonitorDPI( hwnd, &point ); 3480 + ok( !ret, "%lu/%lu: LogicalToPhysicalPointForPerMonitorDPI succeeded\n", i, j ); 3481 + point.x--; 3482 + ret = pLogicalToPhysicalPointForPerMonitorDPI( hwnd, &point ); 3483 + ok( ret, "%lu/%lu: LogicalToPhysicalPointForPerMonitorDPI failed\n", i, j ); 3484 + /* get physical window rect */ 3485 + pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE ); 3486 + GetWindowRect( hwnd, &rect ); 3487 + pSetThreadDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)~j ); 3488 + point.x = rect.left - 1; 3489 + point.y = rect.top; 3490 + ret = pPhysicalToLogicalPointForPerMonitorDPI( hwnd, &point ); 3491 + ok( !ret, "%lu/%lu: PhysicalToLogicalPointForPerMonitorDPI succeeded\n", i, j ); 3492 + point.x++; 3493 + point.y--; 3494 + ret = pPhysicalToLogicalPointForPerMonitorDPI( hwnd, &point ); 3495 + ok( !ret, "%lu/%lu: PhysicalToLogicalPointForPerMonitorDPI succeeded\n", i, j ); 3496 + point.y++; 3497 + ret = pPhysicalToLogicalPointForPerMonitorDPI( hwnd, &point ); 3498 + ok( ret, "%lu/%lu: PhysicalToLogicalPointForPerMonitorDPI failed\n", i, j ); 3499 + point.x = rect.right; 3500 + point.y = rect.bottom + 1; 3501 + ret = pPhysicalToLogicalPointForPerMonitorDPI( hwnd, &point ); 3502 + ok( !ret, "%lu/%lu: PhysicalToLogicalPointForPerMonitorDPI succeeded\n", i, j ); 3503 + point.x++; 3504 + point.y--; 3505 + ret = pPhysicalToLogicalPointForPerMonitorDPI( hwnd, &point ); 3506 + ok( !ret, "%lu/%lu: PhysicalToLogicalPointForPerMonitorDPI succeeded\n", i, j ); 3507 + point.x--; 3508 + ret = pPhysicalToLogicalPointForPerMonitorDPI( hwnd, &point ); 3509 + ok( ret, "%lu/%lu: PhysicalToLogicalPointForPerMonitorDPI failed\n", i, j ); 3510 + } 3511 + DestroyWindow( hwnd ); 3512 + } 3513 + pSetThreadDpiAwarenessContext( context ); 3514 + } 3515 + 2991 3516 static void test_dpi_aware(void) 2992 3517 { 2993 3518 BOOL ret; ··· 3006 3531 3007 3532 dpi = real_dpi; 3008 3533 test_GetSystemMetrics(); 3534 + test_metrics_for_dpi( 96 ); 3535 + test_metrics_for_dpi( 192 ); 3536 + } 3537 + 3538 + static void test_dpi_context(void) 3539 + { 3540 + DPI_AWARENESS awareness; 3541 + DPI_AWARENESS_CONTEXT context; 3542 + ULONG_PTR i, flags; 3543 + BOOL ret; 3544 + UINT dpi; 3545 + HDC hdc = GetDC( 0 ); 3546 + 3547 + context = pGetThreadDpiAwarenessContext(); 3548 + /* Windows 10 >= 1709 adds extra 0x6000 flags */ 3549 + flags = (ULONG_PTR)context & 0x6000; 3550 + todo_wine 3551 + ok( context == (DPI_AWARENESS_CONTEXT)(0x10 | flags), "wrong context %p\n", context ); 3552 + awareness = pGetAwarenessFromDpiAwarenessContext( context ); 3553 + todo_wine 3554 + ok( awareness == DPI_AWARENESS_UNAWARE, "wrong awareness %u\n", awareness ); 3555 + todo_wine 3556 + ok( !pIsProcessDPIAware(), "already aware\n" ); 3557 + dpi = pGetDpiForSystem(); 3558 + todo_wine_if (real_dpi != USER_DEFAULT_SCREEN_DPI) 3559 + ok( dpi == USER_DEFAULT_SCREEN_DPI, "wrong dpi %u\n", dpi ); 3560 + dpi = GetDeviceCaps( hdc, LOGPIXELSX ); 3561 + todo_wine_if (real_dpi != USER_DEFAULT_SCREEN_DPI) 3562 + ok( dpi == USER_DEFAULT_SCREEN_DPI, "wrong dpi %u\n", dpi ); 3563 + SetLastError( 0xdeadbeef ); 3564 + ret = pSetProcessDpiAwarenessContext( NULL ); 3565 + ok( !ret, "got %d\n", ret ); 3566 + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); 3567 + SetLastError( 0xdeadbeef ); 3568 + ret = pSetProcessDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)-6 ); 3569 + ok( !ret, "got %d\n", ret ); 3570 + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); 3571 + ret = pSetProcessDpiAwarenessContext( DPI_AWARENESS_CONTEXT_SYSTEM_AWARE ); 3572 + todo_wine 3573 + ok( ret, "got %d\n", ret ); 3574 + ok( pIsProcessDPIAware(), "not aware\n" ); 3575 + real_dpi = pGetDpiForSystem(); 3576 + SetLastError( 0xdeadbeef ); 3577 + ret = pSetProcessDpiAwarenessContext( DPI_AWARENESS_CONTEXT_SYSTEM_AWARE ); 3578 + ok( !ret, "got %d\n", ret ); 3579 + ok( GetLastError() == ERROR_ACCESS_DENIED, "wrong error %u\n", GetLastError() ); 3580 + SetLastError( 0xdeadbeef ); 3581 + ret = pSetProcessDpiAwarenessContext( DPI_AWARENESS_CONTEXT_UNAWARE ); 3582 + ok( !ret, "got %d\n", ret ); 3583 + ok( GetLastError() == ERROR_ACCESS_DENIED, "wrong error %u\n", GetLastError() ); 3584 + 3585 + ret = pSetProcessDpiAwarenessInternal( DPI_AWARENESS_INVALID ); 3586 + ok( !ret, "got %d\n", ret ); 3587 + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); 3588 + ret = pSetProcessDpiAwarenessInternal( DPI_AWARENESS_UNAWARE ); 3589 + ok( !ret, "got %d\n", ret ); 3590 + ok( GetLastError() == ERROR_ACCESS_DENIED, "wrong error %u\n", GetLastError() ); 3591 + ret = pGetProcessDpiAwarenessInternal( 0, &awareness ); 3592 + ok( ret, "got %d\n", ret ); 3593 + todo_wine 3594 + ok( awareness == DPI_AWARENESS_SYSTEM_AWARE, "wrong value %d\n", awareness ); 3595 + ret = pGetProcessDpiAwarenessInternal( GetCurrentProcess(), &awareness ); 3596 + ok( ret, "got %d\n", ret ); 3597 + todo_wine 3598 + ok( awareness == DPI_AWARENESS_SYSTEM_AWARE, "wrong value %d\n", awareness ); 3599 + ret = pGetProcessDpiAwarenessInternal( (HANDLE)0xdeadbeef, &awareness ); 3600 + ok( ret, "got %d\n", ret ); 3601 + ok( awareness == DPI_AWARENESS_UNAWARE, "wrong value %d\n", awareness ); 3602 + 3603 + ret = pIsProcessDPIAware(); 3604 + ok(ret, "got %d\n", ret); 3605 + context = pGetThreadDpiAwarenessContext(); 3606 + todo_wine 3607 + ok( context == (DPI_AWARENESS_CONTEXT)(0x11 | flags), "wrong context %p\n", context ); 3608 + awareness = pGetAwarenessFromDpiAwarenessContext( context ); 3609 + todo_wine 3610 + ok( awareness == DPI_AWARENESS_SYSTEM_AWARE, "wrong awareness %u\n", awareness ); 3611 + SetLastError( 0xdeadbeef ); 3612 + context = pSetThreadDpiAwarenessContext( 0 ); 3613 + ok( !context, "got %p\n", context ); 3614 + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); 3615 + SetLastError( 0xdeadbeef ); 3616 + context = pSetThreadDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)-6 ); 3617 + ok( !context, "got %p\n", context ); 3618 + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); 3619 + context = pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_UNAWARE ); 3620 + todo_wine 3621 + ok( context == (DPI_AWARENESS_CONTEXT)(0x80000011 | flags), "wrong context %p\n", context ); 3622 + awareness = pGetAwarenessFromDpiAwarenessContext( context ); 3623 + todo_wine 3624 + ok( awareness == DPI_AWARENESS_SYSTEM_AWARE, "wrong awareness %u\n", awareness ); 3625 + dpi = pGetDpiForSystem(); 3626 + ok( dpi == USER_DEFAULT_SCREEN_DPI, "wrong dpi %u\n", dpi ); 3627 + dpi = GetDeviceCaps( hdc, LOGPIXELSX ); 3628 + ok( dpi == USER_DEFAULT_SCREEN_DPI, "wrong dpi %u\n", dpi ); 3629 + ok( !pIsProcessDPIAware(), "still aware\n" ); 3630 + context = pGetThreadDpiAwarenessContext(); 3631 + ok( context == (DPI_AWARENESS_CONTEXT)(0x10 | flags), "wrong context %p\n", context ); 3632 + awareness = pGetAwarenessFromDpiAwarenessContext( context ); 3633 + ok( awareness == DPI_AWARENESS_UNAWARE, "wrong awareness %u\n", awareness ); 3634 + context = pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE ); 3635 + ok( context == (DPI_AWARENESS_CONTEXT)(0x10 | flags), "wrong context %p\n", context ); 3636 + awareness = pGetAwarenessFromDpiAwarenessContext( context ); 3637 + ok( awareness == DPI_AWARENESS_UNAWARE, "wrong awareness %u\n", awareness ); 3638 + dpi = pGetDpiForSystem(); 3639 + ok( dpi == real_dpi, "wrong dpi %u/%u\n", dpi, real_dpi ); 3640 + dpi = GetDeviceCaps( hdc, LOGPIXELSX ); 3641 + ok( dpi == real_dpi, "wrong dpi %u\n", dpi ); 3642 + context = pGetThreadDpiAwarenessContext(); 3643 + ok( context == (DPI_AWARENESS_CONTEXT)0x12, "wrong context %p\n", context ); 3644 + awareness = pGetAwarenessFromDpiAwarenessContext( context ); 3645 + ok( awareness == DPI_AWARENESS_PER_MONITOR_AWARE, "wrong awareness %u\n", awareness ); 3646 + context = pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_SYSTEM_AWARE ); 3647 + ok( context == (DPI_AWARENESS_CONTEXT)0x12, "wrong context %p\n", context ); 3648 + awareness = pGetAwarenessFromDpiAwarenessContext( context ); 3649 + ok( awareness == DPI_AWARENESS_PER_MONITOR_AWARE, "wrong awareness %u\n", awareness ); 3650 + dpi = pGetDpiForSystem(); 3651 + ok( dpi == real_dpi, "wrong dpi %u/%u\n", dpi, real_dpi ); 3652 + dpi = GetDeviceCaps( hdc, LOGPIXELSX ); 3653 + ok( dpi == real_dpi, "wrong dpi %u\n", dpi ); 3654 + ok( pIsProcessDPIAware(), "not aware\n" ); 3655 + context = pGetThreadDpiAwarenessContext(); 3656 + ok( context == (DPI_AWARENESS_CONTEXT)(0x11 | flags), "wrong context %p\n", context ); 3657 + context = pSetThreadDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)(0x80000010 | flags) ); 3658 + ok( context == (DPI_AWARENESS_CONTEXT)(0x11 | flags), "wrong context %p\n", context ); 3659 + context = pGetThreadDpiAwarenessContext(); 3660 + todo_wine 3661 + ok( context == (DPI_AWARENESS_CONTEXT)(0x11 | flags), "wrong context %p\n", context ); 3662 + context = pSetThreadDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)(0x80000011 | flags) ); 3663 + todo_wine 3664 + ok( context == (DPI_AWARENESS_CONTEXT)(0x80000011 | flags), "wrong context %p\n", context ); 3665 + context = pGetThreadDpiAwarenessContext(); 3666 + todo_wine 3667 + ok( context == (DPI_AWARENESS_CONTEXT)(0x11 | flags), "wrong context %p\n", context ); 3668 + context = pSetThreadDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)0x12 ); 3669 + todo_wine 3670 + ok( context == (DPI_AWARENESS_CONTEXT)(0x80000011 | flags), "wrong context %p\n", context ); 3671 + context = pSetThreadDpiAwarenessContext( context ); 3672 + ok( context == (DPI_AWARENESS_CONTEXT)(0x12), "wrong context %p\n", context ); 3673 + context = pGetThreadDpiAwarenessContext(); 3674 + todo_wine 3675 + ok( context == (DPI_AWARENESS_CONTEXT)(0x11 | flags), "wrong context %p\n", context ); 3676 + for (i = 0; i < 0x100; i++) 3677 + { 3678 + awareness = pGetAwarenessFromDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)i ); 3679 + switch (i) 3680 + { 3681 + case 0x10: 3682 + case 0x11: 3683 + case 0x12: 3684 + ok( awareness == (i & ~0x10), "%lx: wrong value %u\n", i, awareness ); 3685 + ok( pIsValidDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)i ), "%lx: not valid\n", i ); 3686 + break; 3687 + default: 3688 + ok( awareness == DPI_AWARENESS_INVALID, "%lx: wrong value %u\n", i, awareness ); 3689 + ok( !pIsValidDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)i ), "%lx: valid\n", i ); 3690 + break; 3691 + } 3692 + awareness = pGetAwarenessFromDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)(i | 0x80000000) ); 3693 + switch (i) 3694 + { 3695 + case 0x10: 3696 + case 0x11: 3697 + case 0x12: 3698 + ok( awareness == (i & ~0x10), "%lx: wrong value %u\n", i | 0x80000000, awareness ); 3699 + ok( pIsValidDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)(i | 0x80000000) ), 3700 + "%lx: not valid\n", i | 0x80000000 ); 3701 + break; 3702 + default: 3703 + ok( awareness == DPI_AWARENESS_INVALID, "%lx: wrong value %u\n", i | 0x80000000, awareness ); 3704 + ok( !pIsValidDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)(i | 0x80000000) ), 3705 + "%lx: valid\n", i | 0x80000000 ); 3706 + break; 3707 + } 3708 + awareness = pGetAwarenessFromDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)~i ); 3709 + switch (~i) 3710 + { 3711 + case (ULONG_PTR)DPI_AWARENESS_CONTEXT_UNAWARE: 3712 + case (ULONG_PTR)DPI_AWARENESS_CONTEXT_SYSTEM_AWARE: 3713 + case (ULONG_PTR)DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE: 3714 + ok( awareness == i, "%lx: wrong value %u\n", ~i, awareness ); 3715 + ok( pIsValidDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)~i ), "%lx: not valid\n", ~i ); 3716 + break; 3717 + case (ULONG_PTR)DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2: 3718 + if (pIsValidDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)~i )) 3719 + ok( awareness == DPI_AWARENESS_PER_MONITOR_AWARE, "%lx: wrong value %u\n", ~i, awareness ); 3720 + else 3721 + ok( awareness == DPI_AWARENESS_INVALID, "%lx: wrong value %u\n", ~i, awareness ); 3722 + break; 3723 + case (ULONG_PTR)DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED: 3724 + if (pIsValidDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)~i )) 3725 + ok( awareness == DPI_AWARENESS_UNAWARE, "%lx: wrong value %u\n", ~i, awareness ); 3726 + else 3727 + ok( awareness == DPI_AWARENESS_INVALID, "%lx: wrong value %u\n", ~i, awareness ); 3728 + break; 3729 + default: 3730 + ok( awareness == DPI_AWARENESS_INVALID, "%lx: wrong value %u\n", ~i, awareness ); 3731 + ok( !pIsValidDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)~i ), "%lx: valid\n", ~i ); 3732 + break; 3733 + } 3734 + } 3735 + if (real_dpi != USER_DEFAULT_SCREEN_DPI) test_dpi_stock_objects( hdc ); 3736 + ReleaseDC( 0, hdc ); 3737 + } 3738 + 3739 + static LRESULT CALLBACK dpi_winproc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ) 3740 + { 3741 + DPI_AWARENESS_CONTEXT ctx = pGetWindowDpiAwarenessContext( hwnd ); 3742 + DPI_AWARENESS_CONTEXT ctx2 = pGetThreadDpiAwarenessContext(); 3743 + DWORD pos, pos2; 3744 + 3745 + ok( pGetAwarenessFromDpiAwarenessContext( ctx ) == pGetAwarenessFromDpiAwarenessContext( ctx2 ), 3746 + "msg %04x wrong awareness %p / %p\n", msg, ctx, ctx2 ); 3747 + pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_UNAWARE ); 3748 + pos = GetMessagePos(); 3749 + pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE ); 3750 + pos2 = GetMessagePos(); 3751 + ok( pos == pos2, "wrong pos %08x / %08x\n", pos, pos2 ); 3752 + pSetThreadDpiAwarenessContext( ctx2 ); 3753 + return DefWindowProcA( hwnd, msg, wp, lp ); 3754 + } 3755 + 3756 + static void test_dpi_window(void) 3757 + { 3758 + DPI_AWARENESS_CONTEXT context, orig; 3759 + DPI_AWARENESS awareness; 3760 + ULONG_PTR i, j; 3761 + UINT dpi; 3762 + HWND hwnd, child, ret; 3763 + MSG msg = { 0, WM_USER + 1, 0, 0 }; 3764 + 3765 + if (!pGetWindowDpiAwarenessContext) 3766 + { 3767 + win_skip( "GetWindowDpiAwarenessContext not supported\n" ); 3768 + return; 3769 + } 3770 + orig = pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_UNAWARE ); 3771 + for (i = DPI_AWARENESS_UNAWARE; i <= DPI_AWARENESS_PER_MONITOR_AWARE; i++) 3772 + { 3773 + pSetThreadDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)~i ); 3774 + hwnd = CreateWindowA( "DpiTestClass", "Test", 3775 + WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL ); 3776 + ok( hwnd != 0, "failed to create window\n" ); 3777 + context = pGetWindowDpiAwarenessContext( hwnd ); 3778 + awareness = pGetAwarenessFromDpiAwarenessContext( context ); 3779 + ok( awareness == i, "%lu: wrong awareness %u\n", i, awareness ); 3780 + dpi = pGetDpiForWindow( hwnd ); 3781 + ok( dpi == (i == DPI_AWARENESS_UNAWARE ? USER_DEFAULT_SCREEN_DPI : real_dpi), 3782 + "%lu: got %u / %u\n", i, dpi, real_dpi ); 3783 + if (pGetDpiForMonitorInternal) 3784 + { 3785 + BOOL res; 3786 + SetLastError( 0xdeadbeef ); 3787 + res = pGetDpiForMonitorInternal( MonitorFromWindow( hwnd, 0 ), 0, &dpi, NULL ); 3788 + ok( !res, "succeeded\n" ); 3789 + ok( GetLastError() == ERROR_INVALID_ADDRESS, "wrong error %u\n", GetLastError() ); 3790 + SetLastError( 0xdeadbeef ); 3791 + res = pGetDpiForMonitorInternal( MonitorFromWindow( hwnd, 0 ), 3, &dpi, &dpi ); 3792 + ok( !res, "succeeded\n" ); 3793 + ok( GetLastError() == ERROR_BAD_ARGUMENTS, "wrong error %u\n", GetLastError() ); 3794 + SetLastError( 0xdeadbeef ); 3795 + res = pGetDpiForMonitorInternal( MonitorFromWindow( hwnd, 0 ), 3, &dpi, NULL ); 3796 + ok( !res, "succeeded\n" ); 3797 + ok( GetLastError() == ERROR_BAD_ARGUMENTS, "wrong error %u\n", GetLastError() ); 3798 + res = pGetDpiForMonitorInternal( MonitorFromWindow( hwnd, 0 ), 0, &dpi, &dpi ); 3799 + ok( res, "failed err %u\n", GetLastError() ); 3800 + ok( dpi == (i == DPI_AWARENESS_UNAWARE ? USER_DEFAULT_SCREEN_DPI : real_dpi), 3801 + "%lu: got %u / %u\n", i, dpi, real_dpi ); 3802 + } 3803 + msg.hwnd = hwnd; 3804 + for (j = DPI_AWARENESS_UNAWARE; j <= DPI_AWARENESS_PER_MONITOR_AWARE; j++) 3805 + { 3806 + pSetThreadDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)~j ); 3807 + SendMessageA( hwnd, WM_USER, 0, 0 ); 3808 + DispatchMessageA( &msg ); 3809 + CallWindowProcA( dpi_winproc, hwnd, WM_USER + 2, 0, 0 ); 3810 + child = CreateWindowA( "DpiTestClass", "Test", 3811 + WS_CHILD, 0, 0, 100, 100, hwnd, 0, GetModuleHandleA(0), NULL ); 3812 + context = pGetWindowDpiAwarenessContext( child ); 3813 + awareness = pGetAwarenessFromDpiAwarenessContext( context ); 3814 + ok( awareness == i, "%lu/%lu: wrong awareness %u\n", i, j, awareness ); 3815 + dpi = pGetDpiForWindow( child ); 3816 + ok( dpi == (i == DPI_AWARENESS_UNAWARE ? USER_DEFAULT_SCREEN_DPI : real_dpi), 3817 + "%lu/%lu: got %u / %u\n", i, j, dpi, real_dpi ); 3818 + ret = SetParent( child, NULL ); 3819 + ok( ret != 0, "SetParent failed err %u\n", GetLastError() ); 3820 + context = pGetWindowDpiAwarenessContext( child ); 3821 + awareness = pGetAwarenessFromDpiAwarenessContext( context ); 3822 + ok( awareness == i, "%lu/%lu: wrong awareness %u\n", i, j, awareness ); 3823 + dpi = pGetDpiForWindow( child ); 3824 + ok( dpi == (i == DPI_AWARENESS_UNAWARE ? USER_DEFAULT_SCREEN_DPI : real_dpi), 3825 + "%lu/%lu: got %u / %u\n", i, j, dpi, real_dpi ); 3826 + DestroyWindow( child ); 3827 + child = CreateWindowA( "DpiTestClass", "Test", 3828 + WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL ); 3829 + context = pGetWindowDpiAwarenessContext( child ); 3830 + awareness = pGetAwarenessFromDpiAwarenessContext( context ); 3831 + ok( awareness == j, "%lu/%lu: wrong awareness %u\n", i, j, awareness ); 3832 + dpi = pGetDpiForWindow( child ); 3833 + ok( dpi == (j == DPI_AWARENESS_UNAWARE ? USER_DEFAULT_SCREEN_DPI : real_dpi), 3834 + "%lu/%lu: got %u / %u\n", i, j, dpi, real_dpi ); 3835 + ret = SetParent( child, hwnd ); 3836 + ok( ret != 0 || GetLastError() == ERROR_INVALID_STATE, 3837 + "SetParent failed err %u\n", GetLastError() ); 3838 + context = pGetWindowDpiAwarenessContext( child ); 3839 + awareness = pGetAwarenessFromDpiAwarenessContext( context ); 3840 + ok( awareness == (ret ? i : j), "%lu/%lu: wrong awareness %u\n", i, j, awareness ); 3841 + dpi = pGetDpiForWindow( child ); 3842 + ok( dpi == (i == DPI_AWARENESS_UNAWARE ? USER_DEFAULT_SCREEN_DPI : real_dpi), 3843 + "%lu/%lu: got %u / %u\n", i, j, dpi, real_dpi ); 3844 + DestroyWindow( child ); 3845 + } 3846 + DestroyWindow( hwnd ); 3847 + } 3848 + 3849 + SetLastError( 0xdeadbeef ); 3850 + context = pGetWindowDpiAwarenessContext( (HWND)0xdeadbeef ); 3851 + ok( !context, "got %p\n", context ); 3852 + ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError() ); 3853 + SetLastError( 0xdeadbeef ); 3854 + dpi = pGetDpiForWindow( (HWND)0xdeadbeef ); 3855 + ok( !dpi, "got %u\n", dpi ); 3856 + ok( GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_INVALID_WINDOW_HANDLE, 3857 + "wrong error %u\n", GetLastError() ); 3858 + 3859 + SetLastError( 0xdeadbeef ); 3860 + context = pGetWindowDpiAwarenessContext( GetDesktopWindow() ); 3861 + awareness = pGetAwarenessFromDpiAwarenessContext( context ); 3862 + ok( awareness == DPI_AWARENESS_PER_MONITOR_AWARE, "wrong awareness %u\n", awareness ); 3863 + dpi = pGetDpiForWindow( GetDesktopWindow() ); 3864 + ok( dpi == real_dpi, "got %u / %u\n", dpi, real_dpi ); 3865 + 3866 + pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_UNAWARE ); 3867 + SetLastError( 0xdeadbeef ); 3868 + context = pGetWindowDpiAwarenessContext( GetDesktopWindow() ); 3869 + awareness = pGetAwarenessFromDpiAwarenessContext( context ); 3870 + ok( awareness == DPI_AWARENESS_PER_MONITOR_AWARE, "wrong awareness %u\n", awareness ); 3871 + dpi = pGetDpiForWindow( GetDesktopWindow() ); 3872 + ok( dpi == real_dpi, "got %u / %u\n", dpi, real_dpi ); 3873 + 3874 + pSetThreadDpiAwarenessContext( orig ); 3009 3875 } 3010 3876 3011 3877 static void test_GetAutoRotationState(void) ··· 3027 3893 state = 0; 3028 3894 ret = pGetAutoRotationState(&state); 3029 3895 ok(ret, "Expected GetAutoRotationState to succeed, error %d\n", GetLastError()); 3030 - ok((state & AR_NOSENSOR) != 0, "Expected AR_NOSENSOR, got %d\n", state); 3031 3896 } 3032 3897 3033 3898 START_TEST(sysparams) ··· 3036 3901 char** argv; 3037 3902 WNDCLASSA wc; 3038 3903 MSG msg; 3904 + HDC hdc; 3039 3905 HANDLE hThread; 3040 3906 DWORD dwThreadId; 3041 3907 HANDLE hInstance, hdll; ··· 3044 3910 pChangeDisplaySettingsExA = (void*)GetProcAddress(hdll, "ChangeDisplaySettingsExA"); 3045 3911 pIsProcessDPIAware = (void*)GetProcAddress(hdll, "IsProcessDPIAware"); 3046 3912 pSetProcessDPIAware = (void*)GetProcAddress(hdll, "SetProcessDPIAware"); 3913 + pGetDpiForSystem = (void*)GetProcAddress(hdll, "GetDpiForSystem"); 3914 + pGetDpiForWindow = (void*)GetProcAddress(hdll, "GetDpiForWindow"); 3915 + pGetDpiForMonitorInternal = (void*)GetProcAddress(hdll, "GetDpiForMonitorInternal"); 3916 + pSetProcessDpiAwarenessContext = (void*)GetProcAddress(hdll, "SetProcessDpiAwarenessContext"); 3917 + pGetProcessDpiAwarenessInternal = (void*)GetProcAddress(hdll, "GetProcessDpiAwarenessInternal"); 3918 + pSetProcessDpiAwarenessInternal = (void*)GetProcAddress(hdll, "SetProcessDpiAwarenessInternal"); 3919 + pGetThreadDpiAwarenessContext = (void*)GetProcAddress(hdll, "GetThreadDpiAwarenessContext"); 3920 + pSetThreadDpiAwarenessContext = (void*)GetProcAddress(hdll, "SetThreadDpiAwarenessContext"); 3921 + pGetWindowDpiAwarenessContext = (void*)GetProcAddress(hdll, "GetWindowDpiAwarenessContext"); 3922 + pGetAwarenessFromDpiAwarenessContext = (void*)GetProcAddress(hdll, "GetAwarenessFromDpiAwarenessContext"); 3923 + pIsValidDpiAwarenessContext = (void*)GetProcAddress(hdll, "IsValidDpiAwarenessContext"); 3924 + pGetSystemMetricsForDpi = (void*)GetProcAddress(hdll, "GetSystemMetricsForDpi"); 3925 + pSystemParametersInfoForDpi = (void*)GetProcAddress(hdll, "SystemParametersInfoForDpi"); 3926 + pAdjustWindowRectExForDpi = (void*)GetProcAddress(hdll, "AdjustWindowRectExForDpi"); 3927 + pLogicalToPhysicalPointForPerMonitorDPI = (void*)GetProcAddress(hdll, "LogicalToPhysicalPointForPerMonitorDPI"); 3928 + pPhysicalToLogicalPointForPerMonitorDPI = (void*)GetProcAddress(hdll, "PhysicalToLogicalPointForPerMonitorDPI"); 3047 3929 pGetAutoRotationState = (void*)GetProcAddress(hdll, "GetAutoRotationState"); 3048 3930 3049 3931 hInstance = GetModuleHandleA( NULL ); ··· 3051 3933 dpi = GetDeviceCaps( hdc, LOGPIXELSY); 3052 3934 real_dpi = get_real_dpi(); 3053 3935 trace("dpi %d real_dpi %d\n", dpi, real_dpi); 3054 - iswin9x = GetVersion() & 0x80000000; 3936 + ReleaseDC( 0, hdc); 3055 3937 3056 3938 /* This test requires interactivity, if we don't have it, give up */ 3057 3939 if (!SystemParametersInfoA( SPI_SETBEEP, TRUE, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE ) && ··· 3063 3945 3064 3946 trace("testing GetSystemMetrics with your current desktop settings\n"); 3065 3947 test_GetSystemMetrics( ); 3066 - trace("testing EnumDisplaySettings vs GetDeviceCaps\n"); 3948 + test_metrics_for_dpi( 192 ); 3067 3949 test_EnumDisplaySettings( ); 3068 3950 test_GetSysColorBrush( ); 3069 3951 test_GetAutoRotationState( ); ··· 3082 3964 wc.cbClsExtra = 0; 3083 3965 wc.cbWndExtra = 0; 3084 3966 RegisterClassA( &wc ); 3967 + wc.lpszClassName = "DpiTestClass"; 3968 + wc.lpfnWndProc = dpi_winproc; 3969 + RegisterClassA( &wc ); 3085 3970 3086 3971 ghTestWnd = CreateWindowA( "SysParamsTestClass", "Test System Parameters Application", 3087 3972 WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, 0, 0, hInstance, NULL ); ··· 3094 3979 TranslateMessage( &msg ); 3095 3980 DispatchMessageA( &msg ); 3096 3981 } 3097 - ReleaseDC( 0, hdc); 3982 + 3983 + if (pSetThreadDpiAwarenessContext) 3984 + { 3985 + test_dpi_context(); 3986 + test_dpi_mapping(); 3987 + test_dpi_window(); 3988 + } 3989 + else win_skip( "SetThreadDpiAwarenessContext not supported\n" ); 3098 3990 3099 3991 test_dpi_aware(); 3100 3992 }
+2
modules/rostests/winetests/user32/testlist.c
··· 32 32 extern void func_msg_layered_window(void); 33 33 extern void func_msg_dialog(void); 34 34 extern void func_msg_clipboard(void); 35 + extern void func_rawinput(void); 35 36 extern void func_resource(void); 36 37 extern void func_scroll(void); 37 38 extern void func_static(void); ··· 72 73 { "msg_layered_window", func_msg_layered_window}, 73 74 { "msg_dialog", func_msg_dialog}, 74 75 { "msg_clipboard", func_msg_clipboard}, 76 + { "rawinput", func_rawinput }, 75 77 { "resource", func_resource }, 76 78 { "scroll", func_scroll }, 77 79 { "static", func_static },
+19 -4
modules/rostests/winetests/user32/text.c
··· 277 277 ok(textheight==0,"Got textheight from DrawTextA\n"); 278 278 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n"); 279 279 280 + /* When offset to top is zero, return 1 */ 281 + SetRectEmpty(&rect); 282 + textheight = DrawTextExW(hdc, textW, -1, &rect, DT_SINGLELINE | DT_CALCRECT | DT_BOTTOM, NULL); 283 + ok(textheight == 1, "Expect returned height:1 got:%d\n", textheight); 284 + 285 + SetRect(&rect, 0, 100, 0, 100); 286 + textheight = DrawTextExW(hdc, textW, -1, &rect, DT_SINGLELINE | DT_CALCRECT | DT_BOTTOM, NULL); 287 + ok(textheight == 1, "Expect returned height:1 got:%d\n", textheight); 288 + 289 + SetRectEmpty(&rect); 290 + textheight = DrawTextExW(hdc, textW, -1, &rect, DT_SINGLELINE | DT_CALCRECT | DT_TOP, NULL); 291 + /* Set top to text height and bottom zero, so bottom of drawn text to top is zero when DT_VCENTER is used */ 292 + SetRect(&rect, 0, textheight, 0, 0); 293 + textheight = DrawTextExW(hdc, textW, -1, &rect, DT_SINGLELINE | DT_CALCRECT | DT_VCENTER, NULL); 294 + ok(textheight == 1, "Expect returned height:1 got:%d\n", textheight); 280 295 281 296 /* invalid dtp size test */ 282 297 dtp.cbSize = -1; /* Invalid */ ··· 750 765 char oem; 751 766 WCHAR uni, expect; 752 767 753 - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) 768 + for (i = 0; i < ARRAY_SIZE(tests); i++) 754 769 { 755 770 const char *expected = tests[i].ret ? helloWorld : ""; 756 771 const char *src = tests[i].src ? helloWorld : NULL; ··· 777 792 ok(!strcmp(buf, expected), "test %d: got '%s'\n", i, buf); 778 793 } 779 794 780 - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) 795 + for (i = 0; i < ARRAY_SIZE(tests); i++) 781 796 { 782 797 const char *expected = tests[i].ret ? helloWorld : ""; 783 798 const WCHAR *src = tests[i].src ? helloWorldW : NULL; ··· 789 804 ok(!strcmp(buf, expected), "test %d: got '%s'\n", i, buf); 790 805 791 806 memset(buf, 0, sizeof(buf)); 792 - ret = CharToOemBuffW(src, dst, sizeof(helloWorldW)/sizeof(WCHAR)); 807 + ret = CharToOemBuffW(src, dst, ARRAY_SIZE(helloWorldW)); 793 808 ok(ret == tests[i].ret, "test %d: expected %d, got %d\n", i, tests[i].ret, ret); 794 809 ok(!strcmp(buf, expected), "test %d: got '%s'\n", i, buf); 795 810 } 796 811 797 - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) 812 + for (i = 0; i < ARRAY_SIZE(tests); i++) 798 813 { 799 814 const WCHAR *expected = tests[i].ret ? helloWorldW : emptyW; 800 815 const char *src = tests[i].src ? helloWorld : NULL;
+1 -1
modules/rostests/winetests/user32/uitools.c
··· 175 175 {{-109, -107, -103, -101}, FALSE}, 176 176 }; 177 177 178 - for (i = 0; i < sizeof(rtest)/sizeof(rtest[0]); i++) { 178 + for (i = 0; i < ARRAY_SIZE(rtest); i++) { 179 179 ret = IsRectEmpty(&rtest[i].rect); 180 180 ok(ret == rtest[i].ret, "Test %d: IsRectEmpty returned %s for %s\n", i, 181 181 ret ? "TRUE" : "FALSE", wine_dbgstr_rect(&rtest[i].rect));
+4 -4
modules/rostests/winetests/user32/wsprintf.c
··· 66 66 win_skip( "I64 formats not supported\n" ); 67 67 return; 68 68 } 69 - for (i = 0; i < sizeof(i64_formats)/sizeof(i64_formats[0]); i++) 69 + for (i = 0; i < ARRAY_SIZE(i64_formats); i++) 70 70 { 71 71 rc = wsprintfA(buf, i64_formats[i].fmt, i64_formats[i].value); 72 72 ok(rc == strlen(i64_formats[i].res), "%u: wsprintfA length failure: rc=%d\n", i, rc); ··· 98 98 win_skip( "I64 formats not supported\n" ); 99 99 return; 100 100 } 101 - for (i = 0; i < sizeof(i64_formats)/sizeof(i64_formats[0]); i++) 101 + for (i = 0; i < ARRAY_SIZE(i64_formats); i++) 102 102 { 103 - MultiByteToWideChar( CP_ACP, 0, i64_formats[i].fmt, -1, fmt, sizeof(fmt)/sizeof(WCHAR) ); 104 - MultiByteToWideChar( CP_ACP, 0, i64_formats[i].res, -1, res, sizeof(res)/sizeof(WCHAR) ); 103 + MultiByteToWideChar( CP_ACP, 0, i64_formats[i].fmt, -1, fmt, ARRAY_SIZE(fmt)); 104 + MultiByteToWideChar( CP_ACP, 0, i64_formats[i].res, -1, res, ARRAY_SIZE(res)); 105 105 rc = wsprintfW(buf, fmt, i64_formats[i].value); 106 106 ok(rc == lstrlenW(res), "%u: wsprintfW length failure: rc=%d\n", i, rc); 107 107 ok(!lstrcmpW(buf, res), "%u: wrong result [%s]\n", i, wine_dbgstr_w(buf));