diff --git a/dlls/user/tests/win.c b/dlls/user/tests/win.c index d070d546285..1dd73c11893 100644 --- a/dlls/user/tests/win.c +++ b/dlls/user/tests/win.c @@ -928,7 +928,7 @@ static void test_shell_window(void) static const char mdi_lParam_test_message[] = "just a test string"; -static void test_MDI_create(HWND parent, HWND mdi_client) +static void test_MDI_create(HWND parent, HWND mdi_client, INT first_id) { MDICREATESTRUCTA mdi_cs; HWND mdi_child; @@ -947,12 +947,14 @@ static void test_MDI_create(HWND parent, HWND mdi_client) mdi_cs.lParam = (LPARAM)mdi_lParam_test_message; mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs); ok(mdi_child != 0, "MDI child creation failed\n"); + ok(GetWindowLongA(mdi_child, GWL_ID) == first_id, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0); ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n"); mdi_cs.style = 0x7fffffff; /* without WS_POPUP */ mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs); ok(mdi_child != 0, "MDI child creation failed\n"); + ok(GetWindowLongA(mdi_child, GWL_ID) == first_id, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0); ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n"); @@ -965,6 +967,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client) else { ok(mdi_child != 0, "MDI child creation failed\n"); + ok(GetWindowLongA(mdi_child, GWL_ID) == first_id, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0); ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n"); } @@ -985,6 +988,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client) } else { + ok(GetWindowLongA(mdi_child, GWL_ID) == first_id, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0); ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n"); } @@ -996,6 +1000,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client) mdi_client, GetModuleHandle(0), (LPARAM)mdi_lParam_test_message); ok(mdi_child != 0, "MDI child creation failed\n"); + ok(GetWindowLongA(mdi_child, GWL_ID) == first_id, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0); ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n"); @@ -1006,6 +1011,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client) mdi_client, GetModuleHandle(0), (LPARAM)mdi_lParam_test_message); ok(mdi_child != 0, "MDI child creation failed\n"); + ok(GetWindowLongA(mdi_child, GWL_ID) == first_id, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0); ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n"); @@ -1022,6 +1028,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client) else { ok(mdi_child != 0, "MDI child creation failed\n"); + ok(GetWindowLongA(mdi_child, GWL_ID) == first_id, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0); ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n"); } @@ -1043,6 +1050,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client) } else { + ok(GetWindowLongA(mdi_child, GWL_ID) == first_id, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0); ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n"); } @@ -1054,6 +1062,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client) mdi_client, 0, GetModuleHandle(0), (LPVOID)mdi_lParam_test_message); ok(mdi_child != 0, "MDI child creation failed\n"); + ok(GetWindowLongA(mdi_child, GWL_ID) == first_id, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0); ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n"); @@ -1064,6 +1073,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client) mdi_client, 0, GetModuleHandle(0), (LPVOID)mdi_lParam_test_message); ok(mdi_child != 0, "MDI child creation failed\n"); + ok(GetWindowLongA(mdi_child, GWL_ID) == first_id, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0); ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n"); @@ -1080,6 +1090,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client) else { ok(mdi_child != 0, "MDI child creation failed\n"); + ok(GetWindowLongA(mdi_child, GWL_ID) == first_id, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0); ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n"); } @@ -1101,6 +1112,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client) } else { + ok(GetWindowLongA(mdi_child, GWL_ID) == first_id, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0); ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n"); } @@ -1124,6 +1136,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client) mdi_client, 0, GetModuleHandle(0), (LPVOID)mdi_lParam_test_message); ok(mdi_child != 0, "MDI child creation failed\n"); + ok(GetWindowLongA(mdi_child, GWL_ID) == 0, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); DestroyWindow(mdi_child); mdi_child = CreateWindowExA(0, "MDI_child_Class_2", "MDI child", @@ -1133,6 +1146,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client) mdi_client, 0, GetModuleHandle(0), (LPVOID)mdi_lParam_test_message); ok(mdi_child != 0, "MDI child creation failed\n"); + ok(GetWindowLongA(mdi_child, GWL_ID) == 0, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); DestroyWindow(mdi_child); /* maximized child */ @@ -1143,6 +1157,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client) mdi_client, 0, GetModuleHandle(0), (LPVOID)mdi_lParam_test_message); ok(mdi_child != 0, "MDI child creation failed\n"); + ok(GetWindowLongA(mdi_child, GWL_ID) == 0, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); DestroyWindow(mdi_child); trace("Creating maximized child with a caption\n"); @@ -1153,6 +1168,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client) mdi_client, 0, GetModuleHandle(0), (LPVOID)mdi_lParam_test_message); ok(mdi_child != 0, "MDI child creation failed\n"); + ok(GetWindowLongA(mdi_child, GWL_ID) == 0, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); DestroyWindow(mdi_child); trace("Creating maximized child with a caption and a thick frame\n"); @@ -1163,6 +1179,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client) mdi_client, 0, GetModuleHandle(0), (LPVOID)mdi_lParam_test_message); ok(mdi_child != 0, "MDI child creation failed\n"); + ok(GetWindowLongA(mdi_child, GWL_ID) == 0, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); DestroyWindow(mdi_child); } @@ -1466,7 +1483,7 @@ static LRESULT WINAPI mdi_main_wnd_procA(HWND hwnd, UINT msg, WPARAM wparam, LPA hwnd, 0, GetModuleHandle(0), (LPVOID)&client_cs); assert(mdi_client); - test_MDI_create(hwnd, mdi_client); + test_MDI_create(hwnd, mdi_client, client_cs.idFirstChild); DestroyWindow(mdi_client); /* MDIClient with MDIS_ALLCHILDSTYLES */ @@ -1478,7 +1495,7 @@ static LRESULT WINAPI mdi_main_wnd_procA(HWND hwnd, UINT msg, WPARAM wparam, LPA hwnd, 0, GetModuleHandle(0), (LPVOID)&client_cs); assert(mdi_client); - test_MDI_create(hwnd, mdi_client); + test_MDI_create(hwnd, mdi_client, client_cs.idFirstChild); DestroyWindow(mdi_client); break; } diff --git a/include/win.h b/include/win.h index 11deac68929..ce1025aac23 100644 --- a/include/win.h +++ b/include/win.h @@ -93,7 +93,7 @@ extern void WIN_DestroyThreadWindows( HWND hwnd ); extern BOOL WIN_CreateDesktopWindow(void); extern BOOL WIN_IsWindowDrawable( HWND hwnd, BOOL ); extern HWND *WIN_ListChildren( HWND hwnd ); -extern void MDI_CalcDefaultChildPos( HWND hwndClient, INT total, LPPOINT lpPos, INT delta ); +extern void MDI_CalcDefaultChildPos( HWND hwndClient, INT total, LPPOINT lpPos, INT delta, UINT *id ); /* internal SendInput codes (FIXME) */ #define WINE_INTERNAL_INPUT_MOUSE (16+INPUT_MOUSE) diff --git a/windows/mdi.c b/windows/mdi.c index caeb695c485..c4b9e4c259d 100644 --- a/windows/mdi.c +++ b/windows/mdi.c @@ -247,17 +247,17 @@ static HWND MDI_GetWindow(MDICLIENTINFO *clientInfo, HWND hWnd, BOOL bNext, * * It seems that the default height is about 2/3 of the client rect */ -void MDI_CalcDefaultChildPos( HWND hwndClient, INT total, LPPOINT lpPos, INT delta ) +void MDI_CalcDefaultChildPos( HWND hwndClient, INT total, LPPOINT lpPos, INT delta, UINT *id ) { INT nstagger; RECT rect; - INT spacing = GetSystemMetrics(SM_CYCAPTION) + - GetSystemMetrics(SM_CYFRAME) - 1; + INT spacing = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME) - 1; - if (total < 0) + if (total < 0) /* we are called from CreateWindow */ { MDICLIENTINFO *ci = get_client_info(hwndClient); total = ci ? ci->nTotalCreated : 0; + *id = ci->idFirstChild + ci->nActiveChildren; } GetClientRect( hwndClient, &rect ); @@ -688,7 +688,7 @@ static LONG MDICascade( HWND client, MDICLIENTINFO *ci ) TRACE("move %p to (%ld,%ld) size [%ld,%ld]\n", win_array[i], pos[0].x, pos[0].y, pos[1].x, pos[1].y); - MDI_CalcDefaultChildPos(client, n++, pos, delta); + MDI_CalcDefaultChildPos(client, n++, pos, delta, NULL); SetWindowPos( win_array[i], 0, pos[0].x, pos[0].y, pos[1].x, pos[1].y, SWP_DRAWFRAME | SWP_NOACTIVATE | SWP_NOZORDER); } diff --git a/windows/win.c b/windows/win.c index 5f6190ed71c..b1de4a4ed1a 100644 --- a/windows/win.c +++ b/windows/win.c @@ -786,9 +786,11 @@ static void WIN_FixCoordinates( CREATESTRUCTA *cs, INT *sw) { if (cs->dwExStyle & WS_EX_MDICHILD) { + UINT id = 0; POINT pos[2]; - MDI_CalcDefaultChildPos(cs->hwndParent, -1, pos, 0); + MDI_CalcDefaultChildPos(cs->hwndParent, -1, pos, 0, &id); + if (!(cs->style & WS_POPUP)) cs->hMenu = (HMENU)id; if (cs->x == CW_USEDEFAULT || cs->x == CW_USEDEFAULT16) {