ReactOS 0.4.15-dev-8100-g1887773
nonclient.c
Go to the documentation of this file.
1/*
2 * ReactOS User32 Library
3 * - Window non-client area management
4 *
5 * Copyright (C) 2003 ReactOS Team
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include <user32.h>
23
25
26#define HASSIZEGRIP(Style, ExStyle, ParentStyle, WindowRect, ParentClientRect) \
27 ((!(Style & WS_CHILD) && (Style & WS_THICKFRAME) && !(Style & WS_MAXIMIZE)) || \
28 ((Style & WS_CHILD) && (ParentStyle & WS_THICKFRAME) && !(ParentStyle & WS_MAXIMIZE) && \
29 (WindowRect.right - WindowRect.left == ParentClientRect.right) && \
30 (WindowRect.bottom - WindowRect.top == ParentClientRect.bottom)))
31
32
33/* PRIVATE FUNCTIONS **********************************************************/
34
35BOOL
37{
38 if (Style & WS_MINIMIZE)
39 return TRUE;
41 return TRUE;
43 return FALSE;
44 if (Style & WS_THICKFRAME)
45 return TRUE;
47 if (Style == WS_DLGFRAME || Style == WS_CAPTION)
48 return TRUE;
49 return FALSE;
50}
51
52VOID
54{
55 DWORD Border = 0;
56
58 Border += 2;
59 else if (ExStyle & WS_EX_STATICEDGE)
60 Border += 1;
61 if ((ExStyle & WS_EX_CLIENTEDGE) && WithClient)
62 Border += 2;
64 Border ++;
65 Size->cx = Size->cy = Border;
66 if ((Style & WS_THICKFRAME) && !(Style & WS_MINIMIZE))
67 {
70 }
73}
74
75/*
76 RealUserDrawCaption: This function is passed through RegisterUserApiHook to uxtheme
77 to call it when the classic caption is needed to be drawn.
78 */
81{
82 ERR("Real DC flags %08x\n",uFlags);
83 return NtUserDrawCaption(hWnd, hDC, lpRc, uFlags);
84}
85
86
87/* PUBLIC FUNCTIONS ***********************************************************/
88
91 DWORD dwStyle,
92 BOOL bMenu,
93 DWORD dwExStyle)
94{
95 SIZE BorderSize;
96
97 if (bMenu)
98 {
99 lpRect->top -= GetSystemMetrics(SM_CYMENU);
100 }
101 if ((dwStyle & WS_CAPTION) == WS_CAPTION)
102 {
103 if (dwExStyle & WS_EX_TOOLWINDOW)
105 else
107 }
108 UserGetWindowBorders(dwStyle, dwExStyle, &BorderSize, TRUE);
110 lpRect,
111 BorderSize.cx,
112 BorderSize.cy);
113
114 return TRUE;
115}
116
117/*
118 * @implemented
119 */
120BOOL
121WINAPI
124 DWORD dwStyle,
125 BOOL bMenu,
126 DWORD dwExStyle)
127{
128 BOOL Hook, Ret = FALSE;
129
131
133
134 /* Bypass SEH and go direct. */
135 if (!Hook) return RealAdjustWindowRectEx(lpRect, dwStyle, bMenu, dwExStyle);
136
138 {
139 Ret = guah.AdjustWindowRectEx(lpRect, dwStyle, bMenu, dwExStyle);
140 }
142 {
143 }
144 _SEH2_END;
145
147
148 return Ret;
149}
150
151
152/*
153 * @implemented
154 */
155BOOL
156WINAPI
159 DWORD dwStyle,
160 BOOL bMenu)
161{
162 return AdjustWindowRectEx(lpRect, dwStyle, bMenu, 0);
163}
164
165// Enabling this will cause captions to draw smoother, but slower:
166#define DOUBLE_BUFFER_CAPTION
167
168/*
169 * @implemented
170 */
173{
174 BOOL Hook, Ret = FALSE;
175
177
179
180 /* Bypass SEH and go direct. */
181 if (!Hook) return NtUserDrawCaption(hWnd, hDC, lprc, uFlags);
182
184 {
186 }
188 {
189 }
190 _SEH2_END;
191
193
194 return Ret;
195}
196
197/*
198 * @implemented
199 */
200BOOL
201WINAPI
203 HWND hWnd,
204 HDC hDC,
205 const RECT *rect,
206 HFONT hFont,
207 HICON hIcon,
208 LPCWSTR str,
210 )
211{
212 UNICODE_STRING Text = {0};
215}
216
217/*
218 * @implemented
219 */
220BOOL
221WINAPI
223 HWND hwnd,
224 HDC hdc,
225 const RECT *rect,
226 HFONT hFont,
227 HICON hIcon,
228 LPCSTR str,
230 )
231{
232 LPWSTR strW;
233 INT len;
234 BOOL ret = FALSE;
235
236 if (!(uFlags & DC_TEXT) || !str)
238
239 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
240 if ((strW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR))))
241 {
245 }
246 return ret;
247}
static HDC hDC
Definition: 3dtext.c:33
#define DECLSPEC_HOTPATCH
Definition: _mingw.h:243
const DWORD Style
Definition: appswitch.c:71
const DWORD ExStyle
Definition: appswitch.c:72
HWND hWnd
Definition: settings.c:17
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
HFONT hFont
Definition: main.c:53
#define ERR(fmt,...)
Definition: debug.h:113
char * Text
Definition: combotst.c:136
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
UINT uFlags
Definition: api.c:59
#define GetProcessHeap()
Definition: compat.h:736
#define CP_ACP
Definition: compat.h:109
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define MultiByteToWideChar
Definition: compat.h:110
static BOOL UserHasWindowEdge(DWORD Style, DWORD ExStyle)
Definition: nonclient.c:46
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
BOOL NTAPI NtUserDrawCaptionTemp(HWND hWnd, HDC hDC, LPCRECT lpRc, HFONT hFont, HICON hIcon, const PUNICODE_STRING str, UINT uFlags)
Definition: painting.c:2373
BOOL NTAPI NtUserDrawCaption(HWND hWnd, HDC hDc, LPCRECT lpRc, UINT uFlags)
Definition: painting.c:2456
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
static HICON
Definition: imagelist.c:84
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
WCHAR strW[12]
Definition: clipboard.c:2029
HICON hIcon
Definition: msconfig.c:44
unsigned int UINT
Definition: ndis.h:50
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
VOID UserGetWindowBorders(DWORD Style, DWORD ExStyle, SIZE *Size, BOOL WithClient)
Definition: winpos.c:888
#define WS_CAPTION
Definition: pedump.c:624
#define WS_EX_DLGMODALFRAME
Definition: pedump.c:645
#define WS_MINIMIZE
Definition: pedump.c:622
#define WS_DLGFRAME
Definition: pedump.c:626
#define WS_THICKFRAME
Definition: pedump.c:630
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
const WCHAR * str
& rect
Definition: startmenu.cpp:1413
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
LONG top
Definition: windef.h:307
ADJUSTWINDOWRECTEX AdjustWindowRectEx
Definition: undocuser.h:345
DRAWCAPTION DrawCaption
Definition: undocuser.h:358
int32_t INT
Definition: typedefs.h:58
BOOL FASTCALL EndUserApiHook(VOID)
Definition: usrapihk.c:164
BOOL FASTCALL BeginIfHookedUserApiHook(VOID)
Definition: usrapihk.c:106
USERAPIHOOK guah
Definition: usrapihk.c:344
static __inline void LoadUserApiHook()
Definition: user_x.h:85
int ret
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
BOOL WINAPI DrawCaptionTempA(HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont, HICON hIcon, LPCSTR str, UINT uFlags)
Definition: nonclient.c:222
BOOL WINAPI RealAdjustWindowRectEx(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle)
Definition: nonclient.c:90
BOOL WINAPI DECLSPEC_HOTPATCH AdjustWindowRectEx(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle)
Definition: nonclient.c:123
BOOL WINAPI DECLSPEC_HOTPATCH AdjustWindowRect(LPRECT lpRect, DWORD dwStyle, BOOL bMenu)
Definition: nonclient.c:158
BOOL WINAPI DrawCaption(HWND hWnd, HDC hDC, LPCRECT lprc, UINT uFlags)
Definition: nonclient.c:172
BOOL WINAPI DrawCaptionTempW(HWND hWnd, HDC hDC, const RECT *rect, HFONT hFont, HICON hIcon, LPCWSTR str, UINT uFlags)
Definition: nonclient.c:202
BOOL WINAPI RealUserDrawCaption(HWND hWnd, HDC hDC, LPCRECT lpRc, UINT uFlags)
Definition: nonclient.c:80
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define WINAPI
Definition: msvc.h:6
#define WS_EX_STATICEDGE
Definition: winuser.h:403
#define SM_CXFRAME
Definition: winuser.h:994
#define SM_CYMENU
Definition: winuser.h:976
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
#define SM_CYFRAME
Definition: winuser.h:996
#define SM_CYBORDER
Definition: winuser.h:965
#define SM_CXBORDER
Definition: winuser.h:964
#define DC_TEXT
Definition: winuser.h:430
#define SM_CXDLGFRAME
Definition: winuser.h:966
_In_ int _Inout_ LPRECT lprc
Definition: winuser.h:4466
#define SM_CYSMCAPTION
Definition: winuser.h:1014
#define SM_CYDLGFRAME
Definition: winuser.h:968
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define SM_CYCAPTION
Definition: winuser.h:963
int WINAPI GetSystemMetrics(_In_ int)
const char * LPCSTR
Definition: xmlstorage.h:183
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185