diff --git a/modules/rostests/apitests/user32/CMakeLists.txt b/modules/rostests/apitests/user32/CMakeLists.txt index 24a6921472b..302a084934e 100644 --- a/modules/rostests/apitests/user32/CMakeLists.txt +++ b/modules/rostests/apitests/user32/CMakeLists.txt @@ -8,6 +8,7 @@ list(APPEND SOURCE CreateWindowEx.c DeferWindowPos.c DestroyCursorIcon.c + DM_REPOSITION.c DrawIconEx.c desktop.c EmptyClipboard.c diff --git a/modules/rostests/apitests/user32/DM_REPOSITION.c b/modules/rostests/apitests/user32/DM_REPOSITION.c new file mode 100644 index 00000000000..70d7c9e7632 --- /dev/null +++ b/modules/rostests/apitests/user32/DM_REPOSITION.c @@ -0,0 +1,98 @@ +/* + * PROJECT: ReactOS API tests + * LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+) + * PURPOSE: Test for DM_REPOSITION + * COPYRIGHT: Copyright 2019 Katayama Hirofumi MZ + */ + +#include "precomp.h" +#include + +static BOOL OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam) +{ + RECT rc, rcWork; + INT cx, cy; + HMONITOR hMon; + MONITORINFO mi = { sizeof(mi) }; + + /* get monitor info */ + hMon = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST); + ok(hMon != NULL, "hMon is NULL\n"); + ok_int(GetMonitorInfoW(hMon, &mi), TRUE); + rcWork = mi.rcWork; + + /* get size */ + GetWindowRect(hwnd, &rc); + cx = rc.right - rc.left; + cy = rc.bottom - rc.top; + + /* move */ + ok_int(SetWindowPos(hwnd, NULL, rcWork.left - 80, rcWork.top - 80, 0, 0, + SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOOWNERZORDER | + SWP_NOZORDER), TRUE); + ok_int(GetWindowRect(hwnd, &rc), TRUE); + ok_long(rc.left, rcWork.left - 80); + ok_long(rc.top, rcWork.top - 80); + ok_long(rc.right, rc.left + cx); + ok_long(rc.bottom, rc.top + cy); + + /* reposition */ + ok_int(SendMessageW(hwnd, DM_REPOSITION, 0, 0), 0); + ok_int(GetWindowRect(hwnd, &rc), TRUE); + ok_long(rc.left, rcWork.left); + ok_long(rc.top, rcWork.top); + ok_long(rc.right, rc.left + cx); + ok_long(rc.bottom, rc.top + cy); + + /* move */ + ok_int(SetWindowPos(hwnd, NULL, + rcWork.right - cx + 80, rcWork.bottom - cy + 80, 0, 0, + SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOOWNERZORDER | + SWP_NOZORDER), TRUE); + ok_int(GetWindowRect(hwnd, &rc), TRUE); + ok_long(rc.left, rcWork.right - cx + 80); + ok_long(rc.top, rcWork.bottom - cy + 80); + ok_long(rc.right, rc.left + cx); + ok_long(rc.bottom, rc.top + cy); + + /* reposition */ + ok_int(SendMessageW(hwnd, DM_REPOSITION, 0, 0), 0); + ok_int(GetWindowRect(hwnd, &rc), TRUE); + ok_long(rc.left, rcWork.right - cx); + ok_long(rc.top, rcWork.bottom - cy - 4); + ok_long(rc.right, rc.left + cx); + ok_long(rc.bottom, rc.top + cy); + + /* quit */ + PostMessage(hwnd, WM_COMMAND, IDOK, 0); + return TRUE; +} + +static void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) +{ + switch (id) + { + case IDOK: + case IDCANCEL: + EndDialog(hwnd, id); + break; + } +} + +static INT_PTR CALLBACK +DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uMsg) + { + HANDLE_MSG(hwnd, WM_INITDIALOG, OnInitDialog); + HANDLE_MSG(hwnd, WM_COMMAND, OnCommand); + } + return 0; +} + +START_TEST(DM_REPOSITION) +{ + HMODULE hMod = GetModuleHandle(NULL); + ok(hMod != NULL, "\n"); + DialogBox(hMod, TEXT("REPOSITION"), NULL, DialogProc); +} diff --git a/modules/rostests/apitests/user32/testlist.c b/modules/rostests/apitests/user32/testlist.c index 0118bf23b69..5803f028e69 100644 --- a/modules/rostests/apitests/user32/testlist.c +++ b/modules/rostests/apitests/user32/testlist.c @@ -10,6 +10,7 @@ extern void func_CreateIconFromResourceEx(void); extern void func_CreateWindowEx(void); extern void func_DeferWindowPos(void); extern void func_DestroyCursorIcon(void); +extern void func_DM_REPOSITION(void); extern void func_DrawIconEx(void); extern void func_desktop(void); extern void func_EmptyClipboard(void); @@ -57,6 +58,7 @@ const struct test winetest_testlist[] = { "CreateWindowEx", func_CreateWindowEx }, { "DeferWindowPos", func_DeferWindowPos }, { "DestroyCursorIcon", func_DestroyCursorIcon }, + { "DM_REPOSITION", func_DM_REPOSITION }, { "DrawIconEx", func_DrawIconEx }, { "desktop", func_desktop }, { "EmptyClipboard", func_EmptyClipboard }, diff --git a/modules/rostests/apitests/user32/user32_apitest.rc b/modules/rostests/apitests/user32/user32_apitest.rc index 85b88e08da5..8f56c8c8647 100644 --- a/modules/rostests/apitests/user32/user32_apitest.rc +++ b/modules/rostests/apitests/user32/user32_apitest.rc @@ -31,3 +31,10 @@ FONT 8, "MS Shell Dlg" CONTROL "OK", IDOK, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 65, 98, 60, 14 CONTROL "Cancel", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 187, 100, 60, 14 } + +REPOSITION DIALOG 0, 0, 200, 150 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "DM_REPOSITION" +FONT 8, "MS Shell Dlg" +{ +}