blob: 1ed679f378ee0f9e58be4ee4950b2ae2b9793d11 [file] [log] [blame]
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001/*
2 * Non-client area window functions
3 *
4 * Copyright 1994 Alexandre Julliard
Alexandre Julliard234bc241994-12-10 13:02:28 +00005 *
Alexandre Julliard7cbe6571995-01-09 18:21:16 +00006 */
Alexandre Julliardcdd09231994-01-12 11:12:51 +00007
Jeremy Whited3e22d92000-02-10 19:03:02 +00008#include "windef.h"
9#include "wingdi.h"
Michael Veksler9d14a001999-05-08 12:40:24 +000010#include "wine/winuser16.h"
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +000011#include "version.h"
Alexandre Julliardcdd09231994-01-12 11:12:51 +000012#include "win.h"
Alexandre Julliarddba420a1994-02-02 06:48:31 +000013#include "user.h"
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +000014#include "heap.h"
Alex Korobka4f1ac051999-03-28 09:37:57 +000015#include "dce.h"
Alexandre Julliard91222da2000-12-10 23:01:33 +000016#include "controls.h"
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000017#include "cursoricon.h"
Alexandre Julliard234bc241994-12-10 13:02:28 +000018#include "winpos.h"
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +000019#include "hook.h"
Alexandre Julliard234bc241994-12-10 13:02:28 +000020#include "nonclient.h"
Alexandre Julliard06c275a1999-05-02 14:32:27 +000021#include "debugtools.h"
Marcus Meissner317af321999-02-17 13:51:06 +000022#include "shellapi.h"
Pascal Lessardd814bb61999-07-31 13:02:02 +000023#include "bitmap.h"
Alexandre Julliardcdd09231994-01-12 11:12:51 +000024
Dimitrie O. Paun529da542000-11-27 23:54:25 +000025DEFAULT_DEBUG_CHANNEL(nonclient);
26DECLARE_DEBUG_CHANNEL(shell);
Patrik Stridvallb4b9fae1999-04-19 14:56:29 +000027
Pascal Lessardd814bb61999-07-31 13:02:02 +000028BOOL NC_DrawGrayButton(HDC hdc, int x, int y);
29
Alexandre Julliardc1d35cc2001-01-24 19:47:57 +000030static HBITMAP hbitmapClose;
31static HBITMAP hbitmapMinimize;
32static HBITMAP hbitmapMinimizeD;
33static HBITMAP hbitmapMaximize;
34static HBITMAP hbitmapMaximizeD;
35static HBITMAP hbitmapRestore;
36static HBITMAP hbitmapRestoreD;
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +000037
Alexandre Julliardc1d35cc2001-01-24 19:47:57 +000038static const BYTE lpGrayMask[] = { 0xAA, 0xA0,
Pascal Lessardd814bb61999-07-31 13:02:02 +000039 0x55, 0x50,
40 0xAA, 0xA0,
41 0x55, 0x50,
42 0xAA, 0xA0,
43 0x55, 0x50,
44 0xAA, 0xA0,
45 0x55, 0x50,
46 0xAA, 0xA0,
47 0x55, 0x50};
48
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +000049#define SC_ABOUTWINE (SC_SCREENSAVE+1)
Uwe Bonnes37007771998-11-01 15:07:24 +000050#define SC_PUTMARK (SC_SCREENSAVE+2)
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +000051
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +000052 /* Some useful macros */
53#define HAS_DLGFRAME(style,exStyle) \
Alexandre Julliard0c126c71996-02-18 18:44:41 +000054 (((exStyle) & WS_EX_DLGMODALFRAME) || \
Ove Kaaven60c78f11999-07-03 15:40:29 +000055 (((style) & WS_DLGFRAME) && !((style) & WS_THICKFRAME)))
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +000056
Ove Kaaven60c78f11999-07-03 15:40:29 +000057#define HAS_THICKFRAME(style,exStyle) \
Alexandre Julliard0c126c71996-02-18 18:44:41 +000058 (((style) & WS_THICKFRAME) && \
Abey George48c6eb51999-09-03 12:33:40 +000059 !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +000060
Ove Kaaven60c78f11999-07-03 15:40:29 +000061#define HAS_THINFRAME(style) \
62 (((style) & WS_BORDER) || !((style) & (WS_CHILD | WS_POPUP)))
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000063
Ove Kaaven60c78f11999-07-03 15:40:29 +000064#define HAS_BIGFRAME(style,exStyle) \
65 (((style) & (WS_THICKFRAME | WS_DLGFRAME)) || \
66 ((exStyle) & WS_EX_DLGMODALFRAME))
Gerard Patel5773dad1999-06-12 14:45:56 +000067
Bill Medlandcbfbf2a2001-07-20 18:36:49 +000068#define HAS_STATICOUTERFRAME(style,exStyle) \
69 (((exStyle) & (WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME)) == \
70 WS_EX_STATICEDGE)
71
Ove Kaaven60c78f11999-07-03 15:40:29 +000072#define HAS_ANYFRAME(style,exStyle) \
73 (((style) & (WS_THICKFRAME | WS_DLGFRAME | WS_BORDER)) || \
74 ((exStyle) & WS_EX_DLGMODALFRAME) || \
75 !((style) & (WS_CHILD | WS_POPUP)))
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000076
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +000077#define HAS_MENU(w) (!((w)->dwStyle & WS_CHILD) && ((w)->wIDmenu != 0))
78
Sylvain St-Germain00bf3811999-07-24 12:11:22 +000079
80/***********************************************************************
Alexandre Julliardcdd09231994-01-12 11:12:51 +000081 * NC_AdjustRect
82 *
83 * Compute the size of the window rectangle from the size of the
84 * client rectangle.
85 */
Alexandre Julliard3abeae82001-05-09 17:21:04 +000086static void NC_AdjustRect( LPRECT rect, DWORD style, BOOL menu, DWORD exStyle )
Alexandre Julliardcdd09231994-01-12 11:12:51 +000087{
Alexandre Julliardd30dfd21998-09-27 18:28:36 +000088 if (TWEAK_WineLook > WIN31_LOOK)
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +000089 ERR("Called in Win95 mode. Aiee! Please report this.\n" );
Alexandre Julliardd37eb361997-07-20 16:23:21 +000090
Alexandre Julliardbf9130a1996-10-13 17:45:47 +000091 if(style & WS_ICONIC) return;
Alexandre Julliard0c126c71996-02-18 18:44:41 +000092
Alexandre Julliarddc4fe772001-06-04 21:55:17 +000093 if (HAS_THICKFRAME( style, exStyle ))
94 InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
95 else if (HAS_DLGFRAME( style, exStyle ))
96 InflateRect( rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
97 else if (HAS_THINFRAME( style ))
98 InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
99
100 if ((style & WS_CAPTION) == WS_CAPTION)
101 rect->top -= GetSystemMetrics(SM_CYCAPTION) - GetSystemMetrics(SM_CYBORDER);
102
Marcus Meissnerddca3151999-05-22 11:33:23 +0000103 if (menu) rect->top -= GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CYBORDER);
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000104
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000105 if (style & WS_VSCROLL) {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000106 rect->right += GetSystemMetrics(SM_CXVSCROLL) - 1;
Ove Kaaven60c78f11999-07-03 15:40:29 +0000107 if(!HAS_ANYFRAME( style, exStyle ))
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000108 rect->right++;
109 }
110
111 if (style & WS_HSCROLL) {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000112 rect->bottom += GetSystemMetrics(SM_CYHSCROLL) - 1;
Ove Kaaven60c78f11999-07-03 15:40:29 +0000113 if(!HAS_ANYFRAME( style, exStyle ))
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000114 rect->bottom++;
115 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000116}
117
118
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000119/******************************************************************************
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000120 * NC_AdjustRectOuter95
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000121 *
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000122 * Computes the size of the "outside" parts of the window based on the
123 * parameters of the client area.
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000124 *
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000125 + PARAMS
126 * LPRECT16 rect
127 * DWORD style
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000128 * BOOL menu
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000129 * DWORD exStyle
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000130 *
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000131 * NOTES
132 * "Outer" parts of a window means the whole window frame, caption and
133 * menu bar. It does not include "inner" parts of the frame like client
134 * edge, static edge or scroll bars.
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000135 *
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000136 * Revision history
137 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
138 * Original (NC_AdjustRect95) cut & paste from NC_AdjustRect
139 *
140 * 20-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
141 * Split NC_AdjustRect95 into NC_AdjustRectOuter95 and
142 * NC_AdjustRectInner95 and added handling of Win95 styles.
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000143 *
Ove Kaaven60c78f11999-07-03 15:40:29 +0000144 * 28-Jul-1999 Ove KÃ¥ven (ovek@arcticnet.no)
145 * Streamlined window style checks.
146 *
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000147 *****************************************************************************/
148
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000149static void
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000150NC_AdjustRectOuter95 (LPRECT rect, DWORD style, BOOL menu, DWORD exStyle)
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000151{
Bill Medlandcbfbf2a2001-07-20 18:36:49 +0000152 int adjust;
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000153 if(style & WS_ICONIC) return;
154
Bill Medlandcbfbf2a2001-07-20 18:36:49 +0000155 if ((exStyle & (WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME)) ==
156 WS_EX_STATICEDGE)
157 {
158 adjust = 1; /* for the outer frame always present */
159 }
160 else
161 {
162 adjust = 0;
163 if ((exStyle & WS_EX_DLGMODALFRAME) ||
164 (style & (WS_THICKFRAME|WS_DLGFRAME))) adjust = 2; /* outer */
165 }
166 if (style & WS_THICKFRAME)
167 adjust += ( GetSystemMetrics (SM_CXFRAME)
168 - GetSystemMetrics (SM_CXDLGFRAME)); /* The resize border */
169 if ((style & (WS_BORDER|WS_DLGFRAME)) ||
170 (exStyle & WS_EX_DLGMODALFRAME))
171 adjust++; /* The other border */
172
173 InflateRect (rect, adjust, adjust);
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000174
175 if ((style & WS_CAPTION) == WS_CAPTION)
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000176 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000177 if (exStyle & WS_EX_TOOLWINDOW)
178 rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
Ove Kaaven60c78f11999-07-03 15:40:29 +0000179 else
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000180 rect->top -= GetSystemMetrics(SM_CYCAPTION);
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000181 }
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000182 if (menu) rect->top -= GetSystemMetrics(SM_CYMENU);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000183}
184
185
186/******************************************************************************
187 * NC_AdjustRectInner95
188 *
189 * Computes the size of the "inside" part of the window based on the
190 * parameters of the client area.
191 *
192 + PARAMS
193 * LPRECT16 rect
194 * DWORD style
195 * DWORD exStyle
196 *
197 * NOTES
198 * "Inner" part of a window means the window frame inside of the flat
199 * window frame. It includes the client edge, the static edge and the
200 * scroll bars.
201 *
202 * Revision history
203 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
204 * Original (NC_AdjustRect95) cut & paste from NC_AdjustRect
205 *
206 * 20-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
207 * Split NC_AdjustRect95 into NC_AdjustRectOuter95 and
208 * NC_AdjustRectInner95 and added handling of Win95 styles.
209 *
210 *****************************************************************************/
211
212static void
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000213NC_AdjustRectInner95 (LPRECT rect, DWORD style, DWORD exStyle)
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000214{
215 if(style & WS_ICONIC) return;
216
217 if (exStyle & WS_EX_CLIENTEDGE)
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000218 InflateRect(rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000219
Marcus Meissnerddca3151999-05-22 11:33:23 +0000220 if (style & WS_VSCROLL) rect->right += GetSystemMetrics(SM_CXVSCROLL);
221 if (style & WS_HSCROLL) rect->bottom += GetSystemMetrics(SM_CYHSCROLL);
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000222}
223
224
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000225
226static HICON NC_IconForWindow( HWND hwnd )
227{
228 HICON hIcon = (HICON) GetClassLongA( hwnd, GCL_HICONSM );
229 if (!hIcon) hIcon = (HICON) GetClassLongA( hwnd, GCL_HICON );
230
231 /* If there is no hIcon specified and this is a modal dialog,
232 * get the default one.
233 */
234 if (!hIcon && (GetWindowLongA( hwnd, GWL_STYLE ) & DS_MODALFRAME))
235 hIcon = LoadImageA(0, IDI_WINLOGOA, IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
236 return hIcon;
237}
238
Alexandre Julliarde658d821997-11-30 17:45:40 +0000239/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000240 * DrawCaption (USER32.@) Draws a caption bar
Eric Kohl8e517b51998-10-11 13:06:35 +0000241 *
242 * PARAMS
243 * hwnd [I]
244 * hdc [I]
245 * lpRect [I]
246 * uFlags [I]
247 *
Eric Kohld0b79c01998-10-24 10:45:42 +0000248 * RETURNS
249 * Success:
250 * Failure:
Eric Kohl8e517b51998-10-11 13:06:35 +0000251 */
252
Alexandre Julliarda3960291999-02-26 11:11:13 +0000253BOOL WINAPI
254DrawCaption (HWND hwnd, HDC hdc, const RECT *lpRect, UINT uFlags)
Eric Kohl8e517b51998-10-11 13:06:35 +0000255{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000256 return DrawCaptionTempA (hwnd, hdc, lpRect, 0, 0, NULL, uFlags & 0x1F);
Eric Kohl8e517b51998-10-11 13:06:35 +0000257}
258
259
260/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000261 * DrawCaptionTempA (USER32.@)
Eric Kohl8e517b51998-10-11 13:06:35 +0000262 *
Eric Kohld0b79c01998-10-24 10:45:42 +0000263 * PARAMS
264 *
265 * RETURNS
266 * Success:
267 * Failure:
Eric Kohl8e517b51998-10-11 13:06:35 +0000268 */
269
Alexandre Julliarda3960291999-02-26 11:11:13 +0000270BOOL WINAPI
271DrawCaptionTempA (HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont,
272 HICON hIcon, LPCSTR str, UINT uFlags)
Eric Kohl8e517b51998-10-11 13:06:35 +0000273{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000274 RECT rc = *rect;
Eric Kohl8e517b51998-10-11 13:06:35 +0000275
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +0000276 TRACE("(%08x,%08x,%p,%08x,%08x,\"%s\",%08x)\n",
277 hwnd, hdc, rect, hFont, hIcon, str, uFlags);
Eric Kohl8e517b51998-10-11 13:06:35 +0000278
279 /* drawing background */
280 if (uFlags & DC_INBUTTON) {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000281 FillRect (hdc, &rc, GetSysColorBrush (COLOR_3DFACE));
Eric Kohl8e517b51998-10-11 13:06:35 +0000282
283 if (uFlags & DC_ACTIVE) {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000284 HBRUSH hbr = SelectObject (hdc, CACHE_GetPattern55AABrush ());
285 PatBlt (hdc, rc.left, rc.top,
Eric Kohl8e517b51998-10-11 13:06:35 +0000286 rc.right-rc.left, rc.bottom-rc.top, 0xFA0089);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000287 SelectObject (hdc, hbr);
Eric Kohl8e517b51998-10-11 13:06:35 +0000288 }
289 }
290 else {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000291 FillRect (hdc, &rc, GetSysColorBrush ((uFlags & DC_ACTIVE) ?
Eric Kohl8e517b51998-10-11 13:06:35 +0000292 COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION));
293 }
294
295
296 /* drawing icon */
297 if ((uFlags & DC_ICON) && !(uFlags & DC_SMALLCAP)) {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000298 POINT pt;
Eric Kohl8e517b51998-10-11 13:06:35 +0000299
300 pt.x = rc.left + 2;
Marcus Meissnerddca3151999-05-22 11:33:23 +0000301 pt.y = (rc.bottom + rc.top - GetSystemMetrics(SM_CYSMICON)) / 2;
Eric Kohl8e517b51998-10-11 13:06:35 +0000302
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000303 if (!hIcon) hIcon = NC_IconForWindow(hwnd);
304 DrawIconEx (hdc, pt.x, pt.y, hIcon, GetSystemMetrics(SM_CXSMICON),
305 GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL);
Eric Kohl8e517b51998-10-11 13:06:35 +0000306 rc.left += (rc.bottom - rc.top);
307 }
308
309 /* drawing text */
310 if (uFlags & DC_TEXT) {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000311 HFONT hOldFont;
Eric Kohl8e517b51998-10-11 13:06:35 +0000312
313 if (uFlags & DC_INBUTTON)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000314 SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
Eric Kohl8e517b51998-10-11 13:06:35 +0000315 else if (uFlags & DC_ACTIVE)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000316 SetTextColor (hdc, GetSysColor (COLOR_CAPTIONTEXT));
Eric Kohl8e517b51998-10-11 13:06:35 +0000317 else
Alexandre Julliarda3960291999-02-26 11:11:13 +0000318 SetTextColor (hdc, GetSysColor (COLOR_INACTIVECAPTIONTEXT));
Eric Kohl8e517b51998-10-11 13:06:35 +0000319
Alexandre Julliarda3960291999-02-26 11:11:13 +0000320 SetBkMode (hdc, TRANSPARENT);
Eric Kohl8e517b51998-10-11 13:06:35 +0000321
322 if (hFont)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000323 hOldFont = SelectObject (hdc, hFont);
Eric Kohl8e517b51998-10-11 13:06:35 +0000324 else {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000325 NONCLIENTMETRICSA nclm;
326 HFONT hNewFont;
327 nclm.cbSize = sizeof(NONCLIENTMETRICSA);
328 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
329 hNewFont = CreateFontIndirectA ((uFlags & DC_SMALLCAP) ?
Eric Kohl8e517b51998-10-11 13:06:35 +0000330 &nclm.lfSmCaptionFont : &nclm.lfCaptionFont);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000331 hOldFont = SelectObject (hdc, hNewFont);
Eric Kohl8e517b51998-10-11 13:06:35 +0000332 }
333
334 if (str)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000335 DrawTextA (hdc, str, -1, &rc,
Eric Kohl8e517b51998-10-11 13:06:35 +0000336 DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT);
337 else {
338 CHAR szText[128];
Alexandre Julliarda3960291999-02-26 11:11:13 +0000339 INT nLen;
340 nLen = GetWindowTextA (hwnd, szText, 128);
341 DrawTextA (hdc, szText, nLen, &rc,
Eric Kohl8e517b51998-10-11 13:06:35 +0000342 DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT);
343 }
344
345 if (hFont)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000346 SelectObject (hdc, hOldFont);
Eric Kohl8e517b51998-10-11 13:06:35 +0000347 else
Alexandre Julliarda3960291999-02-26 11:11:13 +0000348 DeleteObject (SelectObject (hdc, hOldFont));
Eric Kohl8e517b51998-10-11 13:06:35 +0000349 }
350
351 /* drawing focus ??? */
352 if (uFlags & 0x2000)
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +0000353 FIXME("undocumented flag (0x2000)!\n");
Eric Kohl8e517b51998-10-11 13:06:35 +0000354
355 return 0;
356}
357
358
359/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000360 * DrawCaptionTempW (USER32.@)
Eric Kohl8e517b51998-10-11 13:06:35 +0000361 *
Eric Kohld0b79c01998-10-24 10:45:42 +0000362 * PARAMS
363 *
364 * RETURNS
365 * Success:
366 * Failure:
Eric Kohl8e517b51998-10-11 13:06:35 +0000367 */
368
Alexandre Julliarda3960291999-02-26 11:11:13 +0000369BOOL WINAPI
370DrawCaptionTempW (HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont,
371 HICON hIcon, LPCWSTR str, UINT uFlags)
Eric Kohl8e517b51998-10-11 13:06:35 +0000372{
373 LPSTR p = HEAP_strdupWtoA (GetProcessHeap (), 0, str);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000374 BOOL res = DrawCaptionTempA (hwnd, hdc, rect, hFont, hIcon, p, uFlags);
Eric Kohl8e517b51998-10-11 13:06:35 +0000375 HeapFree (GetProcessHeap (), 0, p);
376 return res;
377}
378
379
380/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000381 * AdjustWindowRect (USER.102)
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000382 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000383BOOL16 WINAPI AdjustWindowRect16( LPRECT16 rect, DWORD style, BOOL16 menu )
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000384{
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000385 return AdjustWindowRectEx16( rect, style, menu, 0 );
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000386}
387
388
389/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000390 * AdjustWindowRect (USER32.@)
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000391 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000392BOOL WINAPI AdjustWindowRect( LPRECT rect, DWORD style, BOOL menu )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000393{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000394 return AdjustWindowRectEx( rect, style, menu, 0 );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000395}
396
397
398/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000399 * AdjustWindowRectEx (USER.454)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000400 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000401BOOL16 WINAPI AdjustWindowRectEx16( LPRECT16 rect, DWORD style,
402 BOOL16 menu, DWORD exStyle )
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000403{
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000404 RECT rect32;
405 BOOL ret;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000406
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000407 CONV_RECT16TO32( rect, &rect32 );
408 ret = AdjustWindowRectEx( &rect32, style, menu, exStyle );
409 CONV_RECT32TO16( &rect32, rect );
410 return ret;
411}
412
413
414/***********************************************************************
415 * AdjustWindowRectEx (USER32.@)
416 */
417BOOL WINAPI AdjustWindowRectEx( LPRECT rect, DWORD style, BOOL menu, DWORD exStyle )
418{
419 /* Correct the window style */
420
421 if (!(style & (WS_POPUP | WS_CHILD))) style |= WS_CAPTION; /* Overlapped window */
Alexandre Julliard84c70f51997-05-09 08:40:27 +0000422 style &= (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME | WS_CHILD);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000423 exStyle &= (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE |
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000424 WS_EX_STATICEDGE | WS_EX_TOOLWINDOW);
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000425 if (exStyle & WS_EX_DLGMODALFRAME) style &= ~WS_THICKFRAME;
426
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +0000427 TRACE("(%d,%d)-(%d,%d) %08lx %d %08lx\n",
428 rect->left, rect->top, rect->right, rect->bottom,
429 style, menu, exStyle );
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000430
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000431 if (TWEAK_WineLook == WIN31_LOOK)
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000432 NC_AdjustRect( rect, style, menu, exStyle );
433 else
434 {
435 NC_AdjustRectOuter95( rect, style, menu, exStyle );
436 NC_AdjustRectInner95( rect, style, exStyle );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000437 }
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000438 return TRUE;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000439}
440
441
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000442/***********************************************************************
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000443 * NC_HandleNCCalcSize
444 *
445 * Handle a WM_NCCALCSIZE message. Called from DefWindowProc().
446 */
Alexandre Julliardde424282001-08-10 22:51:42 +0000447LONG NC_HandleNCCalcSize( HWND hwnd, RECT *winRect )
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000448{
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000449 RECT tmpRect = { 0, 0, 0, 0 };
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +0000450 LONG result = 0;
Alexandre Julliardde424282001-08-10 22:51:42 +0000451 LONG cls_style = GetClassLongA(hwnd, GCL_STYLE);
452 LONG style = GetWindowLongA( hwnd, GWL_STYLE );
453 LONG exStyle = GetWindowLongA( hwnd, GWL_EXSTYLE );
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +0000454
Alexandre Julliardde424282001-08-10 22:51:42 +0000455 if (cls_style & CS_VREDRAW) result |= WVR_VREDRAW;
456 if (cls_style & CS_HREDRAW) result |= WVR_HREDRAW;
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000457
Alexandre Julliardde424282001-08-10 22:51:42 +0000458 if (!IsIconic(hwnd))
459 {
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000460 if (TWEAK_WineLook == WIN31_LOOK)
Alexandre Julliardde424282001-08-10 22:51:42 +0000461 NC_AdjustRect( &tmpRect, style, FALSE, exStyle );
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000462 else
Alexandre Julliardde424282001-08-10 22:51:42 +0000463 NC_AdjustRectOuter95( &tmpRect, style, FALSE, exStyle );
Alexandre Julliard1e37a181996-08-18 16:21:52 +0000464
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000465 winRect->left -= tmpRect.left;
466 winRect->top -= tmpRect.top;
467 winRect->right -= tmpRect.right;
468 winRect->bottom -= tmpRect.bottom;
469
Alexandre Julliardde424282001-08-10 22:51:42 +0000470 if (!(style & WS_CHILD) && GetMenu(hwnd))
471 {
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +0000472 TRACE("Calling GetMenuBarHeight with HWND 0x%x, width %d, "
Alexandre Julliardde424282001-08-10 22:51:42 +0000473 "at (%d, %d).\n", hwnd,
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +0000474 winRect->right - winRect->left,
475 -tmpRect.left, -tmpRect.top );
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000476
477 winRect->top +=
Alexandre Julliardde424282001-08-10 22:51:42 +0000478 MENU_GetMenuBarHeight( hwnd,
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000479 winRect->right - winRect->left,
480 -tmpRect.left, -tmpRect.top ) + 1;
481 }
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000482
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000483 if (TWEAK_WineLook > WIN31_LOOK) {
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000484 SetRect(&tmpRect, 0, 0, 0, 0);
Alexandre Julliardde424282001-08-10 22:51:42 +0000485 NC_AdjustRectInner95 (&tmpRect, style, exStyle);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000486 winRect->left -= tmpRect.left;
487 winRect->top -= tmpRect.top;
488 winRect->right -= tmpRect.right;
489 winRect->bottom -= tmpRect.bottom;
490 }
Mike McCormacka2bdade2000-09-12 23:37:57 +0000491
492 if (winRect->top > winRect->bottom)
493 winRect->bottom = winRect->top;
494
495 if (winRect->left > winRect->right)
496 winRect->right = winRect->left;
Alexandre Julliard2d159fb1994-07-15 16:04:31 +0000497 }
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +0000498 return result;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000499}
500
501
502/***********************************************************************
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000503 * NC_GetInsideRect
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000504 *
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000505 * Get the 'inside' rectangle of a window, i.e. the whole window rectangle
506 * but without the borders (if any).
507 * The rectangle is in window coordinates (for drawing with GetWindowDC()).
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000508 */
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000509void NC_GetInsideRect( HWND hwnd, RECT *rect )
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000510{
511 WND * wndPtr = WIN_FindWndPtr( hwnd );
512
513 rect->top = rect->left = 0;
514 rect->right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
515 rect->bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
516
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000517 if (wndPtr->dwStyle & WS_ICONIC) goto END;
Alexandre Julliard3ed37e01994-11-07 18:20:42 +0000518
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000519 /* Remove frame from rectangle */
Ove Kaaven60c78f11999-07-03 15:40:29 +0000520 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000521 {
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000522 InflateRect( rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) );
523 }
524 else if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
525 {
526 InflateRect( rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
527 /* FIXME: this isn't in NC_AdjustRect? why not? */
528 if ((TWEAK_WineLook == WIN31_LOOK) && (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME))
Alexandre Julliarda3960291999-02-26 11:11:13 +0000529 InflateRect( rect, -1, 0 );
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000530 }
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000531 else if (HAS_THINFRAME( wndPtr->dwStyle ))
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000532 {
Ove Kaaven60c78f11999-07-03 15:40:29 +0000533 InflateRect( rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER) );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000534 }
535
Francis Beaudet1cc0a9a1999-09-03 15:00:45 +0000536 /* We have additional border information if the window
537 * is a child (but not an MDI child) */
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000538 if (TWEAK_WineLook != WIN31_LOOK)
539 {
540 if ( (wndPtr->dwStyle & WS_CHILD) &&
541 ( (wndPtr->dwExStyle & WS_EX_MDICHILD) == 0 ) )
542 {
543 if (wndPtr->dwExStyle & WS_EX_CLIENTEDGE)
544 InflateRect (rect, -GetSystemMetrics(SM_CXEDGE), -GetSystemMetrics(SM_CYEDGE));
545 if (wndPtr->dwExStyle & WS_EX_STATICEDGE)
546 InflateRect (rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
547 }
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000548 }
Alexandre Julliard3abeae82001-05-09 17:21:04 +0000549
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000550END:
551 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000552 return;
553}
554
555
556/***********************************************************************
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000557 * NC_DoNCHitTest
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000558 *
Andreas Mohr260f1a12000-09-22 20:59:29 +0000559 * Handle a WM_NCHITTEST message. Called from NC_HandleNCHitTest().
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000560 */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000561
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000562static LONG NC_DoNCHitTest (WND *wndPtr, POINT pt )
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000563{
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000564 RECT rect;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000565
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000566 TRACE("hwnd=%04x pt=%ld,%ld\n", wndPtr->hwndSelf, pt.x, pt.y );
Alexandre Julliard940d58c1994-09-16 09:24:37 +0000567
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000568 GetWindowRect(wndPtr->hwndSelf, &rect );
569 if (!PtInRect( &rect, pt )) return HTNOWHERE;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000570
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000571 if (wndPtr->dwStyle & WS_MINIMIZE) return HTCAPTION;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000572
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000573 /* Check borders */
574 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000575 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000576 InflateRect( &rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) );
577 if (!PtInRect( &rect, pt ))
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000578 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000579 /* Check top sizing border */
580 if (pt.y < rect.top)
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000581 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000582 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTTOPLEFT;
583 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTTOPRIGHT;
584 return HTTOP;
585 }
586 /* Check bottom sizing border */
587 if (pt.y >= rect.bottom)
588 {
589 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMLEFT;
590 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMRIGHT;
591 return HTBOTTOM;
592 }
593 /* Check left sizing border */
594 if (pt.x < rect.left)
595 {
596 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPLEFT;
597 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMLEFT;
598 return HTLEFT;
599 }
600 /* Check right sizing border */
601 if (pt.x >= rect.right)
602 {
603 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPRIGHT;
604 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMRIGHT;
605 return HTRIGHT;
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000606 }
607 }
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000608 }
609 else /* No thick frame */
610 {
611 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
612 InflateRect(&rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
613 else if (HAS_THINFRAME( wndPtr->dwStyle ))
614 InflateRect(&rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
615 if (!PtInRect( &rect, pt )) return HTBORDER;
616 }
617
618 /* Check caption */
619
620 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
621 {
622 rect.top += GetSystemMetrics(SM_CYCAPTION) - GetSystemMetrics(SM_CYBORDER);
623 if (!PtInRect( &rect, pt ))
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000624 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000625 /* Check system menu */
626 if ((wndPtr->dwStyle & WS_SYSMENU) && !(wndPtr->dwExStyle & WS_EX_TOOLWINDOW))
627 rect.left += GetSystemMetrics(SM_CXSIZE);
628 if (pt.x <= rect.left) return HTSYSMENU;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000629
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000630 /* Check maximize box */
631 if (wndPtr->dwStyle & WS_MAXIMIZEBOX)
632 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
Alexandre Julliardf7207251994-07-23 07:57:48 +0000633
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000634 if (pt.x >= rect.right) return HTMAXBUTTON;
635 /* Check minimize box */
636 if (wndPtr->dwStyle & WS_MINIMIZEBOX)
637 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
638 if (pt.x >= rect.right) return HTMINBUTTON;
639 return HTCAPTION;
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000640 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000641 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000642
Alexandre Julliardf7207251994-07-23 07:57:48 +0000643 /* Check client area */
644
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000645 ScreenToClient( wndPtr->hwndSelf, &pt );
646 GetClientRect( wndPtr->hwndSelf, &rect );
647 if (PtInRect( &rect, pt )) return HTCLIENT;
Alexandre Julliardf7207251994-07-23 07:57:48 +0000648
649 /* Check vertical scroll bar */
650
651 if (wndPtr->dwStyle & WS_VSCROLL)
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000652 {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000653 rect.right += GetSystemMetrics(SM_CXVSCROLL);
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000654 if (PtInRect( &rect, pt )) return HTVSCROLL;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000655 }
656
Alexandre Julliardf7207251994-07-23 07:57:48 +0000657 /* Check horizontal scroll bar */
658
659 if (wndPtr->dwStyle & WS_HSCROLL)
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000660 {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000661 rect.bottom += GetSystemMetrics(SM_CYHSCROLL);
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000662 if (PtInRect( &rect, pt ))
Alexandre Julliardf7207251994-07-23 07:57:48 +0000663 {
664 /* Check size box */
665 if ((wndPtr->dwStyle & WS_VSCROLL) &&
Marcus Meissnerddca3151999-05-22 11:33:23 +0000666 (pt.x >= rect.right - GetSystemMetrics(SM_CXVSCROLL)))
Alexandre Julliardf7207251994-07-23 07:57:48 +0000667 return HTSIZE;
668 return HTHSCROLL;
669 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000670 }
671
Alexandre Julliardf7207251994-07-23 07:57:48 +0000672 /* Check menu bar */
673
674 if (HAS_MENU(wndPtr))
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000675 {
Alexandre Julliardf7207251994-07-23 07:57:48 +0000676 if ((pt.y < 0) && (pt.x >= 0) && (pt.x < rect.right))
677 return HTMENU;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000678 }
679
Francois Boisvert5538ec42000-07-29 00:00:29 +0000680 /* Has to return HTNOWHERE if nothing was found
681 Could happen when a window has a customized non client area */
682 return HTNOWHERE;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000683}
684
685
686/***********************************************************************
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000687 * NC_DoNCHitTest95
688 *
689 * Handle a WM_NCHITTEST message. Called from NC_HandleNCHitTest().
690 *
Alexandre Julliard829fe321998-07-26 14:27:39 +0000691 * FIXME: Just a modified copy of the Win 3.1 version.
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000692 */
693
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000694static LONG NC_DoNCHitTest95 (WND *wndPtr, POINT pt )
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000695{
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000696 RECT rect;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000697
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000698 TRACE("hwnd=%04x pt=%ld,%ld\n", wndPtr->hwndSelf, pt.x, pt.y );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000699
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000700 GetWindowRect(wndPtr->hwndSelf, &rect );
701 if (!PtInRect( &rect, pt )) return HTNOWHERE;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000702
703 if (wndPtr->dwStyle & WS_MINIMIZE) return HTCAPTION;
704
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000705 /* Check borders */
706 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000707 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000708 InflateRect( &rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) );
709 if (!PtInRect( &rect, pt ))
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000710 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000711 /* Check top sizing border */
712 if (pt.y < rect.top)
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000713 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000714 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTTOPLEFT;
715 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTTOPRIGHT;
716 return HTTOP;
717 }
718 /* Check bottom sizing border */
719 if (pt.y >= rect.bottom)
720 {
721 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMLEFT;
722 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMRIGHT;
723 return HTBOTTOM;
724 }
725 /* Check left sizing border */
726 if (pt.x < rect.left)
727 {
728 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPLEFT;
729 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMLEFT;
730 return HTLEFT;
731 }
732 /* Check right sizing border */
733 if (pt.x >= rect.right)
734 {
735 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPRIGHT;
736 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMRIGHT;
737 return HTRIGHT;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000738 }
739 }
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000740 }
741 else /* No thick frame */
742 {
743 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
744 InflateRect(&rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
745 else if (HAS_THINFRAME( wndPtr->dwStyle ))
746 InflateRect(&rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
747 if (!PtInRect( &rect, pt )) return HTBORDER;
748 }
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000749
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000750 /* Check caption */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000751
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000752 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
753 {
754 if (wndPtr->dwExStyle & WS_EX_TOOLWINDOW)
755 rect.top += GetSystemMetrics(SM_CYSMCAPTION) - 1;
756 else
757 rect.top += GetSystemMetrics(SM_CYCAPTION) - 1;
758 if (!PtInRect( &rect, pt ))
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000759 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000760 /* Check system menu */
761 if ((wndPtr->dwStyle & WS_SYSMENU) && !(wndPtr->dwExStyle & WS_EX_TOOLWINDOW))
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000762 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000763 if (NC_IconForWindow(wndPtr->hwndSelf))
764 rect.left += GetSystemMetrics(SM_CYCAPTION) - 1;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000765 }
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000766 if (pt.x < rect.left) return HTSYSMENU;
767
768 /* Check close button */
769 if (wndPtr->dwStyle & WS_SYSMENU)
770 rect.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
771 if (pt.x > rect.right) return HTCLOSE;
772
773 /* Check maximize box */
774 /* In win95 there is automatically a Maximize button when there is a minimize one*/
775 if ((wndPtr->dwStyle & WS_MAXIMIZEBOX)|| (wndPtr->dwStyle & WS_MINIMIZEBOX))
776 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
777 if (pt.x > rect.right) return HTMAXBUTTON;
778
779 /* Check minimize box */
780 /* In win95 there is automatically a Maximize button when there is a Maximize one*/
781 if ((wndPtr->dwStyle & WS_MINIMIZEBOX)||(wndPtr->dwStyle & WS_MAXIMIZEBOX))
782 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
783
784 if (pt.x > rect.right) return HTMINBUTTON;
785 return HTCAPTION;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000786 }
787 }
788
789 /* Check client area */
790
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000791 ScreenToClient( wndPtr->hwndSelf, &pt );
792 GetClientRect( wndPtr->hwndSelf, &rect );
793 if (PtInRect( &rect, pt )) return HTCLIENT;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000794
795 /* Check vertical scroll bar */
796
797 if (wndPtr->dwStyle & WS_VSCROLL)
798 {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000799 rect.right += GetSystemMetrics(SM_CXVSCROLL);
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000800 if (PtInRect( &rect, pt )) return HTVSCROLL;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000801 }
802
803 /* Check horizontal scroll bar */
804
805 if (wndPtr->dwStyle & WS_HSCROLL)
806 {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000807 rect.bottom += GetSystemMetrics(SM_CYHSCROLL);
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000808 if (PtInRect( &rect, pt ))
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000809 {
810 /* Check size box */
811 if ((wndPtr->dwStyle & WS_VSCROLL) &&
Marcus Meissnerddca3151999-05-22 11:33:23 +0000812 (pt.x >= rect.right - GetSystemMetrics(SM_CXVSCROLL)))
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000813 return HTSIZE;
814 return HTHSCROLL;
815 }
816 }
817
818 /* Check menu bar */
819
820 if (HAS_MENU(wndPtr))
821 {
822 if ((pt.y < 0) && (pt.x >= 0) && (pt.x < rect.right))
823 return HTMENU;
824 }
825
Francois Boisvert5538ec42000-07-29 00:00:29 +0000826 /* Has to return HTNOWHERE if nothing was found
827 Could happen when a window has a customized non client area */
828 return HTNOWHERE;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000829}
830
831
832/***********************************************************************
833 * NC_HandleNCHitTest
834 *
835 * Handle a WM_NCHITTEST message. Called from DefWindowProc().
836 */
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000837LONG NC_HandleNCHitTest (HWND hwnd , POINT pt)
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000838{
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000839 LONG retvalue;
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000840 WND *wndPtr = WIN_FindWndPtr (hwnd);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000841
842 if (!wndPtr)
843 return HTERROR;
844
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000845 if (TWEAK_WineLook == WIN31_LOOK)
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000846 retvalue = NC_DoNCHitTest (wndPtr, pt);
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000847 else
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000848 retvalue = NC_DoNCHitTest95 (wndPtr, pt);
849 WIN_ReleaseWndPtr(wndPtr);
850 return retvalue;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000851}
852
853
854/***********************************************************************
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000855 * NC_DrawSysButton
856 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000857void NC_DrawSysButton( HWND hwnd, HDC hdc, BOOL down )
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000858{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000859 RECT rect;
860 HDC hdcMem;
861 HBITMAP hbitmap;
Alexandre Julliard7cbe6571995-01-09 18:21:16 +0000862
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000863 NC_GetInsideRect( hwnd, &rect );
864 hdcMem = CreateCompatibleDC( hdc );
865 hbitmap = SelectObject( hdcMem, hbitmapClose );
866 BitBlt(hdc, rect.left, rect.top, GetSystemMetrics(SM_CXSIZE), GetSystemMetrics(SM_CYSIZE),
867 hdcMem, (GetWindowLongA(hwnd,GWL_STYLE) & WS_CHILD) ? GetSystemMetrics(SM_CXSIZE) : 0, 0,
868 down ? NOTSRCCOPY : SRCCOPY );
869 SelectObject( hdcMem, hbitmap );
870 DeleteDC( hdcMem );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000871}
872
873
874/***********************************************************************
875 * NC_DrawMaxButton
876 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000877static void NC_DrawMaxButton( HWND hwnd, HDC16 hdc, BOOL down )
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000878{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000879 RECT rect;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000880 HDC hdcMem;
Alexandre Julliard1e37a181996-08-18 16:21:52 +0000881
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000882 NC_GetInsideRect( hwnd, &rect );
883 hdcMem = CreateCompatibleDC( hdc );
884 SelectObject( hdcMem, (IsZoomed(hwnd)
885 ? (down ? hbitmapRestoreD : hbitmapRestore)
886 : (down ? hbitmapMaximizeD : hbitmapMaximize)) );
887 BitBlt( hdc, rect.right - GetSystemMetrics(SM_CXSIZE) - 1, rect.top,
888 GetSystemMetrics(SM_CXSIZE) + 1, GetSystemMetrics(SM_CYSIZE), hdcMem, 0, 0,
889 SRCCOPY );
890 DeleteDC( hdcMem );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000891
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000892}
893
894
895/***********************************************************************
896 * NC_DrawMinButton
897 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000898static void NC_DrawMinButton( HWND hwnd, HDC16 hdc, BOOL down )
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000899{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000900 RECT rect;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000901 HDC hdcMem;
Alexandre Julliard1e37a181996-08-18 16:21:52 +0000902
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000903 NC_GetInsideRect( hwnd, &rect );
904 hdcMem = CreateCompatibleDC( hdc );
905 SelectObject( hdcMem, (down ? hbitmapMinimizeD : hbitmapMinimize) );
906 if (GetWindowLongA(hwnd,GWL_STYLE) & WS_MAXIMIZEBOX)
907 rect.right -= GetSystemMetrics(SM_CXSIZE)+1;
908 BitBlt( hdc, rect.right - GetSystemMetrics(SM_CXSIZE) - 1, rect.top,
909 GetSystemMetrics(SM_CXSIZE) + 1, GetSystemMetrics(SM_CYSIZE), hdcMem, 0, 0,
910 SRCCOPY );
911 DeleteDC( hdcMem );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000912}
913
914
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000915/******************************************************************************
916 *
917 * void NC_DrawSysButton95(
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000918 * HWND hwnd,
919 * HDC hdc,
920 * BOOL down )
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000921 *
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000922 * Draws the Win95 system icon.
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000923 *
924 * Revision history
925 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
926 * Original implementation from NC_DrawSysButton source.
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000927 * 11-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
928 * Fixed most bugs.
929 *
930 *****************************************************************************/
931
Alexandre Julliarda3960291999-02-26 11:11:13 +0000932BOOL
933NC_DrawSysButton95 (HWND hwnd, HDC hdc, BOOL down)
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000934{
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000935 HICON hIcon = NC_IconForWindow( hwnd );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000936
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000937 if (hIcon)
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000938 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000939 RECT rect;
940 NC_GetInsideRect( hwnd, &rect );
941 DrawIconEx (hdc, rect.left + 2, rect.top + 2, hIcon,
942 GetSystemMetrics(SM_CXSMICON),
943 GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000944 }
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000945 return (hIcon != 0);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000946}
947
948
949/******************************************************************************
950 *
951 * void NC_DrawCloseButton95(
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000952 * HWND hwnd,
953 * HDC hdc,
954 * BOOL down,
Pascal Lessardd814bb61999-07-31 13:02:02 +0000955 * BOOL bGrayed )
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000956 *
957 * Draws the Win95 close button.
958 *
Pascal Lessardd814bb61999-07-31 13:02:02 +0000959 * If bGrayed is true, then draw a disabled Close button
960 *
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000961 * Revision history
962 * 11-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
963 * Original implementation from NC_DrawSysButton95 source.
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000964 *
965 *****************************************************************************/
966
Pascal Lessardd814bb61999-07-31 13:02:02 +0000967static void NC_DrawCloseButton95 (HWND hwnd, HDC hdc, BOOL down, BOOL bGrayed)
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000968{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000969 RECT rect;
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000970
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000971 NC_GetInsideRect( hwnd, &rect );
972
973 /* A tool window has a smaller Close button */
974 if (GetWindowLongA( hwnd, GWL_EXSTYLE ) & WS_EX_TOOLWINDOW)
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000975 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000976 INT iBmpHeight = 11; /* Windows does not use SM_CXSMSIZE and SM_CYSMSIZE */
977 INT iBmpWidth = 11; /* it uses 11x11 for the close button in tool window */
978 INT iCaptionHeight = GetSystemMetrics(SM_CYSMCAPTION);
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000979
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000980 rect.top = rect.top + (iCaptionHeight - 1 - iBmpHeight) / 2;
981 rect.left = rect.right - (iCaptionHeight + 1 + iBmpWidth) / 2;
982 rect.bottom = rect.top + iBmpHeight;
983 rect.right = rect.left + iBmpWidth;
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000984 }
Alexandre Julliarddc4fe772001-06-04 21:55:17 +0000985 else
986 {
987 rect.left = rect.right - GetSystemMetrics(SM_CXSIZE) - 1;
988 rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) - 1;
989 rect.top += 2;
990 rect.right -= 2;
991 }
992 DrawFrameControl( hdc, &rect, DFC_CAPTION,
993 (DFCS_CAPTIONCLOSE |
994 (down ? DFCS_PUSHED : 0) |
995 (bGrayed ? DFCS_INACTIVE : 0)) );
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000996}
997
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000998/******************************************************************************
Alexandre Julliardc1d35cc2001-01-24 19:47:57 +0000999 * NC_DrawMaxButton95
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001000 *
1001 * Draws the maximize button for Win95 style windows.
Pascal Lessardd814bb61999-07-31 13:02:02 +00001002 * If bGrayed is true, then draw a disabled Maximize button
Alexandre Julliardc1d35cc2001-01-24 19:47:57 +00001003 */
Pascal Lessardd814bb61999-07-31 13:02:02 +00001004static void NC_DrawMaxButton95(HWND hwnd,HDC16 hdc,BOOL down, BOOL bGrayed)
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001005{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001006 RECT rect;
Alexandre Julliarddc4fe772001-06-04 21:55:17 +00001007 UINT flags = IsZoomed(hwnd) ? DFCS_CAPTIONRESTORE : DFCS_CAPTIONMAX;
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001008
Alexandre Julliarddc4fe772001-06-04 21:55:17 +00001009 NC_GetInsideRect( hwnd, &rect );
1010 if (GetWindowLongA( hwnd, GWL_STYLE) & WS_SYSMENU)
1011 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1012 rect.left = rect.right - GetSystemMetrics(SM_CXSIZE);
1013 rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) - 1;
1014 rect.top += 2;
1015 rect.right -= 2;
1016 if (down) flags |= DFCS_PUSHED;
1017 if (bGrayed) flags |= DFCS_INACTIVE;
1018 DrawFrameControl( hdc, &rect, DFC_CAPTION, flags );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001019}
1020
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001021/******************************************************************************
Alexandre Julliardc1d35cc2001-01-24 19:47:57 +00001022 * NC_DrawMinButton95
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001023 *
1024 * Draws the minimize button for Win95 style windows.
Pascal Lessardd814bb61999-07-31 13:02:02 +00001025 * If bGrayed is true, then draw a disabled Minimize button
Alexandre Julliardc1d35cc2001-01-24 19:47:57 +00001026 */
Pascal Lessardd814bb61999-07-31 13:02:02 +00001027static void NC_DrawMinButton95(HWND hwnd,HDC16 hdc,BOOL down, BOOL bGrayed)
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001028{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001029 RECT rect;
Alexandre Julliarddc4fe772001-06-04 21:55:17 +00001030 UINT flags = DFCS_CAPTIONMIN;
1031 DWORD style = GetWindowLongA( hwnd, GWL_STYLE );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001032
Alexandre Julliarddc4fe772001-06-04 21:55:17 +00001033 NC_GetInsideRect( hwnd, &rect );
1034 if (style & WS_SYSMENU)
1035 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1036 if (style & (WS_MAXIMIZEBOX|WS_MINIMIZEBOX))
1037 rect.right -= GetSystemMetrics(SM_CXSIZE) - 2;
1038 rect.left = rect.right - GetSystemMetrics(SM_CXSIZE);
1039 rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) - 1;
1040 rect.top += 2;
1041 rect.right -= 2;
1042 if (down) flags |= DFCS_PUSHED;
1043 if (bGrayed) flags |= DFCS_INACTIVE;
1044 DrawFrameControl( hdc, &rect, DFC_CAPTION, flags );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001045}
1046
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001047/***********************************************************************
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001048 * NC_DrawFrame
1049 *
1050 * Draw a window frame inside the given rectangle, and update the rectangle.
Alexandre Julliardaca05781994-10-17 18:12:41 +00001051 * The correct pen for the frame must be selected in the DC.
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001052 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001053static void NC_DrawFrame( HDC hdc, RECT *rect, BOOL dlgFrame,
1054 BOOL active )
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001055{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001056 INT width, height;
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001057
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00001058 if (TWEAK_WineLook != WIN31_LOOK)
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +00001059 ERR("Called in Win95 mode. Aiee! Please report this.\n" );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001060
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001061 if (dlgFrame)
1062 {
Marcus Meissnerddca3151999-05-22 11:33:23 +00001063 width = GetSystemMetrics(SM_CXDLGFRAME) - 1;
1064 height = GetSystemMetrics(SM_CYDLGFRAME) - 1;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001065 SelectObject( hdc, GetSysColorBrush(active ? COLOR_ACTIVECAPTION :
Alexandre Julliard02e90081998-01-04 17:49:09 +00001066 COLOR_INACTIVECAPTION) );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001067 }
1068 else
1069 {
Ove Kaaven60c78f11999-07-03 15:40:29 +00001070 width = GetSystemMetrics(SM_CXFRAME) - 2;
1071 height = GetSystemMetrics(SM_CYFRAME) - 2;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001072 SelectObject( hdc, GetSysColorBrush(active ? COLOR_ACTIVEBORDER :
Alexandre Julliard02e90081998-01-04 17:49:09 +00001073 COLOR_INACTIVEBORDER) );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001074 }
1075
1076 /* Draw frame */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001077 PatBlt( hdc, rect->left, rect->top,
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001078 rect->right - rect->left, height, PATCOPY );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001079 PatBlt( hdc, rect->left, rect->top,
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001080 width, rect->bottom - rect->top, PATCOPY );
Randy Weems0bc73c71999-03-25 15:49:11 +00001081 PatBlt( hdc, rect->left, rect->bottom - 1,
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001082 rect->right - rect->left, -height, PATCOPY );
Randy Weems0bc73c71999-03-25 15:49:11 +00001083 PatBlt( hdc, rect->right - 1, rect->top,
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001084 -width, rect->bottom - rect->top, PATCOPY );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001085
1086 if (dlgFrame)
1087 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001088 InflateRect( rect, -width, -height );
Alexandre Julliarddf2673b1997-03-29 17:20:20 +00001089 }
1090 else
1091 {
Ove Kaaven60c78f11999-07-03 15:40:29 +00001092 INT decYOff = GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXSIZE) - 1;
1093 INT decXOff = GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYSIZE) - 1;
Huw D M Davies2d617be1998-12-08 09:14:09 +00001094
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001095 /* Draw inner rectangle */
Alexandre Julliarddf2673b1997-03-29 17:20:20 +00001096
Alexandre Julliarda3960291999-02-26 11:11:13 +00001097 SelectObject( hdc, GetStockObject(NULL_BRUSH) );
1098 Rectangle( hdc, rect->left + width, rect->top + height,
Huw D M Davies2d617be1998-12-08 09:14:09 +00001099 rect->right - width , rect->bottom - height );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001100
1101 /* Draw the decorations */
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001102
Alexandre Julliarda3960291999-02-26 11:11:13 +00001103 MoveToEx( hdc, rect->left, rect->top + decYOff, NULL );
1104 LineTo( hdc, rect->left + width, rect->top + decYOff );
1105 MoveToEx( hdc, rect->right - 1, rect->top + decYOff, NULL );
1106 LineTo( hdc, rect->right - width - 1, rect->top + decYOff );
1107 MoveToEx( hdc, rect->left, rect->bottom - decYOff, NULL );
1108 LineTo( hdc, rect->left + width, rect->bottom - decYOff );
1109 MoveToEx( hdc, rect->right - 1, rect->bottom - decYOff, NULL );
1110 LineTo( hdc, rect->right - width - 1, rect->bottom - decYOff );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001111
Alexandre Julliarda3960291999-02-26 11:11:13 +00001112 MoveToEx( hdc, rect->left + decXOff, rect->top, NULL );
1113 LineTo( hdc, rect->left + decXOff, rect->top + height);
1114 MoveToEx( hdc, rect->left + decXOff, rect->bottom - 1, NULL );
1115 LineTo( hdc, rect->left + decXOff, rect->bottom - height - 1 );
1116 MoveToEx( hdc, rect->right - decXOff, rect->top, NULL );
1117 LineTo( hdc, rect->right - decXOff, rect->top + height );
1118 MoveToEx( hdc, rect->right - decXOff, rect->bottom - 1, NULL );
1119 LineTo( hdc, rect->right - decXOff, rect->bottom - height - 1 );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001120
Alexandre Julliarda3960291999-02-26 11:11:13 +00001121 InflateRect( rect, -width - 1, -height - 1 );
Alexandre Julliarddf2673b1997-03-29 17:20:20 +00001122 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001123}
1124
1125
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001126/******************************************************************************
1127 *
1128 * void NC_DrawFrame95(
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001129 * HDC hdc,
1130 * RECT *rect,
Bill Medlandcbfbf2a2001-07-20 18:36:49 +00001131 * BOOL active,
1132 * DWORD style,
1133 * DWORD exStyle )
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001134 *
1135 * Draw a window frame inside the given rectangle, and update the rectangle.
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001136 *
1137 * Bugs
1138 * Many. First, just what IS a frame in Win95? Note that the 3D look
1139 * on the outer edge is handled by NC_DoNCPaint95. As is the inner
1140 * edge. The inner rectangle just inside the frame is handled by the
1141 * Caption code.
1142 *
1143 * In short, for most people, this function should be a nop (unless
1144 * you LIKE thick borders in Win95/NT4.0 -- I've been working with
1145 * them lately, but just to get this code right). Even so, it doesn't
1146 * appear to be so. It's being worked on...
1147 *
1148 * Revision history
1149 * 06-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1150 * Original implementation (based on NC_DrawFrame)
Alexandre Julliardf90efa91998-06-14 15:24:15 +00001151 * 02-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1152 * Some minor fixes.
Ove Kaaven60c78f11999-07-03 15:40:29 +00001153 * 29-Jun-1999 Ove KÃ¥ven (ovek@arcticnet.no)
1154 * Fixed a fix or something.
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001155 *
1156 *****************************************************************************/
1157
1158static void NC_DrawFrame95(
Alexandre Julliarda3960291999-02-26 11:11:13 +00001159 HDC hdc,
1160 RECT *rect,
Bill Medlandcbfbf2a2001-07-20 18:36:49 +00001161 BOOL active,
1162 DWORD style,
1163 DWORD exStyle)
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001164{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001165 INT width, height;
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001166
Bill Medlandcbfbf2a2001-07-20 18:36:49 +00001167 /* Firstly the "thick" frame */
1168 if (style & WS_THICKFRAME)
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001169 {
Bill Medlandcbfbf2a2001-07-20 18:36:49 +00001170 width = GetSystemMetrics(SM_CXFRAME) - GetSystemMetrics(SM_CXDLGFRAME);
1171 height = GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYDLGFRAME);
1172
1173 SelectObject( hdc, GetSysColorBrush(active ? COLOR_ACTIVEBORDER :
1174 COLOR_INACTIVEBORDER) );
1175 /* Draw frame */
1176 PatBlt( hdc, rect->left, rect->top,
1177 rect->right - rect->left, height, PATCOPY );
1178 PatBlt( hdc, rect->left, rect->top,
1179 width, rect->bottom - rect->top, PATCOPY );
1180 PatBlt( hdc, rect->left, rect->bottom - 1,
1181 rect->right - rect->left, -height, PATCOPY );
1182 PatBlt( hdc, rect->right - 1, rect->top,
1183 -width, rect->bottom - rect->top, PATCOPY );
1184
1185 InflateRect( rect, -width, -height );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001186 }
1187
Bill Medlandcbfbf2a2001-07-20 18:36:49 +00001188 /* Now the other bit of the frame */
1189 if ((style & (WS_BORDER|WS_DLGFRAME)) ||
1190 (exStyle & WS_EX_DLGMODALFRAME))
1191 {
1192 width = GetSystemMetrics(SM_CXDLGFRAME) - GetSystemMetrics(SM_CXEDGE);
1193 height = GetSystemMetrics(SM_CYDLGFRAME) - GetSystemMetrics(SM_CYEDGE);
1194 /* This should give a value of 1 that should also work for a border */
Alexandre Julliardf90efa91998-06-14 15:24:15 +00001195
Bill Medlandcbfbf2a2001-07-20 18:36:49 +00001196 SelectObject( hdc, GetSysColorBrush(
1197 (exStyle & (WS_EX_DLGMODALFRAME|WS_EX_CLIENTEDGE)) ?
1198 COLOR_3DFACE :
1199 (exStyle & WS_EX_STATICEDGE) ?
1200 COLOR_WINDOWFRAME :
1201 (style & (WS_DLGFRAME|WS_THICKFRAME)) ?
1202 COLOR_3DFACE :
1203 /* else */
1204 COLOR_WINDOWFRAME));
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001205
Bill Medlandcbfbf2a2001-07-20 18:36:49 +00001206 /* Draw frame */
1207 PatBlt( hdc, rect->left, rect->top,
1208 rect->right - rect->left, height, PATCOPY );
1209 PatBlt( hdc, rect->left, rect->top,
1210 width, rect->bottom - rect->top, PATCOPY );
1211 PatBlt( hdc, rect->left, rect->bottom - 1,
1212 rect->right - rect->left, -height, PATCOPY );
1213 PatBlt( hdc, rect->right - 1, rect->top,
1214 -width, rect->bottom - rect->top, PATCOPY );
1215
1216 InflateRect( rect, -width, -height );
1217 }
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001218}
1219
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001220
1221/***********************************************************************
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001222 * NC_DrawCaption
1223 *
1224 * Draw the window caption.
1225 * The correct pen for the window frame must be selected in the DC.
1226 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001227static void NC_DrawCaption( HDC hdc, RECT *rect, HWND hwnd,
1228 DWORD style, BOOL active )
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001229{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001230 RECT r = *rect;
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001231 char buffer[256];
1232
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001233 if (!hbitmapClose)
1234 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +00001235 if (!(hbitmapClose = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_CLOSE) ))) return;
Alexandre Julliard2682bc22000-11-27 22:03:23 +00001236 hbitmapMinimize = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_REDUCE) );
1237 hbitmapMinimizeD = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_REDUCED) );
1238 hbitmapMaximize = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_ZOOM) );
1239 hbitmapMaximizeD = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_ZOOMD) );
1240 hbitmapRestore = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_RESTORE) );
1241 hbitmapRestoreD = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_RESTORED) );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001242 }
1243
Alexandre Julliarddc4fe772001-06-04 21:55:17 +00001244 if (GetWindowLongA( hwnd, GWL_EXSTYLE) & WS_EX_DLGMODALFRAME)
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001245 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001246 HBRUSH hbrushOld = SelectObject(hdc, GetSysColorBrush(COLOR_WINDOW) );
1247 PatBlt( hdc, r.left, r.top, 1, r.bottom-r.top+1,PATCOPY );
1248 PatBlt( hdc, r.right-1, r.top, 1, r.bottom-r.top+1, PATCOPY );
1249 PatBlt( hdc, r.left, r.top-1, r.right-r.left, 1, PATCOPY );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001250 r.left++;
1251 r.right--;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001252 SelectObject( hdc, hbrushOld );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001253 }
Alexandre Julliardb0efe282000-08-04 04:18:04 +00001254 MoveToEx( hdc, r.left, r.bottom, NULL );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001255 LineTo( hdc, r.right, r.bottom );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001256
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001257 if (style & WS_SYSMENU)
1258 {
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001259 NC_DrawSysButton( hwnd, hdc, FALSE );
Marcus Meissnerddca3151999-05-22 11:33:23 +00001260 r.left += GetSystemMetrics(SM_CXSIZE) + 1;
Alexandre Julliardb0efe282000-08-04 04:18:04 +00001261 MoveToEx( hdc, r.left - 1, r.top, NULL );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001262 LineTo( hdc, r.left - 1, r.bottom );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001263 }
1264 if (style & WS_MAXIMIZEBOX)
1265 {
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001266 NC_DrawMaxButton( hwnd, hdc, FALSE );
Marcus Meissnerddca3151999-05-22 11:33:23 +00001267 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001268 }
1269 if (style & WS_MINIMIZEBOX)
1270 {
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001271 NC_DrawMinButton( hwnd, hdc, FALSE );
Marcus Meissnerddca3151999-05-22 11:33:23 +00001272 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001273 }
1274
Alexandre Julliarda3960291999-02-26 11:11:13 +00001275 FillRect( hdc, &r, GetSysColorBrush(active ? COLOR_ACTIVECAPTION :
Alexandre Julliard02e90081998-01-04 17:49:09 +00001276 COLOR_INACTIVECAPTION) );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001277
Alexandre Julliarda3960291999-02-26 11:11:13 +00001278 if (GetWindowTextA( hwnd, buffer, sizeof(buffer) ))
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001279 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001280 if (active) SetTextColor( hdc, GetSysColor( COLOR_CAPTIONTEXT ) );
1281 else SetTextColor( hdc, GetSysColor( COLOR_INACTIVECAPTIONTEXT ) );
1282 SetBkMode( hdc, TRANSPARENT );
1283 DrawTextA( hdc, buffer, -1, &r,
Alexandre Julliarddf2673b1997-03-29 17:20:20 +00001284 DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_NOPREFIX );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001285 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001286}
1287
1288
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001289/******************************************************************************
1290 *
1291 * NC_DrawCaption95(
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001292 * HDC hdc,
1293 * RECT *rect,
1294 * HWND hwnd,
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001295 * DWORD style,
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001296 * BOOL active )
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001297 *
1298 * Draw the window caption for Win95 style windows.
1299 * The correct pen for the window frame must be selected in the DC.
1300 *
1301 * Bugs
Alexandre Julliardf90efa91998-06-14 15:24:15 +00001302 * Hey, a function that finally works! Well, almost.
1303 * It's being worked on.
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001304 *
1305 * Revision history
1306 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1307 * Original implementation.
Alexandre Julliardf90efa91998-06-14 15:24:15 +00001308 * 02-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1309 * Some minor fixes.
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001310 *
1311 *****************************************************************************/
1312
1313static void NC_DrawCaption95(
Alexandre Julliarda3960291999-02-26 11:11:13 +00001314 HDC hdc,
1315 RECT *rect,
1316 HWND hwnd,
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001317 DWORD style,
Eric Kohl8e517b51998-10-11 13:06:35 +00001318 DWORD exStyle,
Alexandre Julliarda3960291999-02-26 11:11:13 +00001319 BOOL active )
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001320{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001321 RECT r = *rect;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001322 char buffer[256];
Alexandre Julliarda3960291999-02-26 11:11:13 +00001323 HPEN hPrevPen;
Pascal Lessardd814bb61999-07-31 13:02:02 +00001324 HMENU hSysMenu;
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001325
Bill Medlandcbfbf2a2001-07-20 18:36:49 +00001326 hPrevPen = SelectObject( hdc, GetSysColorPen(
1327 ((exStyle & (WS_EX_STATICEDGE|WS_EX_CLIENTEDGE|
1328 WS_EX_DLGMODALFRAME)) == WS_EX_STATICEDGE) ?
1329 COLOR_WINDOWFRAME : COLOR_3DFACE) );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001330 MoveToEx( hdc, r.left, r.bottom - 1, NULL );
1331 LineTo( hdc, r.right, r.bottom - 1 );
1332 SelectObject( hdc, hPrevPen );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001333 r.bottom--;
1334
Alexandre Julliarda3960291999-02-26 11:11:13 +00001335 FillRect( hdc, &r, GetSysColorBrush(active ? COLOR_ACTIVECAPTION :
Alexandre Julliard02e90081998-01-04 17:49:09 +00001336 COLOR_INACTIVECAPTION) );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001337
Eric Kohl8e517b51998-10-11 13:06:35 +00001338 if ((style & WS_SYSMENU) && !(exStyle & WS_EX_TOOLWINDOW)) {
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001339 if (NC_DrawSysButton95 (hwnd, hdc, FALSE))
Marcus Meissnerddca3151999-05-22 11:33:23 +00001340 r.left += GetSystemMetrics(SM_CYCAPTION) - 1;
Eric Kohl8e517b51998-10-11 13:06:35 +00001341 }
Pascal Lessardd814bb61999-07-31 13:02:02 +00001342
1343 if (style & WS_SYSMENU)
1344 {
1345 UINT state;
1346
1347 /* Go get the sysmenu */
1348 hSysMenu = GetSystemMenu(hwnd, FALSE);
1349 state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
1350
1351 /* Draw a grayed close button if disabled and a normal one if SC_CLOSE is not there */
1352 NC_DrawCloseButton95 (hwnd, hdc, FALSE,
1353 ((((state & MF_DISABLED) || (state & MF_GRAYED))) && (state != 0xFFFFFFFF)));
Marcus Meissnerddca3151999-05-22 11:33:23 +00001354 r.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
Pascal Lessardd814bb61999-07-31 13:02:02 +00001355
1356 if ((style & WS_MAXIMIZEBOX) || (style & WS_MINIMIZEBOX))
1357 {
1358 /* In win95 the two buttons are always there */
1359 /* But if the menu item is not in the menu they're disabled*/
1360
1361 NC_DrawMaxButton95( hwnd, hdc, FALSE, (!(style & WS_MAXIMIZEBOX)));
1362 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1363
1364 NC_DrawMinButton95( hwnd, hdc, FALSE, (!(style & WS_MINIMIZEBOX)));
1365 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1366 }
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001367 }
1368
Alexandre Julliarda3960291999-02-26 11:11:13 +00001369 if (GetWindowTextA( hwnd, buffer, sizeof(buffer) )) {
1370 NONCLIENTMETRICSA nclm;
1371 HFONT hFont, hOldFont;
1372 nclm.cbSize = sizeof(NONCLIENTMETRICSA);
1373 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
Eric Kohl8e517b51998-10-11 13:06:35 +00001374 if (exStyle & WS_EX_TOOLWINDOW)
Alexandre Julliarda3960291999-02-26 11:11:13 +00001375 hFont = CreateFontIndirectA (&nclm.lfSmCaptionFont);
Eric Kohl8e517b51998-10-11 13:06:35 +00001376 else
Alexandre Julliarda3960291999-02-26 11:11:13 +00001377 hFont = CreateFontIndirectA (&nclm.lfCaptionFont);
1378 hOldFont = SelectObject (hdc, hFont);
1379 if (active) SetTextColor( hdc, GetSysColor( COLOR_CAPTIONTEXT ) );
1380 else SetTextColor( hdc, GetSysColor( COLOR_INACTIVECAPTIONTEXT ) );
1381 SetBkMode( hdc, TRANSPARENT );
Alexandre Julliardf90efa91998-06-14 15:24:15 +00001382 r.left += 2;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001383 DrawTextA( hdc, buffer, -1, &r,
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001384 DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001385 DeleteObject (SelectObject (hdc, hOldFont));
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001386 }
1387}
1388
1389
1390
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001391/***********************************************************************
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001392 * NC_DoNCPaint
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001393 *
Alexandre Julliardc981d0b1996-03-31 16:40:13 +00001394 * Paint the non-client area. clip is currently unused.
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001395 */
Patrik Stridvall1ed4ecf1999-06-26 14:58:24 +00001396static void NC_DoNCPaint( WND* wndPtr, HRGN clip, BOOL suppress_menupaint )
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001397{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001398 HDC hdc;
1399 RECT rect;
1400 BOOL active;
1401 HWND hwnd = wndPtr->hwndSelf;
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001402
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001403 if ( wndPtr->dwStyle & WS_MINIMIZE ||
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001404 !WIN_IsWindowDrawable( wndPtr, 0 )) return; /* Nothing to do */
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001405
Alexandre Julliardc981d0b1996-03-31 16:40:13 +00001406 active = wndPtr->flags & WIN_NCACTIVATED;
1407
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +00001408 TRACE("%04x %d\n", hwnd, active );
Alexandre Julliardc981d0b1996-03-31 16:40:13 +00001409
Alex Korobka4f1ac051999-03-28 09:37:57 +00001410 if (!(hdc = GetDCEx( hwnd, (clip > 1) ? clip : 0, DCX_USESTYLE | DCX_WINDOW |
1411 ((clip > 1) ? (DCX_INTERSECTRGN | DCX_KEEPCLIPRGN): 0) ))) return;
Alexandre Julliard940d58c1994-09-16 09:24:37 +00001412
Alexandre Julliarda3960291999-02-26 11:11:13 +00001413 if (ExcludeVisRect16( hdc, wndPtr->rectClient.left-wndPtr->rectWindow.left,
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001414 wndPtr->rectClient.top-wndPtr->rectWindow.top,
1415 wndPtr->rectClient.right-wndPtr->rectWindow.left,
1416 wndPtr->rectClient.bottom-wndPtr->rectWindow.top )
1417 == NULLREGION)
1418 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001419 ReleaseDC( hwnd, hdc );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001420 return;
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001421 }
1422
1423 rect.top = rect.left = 0;
1424 rect.right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
1425 rect.bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
1426
Alexandre Julliarda3960291999-02-26 11:11:13 +00001427 SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001428
Alexandre Julliarddc4fe772001-06-04 21:55:17 +00001429 if (HAS_ANYFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001430 {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +00001431 SelectObject( hdc, GetStockObject(NULL_BRUSH) );
1432 Rectangle( hdc, 0, 0, rect.right, rect.bottom );
1433 InflateRect( &rect, -1, -1 );
1434 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001435
Alexandre Julliarddc4fe772001-06-04 21:55:17 +00001436 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
1437 NC_DrawFrame(hdc, &rect, FALSE, active );
1438 else if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
1439 NC_DrawFrame( hdc, &rect, TRUE, active );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001440
Alexandre Julliarddc4fe772001-06-04 21:55:17 +00001441 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
1442 {
1443 RECT r = rect;
1444 r.bottom = rect.top + GetSystemMetrics(SM_CYSIZE);
1445 rect.top += GetSystemMetrics(SM_CYSIZE) + GetSystemMetrics(SM_CYBORDER);
1446 NC_DrawCaption( hdc, &r, hwnd, wndPtr->dwStyle, active );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001447 }
1448
Alexandre Julliardf7207251994-07-23 07:57:48 +00001449 if (HAS_MENU(wndPtr))
1450 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001451 RECT r = rect;
Marcus Meissnerddca3151999-05-22 11:33:23 +00001452 r.bottom = rect.top + GetSystemMetrics(SM_CYMENU); /* default height */
Alexandre Julliard940d58c1994-09-16 09:24:37 +00001453 rect.top += MENU_DrawMenuBar( hdc, &r, hwnd, suppress_menupaint );
Alexandre Julliardf7207251994-07-23 07:57:48 +00001454 }
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001455
Alexandre Julliardecc37121994-11-22 16:31:29 +00001456 /* Draw the scroll-bars */
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001457
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001458 if (wndPtr->dwStyle & WS_VSCROLL)
Alex Korobkad2085841998-10-18 10:37:46 +00001459 SCROLL_DrawScrollBar( hwnd, hdc, SB_VERT, TRUE, TRUE );
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001460 if (wndPtr->dwStyle & WS_HSCROLL)
Alex Korobkad2085841998-10-18 10:37:46 +00001461 SCROLL_DrawScrollBar( hwnd, hdc, SB_HORZ, TRUE, TRUE );
Alexandre Julliardecc37121994-11-22 16:31:29 +00001462
1463 /* Draw the "size-box" */
1464
1465 if ((wndPtr->dwStyle & WS_VSCROLL) && (wndPtr->dwStyle & WS_HSCROLL))
1466 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001467 RECT r = rect;
Marcus Meissnerddca3151999-05-22 11:33:23 +00001468 r.left = r.right - GetSystemMetrics(SM_CXVSCROLL) + 1;
1469 r.top = r.bottom - GetSystemMetrics(SM_CYHSCROLL) + 1;
Alexandre Julliardf90efa91998-06-14 15:24:15 +00001470 if(wndPtr->dwStyle & WS_BORDER) {
1471 r.left++;
1472 r.top++;
1473 }
Alexandre Julliarda3960291999-02-26 11:11:13 +00001474 FillRect( hdc, &r, GetSysColorBrush(COLOR_SCROLLBAR) );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001475 }
1476
Alexandre Julliarda3960291999-02-26 11:11:13 +00001477 ReleaseDC( hwnd, hdc );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001478}
1479
1480
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001481/******************************************************************************
1482 *
1483 * void NC_DoNCPaint95(
1484 * WND *wndPtr,
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001485 * HRGN clip,
1486 * BOOL suppress_menupaint )
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001487 *
1488 * Paint the non-client area for Win95 windows. The clip region is
1489 * currently ignored.
1490 *
1491 * Bugs
1492 * grep -E -A10 -B5 \(95\)\|\(Bugs\)\|\(FIXME\) windows/nonclient.c \
1493 * misc/tweak.c controls/menu.c # :-)
1494 *
1495 * Revision history
1496 * 03-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1497 * Original implementation
Alexandre Julliardf90efa91998-06-14 15:24:15 +00001498 * 10-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1499 * Fixed some bugs.
Ove Kaaven60c78f11999-07-03 15:40:29 +00001500 * 29-Jun-1999 Ove KÃ¥ven (ovek@arcticnet.no)
1501 * Streamlined window style checks.
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001502 *
1503 *****************************************************************************/
1504
Patrik Stridvall1ed4ecf1999-06-26 14:58:24 +00001505static void NC_DoNCPaint95(
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001506 WND *wndPtr,
Alexandre Julliarda3960291999-02-26 11:11:13 +00001507 HRGN clip,
1508 BOOL suppress_menupaint )
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001509{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001510 HDC hdc;
Alex Korobka4f1ac051999-03-28 09:37:57 +00001511 RECT rfuzz, rect, rectClip;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001512 BOOL active;
1513 HWND hwnd = wndPtr->hwndSelf;
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001514
1515 if ( wndPtr->dwStyle & WS_MINIMIZE ||
1516 !WIN_IsWindowDrawable( wndPtr, 0 )) return; /* Nothing to do */
1517
1518 active = wndPtr->flags & WIN_NCACTIVATED;
1519
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +00001520 TRACE("%04x %d\n", hwnd, active );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001521
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +00001522 /* MSDN docs are pretty idiotic here, they say app CAN use clipRgn in
1523 the call to GetDCEx implying that it is allowed not to use it either.
1524 However, the suggested GetDCEx( , DCX_WINDOW | DCX_INTERSECTRGN)
1525 will cause clipRgn to be deleted after ReleaseDC().
1526 Now, how is the "system" supposed to tell what happened?
Alex Korobka4f1ac051999-03-28 09:37:57 +00001527 */
1528
1529 if (!(hdc = GetDCEx( hwnd, (clip > 1) ? clip : 0, DCX_USESTYLE | DCX_WINDOW |
1530 ((clip > 1) ?(DCX_INTERSECTRGN | DCX_KEEPCLIPRGN) : 0) ))) return;
1531
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001532
Alexandre Julliarda3960291999-02-26 11:11:13 +00001533 if (ExcludeVisRect16( hdc, wndPtr->rectClient.left-wndPtr->rectWindow.left,
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001534 wndPtr->rectClient.top-wndPtr->rectWindow.top,
1535 wndPtr->rectClient.right-wndPtr->rectWindow.left,
1536 wndPtr->rectClient.bottom-wndPtr->rectWindow.top )
1537 == NULLREGION)
1538 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001539 ReleaseDC( hwnd, hdc );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001540 return;
1541 }
1542
1543 rect.top = rect.left = 0;
1544 rect.right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
1545 rect.bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
1546
Alex Korobka4f1ac051999-03-28 09:37:57 +00001547 if( clip > 1 )
1548 GetRgnBox( clip, &rectClip );
1549 else
1550 {
1551 clip = 0;
1552 rectClip = rect;
1553 }
1554
Alexandre Julliarda3960291999-02-26 11:11:13 +00001555 SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001556
Bill Medlandcbfbf2a2001-07-20 18:36:49 +00001557 if (HAS_STATICOUTERFRAME(wndPtr->dwStyle, wndPtr->dwExStyle)) {
1558 DrawEdge (hdc, &rect, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
1559 }
1560 else if (HAS_BIGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle)) {
Alexandre Julliarddc4fe772001-06-04 21:55:17 +00001561 DrawEdge (hdc, &rect, EDGE_RAISED, BF_RECT | BF_ADJUST);
1562 }
Bill Medlandcbfbf2a2001-07-20 18:36:49 +00001563
1564 NC_DrawFrame95(hdc, &rect, active, wndPtr->dwStyle, wndPtr->dwExStyle );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001565
Alexandre Julliarddc4fe772001-06-04 21:55:17 +00001566 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
1567 {
1568 RECT r = rect;
1569 if (wndPtr->dwExStyle & WS_EX_TOOLWINDOW) {
1570 r.bottom = rect.top + GetSystemMetrics(SM_CYSMCAPTION);
1571 rect.top += GetSystemMetrics(SM_CYSMCAPTION);
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001572 }
Alexandre Julliarddc4fe772001-06-04 21:55:17 +00001573 else {
1574 r.bottom = rect.top + GetSystemMetrics(SM_CYCAPTION);
1575 rect.top += GetSystemMetrics(SM_CYCAPTION);
1576 }
1577 if( !clip || IntersectRect( &rfuzz, &r, &rectClip ) )
1578 NC_DrawCaption95 (hdc, &r, hwnd, wndPtr->dwStyle,
1579 wndPtr->dwExStyle, active);
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001580 }
1581
1582 if (HAS_MENU(wndPtr))
1583 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001584 RECT r = rect;
Marcus Meissnerddca3151999-05-22 11:33:23 +00001585 r.bottom = rect.top + GetSystemMetrics(SM_CYMENU);
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001586
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +00001587 TRACE("Calling DrawMenuBar with rect (%d, %d)-(%d, %d)\n",
1588 r.left, r.top, r.right, r.bottom);
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001589
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001590 rect.top += MENU_DrawMenuBar( hdc, &r, hwnd, suppress_menupaint ) + 1;
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001591 }
1592
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +00001593 TRACE("After MenuBar, rect is (%d, %d)-(%d, %d).\n",
1594 rect.left, rect.top, rect.right, rect.bottom );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001595
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001596 if (wndPtr->dwExStyle & WS_EX_CLIENTEDGE)
Alexandre Julliarda3960291999-02-26 11:11:13 +00001597 DrawEdge (hdc, &rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001598
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001599 /* Draw the scroll-bars */
1600
1601 if (wndPtr->dwStyle & WS_VSCROLL)
Alex Korobkad2085841998-10-18 10:37:46 +00001602 SCROLL_DrawScrollBar( hwnd, hdc, SB_VERT, TRUE, TRUE );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001603 if (wndPtr->dwStyle & WS_HSCROLL)
Alex Korobkad2085841998-10-18 10:37:46 +00001604 SCROLL_DrawScrollBar( hwnd, hdc, SB_HORZ, TRUE, TRUE );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001605
1606 /* Draw the "size-box" */
1607 if ((wndPtr->dwStyle & WS_VSCROLL) && (wndPtr->dwStyle & WS_HSCROLL))
1608 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001609 RECT r = rect;
Marcus Meissnerddca3151999-05-22 11:33:23 +00001610 r.left = r.right - GetSystemMetrics(SM_CXVSCROLL) + 1;
1611 r.top = r.bottom - GetSystemMetrics(SM_CYHSCROLL) + 1;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001612 FillRect( hdc, &r, GetSysColorBrush(COLOR_SCROLLBAR) );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001613 }
1614
Alexandre Julliarda3960291999-02-26 11:11:13 +00001615 ReleaseDC( hwnd, hdc );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001616}
1617
1618
1619
Alexandre Julliard988ca971994-06-21 16:15:21 +00001620
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001621/***********************************************************************
1622 * NC_HandleNCPaint
1623 *
1624 * Handle a WM_NCPAINT message. Called from DefWindowProc().
1625 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001626LONG NC_HandleNCPaint( HWND hwnd , HRGN clip)
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001627{
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001628 WND* wndPtr = WIN_FindWndPtr( hwnd );
1629
1630 if( wndPtr && wndPtr->dwStyle & WS_VISIBLE )
1631 {
1632 if( wndPtr->dwStyle & WS_MINIMIZE )
1633 WINPOS_RedrawIconTitle( hwnd );
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00001634 else if (TWEAK_WineLook == WIN31_LOOK)
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001635 NC_DoNCPaint( wndPtr, clip, FALSE );
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00001636 else
1637 NC_DoNCPaint95( wndPtr, clip, FALSE );
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001638 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001639 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001640 return 0;
1641}
1642
1643
1644/***********************************************************************
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001645 * NC_HandleNCActivate
1646 *
1647 * Handle a WM_NCACTIVATE message. Called from DefWindowProc().
1648 */
Alexandre Julliardde424282001-08-10 22:51:42 +00001649LONG NC_HandleNCActivate( HWND hwnd, WPARAM wParam )
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001650{
Alexandre Julliardde424282001-08-10 22:51:42 +00001651 WND* wndPtr = WIN_FindWndPtr( hwnd );
1652
Dmitry Timoshkovd1e648f2001-06-04 02:49:22 +00001653 /* Lotus Notes draws menu descriptions in the caption of its main
1654 * window. When it wants to restore original "system" view, it just
1655 * sends WM_NCACTIVATE message to itself. Any optimizations here in
1656 * attempt to minimize redrawings lead to a not restored caption.
1657 */
Alexandre Julliardde424282001-08-10 22:51:42 +00001658 if (wndPtr)
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001659 {
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001660 if (wParam) wndPtr->flags |= WIN_NCACTIVATED;
1661 else wndPtr->flags &= ~WIN_NCACTIVATED;
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001662
Alexandre Julliardde424282001-08-10 22:51:42 +00001663 if (IsIconic(hwnd)) WINPOS_RedrawIconTitle( hwnd );
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00001664 else if (TWEAK_WineLook == WIN31_LOOK)
Alexandre Julliarda3960291999-02-26 11:11:13 +00001665 NC_DoNCPaint( wndPtr, (HRGN)1, FALSE );
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00001666 else
Alexandre Julliarda3960291999-02-26 11:11:13 +00001667 NC_DoNCPaint95( wndPtr, (HRGN)1, FALSE );
Alexandre Julliardde424282001-08-10 22:51:42 +00001668 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001669 }
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001670 return TRUE;
1671}
1672
1673
1674/***********************************************************************
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001675 * NC_HandleSetCursor
1676 *
1677 * Handle a WM_SETCURSOR message. Called from DefWindowProc().
1678 */
Alexandre Julliardcb25e252001-08-08 23:28:42 +00001679LONG NC_HandleSetCursor( HWND hwnd, WPARAM wParam, LPARAM lParam )
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001680{
Alexandre Julliard021dd992001-09-14 21:29:19 +00001681 if (hwnd != WIN_GetFullHandle( (HWND)wParam ))
1682 return 0; /* Don't set the cursor for child windows */
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001683
1684 switch(LOWORD(lParam))
1685 {
1686 case HTERROR:
1687 {
1688 WORD msg = HIWORD( lParam );
1689 if ((msg == WM_LBUTTONDOWN) || (msg == WM_MBUTTONDOWN) ||
1690 (msg == WM_RBUTTONDOWN))
Alexandre Julliarda3960291999-02-26 11:11:13 +00001691 MessageBeep(0);
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001692 }
1693 break;
1694
1695 case HTCLIENT:
1696 {
Alexandre Julliardd44e4952001-08-20 18:09:39 +00001697 HCURSOR hCursor = GetClassLongA(hwnd, GCL_HCURSOR);
Gerard Patel5773dad1999-06-12 14:45:56 +00001698 if(hCursor) {
Alexandre Julliardd44e4952001-08-20 18:09:39 +00001699 SetCursor(hCursor);
Gerard Patel5773dad1999-06-12 14:45:56 +00001700 return TRUE;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001701 }
Gerard Patel5773dad1999-06-12 14:45:56 +00001702 return FALSE;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001703 }
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001704
1705 case HTLEFT:
1706 case HTRIGHT:
Alexandre Julliard2682bc22000-11-27 22:03:23 +00001707 return (LONG)SetCursor( LoadCursorA( 0, IDC_SIZEWEA ) );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001708
1709 case HTTOP:
1710 case HTBOTTOM:
Alexandre Julliard2682bc22000-11-27 22:03:23 +00001711 return (LONG)SetCursor( LoadCursorA( 0, IDC_SIZENSA ) );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001712
1713 case HTTOPLEFT:
1714 case HTBOTTOMRIGHT:
Alexandre Julliard2682bc22000-11-27 22:03:23 +00001715 return (LONG)SetCursor( LoadCursorA( 0, IDC_SIZENWSEA ) );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001716
1717 case HTTOPRIGHT:
1718 case HTBOTTOMLEFT:
Alexandre Julliard2682bc22000-11-27 22:03:23 +00001719 return (LONG)SetCursor( LoadCursorA( 0, IDC_SIZENESWA ) );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001720 }
1721
1722 /* Default cursor: arrow */
Alexandre Julliard2682bc22000-11-27 22:03:23 +00001723 return (LONG)SetCursor( LoadCursorA( 0, IDC_ARROWA ) );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001724}
1725
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001726/***********************************************************************
1727 * NC_GetSysPopupPos
1728 */
Alexandre Julliardde424282001-08-10 22:51:42 +00001729void NC_GetSysPopupPos( HWND hwnd, RECT* rect )
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001730{
Alexandre Julliardde424282001-08-10 22:51:42 +00001731 if (IsIconic(hwnd)) GetWindowRect( hwnd, rect );
1732 else
1733 {
1734 WND *wndPtr = WIN_FindWndPtr( hwnd );
1735 if (!wndPtr) return;
1736
1737 NC_GetInsideRect( hwnd, rect );
1738 OffsetRect( rect, wndPtr->rectWindow.left, wndPtr->rectWindow.top);
1739 if (wndPtr->dwStyle & WS_CHILD)
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001740 ClientToScreen( GetParent(hwnd), (POINT *)rect );
Alexandre Julliardde424282001-08-10 22:51:42 +00001741 if (TWEAK_WineLook == WIN31_LOOK) {
Marcus Meissnerddca3151999-05-22 11:33:23 +00001742 rect->right = rect->left + GetSystemMetrics(SM_CXSIZE);
1743 rect->bottom = rect->top + GetSystemMetrics(SM_CYSIZE);
Alexandre Julliardde424282001-08-10 22:51:42 +00001744 }
1745 else {
Marcus Meissnerddca3151999-05-22 11:33:23 +00001746 rect->right = rect->left + GetSystemMetrics(SM_CYCAPTION) - 1;
1747 rect->bottom = rect->top + GetSystemMetrics(SM_CYCAPTION) - 1;
Alexandre Julliardde424282001-08-10 22:51:42 +00001748 }
1749 WIN_ReleaseWndPtr( wndPtr );
1750 }
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001751}
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001752
1753/***********************************************************************
Pascal Lessardd814bb61999-07-31 13:02:02 +00001754 * NC_TrackMinMaxBox95
1755 *
1756 * Track a mouse button press on the minimize or maximize box.
1757 *
1758 * The big difference between 3.1 and 95 is the disabled button state.
1759 * In win95 the system button can be disabled, so it can ignore the mouse
1760 * event.
1761 *
1762 */
1763static void NC_TrackMinMaxBox95( HWND hwnd, WORD wParam )
1764{
1765 MSG msg;
Pascal Lessardd814bb61999-07-31 13:02:02 +00001766 HDC hdc = GetWindowDC( hwnd );
1767 BOOL pressed = TRUE;
1768 UINT state;
1769 DWORD wndStyle = GetWindowLongA( hwnd, GWL_STYLE);
1770 HMENU hSysMenu = GetSystemMenu(hwnd, FALSE);
1771
1772 void (*paintButton)(HWND, HDC16, BOOL, BOOL);
1773
1774 if (wParam == HTMINBUTTON)
1775 {
1776 /* If the style is not present, do nothing */
1777 if (!(wndStyle & WS_MINIMIZEBOX))
1778 return;
1779
1780 /* Check if the sysmenu item for minimize is there */
1781 state = GetMenuState(hSysMenu, SC_MINIMIZE, MF_BYCOMMAND);
1782
1783 paintButton = &NC_DrawMinButton95;
1784 }
1785 else
1786 {
1787 /* If the style is not present, do nothing */
1788 if (!(wndStyle & WS_MAXIMIZEBOX))
1789 return;
1790
1791 /* Check if the sysmenu item for maximize is there */
1792 state = GetMenuState(hSysMenu, SC_MAXIMIZE, MF_BYCOMMAND);
1793
1794 paintButton = &NC_DrawMaxButton95;
1795 }
1796
1797 SetCapture( hwnd );
1798
1799 (*paintButton)( hwnd, hdc, TRUE, FALSE);
1800
Dmitry Timoshkov63ba91d2000-10-15 00:22:29 +00001801 while(1)
Pascal Lessardd814bb61999-07-31 13:02:02 +00001802 {
1803 BOOL oldstate = pressed;
Alexandre Julliardbfb4a232001-08-06 18:05:47 +00001804
1805 if (!GetMessageW( &msg, 0, WM_MOUSEFIRST, WM_MOUSELAST )) break;
1806 if (CallMsgFilterW( &msg, MSGF_MAX )) continue;
Pascal Lessardd814bb61999-07-31 13:02:02 +00001807
Dmitry Timoshkov63ba91d2000-10-15 00:22:29 +00001808 if(msg.message == WM_LBUTTONUP)
1809 break;
1810
1811 if(msg.message != WM_MOUSEMOVE)
1812 continue;
1813
Alexandre Julliard83f52d12000-09-26 22:20:14 +00001814 pressed = (NC_HandleNCHitTest( hwnd, msg.pt ) == wParam);
Pascal Lessardd814bb61999-07-31 13:02:02 +00001815 if (pressed != oldstate)
1816 (*paintButton)( hwnd, hdc, pressed, FALSE);
Dmitry Timoshkov63ba91d2000-10-15 00:22:29 +00001817 }
Pascal Lessardd814bb61999-07-31 13:02:02 +00001818
Dmitry Timoshkov63ba91d2000-10-15 00:22:29 +00001819 if(pressed)
1820 (*paintButton)(hwnd, hdc, FALSE, FALSE);
Pascal Lessardd814bb61999-07-31 13:02:02 +00001821
1822 ReleaseCapture();
1823 ReleaseDC( hwnd, hdc );
1824
1825 /* If the item minimize or maximize of the sysmenu are not there */
1826 /* or if the style is not present, do nothing */
1827 if ((!pressed) || (state == 0xFFFFFFFF))
1828 return;
1829
1830 if (wParam == HTMINBUTTON)
Alexandre Julliard83f52d12000-09-26 22:20:14 +00001831 SendMessageA( hwnd, WM_SYSCOMMAND, SC_MINIMIZE, MAKELONG(msg.pt.x,msg.pt.y) );
Pascal Lessardd814bb61999-07-31 13:02:02 +00001832 else
Alexandre Julliard83f52d12000-09-26 22:20:14 +00001833 SendMessageA( hwnd, WM_SYSCOMMAND,
1834 IsZoomed(hwnd) ? SC_RESTORE:SC_MAXIMIZE, MAKELONG(msg.pt.x,msg.pt.y) );
Pascal Lessardd814bb61999-07-31 13:02:02 +00001835}
1836
1837/***********************************************************************
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001838 * NC_TrackMinMaxBox
1839 *
1840 * Track a mouse button press on the minimize or maximize box.
1841 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001842static void NC_TrackMinMaxBox( HWND hwnd, WORD wParam )
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001843{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001844 MSG msg;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001845 HDC hdc = GetWindowDC( hwnd );
1846 BOOL pressed = TRUE;
1847 void (*paintButton)(HWND, HDC16, BOOL);
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001848
Alexandre Julliarda3960291999-02-26 11:11:13 +00001849 SetCapture( hwnd );
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001850
Pascal Lessardd814bb61999-07-31 13:02:02 +00001851 if (wParam == HTMINBUTTON)
1852 paintButton = &NC_DrawMinButton;
1853 else
1854 paintButton = &NC_DrawMaxButton;
1855
1856 (*paintButton)( hwnd, hdc, TRUE);
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001857
Dmitry Timoshkov63ba91d2000-10-15 00:22:29 +00001858 while(1)
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001859 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001860 BOOL oldstate = pressed;
Alexandre Julliardbfb4a232001-08-06 18:05:47 +00001861
1862 if (!GetMessageW( &msg, 0, WM_MOUSEFIRST, WM_MOUSELAST )) break;
1863 if (CallMsgFilterW( &msg, MSGF_MAX )) continue;
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001864
Dmitry Timoshkov63ba91d2000-10-15 00:22:29 +00001865 if(msg.message == WM_LBUTTONUP)
1866 break;
1867
1868 if(msg.message != WM_MOUSEMOVE)
1869 continue;
1870
Alexandre Julliard83f52d12000-09-26 22:20:14 +00001871 pressed = (NC_HandleNCHitTest( hwnd, msg.pt ) == wParam);
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001872 if (pressed != oldstate)
Pascal Lessardd814bb61999-07-31 13:02:02 +00001873 (*paintButton)( hwnd, hdc, pressed);
Dmitry Timoshkov63ba91d2000-10-15 00:22:29 +00001874 }
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001875
Dmitry Timoshkov63ba91d2000-10-15 00:22:29 +00001876 if(pressed)
1877 (*paintButton)( hwnd, hdc, FALSE);
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001878
1879 ReleaseCapture();
Alexandre Julliarda3960291999-02-26 11:11:13 +00001880 ReleaseDC( hwnd, hdc );
Pascal Lessardd814bb61999-07-31 13:02:02 +00001881
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001882 if (!pressed) return;
1883
1884 if (wParam == HTMINBUTTON)
Alexandre Julliard83f52d12000-09-26 22:20:14 +00001885 SendMessageA( hwnd, WM_SYSCOMMAND, SC_MINIMIZE, MAKELONG(msg.pt.x,msg.pt.y) );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001886 else
Alexandre Julliard83f52d12000-09-26 22:20:14 +00001887 SendMessageA( hwnd, WM_SYSCOMMAND,
1888 IsZoomed(hwnd) ? SC_RESTORE:SC_MAXIMIZE, MAKELONG(msg.pt.x,msg.pt.y) );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001889}
1890
1891
1892/***********************************************************************
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001893 * NC_TrackCloseButton95
1894 *
1895 * Track a mouse button press on the Win95 close button.
1896 */
1897static void
Alexandre Julliarda3960291999-02-26 11:11:13 +00001898NC_TrackCloseButton95 (HWND hwnd, WORD wParam)
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001899{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001900 MSG msg;
Pascal Lessardd814bb61999-07-31 13:02:02 +00001901 HDC hdc;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001902 BOOL pressed = TRUE;
Pascal Lessardd814bb61999-07-31 13:02:02 +00001903 HMENU hSysMenu = GetSystemMenu(hwnd, FALSE);
1904 UINT state;
1905
1906 if(hSysMenu == 0)
1907 return;
1908
1909 state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
1910
1911 /* If the item close of the sysmenu is disabled or not there do nothing */
1912 if((state & MF_DISABLED) || (state & MF_GRAYED) || (state == 0xFFFFFFFF))
1913 return;
1914
1915 hdc = GetWindowDC( hwnd );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001916
Alexandre Julliarda3960291999-02-26 11:11:13 +00001917 SetCapture( hwnd );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001918
Pascal Lessardd814bb61999-07-31 13:02:02 +00001919 NC_DrawCloseButton95 (hwnd, hdc, TRUE, FALSE);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001920
Dmitry Timoshkov63ba91d2000-10-15 00:22:29 +00001921 while(1)
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001922 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001923 BOOL oldstate = pressed;
Alexandre Julliardbfb4a232001-08-06 18:05:47 +00001924
1925 if (!GetMessageW( &msg, 0, WM_MOUSEFIRST, WM_MOUSELAST )) break;
1926 if (CallMsgFilterW( &msg, MSGF_MAX )) continue;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001927
Dmitry Timoshkov63ba91d2000-10-15 00:22:29 +00001928 if(msg.message == WM_LBUTTONUP)
1929 break;
1930
1931 if(msg.message != WM_MOUSEMOVE)
1932 continue;
1933
Alexandre Julliard83f52d12000-09-26 22:20:14 +00001934 pressed = (NC_HandleNCHitTest( hwnd, msg.pt ) == wParam);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001935 if (pressed != oldstate)
Pascal Lessardd814bb61999-07-31 13:02:02 +00001936 NC_DrawCloseButton95 (hwnd, hdc, pressed, FALSE);
Dmitry Timoshkov63ba91d2000-10-15 00:22:29 +00001937 }
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001938
Dmitry Timoshkov63ba91d2000-10-15 00:22:29 +00001939 if(pressed)
1940 NC_DrawCloseButton95 (hwnd, hdc, FALSE, FALSE);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001941
1942 ReleaseCapture();
Alexandre Julliarda3960291999-02-26 11:11:13 +00001943 ReleaseDC( hwnd, hdc );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001944 if (!pressed) return;
1945
Alexandre Julliard83f52d12000-09-26 22:20:14 +00001946 SendMessageA( hwnd, WM_SYSCOMMAND, SC_CLOSE, MAKELONG(msg.pt.x,msg.pt.y) );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001947}
1948
1949
1950/***********************************************************************
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001951 * NC_TrackScrollBar
1952 *
1953 * Track a mouse button press on the horizontal or vertical scroll-bar.
1954 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001955static void NC_TrackScrollBar( HWND hwnd, WPARAM wParam, POINT pt )
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001956{
Alexandre Julliardbfb4a232001-08-06 18:05:47 +00001957 MSG msg;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001958 INT scrollbar;
Alexandre Julliardecc37121994-11-22 16:31:29 +00001959 WND *wndPtr = WIN_FindWndPtr( hwnd );
1960
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001961 if ((wParam & 0xfff0) == SC_HSCROLL)
1962 {
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001963 if ((wParam & 0x0f) != HTHSCROLL) goto END;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001964 scrollbar = SB_HORZ;
1965 }
1966 else /* SC_VSCROLL */
1967 {
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001968 if ((wParam & 0x0f) != HTVSCROLL) goto END;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001969 scrollbar = SB_VERT;
1970 }
1971
Alexandre Julliardecc37121994-11-22 16:31:29 +00001972 pt.x -= wndPtr->rectWindow.left;
1973 pt.y -= wndPtr->rectWindow.top;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001974 SetCapture( hwnd );
Alexandre Julliardecc37121994-11-22 16:31:29 +00001975 SCROLL_HandleScrollEvent( hwnd, scrollbar, WM_LBUTTONDOWN, pt );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001976
1977 do
1978 {
Alexandre Julliardbfb4a232001-08-06 18:05:47 +00001979 if (!GetMessageW( &msg, 0, 0, 0 )) break;
1980 if (CallMsgFilterW( &msg, MSGF_SCROLLBAR )) continue;
1981 switch(msg.message)
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001982 {
1983 case WM_LBUTTONUP:
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001984 case WM_MOUSEMOVE:
Alexandre Julliardecc37121994-11-22 16:31:29 +00001985 case WM_SYSTIMER:
Alexandre Julliardbfb4a232001-08-06 18:05:47 +00001986 pt.x = LOWORD(msg.lParam) + wndPtr->rectClient.left - wndPtr->rectWindow.left;
1987 pt.y = HIWORD(msg.lParam) + wndPtr->rectClient.top - wndPtr->rectWindow.top;
1988 SCROLL_HandleScrollEvent( hwnd, scrollbar, msg.message, pt );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001989 break;
Alexandre Julliardecc37121994-11-22 16:31:29 +00001990 default:
Alexandre Julliardbfb4a232001-08-06 18:05:47 +00001991 TranslateMessage( &msg );
1992 DispatchMessageW( &msg );
Alexandre Julliardecc37121994-11-22 16:31:29 +00001993 break;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001994 }
Alexandre Julliarda3960291999-02-26 11:11:13 +00001995 if (!IsWindow( hwnd ))
Alexandre Julliardecc37121994-11-22 16:31:29 +00001996 {
1997 ReleaseCapture();
1998 break;
1999 }
Alexandre Julliardbfb4a232001-08-06 18:05:47 +00002000 } while (msg.message != WM_LBUTTONUP);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002001END:
2002 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002003}
2004
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002005/***********************************************************************
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002006 * NC_HandleNCLButtonDown
Alexandre Julliardcdd09231994-01-12 11:12:51 +00002007 *
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002008 * Handle a WM_NCLBUTTONDOWN message. Called from DefWindowProc().
Alexandre Julliardcdd09231994-01-12 11:12:51 +00002009 */
Alexandre Julliardde424282001-08-10 22:51:42 +00002010LONG NC_HandleNCLButtonDown( HWND hwnd, WPARAM wParam, LPARAM lParam )
Alexandre Julliardcdd09231994-01-12 11:12:51 +00002011{
Alexandre Julliardde424282001-08-10 22:51:42 +00002012 LONG style = GetWindowLongA( hwnd, GWL_STYLE );
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002013
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002014 switch(wParam) /* Hit test */
Alexandre Julliardcdd09231994-01-12 11:12:51 +00002015 {
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002016 case HTCAPTION:
Alexandre Julliardde424282001-08-10 22:51:42 +00002017 {
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00002018 HWND top = GetAncestor( hwnd, GA_ROOT );
Alexandre Julliard23946ad1997-06-16 17:43:53 +00002019
Alexandre Julliardde424282001-08-10 22:51:42 +00002020 if( WINPOS_SetActiveWindow(top, TRUE, TRUE) || (GetActiveWindow() == top) )
2021 SendMessageW( hwnd, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, lParam );
2022 break;
2023 }
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002024
Alexandre Julliardcdd09231994-01-12 11:12:51 +00002025 case HTSYSMENU:
Alexandre Julliardde424282001-08-10 22:51:42 +00002026 if( style & WS_SYSMENU )
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002027 {
Alexandre Julliardde424282001-08-10 22:51:42 +00002028 if( !(style & WS_MINIMIZE) )
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002029 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00002030 HDC hDC = GetWindowDC(hwnd);
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00002031 if (TWEAK_WineLook == WIN31_LOOK)
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002032 NC_DrawSysButton( hwnd, hDC, TRUE );
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00002033 else
2034 NC_DrawSysButton95( hwnd, hDC, TRUE );
Alexandre Julliarda3960291999-02-26 11:11:13 +00002035 ReleaseDC( hwnd, hDC );
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002036 }
Alexandre Julliardcb25e252001-08-08 23:28:42 +00002037 SendMessageW( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU + HTSYSMENU, lParam );
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002038 }
2039 break;
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002040
2041 case HTMENU:
Alexandre Julliardcb25e252001-08-08 23:28:42 +00002042 SendMessageW( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU, lParam );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002043 break;
2044
2045 case HTHSCROLL:
Alexandre Julliardcb25e252001-08-08 23:28:42 +00002046 SendMessageW( hwnd, WM_SYSCOMMAND, SC_HSCROLL + HTHSCROLL, lParam );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002047 break;
2048
2049 case HTVSCROLL:
Alexandre Julliardcb25e252001-08-08 23:28:42 +00002050 SendMessageW( hwnd, WM_SYSCOMMAND, SC_VSCROLL + HTVSCROLL, lParam );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002051 break;
2052
2053 case HTMINBUTTON:
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002054 case HTMAXBUTTON:
Pascal Lessardd814bb61999-07-31 13:02:02 +00002055 if (TWEAK_WineLook == WIN31_LOOK)
2056 NC_TrackMinMaxBox( hwnd, wParam );
2057 else
2058 NC_TrackMinMaxBox95( hwnd, wParam );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002059 break;
2060
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00002061 case HTCLOSE:
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00002062 if (TWEAK_WineLook >= WIN95_LOOK)
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00002063 NC_TrackCloseButton95 (hwnd, wParam);
2064 break;
Pascal Lessardd814bb61999-07-31 13:02:02 +00002065
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002066 case HTLEFT:
2067 case HTRIGHT:
2068 case HTTOP:
2069 case HTTOPLEFT:
2070 case HTTOPRIGHT:
2071 case HTBOTTOM:
2072 case HTBOTTOMLEFT:
2073 case HTBOTTOMRIGHT:
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002074 /* make sure hittest fits into 0xf and doesn't overlap with HTSYSMENU */
Alexandre Julliardcb25e252001-08-08 23:28:42 +00002075 SendMessageW( hwnd, WM_SYSCOMMAND, SC_SIZE + wParam - 2, lParam);
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002076 break;
2077
2078 case HTBORDER:
2079 break;
2080 }
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002081 return 0;
2082}
2083
2084
2085/***********************************************************************
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002086 * NC_HandleNCLButtonDblClk
2087 *
2088 * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc().
2089 */
Alexandre Julliardde424282001-08-10 22:51:42 +00002090LONG NC_HandleNCLButtonDblClk( HWND hwnd, WPARAM wParam, LPARAM lParam )
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002091{
Alexandre Julliard940d58c1994-09-16 09:24:37 +00002092 /*
2093 * if this is an icon, send a restore since we are handling
2094 * a double click
2095 */
Alexandre Julliardde424282001-08-10 22:51:42 +00002096 if (IsIconic(hwnd))
Alexandre Julliard940d58c1994-09-16 09:24:37 +00002097 {
Alexandre Julliardde424282001-08-10 22:51:42 +00002098 SendMessageW( hwnd, WM_SYSCOMMAND, SC_RESTORE, lParam );
Alexandre Julliard1285c2f1996-05-06 16:06:24 +00002099 return 0;
Alexandre Julliard940d58c1994-09-16 09:24:37 +00002100 }
2101
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002102 switch(wParam) /* Hit test */
2103 {
2104 case HTCAPTION:
Alexandre Julliard902da691995-11-05 14:39:02 +00002105 /* stop processing if WS_MAXIMIZEBOX is missing */
Alexandre Julliardde424282001-08-10 22:51:42 +00002106 if (GetWindowLongA( hwnd, GWL_STYLE ) & WS_MAXIMIZEBOX)
2107 SendMessageW( hwnd, WM_SYSCOMMAND,
2108 IsZoomed(hwnd) ? SC_RESTORE : SC_MAXIMIZE, lParam );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002109 break;
2110
2111 case HTSYSMENU:
Alexandre Julliardd44e4952001-08-20 18:09:39 +00002112 if (!(GetClassLongW(hwnd, GCL_STYLE) & CS_NOCLOSE))
Alexandre Julliardde424282001-08-10 22:51:42 +00002113 SendMessageW( hwnd, WM_SYSCOMMAND, SC_CLOSE, lParam );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00002114 break;
Alexandre Julliard491502b1997-11-01 19:08:16 +00002115
2116 case HTHSCROLL:
Alexandre Julliardde424282001-08-10 22:51:42 +00002117 SendMessageW( hwnd, WM_SYSCOMMAND, SC_HSCROLL + HTHSCROLL, lParam );
Alexandre Julliard491502b1997-11-01 19:08:16 +00002118 break;
2119
2120 case HTVSCROLL:
Alexandre Julliardde424282001-08-10 22:51:42 +00002121 SendMessageW( hwnd, WM_SYSCOMMAND, SC_VSCROLL + HTVSCROLL, lParam );
Alexandre Julliard491502b1997-11-01 19:08:16 +00002122 break;
Alexandre Julliardcdd09231994-01-12 11:12:51 +00002123 }
2124 return 0;
2125}
2126
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002127
2128/***********************************************************************
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002129 * NC_HandleSysCommand
2130 *
2131 * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
2132 */
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002133LONG NC_HandleSysCommand( HWND hwnd, WPARAM wParam, POINT pt )
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002134{
2135 WND *wndPtr = WIN_FindWndPtr( hwnd );
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002136 UINT16 uCommand = wParam & 0xFFF0;
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002137
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002138 TRACE("Handling WM_SYSCOMMAND %x %ld,%ld\n", wParam, pt.x, pt.y );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002139
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00002140 if (uCommand != SC_KEYMENU)
2141 {
2142 HWND parent = GetAncestor( hwnd, GA_PARENT );
2143 if (parent != GetDesktopWindow()) ScreenToClient( parent, &pt );
2144 }
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002145
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002146 switch (uCommand)
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002147 {
2148 case SC_SIZE:
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002149 case SC_MOVE:
Alexandre Julliard3abeae82001-05-09 17:21:04 +00002150 if (USER_Driver.pSysCommandSizeMove)
2151 USER_Driver.pSysCommandSizeMove( hwnd, wParam );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002152 break;
2153
2154 case SC_MINIMIZE:
Noomen Hamzad1a1f7d1999-10-24 00:02:27 +00002155 if (hwnd == GetForegroundWindow())
2156 ShowOwnedPopups(hwnd,FALSE);
Alexandre Julliarda3960291999-02-26 11:11:13 +00002157 ShowWindow( hwnd, SW_MINIMIZE );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002158 break;
2159
2160 case SC_MAXIMIZE:
Noomen Hamzad1a1f7d1999-10-24 00:02:27 +00002161 if (IsIconic(hwnd) && hwnd == GetForegroundWindow())
2162 ShowOwnedPopups(hwnd,TRUE);
Alexandre Julliarda3960291999-02-26 11:11:13 +00002163 ShowWindow( hwnd, SW_MAXIMIZE );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002164 break;
2165
2166 case SC_RESTORE:
Noomen Hamzad1a1f7d1999-10-24 00:02:27 +00002167 if (IsIconic(hwnd) && hwnd == GetForegroundWindow())
2168 ShowOwnedPopups(hwnd,TRUE);
Alexandre Julliarda3960291999-02-26 11:11:13 +00002169 ShowWindow( hwnd, SW_RESTORE );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002170 break;
2171
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002172 case SC_CLOSE:
Francois Boisvert3a3cd9f1999-03-28 12:42:52 +00002173 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002174 return SendMessageA( hwnd, WM_CLOSE, 0, 0 );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002175
2176 case SC_VSCROLL:
2177 case SC_HSCROLL:
Alexandre Julliard83f52d12000-09-26 22:20:14 +00002178 NC_TrackScrollBar( hwnd, wParam, pt );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00002179 break;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002180
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002181 case SC_MOUSEMENU:
Alexandre Julliardde424282001-08-10 22:51:42 +00002182 MENU_TrackMouseMenuBar( hwnd, wParam & 0x000F, pt );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002183 break;
2184
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002185 case SC_KEYMENU:
Alexandre Julliardde424282001-08-10 22:51:42 +00002186 MENU_TrackKbdMenuBar( hwnd, wParam , pt.x );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00002187 break;
2188
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002189 case SC_TASKLIST:
Alexandre Julliarda3960291999-02-26 11:11:13 +00002190 WinExec( "taskman.exe", SW_SHOWNORMAL );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002191 break;
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +00002192
2193 case SC_SCREENSAVE:
2194 if (wParam == SC_ABOUTWINE)
Alexandre Julliard563561e2000-01-24 05:46:47 +00002195 {
2196 HMODULE hmodule = LoadLibraryA( "shell32.dll" );
2197 if (hmodule)
2198 {
2199 FARPROC aboutproc = GetProcAddress( hmodule, "ShellAboutA" );
2200 if (aboutproc) aboutproc( hwnd, "Wine", WINE_RELEASE_INFO, 0 );
2201 FreeLibrary( hmodule );
2202 }
2203 }
Uwe Bonnes37007771998-11-01 15:07:24 +00002204 else
2205 if (wParam == SC_PUTMARK)
Alexandre Julliard06c275a1999-05-02 14:32:27 +00002206 TRACE_(shell)("Mark requested by user\n");
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +00002207 break;
Alexandre Julliard9ea19e51997-01-01 17:29:55 +00002208
2209 case SC_HOTKEY:
2210 case SC_ARRANGE:
2211 case SC_NEXTWINDOW:
2212 case SC_PREVWINDOW:
Dimitrie O. Paundd03cc11999-12-08 03:56:23 +00002213 FIXME("unimplemented!\n");
Alexandre Julliard9ea19e51997-01-01 17:29:55 +00002214 break;
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002215 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002216 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00002217 return 0;
2218}
Pascal Lessardd814bb61999-07-31 13:02:02 +00002219
2220/*************************************************************
2221* NC_DrawGrayButton
2222*
2223* Stub for the grayed button of the caption
2224*
2225*************************************************************/
2226
2227BOOL NC_DrawGrayButton(HDC hdc, int x, int y)
2228{
2229 HBITMAP hMaskBmp;
2230 HDC hdcMask = CreateCompatibleDC (0);
2231 HBRUSH hOldBrush;
2232
2233 hMaskBmp = CreateBitmap (12, 10, 1, 1, lpGrayMask);
2234
2235 if(hMaskBmp == 0)
2236 return FALSE;
2237
2238 SelectObject (hdcMask, hMaskBmp);
2239
2240 /* Draw the grayed bitmap using the mask */
2241 hOldBrush = SelectObject (hdc, RGB(128, 128, 128));
2242 BitBlt (hdc, x, y, 12, 10,
2243 hdcMask, 0, 0, 0xB8074A);
2244
2245 /* Clean up */
2246 SelectObject (hdc, hOldBrush);
2247 DeleteObject(hMaskBmp);
2248 DeleteDC (hdcMask);
2249
2250 return TRUE;
2251}