ReactOS 0.4.15-dev-7131-ge4d03f4
DM_REPOSITION.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS API tests
3 * LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
4 * PURPOSE: Test for DM_REPOSITION
5 * COPYRIGHT: Copyright 2019 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6 */
7
8#include "precomp.h"
9#include <windowsx.h>
10
12{
13 RECT rc, rc2, rcWork;
14 INT cx, cy, nBitsPixel;
15 HMONITOR hMon;
16 MONITORINFO mi = { sizeof(mi) };
17 HDC hdc;
18
19 /* get monitor info */
20 hMon = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
21 ok(hMon != NULL, "hMon is NULL\n");
22 ok_int(GetMonitorInfoW(hMon, &mi), TRUE);
23 rcWork = mi.rcWork;
24
25 /* get size */
26 GetWindowRect(hwnd, &rc);
27 cx = rc.right - rc.left;
28 cy = rc.bottom - rc.top;
29
30 /* move */
31 ok_int(SetWindowPos(hwnd, NULL, rcWork.left - 80, rcWork.top - 80, 0, 0,
35 ok_long(rc.left, rcWork.left - 80);
36 ok_long(rc.top, rcWork.top - 80);
37 ok_long(rc.right, rc.left + cx);
38 ok_long(rc.bottom, rc.top + cy);
39
40 /* reposition */
43 ok_long(rc.left, rcWork.left);
44 ok_long(rc.top, rcWork.top);
45 ok_long(rc.right, rc.left + cx);
46 ok_long(rc.bottom, rc.top + cy);
47
48 /* move */
50 rcWork.right - cx + 80, rcWork.bottom - cy + 80, 0, 0,
54 ok_long(rc.left, rcWork.right - cx + 80);
55 ok_long(rc.top, rcWork.bottom - cy + 80);
56 ok_long(rc.right, rc.left + cx);
57 ok_long(rc.bottom, rc.top + cy);
58
59 /* reposition */
62 ok_long(rc.left, rcWork.right - cx);
63 ok_long(rc.top, rcWork.bottom - cy - 4);
64 ok_long(rc.right, rc.left + cx);
65 ok_long(rc.bottom, rc.top + cy);
66
67 /* minimize */
70
71 /* reposition */
74 ok_int(EqualRect(&rc, &rc2), TRUE);
75
76 /* restore */
78
79 /* move */
81 rcWork.right - cx + 80, rcWork.bottom - cy + 80, 0, 0,
85 ok_long(rc.left, rcWork.right - cx + 80);
86 ok_long(rc.top, rcWork.bottom - cy + 80);
87 ok_long(rc.right, rc.left + cx);
88 ok_long(rc.bottom, rc.top + cy);
89
90 /* WM_DISPLAYCHANGE */
92 nBitsPixel = GetDeviceCaps(hdc, BITSPIXEL);
94 SendMessageW(hwnd, WM_DISPLAYCHANGE, nBitsPixel,
98 ok_long(rc.left, rcWork.right - cx + 80);
99 ok_long(rc.top, rcWork.bottom - cy + 80);
100 ok_long(rc.right, rc.left + cx);
101 ok_long(rc.bottom, rc.top + cy);
102
103 /* quit */
105 return TRUE;
106}
107
108static void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
109{
110 switch (id)
111 {
112 case IDOK:
113 case IDCANCEL:
114 EndDialog(hwnd, id);
115 break;
116 }
117}
118
119static INT_PTR CALLBACK
121{
122 switch (uMsg)
123 {
126 }
127 return 0;
128}
129
131{
133 ok(hMod != NULL, "\n");
134 DialogBox(hMod, TEXT("REPOSITION"), NULL, DialogProc);
135}
static INT_PTR CALLBACK DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
static BOOL OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
Definition: DM_REPOSITION.c:11
static void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
#define ok_long(expression, result)
Definition: atltest.h:133
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define ok_int(expression, result)
Definition: atltest.h:134
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
static const WCHAR rc2[]
Definition: oid.c:1216
#define CALLBACK
Definition: compat.h:35
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TEXT(s)
Definition: k32.h:26
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
HMONITOR WINAPI MonitorFromWindow(HWND, DWORD)
unsigned int UINT
Definition: ndis.h:50
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
int32_t INT_PTR
Definition: typedefs.h:64
int32_t INT
Definition: typedefs.h:58
#define MAKELONG(a, b)
Definition: typedefs.h:249
static MONITORINFO mi
Definition: win.c:7338
#define GetModuleHandle
Definition: winbase.h:3762
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define HANDLE_MSG(hwnd, message, fn)
Definition: windowsx.h:322
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define BITSPIXEL
Definition: wingdi.h:720
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define SWP_NOACTIVATE
Definition: winuser.h:1241
HDC WINAPI GetWindowDC(_In_opt_ HWND)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define SM_CYSCREEN
Definition: winuser.h:959
#define IDCANCEL
Definition: winuser.h:830
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define SW_MINIMIZE
Definition: winuser.h:775
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define WM_COMMAND
Definition: winuser.h:1739
#define SWP_NOSIZE
Definition: winuser.h:1244
#define WM_INITDIALOG
Definition: winuser.h:1738
#define IDOK
Definition: winuser.h:829
#define PostMessage
Definition: winuser.h:5831
#define SWP_NOOWNERZORDER
Definition: winuser.h:1248
#define SW_RESTORE
Definition: winuser.h:778
#define SM_CXSCREEN
Definition: winuser.h:958
BOOL WINAPI GetMonitorInfoW(_In_ HMONITOR, _Inout_ LPMONITORINFO)
#define SWP_NOZORDER
Definition: winuser.h:1246
#define DM_REPOSITION
Definition: winuser.h:2099
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)
int WINAPI GetSystemMetrics(_In_ int)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define DialogBox
Definition: winuser.h:5760
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)