blob: 38041509c579d61140470174f038a021ead6f91d [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 "message.h"
Alexandre Julliarddba420a1994-02-02 06:48:31 +000014#include "user.h"
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +000015#include "heap.h"
Alex Korobka4f1ac051999-03-28 09:37:57 +000016#include "dce.h"
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000017#include "cursoricon.h"
Alexandre Julliard234bc241994-12-10 13:02:28 +000018#include "dialog.h"
Alexandre Julliard234bc241994-12-10 13:02:28 +000019#include "menu.h"
20#include "winpos.h"
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +000021#include "hook.h"
Alexandre Julliard234bc241994-12-10 13:02:28 +000022#include "scroll.h"
23#include "nonclient.h"
Alexandre Julliardc981d0b1996-03-31 16:40:13 +000024#include "queue.h"
Alexandre Julliardfa68b751995-04-03 16:55:37 +000025#include "selectors.h"
Alexandre Julliardd37eb361997-07-20 16:23:21 +000026#include "tweak.h"
Alexandre Julliard06c275a1999-05-02 14:32:27 +000027#include "debugtools.h"
Alexandre Julliardd4719651995-12-12 18:49:11 +000028#include "options.h"
Marcus Meissner317af321999-02-17 13:51:06 +000029#include "shellapi.h"
Eric Kohl8e517b51998-10-11 13:06:35 +000030#include "cache.h"
Pascal Lessardd814bb61999-07-31 13:02:02 +000031#include "bitmap.h"
Alexandre Julliardcdd09231994-01-12 11:12:51 +000032
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +000033DEFAULT_DEBUG_CHANNEL(nonclient)
Patrik Stridvallb4b9fae1999-04-19 14:56:29 +000034DECLARE_DEBUG_CHANNEL(shell)
35
Pascal Lessardd814bb61999-07-31 13:02:02 +000036BOOL NC_DrawGrayButton(HDC hdc, int x, int y);
37
Alexandre Julliardbf9130a1996-10-13 17:45:47 +000038static HBITMAP16 hbitmapClose = 0;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000039static HBITMAP16 hbitmapCloseD = 0;
Alexandre Julliardbf9130a1996-10-13 17:45:47 +000040static HBITMAP16 hbitmapMinimize = 0;
41static HBITMAP16 hbitmapMinimizeD = 0;
42static HBITMAP16 hbitmapMaximize = 0;
43static HBITMAP16 hbitmapMaximizeD = 0;
44static HBITMAP16 hbitmapRestore = 0;
45static HBITMAP16 hbitmapRestoreD = 0;
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +000046
Pascal Lessardd814bb61999-07-31 13:02:02 +000047BYTE lpGrayMask[] = { 0xAA, 0xA0,
48 0x55, 0x50,
49 0xAA, 0xA0,
50 0x55, 0x50,
51 0xAA, 0xA0,
52 0x55, 0x50,
53 0xAA, 0xA0,
54 0x55, 0x50,
55 0xAA, 0xA0,
56 0x55, 0x50};
57
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +000058#define SC_ABOUTWINE (SC_SCREENSAVE+1)
Uwe Bonnes37007771998-11-01 15:07:24 +000059#define SC_PUTMARK (SC_SCREENSAVE+2)
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +000060
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +000061 /* Some useful macros */
62#define HAS_DLGFRAME(style,exStyle) \
Alexandre Julliard0c126c71996-02-18 18:44:41 +000063 (((exStyle) & WS_EX_DLGMODALFRAME) || \
Ove Kaaven60c78f11999-07-03 15:40:29 +000064 (((style) & WS_DLGFRAME) && !((style) & WS_THICKFRAME)))
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +000065
Ove Kaaven60c78f11999-07-03 15:40:29 +000066#define HAS_THICKFRAME(style,exStyle) \
Alexandre Julliard0c126c71996-02-18 18:44:41 +000067 (((style) & WS_THICKFRAME) && \
Abey George48c6eb51999-09-03 12:33:40 +000068 !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +000069
Ove Kaaven60c78f11999-07-03 15:40:29 +000070#define HAS_THINFRAME(style) \
71 (((style) & WS_BORDER) || !((style) & (WS_CHILD | WS_POPUP)))
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000072
Ove Kaaven60c78f11999-07-03 15:40:29 +000073#define HAS_BIGFRAME(style,exStyle) \
74 (((style) & (WS_THICKFRAME | WS_DLGFRAME)) || \
75 ((exStyle) & WS_EX_DLGMODALFRAME))
Gerard Patel5773dad1999-06-12 14:45:56 +000076
Ove Kaaven60c78f11999-07-03 15:40:29 +000077#define HAS_ANYFRAME(style,exStyle) \
78 (((style) & (WS_THICKFRAME | WS_DLGFRAME | WS_BORDER)) || \
79 ((exStyle) & WS_EX_DLGMODALFRAME) || \
80 !((style) & (WS_CHILD | WS_POPUP)))
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000081
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +000082#define HAS_MENU(w) (!((w)->dwStyle & WS_CHILD) && ((w)->wIDmenu != 0))
83
Alexandre Julliardfb9a9191994-03-01 19:48:04 +000084#define ON_LEFT_BORDER(hit) \
85 (((hit) == HTLEFT) || ((hit) == HTTOPLEFT) || ((hit) == HTBOTTOMLEFT))
86#define ON_RIGHT_BORDER(hit) \
87 (((hit) == HTRIGHT) || ((hit) == HTTOPRIGHT) || ((hit) == HTBOTTOMRIGHT))
88#define ON_TOP_BORDER(hit) \
89 (((hit) == HTTOP) || ((hit) == HTTOPLEFT) || ((hit) == HTTOPRIGHT))
90#define ON_BOTTOM_BORDER(hit) \
91 (((hit) == HTBOTTOM) || ((hit) == HTBOTTOMLEFT) || ((hit) == HTBOTTOMRIGHT))
92
Alexandre Julliardcdd09231994-01-12 11:12:51 +000093/***********************************************************************
Sylvain St-Germain00bf3811999-07-24 12:11:22 +000094 * WIN_WindowNeedsWMBorder
95 *
96 * This method defines the rules for a window to have a WM border,
97 * caption... It is used for consitency purposes.
98 */
99BOOL WIN_WindowNeedsWMBorder( DWORD style, DWORD exStyle )
100{
Francis Beaudetc9a50fd1999-09-10 13:59:24 +0000101 if (!(style & WS_CHILD) &&
102 Options.managed &&
103 !(exStyle & WS_EX_TOOLWINDOW) &&
104 ( ((style & WS_CAPTION) == WS_CAPTION) ||
105 (style & WS_THICKFRAME)))
Thuy Nguyen46570a91999-08-07 12:25:32 +0000106 return TRUE;
Alexandre Julliard1dc551c1999-12-11 23:54:59 +0000107 if (exStyle & WS_EX_TRAYWINDOW)
108 return TRUE;
Sylvain St-Germain00bf3811999-07-24 12:11:22 +0000109 return FALSE;
110}
111
112/***********************************************************************
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000113 * NC_AdjustRect
114 *
115 * Compute the size of the window rectangle from the size of the
116 * client rectangle.
117 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000118static void NC_AdjustRect( LPRECT16 rect, DWORD style, BOOL menu,
Alexandre Julliard21979011997-03-05 08:22:35 +0000119 DWORD exStyle )
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000120{
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000121 if (TWEAK_WineLook > WIN31_LOOK)
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +0000122 ERR("Called in Win95 mode. Aiee! Please report this.\n" );
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000123
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000124 if(style & WS_ICONIC) return;
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000125 /* Decide if the window will be managed (see CreateWindowEx) */
Sylvain St-Germain00bf3811999-07-24 12:11:22 +0000126 if (!WIN_WindowNeedsWMBorder(style, exStyle))
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000127 {
Ove Kaaven60c78f11999-07-03 15:40:29 +0000128 if (HAS_THICKFRAME( style, exStyle ))
129 InflateRect16( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000130 else
Ove Kaaven60c78f11999-07-03 15:40:29 +0000131 if (HAS_DLGFRAME( style, exStyle ))
132 InflateRect16( rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
133 else
134 if (HAS_THINFRAME( style ))
135 InflateRect16( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000136
137 if ((style & WS_CAPTION) == WS_CAPTION)
Marcus Meissnerddca3151999-05-22 11:33:23 +0000138 rect->top -= GetSystemMetrics(SM_CYCAPTION) - GetSystemMetrics(SM_CYBORDER);
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000139 }
Marcus Meissnerddca3151999-05-22 11:33:23 +0000140 if (menu) rect->top -= GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CYBORDER);
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000141
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000142 if (style & WS_VSCROLL) {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000143 rect->right += GetSystemMetrics(SM_CXVSCROLL) - 1;
Ove Kaaven60c78f11999-07-03 15:40:29 +0000144 if(!HAS_ANYFRAME( style, exStyle ))
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000145 rect->right++;
146 }
147
148 if (style & WS_HSCROLL) {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000149 rect->bottom += GetSystemMetrics(SM_CYHSCROLL) - 1;
Ove Kaaven60c78f11999-07-03 15:40:29 +0000150 if(!HAS_ANYFRAME( style, exStyle ))
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000151 rect->bottom++;
152 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000153}
154
155
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000156/******************************************************************************
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000157 * NC_AdjustRectOuter95
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000158 *
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000159 * Computes the size of the "outside" parts of the window based on the
160 * parameters of the client area.
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000161 *
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000162 + PARAMS
163 * LPRECT16 rect
164 * DWORD style
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000165 * BOOL menu
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000166 * DWORD exStyle
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000167 *
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000168 * NOTES
169 * "Outer" parts of a window means the whole window frame, caption and
170 * menu bar. It does not include "inner" parts of the frame like client
171 * edge, static edge or scroll bars.
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000172 *
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000173 * Revision history
174 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
175 * Original (NC_AdjustRect95) cut & paste from NC_AdjustRect
176 *
177 * 20-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
178 * Split NC_AdjustRect95 into NC_AdjustRectOuter95 and
179 * NC_AdjustRectInner95 and added handling of Win95 styles.
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000180 *
Ove Kaaven60c78f11999-07-03 15:40:29 +0000181 * 28-Jul-1999 Ove KÃ¥ven (ovek@arcticnet.no)
182 * Streamlined window style checks.
183 *
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000184 *****************************************************************************/
185
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000186static void
Alexandre Julliarda3960291999-02-26 11:11:13 +0000187NC_AdjustRectOuter95 (LPRECT16 rect, DWORD style, BOOL menu, DWORD exStyle)
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000188{
189 if(style & WS_ICONIC) return;
190
191 /* Decide if the window will be managed (see CreateWindowEx) */
Sylvain St-Germain00bf3811999-07-24 12:11:22 +0000192 if (!WIN_WindowNeedsWMBorder(style, exStyle))
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000193 {
Ove Kaaven60c78f11999-07-03 15:40:29 +0000194 if (HAS_THICKFRAME( style, exStyle ))
195 InflateRect16( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
196 else
197 if (HAS_DLGFRAME( style, exStyle ))
Marcus Meissnerddca3151999-05-22 11:33:23 +0000198 InflateRect16(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000199 else
Ove Kaaven60c78f11999-07-03 15:40:29 +0000200 if (HAS_THINFRAME( style ))
201 InflateRect16( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000202
203 if ((style & WS_CAPTION) == WS_CAPTION)
Jesper Skov5c3e4571998-11-01 19:27:22 +0000204 {
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000205 if (exStyle & WS_EX_TOOLWINDOW)
Marcus Meissnerddca3151999-05-22 11:33:23 +0000206 rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000207 else
Marcus Meissnerddca3151999-05-22 11:33:23 +0000208 rect->top -= GetSystemMetrics(SM_CYCAPTION);
Jesper Skov5c3e4571998-11-01 19:27:22 +0000209 }
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000210 }
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000211
212 if (menu)
Marcus Meissnerddca3151999-05-22 11:33:23 +0000213 rect->top -= GetSystemMetrics(SM_CYMENU);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000214}
215
216
217/******************************************************************************
218 * NC_AdjustRectInner95
219 *
220 * Computes the size of the "inside" part of the window based on the
221 * parameters of the client area.
222 *
223 + PARAMS
224 * LPRECT16 rect
225 * DWORD style
226 * DWORD exStyle
227 *
228 * NOTES
229 * "Inner" part of a window means the window frame inside of the flat
230 * window frame. It includes the client edge, the static edge and the
231 * scroll bars.
232 *
233 * Revision history
234 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
235 * Original (NC_AdjustRect95) cut & paste from NC_AdjustRect
236 *
237 * 20-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
238 * Split NC_AdjustRect95 into NC_AdjustRectOuter95 and
239 * NC_AdjustRectInner95 and added handling of Win95 styles.
240 *
241 *****************************************************************************/
242
243static void
244NC_AdjustRectInner95 (LPRECT16 rect, DWORD style, DWORD exStyle)
245{
246 if(style & WS_ICONIC) return;
247
248 if (exStyle & WS_EX_CLIENTEDGE)
Marcus Meissnerddca3151999-05-22 11:33:23 +0000249 InflateRect16 (rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000250
251 if (exStyle & WS_EX_STATICEDGE)
Marcus Meissnerddca3151999-05-22 11:33:23 +0000252 InflateRect16 (rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000253
Marcus Meissnerddca3151999-05-22 11:33:23 +0000254 if (style & WS_VSCROLL) rect->right += GetSystemMetrics(SM_CXVSCROLL);
255 if (style & WS_HSCROLL) rect->bottom += GetSystemMetrics(SM_CYHSCROLL);
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000256}
257
258
Alexandre Julliarde658d821997-11-30 17:45:40 +0000259/***********************************************************************
Eric Kohl8e517b51998-10-11 13:06:35 +0000260 * DrawCaption16 [USER.660] Draws a caption bar
261 *
262 * PARAMS
263 * hwnd [I]
264 * hdc [I]
265 * lpRect [I]
266 * uFlags [I]
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000267 *
Eric Kohld0b79c01998-10-24 10:45:42 +0000268 * RETURNS
269 * Success:
270 * Failure:
Alexandre Julliarde658d821997-11-30 17:45:40 +0000271 */
Eric Kohl8e517b51998-10-11 13:06:35 +0000272
273BOOL16 WINAPI
Eric Kohld0b79c01998-10-24 10:45:42 +0000274DrawCaption16 (HWND16 hwnd, HDC16 hdc, const RECT16 *rect, UINT16 uFlags)
Alexandre Julliarda845b881998-06-01 10:44:35 +0000275{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000276 RECT rect32;
Eric Kohl8e517b51998-10-11 13:06:35 +0000277
Eric Kohld0b79c01998-10-24 10:45:42 +0000278 if (rect)
279 CONV_RECT16TO32 (rect, &rect32);
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000280
Alexandre Julliarda3960291999-02-26 11:11:13 +0000281 return (BOOL16)DrawCaptionTempA (hwnd, hdc, rect ? &rect32 : NULL,
Eric Kohld0b79c01998-10-24 10:45:42 +0000282 0, 0, NULL, uFlags & 0x1F);
Alexandre Julliarde658d821997-11-30 17:45:40 +0000283}
284
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000285
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000286/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000287 * DrawCaption [USER32.154] Draws a caption bar
Eric Kohl8e517b51998-10-11 13:06:35 +0000288 *
289 * PARAMS
290 * hwnd [I]
291 * hdc [I]
292 * lpRect [I]
293 * uFlags [I]
294 *
Eric Kohld0b79c01998-10-24 10:45:42 +0000295 * RETURNS
296 * Success:
297 * Failure:
Eric Kohl8e517b51998-10-11 13:06:35 +0000298 */
299
Alexandre Julliarda3960291999-02-26 11:11:13 +0000300BOOL WINAPI
301DrawCaption (HWND hwnd, HDC hdc, const RECT *lpRect, UINT uFlags)
Eric Kohl8e517b51998-10-11 13:06:35 +0000302{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000303 return DrawCaptionTempA (hwnd, hdc, lpRect, 0, 0, NULL, uFlags & 0x1F);
Eric Kohl8e517b51998-10-11 13:06:35 +0000304}
305
306
307/***********************************************************************
308 * DrawCaptionTemp16 [USER.657]
309 *
Eric Kohld0b79c01998-10-24 10:45:42 +0000310 * PARAMS
311 *
312 * RETURNS
313 * Success:
314 * Failure:
Eric Kohl8e517b51998-10-11 13:06:35 +0000315 */
316
317BOOL16 WINAPI
318DrawCaptionTemp16 (HWND16 hwnd, HDC16 hdc, const RECT16 *rect, HFONT16 hFont,
319 HICON16 hIcon, LPCSTR str, UINT16 uFlags)
320{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000321 RECT rect32;
Eric Kohl8e517b51998-10-11 13:06:35 +0000322
Eric Kohld0b79c01998-10-24 10:45:42 +0000323 if (rect)
324 CONV_RECT16TO32(rect,&rect32);
Eric Kohl8e517b51998-10-11 13:06:35 +0000325
Alexandre Julliarda3960291999-02-26 11:11:13 +0000326 return (BOOL16)DrawCaptionTempA (hwnd, hdc, rect?&rect32:NULL, hFont,
Eric Kohld0b79c01998-10-24 10:45:42 +0000327 hIcon, str, uFlags & 0x1F);
Eric Kohl8e517b51998-10-11 13:06:35 +0000328}
329
330
331/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000332 * DrawCaptionTempA [USER32.599]
Eric Kohl8e517b51998-10-11 13:06:35 +0000333 *
Eric Kohld0b79c01998-10-24 10:45:42 +0000334 * PARAMS
335 *
336 * RETURNS
337 * Success:
338 * Failure:
Eric Kohl8e517b51998-10-11 13:06:35 +0000339 */
340
Alexandre Julliarda3960291999-02-26 11:11:13 +0000341BOOL WINAPI
342DrawCaptionTempA (HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont,
343 HICON hIcon, LPCSTR str, UINT uFlags)
Eric Kohl8e517b51998-10-11 13:06:35 +0000344{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000345 RECT rc = *rect;
Eric Kohl8e517b51998-10-11 13:06:35 +0000346
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +0000347 TRACE("(%08x,%08x,%p,%08x,%08x,\"%s\",%08x)\n",
348 hwnd, hdc, rect, hFont, hIcon, str, uFlags);
Eric Kohl8e517b51998-10-11 13:06:35 +0000349
350 /* drawing background */
351 if (uFlags & DC_INBUTTON) {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000352 FillRect (hdc, &rc, GetSysColorBrush (COLOR_3DFACE));
Eric Kohl8e517b51998-10-11 13:06:35 +0000353
354 if (uFlags & DC_ACTIVE) {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000355 HBRUSH hbr = SelectObject (hdc, CACHE_GetPattern55AABrush ());
356 PatBlt (hdc, rc.left, rc.top,
Eric Kohl8e517b51998-10-11 13:06:35 +0000357 rc.right-rc.left, rc.bottom-rc.top, 0xFA0089);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000358 SelectObject (hdc, hbr);
Eric Kohl8e517b51998-10-11 13:06:35 +0000359 }
360 }
361 else {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000362 FillRect (hdc, &rc, GetSysColorBrush ((uFlags & DC_ACTIVE) ?
Eric Kohl8e517b51998-10-11 13:06:35 +0000363 COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION));
364 }
365
366
367 /* drawing icon */
368 if ((uFlags & DC_ICON) && !(uFlags & DC_SMALLCAP)) {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000369 POINT pt;
Eric Kohl8e517b51998-10-11 13:06:35 +0000370
371 pt.x = rc.left + 2;
Marcus Meissnerddca3151999-05-22 11:33:23 +0000372 pt.y = (rc.bottom + rc.top - GetSystemMetrics(SM_CYSMICON)) / 2;
Eric Kohl8e517b51998-10-11 13:06:35 +0000373
374 if (hIcon) {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000375 DrawIconEx (hdc, pt.x, pt.y, hIcon, GetSystemMetrics(SM_CXSMICON),
376 GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL);
Eric Kohl8e517b51998-10-11 13:06:35 +0000377 }
378 else {
Susan Farley9ce83822000-05-23 04:12:23 +0000379 WND* wndPtr = WIN_FindWndPtr(hwnd);
380 HICON hAppIcon = (HICON) NC_IconForWindow(wndPtr);
Marcus Meissnerddca3151999-05-22 11:33:23 +0000381 DrawIconEx (hdc, pt.x, pt.y, hAppIcon, GetSystemMetrics(SM_CXSMICON),
382 GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL);
Susan Farley9ce83822000-05-23 04:12:23 +0000383 WIN_ReleaseWndPtr(wndPtr);
Eric Kohl8e517b51998-10-11 13:06:35 +0000384 }
385
386 rc.left += (rc.bottom - rc.top);
387 }
388
389 /* drawing text */
390 if (uFlags & DC_TEXT) {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000391 HFONT hOldFont;
Eric Kohl8e517b51998-10-11 13:06:35 +0000392
393 if (uFlags & DC_INBUTTON)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000394 SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
Eric Kohl8e517b51998-10-11 13:06:35 +0000395 else if (uFlags & DC_ACTIVE)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000396 SetTextColor (hdc, GetSysColor (COLOR_CAPTIONTEXT));
Eric Kohl8e517b51998-10-11 13:06:35 +0000397 else
Alexandre Julliarda3960291999-02-26 11:11:13 +0000398 SetTextColor (hdc, GetSysColor (COLOR_INACTIVECAPTIONTEXT));
Eric Kohl8e517b51998-10-11 13:06:35 +0000399
Alexandre Julliarda3960291999-02-26 11:11:13 +0000400 SetBkMode (hdc, TRANSPARENT);
Eric Kohl8e517b51998-10-11 13:06:35 +0000401
402 if (hFont)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000403 hOldFont = SelectObject (hdc, hFont);
Eric Kohl8e517b51998-10-11 13:06:35 +0000404 else {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000405 NONCLIENTMETRICSA nclm;
406 HFONT hNewFont;
407 nclm.cbSize = sizeof(NONCLIENTMETRICSA);
408 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
409 hNewFont = CreateFontIndirectA ((uFlags & DC_SMALLCAP) ?
Eric Kohl8e517b51998-10-11 13:06:35 +0000410 &nclm.lfSmCaptionFont : &nclm.lfCaptionFont);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000411 hOldFont = SelectObject (hdc, hNewFont);
Eric Kohl8e517b51998-10-11 13:06:35 +0000412 }
413
414 if (str)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000415 DrawTextA (hdc, str, -1, &rc,
Eric Kohl8e517b51998-10-11 13:06:35 +0000416 DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT);
417 else {
418 CHAR szText[128];
Alexandre Julliarda3960291999-02-26 11:11:13 +0000419 INT nLen;
420 nLen = GetWindowTextA (hwnd, szText, 128);
421 DrawTextA (hdc, szText, nLen, &rc,
Eric Kohl8e517b51998-10-11 13:06:35 +0000422 DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT);
423 }
424
425 if (hFont)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000426 SelectObject (hdc, hOldFont);
Eric Kohl8e517b51998-10-11 13:06:35 +0000427 else
Alexandre Julliarda3960291999-02-26 11:11:13 +0000428 DeleteObject (SelectObject (hdc, hOldFont));
Eric Kohl8e517b51998-10-11 13:06:35 +0000429 }
430
431 /* drawing focus ??? */
432 if (uFlags & 0x2000)
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +0000433 FIXME("undocumented flag (0x2000)!\n");
Eric Kohl8e517b51998-10-11 13:06:35 +0000434
435 return 0;
436}
437
438
439/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000440 * DrawCaptionTempW [USER32.602]
Eric Kohl8e517b51998-10-11 13:06:35 +0000441 *
Eric Kohld0b79c01998-10-24 10:45:42 +0000442 * PARAMS
443 *
444 * RETURNS
445 * Success:
446 * Failure:
Eric Kohl8e517b51998-10-11 13:06:35 +0000447 */
448
Alexandre Julliarda3960291999-02-26 11:11:13 +0000449BOOL WINAPI
450DrawCaptionTempW (HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont,
451 HICON hIcon, LPCWSTR str, UINT uFlags)
Eric Kohl8e517b51998-10-11 13:06:35 +0000452{
453 LPSTR p = HEAP_strdupWtoA (GetProcessHeap (), 0, str);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000454 BOOL res = DrawCaptionTempA (hwnd, hdc, rect, hFont, hIcon, p, uFlags);
Eric Kohl8e517b51998-10-11 13:06:35 +0000455 HeapFree (GetProcessHeap (), 0, p);
456 return res;
457}
458
459
460/***********************************************************************
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000461 * AdjustWindowRect16 (USER.102)
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000462 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000463BOOL16 WINAPI AdjustWindowRect16( LPRECT16 rect, DWORD style, BOOL16 menu )
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000464{
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000465 return AdjustWindowRectEx16( rect, style, menu, 0 );
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000466}
467
468
469/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000470 * AdjustWindowRect (USER32.2)
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000471 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000472BOOL WINAPI AdjustWindowRect( LPRECT rect, DWORD style, BOOL menu )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000473{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000474 return AdjustWindowRectEx( rect, style, menu, 0 );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000475}
476
477
478/***********************************************************************
479 * AdjustWindowRectEx16 (USER.454)
480 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000481BOOL16 WINAPI AdjustWindowRectEx16( LPRECT16 rect, DWORD style,
482 BOOL16 menu, DWORD exStyle )
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000483{
484 /* Correct the window style */
485
486 if (!(style & (WS_POPUP | WS_CHILD))) /* Overlapped window */
487 style |= WS_CAPTION;
Alexandre Julliard84c70f51997-05-09 08:40:27 +0000488 style &= (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME | WS_CHILD);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000489 exStyle &= (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE |
490 WS_EX_STATICEDGE | WS_EX_TOOLWINDOW);
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000491 if (exStyle & WS_EX_DLGMODALFRAME) style &= ~WS_THICKFRAME;
492
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +0000493 TRACE("(%d,%d)-(%d,%d) %08lx %d %08lx\n",
494 rect->left, rect->top, rect->right, rect->bottom,
495 style, menu, exStyle );
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000496
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000497 if (TWEAK_WineLook == WIN31_LOOK)
498 NC_AdjustRect( rect, style, menu, exStyle );
499 else {
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000500 NC_AdjustRectOuter95( rect, style, menu, exStyle );
501 NC_AdjustRectInner95( rect, style, exStyle );
502 }
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000503
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000504 return TRUE;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000505}
506
507
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000508/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000509 * AdjustWindowRectEx (USER32.3)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000510 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000511BOOL WINAPI AdjustWindowRectEx( LPRECT rect, DWORD style,
512 BOOL menu, DWORD exStyle )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000513{
514 RECT16 rect16;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000515 BOOL ret;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000516
517 CONV_RECT32TO16( rect, &rect16 );
518 ret = AdjustWindowRectEx16( &rect16, style, (BOOL16)menu, exStyle );
519 CONV_RECT16TO32( &rect16, rect );
520 return ret;
521}
522
523
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000524/***********************************************************************
525 * NC_HandleNCCalcSize
526 *
527 * Handle a WM_NCCALCSIZE message. Called from DefWindowProc().
528 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000529LONG NC_HandleNCCalcSize( WND *pWnd, RECT *winRect )
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000530{
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000531 RECT16 tmpRect = { 0, 0, 0, 0 };
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +0000532 LONG result = 0;
Gerard Patel5773dad1999-06-12 14:45:56 +0000533 UINT style = (UINT) GetClassLongA(pWnd->hwndSelf, GCL_STYLE);
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +0000534
Gerard Patel5773dad1999-06-12 14:45:56 +0000535 if (style & CS_VREDRAW) result |= WVR_VREDRAW;
536 if (style & CS_HREDRAW) result |= WVR_HREDRAW;
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000537
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000538 if( !( pWnd->dwStyle & WS_MINIMIZE ) ) {
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000539 if (TWEAK_WineLook == WIN31_LOOK)
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000540 NC_AdjustRect( &tmpRect, pWnd->dwStyle, FALSE, pWnd->dwExStyle );
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000541 else
542 NC_AdjustRectOuter95( &tmpRect, pWnd->dwStyle, FALSE, pWnd->dwExStyle );
Alexandre Julliard1e37a181996-08-18 16:21:52 +0000543
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000544 winRect->left -= tmpRect.left;
545 winRect->top -= tmpRect.top;
546 winRect->right -= tmpRect.right;
547 winRect->bottom -= tmpRect.bottom;
548
549 if (HAS_MENU(pWnd)) {
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +0000550 TRACE("Calling GetMenuBarHeight with HWND 0x%x, width %d, "
551 "at (%d, %d).\n", pWnd->hwndSelf,
552 winRect->right - winRect->left,
553 -tmpRect.left, -tmpRect.top );
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000554
555 winRect->top +=
556 MENU_GetMenuBarHeight( pWnd->hwndSelf,
557 winRect->right - winRect->left,
558 -tmpRect.left, -tmpRect.top ) + 1;
559 }
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000560
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000561 if (TWEAK_WineLook > WIN31_LOOK) {
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000562 SetRect16 (&tmpRect, 0, 0, 0, 0);
563 NC_AdjustRectInner95 (&tmpRect, pWnd->dwStyle, pWnd->dwExStyle);
564 winRect->left -= tmpRect.left;
565 winRect->top -= tmpRect.top;
566 winRect->right -= tmpRect.right;
567 winRect->bottom -= tmpRect.bottom;
568 }
Mike McCormacka2bdade2000-09-12 23:37:57 +0000569
570 if (winRect->top > winRect->bottom)
571 winRect->bottom = winRect->top;
572
573 if (winRect->left > winRect->right)
574 winRect->right = winRect->left;
Alexandre Julliard2d159fb1994-07-15 16:04:31 +0000575 }
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +0000576 return result;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000577}
578
579
580/***********************************************************************
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000581 * NC_GetInsideRect
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000582 *
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000583 * Get the 'inside' rectangle of a window, i.e. the whole window rectangle
584 * but without the borders (if any).
585 * The rectangle is in window coordinates (for drawing with GetWindowDC()).
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000586 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000587static void NC_GetInsideRect( HWND hwnd, RECT *rect )
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000588{
589 WND * wndPtr = WIN_FindWndPtr( hwnd );
590
591 rect->top = rect->left = 0;
592 rect->right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
593 rect->bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
594
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000595 if ((wndPtr->dwStyle & WS_ICONIC) || (wndPtr->flags & WIN_MANAGED)) goto END;
Alexandre Julliard3ed37e01994-11-07 18:20:42 +0000596
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000597 /* Remove frame from rectangle */
Ove Kaaven60c78f11999-07-03 15:40:29 +0000598 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
599 InflateRect( rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) );
600 else
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000601 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000602 {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000603 InflateRect( rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
Ove Kaaven60c78f11999-07-03 15:40:29 +0000604 /* FIXME: this isn't in NC_AdjustRect? why not? */
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000605 if (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000606 InflateRect( rect, -1, 0 );
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000607 }
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000608 else
Ove Kaaven60c78f11999-07-03 15:40:29 +0000609 if (HAS_THINFRAME( wndPtr->dwStyle ))
610 InflateRect( rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER) );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000611END:
612 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000613 return;
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000614}
615
616
617/***********************************************************************
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000618 * NC_GetInsideRect95
619 *
620 * Get the 'inside' rectangle of a window, i.e. the whole window rectangle
621 * but without the borders (if any).
622 * The rectangle is in window coordinates (for drawing with GetWindowDC()).
623 */
624
625static void
Alexandre Julliarda3960291999-02-26 11:11:13 +0000626NC_GetInsideRect95 (HWND hwnd, RECT *rect)
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000627{
628 WND * wndPtr = WIN_FindWndPtr( hwnd );
629
630 rect->top = rect->left = 0;
631 rect->right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
632 rect->bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
633
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000634 if ((wndPtr->dwStyle & WS_ICONIC) || (wndPtr->flags & WIN_MANAGED)) goto END;
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000635
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000636 /* Remove frame from rectangle */
Ove Kaaven60c78f11999-07-03 15:40:29 +0000637 if (HAS_THICKFRAME (wndPtr->dwStyle, wndPtr->dwExStyle))
638 {
639 InflateRect( rect, -GetSystemMetrics(SM_CXSIZEFRAME), -GetSystemMetrics(SM_CYSIZEFRAME) );
640 }
641 else if (HAS_DLGFRAME (wndPtr->dwStyle, wndPtr->dwExStyle ))
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000642 {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000643 InflateRect( rect, -GetSystemMetrics(SM_CXFIXEDFRAME), -GetSystemMetrics(SM_CYFIXEDFRAME));
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000644 }
Ove Kaaven60c78f11999-07-03 15:40:29 +0000645 else if (HAS_THINFRAME (wndPtr->dwStyle))
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000646 {
Ove Kaaven60c78f11999-07-03 15:40:29 +0000647 InflateRect( rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER) );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000648 }
649
Francis Beaudet1cc0a9a1999-09-03 15:00:45 +0000650 /* We have additional border information if the window
651 * is a child (but not an MDI child) */
652 if ( (wndPtr->dwStyle & WS_CHILD) &&
653 ( (wndPtr->dwExStyle & WS_EX_MDICHILD) == 0 ) )
654 {
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000655 if (wndPtr->dwExStyle & WS_EX_CLIENTEDGE)
Marcus Meissnerddca3151999-05-22 11:33:23 +0000656 InflateRect (rect, -GetSystemMetrics(SM_CXEDGE), -GetSystemMetrics(SM_CYEDGE));
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000657
658 if (wndPtr->dwExStyle & WS_EX_STATICEDGE)
Marcus Meissnerddca3151999-05-22 11:33:23 +0000659 InflateRect (rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000660 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000661END:
662 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000663 return;
664}
665
666
667/***********************************************************************
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000668 * NC_DoNCHitTest
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000669 *
Andreas Mohr260f1a12000-09-22 20:59:29 +0000670 * Handle a WM_NCHITTEST message. Called from NC_HandleNCHitTest().
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000671 */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000672
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000673static LONG NC_DoNCHitTest (WND *wndPtr, POINT pt )
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000674{
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000675 RECT rect;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000676
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000677 TRACE("hwnd=%04x pt=%ld,%ld\n", wndPtr->hwndSelf, pt.x, pt.y );
Alexandre Julliard940d58c1994-09-16 09:24:37 +0000678
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000679 GetWindowRect(wndPtr->hwndSelf, &rect );
680 if (!PtInRect( &rect, pt )) return HTNOWHERE;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000681
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000682 if (wndPtr->dwStyle & WS_MINIMIZE) return HTCAPTION;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000683
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000684 if (!(wndPtr->flags & WIN_MANAGED))
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000685 {
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000686 /* Check borders */
Ove Kaaven60c78f11999-07-03 15:40:29 +0000687 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000688 {
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000689 InflateRect( &rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) );
690 if (!PtInRect( &rect, pt ))
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000691 {
692 /* Check top sizing border */
693 if (pt.y < rect.top)
694 {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000695 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTTOPLEFT;
696 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTTOPRIGHT;
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000697 return HTTOP;
698 }
699 /* Check bottom sizing border */
700 if (pt.y >= rect.bottom)
701 {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000702 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMLEFT;
703 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMRIGHT;
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000704 return HTBOTTOM;
705 }
706 /* Check left sizing border */
707 if (pt.x < rect.left)
708 {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000709 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPLEFT;
710 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMLEFT;
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000711 return HTLEFT;
712 }
713 /* Check right sizing border */
714 if (pt.x >= rect.right)
715 {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000716 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPRIGHT;
717 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMRIGHT;
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000718 return HTRIGHT;
719 }
720 }
721 }
722 else /* No thick frame */
723 {
724 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000725 InflateRect(&rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
Ove Kaaven60c78f11999-07-03 15:40:29 +0000726 else if (HAS_THINFRAME( wndPtr->dwStyle ))
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000727 InflateRect(&rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
728 if (!PtInRect( &rect, pt )) return HTBORDER;
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000729 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000730
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000731 /* Check caption */
Alexandre Julliardf7207251994-07-23 07:57:48 +0000732
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000733 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
734 {
Ove Kaaven60c78f11999-07-03 15:40:29 +0000735 rect.top += GetSystemMetrics(SM_CYCAPTION) - GetSystemMetrics(SM_CYBORDER);
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000736 if (!PtInRect( &rect, pt ))
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000737 {
738 /* Check system menu */
Francois Methotbd1908f2000-08-28 21:31:23 +0000739 if ((wndPtr->dwStyle & WS_SYSMENU) && !(wndPtr->dwExStyle & WS_EX_TOOLWINDOW))
Marcus Meissnerddca3151999-05-22 11:33:23 +0000740 rect.left += GetSystemMetrics(SM_CXSIZE);
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000741 if (pt.x <= rect.left) return HTSYSMENU;
Pascal Lessardd814bb61999-07-31 13:02:02 +0000742
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000743 /* Check maximize box */
744 if (wndPtr->dwStyle & WS_MAXIMIZEBOX)
Marcus Meissnerddca3151999-05-22 11:33:23 +0000745 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
Pascal Lessardd814bb61999-07-31 13:02:02 +0000746
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000747 if (pt.x >= rect.right) return HTMAXBUTTON;
748 /* Check minimize box */
749 if (wndPtr->dwStyle & WS_MINIMIZEBOX)
Marcus Meissnerddca3151999-05-22 11:33:23 +0000750 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000751 if (pt.x >= rect.right) return HTMINBUTTON;
752 return HTCAPTION;
753 }
754 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000755 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000756
Alexandre Julliardf7207251994-07-23 07:57:48 +0000757 /* Check client area */
758
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000759 ScreenToClient( wndPtr->hwndSelf, &pt );
760 GetClientRect( wndPtr->hwndSelf, &rect );
761 if (PtInRect( &rect, pt )) return HTCLIENT;
Alexandre Julliardf7207251994-07-23 07:57:48 +0000762
763 /* Check vertical scroll bar */
764
765 if (wndPtr->dwStyle & WS_VSCROLL)
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000766 {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000767 rect.right += GetSystemMetrics(SM_CXVSCROLL);
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000768 if (PtInRect( &rect, pt )) return HTVSCROLL;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000769 }
770
Alexandre Julliardf7207251994-07-23 07:57:48 +0000771 /* Check horizontal scroll bar */
772
773 if (wndPtr->dwStyle & WS_HSCROLL)
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000774 {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000775 rect.bottom += GetSystemMetrics(SM_CYHSCROLL);
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000776 if (PtInRect( &rect, pt ))
Alexandre Julliardf7207251994-07-23 07:57:48 +0000777 {
778 /* Check size box */
779 if ((wndPtr->dwStyle & WS_VSCROLL) &&
Marcus Meissnerddca3151999-05-22 11:33:23 +0000780 (pt.x >= rect.right - GetSystemMetrics(SM_CXVSCROLL)))
Alexandre Julliardf7207251994-07-23 07:57:48 +0000781 return HTSIZE;
782 return HTHSCROLL;
783 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000784 }
785
Alexandre Julliardf7207251994-07-23 07:57:48 +0000786 /* Check menu bar */
787
788 if (HAS_MENU(wndPtr))
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000789 {
Alexandre Julliardf7207251994-07-23 07:57:48 +0000790 if ((pt.y < 0) && (pt.x >= 0) && (pt.x < rect.right))
791 return HTMENU;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000792 }
793
Francois Boisvert5538ec42000-07-29 00:00:29 +0000794 /* Has to return HTNOWHERE if nothing was found
795 Could happen when a window has a customized non client area */
796 return HTNOWHERE;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000797}
798
799
800/***********************************************************************
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000801 * NC_DoNCHitTest95
802 *
803 * Handle a WM_NCHITTEST message. Called from NC_HandleNCHitTest().
804 *
Alexandre Julliard829fe321998-07-26 14:27:39 +0000805 * FIXME: Just a modified copy of the Win 3.1 version.
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000806 */
807
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000808static LONG NC_DoNCHitTest95 (WND *wndPtr, POINT pt )
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000809{
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000810 RECT rect;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000811
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000812 TRACE("hwnd=%04x pt=%ld,%ld\n", wndPtr->hwndSelf, pt.x, pt.y );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000813
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000814 GetWindowRect(wndPtr->hwndSelf, &rect );
815 if (!PtInRect( &rect, pt )) return HTNOWHERE;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000816
817 if (wndPtr->dwStyle & WS_MINIMIZE) return HTCAPTION;
818
819 if (!(wndPtr->flags & WIN_MANAGED))
820 {
821 /* Check borders */
Ove Kaaven60c78f11999-07-03 15:40:29 +0000822 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000823 {
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000824 InflateRect( &rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) );
825 if (!PtInRect( &rect, pt ))
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000826 {
827 /* Check top sizing border */
828 if (pt.y < rect.top)
829 {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000830 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTTOPLEFT;
831 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTTOPRIGHT;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000832 return HTTOP;
833 }
834 /* Check bottom sizing border */
835 if (pt.y >= rect.bottom)
836 {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000837 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMLEFT;
838 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMRIGHT;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000839 return HTBOTTOM;
840 }
841 /* Check left sizing border */
842 if (pt.x < rect.left)
843 {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000844 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPLEFT;
845 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMLEFT;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000846 return HTLEFT;
847 }
848 /* Check right sizing border */
849 if (pt.x >= rect.right)
850 {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000851 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPRIGHT;
852 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMRIGHT;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000853 return HTRIGHT;
854 }
855 }
856 }
857 else /* No thick frame */
858 {
Ove Kaaven60c78f11999-07-03 15:40:29 +0000859 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000860 InflateRect(&rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
Ove Kaaven60c78f11999-07-03 15:40:29 +0000861 else if (HAS_THINFRAME( wndPtr->dwStyle ))
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000862 InflateRect(&rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
863 if (!PtInRect( &rect, pt )) return HTBORDER;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000864 }
865
866 /* Check caption */
867
868 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
869 {
870 if (wndPtr->dwExStyle & WS_EX_TOOLWINDOW)
Marcus Meissnerddca3151999-05-22 11:33:23 +0000871 rect.top += GetSystemMetrics(SM_CYSMCAPTION) - 1;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000872 else
Marcus Meissnerddca3151999-05-22 11:33:23 +0000873 rect.top += GetSystemMetrics(SM_CYCAPTION) - 1;
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000874 if (!PtInRect( &rect, pt ))
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000875 {
876 /* Check system menu */
Francois Methotbd1908f2000-08-28 21:31:23 +0000877 if ((wndPtr->dwStyle & WS_SYSMENU) && !(wndPtr->dwExStyle & WS_EX_TOOLWINDOW))
Pascal Lessardecbf1d91999-08-21 13:09:16 +0000878 {
Susan Farley9ce83822000-05-23 04:12:23 +0000879 if (NC_IconForWindow(wndPtr))
Pascal Lessardecbf1d91999-08-21 13:09:16 +0000880 rect.left += GetSystemMetrics(SM_CYCAPTION) - 1;
881 }
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000882 if (pt.x < rect.left) return HTSYSMENU;
883
884 /* Check close button */
885 if (wndPtr->dwStyle & WS_SYSMENU)
Marcus Meissnerddca3151999-05-22 11:33:23 +0000886 rect.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000887 if (pt.x > rect.right) return HTCLOSE;
888
889 /* Check maximize box */
Pascal Lessardd814bb61999-07-31 13:02:02 +0000890 /* In win95 there is automatically a Maximize button when there is a minimize one*/
891 if ((wndPtr->dwStyle & WS_MAXIMIZEBOX)|| (wndPtr->dwStyle & WS_MINIMIZEBOX))
Marcus Meissnerddca3151999-05-22 11:33:23 +0000892 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000893 if (pt.x > rect.right) return HTMAXBUTTON;
894
895 /* Check minimize box */
Pascal Lessardd814bb61999-07-31 13:02:02 +0000896 /* In win95 there is automatically a Maximize button when there is a Maximize one*/
897 if ((wndPtr->dwStyle & WS_MINIMIZEBOX)||(wndPtr->dwStyle & WS_MAXIMIZEBOX))
Marcus Meissnerddca3151999-05-22 11:33:23 +0000898 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
Pascal Lessardd814bb61999-07-31 13:02:02 +0000899
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000900 if (pt.x > rect.right) return HTMINBUTTON;
901 return HTCAPTION;
902 }
903 }
904 }
905
906 /* Check client area */
907
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000908 ScreenToClient( wndPtr->hwndSelf, &pt );
909 GetClientRect( wndPtr->hwndSelf, &rect );
910 if (PtInRect( &rect, pt )) return HTCLIENT;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000911
912 /* Check vertical scroll bar */
913
914 if (wndPtr->dwStyle & WS_VSCROLL)
915 {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000916 rect.right += GetSystemMetrics(SM_CXVSCROLL);
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000917 if (PtInRect( &rect, pt )) return HTVSCROLL;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000918 }
919
920 /* Check horizontal scroll bar */
921
922 if (wndPtr->dwStyle & WS_HSCROLL)
923 {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000924 rect.bottom += GetSystemMetrics(SM_CYHSCROLL);
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000925 if (PtInRect( &rect, pt ))
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000926 {
927 /* Check size box */
928 if ((wndPtr->dwStyle & WS_VSCROLL) &&
Marcus Meissnerddca3151999-05-22 11:33:23 +0000929 (pt.x >= rect.right - GetSystemMetrics(SM_CXVSCROLL)))
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000930 return HTSIZE;
931 return HTHSCROLL;
932 }
933 }
934
935 /* Check menu bar */
936
937 if (HAS_MENU(wndPtr))
938 {
939 if ((pt.y < 0) && (pt.x >= 0) && (pt.x < rect.right))
940 return HTMENU;
941 }
942
Francois Boisvert5538ec42000-07-29 00:00:29 +0000943 /* Has to return HTNOWHERE if nothing was found
944 Could happen when a window has a customized non client area */
945 return HTNOWHERE;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000946}
947
948
949/***********************************************************************
950 * NC_HandleNCHitTest
951 *
952 * Handle a WM_NCHITTEST message. Called from DefWindowProc().
953 */
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000954LONG NC_HandleNCHitTest (HWND hwnd , POINT pt)
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000955{
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000956 LONG retvalue;
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000957 WND *wndPtr = WIN_FindWndPtr (hwnd);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000958
959 if (!wndPtr)
960 return HTERROR;
961
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000962 if (TWEAK_WineLook == WIN31_LOOK)
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000963 retvalue = NC_DoNCHitTest (wndPtr, pt);
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000964 else
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000965 retvalue = NC_DoNCHitTest95 (wndPtr, pt);
966 WIN_ReleaseWndPtr(wndPtr);
967 return retvalue;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000968}
969
970
971/***********************************************************************
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000972 * NC_DrawSysButton
973 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000974void NC_DrawSysButton( HWND hwnd, HDC hdc, BOOL down )
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000975{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000976 RECT rect;
977 HDC hdcMem;
978 HBITMAP hbitmap;
Alexandre Julliard1f579291994-05-25 16:25:21 +0000979 WND *wndPtr = WIN_FindWndPtr( hwnd );
Alexandre Julliard7cbe6571995-01-09 18:21:16 +0000980
Alexandre Julliard1e37a181996-08-18 16:21:52 +0000981 if( !(wndPtr->flags & WIN_MANAGED) )
982 {
983 NC_GetInsideRect( hwnd, &rect );
Alexandre Julliarda3960291999-02-26 11:11:13 +0000984 hdcMem = CreateCompatibleDC( hdc );
985 hbitmap = SelectObject( hdcMem, hbitmapClose );
Marcus Meissnerddca3151999-05-22 11:33:23 +0000986 BitBlt(hdc, rect.left, rect.top, GetSystemMetrics(SM_CXSIZE), GetSystemMetrics(SM_CYSIZE),
987 hdcMem, (wndPtr->dwStyle & WS_CHILD) ? GetSystemMetrics(SM_CXSIZE) : 0, 0,
Alexandre Julliardf0a0e121999-02-19 16:02:32 +0000988 down ? NOTSRCCOPY : SRCCOPY );
Alexandre Julliarda3960291999-02-26 11:11:13 +0000989 SelectObject( hdcMem, hbitmap );
990 DeleteDC( hdcMem );
Alexandre Julliard1e37a181996-08-18 16:21:52 +0000991 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000992 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000993}
994
995
996/***********************************************************************
997 * NC_DrawMaxButton
998 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000999static void NC_DrawMaxButton( HWND hwnd, HDC16 hdc, BOOL down )
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001000{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001001 RECT rect;
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001002 WND *wndPtr = WIN_FindWndPtr( hwnd );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001003 HDC hdcMem;
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001004
1005 if( !(wndPtr->flags & WIN_MANAGED) )
1006 {
1007 NC_GetInsideRect( hwnd, &rect );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001008 hdcMem = CreateCompatibleDC( hdc );
1009 SelectObject( hdcMem, (IsZoomed(hwnd)
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001010 ? (down ? hbitmapRestoreD : hbitmapRestore)
Huw D M Davies2d617be1998-12-08 09:14:09 +00001011 : (down ? hbitmapMaximizeD : hbitmapMaximize)) );
Marcus Meissnerddca3151999-05-22 11:33:23 +00001012 BitBlt( hdc, rect.right - GetSystemMetrics(SM_CXSIZE) - 1, rect.top,
1013 GetSystemMetrics(SM_CXSIZE) + 1, GetSystemMetrics(SM_CYSIZE), hdcMem, 0, 0,
Huw D M Davies2d617be1998-12-08 09:14:09 +00001014 SRCCOPY );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001015 DeleteDC( hdcMem );
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001016 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001017 WIN_ReleaseWndPtr(wndPtr);
1018
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001019}
1020
1021
1022/***********************************************************************
1023 * NC_DrawMinButton
1024 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001025static void NC_DrawMinButton( HWND hwnd, HDC16 hdc, BOOL down )
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001026{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001027 RECT rect;
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001028 WND *wndPtr = WIN_FindWndPtr( hwnd );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001029 HDC hdcMem;
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001030
1031 if( !(wndPtr->flags & WIN_MANAGED) )
1032 {
1033 NC_GetInsideRect( hwnd, &rect );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001034 hdcMem = CreateCompatibleDC( hdc );
1035 SelectObject( hdcMem, (down ? hbitmapMinimizeD : hbitmapMinimize) );
Marcus Meissnerddca3151999-05-22 11:33:23 +00001036 if (wndPtr->dwStyle & WS_MAXIMIZEBOX) rect.right -= GetSystemMetrics(SM_CXSIZE)+1;
1037 BitBlt( hdc, rect.right - GetSystemMetrics(SM_CXSIZE) - 1, rect.top,
1038 GetSystemMetrics(SM_CXSIZE) + 1, GetSystemMetrics(SM_CYSIZE), hdcMem, 0, 0,
Huw D M Davies2d617be1998-12-08 09:14:09 +00001039 SRCCOPY );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001040 DeleteDC( hdcMem );
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001041 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001042 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001043}
1044
1045
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001046/******************************************************************************
1047 *
1048 * void NC_DrawSysButton95(
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001049 * HWND hwnd,
1050 * HDC hdc,
1051 * BOOL down )
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001052 *
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001053 * Draws the Win95 system icon.
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001054 *
1055 * Revision history
1056 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1057 * Original implementation from NC_DrawSysButton source.
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001058 * 11-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1059 * Fixed most bugs.
1060 *
1061 *****************************************************************************/
1062
Alexandre Julliarda3960291999-02-26 11:11:13 +00001063BOOL
1064NC_DrawSysButton95 (HWND hwnd, HDC hdc, BOOL down)
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001065{
1066 WND *wndPtr = WIN_FindWndPtr( hwnd );
1067
1068 if( !(wndPtr->flags & WIN_MANAGED) )
1069 {
Gerard Patel5773dad1999-06-12 14:45:56 +00001070 HICON hIcon;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001071 RECT rect;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001072
1073 NC_GetInsideRect95( hwnd, &rect );
1074
Susan Farley9ce83822000-05-23 04:12:23 +00001075 hIcon = NC_IconForWindow( wndPtr );
Thuy Nguyen46570a91999-08-07 12:25:32 +00001076
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001077 if (hIcon)
Alexandre Julliarda3960291999-02-26 11:11:13 +00001078 DrawIconEx (hdc, rect.left + 2, rect.top + 2, hIcon,
Marcus Meissnerddca3151999-05-22 11:33:23 +00001079 GetSystemMetrics(SM_CXSMICON),
1080 GetSystemMetrics(SM_CYSMICON),
Alexandre Julliard829fe321998-07-26 14:27:39 +00001081 0, 0, DI_NORMAL);
1082
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001083 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001084 return (hIcon != 0);
1085 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001086 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001087 return FALSE;
1088}
1089
1090
1091/******************************************************************************
1092 *
1093 * void NC_DrawCloseButton95(
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001094 * HWND hwnd,
1095 * HDC hdc,
1096 * BOOL down,
Pascal Lessardd814bb61999-07-31 13:02:02 +00001097 * BOOL bGrayed )
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001098 *
1099 * Draws the Win95 close button.
1100 *
Pascal Lessardd814bb61999-07-31 13:02:02 +00001101 * If bGrayed is true, then draw a disabled Close button
1102 *
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001103 * Revision history
1104 * 11-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1105 * Original implementation from NC_DrawSysButton95 source.
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001106 *
1107 *****************************************************************************/
1108
Pascal Lessardd814bb61999-07-31 13:02:02 +00001109static void NC_DrawCloseButton95 (HWND hwnd, HDC hdc, BOOL down, BOOL bGrayed)
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001110{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001111 RECT rect;
1112 HDC hdcMem;
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001113 WND *wndPtr = WIN_FindWndPtr( hwnd );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001114
1115 if( !(wndPtr->flags & WIN_MANAGED) )
1116 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001117 BITMAP bmp;
1118 HBITMAP hBmp, hOldBmp;
Alexandre Julliardf90efa91998-06-14 15:24:15 +00001119
1120 NC_GetInsideRect95( hwnd, &rect );
Alexandre Julliardf90efa91998-06-14 15:24:15 +00001121
Alexandre Julliard16e92372000-05-18 00:12:23 +00001122 /* A tool window has a smaller Close button */
1123 if(wndPtr->dwExStyle & WS_EX_TOOLWINDOW)
1124 {
1125 RECT toolRect;
1126 INT iBmpHeight = 11; /* Windows does not use SM_CXSMSIZE and SM_CYSMSIZE */
1127 INT iBmpWidth = 11; /* it uses 11x11 for the close button in tool window */
1128 INT iCaptionHeight = GetSystemMetrics(SM_CYSMCAPTION);
Pascal Lessardd814bb61999-07-31 13:02:02 +00001129
Alexandre Julliard16e92372000-05-18 00:12:23 +00001130 toolRect.top = rect.top + (iCaptionHeight - 1 - iBmpHeight) / 2;
1131 toolRect.left = rect.right - (iCaptionHeight + 1 + iBmpWidth) / 2;
1132 toolRect.bottom = toolRect.top + iBmpHeight;
1133 toolRect.right = toolRect.left + iBmpWidth;
1134 DrawFrameControl(hdc,&toolRect,
1135 DFC_CAPTION,DFCS_CAPTIONCLOSE |
1136 down ? DFCS_PUSHED : 0 |
1137 bGrayed ? DFCS_INACTIVE : 0);
1138 }
1139 else
1140 {
1141 hdcMem = CreateCompatibleDC( hdc );
1142 hBmp = down ? hbitmapCloseD : hbitmapClose;
1143 hOldBmp = SelectObject (hdcMem, hBmp);
1144 GetObjectA (hBmp, sizeof(BITMAP), &bmp);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001145
Alexandre Julliard16e92372000-05-18 00:12:23 +00001146 BitBlt (hdc, rect.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2,
1147 rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
1148 bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY);
Pascal Lessardd814bb61999-07-31 13:02:02 +00001149
Alexandre Julliard16e92372000-05-18 00:12:23 +00001150 if(bGrayed)
1151 NC_DrawGrayButton(hdc,rect.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2 + 2,
1152 rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
1153
1154 SelectObject (hdcMem, hOldBmp);
1155 DeleteDC (hdcMem);
1156 }
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001157 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001158 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001159}
1160
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001161/******************************************************************************
1162 *
1163 * NC_DrawMaxButton95(
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001164 * HWND hwnd,
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001165 * HDC16 hdc,
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001166 * BOOL down
Pascal Lessardd814bb61999-07-31 13:02:02 +00001167 * BOOL bGrayed )
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001168 *
1169 * Draws the maximize button for Win95 style windows.
1170 *
Pascal Lessardd814bb61999-07-31 13:02:02 +00001171 * If bGrayed is true, then draw a disabled Maximize button
1172 *
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001173 * Bugs
1174 * Many. Spacing might still be incorrect. Need to fit a close
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001175 * button between the max button and the edge.
1176 * Should scale the image with the title bar. And more...
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001177 *
1178 * Revision history
1179 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1180 * Original implementation.
1181 *
1182 *****************************************************************************/
1183
Pascal Lessardd814bb61999-07-31 13:02:02 +00001184static void NC_DrawMaxButton95(HWND hwnd,HDC16 hdc,BOOL down, BOOL bGrayed)
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001185{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001186 RECT rect;
1187 HDC hdcMem;
Noomen Hamzabfd02281999-01-20 14:03:49 +00001188 WND *wndPtr = WIN_FindWndPtr( hwnd );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001189
Noomen Hamzabfd02281999-01-20 14:03:49 +00001190 if( !(wndPtr->flags & WIN_MANAGED))
1191 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001192 BITMAP bmp;
1193 HBITMAP hBmp,hOldBmp;
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001194
Alexandre Julliardf90efa91998-06-14 15:24:15 +00001195 NC_GetInsideRect95( hwnd, &rect );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001196 hdcMem = CreateCompatibleDC( hdc );
Pascal Lessardd814bb61999-07-31 13:02:02 +00001197 hBmp = IsZoomed(hwnd) ?
1198 (down ? hbitmapRestoreD : hbitmapRestore ) :
1199 (down ? hbitmapMaximizeD: hbitmapMaximize);
Alexandre Julliarda3960291999-02-26 11:11:13 +00001200 hOldBmp=SelectObject( hdcMem, hBmp );
1201 GetObjectA (hBmp, sizeof(BITMAP), &bmp);
Pascal Lessardd814bb61999-07-31 13:02:02 +00001202
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001203 if (wndPtr->dwStyle & WS_SYSMENU)
Marcus Meissnerddca3151999-05-22 11:33:23 +00001204 rect.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001205
Marcus Meissnerddca3151999-05-22 11:33:23 +00001206 BitBlt( hdc, rect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
1207 rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
Noomen Hamzabfd02281999-01-20 14:03:49 +00001208 bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY );
Pascal Lessardd814bb61999-07-31 13:02:02 +00001209
1210 if(bGrayed)
1211 NC_DrawGrayButton(hdc, rect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2 + 2,
1212 rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
1213
1214
Alexandre Julliarda3960291999-02-26 11:11:13 +00001215 SelectObject (hdcMem, hOldBmp);
1216 DeleteDC( hdcMem );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001217 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001218 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001219}
1220
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001221/******************************************************************************
1222 *
1223 * NC_DrawMinButton95(
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001224 * HWND hwnd,
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001225 * HDC16 hdc,
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001226 * BOOL down,
Pascal Lessardd814bb61999-07-31 13:02:02 +00001227 * BOOL bGrayed )
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001228 *
1229 * Draws the minimize button for Win95 style windows.
1230 *
Pascal Lessardd814bb61999-07-31 13:02:02 +00001231 * If bGrayed is true, then draw a disabled Minimize button
1232 *
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001233 * Bugs
1234 * Many. Spacing is still incorrect. Should scale the image with the
1235 * title bar. And more...
1236 *
1237 * Revision history
1238 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1239 * Original implementation.
1240 *
1241 *****************************************************************************/
1242
Pascal Lessardd814bb61999-07-31 13:02:02 +00001243static void NC_DrawMinButton95(HWND hwnd,HDC16 hdc,BOOL down, BOOL bGrayed)
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001244{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001245 RECT rect;
1246 HDC hdcMem;
Noomen Hamzabfd02281999-01-20 14:03:49 +00001247 WND *wndPtr = WIN_FindWndPtr( hwnd );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001248
Noomen Hamzabfd02281999-01-20 14:03:49 +00001249 if( !(wndPtr->flags & WIN_MANAGED))
1250
1251 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001252 BITMAP bmp;
1253 HBITMAP hBmp,hOldBmp;
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001254
Alexandre Julliardf90efa91998-06-14 15:24:15 +00001255 NC_GetInsideRect95( hwnd, &rect );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001256
Alexandre Julliarda3960291999-02-26 11:11:13 +00001257 hdcMem = CreateCompatibleDC( hdc );
Noomen Hamzabfd02281999-01-20 14:03:49 +00001258 hBmp = down ? hbitmapMinimizeD : hbitmapMinimize;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001259 hOldBmp= SelectObject( hdcMem, hBmp );
1260 GetObjectA (hBmp, sizeof(BITMAP), &bmp);
Noomen Hamzabfd02281999-01-20 14:03:49 +00001261
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001262 if (wndPtr->dwStyle & WS_SYSMENU)
Marcus Meissnerddca3151999-05-22 11:33:23 +00001263 rect.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001264
Pascal Lessardd814bb61999-07-31 13:02:02 +00001265 /* In win 95 there is always a Maximize box when there is a Minimize one */
1266 if ((wndPtr->dwStyle & WS_MAXIMIZEBOX) || (wndPtr->dwStyle & WS_MINIMIZEBOX))
Marcus Meissnerddca3151999-05-22 11:33:23 +00001267 rect.right += -1 - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2;
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001268
Marcus Meissnerddca3151999-05-22 11:33:23 +00001269 BitBlt( hdc, rect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
1270 rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
Noomen Hamzabfd02281999-01-20 14:03:49 +00001271 bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY );
1272
Pascal Lessardd814bb61999-07-31 13:02:02 +00001273 if(bGrayed)
1274 NC_DrawGrayButton(hdc, rect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2 + 2,
1275 rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
1276
1277
Alexandre Julliarda3960291999-02-26 11:11:13 +00001278 SelectObject (hdcMem, hOldBmp);
Pascal Lessardd814bb61999-07-31 13:02:02 +00001279 DeleteDC( hdcMem );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001280 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001281 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001282}
1283
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001284/***********************************************************************
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001285 * NC_DrawFrame
1286 *
1287 * Draw a window frame inside the given rectangle, and update the rectangle.
Alexandre Julliardaca05781994-10-17 18:12:41 +00001288 * The correct pen for the frame must be selected in the DC.
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001289 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001290static void NC_DrawFrame( HDC hdc, RECT *rect, BOOL dlgFrame,
1291 BOOL active )
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001292{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001293 INT width, height;
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001294
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00001295 if (TWEAK_WineLook != WIN31_LOOK)
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +00001296 ERR("Called in Win95 mode. Aiee! Please report this.\n" );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001297
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001298 if (dlgFrame)
1299 {
Marcus Meissnerddca3151999-05-22 11:33:23 +00001300 width = GetSystemMetrics(SM_CXDLGFRAME) - 1;
1301 height = GetSystemMetrics(SM_CYDLGFRAME) - 1;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001302 SelectObject( hdc, GetSysColorBrush(active ? COLOR_ACTIVECAPTION :
Alexandre Julliard02e90081998-01-04 17:49:09 +00001303 COLOR_INACTIVECAPTION) );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001304 }
1305 else
1306 {
Ove Kaaven60c78f11999-07-03 15:40:29 +00001307 width = GetSystemMetrics(SM_CXFRAME) - 2;
1308 height = GetSystemMetrics(SM_CYFRAME) - 2;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001309 SelectObject( hdc, GetSysColorBrush(active ? COLOR_ACTIVEBORDER :
Alexandre Julliard02e90081998-01-04 17:49:09 +00001310 COLOR_INACTIVEBORDER) );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001311 }
1312
1313 /* Draw frame */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001314 PatBlt( hdc, rect->left, rect->top,
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001315 rect->right - rect->left, height, PATCOPY );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001316 PatBlt( hdc, rect->left, rect->top,
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001317 width, rect->bottom - rect->top, PATCOPY );
Randy Weems0bc73c71999-03-25 15:49:11 +00001318 PatBlt( hdc, rect->left, rect->bottom - 1,
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001319 rect->right - rect->left, -height, PATCOPY );
Randy Weems0bc73c71999-03-25 15:49:11 +00001320 PatBlt( hdc, rect->right - 1, rect->top,
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001321 -width, rect->bottom - rect->top, PATCOPY );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001322
1323 if (dlgFrame)
1324 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001325 InflateRect( rect, -width, -height );
Alexandre Julliarddf2673b1997-03-29 17:20:20 +00001326 }
1327 else
1328 {
Ove Kaaven60c78f11999-07-03 15:40:29 +00001329 INT decYOff = GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXSIZE) - 1;
1330 INT decXOff = GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYSIZE) - 1;
Huw D M Davies2d617be1998-12-08 09:14:09 +00001331
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001332 /* Draw inner rectangle */
Alexandre Julliarddf2673b1997-03-29 17:20:20 +00001333
Alexandre Julliarda3960291999-02-26 11:11:13 +00001334 SelectObject( hdc, GetStockObject(NULL_BRUSH) );
1335 Rectangle( hdc, rect->left + width, rect->top + height,
Huw D M Davies2d617be1998-12-08 09:14:09 +00001336 rect->right - width , rect->bottom - height );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001337
1338 /* Draw the decorations */
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001339
Alexandre Julliarda3960291999-02-26 11:11:13 +00001340 MoveToEx( hdc, rect->left, rect->top + decYOff, NULL );
1341 LineTo( hdc, rect->left + width, rect->top + decYOff );
1342 MoveToEx( hdc, rect->right - 1, rect->top + decYOff, NULL );
1343 LineTo( hdc, rect->right - width - 1, rect->top + decYOff );
1344 MoveToEx( hdc, rect->left, rect->bottom - decYOff, NULL );
1345 LineTo( hdc, rect->left + width, rect->bottom - decYOff );
1346 MoveToEx( hdc, rect->right - 1, rect->bottom - decYOff, NULL );
1347 LineTo( hdc, rect->right - width - 1, rect->bottom - decYOff );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001348
Alexandre Julliarda3960291999-02-26 11:11:13 +00001349 MoveToEx( hdc, rect->left + decXOff, rect->top, NULL );
1350 LineTo( hdc, rect->left + decXOff, rect->top + height);
1351 MoveToEx( hdc, rect->left + decXOff, rect->bottom - 1, NULL );
1352 LineTo( hdc, rect->left + decXOff, rect->bottom - height - 1 );
1353 MoveToEx( hdc, rect->right - decXOff, rect->top, NULL );
1354 LineTo( hdc, rect->right - decXOff, rect->top + height );
1355 MoveToEx( hdc, rect->right - decXOff, rect->bottom - 1, NULL );
1356 LineTo( hdc, rect->right - decXOff, rect->bottom - height - 1 );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001357
Alexandre Julliarda3960291999-02-26 11:11:13 +00001358 InflateRect( rect, -width - 1, -height - 1 );
Alexandre Julliarddf2673b1997-03-29 17:20:20 +00001359 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001360}
1361
1362
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001363/******************************************************************************
1364 *
1365 * void NC_DrawFrame95(
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001366 * HDC hdc,
1367 * RECT *rect,
1368 * BOOL dlgFrame,
1369 * BOOL active )
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001370 *
1371 * Draw a window frame inside the given rectangle, and update the rectangle.
1372 * The correct pen for the frame must be selected in the DC.
1373 *
1374 * Bugs
1375 * Many. First, just what IS a frame in Win95? Note that the 3D look
1376 * on the outer edge is handled by NC_DoNCPaint95. As is the inner
1377 * edge. The inner rectangle just inside the frame is handled by the
1378 * Caption code.
1379 *
1380 * In short, for most people, this function should be a nop (unless
1381 * you LIKE thick borders in Win95/NT4.0 -- I've been working with
1382 * them lately, but just to get this code right). Even so, it doesn't
1383 * appear to be so. It's being worked on...
1384 *
1385 * Revision history
1386 * 06-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1387 * Original implementation (based on NC_DrawFrame)
Alexandre Julliardf90efa91998-06-14 15:24:15 +00001388 * 02-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1389 * Some minor fixes.
Ove Kaaven60c78f11999-07-03 15:40:29 +00001390 * 29-Jun-1999 Ove KÃ¥ven (ovek@arcticnet.no)
1391 * Fixed a fix or something.
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001392 *
1393 *****************************************************************************/
1394
1395static void NC_DrawFrame95(
Alexandre Julliarda3960291999-02-26 11:11:13 +00001396 HDC hdc,
1397 RECT *rect,
1398 BOOL dlgFrame,
1399 BOOL active )
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001400{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001401 INT width, height;
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001402
1403 if (dlgFrame)
1404 {
Marcus Meissnerddca3151999-05-22 11:33:23 +00001405 width = GetSystemMetrics(SM_CXDLGFRAME) - GetSystemMetrics(SM_CXEDGE);
1406 height = GetSystemMetrics(SM_CYDLGFRAME) - GetSystemMetrics(SM_CYEDGE);
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001407 }
1408 else
1409 {
Marcus Meissnerddca3151999-05-22 11:33:23 +00001410 width = GetSystemMetrics(SM_CXFRAME) - GetSystemMetrics(SM_CXEDGE);
1411 height = GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYEDGE);
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001412 }
1413
Alexandre Julliarda3960291999-02-26 11:11:13 +00001414 SelectObject( hdc, GetSysColorBrush(active ? COLOR_ACTIVEBORDER :
Alexandre Julliardf90efa91998-06-14 15:24:15 +00001415 COLOR_INACTIVEBORDER) );
1416
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001417 /* Draw frame */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001418 PatBlt( hdc, rect->left, rect->top,
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001419 rect->right - rect->left, height, PATCOPY );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001420 PatBlt( hdc, rect->left, rect->top,
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001421 width, rect->bottom - rect->top, PATCOPY );
Randy Weems0bc73c71999-03-25 15:49:11 +00001422 PatBlt( hdc, rect->left, rect->bottom - 1,
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001423 rect->right - rect->left, -height, PATCOPY );
Ove Kaaven60c78f11999-07-03 15:40:29 +00001424 PatBlt( hdc, rect->right - 1, rect->top,
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001425 -width, rect->bottom - rect->top, PATCOPY );
1426
Alexandre Julliarda3960291999-02-26 11:11:13 +00001427 InflateRect( rect, -width, -height );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001428}
1429
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001430/***********************************************************************
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001431 * NC_DrawMovingFrame
1432 *
1433 * Draw the frame used when moving or resizing window.
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001434 *
1435 * FIXME: This causes problems in Win95 mode. (why?)
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001436 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001437static void NC_DrawMovingFrame( HDC hdc, RECT *rect, BOOL thickframe )
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001438{
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001439 if (thickframe)
1440 {
1441 RECT16 r16;
1442 CONV_RECT32TO16( rect, &r16 );
Marcus Meissnerddca3151999-05-22 11:33:23 +00001443 FastWindowFrame16( hdc, &r16, GetSystemMetrics(SM_CXFRAME),
1444 GetSystemMetrics(SM_CYFRAME), PATINVERT );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001445 }
Alexandre Julliarda3960291999-02-26 11:11:13 +00001446 else DrawFocusRect( hdc, rect );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001447}
1448
1449
1450/***********************************************************************
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001451 * NC_DrawCaption
1452 *
1453 * Draw the window caption.
1454 * The correct pen for the window frame must be selected in the DC.
1455 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001456static void NC_DrawCaption( HDC hdc, RECT *rect, HWND hwnd,
1457 DWORD style, BOOL active )
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001458{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001459 RECT r = *rect;
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001460 WND * wndPtr = WIN_FindWndPtr( hwnd );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001461 char buffer[256];
1462
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001463 if (wndPtr->flags & WIN_MANAGED)
1464 {
1465 WIN_ReleaseWndPtr(wndPtr);
1466 return;
1467 }
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001468
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001469 if (!hbitmapClose)
1470 {
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001471 if (!(hbitmapClose = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_CLOSE) )))
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001472 {
1473 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001474 return;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001475 }
Francois Boisvert308c6af1999-02-18 10:37:17 +00001476 hbitmapCloseD = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_CLOSED) );
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001477 hbitmapMinimize = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_REDUCE) );
1478 hbitmapMinimizeD = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_REDUCED) );
1479 hbitmapMaximize = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_ZOOM) );
1480 hbitmapMaximizeD = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_ZOOMD) );
1481 hbitmapRestore = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_RESTORE) );
1482 hbitmapRestoreD = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_RESTORED) );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001483 }
1484
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001485 if (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME)
1486 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001487 HBRUSH hbrushOld = SelectObject(hdc, GetSysColorBrush(COLOR_WINDOW) );
1488 PatBlt( hdc, r.left, r.top, 1, r.bottom-r.top+1,PATCOPY );
1489 PatBlt( hdc, r.right-1, r.top, 1, r.bottom-r.top+1, PATCOPY );
1490 PatBlt( hdc, r.left, r.top-1, r.right-r.left, 1, PATCOPY );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001491 r.left++;
1492 r.right--;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001493 SelectObject( hdc, hbrushOld );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001494 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001495 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliardb0efe282000-08-04 04:18:04 +00001496 MoveToEx( hdc, r.left, r.bottom, NULL );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001497 LineTo( hdc, r.right, r.bottom );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001498
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001499 if (style & WS_SYSMENU)
1500 {
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001501 NC_DrawSysButton( hwnd, hdc, FALSE );
Marcus Meissnerddca3151999-05-22 11:33:23 +00001502 r.left += GetSystemMetrics(SM_CXSIZE) + 1;
Alexandre Julliardb0efe282000-08-04 04:18:04 +00001503 MoveToEx( hdc, r.left - 1, r.top, NULL );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001504 LineTo( hdc, r.left - 1, r.bottom );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001505 }
1506 if (style & WS_MAXIMIZEBOX)
1507 {
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001508 NC_DrawMaxButton( hwnd, hdc, FALSE );
Marcus Meissnerddca3151999-05-22 11:33:23 +00001509 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001510 }
1511 if (style & WS_MINIMIZEBOX)
1512 {
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001513 NC_DrawMinButton( hwnd, hdc, FALSE );
Marcus Meissnerddca3151999-05-22 11:33:23 +00001514 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001515 }
1516
Alexandre Julliarda3960291999-02-26 11:11:13 +00001517 FillRect( hdc, &r, GetSysColorBrush(active ? COLOR_ACTIVECAPTION :
Alexandre Julliard02e90081998-01-04 17:49:09 +00001518 COLOR_INACTIVECAPTION) );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001519
Alexandre Julliarda3960291999-02-26 11:11:13 +00001520 if (GetWindowTextA( hwnd, buffer, sizeof(buffer) ))
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001521 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001522 if (active) SetTextColor( hdc, GetSysColor( COLOR_CAPTIONTEXT ) );
1523 else SetTextColor( hdc, GetSysColor( COLOR_INACTIVECAPTIONTEXT ) );
1524 SetBkMode( hdc, TRANSPARENT );
1525 DrawTextA( hdc, buffer, -1, &r,
Alexandre Julliarddf2673b1997-03-29 17:20:20 +00001526 DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_NOPREFIX );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001527 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001528}
1529
1530
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001531/******************************************************************************
1532 *
1533 * NC_DrawCaption95(
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001534 * HDC hdc,
1535 * RECT *rect,
1536 * HWND hwnd,
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001537 * DWORD style,
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001538 * BOOL active )
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001539 *
1540 * Draw the window caption for Win95 style windows.
1541 * The correct pen for the window frame must be selected in the DC.
1542 *
1543 * Bugs
Alexandre Julliardf90efa91998-06-14 15:24:15 +00001544 * Hey, a function that finally works! Well, almost.
1545 * It's being worked on.
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001546 *
1547 * Revision history
1548 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1549 * Original implementation.
Alexandre Julliardf90efa91998-06-14 15:24:15 +00001550 * 02-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1551 * Some minor fixes.
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001552 *
1553 *****************************************************************************/
1554
1555static void NC_DrawCaption95(
Alexandre Julliarda3960291999-02-26 11:11:13 +00001556 HDC hdc,
1557 RECT *rect,
1558 HWND hwnd,
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001559 DWORD style,
Eric Kohl8e517b51998-10-11 13:06:35 +00001560 DWORD exStyle,
Alexandre Julliarda3960291999-02-26 11:11:13 +00001561 BOOL active )
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001562{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001563 RECT r = *rect;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001564 WND *wndPtr = WIN_FindWndPtr( hwnd );
1565 char buffer[256];
Alexandre Julliarda3960291999-02-26 11:11:13 +00001566 HPEN hPrevPen;
Pascal Lessardd814bb61999-07-31 13:02:02 +00001567 HMENU hSysMenu;
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001568
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001569 if (wndPtr->flags & WIN_MANAGED)
1570 {
1571 WIN_ReleaseWndPtr(wndPtr);
1572 return;
1573 }
1574 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001575
Alexandre Julliarda3960291999-02-26 11:11:13 +00001576 hPrevPen = SelectObject( hdc, GetSysColorPen(COLOR_3DFACE) );
1577 MoveToEx( hdc, r.left, r.bottom - 1, NULL );
1578 LineTo( hdc, r.right, r.bottom - 1 );
1579 SelectObject( hdc, hPrevPen );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001580 r.bottom--;
1581
Alexandre Julliarda3960291999-02-26 11:11:13 +00001582 FillRect( hdc, &r, GetSysColorBrush(active ? COLOR_ACTIVECAPTION :
Alexandre Julliard02e90081998-01-04 17:49:09 +00001583 COLOR_INACTIVECAPTION) );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001584
1585 if (!hbitmapClose) {
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001586 if (!(hbitmapClose = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_CLOSE) )))
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001587 return;
Francois Boisvert308c6af1999-02-18 10:37:17 +00001588 hbitmapCloseD = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_CLOSED));
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001589 hbitmapMinimize = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_REDUCE) );
1590 hbitmapMinimizeD = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_REDUCED) );
1591 hbitmapMaximize = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_ZOOM) );
1592 hbitmapMaximizeD = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_ZOOMD) );
1593 hbitmapRestore = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_RESTORE) );
1594 hbitmapRestoreD = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_RESTORED) );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001595 }
Pascal Lessardd814bb61999-07-31 13:02:02 +00001596
Eric Kohl8e517b51998-10-11 13:06:35 +00001597 if ((style & WS_SYSMENU) && !(exStyle & WS_EX_TOOLWINDOW)) {
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001598 if (NC_DrawSysButton95 (hwnd, hdc, FALSE))
Marcus Meissnerddca3151999-05-22 11:33:23 +00001599 r.left += GetSystemMetrics(SM_CYCAPTION) - 1;
Eric Kohl8e517b51998-10-11 13:06:35 +00001600 }
Pascal Lessardd814bb61999-07-31 13:02:02 +00001601
1602 if (style & WS_SYSMENU)
1603 {
1604 UINT state;
1605
1606 /* Go get the sysmenu */
1607 hSysMenu = GetSystemMenu(hwnd, FALSE);
1608 state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
1609
1610 /* Draw a grayed close button if disabled and a normal one if SC_CLOSE is not there */
1611 NC_DrawCloseButton95 (hwnd, hdc, FALSE,
1612 ((((state & MF_DISABLED) || (state & MF_GRAYED))) && (state != 0xFFFFFFFF)));
Marcus Meissnerddca3151999-05-22 11:33:23 +00001613 r.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
Pascal Lessardd814bb61999-07-31 13:02:02 +00001614
1615 if ((style & WS_MAXIMIZEBOX) || (style & WS_MINIMIZEBOX))
1616 {
1617 /* In win95 the two buttons are always there */
1618 /* But if the menu item is not in the menu they're disabled*/
1619
1620 NC_DrawMaxButton95( hwnd, hdc, FALSE, (!(style & WS_MAXIMIZEBOX)));
1621 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1622
1623 NC_DrawMinButton95( hwnd, hdc, FALSE, (!(style & WS_MINIMIZEBOX)));
1624 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1625 }
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001626 }
1627
Alexandre Julliarda3960291999-02-26 11:11:13 +00001628 if (GetWindowTextA( hwnd, buffer, sizeof(buffer) )) {
1629 NONCLIENTMETRICSA nclm;
1630 HFONT hFont, hOldFont;
1631 nclm.cbSize = sizeof(NONCLIENTMETRICSA);
1632 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
Eric Kohl8e517b51998-10-11 13:06:35 +00001633 if (exStyle & WS_EX_TOOLWINDOW)
Alexandre Julliarda3960291999-02-26 11:11:13 +00001634 hFont = CreateFontIndirectA (&nclm.lfSmCaptionFont);
Eric Kohl8e517b51998-10-11 13:06:35 +00001635 else
Alexandre Julliarda3960291999-02-26 11:11:13 +00001636 hFont = CreateFontIndirectA (&nclm.lfCaptionFont);
1637 hOldFont = SelectObject (hdc, hFont);
1638 if (active) SetTextColor( hdc, GetSysColor( COLOR_CAPTIONTEXT ) );
1639 else SetTextColor( hdc, GetSysColor( COLOR_INACTIVECAPTIONTEXT ) );
1640 SetBkMode( hdc, TRANSPARENT );
Alexandre Julliardf90efa91998-06-14 15:24:15 +00001641 r.left += 2;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001642 DrawTextA( hdc, buffer, -1, &r,
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001643 DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001644 DeleteObject (SelectObject (hdc, hOldFont));
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001645 }
1646}
1647
1648
1649
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001650/***********************************************************************
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001651 * NC_DoNCPaint
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001652 *
Alexandre Julliardc981d0b1996-03-31 16:40:13 +00001653 * Paint the non-client area. clip is currently unused.
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001654 */
Patrik Stridvall1ed4ecf1999-06-26 14:58:24 +00001655static void NC_DoNCPaint( WND* wndPtr, HRGN clip, BOOL suppress_menupaint )
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001656{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001657 HDC hdc;
1658 RECT rect;
1659 BOOL active;
1660 HWND hwnd = wndPtr->hwndSelf;
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001661
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001662 if ( wndPtr->dwStyle & WS_MINIMIZE ||
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001663 !WIN_IsWindowDrawable( wndPtr, 0 )) return; /* Nothing to do */
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001664
Alexandre Julliardc981d0b1996-03-31 16:40:13 +00001665 active = wndPtr->flags & WIN_NCACTIVATED;
1666
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +00001667 TRACE("%04x %d\n", hwnd, active );
Alexandre Julliardc981d0b1996-03-31 16:40:13 +00001668
Alex Korobka4f1ac051999-03-28 09:37:57 +00001669 if (!(hdc = GetDCEx( hwnd, (clip > 1) ? clip : 0, DCX_USESTYLE | DCX_WINDOW |
1670 ((clip > 1) ? (DCX_INTERSECTRGN | DCX_KEEPCLIPRGN): 0) ))) return;
Alexandre Julliard940d58c1994-09-16 09:24:37 +00001671
Alexandre Julliarda3960291999-02-26 11:11:13 +00001672 if (ExcludeVisRect16( hdc, wndPtr->rectClient.left-wndPtr->rectWindow.left,
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001673 wndPtr->rectClient.top-wndPtr->rectWindow.top,
1674 wndPtr->rectClient.right-wndPtr->rectWindow.left,
1675 wndPtr->rectClient.bottom-wndPtr->rectWindow.top )
1676 == NULLREGION)
1677 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001678 ReleaseDC( hwnd, hdc );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001679 return;
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001680 }
1681
1682 rect.top = rect.left = 0;
1683 rect.right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
1684 rect.bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
1685
Alexandre Julliarda3960291999-02-26 11:11:13 +00001686 SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001687
Alexandre Julliard0c126c71996-02-18 18:44:41 +00001688 if (!(wndPtr->flags & WIN_MANAGED))
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001689 {
Ove Kaaven60c78f11999-07-03 15:40:29 +00001690 if (HAS_ANYFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
1691 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001692 SelectObject( hdc, GetStockObject(NULL_BRUSH) );
1693 Rectangle( hdc, 0, 0, rect.right, rect.bottom );
1694 InflateRect( &rect, -1, -1 );
Alexandre Julliard0c126c71996-02-18 18:44:41 +00001695 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001696
Ove Kaaven60c78f11999-07-03 15:40:29 +00001697 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
Alexandre Julliard0c126c71996-02-18 18:44:41 +00001698 NC_DrawFrame(hdc, &rect, FALSE, active );
Ove Kaaven60c78f11999-07-03 15:40:29 +00001699 else if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
1700 NC_DrawFrame( hdc, &rect, TRUE, active );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001701
Alexandre Julliard0c126c71996-02-18 18:44:41 +00001702 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
1703 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001704 RECT r = rect;
Marcus Meissnerddca3151999-05-22 11:33:23 +00001705 r.bottom = rect.top + GetSystemMetrics(SM_CYSIZE);
1706 rect.top += GetSystemMetrics(SM_CYSIZE) + GetSystemMetrics(SM_CYBORDER);
Alexandre Julliard0c126c71996-02-18 18:44:41 +00001707 NC_DrawCaption( hdc, &r, hwnd, wndPtr->dwStyle, active );
1708 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001709 }
1710
Alexandre Julliardf7207251994-07-23 07:57:48 +00001711 if (HAS_MENU(wndPtr))
1712 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001713 RECT r = rect;
Marcus Meissnerddca3151999-05-22 11:33:23 +00001714 r.bottom = rect.top + GetSystemMetrics(SM_CYMENU); /* default height */
Alexandre Julliard940d58c1994-09-16 09:24:37 +00001715 rect.top += MENU_DrawMenuBar( hdc, &r, hwnd, suppress_menupaint );
Alexandre Julliardf7207251994-07-23 07:57:48 +00001716 }
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001717
Alexandre Julliardecc37121994-11-22 16:31:29 +00001718 /* Draw the scroll-bars */
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001719
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001720 if (wndPtr->dwStyle & WS_VSCROLL)
Alex Korobkad2085841998-10-18 10:37:46 +00001721 SCROLL_DrawScrollBar( hwnd, hdc, SB_VERT, TRUE, TRUE );
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001722 if (wndPtr->dwStyle & WS_HSCROLL)
Alex Korobkad2085841998-10-18 10:37:46 +00001723 SCROLL_DrawScrollBar( hwnd, hdc, SB_HORZ, TRUE, TRUE );
Alexandre Julliardecc37121994-11-22 16:31:29 +00001724
1725 /* Draw the "size-box" */
1726
1727 if ((wndPtr->dwStyle & WS_VSCROLL) && (wndPtr->dwStyle & WS_HSCROLL))
1728 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001729 RECT r = rect;
Marcus Meissnerddca3151999-05-22 11:33:23 +00001730 r.left = r.right - GetSystemMetrics(SM_CXVSCROLL) + 1;
1731 r.top = r.bottom - GetSystemMetrics(SM_CYHSCROLL) + 1;
Alexandre Julliardf90efa91998-06-14 15:24:15 +00001732 if(wndPtr->dwStyle & WS_BORDER) {
1733 r.left++;
1734 r.top++;
1735 }
Alexandre Julliarda3960291999-02-26 11:11:13 +00001736 FillRect( hdc, &r, GetSysColorBrush(COLOR_SCROLLBAR) );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001737 }
1738
Alexandre Julliarda3960291999-02-26 11:11:13 +00001739 ReleaseDC( hwnd, hdc );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001740}
1741
1742
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001743/******************************************************************************
1744 *
1745 * void NC_DoNCPaint95(
1746 * WND *wndPtr,
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001747 * HRGN clip,
1748 * BOOL suppress_menupaint )
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001749 *
1750 * Paint the non-client area for Win95 windows. The clip region is
1751 * currently ignored.
1752 *
1753 * Bugs
1754 * grep -E -A10 -B5 \(95\)\|\(Bugs\)\|\(FIXME\) windows/nonclient.c \
1755 * misc/tweak.c controls/menu.c # :-)
1756 *
1757 * Revision history
1758 * 03-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1759 * Original implementation
Alexandre Julliardf90efa91998-06-14 15:24:15 +00001760 * 10-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1761 * Fixed some bugs.
Ove Kaaven60c78f11999-07-03 15:40:29 +00001762 * 29-Jun-1999 Ove KÃ¥ven (ovek@arcticnet.no)
1763 * Streamlined window style checks.
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001764 *
1765 *****************************************************************************/
1766
Patrik Stridvall1ed4ecf1999-06-26 14:58:24 +00001767static void NC_DoNCPaint95(
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001768 WND *wndPtr,
Alexandre Julliarda3960291999-02-26 11:11:13 +00001769 HRGN clip,
1770 BOOL suppress_menupaint )
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001771{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001772 HDC hdc;
Alex Korobka4f1ac051999-03-28 09:37:57 +00001773 RECT rfuzz, rect, rectClip;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001774 BOOL active;
1775 HWND hwnd = wndPtr->hwndSelf;
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001776
1777 if ( wndPtr->dwStyle & WS_MINIMIZE ||
1778 !WIN_IsWindowDrawable( wndPtr, 0 )) return; /* Nothing to do */
1779
1780 active = wndPtr->flags & WIN_NCACTIVATED;
1781
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +00001782 TRACE("%04x %d\n", hwnd, active );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001783
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +00001784 /* MSDN docs are pretty idiotic here, they say app CAN use clipRgn in
1785 the call to GetDCEx implying that it is allowed not to use it either.
1786 However, the suggested GetDCEx( , DCX_WINDOW | DCX_INTERSECTRGN)
1787 will cause clipRgn to be deleted after ReleaseDC().
1788 Now, how is the "system" supposed to tell what happened?
Alex Korobka4f1ac051999-03-28 09:37:57 +00001789 */
1790
1791 if (!(hdc = GetDCEx( hwnd, (clip > 1) ? clip : 0, DCX_USESTYLE | DCX_WINDOW |
1792 ((clip > 1) ?(DCX_INTERSECTRGN | DCX_KEEPCLIPRGN) : 0) ))) return;
1793
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001794
Alexandre Julliarda3960291999-02-26 11:11:13 +00001795 if (ExcludeVisRect16( hdc, wndPtr->rectClient.left-wndPtr->rectWindow.left,
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001796 wndPtr->rectClient.top-wndPtr->rectWindow.top,
1797 wndPtr->rectClient.right-wndPtr->rectWindow.left,
1798 wndPtr->rectClient.bottom-wndPtr->rectWindow.top )
1799 == NULLREGION)
1800 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001801 ReleaseDC( hwnd, hdc );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001802 return;
1803 }
1804
1805 rect.top = rect.left = 0;
1806 rect.right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
1807 rect.bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
1808
Alex Korobka4f1ac051999-03-28 09:37:57 +00001809 if( clip > 1 )
1810 GetRgnBox( clip, &rectClip );
1811 else
1812 {
1813 clip = 0;
1814 rectClip = rect;
1815 }
1816
Alexandre Julliarda3960291999-02-26 11:11:13 +00001817 SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001818
1819 if(!(wndPtr->flags & WIN_MANAGED)) {
Ove Kaaven60c78f11999-07-03 15:40:29 +00001820 if (HAS_BIGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle)) {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001821 DrawEdge (hdc, &rect, EDGE_RAISED, BF_RECT | BF_ADJUST);
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001822 }
Ove Kaaven60c78f11999-07-03 15:40:29 +00001823 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
1824 NC_DrawFrame95(hdc, &rect, FALSE, active );
1825 else if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
1826 NC_DrawFrame95( hdc, &rect, TRUE, active );
1827 else if (HAS_THINFRAME( wndPtr->dwStyle )) {
Gerard Patel5773dad1999-06-12 14:45:56 +00001828 SelectObject( hdc, GetStockObject(NULL_BRUSH) );
1829 Rectangle( hdc, 0, 0, rect.right, rect.bottom );
Ove Kaaven60c78f11999-07-03 15:40:29 +00001830 }
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001831
1832 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
1833 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001834 RECT r = rect;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001835 if (wndPtr->dwExStyle & WS_EX_TOOLWINDOW) {
Marcus Meissnerddca3151999-05-22 11:33:23 +00001836 r.bottom = rect.top + GetSystemMetrics(SM_CYSMCAPTION);
1837 rect.top += GetSystemMetrics(SM_CYSMCAPTION);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001838 }
1839 else {
Marcus Meissnerddca3151999-05-22 11:33:23 +00001840 r.bottom = rect.top + GetSystemMetrics(SM_CYCAPTION);
1841 rect.top += GetSystemMetrics(SM_CYCAPTION);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001842 }
Alex Korobka4f1ac051999-03-28 09:37:57 +00001843 if( !clip || IntersectRect( &rfuzz, &r, &rectClip ) )
1844 NC_DrawCaption95 (hdc, &r, hwnd, wndPtr->dwStyle,
1845 wndPtr->dwExStyle, active);
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001846 }
1847 }
1848
1849 if (HAS_MENU(wndPtr))
1850 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001851 RECT r = rect;
Marcus Meissnerddca3151999-05-22 11:33:23 +00001852 r.bottom = rect.top + GetSystemMetrics(SM_CYMENU);
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001853
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +00001854 TRACE("Calling DrawMenuBar with rect (%d, %d)-(%d, %d)\n",
1855 r.left, r.top, r.right, r.bottom);
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001856
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001857 rect.top += MENU_DrawMenuBar( hdc, &r, hwnd, suppress_menupaint ) + 1;
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001858 }
1859
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +00001860 TRACE("After MenuBar, rect is (%d, %d)-(%d, %d).\n",
1861 rect.left, rect.top, rect.right, rect.bottom );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001862
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001863 if (wndPtr->dwExStyle & WS_EX_CLIENTEDGE)
Alexandre Julliarda3960291999-02-26 11:11:13 +00001864 DrawEdge (hdc, &rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001865
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001866 if (wndPtr->dwExStyle & WS_EX_STATICEDGE)
Alexandre Julliarda3960291999-02-26 11:11:13 +00001867 DrawEdge (hdc, &rect, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
Alexandre Julliardf90efa91998-06-14 15:24:15 +00001868
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001869 /* Draw the scroll-bars */
1870
1871 if (wndPtr->dwStyle & WS_VSCROLL)
Alex Korobkad2085841998-10-18 10:37:46 +00001872 SCROLL_DrawScrollBar( hwnd, hdc, SB_VERT, TRUE, TRUE );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001873 if (wndPtr->dwStyle & WS_HSCROLL)
Alex Korobkad2085841998-10-18 10:37:46 +00001874 SCROLL_DrawScrollBar( hwnd, hdc, SB_HORZ, TRUE, TRUE );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001875
1876 /* Draw the "size-box" */
1877 if ((wndPtr->dwStyle & WS_VSCROLL) && (wndPtr->dwStyle & WS_HSCROLL))
1878 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001879 RECT r = rect;
Marcus Meissnerddca3151999-05-22 11:33:23 +00001880 r.left = r.right - GetSystemMetrics(SM_CXVSCROLL) + 1;
1881 r.top = r.bottom - GetSystemMetrics(SM_CYHSCROLL) + 1;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001882 FillRect( hdc, &r, GetSysColorBrush(COLOR_SCROLLBAR) );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001883 }
1884
Alexandre Julliarda3960291999-02-26 11:11:13 +00001885 ReleaseDC( hwnd, hdc );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001886}
1887
1888
1889
Alexandre Julliard988ca971994-06-21 16:15:21 +00001890
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001891/***********************************************************************
1892 * NC_HandleNCPaint
1893 *
1894 * Handle a WM_NCPAINT message. Called from DefWindowProc().
1895 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001896LONG NC_HandleNCPaint( HWND hwnd , HRGN clip)
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001897{
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001898 WND* wndPtr = WIN_FindWndPtr( hwnd );
1899
1900 if( wndPtr && wndPtr->dwStyle & WS_VISIBLE )
1901 {
1902 if( wndPtr->dwStyle & WS_MINIMIZE )
1903 WINPOS_RedrawIconTitle( hwnd );
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00001904 else if (TWEAK_WineLook == WIN31_LOOK)
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001905 NC_DoNCPaint( wndPtr, clip, FALSE );
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00001906 else
1907 NC_DoNCPaint95( wndPtr, clip, FALSE );
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001908 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001909 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001910 return 0;
1911}
1912
1913
1914/***********************************************************************
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001915 * NC_HandleNCActivate
1916 *
1917 * Handle a WM_NCACTIVATE message. Called from DefWindowProc().
1918 */
Alexandre Julliard530ee841996-10-23 16:59:13 +00001919LONG NC_HandleNCActivate( WND *wndPtr, WPARAM16 wParam )
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001920{
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001921 WORD wStateChange;
Alexandre Julliardd4719651995-12-12 18:49:11 +00001922
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001923 if( wParam ) wStateChange = !(wndPtr->flags & WIN_NCACTIVATED);
1924 else wStateChange = wndPtr->flags & WIN_NCACTIVATED;
Alexandre Julliardd4719651995-12-12 18:49:11 +00001925
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001926 if( wStateChange )
1927 {
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001928 if (wParam) wndPtr->flags |= WIN_NCACTIVATED;
1929 else wndPtr->flags &= ~WIN_NCACTIVATED;
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001930
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001931 if( wndPtr->dwStyle & WS_MINIMIZE )
1932 WINPOS_RedrawIconTitle( wndPtr->hwndSelf );
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00001933 else if (TWEAK_WineLook == WIN31_LOOK)
Alexandre Julliarda3960291999-02-26 11:11:13 +00001934 NC_DoNCPaint( wndPtr, (HRGN)1, FALSE );
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00001935 else
Alexandre Julliarda3960291999-02-26 11:11:13 +00001936 NC_DoNCPaint95( wndPtr, (HRGN)1, FALSE );
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001937 }
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001938 return TRUE;
1939}
1940
1941
1942/***********************************************************************
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001943 * NC_HandleSetCursor
1944 *
1945 * Handle a WM_SETCURSOR message. Called from DefWindowProc().
1946 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001947LONG NC_HandleSetCursor( HWND hwnd, WPARAM16 wParam, LPARAM lParam )
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001948{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001949 if (hwnd != (HWND)wParam) return 0; /* Don't set the cursor for child windows */
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001950
1951 switch(LOWORD(lParam))
1952 {
1953 case HTERROR:
1954 {
1955 WORD msg = HIWORD( lParam );
1956 if ((msg == WM_LBUTTONDOWN) || (msg == WM_MBUTTONDOWN) ||
1957 (msg == WM_RBUTTONDOWN))
Alexandre Julliarda3960291999-02-26 11:11:13 +00001958 MessageBeep(0);
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001959 }
1960 break;
1961
1962 case HTCLIENT:
1963 {
Gerard Patel5773dad1999-06-12 14:45:56 +00001964 HICON16 hCursor = (HICON16) GetClassWord(hwnd, GCW_HCURSOR);
1965 if(hCursor) {
1966 SetCursor16(hCursor);
1967 return TRUE;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001968 }
Gerard Patel5773dad1999-06-12 14:45:56 +00001969 return FALSE;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001970 }
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001971
1972 case HTLEFT:
1973 case HTRIGHT:
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001974 return (LONG)SetCursor16( LoadCursor16( 0, IDC_SIZEWE16 ) );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001975
1976 case HTTOP:
1977 case HTBOTTOM:
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001978 return (LONG)SetCursor16( LoadCursor16( 0, IDC_SIZENS16 ) );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001979
1980 case HTTOPLEFT:
1981 case HTBOTTOMRIGHT:
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001982 return (LONG)SetCursor16( LoadCursor16( 0, IDC_SIZENWSE16 ) );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001983
1984 case HTTOPRIGHT:
1985 case HTBOTTOMLEFT:
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001986 return (LONG)SetCursor16( LoadCursor16( 0, IDC_SIZENESW16 ) );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001987 }
1988
1989 /* Default cursor: arrow */
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001990 return (LONG)SetCursor16( LoadCursor16( 0, IDC_ARROW16 ) );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001991}
1992
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001993/***********************************************************************
1994 * NC_GetSysPopupPos
1995 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001996BOOL NC_GetSysPopupPos( WND* wndPtr, RECT* rect )
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001997{
Alexandre Julliard9ea19e51997-01-01 17:29:55 +00001998 if( wndPtr->hSysMenu )
1999 {
2000 if( wndPtr->dwStyle & WS_MINIMIZE )
Alexandre Julliarda3960291999-02-26 11:11:13 +00002001 GetWindowRect( wndPtr->hwndSelf, rect );
Alexandre Julliard9ea19e51997-01-01 17:29:55 +00002002 else
2003 {
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00002004 if (TWEAK_WineLook == WIN31_LOOK)
Alexandre Julliardf90efa91998-06-14 15:24:15 +00002005 NC_GetInsideRect( wndPtr->hwndSelf, rect );
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00002006 else
2007 NC_GetInsideRect95( wndPtr->hwndSelf, rect );
Alexandre Julliarda3960291999-02-26 11:11:13 +00002008 OffsetRect( rect, wndPtr->rectWindow.left, wndPtr->rectWindow.top);
Alexandre Julliard9ea19e51997-01-01 17:29:55 +00002009 if (wndPtr->dwStyle & WS_CHILD)
Alexandre Julliarda3960291999-02-26 11:11:13 +00002010 ClientToScreen( wndPtr->parent->hwndSelf, (POINT *)rect );
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00002011 if (TWEAK_WineLook == WIN31_LOOK) {
Marcus Meissnerddca3151999-05-22 11:33:23 +00002012 rect->right = rect->left + GetSystemMetrics(SM_CXSIZE);
2013 rect->bottom = rect->top + GetSystemMetrics(SM_CYSIZE);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00002014 }
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00002015 else {
Marcus Meissnerddca3151999-05-22 11:33:23 +00002016 rect->right = rect->left + GetSystemMetrics(SM_CYCAPTION) - 1;
2017 rect->bottom = rect->top + GetSystemMetrics(SM_CYCAPTION) - 1;
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00002018 }
Alexandre Julliard9ea19e51997-01-01 17:29:55 +00002019 }
2020 return TRUE;
2021 }
2022 return FALSE;
Alexandre Julliard1e37a181996-08-18 16:21:52 +00002023}
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002024
2025/***********************************************************************
2026 * NC_StartSizeMove
2027 *
2028 * Initialisation of a move or resize, when initiatied from a menu choice.
2029 * Return hit test code for caption or sizing border.
2030 */
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002031static LONG NC_StartSizeMove( WND* wndPtr, WPARAM16 wParam,
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002032 POINT *capturePoint )
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002033{
2034 LONG hittest = 0;
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002035 POINT pt;
Alexandre Julliarda3960291999-02-26 11:11:13 +00002036 MSG msg;
Noomen Hamzae3e54cd1999-06-26 10:31:44 +00002037 RECT rectWindow;
2038
2039 GetWindowRect(wndPtr->hwndSelf,&rectWindow);
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002040
2041 if ((wParam & 0xfff0) == SC_MOVE)
2042 {
2043 /* Move pointer at the center of the caption */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002044 RECT rect;
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00002045 if (TWEAK_WineLook == WIN31_LOOK)
Alexandre Julliardf90efa91998-06-14 15:24:15 +00002046 NC_GetInsideRect( wndPtr->hwndSelf, &rect );
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00002047 else
2048 NC_GetInsideRect95( wndPtr->hwndSelf, &rect );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002049 if (wndPtr->dwStyle & WS_SYSMENU)
Marcus Meissnerddca3151999-05-22 11:33:23 +00002050 rect.left += GetSystemMetrics(SM_CXSIZE) + 1;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002051 if (wndPtr->dwStyle & WS_MINIMIZEBOX)
Marcus Meissnerddca3151999-05-22 11:33:23 +00002052 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002053 if (wndPtr->dwStyle & WS_MAXIMIZEBOX)
Marcus Meissnerddca3151999-05-22 11:33:23 +00002054 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
Noomen Hamzae3e54cd1999-06-26 10:31:44 +00002055 pt.x = rectWindow.left + (rect.right - rect.left) / 2;
2056 pt.y = rectWindow.top + rect.top + GetSystemMetrics(SM_CYSIZE)/2;
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002057 hittest = HTCAPTION;
2058 *capturePoint = pt;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002059 }
2060 else /* SC_SIZE */
2061 {
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002062 while(!hittest)
2063 {
Ulrich Weigand2faf2cf1999-12-10 03:47:13 +00002064 MSG_InternalGetMessage( QMSG_WIN32A, &msg, 0, 0, MSGF_SIZE, PM_REMOVE, FALSE, NULL );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002065 switch(msg.message)
2066 {
2067 case WM_MOUSEMOVE:
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002068 hittest = NC_HandleNCHitTest( wndPtr->hwndSelf, msg.pt );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002069 if ((hittest < HTLEFT) || (hittest > HTBOTTOMRIGHT))
2070 hittest = 0;
2071 break;
2072
2073 case WM_LBUTTONUP:
2074 return 0;
2075
2076 case WM_KEYDOWN:
2077 switch(msg.wParam)
2078 {
2079 case VK_UP:
2080 hittest = HTTOP;
Noomen Hamzae3e54cd1999-06-26 10:31:44 +00002081 pt.x =(rectWindow.left+rectWindow.right)/2;
2082 pt.y = rectWindow.top + GetSystemMetrics(SM_CYFRAME) / 2;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002083 break;
2084 case VK_DOWN:
2085 hittest = HTBOTTOM;
Noomen Hamzae3e54cd1999-06-26 10:31:44 +00002086 pt.x =(rectWindow.left+rectWindow.right)/2;
2087 pt.y = rectWindow.bottom - GetSystemMetrics(SM_CYFRAME) / 2;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002088 break;
2089 case VK_LEFT:
2090 hittest = HTLEFT;
Noomen Hamzae3e54cd1999-06-26 10:31:44 +00002091 pt.x = rectWindow.left + GetSystemMetrics(SM_CXFRAME) / 2;
2092 pt.y =(rectWindow.top+rectWindow.bottom)/2;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002093 break;
2094 case VK_RIGHT:
2095 hittest = HTRIGHT;
Noomen Hamzae3e54cd1999-06-26 10:31:44 +00002096 pt.x = rectWindow.right - GetSystemMetrics(SM_CXFRAME) / 2;
2097 pt.y =(rectWindow.top+rectWindow.bottom)/2;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002098 break;
2099 case VK_RETURN:
2100 case VK_ESCAPE: return 0;
2101 }
2102 }
2103 }
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002104 *capturePoint = pt;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002105 }
Alexandre Julliarda3960291999-02-26 11:11:13 +00002106 SetCursorPos( pt.x, pt.y );
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002107 NC_HandleSetCursor( wndPtr->hwndSelf,
2108 wndPtr->hwndSelf, MAKELONG( hittest, WM_MOUSEMOVE ));
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002109 return hittest;
2110}
2111
2112
2113/***********************************************************************
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002114 * NC_DoSizeMove
2115 *
Stephane Lussierb3a99de1999-02-09 15:35:12 +00002116 * Perform SC_MOVE and SC_SIZE commands. `
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002117 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002118static void NC_DoSizeMove( HWND hwnd, WORD wParam )
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002119{
Alexandre Julliarda3960291999-02-26 11:11:13 +00002120 MSG msg;
Dmitry Timoshkov9b1e1dc2000-08-14 17:20:25 +00002121 RECT sizingRect, mouseRect, origRect;
Alexandre Julliarda3960291999-02-26 11:11:13 +00002122 HDC hdc;
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002123 LONG hittest = (LONG)(wParam & 0x0f);
2124 HCURSOR16 hDragCursor = 0, hOldCursor = 0;
Alexandre Julliarda3960291999-02-26 11:11:13 +00002125 POINT minTrack, maxTrack;
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002126 POINT capturePoint, pt;
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002127 WND * wndPtr = WIN_FindWndPtr( hwnd );
Ove Kaaven60c78f11999-07-03 15:40:29 +00002128 BOOL thickframe = HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle );
Alexandre Julliarda3960291999-02-26 11:11:13 +00002129 BOOL iconic = wndPtr->dwStyle & WS_MINIMIZE;
2130 BOOL moved = FALSE;
NF Stevens08aaa5d1998-10-22 11:35:04 +00002131 DWORD dwPoint = GetMessagePos ();
Dmitry Timoshkov9b1e1dc2000-08-14 17:20:25 +00002132 BOOL DragFullWindows = FALSE;
2133 int iWndsLocks;
2134
2135 SystemParametersInfoA(SPI_GETDRAGFULLWINDOWS, 0, &DragFullWindows, 0);
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002136
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002137 pt.x = SLOWORD(dwPoint);
2138 pt.y = SHIWORD(dwPoint);
2139 capturePoint = pt;
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00002140
Alexandre Julliarda3960291999-02-26 11:11:13 +00002141 if (IsZoomed(hwnd) || !IsWindowVisible(hwnd) ||
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002142 (wndPtr->flags & WIN_MANAGED)) goto END;
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002143
2144 if ((wParam & 0xfff0) == SC_MOVE)
2145 {
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002146 if (!hittest)
2147 hittest = NC_StartSizeMove( wndPtr, wParam, &capturePoint );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002148 if (!hittest) goto END;
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002149 }
2150 else /* SC_SIZE */
2151 {
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002152 if (!thickframe) goto END;
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002153 if ( hittest && hittest != HTSYSMENU ) hittest += 2;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002154 else
2155 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00002156 SetCapture(hwnd);
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002157 hittest = NC_StartSizeMove( wndPtr, wParam, &capturePoint );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002158 if (!hittest)
2159 {
2160 ReleaseCapture();
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002161 goto END;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002162 }
2163 }
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002164 }
2165
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002166 /* Get min/max info */
2167
Alexandre Julliard23946ad1997-06-16 17:43:53 +00002168 WINPOS_GetMinMaxInfo( wndPtr, NULL, NULL, &minTrack, &maxTrack );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002169 sizingRect = wndPtr->rectWindow;
Dmitry Timoshkov9b1e1dc2000-08-14 17:20:25 +00002170 origRect = sizingRect;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002171 if (wndPtr->dwStyle & WS_CHILD)
Alexandre Julliarda3960291999-02-26 11:11:13 +00002172 GetClientRect( wndPtr->parent->hwndSelf, &mouseRect );
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002173 else
Marcus Meissnerddca3151999-05-22 11:33:23 +00002174 SetRect(&mouseRect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002175 if (ON_LEFT_BORDER(hittest))
2176 {
Francois Gouget6d77d3a2000-03-25 21:44:35 +00002177 mouseRect.left = max( mouseRect.left, sizingRect.right-maxTrack.x );
2178 mouseRect.right = min( mouseRect.right, sizingRect.right-minTrack.x );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002179 }
2180 else if (ON_RIGHT_BORDER(hittest))
2181 {
Francois Gouget6d77d3a2000-03-25 21:44:35 +00002182 mouseRect.left = max( mouseRect.left, sizingRect.left+minTrack.x );
2183 mouseRect.right = min( mouseRect.right, sizingRect.left+maxTrack.x );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002184 }
2185 if (ON_TOP_BORDER(hittest))
2186 {
Francois Gouget6d77d3a2000-03-25 21:44:35 +00002187 mouseRect.top = max( mouseRect.top, sizingRect.bottom-maxTrack.y );
2188 mouseRect.bottom = min( mouseRect.bottom,sizingRect.bottom-minTrack.y);
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002189 }
2190 else if (ON_BOTTOM_BORDER(hittest))
2191 {
Francois Gouget6d77d3a2000-03-25 21:44:35 +00002192 mouseRect.top = max( mouseRect.top, sizingRect.top+minTrack.y );
2193 mouseRect.bottom = min( mouseRect.bottom, sizingRect.top+maxTrack.y );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002194 }
NF Stevens08aaa5d1998-10-22 11:35:04 +00002195 if (wndPtr->dwStyle & WS_CHILD)
2196 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00002197 MapWindowPoints( wndPtr->parent->hwndSelf, 0,
2198 (LPPOINT)&mouseRect, 2 );
NF Stevens08aaa5d1998-10-22 11:35:04 +00002199 }
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002200 SendMessageA( hwnd, WM_ENTERSIZEMOVE, 0, 0 );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002201
Alexandre Julliarda3960291999-02-26 11:11:13 +00002202 if (GetCapture() != hwnd) SetCapture( hwnd );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002203
Alexandre Julliard3ed37e01994-11-07 18:20:42 +00002204 if (wndPtr->dwStyle & WS_CHILD)
2205 {
2206 /* Retrieve a default cache DC (without using the window style) */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002207 hdc = GetDCEx( wndPtr->parent->hwndSelf, 0, DCX_CACHE );
Alexandre Julliard3ed37e01994-11-07 18:20:42 +00002208 }
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002209 else
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00002210 { /* Grab the server only when moving top-level windows without desktop */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002211 hdc = GetDC( 0 );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002212 }
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002213
Patrik Stridvalle35d6361998-12-07 09:13:40 +00002214 wndPtr->pDriver->pPreSizeMove(wndPtr);
2215
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002216 if( iconic ) /* create a cursor for dragging */
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002217 {
Gerard Patel5773dad1999-06-12 14:45:56 +00002218 HICON16 hIcon = GetClassWord(wndPtr->hwndSelf, GCW_HICON);
2219 if(!hIcon) hIcon = (HICON16) SendMessage16( hwnd, WM_QUERYDRAGICON, 0, 0L);
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002220 if( hIcon ) hDragCursor = CURSORICON_IconToCursor( hIcon, TRUE );
2221 if( !hDragCursor ) iconic = FALSE;
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002222 }
2223
Chris Morgan36219642000-05-14 23:43:29 +00002224 /* invert frame if WIN31_LOOK to indicate mouse click on caption */
2225 if( !iconic && TWEAK_WineLook == WIN31_LOOK )
Dmitry Timoshkov9b1e1dc2000-08-14 17:20:25 +00002226 if(!DragFullWindows)
Chris Morgan36219642000-05-14 23:43:29 +00002227 NC_DrawMovingFrame( hdc, &sizingRect, thickframe );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002228
2229 while(1)
2230 {
Alexandre Julliard7d654eb1996-02-25 11:36:22 +00002231 int dx = 0, dy = 0;
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002232
Ulrich Weigand2faf2cf1999-12-10 03:47:13 +00002233 MSG_InternalGetMessage( QMSG_WIN32A, &msg, 0, 0, MSGF_SIZE, PM_REMOVE, FALSE, NULL );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002234
2235 /* Exit on button-up, Return, or Esc */
2236 if ((msg.message == WM_LBUTTONUP) ||
2237 ((msg.message == WM_KEYDOWN) &&
2238 ((msg.wParam == VK_RETURN) || (msg.wParam == VK_ESCAPE)))) break;
2239
Alexandre Julliardc192ba22000-05-29 21:25:10 +00002240 if (msg.message == WM_PAINT)
2241 {
Dmitry Timoshkov9b1e1dc2000-08-14 17:20:25 +00002242 if(!iconic && !DragFullWindows) NC_DrawMovingFrame( hdc, &sizingRect, thickframe );
Alexandre Julliardc192ba22000-05-29 21:25:10 +00002243 UpdateWindow( msg.hwnd );
Dmitry Timoshkov9b1e1dc2000-08-14 17:20:25 +00002244 if(!iconic && !DragFullWindows) NC_DrawMovingFrame( hdc, &sizingRect, thickframe );
Alexandre Julliardc192ba22000-05-29 21:25:10 +00002245 continue;
2246 }
Dmitry Timoshkov9b1e1dc2000-08-14 17:20:25 +00002247
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002248 if ((msg.message != WM_KEYDOWN) && (msg.message != WM_MOUSEMOVE))
2249 continue; /* We are not interested in other messages */
2250
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002251 pt = msg.pt;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002252
2253 if (msg.message == WM_KEYDOWN) switch(msg.wParam)
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002254 {
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002255 case VK_UP: pt.y -= 8; break;
2256 case VK_DOWN: pt.y += 8; break;
2257 case VK_LEFT: pt.x -= 8; break;
2258 case VK_RIGHT: pt.x += 8; break;
2259 }
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002260
Francois Gouget6d77d3a2000-03-25 21:44:35 +00002261 pt.x = max( pt.x, mouseRect.left );
2262 pt.x = min( pt.x, mouseRect.right );
2263 pt.y = max( pt.y, mouseRect.top );
2264 pt.y = min( pt.y, mouseRect.bottom );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002265
2266 dx = pt.x - capturePoint.x;
2267 dy = pt.y - capturePoint.y;
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002268
2269 if (dx || dy)
2270 {
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002271 if( !moved )
2272 {
2273 moved = TRUE;
Chris Morgan36219642000-05-14 23:43:29 +00002274
2275 if( iconic ) /* ok, no system popup tracking */
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002276 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00002277 hOldCursor = SetCursor(hDragCursor);
2278 ShowCursor( TRUE );
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002279 WINPOS_ShowIconTitle( wndPtr, FALSE );
Chris Morgan36219642000-05-14 23:43:29 +00002280 } else if(TWEAK_WineLook != WIN31_LOOK)
2281 {
Dmitry Timoshkov9b1e1dc2000-08-14 17:20:25 +00002282 if(!DragFullWindows)
Chris Morgan36219642000-05-14 23:43:29 +00002283 NC_DrawMovingFrame( hdc, &sizingRect, thickframe );
2284 }
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002285 }
2286
Alexandre Julliarda3960291999-02-26 11:11:13 +00002287 if (msg.message == WM_KEYDOWN) SetCursorPos( pt.x, pt.y );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002288 else
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002289 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00002290 RECT newRect = sizingRect;
Aric Stewart44675502000-05-05 18:28:10 +00002291 WPARAM wpSizingHit = 0;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002292
Alexandre Julliarda3960291999-02-26 11:11:13 +00002293 if (hittest == HTCAPTION) OffsetRect( &newRect, dx, dy );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002294 if (ON_LEFT_BORDER(hittest)) newRect.left += dx;
2295 else if (ON_RIGHT_BORDER(hittest)) newRect.right += dx;
2296 if (ON_TOP_BORDER(hittest)) newRect.top += dy;
2297 else if (ON_BOTTOM_BORDER(hittest)) newRect.bottom += dy;
Dmitry Timoshkov9b1e1dc2000-08-14 17:20:25 +00002298 if(!iconic && !DragFullWindows) NC_DrawMovingFrame( hdc, &sizingRect, thickframe );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002299 capturePoint = pt;
Aric Stewart44675502000-05-05 18:28:10 +00002300
2301 /* determine the hit location */
2302 if (hittest >= HTLEFT && hittest <= HTBOTTOMRIGHT)
2303 wpSizingHit = WMSZ_LEFT + (hittest - HTLEFT);
2304 SendMessageA( hwnd, WM_SIZING, wpSizingHit, (LPARAM)&newRect );
2305
Dmitry Timoshkov9b1e1dc2000-08-14 17:20:25 +00002306 if (!iconic)
2307 {
2308 if(!DragFullWindows)
2309 NC_DrawMovingFrame( hdc, &newRect, thickframe );
2310 else {
2311 /* To avoid any deadlocks, all the locks on the windows
2312 structures must be suspended before the SetWindowPos */
2313 iWndsLocks = WIN_SuspendWndsLock();
2314 SetWindowPos( hwnd, 0, newRect.left, newRect.top,
2315 newRect.right - newRect.left,
2316 newRect.bottom - newRect.top,
2317 ( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 );
2318 WIN_RestoreWndsLock(iWndsLocks);
2319 }
2320 }
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002321 sizingRect = newRect;
2322 }
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002323 }
2324 }
2325
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002326 ReleaseCapture();
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002327 if( iconic )
2328 {
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002329 if( moved ) /* restore cursors, show icon title later on */
2330 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00002331 ShowCursor( FALSE );
2332 SetCursor( hOldCursor );
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002333 }
Alexandre Julliarda3960291999-02-26 11:11:13 +00002334 DestroyCursor( hDragCursor );
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002335 }
Chris Morgan36219642000-05-14 23:43:29 +00002336 else if(moved || TWEAK_WineLook == WIN31_LOOK)
Dmitry Timoshkov9b1e1dc2000-08-14 17:20:25 +00002337 if(!DragFullWindows)
Chris Morgan36219642000-05-14 23:43:29 +00002338 NC_DrawMovingFrame( hdc, &sizingRect, thickframe );
Alexandre Julliard7d654eb1996-02-25 11:36:22 +00002339
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00002340 if (wndPtr->dwStyle & WS_CHILD)
Alexandre Julliarda3960291999-02-26 11:11:13 +00002341 ReleaseDC( wndPtr->parent->hwndSelf, hdc );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002342 else
Chris Morgan36219642000-05-14 23:43:29 +00002343 ReleaseDC( 0, hdc );
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00002344
Patrik Stridvalle35d6361998-12-07 09:13:40 +00002345 wndPtr->pDriver->pPostSizeMove(wndPtr);
2346
Alexandre Julliard7e6ae4b1996-12-08 19:25:27 +00002347 if (HOOK_IsHooked( WH_CBT ))
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00002348 {
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002349 RECT16* pr = SEGPTR_NEW(RECT16);
2350 if( pr )
2351 {
2352 CONV_RECT32TO16( &sizingRect, pr );
2353 if( HOOK_CallHooks16( WH_CBT, HCBT_MOVESIZE, hwnd,
Alexandre Julliard7e6ae4b1996-12-08 19:25:27 +00002354 (LPARAM)SEGPTR_GET(pr)) )
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002355 sizingRect = wndPtr->rectWindow;
2356 else
2357 CONV_RECT16TO32( pr, &sizingRect );
2358 SEGPTR_FREE(pr);
2359 }
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00002360 }
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002361 SendMessageA( hwnd, WM_EXITSIZEMOVE, 0, 0 );
2362 SendMessageA( hwnd, WM_SETVISIBLE, !IsIconic16(hwnd), 0L);
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002363
Noomen Hamzac01509c1999-07-04 15:54:11 +00002364 /* window moved or resized */
2365 if (moved)
Alexandre Julliard7d654eb1996-02-25 11:36:22 +00002366 {
Dmitry Timoshkov9b1e1dc2000-08-14 17:20:25 +00002367 /* To avoid any deadlocks, all the locks on the windows
2368 structures must be suspended before the SetWindowPos */
2369 iWndsLocks = WIN_SuspendWndsLock();
2370
Noomen Hamzac01509c1999-07-04 15:54:11 +00002371 /* if the moving/resizing isn't canceled call SetWindowPos
2372 * with the new position or the new size of the window
2373 */
2374 if (!((msg.message == WM_KEYDOWN) && (msg.wParam == VK_ESCAPE)) )
2375 {
Alexandre Julliard23946ad1997-06-16 17:43:53 +00002376 /* NOTE: SWP_NOACTIVATE prevents document window activation in Word 6 */
Dmitry Timoshkov9b1e1dc2000-08-14 17:20:25 +00002377 if(!DragFullWindows)
Alexandre Julliarda3960291999-02-26 11:11:13 +00002378 SetWindowPos( hwnd, 0, sizingRect.left, sizingRect.top,
Alexandre Julliard23946ad1997-06-16 17:43:53 +00002379 sizingRect.right - sizingRect.left,
2380 sizingRect.bottom - sizingRect.top,
2381 ( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 );
Noomen Hamzac01509c1999-07-04 15:54:11 +00002382 }
Dmitry Timoshkov9b1e1dc2000-08-14 17:20:25 +00002383 else { /* restore previous size/position */
2384 if(DragFullWindows)
2385 SetWindowPos( hwnd, 0, origRect.left, origRect.top,
2386 origRect.right - origRect.left,
2387 origRect.bottom - origRect.top,
2388 ( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 );
2389 }
2390
2391 WIN_RestoreWndsLock(iWndsLocks);
Alexandre Julliard23946ad1997-06-16 17:43:53 +00002392 }
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002393
Alexandre Julliarda3960291999-02-26 11:11:13 +00002394 if( IsWindow(hwnd) )
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002395 if( wndPtr->dwStyle & WS_MINIMIZE )
2396 {
2397 /* Single click brings up the system menu when iconized */
2398
2399 if( !moved )
2400 {
2401 if( wndPtr->dwStyle & WS_SYSMENU )
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002402 SendMessageA( hwnd, WM_SYSCOMMAND,
2403 SC_MOUSEMENU + HTSYSMENU, MAKELONG(pt.x,pt.y));
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002404 }
2405 else WINPOS_ShowIconTitle( wndPtr, TRUE );
2406 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002407
2408END:
2409 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002410}
2411
2412
2413/***********************************************************************
Pascal Lessardd814bb61999-07-31 13:02:02 +00002414 * NC_TrackMinMaxBox95
2415 *
2416 * Track a mouse button press on the minimize or maximize box.
2417 *
2418 * The big difference between 3.1 and 95 is the disabled button state.
2419 * In win95 the system button can be disabled, so it can ignore the mouse
2420 * event.
2421 *
2422 */
2423static void NC_TrackMinMaxBox95( HWND hwnd, WORD wParam )
2424{
2425 MSG msg;
Pascal Lessardd814bb61999-07-31 13:02:02 +00002426 HDC hdc = GetWindowDC( hwnd );
2427 BOOL pressed = TRUE;
2428 UINT state;
2429 DWORD wndStyle = GetWindowLongA( hwnd, GWL_STYLE);
2430 HMENU hSysMenu = GetSystemMenu(hwnd, FALSE);
2431
2432 void (*paintButton)(HWND, HDC16, BOOL, BOOL);
2433
2434 if (wParam == HTMINBUTTON)
2435 {
2436 /* If the style is not present, do nothing */
2437 if (!(wndStyle & WS_MINIMIZEBOX))
2438 return;
2439
2440 /* Check if the sysmenu item for minimize is there */
2441 state = GetMenuState(hSysMenu, SC_MINIMIZE, MF_BYCOMMAND);
2442
2443 paintButton = &NC_DrawMinButton95;
2444 }
2445 else
2446 {
2447 /* If the style is not present, do nothing */
2448 if (!(wndStyle & WS_MAXIMIZEBOX))
2449 return;
2450
2451 /* Check if the sysmenu item for maximize is there */
2452 state = GetMenuState(hSysMenu, SC_MAXIMIZE, MF_BYCOMMAND);
2453
2454 paintButton = &NC_DrawMaxButton95;
2455 }
2456
2457 SetCapture( hwnd );
2458
2459 (*paintButton)( hwnd, hdc, TRUE, FALSE);
2460
2461 do
2462 {
2463 BOOL oldstate = pressed;
Ulrich Weigand2faf2cf1999-12-10 03:47:13 +00002464 MSG_InternalGetMessage( QMSG_WIN32A, &msg, 0, 0, 0, PM_REMOVE, FALSE, NULL );
Pascal Lessardd814bb61999-07-31 13:02:02 +00002465
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002466 pressed = (NC_HandleNCHitTest( hwnd, msg.pt ) == wParam);
Pascal Lessardd814bb61999-07-31 13:02:02 +00002467 if (pressed != oldstate)
2468 (*paintButton)( hwnd, hdc, pressed, FALSE);
2469 } while (msg.message != WM_LBUTTONUP);
2470
2471 (*paintButton)( hwnd, hdc, FALSE, FALSE);
2472
2473 ReleaseCapture();
2474 ReleaseDC( hwnd, hdc );
2475
2476 /* If the item minimize or maximize of the sysmenu are not there */
2477 /* or if the style is not present, do nothing */
2478 if ((!pressed) || (state == 0xFFFFFFFF))
2479 return;
2480
2481 if (wParam == HTMINBUTTON)
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002482 SendMessageA( hwnd, WM_SYSCOMMAND, SC_MINIMIZE, MAKELONG(msg.pt.x,msg.pt.y) );
Pascal Lessardd814bb61999-07-31 13:02:02 +00002483 else
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002484 SendMessageA( hwnd, WM_SYSCOMMAND,
2485 IsZoomed(hwnd) ? SC_RESTORE:SC_MAXIMIZE, MAKELONG(msg.pt.x,msg.pt.y) );
Pascal Lessardd814bb61999-07-31 13:02:02 +00002486}
2487
2488/***********************************************************************
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002489 * NC_TrackMinMaxBox
2490 *
2491 * Track a mouse button press on the minimize or maximize box.
2492 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002493static void NC_TrackMinMaxBox( HWND hwnd, WORD wParam )
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002494{
Alexandre Julliarda3960291999-02-26 11:11:13 +00002495 MSG msg;
Alexandre Julliarda3960291999-02-26 11:11:13 +00002496 HDC hdc = GetWindowDC( hwnd );
2497 BOOL pressed = TRUE;
2498 void (*paintButton)(HWND, HDC16, BOOL);
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002499
Alexandre Julliarda3960291999-02-26 11:11:13 +00002500 SetCapture( hwnd );
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002501
Pascal Lessardd814bb61999-07-31 13:02:02 +00002502 if (wParam == HTMINBUTTON)
2503 paintButton = &NC_DrawMinButton;
2504 else
2505 paintButton = &NC_DrawMaxButton;
2506
2507 (*paintButton)( hwnd, hdc, TRUE);
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002508
2509 do
2510 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00002511 BOOL oldstate = pressed;
Ulrich Weigand2faf2cf1999-12-10 03:47:13 +00002512 MSG_InternalGetMessage( QMSG_WIN32A, &msg, 0, 0, 0, PM_REMOVE, FALSE, NULL );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002513
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002514 pressed = (NC_HandleNCHitTest( hwnd, msg.pt ) == wParam);
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002515 if (pressed != oldstate)
Pascal Lessardd814bb61999-07-31 13:02:02 +00002516 (*paintButton)( hwnd, hdc, pressed);
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002517 } while (msg.message != WM_LBUTTONUP);
2518
Pascal Lessardd814bb61999-07-31 13:02:02 +00002519 (*paintButton)( hwnd, hdc, FALSE);
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002520
2521 ReleaseCapture();
Alexandre Julliarda3960291999-02-26 11:11:13 +00002522 ReleaseDC( hwnd, hdc );
Pascal Lessardd814bb61999-07-31 13:02:02 +00002523
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002524 if (!pressed) return;
2525
2526 if (wParam == HTMINBUTTON)
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002527 SendMessageA( hwnd, WM_SYSCOMMAND, SC_MINIMIZE, MAKELONG(msg.pt.x,msg.pt.y) );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002528 else
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002529 SendMessageA( hwnd, WM_SYSCOMMAND,
2530 IsZoomed(hwnd) ? SC_RESTORE:SC_MAXIMIZE, MAKELONG(msg.pt.x,msg.pt.y) );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002531}
2532
2533
2534/***********************************************************************
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00002535 * NC_TrackCloseButton95
2536 *
2537 * Track a mouse button press on the Win95 close button.
2538 */
2539static void
Alexandre Julliarda3960291999-02-26 11:11:13 +00002540NC_TrackCloseButton95 (HWND hwnd, WORD wParam)
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00002541{
Alexandre Julliarda3960291999-02-26 11:11:13 +00002542 MSG msg;
Pascal Lessardd814bb61999-07-31 13:02:02 +00002543 HDC hdc;
Alexandre Julliarda3960291999-02-26 11:11:13 +00002544 BOOL pressed = TRUE;
Pascal Lessardd814bb61999-07-31 13:02:02 +00002545 HMENU hSysMenu = GetSystemMenu(hwnd, FALSE);
2546 UINT state;
2547
2548 if(hSysMenu == 0)
2549 return;
2550
2551 state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
2552
2553 /* If the item close of the sysmenu is disabled or not there do nothing */
2554 if((state & MF_DISABLED) || (state & MF_GRAYED) || (state == 0xFFFFFFFF))
2555 return;
2556
2557 hdc = GetWindowDC( hwnd );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00002558
Alexandre Julliarda3960291999-02-26 11:11:13 +00002559 SetCapture( hwnd );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00002560
Pascal Lessardd814bb61999-07-31 13:02:02 +00002561 NC_DrawCloseButton95 (hwnd, hdc, TRUE, FALSE);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00002562
2563 do
2564 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00002565 BOOL oldstate = pressed;
Ulrich Weigand2faf2cf1999-12-10 03:47:13 +00002566 MSG_InternalGetMessage( QMSG_WIN32A, &msg, 0, 0, 0, PM_REMOVE, FALSE, NULL );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00002567
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002568 pressed = (NC_HandleNCHitTest( hwnd, msg.pt ) == wParam);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00002569 if (pressed != oldstate)
Pascal Lessardd814bb61999-07-31 13:02:02 +00002570 NC_DrawCloseButton95 (hwnd, hdc, pressed, FALSE);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00002571 } while (msg.message != WM_LBUTTONUP);
2572
Pascal Lessardd814bb61999-07-31 13:02:02 +00002573 NC_DrawCloseButton95 (hwnd, hdc, FALSE, FALSE);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00002574
2575 ReleaseCapture();
Alexandre Julliarda3960291999-02-26 11:11:13 +00002576 ReleaseDC( hwnd, hdc );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00002577 if (!pressed) return;
2578
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002579 SendMessageA( hwnd, WM_SYSCOMMAND, SC_CLOSE, MAKELONG(msg.pt.x,msg.pt.y) );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00002580}
2581
2582
2583/***********************************************************************
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002584 * NC_TrackScrollBar
2585 *
2586 * Track a mouse button press on the horizontal or vertical scroll-bar.
2587 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002588static void NC_TrackScrollBar( HWND hwnd, WPARAM wParam, POINT pt )
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002589{
Alexandre Julliardd90840e1996-06-11 16:02:08 +00002590 MSG16 *msg;
Alexandre Julliarda3960291999-02-26 11:11:13 +00002591 INT scrollbar;
Alexandre Julliardecc37121994-11-22 16:31:29 +00002592 WND *wndPtr = WIN_FindWndPtr( hwnd );
2593
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002594 if ((wParam & 0xfff0) == SC_HSCROLL)
2595 {
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002596 if ((wParam & 0x0f) != HTHSCROLL) goto END;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002597 scrollbar = SB_HORZ;
2598 }
2599 else /* SC_VSCROLL */
2600 {
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002601 if ((wParam & 0x0f) != HTVSCROLL) goto END;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002602 scrollbar = SB_VERT;
2603 }
2604
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002605 if (!(msg = SEGPTR_NEW(MSG16))) goto END;
Alexandre Julliardecc37121994-11-22 16:31:29 +00002606 pt.x -= wndPtr->rectWindow.left;
2607 pt.y -= wndPtr->rectWindow.top;
Alexandre Julliarda3960291999-02-26 11:11:13 +00002608 SetCapture( hwnd );
Alexandre Julliardecc37121994-11-22 16:31:29 +00002609 SCROLL_HandleScrollEvent( hwnd, scrollbar, WM_LBUTTONDOWN, pt );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002610
2611 do
2612 {
Alexandre Julliard21979011997-03-05 08:22:35 +00002613 GetMessage16( SEGPTR_GET(msg), 0, 0, 0 );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00002614 switch(msg->message)
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002615 {
2616 case WM_LBUTTONUP:
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002617 case WM_MOUSEMOVE:
Alexandre Julliardecc37121994-11-22 16:31:29 +00002618 case WM_SYSTIMER:
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00002619 pt.x = LOWORD(msg->lParam) + wndPtr->rectClient.left -
Alexandre Julliard902da691995-11-05 14:39:02 +00002620 wndPtr->rectWindow.left;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00002621 pt.y = HIWORD(msg->lParam) + wndPtr->rectClient.top -
Alexandre Julliard902da691995-11-05 14:39:02 +00002622 wndPtr->rectWindow.top;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00002623 SCROLL_HandleScrollEvent( hwnd, scrollbar, msg->message, pt );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002624 break;
Alexandre Julliardecc37121994-11-22 16:31:29 +00002625 default:
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00002626 TranslateMessage16( msg );
2627 DispatchMessage16( msg );
Alexandre Julliardecc37121994-11-22 16:31:29 +00002628 break;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002629 }
Alexandre Julliarda3960291999-02-26 11:11:13 +00002630 if (!IsWindow( hwnd ))
Alexandre Julliardecc37121994-11-22 16:31:29 +00002631 {
2632 ReleaseCapture();
2633 break;
2634 }
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00002635 } while (msg->message != WM_LBUTTONUP);
2636 SEGPTR_FREE(msg);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002637END:
2638 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002639}
2640
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002641/***********************************************************************
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002642 * NC_HandleNCLButtonDown
Alexandre Julliardcdd09231994-01-12 11:12:51 +00002643 *
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002644 * Handle a WM_NCLBUTTONDOWN message. Called from DefWindowProc().
Alexandre Julliardcdd09231994-01-12 11:12:51 +00002645 */
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002646LONG NC_HandleNCLButtonDown( WND* pWnd, WPARAM16 wParam, LPARAM lParam )
Alexandre Julliardcdd09231994-01-12 11:12:51 +00002647{
Alexandre Julliarda3960291999-02-26 11:11:13 +00002648 HWND hwnd = pWnd->hwndSelf;
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002649
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002650 switch(wParam) /* Hit test */
Alexandre Julliardcdd09231994-01-12 11:12:51 +00002651 {
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002652 case HTCAPTION:
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002653 hwnd = WIN_GetTopParent(hwnd);
Alexandre Julliard23946ad1997-06-16 17:43:53 +00002654
Alexandre Julliarda3960291999-02-26 11:11:13 +00002655 if( WINPOS_SetActiveWindow(hwnd, TRUE, TRUE) || (GetActiveWindow() == hwnd) )
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002656 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, lParam );
2657 break;
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002658
Alexandre Julliardcdd09231994-01-12 11:12:51 +00002659 case HTSYSMENU:
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002660 if( pWnd->dwStyle & WS_SYSMENU )
2661 {
2662 if( !(pWnd->dwStyle & WS_MINIMIZE) )
2663 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00002664 HDC hDC = GetWindowDC(hwnd);
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00002665 if (TWEAK_WineLook == WIN31_LOOK)
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002666 NC_DrawSysButton( hwnd, hDC, TRUE );
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00002667 else
2668 NC_DrawSysButton95( hwnd, hDC, TRUE );
Alexandre Julliarda3960291999-02-26 11:11:13 +00002669 ReleaseDC( hwnd, hDC );
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002670 }
2671 SendMessage16( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU + HTSYSMENU, lParam );
2672 }
2673 break;
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002674
2675 case HTMENU:
Alexandre Julliard2d93d001996-05-21 15:01:41 +00002676 SendMessage16( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU, lParam );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002677 break;
2678
2679 case HTHSCROLL:
Alexandre Julliard2d93d001996-05-21 15:01:41 +00002680 SendMessage16( hwnd, WM_SYSCOMMAND, SC_HSCROLL + HTHSCROLL, lParam );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002681 break;
2682
2683 case HTVSCROLL:
Alexandre Julliard2d93d001996-05-21 15:01:41 +00002684 SendMessage16( hwnd, WM_SYSCOMMAND, SC_VSCROLL + HTVSCROLL, lParam );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002685 break;
2686
2687 case HTMINBUTTON:
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002688 case HTMAXBUTTON:
Pascal Lessardd814bb61999-07-31 13:02:02 +00002689 if (TWEAK_WineLook == WIN31_LOOK)
2690 NC_TrackMinMaxBox( hwnd, wParam );
2691 else
2692 NC_TrackMinMaxBox95( hwnd, wParam );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002693 break;
2694
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00002695 case HTCLOSE:
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00002696 if (TWEAK_WineLook >= WIN95_LOOK)
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00002697 NC_TrackCloseButton95 (hwnd, wParam);
2698 break;
Pascal Lessardd814bb61999-07-31 13:02:02 +00002699
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002700 case HTLEFT:
2701 case HTRIGHT:
2702 case HTTOP:
2703 case HTTOPLEFT:
2704 case HTTOPRIGHT:
2705 case HTBOTTOM:
2706 case HTBOTTOMLEFT:
2707 case HTBOTTOMRIGHT:
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002708 /* make sure hittest fits into 0xf and doesn't overlap with HTSYSMENU */
2709 SendMessage16( hwnd, WM_SYSCOMMAND, SC_SIZE + wParam - 2, lParam);
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002710 break;
2711
2712 case HTBORDER:
2713 break;
2714 }
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002715 return 0;
2716}
2717
2718
2719/***********************************************************************
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002720 * NC_HandleNCLButtonDblClk
2721 *
2722 * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc().
2723 */
Alexandre Julliard530ee841996-10-23 16:59:13 +00002724LONG NC_HandleNCLButtonDblClk( WND *pWnd, WPARAM16 wParam, LPARAM lParam )
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002725{
Alexandre Julliard940d58c1994-09-16 09:24:37 +00002726 /*
2727 * if this is an icon, send a restore since we are handling
2728 * a double click
2729 */
Alexandre Julliard1285c2f1996-05-06 16:06:24 +00002730 if (pWnd->dwStyle & WS_MINIMIZE)
Alexandre Julliard940d58c1994-09-16 09:24:37 +00002731 {
Alexandre Julliard2d93d001996-05-21 15:01:41 +00002732 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND, SC_RESTORE, lParam );
Alexandre Julliard1285c2f1996-05-06 16:06:24 +00002733 return 0;
Alexandre Julliard940d58c1994-09-16 09:24:37 +00002734 }
2735
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002736 switch(wParam) /* Hit test */
2737 {
2738 case HTCAPTION:
Alexandre Julliard902da691995-11-05 14:39:02 +00002739 /* stop processing if WS_MAXIMIZEBOX is missing */
Alexandre Julliard1285c2f1996-05-06 16:06:24 +00002740 if (pWnd->dwStyle & WS_MAXIMIZEBOX)
Alexandre Julliard2d93d001996-05-21 15:01:41 +00002741 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND,
Alexandre Julliard1285c2f1996-05-06 16:06:24 +00002742 (pWnd->dwStyle & WS_MAXIMIZE) ? SC_RESTORE : SC_MAXIMIZE,
2743 lParam );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002744 break;
2745
2746 case HTSYSMENU:
Gerard Patel5773dad1999-06-12 14:45:56 +00002747 if (!(GetClassWord(pWnd->hwndSelf, GCW_STYLE) & CS_NOCLOSE))
Alexandre Julliard2d93d001996-05-21 15:01:41 +00002748 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND, SC_CLOSE, lParam );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00002749 break;
Alexandre Julliard491502b1997-11-01 19:08:16 +00002750
2751 case HTHSCROLL:
2752 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND, SC_HSCROLL + HTHSCROLL,
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002753 lParam );
Alexandre Julliard491502b1997-11-01 19:08:16 +00002754 break;
2755
2756 case HTVSCROLL:
2757 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND, SC_VSCROLL + HTVSCROLL,
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002758 lParam );
Alexandre Julliard491502b1997-11-01 19:08:16 +00002759 break;
Alexandre Julliardcdd09231994-01-12 11:12:51 +00002760 }
2761 return 0;
2762}
2763
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002764
2765/***********************************************************************
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002766 * NC_HandleSysCommand
2767 *
2768 * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
2769 */
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002770LONG NC_HandleSysCommand( HWND hwnd, WPARAM wParam, POINT pt )
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002771{
2772 WND *wndPtr = WIN_FindWndPtr( hwnd );
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002773 UINT16 uCommand = wParam & 0xFFF0;
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002774
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002775 TRACE("Handling WM_SYSCOMMAND %x %ld,%ld\n", wParam, pt.x, pt.y );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002776
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002777 if (wndPtr->dwStyle & WS_CHILD && uCommand != SC_KEYMENU )
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002778 ScreenToClient( wndPtr->parent->hwndSelf, &pt );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002779
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002780 switch (uCommand)
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002781 {
2782 case SC_SIZE:
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002783 case SC_MOVE:
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00002784 NC_DoSizeMove( hwnd, wParam );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002785 break;
2786
2787 case SC_MINIMIZE:
Noomen Hamzad1a1f7d1999-10-24 00:02:27 +00002788 if (hwnd == GetForegroundWindow())
2789 ShowOwnedPopups(hwnd,FALSE);
Alexandre Julliarda3960291999-02-26 11:11:13 +00002790 ShowWindow( hwnd, SW_MINIMIZE );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002791 break;
2792
2793 case SC_MAXIMIZE:
Noomen Hamzad1a1f7d1999-10-24 00:02:27 +00002794 if (IsIconic(hwnd) && hwnd == GetForegroundWindow())
2795 ShowOwnedPopups(hwnd,TRUE);
Alexandre Julliarda3960291999-02-26 11:11:13 +00002796 ShowWindow( hwnd, SW_MAXIMIZE );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002797 break;
2798
2799 case SC_RESTORE:
Noomen Hamzad1a1f7d1999-10-24 00:02:27 +00002800 if (IsIconic(hwnd) && hwnd == GetForegroundWindow())
2801 ShowOwnedPopups(hwnd,TRUE);
Alexandre Julliarda3960291999-02-26 11:11:13 +00002802 ShowWindow( hwnd, SW_RESTORE );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002803 break;
2804
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002805 case SC_CLOSE:
Francois Boisvert3a3cd9f1999-03-28 12:42:52 +00002806 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002807 return SendMessageA( hwnd, WM_CLOSE, 0, 0 );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002808
2809 case SC_VSCROLL:
2810 case SC_HSCROLL:
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002811 NC_TrackScrollBar( hwnd, wParam, pt );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002812 break;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002813
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002814 case SC_MOUSEMENU:
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002815 MENU_TrackMouseMenuBar( wndPtr, wParam & 0x000F, pt );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002816 break;
2817
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002818 case SC_KEYMENU:
Alexandre Julliardc981d0b1996-03-31 16:40:13 +00002819 MENU_TrackKbdMenuBar( wndPtr , wParam , pt.x );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002820 break;
2821
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002822 case SC_TASKLIST:
Alexandre Julliarda3960291999-02-26 11:11:13 +00002823 WinExec( "taskman.exe", SW_SHOWNORMAL );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002824 break;
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +00002825
2826 case SC_SCREENSAVE:
2827 if (wParam == SC_ABOUTWINE)
Alexandre Julliard563561e2000-01-24 05:46:47 +00002828 {
2829 HMODULE hmodule = LoadLibraryA( "shell32.dll" );
2830 if (hmodule)
2831 {
2832 FARPROC aboutproc = GetProcAddress( hmodule, "ShellAboutA" );
2833 if (aboutproc) aboutproc( hwnd, "Wine", WINE_RELEASE_INFO, 0 );
2834 FreeLibrary( hmodule );
2835 }
2836 }
Uwe Bonnes37007771998-11-01 15:07:24 +00002837 else
2838 if (wParam == SC_PUTMARK)
Alexandre Julliard06c275a1999-05-02 14:32:27 +00002839 TRACE_(shell)("Mark requested by user\n");
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +00002840 break;
Alexandre Julliard9ea19e51997-01-01 17:29:55 +00002841
2842 case SC_HOTKEY:
2843 case SC_ARRANGE:
2844 case SC_NEXTWINDOW:
2845 case SC_PREVWINDOW:
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +00002846 FIXME("unimplemented!\n");
Alexandre Julliard9ea19e51997-01-01 17:29:55 +00002847 break;
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002848 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002849 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002850 return 0;
2851}
Pascal Lessardd814bb61999-07-31 13:02:02 +00002852
2853/*************************************************************
2854* NC_DrawGrayButton
2855*
2856* Stub for the grayed button of the caption
2857*
2858*************************************************************/
2859
2860BOOL NC_DrawGrayButton(HDC hdc, int x, int y)
2861{
2862 HBITMAP hMaskBmp;
2863 HDC hdcMask = CreateCompatibleDC (0);
2864 HBRUSH hOldBrush;
2865
2866 hMaskBmp = CreateBitmap (12, 10, 1, 1, lpGrayMask);
2867
2868 if(hMaskBmp == 0)
2869 return FALSE;
2870
2871 SelectObject (hdcMask, hMaskBmp);
2872
2873 /* Draw the grayed bitmap using the mask */
2874 hOldBrush = SelectObject (hdc, RGB(128, 128, 128));
2875 BitBlt (hdc, x, y, 12, 10,
2876 hdcMask, 0, 0, 0xB8074A);
2877
2878 /* Clean up */
2879 SelectObject (hdc, hOldBrush);
2880 DeleteObject(hMaskBmp);
2881 DeleteDC (hdcMask);
2882
2883 return TRUE;
2884}
Susan Farley9ce83822000-05-23 04:12:23 +00002885
2886HICON16 NC_IconForWindow(WND *wndPtr)
2887{
2888 HICON16 hIcon = (HICON) GetClassLongA(wndPtr->hwndSelf, GCL_HICONSM);
2889 if(!hIcon) hIcon = (HICON) GetClassLongA(wndPtr->hwndSelf, GCL_HICON);
2890
2891 /* If there is no hIcon specified and this is a modal dialog, */
2892 /* get the default one. */
2893 if (!hIcon && (wndPtr->dwStyle & DS_MODALFRAME))
2894 hIcon = LoadImageA(0, MAKEINTRESOURCEA(OIC_WINEICON), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
2895
2896 return hIcon;
2897}