ReactOS  0.4.15-dev-492-ga1108f6
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,
33  SWP_NOZORDER), TRUE);
34  ok_int(GetWindowRect(hwnd, &rc), TRUE);
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 */
42  ok_int(GetWindowRect(hwnd, &rc), TRUE);
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,
52  SWP_NOZORDER), TRUE);
53  ok_int(GetWindowRect(hwnd, &rc), TRUE);
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 */
61  ok_int(GetWindowRect(hwnd, &rc), TRUE);
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 */
69  ok_int(GetWindowRect(hwnd, &rc), TRUE);
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,
83  SWP_NOZORDER), TRUE);
84  ok_int(GetWindowRect(hwnd, &rc), TRUE);
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 */
91  hdc = GetWindowDC(hwnd);
92  nBitsPixel = GetDeviceCaps(hdc, BITSPIXEL);
93  ReleaseDC(hwnd, hdc);
94  SendMessageW(hwnd, WM_DISPLAYCHANGE, nBitsPixel,
97  ok_int(GetWindowRect(hwnd, &rc), TRUE);
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 
108 static 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 
119 static INT_PTR CALLBACK
121 {
122  switch (uMsg)
123  {
126  }
127  return 0;
128 }
129 
131 {
132  HMODULE hMod = GetModuleHandle(NULL);
133  ok(hMod != NULL, "\n");
134  DialogBox(hMod, TEXT("REPOSITION"), NULL, DialogProc);
135 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define BITSPIXEL
Definition: wingdi.h:719
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
static HDC
Definition: imagelist.c:92
#define CALLBACK
Definition: compat.h:27
LONG top
Definition: windef.h:307
static MONITORINFO mi
Definition: win.c:7339
UINT_PTR WPARAM
Definition: windef.h:207
LONG left
Definition: windef.h:306
#define SWP_NOZORDER
Definition: winuser.h:1232
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
int32_t INT_PTR
Definition: typedefs.h:63
#define SW_RESTORE
Definition: winuser.h:773
#define ok_long(expression, result)
Definition: atltest.h:133
LONG right
Definition: windef.h:308
int32_t INT
Definition: typedefs.h:57
WPARAM wParam
Definition: combotst.c:138
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
#define DialogBox
Definition: winuser.h:5736
#define SM_CXSCREEN
Definition: winuser.h:949
unsigned int BOOL
Definition: ntddk_ex.h:94
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:581
#define MAKELONG(a, b)
Definition: typedefs.h:248
smooth NULL
Definition: ftsmooth.c:416
#define ok_int(expression, result)
Definition: atltest.h:134
START_TEST(DM_REPOSITION)
LONG_PTR LPARAM
Definition: windef.h:208
#define PostMessage
Definition: winuser.h:5807
#define SM_CYSCREEN
Definition: winuser.h:950
static INT_PTR CALLBACK DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
BOOL WINAPI GetMonitorInfoW(_In_ HMONITOR, _Inout_ LPMONITORINFO)
#define SWP_NOACTIVATE
Definition: winuser.h:1227
int WINAPI GetSystemMetrics(_In_ int)
#define SW_MINIMIZE
Definition: winuser.h:770
#define DM_REPOSITION
Definition: winuser.h:2082
HDC hdc
Definition: main.c:9
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define WM_COMMAND
Definition: winuser.h:1722
#define SWP_NOSIZE
Definition: winuser.h:1230
#define TEXT(s)
Definition: k32.h:26
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)
#define GetModuleHandle
Definition: winbase.h:3667
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define ok(value,...)
Definition: atltest.h:57
HMONITOR WINAPI MonitorFromWindow(HWND, DWORD)
HDC WINAPI GetWindowDC(_In_opt_ HWND)
unsigned int UINT
Definition: ndis.h:50
static BOOL OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
Definition: DM_REPOSITION.c:11
_Out_opt_ int * cx
Definition: commctrl.h:581
LONG bottom
Definition: windef.h:309
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define HANDLE_MSG(hwnd, message, fn)
Definition: windowsx.h:297
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
static const WCHAR rc2[]
Definition: oid.c:1216
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
static void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
#define SWP_NOOWNERZORDER
Definition: winuser.h:1234