blob: 36bcc8f0433d4f7f5587b9959eff50a60df7d460 [file] [log] [blame]
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001/*
2 * Non-client area window functions
3 *
4 * Copyright 1994 Alexandre Julliard
Alexandre Julliard234bc241994-12-10 13:02:28 +00005 *
Alexandre Julliard7cbe6571995-01-09 18:21:16 +00006 */
Alexandre Julliardcdd09231994-01-12 11:12:51 +00007
Jeremy Whited3e22d92000-02-10 19:03:02 +00008#include "windef.h"
9#include "wingdi.h"
Michael Veksler9d14a001999-05-08 12:40:24 +000010#include "wine/winuser16.h"
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +000011#include "version.h"
Alexandre Julliardcdd09231994-01-12 11:12:51 +000012#include "win.h"
Alexandre Julliarddba420a1994-02-02 06:48:31 +000013#include "user.h"
Alex Korobka4f1ac051999-03-28 09:37:57 +000014#include "dce.h"
Alexandre Julliard91222da2000-12-10 23:01:33 +000015#include "controls.h"
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000016#include "cursoricon.h"
Alexandre Julliard234bc241994-12-10 13:02:28 +000017#include "winpos.h"
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +000018#include "hook.h"
Alexandre Julliard234bc241994-12-10 13:02:28 +000019#include "nonclient.h"
Alexandre Julliard06c275a1999-05-02 14:32:27 +000020#include "debugtools.h"
Marcus Meissner317af321999-02-17 13:51:06 +000021#include "shellapi.h"
Pascal Lessardd814bb61999-07-31 13:02:02 +000022#include "bitmap.h"
Alexandre Julliardcdd09231994-01-12 11:12:51 +000023
Dimitrie O. Paun529da542000-11-27 23:54:25 +000024DEFAULT_DEBUG_CHANNEL(nonclient);
25DECLARE_DEBUG_CHANNEL(shell);
Patrik Stridvallb4b9fae1999-04-19 14:56:29 +000026
Pascal Lessardd814bb61999-07-31 13:02:02 +000027BOOL NC_DrawGrayButton(HDC hdc, int x, int y);
28
Alexandre Julliardc1d35cc2001-01-24 19:47:57 +000029static HBITMAP hbitmapClose;
30static HBITMAP hbitmapMinimize;
31static HBITMAP hbitmapMinimizeD;
32static HBITMAP hbitmapMaximize;
33static HBITMAP hbitmapMaximizeD;
34static HBITMAP hbitmapRestore;
35static HBITMAP hbitmapRestoreD;
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +000036
Alexandre Julliardc1d35cc2001-01-24 19:47:57 +000037static const BYTE lpGrayMask[] = { 0xAA, 0xA0,
Pascal Lessardd814bb61999-07-31 13:02:02 +000038 0x55, 0x50,
39 0xAA, 0xA0,
40 0x55, 0x50,
41 0xAA, 0xA0,
42 0x55, 0x50,
43 0xAA, 0xA0,
44 0x55, 0x50,
45 0xAA, 0xA0,
46 0x55, 0x50};
47
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +000048#define SC_ABOUTWINE (SC_SCREENSAVE+1)
Uwe Bonnes37007771998-11-01 15:07:24 +000049#define SC_PUTMARK (SC_SCREENSAVE+2)
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +000050
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +000051 /* Some useful macros */
52#define HAS_DLGFRAME(style,exStyle) \
Alexandre Julliard0c126c71996-02-18 18:44:41 +000053 (((exStyle) & WS_EX_DLGMODALFRAME) || \
Ove Kaaven60c78f11999-07-03 15:40:29 +000054 (((style) & WS_DLGFRAME) && !((style) & WS_THICKFRAME)))
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +000055
Ove Kaaven60c78f11999-07-03 15:40:29 +000056#define HAS_THICKFRAME(style,exStyle) \
Alexandre Julliard0c126c71996-02-18 18:44:41 +000057 (((style) & WS_THICKFRAME) && \
Abey George48c6eb51999-09-03 12:33:40 +000058 !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +000059
Ove Kaaven60c78f11999-07-03 15:40:29 +000060#define HAS_THINFRAME(style) \
61 (((style) & WS_BORDER) || !((style) & (WS_CHILD | WS_POPUP)))
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000062
Ove Kaaven60c78f11999-07-03 15:40:29 +000063#define HAS_BIGFRAME(style,exStyle) \
64 (((style) & (WS_THICKFRAME | WS_DLGFRAME)) || \
65 ((exStyle) & WS_EX_DLGMODALFRAME))
Gerard Patel5773dad1999-06-12 14:45:56 +000066
Bill Medlandcbfbf2a2001-07-20 18:36:49 +000067#define HAS_STATICOUTERFRAME(style,exStyle) \
68 (((exStyle) & (WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME)) == \
69 WS_EX_STATICEDGE)
70
Ove Kaaven60c78f11999-07-03 15:40:29 +000071#define HAS_ANYFRAME(style,exStyle) \
72 (((style) & (WS_THICKFRAME | WS_DLGFRAME | WS_BORDER)) || \
73 ((exStyle) & WS_EX_DLGMODALFRAME) || \
74 !((style) & (WS_CHILD | WS_POPUP)))
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000075
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +000076#define HAS_MENU(w) (!((w)->dwStyle & WS_CHILD) && ((w)->wIDmenu != 0))
77
Sylvain St-Germain00bf3811999-07-24 12:11:22 +000078
79/***********************************************************************
Alexandre Julliardcdd09231994-01-12 11:12:51 +000080 * NC_AdjustRect
81 *
82 * Compute the size of the window rectangle from the size of the
83 * client rectangle.
84 */
Alexandre Julliard3abeae82001-05-09 17:21:04 +000085static void NC_AdjustRect( LPRECT rect, DWORD style, BOOL menu, DWORD exStyle )
Alexandre Julliardcdd09231994-01-12 11:12:51 +000086{
Alexandre Julliardd30dfd21998-09-27 18:28:36 +000087 if (TWEAK_WineLook > WIN31_LOOK)
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +000088 ERR("Called in Win95 mode. Aiee! Please report this.\n" );
Alexandre Julliardd37eb361997-07-20 16:23:21 +000089
Alexandre Julliardbf9130a1996-10-13 17:45:47 +000090 if(style & WS_ICONIC) return;
Alexandre Julliard0c126c71996-02-18 18:44:41 +000091
Alexandre Julliarddc4fe772001-06-04 21:55:17 +000092 if (HAS_THICKFRAME( style, exStyle ))
93 InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
94 else if (HAS_DLGFRAME( style, exStyle ))
95 InflateRect( rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
96 else if (HAS_THINFRAME( style ))
97 InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
98
99 if ((style & WS_CAPTION) == WS_CAPTION)
100 rect->top -= GetSystemMetrics(SM_CYCAPTION) - GetSystemMetrics(SM_CYBORDER);
101
Marcus Meissnerddca3151999-05-22 11:33:23 +0000102 if (menu) rect->top -= GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CYBORDER);
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000103
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000104 if (style & WS_VSCROLL) {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000105 rect->right += GetSystemMetrics(SM_CXVSCROLL) - 1;
Ove Kaaven60c78f11999-07-03 15:40:29 +0000106 if(!HAS_ANYFRAME( style, exStyle ))
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000107 rect->right++;
108 }
109
110 if (style & WS_HSCROLL) {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000111 rect->bottom += GetSystemMetrics(SM_CYHSCROLL) - 1;
Ove Kaaven60c78f11999-07-03 15:40:29 +0000112 if(!HAS_ANYFRAME( style, exStyle ))
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000113 rect->bottom++;
114 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000115}
116
117
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000118/******************************************************************************
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000119 * NC_AdjustRectOuter95
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000120 *
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000121 * Computes the size of the "outside" parts of the window based on the
122 * parameters of the client area.
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000123 *
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000124 + PARAMS
125 * LPRECT16 rect
126 * DWORD style
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000127 * BOOL menu
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000128 * DWORD exStyle
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000129 *
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000130 * NOTES
131 * "Outer" parts of a window means the whole window frame, caption and
132 * menu bar. It does not include "inner" parts of the frame like client
133 * edge, static edge or scroll bars.
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000134 *
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000135 * Revision history
136 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
137 * Original (NC_AdjustRect95) cut & paste from NC_AdjustRect
138 *
139 * 20-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
140 * Split NC_AdjustRect95 into NC_AdjustRectOuter95 and
141 * NC_AdjustRectInner95 and added handling of Win95 styles.
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000142 *
Ove Kaaven60c78f11999-07-03 15:40:29 +0000143 * 28-Jul-1999 Ove KÃ¥ven (ovek@arcticnet.no)
144 * Streamlined window style checks.
145 *
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000146 *****************************************************************************/
147
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000148static void
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000149NC_AdjustRectOuter95 (LPRECT rect, DWORD style, BOOL menu, DWORD exStyle)
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000150{
Bill Medlandcbfbf2a2001-07-20 18:36:49 +0000151 int adjust;
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000152 if(style & WS_ICONIC) return;
153
Bill Medlandcbfbf2a2001-07-20 18:36:49 +0000154 if ((exStyle & (WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME)) ==
155 WS_EX_STATICEDGE)
156 {
157 adjust = 1; /* for the outer frame always present */
158 }
159 else
160 {
161 adjust = 0;
162 if ((exStyle & WS_EX_DLGMODALFRAME) ||
163 (style & (WS_THICKFRAME|WS_DLGFRAME))) adjust = 2; /* outer */
164 }
165 if (style & WS_THICKFRAME)
166 adjust += ( GetSystemMetrics (SM_CXFRAME)
167 - GetSystemMetrics (SM_CXDLGFRAME)); /* The resize border */
168 if ((style & (WS_BORDER|WS_DLGFRAME)) ||
169 (exStyle & WS_EX_DLGMODALFRAME))
170 adjust++; /* The other border */
171
172 InflateRect (rect, adjust, adjust);
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000173
174 if ((style & WS_CAPTION) == WS_CAPTION)
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000175 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000176 if (exStyle & WS_EX_TOOLWINDOW)
177 rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
Ove Kaaven60c78f11999-07-03 15:40:29 +0000178 else
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000179 rect->top -= GetSystemMetrics(SM_CYCAPTION);
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000180 }
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000181 if (menu) rect->top -= GetSystemMetrics(SM_CYMENU);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000182}
183
184
185/******************************************************************************
186 * NC_AdjustRectInner95
187 *
188 * Computes the size of the "inside" part of the window based on the
189 * parameters of the client area.
190 *
191 + PARAMS
192 * LPRECT16 rect
193 * DWORD style
194 * DWORD exStyle
195 *
196 * NOTES
197 * "Inner" part of a window means the window frame inside of the flat
198 * window frame. It includes the client edge, the static edge and the
199 * scroll bars.
200 *
201 * Revision history
202 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
203 * Original (NC_AdjustRect95) cut & paste from NC_AdjustRect
204 *
205 * 20-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
206 * Split NC_AdjustRect95 into NC_AdjustRectOuter95 and
207 * NC_AdjustRectInner95 and added handling of Win95 styles.
208 *
209 *****************************************************************************/
210
211static void
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000212NC_AdjustRectInner95 (LPRECT rect, DWORD style, DWORD exStyle)
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000213{
214 if(style & WS_ICONIC) return;
215
216 if (exStyle & WS_EX_CLIENTEDGE)
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000217 InflateRect(rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000218
Marcus Meissnerddca3151999-05-22 11:33:23 +0000219 if (style & WS_VSCROLL) rect->right += GetSystemMetrics(SM_CXVSCROLL);
220 if (style & WS_HSCROLL) rect->bottom += GetSystemMetrics(SM_CYHSCROLL);
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000221}
222
223
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000224
225static HICON NC_IconForWindow( HWND hwnd )
226{
227 HICON hIcon = (HICON) GetClassLongA( hwnd, GCL_HICONSM );
228 if (!hIcon) hIcon = (HICON) GetClassLongA( hwnd, GCL_HICON );
229
230 /* If there is no hIcon specified and this is a modal dialog,
231 * get the default one.
232 */
233 if (!hIcon && (GetWindowLongA( hwnd, GWL_STYLE ) & DS_MODALFRAME))
234 hIcon = LoadImageA(0, IDI_WINLOGOA, IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
235 return hIcon;
236}
237
Alexandre Julliarde658d821997-11-30 17:45:40 +0000238/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000239 * DrawCaption (USER32.@) Draws a caption bar
Eric Kohl8e517b51998-10-11 13:06:35 +0000240 *
241 * PARAMS
242 * hwnd [I]
243 * hdc [I]
244 * lpRect [I]
245 * uFlags [I]
246 *
Eric Kohld0b79c01998-10-24 10:45:42 +0000247 * RETURNS
248 * Success:
249 * Failure:
Eric Kohl8e517b51998-10-11 13:06:35 +0000250 */
251
Alexandre Julliarda3960291999-02-26 11:11:13 +0000252BOOL WINAPI
253DrawCaption (HWND hwnd, HDC hdc, const RECT *lpRect, UINT uFlags)
Eric Kohl8e517b51998-10-11 13:06:35 +0000254{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000255 return DrawCaptionTempA (hwnd, hdc, lpRect, 0, 0, NULL, uFlags & 0x1F);
Eric Kohl8e517b51998-10-11 13:06:35 +0000256}
257
258
259/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000260 * DrawCaptionTempA (USER32.@)
Eric Kohl8e517b51998-10-11 13:06:35 +0000261 */
Alexandre Julliard193cf502002-01-01 00:24:30 +0000262BOOL WINAPI DrawCaptionTempA (HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont,
263 HICON hIcon, LPCSTR str, UINT uFlags)
264{
265 LPWSTR strW;
266 INT len;
267 BOOL ret = FALSE;
Eric Kohl8e517b51998-10-11 13:06:35 +0000268
Alexandre Julliard193cf502002-01-01 00:24:30 +0000269 if (!(uFlags & DC_TEXT) || !str)
270 return DrawCaptionTempW( hwnd, hdc, rect, hFont, hIcon, NULL, uFlags );
271
272 len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
273 if ((strW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
274 {
275 MultiByteToWideChar( CP_ACP, 0, str, -1, strW, len );
276 ret = DrawCaptionTempW (hwnd, hdc, rect, hFont, hIcon, strW, uFlags);
277 HeapFree( GetProcessHeap (), 0, strW );
278 }
279 return ret;
280}
281
282
283/***********************************************************************
284 * DrawCaptionTempW (USER32.@)
285 */
286BOOL WINAPI DrawCaptionTempW (HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont,
287 HICON hIcon, LPCWSTR str, UINT uFlags)
Eric Kohl8e517b51998-10-11 13:06:35 +0000288{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000289 RECT rc = *rect;
Eric Kohl8e517b51998-10-11 13:06:35 +0000290
Alexandre Julliard193cf502002-01-01 00:24:30 +0000291 TRACE("(%08x,%08x,%p,%08x,%08x,%s,%08x)\n",
292 hwnd, hdc, rect, hFont, hIcon, debugstr_w(str), uFlags);
Eric Kohl8e517b51998-10-11 13:06:35 +0000293
294 /* drawing background */
295 if (uFlags & DC_INBUTTON) {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000296 FillRect (hdc, &rc, GetSysColorBrush (COLOR_3DFACE));
Eric Kohl8e517b51998-10-11 13:06:35 +0000297
298 if (uFlags & DC_ACTIVE) {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000299 HBRUSH hbr = SelectObject (hdc, CACHE_GetPattern55AABrush ());
300 PatBlt (hdc, rc.left, rc.top,
Eric Kohl8e517b51998-10-11 13:06:35 +0000301 rc.right-rc.left, rc.bottom-rc.top, 0xFA0089);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000302 SelectObject (hdc, hbr);
Eric Kohl8e517b51998-10-11 13:06:35 +0000303 }
304 }
305 else {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000306 FillRect (hdc, &rc, GetSysColorBrush ((uFlags & DC_ACTIVE) ?
Eric Kohl8e517b51998-10-11 13:06:35 +0000307 COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION));
308 }
309
310
311 /* drawing icon */
312 if ((uFlags & DC_ICON) && !(uFlags & DC_SMALLCAP)) {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000313 POINT pt;
Eric Kohl8e517b51998-10-11 13:06:35 +0000314
315 pt.x = rc.left + 2;
Marcus Meissnerddca3151999-05-22 11:33:23 +0000316 pt.y = (rc.bottom + rc.top - GetSystemMetrics(SM_CYSMICON)) / 2;
Eric Kohl8e517b51998-10-11 13:06:35 +0000317
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000318 if (!hIcon) hIcon = NC_IconForWindow(hwnd);
319 DrawIconEx (hdc, pt.x, pt.y, hIcon, GetSystemMetrics(SM_CXSMICON),
320 GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL);
Eric Kohl8e517b51998-10-11 13:06:35 +0000321 rc.left += (rc.bottom - rc.top);
322 }
323
324 /* drawing text */
325 if (uFlags & DC_TEXT) {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000326 HFONT hOldFont;
Eric Kohl8e517b51998-10-11 13:06:35 +0000327
328 if (uFlags & DC_INBUTTON)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000329 SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
Eric Kohl8e517b51998-10-11 13:06:35 +0000330 else if (uFlags & DC_ACTIVE)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000331 SetTextColor (hdc, GetSysColor (COLOR_CAPTIONTEXT));
Eric Kohl8e517b51998-10-11 13:06:35 +0000332 else
Alexandre Julliarda3960291999-02-26 11:11:13 +0000333 SetTextColor (hdc, GetSysColor (COLOR_INACTIVECAPTIONTEXT));
Eric Kohl8e517b51998-10-11 13:06:35 +0000334
Alexandre Julliarda3960291999-02-26 11:11:13 +0000335 SetBkMode (hdc, TRANSPARENT);
Eric Kohl8e517b51998-10-11 13:06:35 +0000336
337 if (hFont)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000338 hOldFont = SelectObject (hdc, hFont);
Eric Kohl8e517b51998-10-11 13:06:35 +0000339 else {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000340 NONCLIENTMETRICSA nclm;
341 HFONT hNewFont;
342 nclm.cbSize = sizeof(NONCLIENTMETRICSA);
343 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
344 hNewFont = CreateFontIndirectA ((uFlags & DC_SMALLCAP) ?
Eric Kohl8e517b51998-10-11 13:06:35 +0000345 &nclm.lfSmCaptionFont : &nclm.lfCaptionFont);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000346 hOldFont = SelectObject (hdc, hNewFont);
Eric Kohl8e517b51998-10-11 13:06:35 +0000347 }
348
349 if (str)
Alexandre Julliard193cf502002-01-01 00:24:30 +0000350 DrawTextW (hdc, str, -1, &rc,
Eric Kohl8e517b51998-10-11 13:06:35 +0000351 DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT);
352 else {
Alexandre Julliard193cf502002-01-01 00:24:30 +0000353 WCHAR szText[128];
Alexandre Julliarda3960291999-02-26 11:11:13 +0000354 INT nLen;
Alexandre Julliard193cf502002-01-01 00:24:30 +0000355 nLen = GetWindowTextW (hwnd, szText, 128);
356 DrawTextW (hdc, szText, nLen, &rc,
Eric Kohl8e517b51998-10-11 13:06:35 +0000357 DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT);
358 }
359
360 if (hFont)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000361 SelectObject (hdc, hOldFont);
Eric Kohl8e517b51998-10-11 13:06:35 +0000362 else
Alexandre Julliarda3960291999-02-26 11:11:13 +0000363 DeleteObject (SelectObject (hdc, hOldFont));
Eric Kohl8e517b51998-10-11 13:06:35 +0000364 }
365
366 /* drawing focus ??? */
367 if (uFlags & 0x2000)
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +0000368 FIXME("undocumented flag (0x2000)!\n");
Eric Kohl8e517b51998-10-11 13:06:35 +0000369
370 return 0;
371}
372
373
374/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000375 * AdjustWindowRect (USER.102)
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000376 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000377BOOL16 WINAPI AdjustWindowRect16( LPRECT16 rect, DWORD style, BOOL16 menu )
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000378{
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000379 return AdjustWindowRectEx16( rect, style, menu, 0 );
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000380}
381
382
383/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000384 * AdjustWindowRect (USER32.@)
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000385 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000386BOOL WINAPI AdjustWindowRect( LPRECT rect, DWORD style, BOOL menu )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000387{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000388 return AdjustWindowRectEx( rect, style, menu, 0 );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000389}
390
391
392/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000393 * AdjustWindowRectEx (USER.454)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000394 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000395BOOL16 WINAPI AdjustWindowRectEx16( LPRECT16 rect, DWORD style,
396 BOOL16 menu, DWORD exStyle )
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000397{
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000398 RECT rect32;
399 BOOL ret;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000400
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000401 CONV_RECT16TO32( rect, &rect32 );
402 ret = AdjustWindowRectEx( &rect32, style, menu, exStyle );
403 CONV_RECT32TO16( &rect32, rect );
404 return ret;
405}
406
407
408/***********************************************************************
409 * AdjustWindowRectEx (USER32.@)
410 */
411BOOL WINAPI AdjustWindowRectEx( LPRECT rect, DWORD style, BOOL menu, DWORD exStyle )
412{
413 /* Correct the window style */
414
415 if (!(style & (WS_POPUP | WS_CHILD))) style |= WS_CAPTION; /* Overlapped window */
Alexandre Julliard84c70f51997-05-09 08:40:27 +0000416 style &= (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME | WS_CHILD);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000417 exStyle &= (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE |
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000418 WS_EX_STATICEDGE | WS_EX_TOOLWINDOW);
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000419 if (exStyle & WS_EX_DLGMODALFRAME) style &= ~WS_THICKFRAME;
420
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +0000421 TRACE("(%d,%d)-(%d,%d) %08lx %d %08lx\n",
422 rect->left, rect->top, rect->right, rect->bottom,
423 style, menu, exStyle );
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000424
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000425 if (TWEAK_WineLook == WIN31_LOOK)
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000426 NC_AdjustRect( rect, style, menu, exStyle );
427 else
428 {
429 NC_AdjustRectOuter95( rect, style, menu, exStyle );
430 NC_AdjustRectInner95( rect, style, exStyle );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000431 }
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000432 return TRUE;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000433}
434
435
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000436/***********************************************************************
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000437 * NC_HandleNCCalcSize
438 *
439 * Handle a WM_NCCALCSIZE message. Called from DefWindowProc().
440 */
Alexandre Julliardde424282001-08-10 22:51:42 +0000441LONG NC_HandleNCCalcSize( HWND hwnd, RECT *winRect )
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000442{
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000443 RECT tmpRect = { 0, 0, 0, 0 };
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +0000444 LONG result = 0;
Alexandre Julliardde424282001-08-10 22:51:42 +0000445 LONG cls_style = GetClassLongA(hwnd, GCL_STYLE);
446 LONG style = GetWindowLongA( hwnd, GWL_STYLE );
447 LONG exStyle = GetWindowLongA( hwnd, GWL_EXSTYLE );
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +0000448
Alexandre Julliardde424282001-08-10 22:51:42 +0000449 if (cls_style & CS_VREDRAW) result |= WVR_VREDRAW;
450 if (cls_style & CS_HREDRAW) result |= WVR_HREDRAW;
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000451
Alexandre Julliardde424282001-08-10 22:51:42 +0000452 if (!IsIconic(hwnd))
453 {
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000454 if (TWEAK_WineLook == WIN31_LOOK)
Alexandre Julliardde424282001-08-10 22:51:42 +0000455 NC_AdjustRect( &tmpRect, style, FALSE, exStyle );
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000456 else
Alexandre Julliardde424282001-08-10 22:51:42 +0000457 NC_AdjustRectOuter95( &tmpRect, style, FALSE, exStyle );
Alexandre Julliard1e37a181996-08-18 16:21:52 +0000458
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000459 winRect->left -= tmpRect.left;
460 winRect->top -= tmpRect.top;
461 winRect->right -= tmpRect.right;
462 winRect->bottom -= tmpRect.bottom;
463
Alexandre Julliardde424282001-08-10 22:51:42 +0000464 if (!(style & WS_CHILD) && GetMenu(hwnd))
465 {
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +0000466 TRACE("Calling GetMenuBarHeight with HWND 0x%x, width %d, "
Alexandre Julliardde424282001-08-10 22:51:42 +0000467 "at (%d, %d).\n", hwnd,
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +0000468 winRect->right - winRect->left,
469 -tmpRect.left, -tmpRect.top );
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000470
471 winRect->top +=
Alexandre Julliardde424282001-08-10 22:51:42 +0000472 MENU_GetMenuBarHeight( hwnd,
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000473 winRect->right - winRect->left,
474 -tmpRect.left, -tmpRect.top ) + 1;
475 }
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000476
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000477 if (TWEAK_WineLook > WIN31_LOOK) {
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000478 SetRect(&tmpRect, 0, 0, 0, 0);
Alexandre Julliardde424282001-08-10 22:51:42 +0000479 NC_AdjustRectInner95 (&tmpRect, style, exStyle);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000480 winRect->left -= tmpRect.left;
481 winRect->top -= tmpRect.top;
482 winRect->right -= tmpRect.right;
483 winRect->bottom -= tmpRect.bottom;
484 }
Mike McCormacka2bdade2000-09-12 23:37:57 +0000485
486 if (winRect->top > winRect->bottom)
487 winRect->bottom = winRect->top;
488
489 if (winRect->left > winRect->right)
490 winRect->right = winRect->left;
Alexandre Julliard2d159fb1994-07-15 16:04:31 +0000491 }
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +0000492 return result;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000493}
494
495
496/***********************************************************************
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000497 * NC_GetInsideRect
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000498 *
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000499 * Get the 'inside' rectangle of a window, i.e. the whole window rectangle
500 * but without the borders (if any).
501 * The rectangle is in window coordinates (for drawing with GetWindowDC()).
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000502 */
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000503void NC_GetInsideRect( HWND hwnd, RECT *rect )
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000504{
505 WND * wndPtr = WIN_FindWndPtr( hwnd );
506
507 rect->top = rect->left = 0;
508 rect->right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
509 rect->bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
510
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000511 if (wndPtr->dwStyle & WS_ICONIC) goto END;
Alexandre Julliard3ed37e01994-11-07 18:20:42 +0000512
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000513 /* Remove frame from rectangle */
Ove Kaaven60c78f11999-07-03 15:40:29 +0000514 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000515 {
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000516 InflateRect( rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) );
517 }
518 else if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
519 {
520 InflateRect( rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
521 /* FIXME: this isn't in NC_AdjustRect? why not? */
522 if ((TWEAK_WineLook == WIN31_LOOK) && (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME))
Alexandre Julliarda3960291999-02-26 11:11:13 +0000523 InflateRect( rect, -1, 0 );
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000524 }
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000525 else if (HAS_THINFRAME( wndPtr->dwStyle ))
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000526 {
Ove Kaaven60c78f11999-07-03 15:40:29 +0000527 InflateRect( rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER) );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000528 }
529
Francis Beaudet1cc0a9a1999-09-03 15:00:45 +0000530 /* We have additional border information if the window
531 * is a child (but not an MDI child) */
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000532 if (TWEAK_WineLook != WIN31_LOOK)
533 {
534 if ( (wndPtr->dwStyle & WS_CHILD) &&
535 ( (wndPtr->dwExStyle & WS_EX_MDICHILD) == 0 ) )
536 {
537 if (wndPtr->dwExStyle & WS_EX_CLIENTEDGE)
538 InflateRect (rect, -GetSystemMetrics(SM_CXEDGE), -GetSystemMetrics(SM_CYEDGE));
539 if (wndPtr->dwExStyle & WS_EX_STATICEDGE)
540 InflateRect (rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
541 }
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000542 }
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000543
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000544END:
545 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000546 return;
547}
548
549
550/***********************************************************************
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000551 * NC_DoNCHitTest
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000552 *
Andreas Mohr260f1a12000-09-22 20:59:29 +0000553 * Handle a WM_NCHITTEST message. Called from NC_HandleNCHitTest().
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000554 */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000555
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000556static LONG NC_DoNCHitTest (WND *wndPtr, POINT pt )
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000557{
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000558 RECT rect;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000559
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000560 TRACE("hwnd=%04x pt=%ld,%ld\n", wndPtr->hwndSelf, pt.x, pt.y );
Alexandre Julliard940d58c1994-09-16 09:24:37 +0000561
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000562 GetWindowRect(wndPtr->hwndSelf, &rect );
563 if (!PtInRect( &rect, pt )) return HTNOWHERE;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000564
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000565 if (wndPtr->dwStyle & WS_MINIMIZE) return HTCAPTION;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000566
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000567 /* Check borders */
568 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000569 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000570 InflateRect( &rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) );
571 if (!PtInRect( &rect, pt ))
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000572 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000573 /* Check top sizing border */
574 if (pt.y < rect.top)
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000575 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000576 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTTOPLEFT;
577 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTTOPRIGHT;
578 return HTTOP;
579 }
580 /* Check bottom sizing border */
581 if (pt.y >= rect.bottom)
582 {
583 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMLEFT;
584 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMRIGHT;
585 return HTBOTTOM;
586 }
587 /* Check left sizing border */
588 if (pt.x < rect.left)
589 {
590 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPLEFT;
591 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMLEFT;
592 return HTLEFT;
593 }
594 /* Check right sizing border */
595 if (pt.x >= rect.right)
596 {
597 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPRIGHT;
598 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMRIGHT;
599 return HTRIGHT;
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000600 }
601 }
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000602 }
603 else /* No thick frame */
604 {
605 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
606 InflateRect(&rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
607 else if (HAS_THINFRAME( wndPtr->dwStyle ))
608 InflateRect(&rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
609 if (!PtInRect( &rect, pt )) return HTBORDER;
610 }
611
612 /* Check caption */
613
614 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
615 {
616 rect.top += GetSystemMetrics(SM_CYCAPTION) - GetSystemMetrics(SM_CYBORDER);
617 if (!PtInRect( &rect, pt ))
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000618 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000619 /* Check system menu */
620 if ((wndPtr->dwStyle & WS_SYSMENU) && !(wndPtr->dwExStyle & WS_EX_TOOLWINDOW))
621 rect.left += GetSystemMetrics(SM_CXSIZE);
622 if (pt.x <= rect.left) return HTSYSMENU;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000623
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000624 /* Check maximize box */
625 if (wndPtr->dwStyle & WS_MAXIMIZEBOX)
626 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
Alexandre Julliardf7207251994-07-23 07:57:48 +0000627
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000628 if (pt.x >= rect.right) return HTMAXBUTTON;
629 /* Check minimize box */
630 if (wndPtr->dwStyle & WS_MINIMIZEBOX)
631 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
632 if (pt.x >= rect.right) return HTMINBUTTON;
633 return HTCAPTION;
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000634 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000635 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000636
Alexandre Julliardf7207251994-07-23 07:57:48 +0000637 /* Check client area */
638
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000639 ScreenToClient( wndPtr->hwndSelf, &pt );
640 GetClientRect( wndPtr->hwndSelf, &rect );
641 if (PtInRect( &rect, pt )) return HTCLIENT;
Alexandre Julliardf7207251994-07-23 07:57:48 +0000642
643 /* Check vertical scroll bar */
644
645 if (wndPtr->dwStyle & WS_VSCROLL)
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000646 {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000647 rect.right += GetSystemMetrics(SM_CXVSCROLL);
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000648 if (PtInRect( &rect, pt )) return HTVSCROLL;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000649 }
650
Alexandre Julliardf7207251994-07-23 07:57:48 +0000651 /* Check horizontal scroll bar */
652
653 if (wndPtr->dwStyle & WS_HSCROLL)
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000654 {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000655 rect.bottom += GetSystemMetrics(SM_CYHSCROLL);
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000656 if (PtInRect( &rect, pt ))
Alexandre Julliardf7207251994-07-23 07:57:48 +0000657 {
658 /* Check size box */
659 if ((wndPtr->dwStyle & WS_VSCROLL) &&
Marcus Meissnerddca3151999-05-22 11:33:23 +0000660 (pt.x >= rect.right - GetSystemMetrics(SM_CXVSCROLL)))
Alexandre Julliardf7207251994-07-23 07:57:48 +0000661 return HTSIZE;
662 return HTHSCROLL;
663 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000664 }
665
Alexandre Julliardf7207251994-07-23 07:57:48 +0000666 /* Check menu bar */
667
668 if (HAS_MENU(wndPtr))
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000669 {
Alexandre Julliardf7207251994-07-23 07:57:48 +0000670 if ((pt.y < 0) && (pt.x >= 0) && (pt.x < rect.right))
671 return HTMENU;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000672 }
673
Francois Boisvert5538ec42000-07-29 00:00:29 +0000674 /* Has to return HTNOWHERE if nothing was found
675 Could happen when a window has a customized non client area */
676 return HTNOWHERE;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000677}
678
679
680/***********************************************************************
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000681 * NC_DoNCHitTest95
682 *
683 * Handle a WM_NCHITTEST message. Called from NC_HandleNCHitTest().
684 *
Alexandre Julliard829fe321998-07-26 14:27:39 +0000685 * FIXME: Just a modified copy of the Win 3.1 version.
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000686 */
687
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000688static LONG NC_DoNCHitTest95 (WND *wndPtr, POINT pt )
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000689{
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000690 RECT rect;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000691
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000692 TRACE("hwnd=%04x pt=%ld,%ld\n", wndPtr->hwndSelf, pt.x, pt.y );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000693
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000694 GetWindowRect(wndPtr->hwndSelf, &rect );
695 if (!PtInRect( &rect, pt )) return HTNOWHERE;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000696
697 if (wndPtr->dwStyle & WS_MINIMIZE) return HTCAPTION;
698
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000699 /* Check borders */
700 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000701 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000702 InflateRect( &rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) );
703 if (!PtInRect( &rect, pt ))
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000704 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000705 /* Check top sizing border */
706 if (pt.y < rect.top)
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000707 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000708 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTTOPLEFT;
709 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTTOPRIGHT;
710 return HTTOP;
711 }
712 /* Check bottom sizing border */
713 if (pt.y >= rect.bottom)
714 {
715 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMLEFT;
716 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMRIGHT;
717 return HTBOTTOM;
718 }
719 /* Check left sizing border */
720 if (pt.x < rect.left)
721 {
722 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPLEFT;
723 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMLEFT;
724 return HTLEFT;
725 }
726 /* Check right sizing border */
727 if (pt.x >= rect.right)
728 {
729 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPRIGHT;
730 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMRIGHT;
731 return HTRIGHT;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000732 }
733 }
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000734 }
735 else /* No thick frame */
736 {
737 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
738 InflateRect(&rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
739 else if (HAS_THINFRAME( wndPtr->dwStyle ))
740 InflateRect(&rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
741 if (!PtInRect( &rect, pt )) return HTBORDER;
742 }
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000743
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000744 /* Check caption */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000745
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000746 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
747 {
748 if (wndPtr->dwExStyle & WS_EX_TOOLWINDOW)
749 rect.top += GetSystemMetrics(SM_CYSMCAPTION) - 1;
750 else
751 rect.top += GetSystemMetrics(SM_CYCAPTION) - 1;
752 if (!PtInRect( &rect, pt ))
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000753 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000754 /* Check system menu */
755 if ((wndPtr->dwStyle & WS_SYSMENU) && !(wndPtr->dwExStyle & WS_EX_TOOLWINDOW))
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000756 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000757 if (NC_IconForWindow(wndPtr->hwndSelf))
758 rect.left += GetSystemMetrics(SM_CYCAPTION) - 1;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000759 }
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000760 if (pt.x < rect.left) return HTSYSMENU;
761
762 /* Check close button */
763 if (wndPtr->dwStyle & WS_SYSMENU)
764 rect.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
765 if (pt.x > rect.right) return HTCLOSE;
766
767 /* Check maximize box */
768 /* In win95 there is automatically a Maximize button when there is a minimize one*/
769 if ((wndPtr->dwStyle & WS_MAXIMIZEBOX)|| (wndPtr->dwStyle & WS_MINIMIZEBOX))
770 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
771 if (pt.x > rect.right) return HTMAXBUTTON;
772
773 /* Check minimize box */
774 /* In win95 there is automatically a Maximize button when there is a Maximize one*/
775 if ((wndPtr->dwStyle & WS_MINIMIZEBOX)||(wndPtr->dwStyle & WS_MAXIMIZEBOX))
776 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
777
778 if (pt.x > rect.right) return HTMINBUTTON;
779 return HTCAPTION;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000780 }
781 }
782
783 /* Check client area */
784
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000785 ScreenToClient( wndPtr->hwndSelf, &pt );
786 GetClientRect( wndPtr->hwndSelf, &rect );
787 if (PtInRect( &rect, pt )) return HTCLIENT;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000788
789 /* Check vertical scroll bar */
790
791 if (wndPtr->dwStyle & WS_VSCROLL)
792 {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000793 rect.right += GetSystemMetrics(SM_CXVSCROLL);
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000794 if (PtInRect( &rect, pt )) return HTVSCROLL;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000795 }
796
797 /* Check horizontal scroll bar */
798
799 if (wndPtr->dwStyle & WS_HSCROLL)
800 {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000801 rect.bottom += GetSystemMetrics(SM_CYHSCROLL);
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000802 if (PtInRect( &rect, pt ))
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000803 {
804 /* Check size box */
805 if ((wndPtr->dwStyle & WS_VSCROLL) &&
Marcus Meissnerddca3151999-05-22 11:33:23 +0000806 (pt.x >= rect.right - GetSystemMetrics(SM_CXVSCROLL)))
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000807 return HTSIZE;
808 return HTHSCROLL;
809 }
810 }
811
812 /* Check menu bar */
813
814 if (HAS_MENU(wndPtr))
815 {
816 if ((pt.y < 0) && (pt.x >= 0) && (pt.x < rect.right))
817 return HTMENU;
818 }
819
Francois Boisvert5538ec42000-07-29 00:00:29 +0000820 /* Has to return HTNOWHERE if nothing was found
821 Could happen when a window has a customized non client area */
822 return HTNOWHERE;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000823}
824
825
826/***********************************************************************
827 * NC_HandleNCHitTest
828 *
829 * Handle a WM_NCHITTEST message. Called from DefWindowProc().
830 */
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000831LONG NC_HandleNCHitTest (HWND hwnd , POINT pt)
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000832{
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000833 LONG retvalue;
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000834 WND *wndPtr = WIN_FindWndPtr (hwnd);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000835
836 if (!wndPtr)
837 return HTERROR;
838
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000839 if (TWEAK_WineLook == WIN31_LOOK)
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000840 retvalue = NC_DoNCHitTest (wndPtr, pt);
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000841 else
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000842 retvalue = NC_DoNCHitTest95 (wndPtr, pt);
843 WIN_ReleaseWndPtr(wndPtr);
844 return retvalue;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000845}
846
847
848/***********************************************************************
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000849 * NC_DrawSysButton
850 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000851void NC_DrawSysButton( HWND hwnd, HDC hdc, BOOL down )
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000852{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000853 RECT rect;
854 HDC hdcMem;
855 HBITMAP hbitmap;
Alexandre Julliard7cbe6571995-01-09 18:21:16 +0000856
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000857 NC_GetInsideRect( hwnd, &rect );
858 hdcMem = CreateCompatibleDC( hdc );
859 hbitmap = SelectObject( hdcMem, hbitmapClose );
860 BitBlt(hdc, rect.left, rect.top, GetSystemMetrics(SM_CXSIZE), GetSystemMetrics(SM_CYSIZE),
861 hdcMem, (GetWindowLongA(hwnd,GWL_STYLE) & WS_CHILD) ? GetSystemMetrics(SM_CXSIZE) : 0, 0,
862 down ? NOTSRCCOPY : SRCCOPY );
863 SelectObject( hdcMem, hbitmap );
864 DeleteDC( hdcMem );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000865}
866
867
868/***********************************************************************
869 * NC_DrawMaxButton
870 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000871static void NC_DrawMaxButton( HWND hwnd, HDC16 hdc, BOOL down )
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000872{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000873 RECT rect;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000874 HDC hdcMem;
Alexandre Julliard1e37a181996-08-18 16:21:52 +0000875
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000876 NC_GetInsideRect( hwnd, &rect );
877 hdcMem = CreateCompatibleDC( hdc );
878 SelectObject( hdcMem, (IsZoomed(hwnd)
879 ? (down ? hbitmapRestoreD : hbitmapRestore)
880 : (down ? hbitmapMaximizeD : hbitmapMaximize)) );
881 BitBlt( hdc, rect.right - GetSystemMetrics(SM_CXSIZE) - 1, rect.top,
882 GetSystemMetrics(SM_CXSIZE) + 1, GetSystemMetrics(SM_CYSIZE), hdcMem, 0, 0,
883 SRCCOPY );
884 DeleteDC( hdcMem );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000885
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000886}
887
888
889/***********************************************************************
890 * NC_DrawMinButton
891 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000892static void NC_DrawMinButton( HWND hwnd, HDC16 hdc, BOOL down )
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000893{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000894 RECT rect;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000895 HDC hdcMem;
Alexandre Julliard1e37a181996-08-18 16:21:52 +0000896
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000897 NC_GetInsideRect( hwnd, &rect );
898 hdcMem = CreateCompatibleDC( hdc );
899 SelectObject( hdcMem, (down ? hbitmapMinimizeD : hbitmapMinimize) );
900 if (GetWindowLongA(hwnd,GWL_STYLE) & WS_MAXIMIZEBOX)
901 rect.right -= GetSystemMetrics(SM_CXSIZE)+1;
902 BitBlt( hdc, rect.right - GetSystemMetrics(SM_CXSIZE) - 1, rect.top,
903 GetSystemMetrics(SM_CXSIZE) + 1, GetSystemMetrics(SM_CYSIZE), hdcMem, 0, 0,
904 SRCCOPY );
905 DeleteDC( hdcMem );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000906}
907
908
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000909/******************************************************************************
910 *
911 * void NC_DrawSysButton95(
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000912 * HWND hwnd,
913 * HDC hdc,
914 * BOOL down )
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000915 *
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000916 * Draws the Win95 system icon.
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000917 *
918 * Revision history
919 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
920 * Original implementation from NC_DrawSysButton source.
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000921 * 11-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
922 * Fixed most bugs.
923 *
924 *****************************************************************************/
925
Alexandre Julliarda3960291999-02-26 11:11:13 +0000926BOOL
927NC_DrawSysButton95 (HWND hwnd, HDC hdc, BOOL down)
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000928{
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000929 HICON hIcon = NC_IconForWindow( hwnd );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000930
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000931 if (hIcon)
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000932 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000933 RECT rect;
934 NC_GetInsideRect( hwnd, &rect );
935 DrawIconEx (hdc, rect.left + 2, rect.top + 2, hIcon,
936 GetSystemMetrics(SM_CXSMICON),
937 GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000938 }
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000939 return (hIcon != 0);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000940}
941
942
943/******************************************************************************
944 *
945 * void NC_DrawCloseButton95(
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000946 * HWND hwnd,
947 * HDC hdc,
948 * BOOL down,
Pascal Lessardd814bb61999-07-31 13:02:02 +0000949 * BOOL bGrayed )
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000950 *
951 * Draws the Win95 close button.
952 *
Pascal Lessardd814bb61999-07-31 13:02:02 +0000953 * If bGrayed is true, then draw a disabled Close button
954 *
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000955 * Revision history
956 * 11-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
957 * Original implementation from NC_DrawSysButton95 source.
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000958 *
959 *****************************************************************************/
960
Pascal Lessardd814bb61999-07-31 13:02:02 +0000961static void NC_DrawCloseButton95 (HWND hwnd, HDC hdc, BOOL down, BOOL bGrayed)
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000962{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000963 RECT rect;
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000964
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000965 NC_GetInsideRect( hwnd, &rect );
966
967 /* A tool window has a smaller Close button */
968 if (GetWindowLongA( hwnd, GWL_EXSTYLE ) & WS_EX_TOOLWINDOW)
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000969 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000970 INT iBmpHeight = 11; /* Windows does not use SM_CXSMSIZE and SM_CYSMSIZE */
971 INT iBmpWidth = 11; /* it uses 11x11 for the close button in tool window */
972 INT iCaptionHeight = GetSystemMetrics(SM_CYSMCAPTION);
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000973
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000974 rect.top = rect.top + (iCaptionHeight - 1 - iBmpHeight) / 2;
975 rect.left = rect.right - (iCaptionHeight + 1 + iBmpWidth) / 2;
976 rect.bottom = rect.top + iBmpHeight;
977 rect.right = rect.left + iBmpWidth;
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000978 }
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000979 else
980 {
981 rect.left = rect.right - GetSystemMetrics(SM_CXSIZE) - 1;
982 rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) - 1;
983 rect.top += 2;
984 rect.right -= 2;
985 }
986 DrawFrameControl( hdc, &rect, DFC_CAPTION,
987 (DFCS_CAPTIONCLOSE |
988 (down ? DFCS_PUSHED : 0) |
989 (bGrayed ? DFCS_INACTIVE : 0)) );
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000990}
991
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000992/******************************************************************************
Alexandre Julliardc1d35cc2001-01-24 19:47:57 +0000993 * NC_DrawMaxButton95
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000994 *
995 * Draws the maximize button for Win95 style windows.
Pascal Lessardd814bb61999-07-31 13:02:02 +0000996 * If bGrayed is true, then draw a disabled Maximize button
Alexandre Julliardc1d35cc2001-01-24 19:47:57 +0000997 */
Pascal Lessardd814bb61999-07-31 13:02:02 +0000998static void NC_DrawMaxButton95(HWND hwnd,HDC16 hdc,BOOL down, BOOL bGrayed)
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000999{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001000 RECT rect;
Alexandre Julliarddc4fe772001-06-04 21:55:17 +00001001 UINT flags = IsZoomed(hwnd) ? DFCS_CAPTIONRESTORE : DFCS_CAPTIONMAX;
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001002
Alexandre Julliarddc4fe772001-06-04 21:55:17 +00001003 NC_GetInsideRect( hwnd, &rect );
1004 if (GetWindowLongA( hwnd, GWL_STYLE) & WS_SYSMENU)
1005 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1006 rect.left = rect.right - GetSystemMetrics(SM_CXSIZE);
1007 rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) - 1;
1008 rect.top += 2;
1009 rect.right -= 2;
1010 if (down) flags |= DFCS_PUSHED;
1011 if (bGrayed) flags |= DFCS_INACTIVE;
1012 DrawFrameControl( hdc, &rect, DFC_CAPTION, flags );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001013}
1014
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001015/******************************************************************************
Alexandre Julliardc1d35cc2001-01-24 19:47:57 +00001016 * NC_DrawMinButton95
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001017 *
1018 * Draws the minimize button for Win95 style windows.
Pascal Lessardd814bb61999-07-31 13:02:02 +00001019 * If bGrayed is true, then draw a disabled Minimize button
Alexandre Julliardc1d35cc2001-01-24 19:47:57 +00001020 */
Pascal Lessardd814bb61999-07-31 13:02:02 +00001021static void NC_DrawMinButton95(HWND hwnd,HDC16 hdc,BOOL down, BOOL bGrayed)
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001022{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001023 RECT rect;
Alexandre Julliarddc4fe772001-06-04 21:55:17 +00001024 UINT flags = DFCS_CAPTIONMIN;
1025 DWORD style = GetWindowLongA( hwnd, GWL_STYLE );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001026
Alexandre Julliarddc4fe772001-06-04 21:55:17 +00001027 NC_GetInsideRect( hwnd, &rect );
1028 if (style & WS_SYSMENU)
1029 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1030 if (style & (WS_MAXIMIZEBOX|WS_MINIMIZEBOX))
1031 rect.right -= GetSystemMetrics(SM_CXSIZE) - 2;
1032 rect.left = rect.right - GetSystemMetrics(SM_CXSIZE);
1033 rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) - 1;
1034 rect.top += 2;
1035 rect.right -= 2;
1036 if (down) flags |= DFCS_PUSHED;
1037 if (bGrayed) flags |= DFCS_INACTIVE;
1038 DrawFrameControl( hdc, &rect, DFC_CAPTION, flags );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001039}
1040
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001041/***********************************************************************
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001042 * NC_DrawFrame
1043 *
1044 * Draw a window frame inside the given rectangle, and update the rectangle.
Alexandre Julliardaca05781994-10-17 18:12:41 +00001045 * The correct pen for the frame must be selected in the DC.
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001046 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001047static void NC_DrawFrame( HDC hdc, RECT *rect, BOOL dlgFrame,
1048 BOOL active )
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001049{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001050 INT width, height;
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001051
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00001052 if (TWEAK_WineLook != WIN31_LOOK)
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +00001053 ERR("Called in Win95 mode. Aiee! Please report this.\n" );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001054
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001055 if (dlgFrame)
1056 {
Marcus Meissnerddca3151999-05-22 11:33:23 +00001057 width = GetSystemMetrics(SM_CXDLGFRAME) - 1;
1058 height = GetSystemMetrics(SM_CYDLGFRAME) - 1;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001059 SelectObject( hdc, GetSysColorBrush(active ? COLOR_ACTIVECAPTION :
Alexandre Julliard02e90081998-01-04 17:49:09 +00001060 COLOR_INACTIVECAPTION) );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001061 }
1062 else
1063 {
Ove Kaaven60c78f11999-07-03 15:40:29 +00001064 width = GetSystemMetrics(SM_CXFRAME) - 2;
1065 height = GetSystemMetrics(SM_CYFRAME) - 2;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001066 SelectObject( hdc, GetSysColorBrush(active ? COLOR_ACTIVEBORDER :
Alexandre Julliard02e90081998-01-04 17:49:09 +00001067 COLOR_INACTIVEBORDER) );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001068 }
1069
1070 /* Draw frame */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001071 PatBlt( hdc, rect->left, rect->top,
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001072 rect->right - rect->left, height, PATCOPY );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001073 PatBlt( hdc, rect->left, rect->top,
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001074 width, rect->bottom - rect->top, PATCOPY );
Randy Weems0bc73c71999-03-25 15:49:11 +00001075 PatBlt( hdc, rect->left, rect->bottom - 1,
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001076 rect->right - rect->left, -height, PATCOPY );
Randy Weems0bc73c71999-03-25 15:49:11 +00001077 PatBlt( hdc, rect->right - 1, rect->top,
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001078 -width, rect->bottom - rect->top, PATCOPY );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001079
1080 if (dlgFrame)
1081 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001082 InflateRect( rect, -width, -height );
Alexandre Julliarddf2673b1997-03-29 17:20:20 +00001083 }
1084 else
1085 {
Ove Kaaven60c78f11999-07-03 15:40:29 +00001086 INT decYOff = GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXSIZE) - 1;
1087 INT decXOff = GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYSIZE) - 1;
Huw D M Davies2d617be1998-12-08 09:14:09 +00001088
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001089 /* Draw inner rectangle */
Alexandre Julliarddf2673b1997-03-29 17:20:20 +00001090
Alexandre Julliarda3960291999-02-26 11:11:13 +00001091 SelectObject( hdc, GetStockObject(NULL_BRUSH) );
1092 Rectangle( hdc, rect->left + width, rect->top + height,
Huw D M Davies2d617be1998-12-08 09:14:09 +00001093 rect->right - width , rect->bottom - height );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001094
1095 /* Draw the decorations */
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001096
Alexandre Julliarda3960291999-02-26 11:11:13 +00001097 MoveToEx( hdc, rect->left, rect->top + decYOff, NULL );
1098 LineTo( hdc, rect->left + width, rect->top + decYOff );
1099 MoveToEx( hdc, rect->right - 1, rect->top + decYOff, NULL );
1100 LineTo( hdc, rect->right - width - 1, rect->top + decYOff );
1101 MoveToEx( hdc, rect->left, rect->bottom - decYOff, NULL );
1102 LineTo( hdc, rect->left + width, rect->bottom - decYOff );
1103 MoveToEx( hdc, rect->right - 1, rect->bottom - decYOff, NULL );
1104 LineTo( hdc, rect->right - width - 1, rect->bottom - decYOff );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001105
Alexandre Julliarda3960291999-02-26 11:11:13 +00001106 MoveToEx( hdc, rect->left + decXOff, rect->top, NULL );
1107 LineTo( hdc, rect->left + decXOff, rect->top + height);
1108 MoveToEx( hdc, rect->left + decXOff, rect->bottom - 1, NULL );
1109 LineTo( hdc, rect->left + decXOff, rect->bottom - height - 1 );
1110 MoveToEx( hdc, rect->right - decXOff, rect->top, NULL );
1111 LineTo( hdc, rect->right - decXOff, rect->top + height );
1112 MoveToEx( hdc, rect->right - decXOff, rect->bottom - 1, NULL );
1113 LineTo( hdc, rect->right - decXOff, rect->bottom - height - 1 );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001114
Alexandre Julliarda3960291999-02-26 11:11:13 +00001115 InflateRect( rect, -width - 1, -height - 1 );
Alexandre Julliarddf2673b1997-03-29 17:20:20 +00001116 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001117}
1118
1119
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001120/******************************************************************************
1121 *
1122 * void NC_DrawFrame95(
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001123 * HDC hdc,
1124 * RECT *rect,
Bill Medlandcbfbf2a2001-07-20 18:36:49 +00001125 * BOOL active,
1126 * DWORD style,
1127 * DWORD exStyle )
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001128 *
1129 * Draw a window frame inside the given rectangle, and update the rectangle.
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001130 *
1131 * Bugs
1132 * Many. First, just what IS a frame in Win95? Note that the 3D look
1133 * on the outer edge is handled by NC_DoNCPaint95. As is the inner
1134 * edge. The inner rectangle just inside the frame is handled by the
1135 * Caption code.
1136 *
1137 * In short, for most people, this function should be a nop (unless
1138 * you LIKE thick borders in Win95/NT4.0 -- I've been working with
1139 * them lately, but just to get this code right). Even so, it doesn't
1140 * appear to be so. It's being worked on...
1141 *
1142 * Revision history
1143 * 06-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1144 * Original implementation (based on NC_DrawFrame)
Alexandre Julliardf90efa91998-06-14 15:24:15 +00001145 * 02-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1146 * Some minor fixes.
Ove Kaaven60c78f11999-07-03 15:40:29 +00001147 * 29-Jun-1999 Ove KÃ¥ven (ovek@arcticnet.no)
1148 * Fixed a fix or something.
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001149 *
1150 *****************************************************************************/
1151
1152static void NC_DrawFrame95(
Alexandre Julliarda3960291999-02-26 11:11:13 +00001153 HDC hdc,
1154 RECT *rect,
Bill Medlandcbfbf2a2001-07-20 18:36:49 +00001155 BOOL active,
1156 DWORD style,
1157 DWORD exStyle)
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001158{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001159 INT width, height;
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001160
Bill Medlandcbfbf2a2001-07-20 18:36:49 +00001161 /* Firstly the "thick" frame */
1162 if (style & WS_THICKFRAME)
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001163 {
Bill Medlandcbfbf2a2001-07-20 18:36:49 +00001164 width = GetSystemMetrics(SM_CXFRAME) - GetSystemMetrics(SM_CXDLGFRAME);
1165 height = GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYDLGFRAME);
1166
1167 SelectObject( hdc, GetSysColorBrush(active ? COLOR_ACTIVEBORDER :
1168 COLOR_INACTIVEBORDER) );
1169 /* Draw frame */
1170 PatBlt( hdc, rect->left, rect->top,
1171 rect->right - rect->left, height, PATCOPY );
1172 PatBlt( hdc, rect->left, rect->top,
1173 width, rect->bottom - rect->top, PATCOPY );
1174 PatBlt( hdc, rect->left, rect->bottom - 1,
1175 rect->right - rect->left, -height, PATCOPY );
1176 PatBlt( hdc, rect->right - 1, rect->top,
1177 -width, rect->bottom - rect->top, PATCOPY );
1178
1179 InflateRect( rect, -width, -height );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001180 }
1181
Bill Medlandcbfbf2a2001-07-20 18:36:49 +00001182 /* Now the other bit of the frame */
1183 if ((style & (WS_BORDER|WS_DLGFRAME)) ||
1184 (exStyle & WS_EX_DLGMODALFRAME))
1185 {
1186 width = GetSystemMetrics(SM_CXDLGFRAME) - GetSystemMetrics(SM_CXEDGE);
1187 height = GetSystemMetrics(SM_CYDLGFRAME) - GetSystemMetrics(SM_CYEDGE);
1188 /* This should give a value of 1 that should also work for a border */
Alexandre Julliardf90efa91998-06-14 15:24:15 +00001189
Bill Medlandcbfbf2a2001-07-20 18:36:49 +00001190 SelectObject( hdc, GetSysColorBrush(
1191 (exStyle & (WS_EX_DLGMODALFRAME|WS_EX_CLIENTEDGE)) ?
1192 COLOR_3DFACE :
1193 (exStyle & WS_EX_STATICEDGE) ?
1194 COLOR_WINDOWFRAME :
1195 (style & (WS_DLGFRAME|WS_THICKFRAME)) ?
1196 COLOR_3DFACE :
1197 /* else */
1198 COLOR_WINDOWFRAME));
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001199
Bill Medlandcbfbf2a2001-07-20 18:36:49 +00001200 /* Draw frame */
1201 PatBlt( hdc, rect->left, rect->top,
1202 rect->right - rect->left, height, PATCOPY );
1203 PatBlt( hdc, rect->left, rect->top,
1204 width, rect->bottom - rect->top, PATCOPY );
1205 PatBlt( hdc, rect->left, rect->bottom - 1,
1206 rect->right - rect->left, -height, PATCOPY );
1207 PatBlt( hdc, rect->right - 1, rect->top,
1208 -width, rect->bottom - rect->top, PATCOPY );
1209
1210 InflateRect( rect, -width, -height );
1211 }
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001212}
1213
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001214
1215/***********************************************************************
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001216 * NC_DrawCaption
1217 *
1218 * Draw the window caption.
1219 * The correct pen for the window frame must be selected in the DC.
1220 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001221static void NC_DrawCaption( HDC hdc, RECT *rect, HWND hwnd,
1222 DWORD style, BOOL active )
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001223{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001224 RECT r = *rect;
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001225 char buffer[256];
1226
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001227 if (!hbitmapClose)
1228 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +00001229 if (!(hbitmapClose = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_CLOSE) ))) return;
Alexandre Julliard2682bc22000-11-27 22:03:23 +00001230 hbitmapMinimize = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_REDUCE) );
1231 hbitmapMinimizeD = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_REDUCED) );
1232 hbitmapMaximize = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_ZOOM) );
1233 hbitmapMaximizeD = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_ZOOMD) );
1234 hbitmapRestore = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_RESTORE) );
1235 hbitmapRestoreD = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_RESTORED) );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001236 }
1237
Alexandre Julliarddc4fe772001-06-04 21:55:17 +00001238 if (GetWindowLongA( hwnd, GWL_EXSTYLE) & WS_EX_DLGMODALFRAME)
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001239 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001240 HBRUSH hbrushOld = SelectObject(hdc, GetSysColorBrush(COLOR_WINDOW) );
1241 PatBlt( hdc, r.left, r.top, 1, r.bottom-r.top+1,PATCOPY );
1242 PatBlt( hdc, r.right-1, r.top, 1, r.bottom-r.top+1, PATCOPY );
1243 PatBlt( hdc, r.left, r.top-1, r.right-r.left, 1, PATCOPY );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001244 r.left++;
1245 r.right--;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001246 SelectObject( hdc, hbrushOld );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001247 }
Alexandre Julliardb0efe282000-08-04 04:18:04 +00001248 MoveToEx( hdc, r.left, r.bottom, NULL );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001249 LineTo( hdc, r.right, r.bottom );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001250
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001251 if (style & WS_SYSMENU)
1252 {
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001253 NC_DrawSysButton( hwnd, hdc, FALSE );
Marcus Meissnerddca3151999-05-22 11:33:23 +00001254 r.left += GetSystemMetrics(SM_CXSIZE) + 1;
Alexandre Julliardb0efe282000-08-04 04:18:04 +00001255 MoveToEx( hdc, r.left - 1, r.top, NULL );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001256 LineTo( hdc, r.left - 1, r.bottom );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001257 }
1258 if (style & WS_MAXIMIZEBOX)
1259 {
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001260 NC_DrawMaxButton( hwnd, hdc, FALSE );
Marcus Meissnerddca3151999-05-22 11:33:23 +00001261 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001262 }
1263 if (style & WS_MINIMIZEBOX)
1264 {
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001265 NC_DrawMinButton( hwnd, hdc, FALSE );
Marcus Meissnerddca3151999-05-22 11:33:23 +00001266 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001267 }
1268
Alexandre Julliarda3960291999-02-26 11:11:13 +00001269 FillRect( hdc, &r, GetSysColorBrush(active ? COLOR_ACTIVECAPTION :
Alexandre Julliard02e90081998-01-04 17:49:09 +00001270 COLOR_INACTIVECAPTION) );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001271
Alexandre Julliarda3960291999-02-26 11:11:13 +00001272 if (GetWindowTextA( hwnd, buffer, sizeof(buffer) ))
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001273 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001274 if (active) SetTextColor( hdc, GetSysColor( COLOR_CAPTIONTEXT ) );
1275 else SetTextColor( hdc, GetSysColor( COLOR_INACTIVECAPTIONTEXT ) );
1276 SetBkMode( hdc, TRANSPARENT );
1277 DrawTextA( hdc, buffer, -1, &r,
Alexandre Julliarddf2673b1997-03-29 17:20:20 +00001278 DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_NOPREFIX );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001279 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001280}
1281
1282
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001283/******************************************************************************
1284 *
1285 * NC_DrawCaption95(
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001286 * HDC hdc,
1287 * RECT *rect,
1288 * HWND hwnd,
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001289 * DWORD style,
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001290 * BOOL active )
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001291 *
1292 * Draw the window caption for Win95 style windows.
1293 * The correct pen for the window frame must be selected in the DC.
1294 *
1295 * Bugs
Alexandre Julliardf90efa91998-06-14 15:24:15 +00001296 * Hey, a function that finally works! Well, almost.
1297 * It's being worked on.
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001298 *
1299 * Revision history
1300 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1301 * Original implementation.
Alexandre Julliardf90efa91998-06-14 15:24:15 +00001302 * 02-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1303 * Some minor fixes.
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001304 *
1305 *****************************************************************************/
1306
1307static void NC_DrawCaption95(
Alexandre Julliarda3960291999-02-26 11:11:13 +00001308 HDC hdc,
1309 RECT *rect,
1310 HWND hwnd,
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001311 DWORD style,
Eric Kohl8e517b51998-10-11 13:06:35 +00001312 DWORD exStyle,
Alexandre Julliarda3960291999-02-26 11:11:13 +00001313 BOOL active )
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001314{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001315 RECT r = *rect;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001316 char buffer[256];
Alexandre Julliarda3960291999-02-26 11:11:13 +00001317 HPEN hPrevPen;
Pascal Lessardd814bb61999-07-31 13:02:02 +00001318 HMENU hSysMenu;
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001319
Bill Medlandcbfbf2a2001-07-20 18:36:49 +00001320 hPrevPen = SelectObject( hdc, GetSysColorPen(
1321 ((exStyle & (WS_EX_STATICEDGE|WS_EX_CLIENTEDGE|
1322 WS_EX_DLGMODALFRAME)) == WS_EX_STATICEDGE) ?
1323 COLOR_WINDOWFRAME : COLOR_3DFACE) );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001324 MoveToEx( hdc, r.left, r.bottom - 1, NULL );
1325 LineTo( hdc, r.right, r.bottom - 1 );
1326 SelectObject( hdc, hPrevPen );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001327 r.bottom--;
1328
Alexandre Julliarda3960291999-02-26 11:11:13 +00001329 FillRect( hdc, &r, GetSysColorBrush(active ? COLOR_ACTIVECAPTION :
Alexandre Julliard02e90081998-01-04 17:49:09 +00001330 COLOR_INACTIVECAPTION) );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001331
Eric Kohl8e517b51998-10-11 13:06:35 +00001332 if ((style & WS_SYSMENU) && !(exStyle & WS_EX_TOOLWINDOW)) {
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001333 if (NC_DrawSysButton95 (hwnd, hdc, FALSE))
Marcus Meissnerddca3151999-05-22 11:33:23 +00001334 r.left += GetSystemMetrics(SM_CYCAPTION) - 1;
Eric Kohl8e517b51998-10-11 13:06:35 +00001335 }
Pascal Lessardd814bb61999-07-31 13:02:02 +00001336
1337 if (style & WS_SYSMENU)
1338 {
1339 UINT state;
1340
1341 /* Go get the sysmenu */
1342 hSysMenu = GetSystemMenu(hwnd, FALSE);
1343 state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
1344
1345 /* Draw a grayed close button if disabled and a normal one if SC_CLOSE is not there */
1346 NC_DrawCloseButton95 (hwnd, hdc, FALSE,
1347 ((((state & MF_DISABLED) || (state & MF_GRAYED))) && (state != 0xFFFFFFFF)));
Marcus Meissnerddca3151999-05-22 11:33:23 +00001348 r.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
Pascal Lessardd814bb61999-07-31 13:02:02 +00001349
1350 if ((style & WS_MAXIMIZEBOX) || (style & WS_MINIMIZEBOX))
1351 {
1352 /* In win95 the two buttons are always there */
1353 /* But if the menu item is not in the menu they're disabled*/
1354
1355 NC_DrawMaxButton95( hwnd, hdc, FALSE, (!(style & WS_MAXIMIZEBOX)));
1356 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1357
1358 NC_DrawMinButton95( hwnd, hdc, FALSE, (!(style & WS_MINIMIZEBOX)));
1359 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1360 }
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001361 }
1362
Alexandre Julliarda3960291999-02-26 11:11:13 +00001363 if (GetWindowTextA( hwnd, buffer, sizeof(buffer) )) {
1364 NONCLIENTMETRICSA nclm;
1365 HFONT hFont, hOldFont;
1366 nclm.cbSize = sizeof(NONCLIENTMETRICSA);
1367 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
Eric Kohl8e517b51998-10-11 13:06:35 +00001368 if (exStyle & WS_EX_TOOLWINDOW)
Alexandre Julliarda3960291999-02-26 11:11:13 +00001369 hFont = CreateFontIndirectA (&nclm.lfSmCaptionFont);
Eric Kohl8e517b51998-10-11 13:06:35 +00001370 else
Alexandre Julliarda3960291999-02-26 11:11:13 +00001371 hFont = CreateFontIndirectA (&nclm.lfCaptionFont);
1372 hOldFont = SelectObject (hdc, hFont);
1373 if (active) SetTextColor( hdc, GetSysColor( COLOR_CAPTIONTEXT ) );
1374 else SetTextColor( hdc, GetSysColor( COLOR_INACTIVECAPTIONTEXT ) );
1375 SetBkMode( hdc, TRANSPARENT );
Alexandre Julliardf90efa91998-06-14 15:24:15 +00001376 r.left += 2;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001377 DrawTextA( hdc, buffer, -1, &r,
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001378 DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001379 DeleteObject (SelectObject (hdc, hOldFont));
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001380 }
1381}
1382
1383
1384
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001385/***********************************************************************
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001386 * NC_DoNCPaint
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001387 *
Alexandre Julliardc981d0b1996-03-31 16:40:13 +00001388 * Paint the non-client area. clip is currently unused.
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001389 */
Gerard Patele9b4fd12001-11-30 23:13:22 +00001390static void NC_DoNCPaint( HWND hwnd, HRGN clip, BOOL suppress_menupaint )
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001391{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001392 HDC hdc;
1393 RECT rect;
1394 BOOL active;
Gerard Patele9b4fd12001-11-30 23:13:22 +00001395 WND *wndPtr;
1396 DWORD dwStyle, dwExStyle;
1397 WORD flags;
1398 RECT rectClient, rectWindow;
1399 int has_menu;
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001400
Gerard Patele9b4fd12001-11-30 23:13:22 +00001401 if (!(wndPtr = WIN_GetPtr( hwnd )) || wndPtr == WND_OTHER_PROCESS) return;
1402 has_menu = HAS_MENU(wndPtr);
1403 dwStyle = wndPtr->dwStyle;
1404 dwExStyle = wndPtr->dwExStyle;
1405 flags = wndPtr->flags;
1406 rectClient = wndPtr->rectClient;
1407 rectWindow = wndPtr->rectWindow;
1408 WIN_ReleasePtr( wndPtr );
1409
1410 if ( dwStyle & WS_MINIMIZE ||
Alexandre Julliard8fd26b92001-10-15 17:56:45 +00001411 !WIN_IsWindowDrawable( hwnd, 0 )) return; /* Nothing to do */
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001412
Gerard Patele9b4fd12001-11-30 23:13:22 +00001413 active = flags & WIN_NCACTIVATED;
Alexandre Julliardc981d0b1996-03-31 16:40:13 +00001414
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +00001415 TRACE("%04x %d\n", hwnd, active );
Alexandre Julliardc981d0b1996-03-31 16:40:13 +00001416
Alex Korobka4f1ac051999-03-28 09:37:57 +00001417 if (!(hdc = GetDCEx( hwnd, (clip > 1) ? clip : 0, DCX_USESTYLE | DCX_WINDOW |
1418 ((clip > 1) ? (DCX_INTERSECTRGN | DCX_KEEPCLIPRGN): 0) ))) return;
Alexandre Julliard940d58c1994-09-16 09:24:37 +00001419
Gerard Patele9b4fd12001-11-30 23:13:22 +00001420 if (ExcludeVisRect16( hdc, rectClient.left-rectWindow.left,
1421 rectClient.top-rectWindow.top,
1422 rectClient.right-rectWindow.left,
1423 rectClient.bottom-rectWindow.top )
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001424 == NULLREGION)
1425 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001426 ReleaseDC( hwnd, hdc );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001427 return;
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001428 }
1429
1430 rect.top = rect.left = 0;
Gerard Patele9b4fd12001-11-30 23:13:22 +00001431 rect.right = rectWindow.right - rectWindow.left;
1432 rect.bottom = rectWindow.bottom - rectWindow.top;
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001433
Alexandre Julliarda3960291999-02-26 11:11:13 +00001434 SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001435
Gerard Patele9b4fd12001-11-30 23:13:22 +00001436 if (HAS_ANYFRAME( dwStyle, dwExStyle ))
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001437 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +00001438 SelectObject( hdc, GetStockObject(NULL_BRUSH) );
1439 Rectangle( hdc, 0, 0, rect.right, rect.bottom );
1440 InflateRect( &rect, -1, -1 );
1441 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001442
Gerard Patele9b4fd12001-11-30 23:13:22 +00001443 if (HAS_THICKFRAME( dwStyle, dwExStyle ))
Alexandre Julliarddc4fe772001-06-04 21:55:17 +00001444 NC_DrawFrame(hdc, &rect, FALSE, active );
Gerard Patele9b4fd12001-11-30 23:13:22 +00001445 else if (HAS_DLGFRAME( dwStyle, dwExStyle ))
Alexandre Julliarddc4fe772001-06-04 21:55:17 +00001446 NC_DrawFrame( hdc, &rect, TRUE, active );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001447
Gerard Patele9b4fd12001-11-30 23:13:22 +00001448 if ((dwStyle & WS_CAPTION) == WS_CAPTION)
Alexandre Julliarddc4fe772001-06-04 21:55:17 +00001449 {
1450 RECT r = rect;
1451 r.bottom = rect.top + GetSystemMetrics(SM_CYSIZE);
1452 rect.top += GetSystemMetrics(SM_CYSIZE) + GetSystemMetrics(SM_CYBORDER);
Gerard Patele9b4fd12001-11-30 23:13:22 +00001453 NC_DrawCaption( hdc, &r, hwnd, dwStyle, active );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001454 }
1455
Gerard Patele9b4fd12001-11-30 23:13:22 +00001456 if (has_menu)
Alexandre Julliardf7207251994-07-23 07:57:48 +00001457 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001458 RECT r = rect;
Marcus Meissnerddca3151999-05-22 11:33:23 +00001459 r.bottom = rect.top + GetSystemMetrics(SM_CYMENU); /* default height */
Alexandre Julliard940d58c1994-09-16 09:24:37 +00001460 rect.top += MENU_DrawMenuBar( hdc, &r, hwnd, suppress_menupaint );
Alexandre Julliardf7207251994-07-23 07:57:48 +00001461 }
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001462
Alexandre Julliardecc37121994-11-22 16:31:29 +00001463 /* Draw the scroll-bars */
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001464
Gerard Patele9b4fd12001-11-30 23:13:22 +00001465 if (dwStyle & WS_VSCROLL)
Alex Korobkad2085841998-10-18 10:37:46 +00001466 SCROLL_DrawScrollBar( hwnd, hdc, SB_VERT, TRUE, TRUE );
Gerard Patele9b4fd12001-11-30 23:13:22 +00001467 if (dwStyle & WS_HSCROLL)
Alex Korobkad2085841998-10-18 10:37:46 +00001468 SCROLL_DrawScrollBar( hwnd, hdc, SB_HORZ, TRUE, TRUE );
Alexandre Julliardecc37121994-11-22 16:31:29 +00001469
1470 /* Draw the "size-box" */
1471
Gerard Patele9b4fd12001-11-30 23:13:22 +00001472 if ((dwStyle & WS_VSCROLL) && (dwStyle & WS_HSCROLL))
Alexandre Julliardecc37121994-11-22 16:31:29 +00001473 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001474 RECT r = rect;
Marcus Meissnerddca3151999-05-22 11:33:23 +00001475 r.left = r.right - GetSystemMetrics(SM_CXVSCROLL) + 1;
1476 r.top = r.bottom - GetSystemMetrics(SM_CYHSCROLL) + 1;
Alexandre Julliardf90efa91998-06-14 15:24:15 +00001477 if(wndPtr->dwStyle & WS_BORDER) {
1478 r.left++;
1479 r.top++;
1480 }
Alexandre Julliarda3960291999-02-26 11:11:13 +00001481 FillRect( hdc, &r, GetSysColorBrush(COLOR_SCROLLBAR) );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001482 }
1483
Alexandre Julliarda3960291999-02-26 11:11:13 +00001484 ReleaseDC( hwnd, hdc );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001485}
1486
1487
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001488/******************************************************************************
1489 *
1490 * void NC_DoNCPaint95(
Gerard Patele9b4fd12001-11-30 23:13:22 +00001491 * HWND hwnd,
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001492 * HRGN clip,
1493 * BOOL suppress_menupaint )
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001494 *
1495 * Paint the non-client area for Win95 windows. The clip region is
1496 * currently ignored.
1497 *
1498 * Bugs
1499 * grep -E -A10 -B5 \(95\)\|\(Bugs\)\|\(FIXME\) windows/nonclient.c \
1500 * misc/tweak.c controls/menu.c # :-)
1501 *
1502 * Revision history
1503 * 03-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1504 * Original implementation
Alexandre Julliardf90efa91998-06-14 15:24:15 +00001505 * 10-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1506 * Fixed some bugs.
Ove Kaaven60c78f11999-07-03 15:40:29 +00001507 * 29-Jun-1999 Ove KÃ¥ven (ovek@arcticnet.no)
1508 * Streamlined window style checks.
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001509 *
1510 *****************************************************************************/
1511
Patrik Stridvall1ed4ecf1999-06-26 14:58:24 +00001512static void NC_DoNCPaint95(
Gerard Patele9b4fd12001-11-30 23:13:22 +00001513 HWND hwnd,
Alexandre Julliarda3960291999-02-26 11:11:13 +00001514 HRGN clip,
1515 BOOL suppress_menupaint )
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001516{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001517 HDC hdc;
Alex Korobka4f1ac051999-03-28 09:37:57 +00001518 RECT rfuzz, rect, rectClip;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001519 BOOL active;
Gerard Patele9b4fd12001-11-30 23:13:22 +00001520 WND *wndPtr;
1521 DWORD dwStyle, dwExStyle;
1522 WORD flags;
1523 RECT rectClient, rectWindow;
1524 int has_menu;
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001525
Gerard Patele9b4fd12001-11-30 23:13:22 +00001526 if (!(wndPtr = WIN_GetPtr( hwnd )) || wndPtr == WND_OTHER_PROCESS) return;
1527 has_menu = HAS_MENU(wndPtr);
1528 dwStyle = wndPtr->dwStyle;
1529 dwExStyle = wndPtr->dwExStyle;
1530 flags = wndPtr->flags;
1531 rectClient = wndPtr->rectClient;
1532 rectWindow = wndPtr->rectWindow;
1533 WIN_ReleasePtr( wndPtr );
1534
1535 if ( dwStyle & WS_MINIMIZE ||
Alexandre Julliard8fd26b92001-10-15 17:56:45 +00001536 !WIN_IsWindowDrawable( hwnd, 0 )) return; /* Nothing to do */
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001537
Gerard Patele9b4fd12001-11-30 23:13:22 +00001538 active = flags & WIN_NCACTIVATED;
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001539
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +00001540 TRACE("%04x %d\n", hwnd, active );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001541
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +00001542 /* MSDN docs are pretty idiotic here, they say app CAN use clipRgn in
1543 the call to GetDCEx implying that it is allowed not to use it either.
1544 However, the suggested GetDCEx( , DCX_WINDOW | DCX_INTERSECTRGN)
1545 will cause clipRgn to be deleted after ReleaseDC().
1546 Now, how is the "system" supposed to tell what happened?
Alex Korobka4f1ac051999-03-28 09:37:57 +00001547 */
1548
1549 if (!(hdc = GetDCEx( hwnd, (clip > 1) ? clip : 0, DCX_USESTYLE | DCX_WINDOW |
1550 ((clip > 1) ?(DCX_INTERSECTRGN | DCX_KEEPCLIPRGN) : 0) ))) return;
1551
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001552
Gerard Patele9b4fd12001-11-30 23:13:22 +00001553 if (ExcludeVisRect16( hdc, rectClient.left-rectWindow.left,
1554 rectClient.top-rectWindow.top,
1555 rectClient.right-rectWindow.left,
1556 rectClient.bottom-rectWindow.top )
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001557 == NULLREGION)
1558 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001559 ReleaseDC( hwnd, hdc );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001560 return;
1561 }
1562
1563 rect.top = rect.left = 0;
Gerard Patele9b4fd12001-11-30 23:13:22 +00001564 rect.right = rectWindow.right - rectWindow.left;
1565 rect.bottom = rectWindow.bottom - rectWindow.top;
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001566
Alex Korobka4f1ac051999-03-28 09:37:57 +00001567 if( clip > 1 )
1568 GetRgnBox( clip, &rectClip );
1569 else
1570 {
1571 clip = 0;
1572 rectClip = rect;
1573 }
1574
Alexandre Julliarda3960291999-02-26 11:11:13 +00001575 SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001576
Gerard Patele9b4fd12001-11-30 23:13:22 +00001577 if (HAS_STATICOUTERFRAME(dwStyle, dwExStyle)) {
Bill Medlandcbfbf2a2001-07-20 18:36:49 +00001578 DrawEdge (hdc, &rect, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
1579 }
Gerard Patele9b4fd12001-11-30 23:13:22 +00001580 else if (HAS_BIGFRAME( dwStyle, dwExStyle)) {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +00001581 DrawEdge (hdc, &rect, EDGE_RAISED, BF_RECT | BF_ADJUST);
1582 }
Bill Medlandcbfbf2a2001-07-20 18:36:49 +00001583
Gerard Patele9b4fd12001-11-30 23:13:22 +00001584 NC_DrawFrame95(hdc, &rect, active, dwStyle, dwExStyle );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001585
Gerard Patele9b4fd12001-11-30 23:13:22 +00001586 if ((dwStyle & WS_CAPTION) == WS_CAPTION)
Alexandre Julliarddc4fe772001-06-04 21:55:17 +00001587 {
1588 RECT r = rect;
Gerard Patele9b4fd12001-11-30 23:13:22 +00001589 if (dwExStyle & WS_EX_TOOLWINDOW) {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +00001590 r.bottom = rect.top + GetSystemMetrics(SM_CYSMCAPTION);
1591 rect.top += GetSystemMetrics(SM_CYSMCAPTION);
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001592 }
Alexandre Julliarddc4fe772001-06-04 21:55:17 +00001593 else {
1594 r.bottom = rect.top + GetSystemMetrics(SM_CYCAPTION);
1595 rect.top += GetSystemMetrics(SM_CYCAPTION);
1596 }
1597 if( !clip || IntersectRect( &rfuzz, &r, &rectClip ) )
Gerard Patele9b4fd12001-11-30 23:13:22 +00001598 NC_DrawCaption95 (hdc, &r, hwnd, dwStyle,
1599 dwExStyle, active);
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001600 }
1601
Gerard Patele9b4fd12001-11-30 23:13:22 +00001602 if (has_menu)
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001603 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001604 RECT r = rect;
Marcus Meissnerddca3151999-05-22 11:33:23 +00001605 r.bottom = rect.top + GetSystemMetrics(SM_CYMENU);
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001606
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +00001607 TRACE("Calling DrawMenuBar with rect (%d, %d)-(%d, %d)\n",
1608 r.left, r.top, r.right, r.bottom);
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001609
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001610 rect.top += MENU_DrawMenuBar( hdc, &r, hwnd, suppress_menupaint ) + 1;
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001611 }
1612
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +00001613 TRACE("After MenuBar, rect is (%d, %d)-(%d, %d).\n",
1614 rect.left, rect.top, rect.right, rect.bottom );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001615
Gerard Patele9b4fd12001-11-30 23:13:22 +00001616 if (dwExStyle & WS_EX_CLIENTEDGE)
Alexandre Julliarda3960291999-02-26 11:11:13 +00001617 DrawEdge (hdc, &rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001618
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001619 /* Draw the scroll-bars */
1620
Gerard Patele9b4fd12001-11-30 23:13:22 +00001621 if (dwStyle & WS_VSCROLL)
Alex Korobkad2085841998-10-18 10:37:46 +00001622 SCROLL_DrawScrollBar( hwnd, hdc, SB_VERT, TRUE, TRUE );
Gerard Patele9b4fd12001-11-30 23:13:22 +00001623 if (dwStyle & WS_HSCROLL)
Alex Korobkad2085841998-10-18 10:37:46 +00001624 SCROLL_DrawScrollBar( hwnd, hdc, SB_HORZ, TRUE, TRUE );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001625
1626 /* Draw the "size-box" */
Gerard Patele9b4fd12001-11-30 23:13:22 +00001627 if ((dwStyle & WS_VSCROLL) && (dwStyle & WS_HSCROLL))
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001628 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001629 RECT r = rect;
Marcus Meissnerddca3151999-05-22 11:33:23 +00001630 r.left = r.right - GetSystemMetrics(SM_CXVSCROLL) + 1;
1631 r.top = r.bottom - GetSystemMetrics(SM_CYHSCROLL) + 1;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001632 FillRect( hdc, &r, GetSysColorBrush(COLOR_SCROLLBAR) );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001633 }
1634
Alexandre Julliarda3960291999-02-26 11:11:13 +00001635 ReleaseDC( hwnd, hdc );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001636}
1637
1638
1639
Alexandre Julliard988ca971994-06-21 16:15:21 +00001640
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001641/***********************************************************************
1642 * NC_HandleNCPaint
1643 *
1644 * Handle a WM_NCPAINT message. Called from DefWindowProc().
1645 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001646LONG NC_HandleNCPaint( HWND hwnd , HRGN clip)
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001647{
Gerard Patele9b4fd12001-11-30 23:13:22 +00001648 DWORD dwStyle = GetWindowLongW( hwnd, GWL_STYLE );
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001649
Gerard Patele9b4fd12001-11-30 23:13:22 +00001650 if( dwStyle & WS_VISIBLE )
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001651 {
Gerard Patele9b4fd12001-11-30 23:13:22 +00001652 if( dwStyle & WS_MINIMIZE )
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001653 WINPOS_RedrawIconTitle( hwnd );
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00001654 else if (TWEAK_WineLook == WIN31_LOOK)
Gerard Patele9b4fd12001-11-30 23:13:22 +00001655 NC_DoNCPaint( hwnd, clip, FALSE );
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00001656 else
Gerard Patele9b4fd12001-11-30 23:13:22 +00001657 NC_DoNCPaint95( hwnd, clip, FALSE );
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001658 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001659 return 0;
1660}
1661
1662
1663/***********************************************************************
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001664 * NC_HandleNCActivate
1665 *
1666 * Handle a WM_NCACTIVATE message. Called from DefWindowProc().
1667 */
Alexandre Julliardde424282001-08-10 22:51:42 +00001668LONG NC_HandleNCActivate( HWND hwnd, WPARAM wParam )
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001669{
Alexandre Julliardde424282001-08-10 22:51:42 +00001670 WND* wndPtr = WIN_FindWndPtr( hwnd );
1671
Dmitry Timoshkovd1e648f2001-06-04 02:49:22 +00001672 /* Lotus Notes draws menu descriptions in the caption of its main
1673 * window. When it wants to restore original "system" view, it just
1674 * sends WM_NCACTIVATE message to itself. Any optimizations here in
1675 * attempt to minimize redrawings lead to a not restored caption.
1676 */
Alexandre Julliardde424282001-08-10 22:51:42 +00001677 if (wndPtr)
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001678 {
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001679 if (wParam) wndPtr->flags |= WIN_NCACTIVATED;
1680 else wndPtr->flags &= ~WIN_NCACTIVATED;
Gerard Patele9b4fd12001-11-30 23:13:22 +00001681 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001682
Alexandre Julliardde424282001-08-10 22:51:42 +00001683 if (IsIconic(hwnd)) WINPOS_RedrawIconTitle( hwnd );
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00001684 else if (TWEAK_WineLook == WIN31_LOOK)
Gerard Patele9b4fd12001-11-30 23:13:22 +00001685 NC_DoNCPaint( hwnd, (HRGN)1, FALSE );
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00001686 else
Gerard Patele9b4fd12001-11-30 23:13:22 +00001687 NC_DoNCPaint95( hwnd, (HRGN)1, FALSE );
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001688 }
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001689 return TRUE;
1690}
1691
1692
1693/***********************************************************************
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001694 * NC_HandleSetCursor
1695 *
1696 * Handle a WM_SETCURSOR message. Called from DefWindowProc().
1697 */
Alexandre Julliardcb25e252001-08-08 23:28:42 +00001698LONG NC_HandleSetCursor( HWND hwnd, WPARAM wParam, LPARAM lParam )
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001699{
Alexandre Julliard021dd992001-09-14 21:29:19 +00001700 if (hwnd != WIN_GetFullHandle( (HWND)wParam ))
1701 return 0; /* Don't set the cursor for child windows */
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001702
1703 switch(LOWORD(lParam))
1704 {
1705 case HTERROR:
1706 {
1707 WORD msg = HIWORD( lParam );
1708 if ((msg == WM_LBUTTONDOWN) || (msg == WM_MBUTTONDOWN) ||
1709 (msg == WM_RBUTTONDOWN))
Alexandre Julliarda3960291999-02-26 11:11:13 +00001710 MessageBeep(0);
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001711 }
1712 break;
1713
1714 case HTCLIENT:
1715 {
Alexandre Julliardd44e4952001-08-20 18:09:39 +00001716 HCURSOR hCursor = GetClassLongA(hwnd, GCL_HCURSOR);
Gerard Patel5773dad1999-06-12 14:45:56 +00001717 if(hCursor) {
Alexandre Julliardd44e4952001-08-20 18:09:39 +00001718 SetCursor(hCursor);
Gerard Patel5773dad1999-06-12 14:45:56 +00001719 return TRUE;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001720 }
Gerard Patel5773dad1999-06-12 14:45:56 +00001721 return FALSE;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001722 }
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001723
1724 case HTLEFT:
1725 case HTRIGHT:
Alexandre Julliard2682bc22000-11-27 22:03:23 +00001726 return (LONG)SetCursor( LoadCursorA( 0, IDC_SIZEWEA ) );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001727
1728 case HTTOP:
1729 case HTBOTTOM:
Alexandre Julliard2682bc22000-11-27 22:03:23 +00001730 return (LONG)SetCursor( LoadCursorA( 0, IDC_SIZENSA ) );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001731
1732 case HTTOPLEFT:
1733 case HTBOTTOMRIGHT:
Alexandre Julliard2682bc22000-11-27 22:03:23 +00001734 return (LONG)SetCursor( LoadCursorA( 0, IDC_SIZENWSEA ) );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001735
1736 case HTTOPRIGHT:
1737 case HTBOTTOMLEFT:
Alexandre Julliard2682bc22000-11-27 22:03:23 +00001738 return (LONG)SetCursor( LoadCursorA( 0, IDC_SIZENESWA ) );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001739 }
1740
1741 /* Default cursor: arrow */
Alexandre Julliard2682bc22000-11-27 22:03:23 +00001742 return (LONG)SetCursor( LoadCursorA( 0, IDC_ARROWA ) );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001743}
1744
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001745/***********************************************************************
1746 * NC_GetSysPopupPos
1747 */
Alexandre Julliardde424282001-08-10 22:51:42 +00001748void NC_GetSysPopupPos( HWND hwnd, RECT* rect )
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001749{
Alexandre Julliardde424282001-08-10 22:51:42 +00001750 if (IsIconic(hwnd)) GetWindowRect( hwnd, rect );
1751 else
1752 {
1753 WND *wndPtr = WIN_FindWndPtr( hwnd );
1754 if (!wndPtr) return;
1755
1756 NC_GetInsideRect( hwnd, rect );
1757 OffsetRect( rect, wndPtr->rectWindow.left, wndPtr->rectWindow.top);
1758 if (wndPtr->dwStyle & WS_CHILD)
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001759 ClientToScreen( GetParent(hwnd), (POINT *)rect );
Alexandre Julliardde424282001-08-10 22:51:42 +00001760 if (TWEAK_WineLook == WIN31_LOOK) {
Marcus Meissnerddca3151999-05-22 11:33:23 +00001761 rect->right = rect->left + GetSystemMetrics(SM_CXSIZE);
1762 rect->bottom = rect->top + GetSystemMetrics(SM_CYSIZE);
Alexandre Julliardde424282001-08-10 22:51:42 +00001763 }
1764 else {
Marcus Meissnerddca3151999-05-22 11:33:23 +00001765 rect->right = rect->left + GetSystemMetrics(SM_CYCAPTION) - 1;
1766 rect->bottom = rect->top + GetSystemMetrics(SM_CYCAPTION) - 1;
Alexandre Julliardde424282001-08-10 22:51:42 +00001767 }
1768 WIN_ReleaseWndPtr( wndPtr );
1769 }
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001770}
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001771
1772/***********************************************************************
Pascal Lessardd814bb61999-07-31 13:02:02 +00001773 * NC_TrackMinMaxBox95
1774 *
1775 * Track a mouse button press on the minimize or maximize box.
1776 *
1777 * The big difference between 3.1 and 95 is the disabled button state.
1778 * In win95 the system button can be disabled, so it can ignore the mouse
1779 * event.
1780 *
1781 */
1782static void NC_TrackMinMaxBox95( HWND hwnd, WORD wParam )
1783{
1784 MSG msg;
Pascal Lessardd814bb61999-07-31 13:02:02 +00001785 HDC hdc = GetWindowDC( hwnd );
1786 BOOL pressed = TRUE;
1787 UINT state;
1788 DWORD wndStyle = GetWindowLongA( hwnd, GWL_STYLE);
1789 HMENU hSysMenu = GetSystemMenu(hwnd, FALSE);
1790
1791 void (*paintButton)(HWND, HDC16, BOOL, BOOL);
1792
1793 if (wParam == HTMINBUTTON)
1794 {
1795 /* If the style is not present, do nothing */
1796 if (!(wndStyle & WS_MINIMIZEBOX))
1797 return;
1798
1799 /* Check if the sysmenu item for minimize is there */
1800 state = GetMenuState(hSysMenu, SC_MINIMIZE, MF_BYCOMMAND);
1801
1802 paintButton = &NC_DrawMinButton95;
1803 }
1804 else
1805 {
1806 /* If the style is not present, do nothing */
1807 if (!(wndStyle & WS_MAXIMIZEBOX))
1808 return;
1809
1810 /* Check if the sysmenu item for maximize is there */
1811 state = GetMenuState(hSysMenu, SC_MAXIMIZE, MF_BYCOMMAND);
1812
1813 paintButton = &NC_DrawMaxButton95;
1814 }
1815
1816 SetCapture( hwnd );
1817
1818 (*paintButton)( hwnd, hdc, TRUE, FALSE);
1819
Dmitry Timoshkov63ba91d2000-10-15 00:22:29 +00001820 while(1)
Pascal Lessardd814bb61999-07-31 13:02:02 +00001821 {
1822 BOOL oldstate = pressed;
Alexandre Julliardbfb4a232001-08-06 18:05:47 +00001823
1824 if (!GetMessageW( &msg, 0, WM_MOUSEFIRST, WM_MOUSELAST )) break;
1825 if (CallMsgFilterW( &msg, MSGF_MAX )) continue;
Pascal Lessardd814bb61999-07-31 13:02:02 +00001826
Dmitry Timoshkov63ba91d2000-10-15 00:22:29 +00001827 if(msg.message == WM_LBUTTONUP)
1828 break;
1829
1830 if(msg.message != WM_MOUSEMOVE)
1831 continue;
1832
Alexandre Julliard83f52d12000-09-26 22:20:14 +00001833 pressed = (NC_HandleNCHitTest( hwnd, msg.pt ) == wParam);
Pascal Lessardd814bb61999-07-31 13:02:02 +00001834 if (pressed != oldstate)
1835 (*paintButton)( hwnd, hdc, pressed, FALSE);
Dmitry Timoshkov63ba91d2000-10-15 00:22:29 +00001836 }
Pascal Lessardd814bb61999-07-31 13:02:02 +00001837
Dmitry Timoshkov63ba91d2000-10-15 00:22:29 +00001838 if(pressed)
1839 (*paintButton)(hwnd, hdc, FALSE, FALSE);
Pascal Lessardd814bb61999-07-31 13:02:02 +00001840
1841 ReleaseCapture();
1842 ReleaseDC( hwnd, hdc );
1843
1844 /* If the item minimize or maximize of the sysmenu are not there */
1845 /* or if the style is not present, do nothing */
1846 if ((!pressed) || (state == 0xFFFFFFFF))
1847 return;
1848
1849 if (wParam == HTMINBUTTON)
Alexandre Julliard83f52d12000-09-26 22:20:14 +00001850 SendMessageA( hwnd, WM_SYSCOMMAND, SC_MINIMIZE, MAKELONG(msg.pt.x,msg.pt.y) );
Pascal Lessardd814bb61999-07-31 13:02:02 +00001851 else
Alexandre Julliard83f52d12000-09-26 22:20:14 +00001852 SendMessageA( hwnd, WM_SYSCOMMAND,
1853 IsZoomed(hwnd) ? SC_RESTORE:SC_MAXIMIZE, MAKELONG(msg.pt.x,msg.pt.y) );
Pascal Lessardd814bb61999-07-31 13:02:02 +00001854}
1855
1856/***********************************************************************
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001857 * NC_TrackMinMaxBox
1858 *
1859 * Track a mouse button press on the minimize or maximize box.
1860 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001861static void NC_TrackMinMaxBox( HWND hwnd, WORD wParam )
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001862{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001863 MSG msg;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001864 HDC hdc = GetWindowDC( hwnd );
1865 BOOL pressed = TRUE;
1866 void (*paintButton)(HWND, HDC16, BOOL);
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001867
Alexandre Julliarda3960291999-02-26 11:11:13 +00001868 SetCapture( hwnd );
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001869
Pascal Lessardd814bb61999-07-31 13:02:02 +00001870 if (wParam == HTMINBUTTON)
1871 paintButton = &NC_DrawMinButton;
1872 else
1873 paintButton = &NC_DrawMaxButton;
1874
1875 (*paintButton)( hwnd, hdc, TRUE);
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001876
Dmitry Timoshkov63ba91d2000-10-15 00:22:29 +00001877 while(1)
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001878 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001879 BOOL oldstate = pressed;
Alexandre Julliardbfb4a232001-08-06 18:05:47 +00001880
1881 if (!GetMessageW( &msg, 0, WM_MOUSEFIRST, WM_MOUSELAST )) break;
1882 if (CallMsgFilterW( &msg, MSGF_MAX )) continue;
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001883
Dmitry Timoshkov63ba91d2000-10-15 00:22:29 +00001884 if(msg.message == WM_LBUTTONUP)
1885 break;
1886
1887 if(msg.message != WM_MOUSEMOVE)
1888 continue;
1889
Alexandre Julliard83f52d12000-09-26 22:20:14 +00001890 pressed = (NC_HandleNCHitTest( hwnd, msg.pt ) == wParam);
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001891 if (pressed != oldstate)
Pascal Lessardd814bb61999-07-31 13:02:02 +00001892 (*paintButton)( hwnd, hdc, pressed);
Dmitry Timoshkov63ba91d2000-10-15 00:22:29 +00001893 }
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001894
Dmitry Timoshkov63ba91d2000-10-15 00:22:29 +00001895 if(pressed)
1896 (*paintButton)( hwnd, hdc, FALSE);
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001897
1898 ReleaseCapture();
Alexandre Julliarda3960291999-02-26 11:11:13 +00001899 ReleaseDC( hwnd, hdc );
Pascal Lessardd814bb61999-07-31 13:02:02 +00001900
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001901 if (!pressed) return;
1902
1903 if (wParam == HTMINBUTTON)
Alexandre Julliard83f52d12000-09-26 22:20:14 +00001904 SendMessageA( hwnd, WM_SYSCOMMAND, SC_MINIMIZE, MAKELONG(msg.pt.x,msg.pt.y) );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001905 else
Alexandre Julliard83f52d12000-09-26 22:20:14 +00001906 SendMessageA( hwnd, WM_SYSCOMMAND,
1907 IsZoomed(hwnd) ? SC_RESTORE:SC_MAXIMIZE, MAKELONG(msg.pt.x,msg.pt.y) );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001908}
1909
1910
1911/***********************************************************************
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001912 * NC_TrackCloseButton95
1913 *
1914 * Track a mouse button press on the Win95 close button.
1915 */
1916static void
Alexandre Julliarda3960291999-02-26 11:11:13 +00001917NC_TrackCloseButton95 (HWND hwnd, WORD wParam)
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001918{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001919 MSG msg;
Pascal Lessardd814bb61999-07-31 13:02:02 +00001920 HDC hdc;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001921 BOOL pressed = TRUE;
Pascal Lessardd814bb61999-07-31 13:02:02 +00001922 HMENU hSysMenu = GetSystemMenu(hwnd, FALSE);
1923 UINT state;
1924
1925 if(hSysMenu == 0)
1926 return;
1927
1928 state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
1929
1930 /* If the item close of the sysmenu is disabled or not there do nothing */
1931 if((state & MF_DISABLED) || (state & MF_GRAYED) || (state == 0xFFFFFFFF))
1932 return;
1933
1934 hdc = GetWindowDC( hwnd );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001935
Alexandre Julliarda3960291999-02-26 11:11:13 +00001936 SetCapture( hwnd );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001937
Pascal Lessardd814bb61999-07-31 13:02:02 +00001938 NC_DrawCloseButton95 (hwnd, hdc, TRUE, FALSE);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001939
Dmitry Timoshkov63ba91d2000-10-15 00:22:29 +00001940 while(1)
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001941 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001942 BOOL oldstate = pressed;
Alexandre Julliardbfb4a232001-08-06 18:05:47 +00001943
1944 if (!GetMessageW( &msg, 0, WM_MOUSEFIRST, WM_MOUSELAST )) break;
1945 if (CallMsgFilterW( &msg, MSGF_MAX )) continue;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001946
Dmitry Timoshkov63ba91d2000-10-15 00:22:29 +00001947 if(msg.message == WM_LBUTTONUP)
1948 break;
1949
1950 if(msg.message != WM_MOUSEMOVE)
1951 continue;
1952
Alexandre Julliard83f52d12000-09-26 22:20:14 +00001953 pressed = (NC_HandleNCHitTest( hwnd, msg.pt ) == wParam);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001954 if (pressed != oldstate)
Pascal Lessardd814bb61999-07-31 13:02:02 +00001955 NC_DrawCloseButton95 (hwnd, hdc, pressed, FALSE);
Dmitry Timoshkov63ba91d2000-10-15 00:22:29 +00001956 }
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001957
Dmitry Timoshkov63ba91d2000-10-15 00:22:29 +00001958 if(pressed)
1959 NC_DrawCloseButton95 (hwnd, hdc, FALSE, FALSE);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001960
1961 ReleaseCapture();
Alexandre Julliarda3960291999-02-26 11:11:13 +00001962 ReleaseDC( hwnd, hdc );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001963 if (!pressed) return;
1964
Alexandre Julliard83f52d12000-09-26 22:20:14 +00001965 SendMessageA( hwnd, WM_SYSCOMMAND, SC_CLOSE, MAKELONG(msg.pt.x,msg.pt.y) );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001966}
1967
1968
1969/***********************************************************************
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001970 * NC_TrackScrollBar
1971 *
1972 * Track a mouse button press on the horizontal or vertical scroll-bar.
1973 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001974static void NC_TrackScrollBar( HWND hwnd, WPARAM wParam, POINT pt )
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001975{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001976 INT scrollbar;
Alexandre Julliardecc37121994-11-22 16:31:29 +00001977
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001978 if ((wParam & 0xfff0) == SC_HSCROLL)
1979 {
Alexandre Julliardb662e112001-10-16 21:52:26 +00001980 if ((wParam & 0x0f) != HTHSCROLL) return;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001981 scrollbar = SB_HORZ;
1982 }
1983 else /* SC_VSCROLL */
1984 {
Alexandre Julliardb662e112001-10-16 21:52:26 +00001985 if ((wParam & 0x0f) != HTVSCROLL) return;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001986 scrollbar = SB_VERT;
1987 }
Alexandre Julliardb662e112001-10-16 21:52:26 +00001988 SCROLL_TrackScrollBar( hwnd, scrollbar, pt );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001989}
1990
Alexandre Julliardb662e112001-10-16 21:52:26 +00001991
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001992/***********************************************************************
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001993 * NC_HandleNCLButtonDown
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001994 *
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001995 * Handle a WM_NCLBUTTONDOWN message. Called from DefWindowProc().
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001996 */
Alexandre Julliardde424282001-08-10 22:51:42 +00001997LONG NC_HandleNCLButtonDown( HWND hwnd, WPARAM wParam, LPARAM lParam )
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001998{
Alexandre Julliardde424282001-08-10 22:51:42 +00001999 LONG style = GetWindowLongA( hwnd, GWL_STYLE );
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002000
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002001 switch(wParam) /* Hit test */
Alexandre Julliardcdd09231994-01-12 11:12:51 +00002002 {
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002003 case HTCAPTION:
Alexandre Julliardde424282001-08-10 22:51:42 +00002004 {
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00002005 HWND top = GetAncestor( hwnd, GA_ROOT );
Alexandre Julliard23946ad1997-06-16 17:43:53 +00002006
Alexandre Julliardde424282001-08-10 22:51:42 +00002007 if( WINPOS_SetActiveWindow(top, TRUE, TRUE) || (GetActiveWindow() == top) )
2008 SendMessageW( hwnd, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, lParam );
2009 break;
2010 }
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002011
Alexandre Julliardcdd09231994-01-12 11:12:51 +00002012 case HTSYSMENU:
Alexandre Julliardde424282001-08-10 22:51:42 +00002013 if( style & WS_SYSMENU )
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002014 {
Alexandre Julliardde424282001-08-10 22:51:42 +00002015 if( !(style & WS_MINIMIZE) )
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002016 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00002017 HDC hDC = GetWindowDC(hwnd);
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00002018 if (TWEAK_WineLook == WIN31_LOOK)
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002019 NC_DrawSysButton( hwnd, hDC, TRUE );
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00002020 else
2021 NC_DrawSysButton95( hwnd, hDC, TRUE );
Alexandre Julliarda3960291999-02-26 11:11:13 +00002022 ReleaseDC( hwnd, hDC );
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002023 }
Alexandre Julliardcb25e252001-08-08 23:28:42 +00002024 SendMessageW( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU + HTSYSMENU, lParam );
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002025 }
2026 break;
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002027
2028 case HTMENU:
Alexandre Julliardcb25e252001-08-08 23:28:42 +00002029 SendMessageW( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU, lParam );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002030 break;
2031
2032 case HTHSCROLL:
Alexandre Julliardcb25e252001-08-08 23:28:42 +00002033 SendMessageW( hwnd, WM_SYSCOMMAND, SC_HSCROLL + HTHSCROLL, lParam );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002034 break;
2035
2036 case HTVSCROLL:
Alexandre Julliardcb25e252001-08-08 23:28:42 +00002037 SendMessageW( hwnd, WM_SYSCOMMAND, SC_VSCROLL + HTVSCROLL, lParam );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002038 break;
2039
2040 case HTMINBUTTON:
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002041 case HTMAXBUTTON:
Pascal Lessardd814bb61999-07-31 13:02:02 +00002042 if (TWEAK_WineLook == WIN31_LOOK)
2043 NC_TrackMinMaxBox( hwnd, wParam );
2044 else
2045 NC_TrackMinMaxBox95( hwnd, wParam );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002046 break;
2047
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00002048 case HTCLOSE:
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00002049 if (TWEAK_WineLook >= WIN95_LOOK)
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00002050 NC_TrackCloseButton95 (hwnd, wParam);
2051 break;
Pascal Lessardd814bb61999-07-31 13:02:02 +00002052
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002053 case HTLEFT:
2054 case HTRIGHT:
2055 case HTTOP:
2056 case HTTOPLEFT:
2057 case HTTOPRIGHT:
2058 case HTBOTTOM:
2059 case HTBOTTOMLEFT:
2060 case HTBOTTOMRIGHT:
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002061 /* make sure hittest fits into 0xf and doesn't overlap with HTSYSMENU */
Alexandre Julliardcb25e252001-08-08 23:28:42 +00002062 SendMessageW( hwnd, WM_SYSCOMMAND, SC_SIZE + wParam - 2, lParam);
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002063 break;
2064
2065 case HTBORDER:
2066 break;
2067 }
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002068 return 0;
2069}
2070
2071
2072/***********************************************************************
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002073 * NC_HandleNCLButtonDblClk
2074 *
2075 * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc().
2076 */
Alexandre Julliardde424282001-08-10 22:51:42 +00002077LONG NC_HandleNCLButtonDblClk( HWND hwnd, WPARAM wParam, LPARAM lParam )
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002078{
Alexandre Julliard940d58c1994-09-16 09:24:37 +00002079 /*
2080 * if this is an icon, send a restore since we are handling
2081 * a double click
2082 */
Alexandre Julliardde424282001-08-10 22:51:42 +00002083 if (IsIconic(hwnd))
Alexandre Julliard940d58c1994-09-16 09:24:37 +00002084 {
Alexandre Julliardde424282001-08-10 22:51:42 +00002085 SendMessageW( hwnd, WM_SYSCOMMAND, SC_RESTORE, lParam );
Alexandre Julliard1285c2f1996-05-06 16:06:24 +00002086 return 0;
Alexandre Julliard940d58c1994-09-16 09:24:37 +00002087 }
2088
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002089 switch(wParam) /* Hit test */
2090 {
2091 case HTCAPTION:
Alexandre Julliard902da691995-11-05 14:39:02 +00002092 /* stop processing if WS_MAXIMIZEBOX is missing */
Alexandre Julliardde424282001-08-10 22:51:42 +00002093 if (GetWindowLongA( hwnd, GWL_STYLE ) & WS_MAXIMIZEBOX)
2094 SendMessageW( hwnd, WM_SYSCOMMAND,
2095 IsZoomed(hwnd) ? SC_RESTORE : SC_MAXIMIZE, lParam );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002096 break;
2097
2098 case HTSYSMENU:
Alexandre Julliardd44e4952001-08-20 18:09:39 +00002099 if (!(GetClassLongW(hwnd, GCL_STYLE) & CS_NOCLOSE))
Alexandre Julliardde424282001-08-10 22:51:42 +00002100 SendMessageW( hwnd, WM_SYSCOMMAND, SC_CLOSE, lParam );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00002101 break;
Alexandre Julliard491502b1997-11-01 19:08:16 +00002102
2103 case HTHSCROLL:
Alexandre Julliardde424282001-08-10 22:51:42 +00002104 SendMessageW( hwnd, WM_SYSCOMMAND, SC_HSCROLL + HTHSCROLL, lParam );
Alexandre Julliard491502b1997-11-01 19:08:16 +00002105 break;
2106
2107 case HTVSCROLL:
Alexandre Julliardde424282001-08-10 22:51:42 +00002108 SendMessageW( hwnd, WM_SYSCOMMAND, SC_VSCROLL + HTVSCROLL, lParam );
Alexandre Julliard491502b1997-11-01 19:08:16 +00002109 break;
Alexandre Julliardcdd09231994-01-12 11:12:51 +00002110 }
2111 return 0;
2112}
2113
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002114
2115/***********************************************************************
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002116 * NC_HandleSysCommand
2117 *
2118 * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
2119 */
Alexandre Julliardb662e112001-10-16 21:52:26 +00002120LONG NC_HandleSysCommand( HWND hwnd, WPARAM wParam, LPARAM lParam )
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002121{
Alexandre Julliardb662e112001-10-16 21:52:26 +00002122 TRACE("Handling WM_SYSCOMMAND %x %lx\n", wParam, lParam );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002123
Alexandre Julliardb662e112001-10-16 21:52:26 +00002124 switch (wParam & 0xfff0)
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002125 {
2126 case SC_SIZE:
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002127 case SC_MOVE:
Alexandre Julliard3abeae82001-05-09 17:21:04 +00002128 if (USER_Driver.pSysCommandSizeMove)
2129 USER_Driver.pSysCommandSizeMove( hwnd, wParam );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002130 break;
2131
2132 case SC_MINIMIZE:
Noomen Hamzad1a1f7d1999-10-24 00:02:27 +00002133 if (hwnd == GetForegroundWindow())
2134 ShowOwnedPopups(hwnd,FALSE);
Alexandre Julliarda3960291999-02-26 11:11:13 +00002135 ShowWindow( hwnd, SW_MINIMIZE );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002136 break;
2137
2138 case SC_MAXIMIZE:
Noomen Hamzad1a1f7d1999-10-24 00:02:27 +00002139 if (IsIconic(hwnd) && hwnd == GetForegroundWindow())
2140 ShowOwnedPopups(hwnd,TRUE);
Alexandre Julliarda3960291999-02-26 11:11:13 +00002141 ShowWindow( hwnd, SW_MAXIMIZE );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002142 break;
2143
2144 case SC_RESTORE:
Noomen Hamzad1a1f7d1999-10-24 00:02:27 +00002145 if (IsIconic(hwnd) && hwnd == GetForegroundWindow())
2146 ShowOwnedPopups(hwnd,TRUE);
Alexandre Julliarda3960291999-02-26 11:11:13 +00002147 ShowWindow( hwnd, SW_RESTORE );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002148 break;
2149
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002150 case SC_CLOSE:
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002151 return SendMessageA( hwnd, WM_CLOSE, 0, 0 );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002152
2153 case SC_VSCROLL:
2154 case SC_HSCROLL:
Alexandre Julliardb662e112001-10-16 21:52:26 +00002155 {
2156 POINT pt;
2157 pt.x = SLOWORD(lParam);
2158 pt.y = SHIWORD(lParam);
2159 NC_TrackScrollBar( hwnd, wParam, pt );
2160 }
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002161 break;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002162
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002163 case SC_MOUSEMENU:
Alexandre Julliardb662e112001-10-16 21:52:26 +00002164 {
2165 POINT pt;
2166 pt.x = SLOWORD(lParam);
2167 pt.y = SHIWORD(lParam);
2168 MENU_TrackMouseMenuBar( hwnd, wParam & 0x000F, pt );
2169 }
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002170 break;
2171
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002172 case SC_KEYMENU:
Alexandre Julliardb662e112001-10-16 21:52:26 +00002173 MENU_TrackKbdMenuBar( hwnd, wParam, LOWORD(lParam) );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002174 break;
Alexandre Julliardb662e112001-10-16 21:52:26 +00002175
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002176 case SC_TASKLIST:
Alexandre Julliarda3960291999-02-26 11:11:13 +00002177 WinExec( "taskman.exe", SW_SHOWNORMAL );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002178 break;
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +00002179
2180 case SC_SCREENSAVE:
2181 if (wParam == SC_ABOUTWINE)
Alexandre Julliard563561e2000-01-24 05:46:47 +00002182 {
2183 HMODULE hmodule = LoadLibraryA( "shell32.dll" );
2184 if (hmodule)
2185 {
2186 FARPROC aboutproc = GetProcAddress( hmodule, "ShellAboutA" );
2187 if (aboutproc) aboutproc( hwnd, "Wine", WINE_RELEASE_INFO, 0 );
2188 FreeLibrary( hmodule );
2189 }
2190 }
Uwe Bonnes37007771998-11-01 15:07:24 +00002191 else
2192 if (wParam == SC_PUTMARK)
Alexandre Julliard06c275a1999-05-02 14:32:27 +00002193 TRACE_(shell)("Mark requested by user\n");
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +00002194 break;
Alexandre Julliard9ea19e51997-01-01 17:29:55 +00002195
2196 case SC_HOTKEY:
2197 case SC_ARRANGE:
2198 case SC_NEXTWINDOW:
2199 case SC_PREVWINDOW:
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +00002200 FIXME("unimplemented!\n");
Alexandre Julliard9ea19e51997-01-01 17:29:55 +00002201 break;
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002202 }
2203 return 0;
2204}
Pascal Lessardd814bb61999-07-31 13:02:02 +00002205
2206/*************************************************************
2207* NC_DrawGrayButton
2208*
2209* Stub for the grayed button of the caption
2210*
2211*************************************************************/
2212
2213BOOL NC_DrawGrayButton(HDC hdc, int x, int y)
2214{
2215 HBITMAP hMaskBmp;
2216 HDC hdcMask = CreateCompatibleDC (0);
2217 HBRUSH hOldBrush;
2218
2219 hMaskBmp = CreateBitmap (12, 10, 1, 1, lpGrayMask);
2220
2221 if(hMaskBmp == 0)
2222 return FALSE;
2223
2224 SelectObject (hdcMask, hMaskBmp);
2225
2226 /* Draw the grayed bitmap using the mask */
2227 hOldBrush = SelectObject (hdc, RGB(128, 128, 128));
2228 BitBlt (hdc, x, y, 12, 10,
2229 hdcMask, 0, 0, 0xB8074A);
2230
2231 /* Clean up */
2232 SelectObject (hdc, hOldBrush);
2233 DeleteObject(hMaskBmp);
2234 DeleteDC (hdcMask);
2235
2236 return TRUE;
2237}