blob: 7bdbce48229153ad862d679739c7b448e06ae909 [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
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00008#include "version.h"
Alexandre Julliardcdd09231994-01-12 11:12:51 +00009#include "win.h"
Alexandre Julliarddba420a1994-02-02 06:48:31 +000010#include "message.h"
Alexandre Julliardcdd09231994-01-12 11:12:51 +000011#include "sysmetrics.h"
Alexandre Julliarddba420a1994-02-02 06:48:31 +000012#include "user.h"
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +000013#include "heap.h"
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000014#include "cursoricon.h"
Alexandre Julliard234bc241994-12-10 13:02:28 +000015#include "dialog.h"
Alexandre Julliard58199531994-04-21 01:20:00 +000016#include "syscolor.h"
Alexandre Julliard234bc241994-12-10 13:02:28 +000017#include "menu.h"
18#include "winpos.h"
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +000019#include "hook.h"
Alexandre Julliard234bc241994-12-10 13:02:28 +000020#include "scroll.h"
21#include "nonclient.h"
22#include "graphics.h"
Alexandre Julliardc981d0b1996-03-31 16:40:13 +000023#include "queue.h"
Alexandre Julliardfa68b751995-04-03 16:55:37 +000024#include "selectors.h"
Alexandre Julliardaca05781994-10-17 18:12:41 +000025#include "stddebug.h"
Alexandre Julliardd37eb361997-07-20 16:23:21 +000026#include "tweak.h"
Alexandre Julliardaca05781994-10-17 18:12:41 +000027#include "debug.h"
Alexandre Julliardd4719651995-12-12 18:49:11 +000028#include "options.h"
Alexandre Julliardaca05781994-10-17 18:12:41 +000029
Alexandre Julliardcdd09231994-01-12 11:12:51 +000030
Alexandre Julliardd37eb361997-07-20 16:23:21 +000031int NC_CaptionLeftNudge;
32int NC_CaptionTopNudge;
33int NC_SysControlNudge;
34int NC_MaxControlNudge;
35int NC_MinControlNudge;
36UINT32 NC_CaptionTextFlags;
37HBRUSH32 NC_WinHighlight95;
38HBRUSH32 NC_WinShadow95;
39
Alexandre Julliardbf9130a1996-10-13 17:45:47 +000040static HBITMAP16 hbitmapClose = 0;
41static HBITMAP16 hbitmapMinimize = 0;
42static HBITMAP16 hbitmapMinimizeD = 0;
43static HBITMAP16 hbitmapMaximize = 0;
44static HBITMAP16 hbitmapMaximizeD = 0;
45static HBITMAP16 hbitmapRestore = 0;
46static HBITMAP16 hbitmapRestoreD = 0;
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +000047
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +000048#define SC_ABOUTWINE (SC_SCREENSAVE+1)
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +000049
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +000050 /* Some useful macros */
51#define HAS_DLGFRAME(style,exStyle) \
Alexandre Julliard0c126c71996-02-18 18:44:41 +000052 (((exStyle) & WS_EX_DLGMODALFRAME) || \
53 (((style) & WS_DLGFRAME) && !((style) & WS_BORDER)))
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +000054
55#define HAS_THICKFRAME(style) \
Alexandre Julliard0c126c71996-02-18 18:44:41 +000056 (((style) & WS_THICKFRAME) && \
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +000057 !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
58
59#define HAS_MENU(w) (!((w)->dwStyle & WS_CHILD) && ((w)->wIDmenu != 0))
60
Alexandre Julliardfb9a9191994-03-01 19:48:04 +000061#define ON_LEFT_BORDER(hit) \
62 (((hit) == HTLEFT) || ((hit) == HTTOPLEFT) || ((hit) == HTBOTTOMLEFT))
63#define ON_RIGHT_BORDER(hit) \
64 (((hit) == HTRIGHT) || ((hit) == HTTOPRIGHT) || ((hit) == HTBOTTOMRIGHT))
65#define ON_TOP_BORDER(hit) \
66 (((hit) == HTTOP) || ((hit) == HTTOPLEFT) || ((hit) == HTTOPRIGHT))
67#define ON_BOTTOM_BORDER(hit) \
68 (((hit) == HTBOTTOM) || ((hit) == HTBOTTOMLEFT) || ((hit) == HTBOTTOMRIGHT))
69
Alexandre Julliardcdd09231994-01-12 11:12:51 +000070/***********************************************************************
71 * NC_AdjustRect
72 *
73 * Compute the size of the window rectangle from the size of the
74 * client rectangle.
75 */
Alexandre Julliard21979011997-03-05 08:22:35 +000076static void NC_AdjustRect( LPRECT16 rect, DWORD style, BOOL32 menu,
77 DWORD exStyle )
Alexandre Julliardcdd09231994-01-12 11:12:51 +000078{
Alexandre Julliardd37eb361997-07-20 16:23:21 +000079 if(TWEAK_Win95Look)
80 fprintf( stddeb, "NC_AdjustRect was called in Win95 mode. Aiee! "
81 "Please report this.\n" );
82
Alexandre Julliardbf9130a1996-10-13 17:45:47 +000083 if(style & WS_ICONIC) return;
Alexandre Julliard0c126c71996-02-18 18:44:41 +000084 /* Decide if the window will be managed (see CreateWindowEx) */
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +000085 if (!(Options.managed && !(style & WS_CHILD) &&
86 ((style & (WS_DLGFRAME | WS_THICKFRAME)) ||
87 (exStyle & WS_EX_DLGMODALFRAME))))
Alexandre Julliard0c126c71996-02-18 18:44:41 +000088 {
89 if (HAS_DLGFRAME( style, exStyle ))
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +000090 InflateRect16(rect, SYSMETRICS_CXDLGFRAME, SYSMETRICS_CYDLGFRAME );
Alexandre Julliard0c126c71996-02-18 18:44:41 +000091 else
92 {
93 if (HAS_THICKFRAME(style))
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +000094 InflateRect16( rect, SYSMETRICS_CXFRAME, SYSMETRICS_CYFRAME );
Alexandre Julliard0c126c71996-02-18 18:44:41 +000095 if (style & WS_BORDER)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +000096 InflateRect16( rect, SYSMETRICS_CXBORDER, SYSMETRICS_CYBORDER);
Alexandre Julliard0c126c71996-02-18 18:44:41 +000097 }
98
99 if ((style & WS_CAPTION) == WS_CAPTION)
100 rect->top -= SYSMETRICS_CYCAPTION - SYSMETRICS_CYBORDER;
101 }
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +0000102 if (menu) rect->top -= SYSMETRICS_CYMENU + SYSMETRICS_CYBORDER;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000103
Alexandre Julliard491502b1997-11-01 19:08:16 +0000104 if (style & WS_VSCROLL) rect->right += SYSMETRICS_CXVSCROLL - 1;
105 if (style & WS_HSCROLL) rect->bottom += SYSMETRICS_CYHSCROLL - 1;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000106}
107
108
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000109/******************************************************************************
110 *
111 * NC_AdjustRect95(
112 * LPRECT16 rect,
113 * DWORD style,
114 * BOOL32 menu,
115 * DWORD exStyle )
116 *
117 * Computes the size of the window based on the parameters of the client
118 * area.
119 *
120 * Bugs
121 * Most of this code is copied from NC_AdjustRect. It shouldn't be.
122 * There are some unique things about Win 95 that are being horribly
123 * neglected here. I don't know what they are, either. :-\
124 *
125 * Revision history
126 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
127 * Original cut & paste from NC_AdjustRect
128 *
129 *****************************************************************************/
130
131static void NC_AdjustRect95( LPRECT16 rect, DWORD style, BOOL32 menu,
132 DWORD exStyle )
133{
134 if(style & WS_ICONIC) return;
135
136 /* Decide if the window will be managed (see CreateWindowEx) */
137 if (!(Options.managed && !(style & WS_CHILD) &&
138 ((style & (WS_DLGFRAME | WS_THICKFRAME)) ||
139 (exStyle & WS_EX_DLGMODALFRAME))))
140 {
141 if (HAS_DLGFRAME( style, exStyle ))
142 InflateRect16(rect, SYSMETRICS_CXDLGFRAME, SYSMETRICS_CYDLGFRAME );
143 else
144 {
145 if (HAS_THICKFRAME(style))
146 InflateRect16( rect, SYSMETRICS_CXFRAME, SYSMETRICS_CYFRAME );
147 if (style & WS_BORDER)
148 InflateRect16( rect, SYSMETRICS_CXBORDER, SYSMETRICS_CYBORDER);
149 }
150
151 if ((style & WS_CAPTION) == WS_CAPTION)
152 rect->top -= SYSMETRICS_CYCAPTION - SYSMETRICS_CYBORDER;
153 }
154 if (menu) rect->top -= SYSMETRICS_CYMENU + SYSMETRICS_CYBORDER + 2;
155 else rect->top += SYSMETRICS_CYBORDER;
156
157 if (style & WS_VSCROLL) rect->right += SYSMETRICS_CXVSCROLL;
158 if (style & WS_HSCROLL) rect->bottom += SYSMETRICS_CYHSCROLL;
159}
160
161
Alexandre Julliarde658d821997-11-30 17:45:40 +0000162/***********************************************************************
163 * DrawCaptionTempA (USER32.)
164 */
165DWORD
166DrawCaptionTemp32A(HWND32 hwnd,HDC32 hdc,LPRECT32 rect,HFONT32 hfont,DWORD x1,LPCSTR str,DWORD x2) {
167 fprintf(stderr,"DrawCaptionTempA(%08x,%08x,%p,%08x,%08lx,\"%s\",%08lx),tub!\n",
168 hwnd,hdc,rect,hfont,x1,str,x2
169 );
170 return 0;
171}
172
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000173
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000174/***********************************************************************
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000175 * AdjustWindowRect16 (USER.102)
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000176 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000177BOOL16 WINAPI AdjustWindowRect16( LPRECT16 rect, DWORD style, BOOL16 menu )
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000178{
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000179 return AdjustWindowRectEx16( rect, style, menu, 0 );
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000180}
181
182
183/***********************************************************************
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000184 * AdjustWindowRect32 (USER32.)
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000185 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000186BOOL32 WINAPI AdjustWindowRect32( LPRECT32 rect, DWORD style, BOOL32 menu )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000187{
188 return AdjustWindowRectEx32( rect, style, menu, 0 );
189}
190
191
192/***********************************************************************
193 * AdjustWindowRectEx16 (USER.454)
194 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000195BOOL16 WINAPI AdjustWindowRectEx16( LPRECT16 rect, DWORD style,
196 BOOL16 menu, DWORD exStyle )
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000197{
198 /* Correct the window style */
199
200 if (!(style & (WS_POPUP | WS_CHILD))) /* Overlapped window */
201 style |= WS_CAPTION;
Alexandre Julliard84c70f51997-05-09 08:40:27 +0000202 style &= (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME | WS_CHILD);
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000203 exStyle &= WS_EX_DLGMODALFRAME;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000204 if (exStyle & WS_EX_DLGMODALFRAME) style &= ~WS_THICKFRAME;
205
Alexandre Julliard59730ae1996-03-24 16:20:51 +0000206 dprintf_nonclient(stddeb, "AdjustWindowRectEx: (%d,%d)-(%d,%d) %08lx %d %08lx\n",
207 rect->left, rect->top, rect->right, rect->bottom,
208 style, menu, exStyle );
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000209
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000210 if(TWEAK_Win95Look)
211 NC_AdjustRect95( rect, style, menu, exStyle );
212 else
213 NC_AdjustRect( rect, style, menu, exStyle );
214
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000215 return TRUE;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000216}
217
218
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000219/***********************************************************************
220 * AdjustWindowRectEx32 (USER32.)
221 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000222BOOL32 WINAPI AdjustWindowRectEx32( LPRECT32 rect, DWORD style,
223 BOOL32 menu, DWORD exStyle )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000224{
225 RECT16 rect16;
226 BOOL32 ret;
227
228 CONV_RECT32TO16( rect, &rect16 );
229 ret = AdjustWindowRectEx16( &rect16, style, (BOOL16)menu, exStyle );
230 CONV_RECT16TO32( &rect16, rect );
231 return ret;
232}
233
234
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000235/***********************************************************************
236 * NC_HandleNCCalcSize
237 *
238 * Handle a WM_NCCALCSIZE message. Called from DefWindowProc().
239 */
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000240LONG NC_HandleNCCalcSize( WND *pWnd, RECT32 *winRect )
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000241{
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000242 RECT16 tmpRect = { 0, 0, 0, 0 };
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +0000243 LONG result = 0;
244
245 if (pWnd->class->style & CS_VREDRAW) result |= WVR_VREDRAW;
246 if (pWnd->class->style & CS_HREDRAW) result |= WVR_HREDRAW;
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000247
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000248 if( !( pWnd->dwStyle & WS_MINIMIZE ) ) {
249 if(TWEAK_Win95Look)
250 NC_AdjustRect95( &tmpRect, pWnd->dwStyle, FALSE, pWnd->dwExStyle );
251 else
252 NC_AdjustRect( &tmpRect, pWnd->dwStyle, FALSE, pWnd->dwExStyle );
Alexandre Julliard1e37a181996-08-18 16:21:52 +0000253
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000254 winRect->left -= tmpRect.left;
255 winRect->top -= tmpRect.top;
256 winRect->right -= tmpRect.right;
257 winRect->bottom -= tmpRect.bottom;
258
259 if (HAS_MENU(pWnd)) {
260 dprintf_nonclient( stddeb, "NC_HandleNCCalcSize: Calling "
261 "GetMenuBarHeight with HWND 0x%x, width %d, "
262 "at (%d, %d).\n", pWnd->hwndSelf,
263 winRect->right - winRect->left,
264 -tmpRect.left, -tmpRect.top );
265
266 winRect->top +=
267 MENU_GetMenuBarHeight( pWnd->hwndSelf,
268 winRect->right - winRect->left,
269 -tmpRect.left, -tmpRect.top ) + 1;
270 }
Alexandre Julliard2d159fb1994-07-15 16:04:31 +0000271 }
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +0000272 return result;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000273}
274
275
276/***********************************************************************
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000277 * NC_GetInsideRect
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000278 *
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000279 * Get the 'inside' rectangle of a window, i.e. the whole window rectangle
280 * but without the borders (if any).
281 * The rectangle is in window coordinates (for drawing with GetWindowDC()).
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000282 *
283 * FIXME: A Win95 version of this function is needed.
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000284 */
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000285static void NC_GetInsideRect( HWND32 hwnd, RECT32 *rect )
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000286{
287 WND * wndPtr = WIN_FindWndPtr( hwnd );
288
289 rect->top = rect->left = 0;
290 rect->right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
291 rect->bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
292
Alexandre Julliard84c70f51997-05-09 08:40:27 +0000293 if ((wndPtr->dwStyle & WS_ICONIC) || (wndPtr->flags & WIN_MANAGED)) return;
Alexandre Julliard3ed37e01994-11-07 18:20:42 +0000294
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000295 /* Remove frame from rectangle */
296 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000297 {
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000298 InflateRect32( rect, -SYSMETRICS_CXDLGFRAME, -SYSMETRICS_CYDLGFRAME);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000299 if (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME)
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000300 InflateRect32( rect, -1, 0 );
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000301 }
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000302 else
303 {
304 if (HAS_THICKFRAME( wndPtr->dwStyle ))
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000305 InflateRect32( rect, -SYSMETRICS_CXFRAME, -SYSMETRICS_CYFRAME );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000306 if (wndPtr->dwStyle & WS_BORDER)
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000307 InflateRect32( rect, -SYSMETRICS_CXBORDER, -SYSMETRICS_CYBORDER );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000308 }
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000309
310 return;
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000311}
312
313
314/***********************************************************************
Alexandre Julliard940d58c1994-09-16 09:24:37 +0000315 * NC_HandleNCHitTest
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000316 *
Alexandre Julliard940d58c1994-09-16 09:24:37 +0000317 * Handle a WM_NCHITTEST message. Called from DefWindowProc().
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000318 *
319 * FIXME: A Win95 version of this function is needed.
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000320 */
Alexandre Julliard139a4b11996-11-02 14:24:07 +0000321LONG NC_HandleNCHitTest( HWND32 hwnd, POINT16 pt )
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000322{
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000323 RECT16 rect;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000324 WND *wndPtr = WIN_FindWndPtr( hwnd );
325 if (!wndPtr) return HTERROR;
326
Alexandre Julliard59730ae1996-03-24 16:20:51 +0000327 dprintf_nonclient(stddeb, "NC_HandleNCHitTest: hwnd=%04x pt=%d,%d\n",
328 hwnd, pt.x, pt.y );
Alexandre Julliard940d58c1994-09-16 09:24:37 +0000329
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000330 GetWindowRect16( hwnd, &rect );
331 if (!PtInRect16( &rect, pt )) return HTNOWHERE;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000332
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000333 if (wndPtr->dwStyle & WS_MINIMIZE) return HTCAPTION;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000334
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000335 if (!(wndPtr->flags & WIN_MANAGED))
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000336 {
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000337 /* Check borders */
338 if (HAS_THICKFRAME( wndPtr->dwStyle ))
339 {
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000340 InflateRect16( &rect, -SYSMETRICS_CXFRAME, -SYSMETRICS_CYFRAME );
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000341 if (wndPtr->dwStyle & WS_BORDER)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000342 InflateRect16(&rect,-SYSMETRICS_CXBORDER,-SYSMETRICS_CYBORDER);
343 if (!PtInRect16( &rect, pt ))
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000344 {
345 /* Check top sizing border */
346 if (pt.y < rect.top)
347 {
348 if (pt.x < rect.left+SYSMETRICS_CXSIZE) return HTTOPLEFT;
349 if (pt.x >= rect.right-SYSMETRICS_CXSIZE) return HTTOPRIGHT;
350 return HTTOP;
351 }
352 /* Check bottom sizing border */
353 if (pt.y >= rect.bottom)
354 {
355 if (pt.x < rect.left+SYSMETRICS_CXSIZE) return HTBOTTOMLEFT;
356 if (pt.x >= rect.right-SYSMETRICS_CXSIZE) return HTBOTTOMRIGHT;
357 return HTBOTTOM;
358 }
359 /* Check left sizing border */
360 if (pt.x < rect.left)
361 {
362 if (pt.y < rect.top+SYSMETRICS_CYSIZE) return HTTOPLEFT;
363 if (pt.y >= rect.bottom-SYSMETRICS_CYSIZE) return HTBOTTOMLEFT;
364 return HTLEFT;
365 }
366 /* Check right sizing border */
367 if (pt.x >= rect.right)
368 {
369 if (pt.y < rect.top+SYSMETRICS_CYSIZE) return HTTOPRIGHT;
370 if (pt.y >= rect.bottom-SYSMETRICS_CYSIZE) return HTBOTTOMRIGHT;
371 return HTRIGHT;
372 }
373 }
374 }
375 else /* No thick frame */
376 {
377 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000378 InflateRect16(&rect, -SYSMETRICS_CXDLGFRAME, -SYSMETRICS_CYDLGFRAME);
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000379 else if (wndPtr->dwStyle & WS_BORDER)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000380 InflateRect16(&rect, -SYSMETRICS_CXBORDER, -SYSMETRICS_CYBORDER);
381 if (!PtInRect16( &rect, pt )) return HTBORDER;
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000382 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000383
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000384 /* Check caption */
Alexandre Julliardf7207251994-07-23 07:57:48 +0000385
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000386 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
387 {
388 rect.top += SYSMETRICS_CYCAPTION - 1;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000389 if (!PtInRect16( &rect, pt ))
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000390 {
391 /* Check system menu */
392 if (wndPtr->dwStyle & WS_SYSMENU)
393 rect.left += SYSMETRICS_CXSIZE;
394 if (pt.x <= rect.left) return HTSYSMENU;
395 /* Check maximize box */
396 if (wndPtr->dwStyle & WS_MAXIMIZEBOX)
397 rect.right -= SYSMETRICS_CXSIZE + 1;
398 if (pt.x >= rect.right) return HTMAXBUTTON;
399 /* Check minimize box */
400 if (wndPtr->dwStyle & WS_MINIMIZEBOX)
401 rect.right -= SYSMETRICS_CXSIZE + 1;
402 if (pt.x >= rect.right) return HTMINBUTTON;
403 return HTCAPTION;
404 }
405 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000406 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000407
Alexandre Julliardf7207251994-07-23 07:57:48 +0000408 /* Check client area */
409
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000410 ScreenToClient16( hwnd, &pt );
411 GetClientRect16( hwnd, &rect );
412 if (PtInRect16( &rect, pt )) return HTCLIENT;
Alexandre Julliardf7207251994-07-23 07:57:48 +0000413
414 /* Check vertical scroll bar */
415
416 if (wndPtr->dwStyle & WS_VSCROLL)
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000417 {
Alexandre Julliardf7207251994-07-23 07:57:48 +0000418 rect.right += SYSMETRICS_CXVSCROLL;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000419 if (PtInRect16( &rect, pt )) return HTVSCROLL;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000420 }
421
Alexandre Julliardf7207251994-07-23 07:57:48 +0000422 /* Check horizontal scroll bar */
423
424 if (wndPtr->dwStyle & WS_HSCROLL)
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000425 {
Alexandre Julliardf7207251994-07-23 07:57:48 +0000426 rect.bottom += SYSMETRICS_CYHSCROLL;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000427 if (PtInRect16( &rect, pt ))
Alexandre Julliardf7207251994-07-23 07:57:48 +0000428 {
429 /* Check size box */
430 if ((wndPtr->dwStyle & WS_VSCROLL) &&
431 (pt.x >= rect.right - SYSMETRICS_CXVSCROLL))
432 return HTSIZE;
433 return HTHSCROLL;
434 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000435 }
436
Alexandre Julliardf7207251994-07-23 07:57:48 +0000437 /* Check menu bar */
438
439 if (HAS_MENU(wndPtr))
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000440 {
Alexandre Julliardf7207251994-07-23 07:57:48 +0000441 if ((pt.y < 0) && (pt.x >= 0) && (pt.x < rect.right))
442 return HTMENU;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000443 }
444
445 /* Should never get here */
446 return HTERROR;
447}
448
449
450/***********************************************************************
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000451 * NC_DrawSysButton
452 */
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000453void NC_DrawSysButton( HWND32 hwnd, HDC32 hdc, BOOL32 down )
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000454{
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000455 RECT32 rect;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000456 HDC32 hdcMem;
457 HBITMAP32 hbitmap;
Alexandre Julliard1f579291994-05-25 16:25:21 +0000458 WND *wndPtr = WIN_FindWndPtr( hwnd );
Alexandre Julliard7cbe6571995-01-09 18:21:16 +0000459
Alexandre Julliard1e37a181996-08-18 16:21:52 +0000460 if( !(wndPtr->flags & WIN_MANAGED) )
461 {
462 NC_GetInsideRect( hwnd, &rect );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000463 hdcMem = CreateCompatibleDC32( hdc );
Alexandre Julliard139a4b11996-11-02 14:24:07 +0000464 hbitmap = SelectObject32( hdcMem, hbitmapClose );
Alexandre Julliard75d86e11996-11-17 18:59:11 +0000465 BitBlt32(hdc, rect.left, rect.top, SYSMETRICS_CXSIZE, SYSMETRICS_CYSIZE,
466 hdcMem, (wndPtr->dwStyle & WS_CHILD) ? SYSMETRICS_CXSIZE : 0, 0,
467 down ? NOTSRCCOPY : SRCCOPY );
Alexandre Julliard139a4b11996-11-02 14:24:07 +0000468 SelectObject32( hdcMem, hbitmap );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000469 DeleteDC32( hdcMem );
Alexandre Julliard1e37a181996-08-18 16:21:52 +0000470 }
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000471}
472
473
474/***********************************************************************
475 * NC_DrawMaxButton
476 */
Alexandre Julliard21979011997-03-05 08:22:35 +0000477static void NC_DrawMaxButton( HWND32 hwnd, HDC16 hdc, BOOL32 down )
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000478{
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000479 RECT32 rect;
Alexandre Julliard1e37a181996-08-18 16:21:52 +0000480 WND *wndPtr = WIN_FindWndPtr( hwnd );
481
482 if( !(wndPtr->flags & WIN_MANAGED) )
483 {
484 NC_GetInsideRect( hwnd, &rect );
Alexandre Julliard7ff1c411997-05-25 13:58:18 +0000485 GRAPH_DrawBitmap( hdc, (IsZoomed32(hwnd)
486 ? (down ? hbitmapRestoreD : hbitmapRestore)
487 : (down ? hbitmapMaximizeD : hbitmapMaximize)),
Alexandre Julliard1e37a181996-08-18 16:21:52 +0000488 rect.right - SYSMETRICS_CXSIZE - 1, rect.top,
Alexandre Julliard7ff1c411997-05-25 13:58:18 +0000489 0, 0, SYSMETRICS_CXSIZE+1, SYSMETRICS_CYSIZE, FALSE );
Alexandre Julliard1e37a181996-08-18 16:21:52 +0000490 }
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000491}
492
493
494/***********************************************************************
495 * NC_DrawMinButton
496 */
Alexandre Julliard21979011997-03-05 08:22:35 +0000497static void NC_DrawMinButton( HWND32 hwnd, HDC16 hdc, BOOL32 down )
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000498{
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000499 RECT32 rect;
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000500 WND *wndPtr = WIN_FindWndPtr( hwnd );
Alexandre Julliard1e37a181996-08-18 16:21:52 +0000501
502 if( !(wndPtr->flags & WIN_MANAGED) )
503 {
504 NC_GetInsideRect( hwnd, &rect );
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000505 if (wndPtr->dwStyle & WS_MAXIMIZEBOX) rect.right -= SYSMETRICS_CXSIZE+1;
Alexandre Julliard1e37a181996-08-18 16:21:52 +0000506 GRAPH_DrawBitmap( hdc, (down ? hbitmapMinimizeD : hbitmapMinimize),
507 rect.right - SYSMETRICS_CXSIZE - 1, rect.top,
Alexandre Julliard7ff1c411997-05-25 13:58:18 +0000508 0, 0, SYSMETRICS_CXSIZE+1, SYSMETRICS_CYSIZE, FALSE );
Alexandre Julliard1e37a181996-08-18 16:21:52 +0000509 }
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000510}
511
512
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000513/******************************************************************************
514 *
515 * void NC_DrawSysButton95(
516 * HWND32 hwnd,
517 * HDC32 hdc,
518 * BOOL32 down )
519 *
520 * Draws a fake Win95 system button. Horribly broken. We should be drawing
521 * an icon, not the X. (This will require some thought)
522 *
523 * Bugs
524 * Plain and simply doesn't work. Fails miserably for child windows.
525 *
526 * Revision history
527 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
528 * Original implementation from NC_DrawSysButton source.
529 *
530 *****************************************************************************/
531
532void NC_DrawSysButton95(
533 HWND32 hwnd,
534 HDC32 hdc,
535 BOOL32 down )
536{
537 RECT32 rect;
538 HDC32 hdcMem;
539 HBITMAP32 hbitmap;
540 WND *wndPtr = WIN_FindWndPtr( hwnd );
541 SIZE32 bmsz;
542
543 if( !(wndPtr->flags & WIN_MANAGED) )
544 {
545 NC_GetInsideRect( hwnd, &rect );
546 hdcMem = CreateCompatibleDC32( hdc );
547 hbitmap = SelectObject32( hdcMem, hbitmapClose );
548 if(GetBitmapDimensionEx32( hbitmapClose, &bmsz )) {
549 BitBlt32(hdc, rect.left + (sysMetrics[SM_CXSIZE] - bmsz.cx) / 2 +
550 NC_SysControlNudge,
551 rect.top + (sysMetrics[SM_CYSIZE] - bmsz.cy - 1) / 2,
552 bmsz.cx, bmsz.cy,
553 hdcMem, 0, 0, down ? NOTSRCCOPY : SRCCOPY );
554 }
555 SelectObject32( hdcMem, hbitmap );
556 DeleteDC32( hdcMem );
557
558 }
559 return;
560}
561
562
563/******************************************************************************
564 *
565 * NC_DrawMaxButton95(
566 * HWND32 hwnd,
567 * HDC16 hdc,
568 * BOOL32 down )
569 *
570 * Draws the maximize button for Win95 style windows.
571 *
572 * Bugs
573 * Many. Spacing might still be incorrect. Need to fit a close
574 * button between the max button and the edge. Draws the wrong thing
575 * (a Win31 up-down) when maximized. Should scale the image with the
576 * title bar. And more...
577 *
578 * Revision history
579 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
580 * Original implementation.
581 *
582 *****************************************************************************/
583
584static void NC_DrawMaxButton95(
585 HWND32 hwnd,
586 HDC16 hdc,
587 BOOL32 down )
588{
589 RECT32 rect;
590 WND *wndPtr = WIN_FindWndPtr( hwnd );
591 SIZE32 bmsz;
592 HBITMAP32 bm;
593
594 if( !(wndPtr->flags & WIN_MANAGED) &&
595 GetBitmapDimensionEx32((bm = IsZoomed32(hwnd) ?
596 (down ? hbitmapRestoreD : hbitmapRestore ) :
597 (down ? hbitmapMaximizeD : hbitmapMaximize)),
598 &bmsz)) {
599
600 NC_GetInsideRect( hwnd, &rect );
601
602 GRAPH_DrawBitmap( hdc, bm,
603 rect.right + NC_MaxControlNudge -
604 (sysMetrics[SM_CXSIZE] + bmsz.cx) / 2,
605 rect.top + (sysMetrics[SM_CYSIZE] - bmsz.cy - 1) / 2,
606 0, 0, bmsz.cx, bmsz.cy, FALSE );
607 }
608
609 return;
610}
611
612
613/******************************************************************************
614 *
615 * NC_DrawMinButton95(
616 * HWND32 hwnd,
617 * HDC16 hdc,
618 * BOOL32 down )
619 *
620 * Draws the minimize button for Win95 style windows.
621 *
622 * Bugs
623 * Many. Spacing is still incorrect. Should scale the image with the
624 * title bar. And more...
625 *
626 * Revision history
627 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
628 * Original implementation.
629 *
630 *****************************************************************************/
631
632static void NC_DrawMinButton95(
633 HWND32 hwnd,
634 HDC16 hdc,
635 BOOL32 down )
636{
637 RECT32 rect;
638 WND *wndPtr = WIN_FindWndPtr( hwnd );
639 SIZE32 bmsz;
640 HBITMAP32 bm;
641
642 if( !(wndPtr->flags & WIN_MANAGED) &&
643 GetBitmapDimensionEx32((bm = down ? hbitmapMinimizeD :
644 hbitmapMinimize), &bmsz)) {
645
646 NC_GetInsideRect( hwnd, &rect );
647
648 if (wndPtr->dwStyle & WS_MAXIMIZEBOX)
649 rect.right += -1 + NC_MaxControlNudge -
650 (sysMetrics[SM_CXSIZE] + bmsz.cx) / 2;
651
652 GRAPH_DrawBitmap( hdc, bm, rect.right + NC_MinControlNudge -
653 (sysMetrics[SM_CXSIZE] + bmsz.cx) / 2,
654 rect.top + (sysMetrics[SM_CYSIZE] - bmsz.cy - 1) / 2,
655 0, 0, bmsz.cx, bmsz.cy, FALSE );
656 }
657
658 return;
659}
660
661
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000662/***********************************************************************
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000663 * NC_DrawFrame
664 *
665 * Draw a window frame inside the given rectangle, and update the rectangle.
Alexandre Julliardaca05781994-10-17 18:12:41 +0000666 * The correct pen for the frame must be selected in the DC.
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000667 */
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000668static void NC_DrawFrame( HDC32 hdc, RECT32 *rect, BOOL32 dlgFrame,
Alexandre Julliard21979011997-03-05 08:22:35 +0000669 BOOL32 active )
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000670{
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000671 INT32 width, height;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000672
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000673 if(TWEAK_Win95Look)
674 fprintf( stddeb, "NC_DrawFrame was called in Win95 mode. Aiee! "
675 "Please report this.\n" );
676
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000677 if (dlgFrame)
678 {
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000679 width = SYSMETRICS_CXDLGFRAME - 1;
680 height = SYSMETRICS_CYDLGFRAME - 1;
Alexandre Julliard139a4b11996-11-02 14:24:07 +0000681 SelectObject32( hdc, active ? sysColorObjects.hbrushActiveCaption :
682 sysColorObjects.hbrushInactiveCaption );
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000683 }
684 else
685 {
686 width = SYSMETRICS_CXFRAME - 1;
687 height = SYSMETRICS_CYFRAME - 1;
Alexandre Julliard139a4b11996-11-02 14:24:07 +0000688 SelectObject32( hdc, active ? sysColorObjects.hbrushActiveBorder :
689 sysColorObjects.hbrushInactiveBorder );
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000690 }
691
692 /* Draw frame */
Alexandre Julliard75d86e11996-11-17 18:59:11 +0000693 PatBlt32( hdc, rect->left, rect->top,
694 rect->right - rect->left, height, PATCOPY );
695 PatBlt32( hdc, rect->left, rect->top,
696 width, rect->bottom - rect->top, PATCOPY );
697 PatBlt32( hdc, rect->left, rect->bottom,
698 rect->right - rect->left, -height, PATCOPY );
699 PatBlt32( hdc, rect->right, rect->top,
700 -width, rect->bottom - rect->top, PATCOPY );
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000701
702 if (dlgFrame)
703 {
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000704 InflateRect32( rect, -width, -height );
705 }
706 else
707 {
708 POINT32 lpt[16];
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000709
710 /* Draw inner rectangle */
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000711
712 GRAPH_DrawRectangle( hdc, rect->left + width,
713 rect->top + height,
714 rect->right - rect->left - 2*width ,
715 rect->bottom - rect->top - 2*height,
716 (HPEN32)0 );
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000717
718 /* Draw the decorations */
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000719
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000720 lpt[4].x = lpt[0].x = rect->left;
721 lpt[5].x = lpt[1].x = rect->left + width;
Alexandre Julliard77b99181997-09-14 17:17:23 +0000722 lpt[6].x = lpt[2].x = rect->right - 1;
723 lpt[7].x = lpt[3].x = rect->right - width - 1;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000724
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000725 lpt[0].y = lpt[1].y = lpt[2].y = lpt[3].y =
726 rect->top + SYSMETRICS_CYFRAME + SYSMETRICS_CYSIZE;
727 lpt[4].y = lpt[5].y = lpt[6].y = lpt[7].y =
Alexandre Julliard77b99181997-09-14 17:17:23 +0000728 rect->bottom - SYSMETRICS_CYFRAME - SYSMETRICS_CYSIZE;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000729
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000730 lpt[8].x = lpt[9].x = lpt[10].x = lpt[11].x =
731 rect->left + SYSMETRICS_CXFRAME + SYSMETRICS_CXSIZE;
732 lpt[12].x = lpt[13].x = lpt[14].x = lpt[15].x =
Alexandre Julliard77b99181997-09-14 17:17:23 +0000733 rect->right - SYSMETRICS_CXFRAME - SYSMETRICS_CYSIZE;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000734
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000735 lpt[12].y = lpt[8].y = rect->top;
736 lpt[13].y = lpt[9].y = rect->top + height;
Alexandre Julliard77b99181997-09-14 17:17:23 +0000737 lpt[14].y = lpt[10].y = rect->bottom - 1;
738 lpt[15].y = lpt[11].y = rect->bottom - height - 1;
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000739
740 GRAPH_DrawLines( hdc, lpt, 8, (HPEN32)0 ); /* 8 is the maximum */
741 InflateRect32( rect, -width - 1, -height - 1 );
742 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000743}
744
745
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000746/******************************************************************************
747 *
748 * void NC_DrawFrame95(
749 * HDC32 hdc,
750 * RECT32 *rect,
751 * BOOL32 dlgFrame,
752 * BOOL32 active )
753 *
754 * Draw a window frame inside the given rectangle, and update the rectangle.
755 * The correct pen for the frame must be selected in the DC.
756 *
757 * Bugs
758 * Many. First, just what IS a frame in Win95? Note that the 3D look
759 * on the outer edge is handled by NC_DoNCPaint95. As is the inner
760 * edge. The inner rectangle just inside the frame is handled by the
761 * Caption code.
762 *
763 * In short, for most people, this function should be a nop (unless
764 * you LIKE thick borders in Win95/NT4.0 -- I've been working with
765 * them lately, but just to get this code right). Even so, it doesn't
766 * appear to be so. It's being worked on...
767 *
768 * Revision history
769 * 06-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
770 * Original implementation (based on NC_DrawFrame)
771 *
772 *****************************************************************************/
773
774static void NC_DrawFrame95(
775 HDC32 hdc,
776 RECT32 *rect,
777 BOOL32 dlgFrame,
778 BOOL32 active )
779{
780 INT32 width, height;
781
782 if (dlgFrame)
783 {
784 width = SYSMETRICS_CXDLGFRAME - 1;
785 height = SYSMETRICS_CYDLGFRAME - 1;
786 SelectObject32( hdc, active ? sysColorObjects.hbrushActiveCaption :
787 sysColorObjects.hbrushInactiveCaption );
788 }
789 else
790 {
791 width = sysMetrics[SM_CXFRAME] - sysMetrics[SM_CXEDGE] - 1;
792 height = sysMetrics[SM_CYFRAME] - sysMetrics[SM_CYEDGE] - 1;
793 SelectObject32( hdc, active ? sysColorObjects.hbrushActiveBorder :
794 sysColorObjects.hbrushInactiveBorder );
795 }
796
797 /* Draw frame */
798 PatBlt32( hdc, rect->left, rect->top,
799 rect->right - rect->left, height, PATCOPY );
800 PatBlt32( hdc, rect->left, rect->top,
801 width, rect->bottom - rect->top, PATCOPY );
802 PatBlt32( hdc, rect->left, rect->bottom,
803 rect->right - rect->left, -height, PATCOPY );
804 PatBlt32( hdc, rect->right, rect->top,
805 -width, rect->bottom - rect->top, PATCOPY );
806
807 InflateRect32( rect, -width, -height );
808
809 if(!dlgFrame) {
810 /* Draw inner rectangle */
811 GRAPH_DrawRectangle( hdc, rect->left, rect->top,
812 rect->right - rect->left,
813 rect->bottom - rect->top,
814 TWEAK_PenC095 );
815
816 InflateRect32( rect, -1, -1 );
817 }
818}
819
820
821
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000822/***********************************************************************
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000823 * NC_DrawMovingFrame
824 *
825 * Draw the frame used when moving or resizing window.
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000826 *
827 * FIXME: This causes problems in Win95 mode. (why?)
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000828 */
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000829static void NC_DrawMovingFrame( HDC32 hdc, RECT32 *rect, BOOL32 thickframe )
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000830{
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000831 if (thickframe)
832 {
833 RECT16 r16;
834 CONV_RECT32TO16( rect, &r16 );
835 FastWindowFrame( hdc, &r16, SYSMETRICS_CXFRAME,
836 SYSMETRICS_CYFRAME, PATINVERT );
837 }
838 else DrawFocusRect32( hdc, rect );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000839}
840
841
842/***********************************************************************
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000843 * NC_DrawCaption
844 *
845 * Draw the window caption.
846 * The correct pen for the window frame must be selected in the DC.
847 */
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000848static void NC_DrawCaption( HDC32 hdc, RECT32 *rect, HWND32 hwnd,
Alexandre Julliard21979011997-03-05 08:22:35 +0000849 DWORD style, BOOL32 active )
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000850{
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000851 RECT32 r = *rect;
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000852 WND * wndPtr = WIN_FindWndPtr( hwnd );
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000853 char buffer[256];
854
Alexandre Julliard1e37a181996-08-18 16:21:52 +0000855 if (wndPtr->flags & WIN_MANAGED) return;
856
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000857 if (!hbitmapClose)
858 {
Alexandre Julliard18f92e71996-07-17 20:02:21 +0000859 if (!(hbitmapClose = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_CLOSE) )))
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000860 return;
Alexandre Julliard18f92e71996-07-17 20:02:21 +0000861 hbitmapMinimize = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_REDUCE) );
862 hbitmapMinimizeD = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_REDUCED) );
863 hbitmapMaximize = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_ZOOM) );
864 hbitmapMaximizeD = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_ZOOMD) );
865 hbitmapRestore = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_RESTORE) );
866 hbitmapRestoreD = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_RESTORED) );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000867 }
868
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000869 if (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME)
870 {
Alexandre Julliard139a4b11996-11-02 14:24:07 +0000871 HBRUSH32 hbrushOld = SelectObject32(hdc, sysColorObjects.hbrushWindow);
Alexandre Julliard75d86e11996-11-17 18:59:11 +0000872 PatBlt32( hdc, r.left, r.top, 1, r.bottom-r.top+1,PATCOPY );
873 PatBlt32( hdc, r.right-1, r.top, 1, r.bottom-r.top+1, PATCOPY );
874 PatBlt32( hdc, r.left, r.top-1, r.right-r.left, 1, PATCOPY );
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000875 r.left++;
876 r.right--;
Alexandre Julliard139a4b11996-11-02 14:24:07 +0000877 SelectObject32( hdc, hbrushOld );
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000878 }
879
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000880 MoveTo( hdc, r.left, r.bottom );
Alexandre Julliard77b99181997-09-14 17:17:23 +0000881 LineTo32( hdc, r.right, r.bottom );
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000882
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000883 if (style & WS_SYSMENU)
884 {
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000885 NC_DrawSysButton( hwnd, hdc, FALSE );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000886 r.left += SYSMETRICS_CXSIZE + 1;
887 MoveTo( hdc, r.left - 1, r.top );
Alexandre Julliard139a4b11996-11-02 14:24:07 +0000888 LineTo32( hdc, r.left - 1, r.bottom );
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000889 }
890 if (style & WS_MAXIMIZEBOX)
891 {
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000892 NC_DrawMaxButton( hwnd, hdc, FALSE );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000893 r.right -= SYSMETRICS_CXSIZE + 1;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000894 }
895 if (style & WS_MINIMIZEBOX)
896 {
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000897 NC_DrawMinButton( hwnd, hdc, FALSE );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +0000898 r.right -= SYSMETRICS_CXSIZE + 1;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000899 }
900
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000901 FillRect32( hdc, &r, active ? sysColorObjects.hbrushActiveCaption :
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000902 sysColorObjects.hbrushInactiveCaption );
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000903
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000904 if (GetWindowText32A( hwnd, buffer, sizeof(buffer) ))
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000905 {
Alexandre Julliard21979011997-03-05 08:22:35 +0000906 if (active) SetTextColor32( hdc, GetSysColor32( COLOR_CAPTIONTEXT ) );
907 else SetTextColor32( hdc, GetSysColor32( COLOR_INACTIVECAPTIONTEXT ) );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000908 SetBkMode32( hdc, TRANSPARENT );
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000909 DrawText32A( hdc, buffer, -1, &r,
910 DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_NOPREFIX );
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000911 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000912}
913
914
Alexandre Julliardd37eb361997-07-20 16:23:21 +0000915/******************************************************************************
916 *
917 * NC_DrawCaption95(
918 * HDC32 hdc,
919 * RECT32 *rect,
920 * HWND32 hwnd,
921 * DWORD style,
922 * BOOL32 active )
923 *
924 * Draw the window caption for Win95 style windows.
925 * The correct pen for the window frame must be selected in the DC.
926 *
927 * Bugs
928 * Hey, a function that finally works! Well, almost. In Win95, the
929 * title has its own font -- not the system font. It's being worked
930 * on.
931 *
932 * Revision history
933 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
934 * Original implementation.
935 *
936 *****************************************************************************/
937
938static void NC_DrawCaption95(
939 HDC32 hdc,
940 RECT32 *rect,
941 HWND32 hwnd,
942 DWORD style,
943 BOOL32 active )
944{
945 RECT32 r = *rect;
946 WND *wndPtr = WIN_FindWndPtr( hwnd );
947 char buffer[256];
948
949 if (wndPtr->flags & WIN_MANAGED) return;
950
951 FillRect32( hdc, &r, active ? sysColorObjects.hbrushActiveCaption :
952 sysColorObjects.hbrushInactiveCaption );
953
954 if (!hbitmapClose) {
955 if (!(hbitmapClose = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_CLOSE) )))
956 return;
957 hbitmapMinimize = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_REDUCE) );
958 hbitmapMinimizeD = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_REDUCED) );
959 hbitmapMaximize = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_ZOOM) );
960 hbitmapMaximizeD = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_ZOOMD) );
961 hbitmapRestore = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_RESTORE) );
962 hbitmapRestoreD = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_RESTORED) );
963 }
964
965 if (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME) {
966 HBRUSH32 hbrushOld = SelectObject32(hdc, sysColorObjects.hbrushWindow);
967 PatBlt32( hdc, r.left, r.top, 1, r.bottom-r.top+1,PATCOPY );
968 PatBlt32( hdc, r.right-1, r.top, 1, r.bottom-r.top+1, PATCOPY );
969 PatBlt32( hdc, r.left, r.top-1, r.right-r.left, 1, PATCOPY );
970 r.left++;
971 r.right--;
972 SelectObject32( hdc, hbrushOld );
973 }
974
975 if (style & WS_SYSMENU) {
976 NC_DrawSysButton95( hwnd, hdc, FALSE );
977 r.left += SYSMETRICS_CXSIZE + 1;
978 }
979 if (style & WS_MAXIMIZEBOX) {
980 NC_DrawMaxButton95( hwnd, hdc, FALSE );
981 r.right -= SYSMETRICS_CXSIZE + 1;
982 }
983 if (style & WS_MINIMIZEBOX) {
984 NC_DrawMinButton95( hwnd, hdc, FALSE );
985 r.right -= SYSMETRICS_CXSIZE + 1;
986 }
987
988 if (GetWindowText32A( hwnd, buffer, sizeof(buffer) )) {
989 if (active) SetTextColor32( hdc, GetSysColor32( COLOR_CAPTIONTEXT ) );
990 else SetTextColor32( hdc, GetSysColor32( COLOR_INACTIVECAPTIONTEXT ) );
991 SetBkMode32( hdc, TRANSPARENT );
992 r.top += NC_CaptionTopNudge - 2;
993 r.left += NC_CaptionLeftNudge;
994 DrawText32A( hdc, buffer, -1, &r, NC_CaptionTextFlags );
995 }
996}
997
998
999
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001000/***********************************************************************
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001001 * NC_DoNCPaint
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001002 *
Alexandre Julliardc981d0b1996-03-31 16:40:13 +00001003 * Paint the non-client area. clip is currently unused.
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001004 */
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001005void NC_DoNCPaint( WND* wndPtr, HRGN32 clip, BOOL32 suppress_menupaint )
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001006{
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001007 HDC32 hdc;
Alexandre Julliarddf2673b1997-03-29 17:20:20 +00001008 RECT32 rect;
Alexandre Julliard139a4b11996-11-02 14:24:07 +00001009 BOOL32 active;
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001010 HWND32 hwnd = wndPtr->hwndSelf;
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001011
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001012 if ( wndPtr->dwStyle & WS_MINIMIZE ||
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001013 !WIN_IsWindowDrawable( wndPtr, 0 )) return; /* Nothing to do */
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001014
Alexandre Julliardc981d0b1996-03-31 16:40:13 +00001015 active = wndPtr->flags & WIN_NCACTIVATED;
1016
1017 dprintf_nonclient(stddeb, "NC_DoNCPaint: %04x %d\n", hwnd, active );
1018
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001019 if (!(hdc = GetDCEx32( hwnd, 0, DCX_USESTYLE | DCX_WINDOW ))) return;
Alexandre Julliard940d58c1994-09-16 09:24:37 +00001020
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001021 if (ExcludeVisRect( hdc, wndPtr->rectClient.left-wndPtr->rectWindow.left,
1022 wndPtr->rectClient.top-wndPtr->rectWindow.top,
1023 wndPtr->rectClient.right-wndPtr->rectWindow.left,
1024 wndPtr->rectClient.bottom-wndPtr->rectWindow.top )
1025 == NULLREGION)
1026 {
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001027 ReleaseDC32( hwnd, hdc );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001028 return;
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001029 }
1030
1031 rect.top = rect.left = 0;
1032 rect.right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
1033 rect.bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
1034
Alexandre Julliard139a4b11996-11-02 14:24:07 +00001035 SelectObject32( hdc, sysColorObjects.hpenWindowFrame );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001036
Alexandre Julliard0c126c71996-02-18 18:44:41 +00001037 if (!(wndPtr->flags & WIN_MANAGED))
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001038 {
Alexandre Julliard0c126c71996-02-18 18:44:41 +00001039 if ((wndPtr->dwStyle & WS_BORDER) || (wndPtr->dwStyle & WS_DLGFRAME) ||
1040 (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME))
1041 {
Alexandre Julliarddf2673b1997-03-29 17:20:20 +00001042 GRAPH_DrawRectangle( hdc, 0, 0,
1043 rect.right, rect.bottom, (HPEN32)0 );
1044 InflateRect32( &rect, -1, -1 );
Alexandre Julliard0c126c71996-02-18 18:44:41 +00001045 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001046
Alexandre Julliard0c126c71996-02-18 18:44:41 +00001047 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
1048 NC_DrawFrame( hdc, &rect, TRUE, active );
1049 else if (wndPtr->dwStyle & WS_THICKFRAME)
1050 NC_DrawFrame(hdc, &rect, FALSE, active );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001051
Alexandre Julliard0c126c71996-02-18 18:44:41 +00001052 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
1053 {
Alexandre Julliarddf2673b1997-03-29 17:20:20 +00001054 RECT32 r = rect;
Alexandre Julliard0c126c71996-02-18 18:44:41 +00001055 r.bottom = rect.top + SYSMETRICS_CYSIZE;
1056 rect.top += SYSMETRICS_CYSIZE + SYSMETRICS_CYBORDER;
1057 NC_DrawCaption( hdc, &r, hwnd, wndPtr->dwStyle, active );
1058 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001059 }
1060
Alexandre Julliardf7207251994-07-23 07:57:48 +00001061 if (HAS_MENU(wndPtr))
1062 {
Alexandre Julliarddf2673b1997-03-29 17:20:20 +00001063 RECT32 r = rect;
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +00001064 r.bottom = rect.top + SYSMETRICS_CYMENU; /* default height */
Alexandre Julliard940d58c1994-09-16 09:24:37 +00001065 rect.top += MENU_DrawMenuBar( hdc, &r, hwnd, suppress_menupaint );
Alexandre Julliardf7207251994-07-23 07:57:48 +00001066 }
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001067
Alexandre Julliardecc37121994-11-22 16:31:29 +00001068 /* Draw the scroll-bars */
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001069
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001070 if (wndPtr->dwStyle & WS_VSCROLL)
1071 SCROLL_DrawScrollBar( hwnd, hdc, SB_VERT, TRUE );
1072 if (wndPtr->dwStyle & WS_HSCROLL)
1073 SCROLL_DrawScrollBar( hwnd, hdc, SB_HORZ, TRUE );
Alexandre Julliardecc37121994-11-22 16:31:29 +00001074
1075 /* Draw the "size-box" */
1076
1077 if ((wndPtr->dwStyle & WS_VSCROLL) && (wndPtr->dwStyle & WS_HSCROLL))
1078 {
Alexandre Julliarddf2673b1997-03-29 17:20:20 +00001079 RECT32 r = rect;
Alexandre Julliardecc37121994-11-22 16:31:29 +00001080 r.left = r.right - SYSMETRICS_CXVSCROLL + 1;
1081 r.top = r.bottom - SYSMETRICS_CYHSCROLL + 1;
Alexandre Julliarddf2673b1997-03-29 17:20:20 +00001082 FillRect32( hdc, &r, sysColorObjects.hbrushScrollbar );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001083 }
1084
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001085 ReleaseDC32( hwnd, hdc );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001086}
1087
1088
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001089/******************************************************************************
1090 *
1091 * void NC_DoNCPaint95(
1092 * WND *wndPtr,
1093 * HRGN32 clip,
1094 * BOOL32 suppress_menupaint )
1095 *
1096 * Paint the non-client area for Win95 windows. The clip region is
1097 * currently ignored.
1098 *
1099 * Bugs
1100 * grep -E -A10 -B5 \(95\)\|\(Bugs\)\|\(FIXME\) windows/nonclient.c \
1101 * misc/tweak.c controls/menu.c # :-)
1102 *
1103 * Revision history
1104 * 03-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1105 * Original implementation
1106 *
1107 *****************************************************************************/
1108
1109void NC_DoNCPaint95(
1110 WND *wndPtr,
1111 HRGN32 clip,
1112 BOOL32 suppress_menupaint )
1113{
1114 HDC32 hdc;
1115 RECT32 rect;
1116 BOOL32 active;
1117 HWND32 hwnd = wndPtr->hwndSelf;
1118
1119 if ( wndPtr->dwStyle & WS_MINIMIZE ||
1120 !WIN_IsWindowDrawable( wndPtr, 0 )) return; /* Nothing to do */
1121
1122 active = wndPtr->flags & WIN_NCACTIVATED;
1123
1124 dprintf_nonclient(stddeb, "NC_DoNCPaint95: %04x %d\n", hwnd, active );
1125
1126 if (!(hdc = GetDCEx32( hwnd, 0, DCX_USESTYLE | DCX_WINDOW ))) return;
1127
1128 if (ExcludeVisRect( hdc, wndPtr->rectClient.left-wndPtr->rectWindow.left,
1129 wndPtr->rectClient.top-wndPtr->rectWindow.top,
1130 wndPtr->rectClient.right-wndPtr->rectWindow.left,
1131 wndPtr->rectClient.bottom-wndPtr->rectWindow.top )
1132 == NULLREGION)
1133 {
1134 ReleaseDC32( hwnd, hdc );
1135 return;
1136 }
1137
1138 rect.top = rect.left = 0;
1139 rect.right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
1140 rect.bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
1141
1142 SelectObject32( hdc, sysColorObjects.hpenWindowFrame );
1143
1144 if(!(wndPtr->flags & WIN_MANAGED)) {
1145 if((wndPtr->dwStyle & WS_BORDER) || (wndPtr->dwStyle & WS_DLGFRAME) ||
1146 (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME)) {
1147 TWEAK_DrawReliefRect95(hdc, &rect);
1148 InflateRect32(&rect, -2, -2);
1149 }
1150
1151 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
1152 NC_DrawFrame95( hdc, &rect, TRUE, active );
1153 else if (wndPtr->dwStyle & WS_THICKFRAME)
1154 NC_DrawFrame95(hdc, &rect, FALSE, active );
1155
1156 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
1157 {
1158 RECT32 r = rect;
1159 POINT32 sep[2] = { { rect.left,
1160 rect.top + sysMetrics[SM_CYCAPTION] - 2 },
1161 { rect.right,
1162 rect.top + sysMetrics[SM_CYCAPTION] - 2 } };
1163
1164 r.bottom = rect.top + sysMetrics[SM_CYCAPTION] - 2;
1165 rect.top += sysMetrics[SM_CYCAPTION] - 2 + sysMetrics[SM_CYBORDER];
1166 NC_DrawCaption95( hdc, &r, hwnd, wndPtr->dwStyle, active );
1167 GRAPH_DrawLines( hdc, sep, 1, TWEAK_PenC095 );
1168 }
1169 }
1170
1171 if (HAS_MENU(wndPtr))
1172 {
1173 RECT32 r = rect;
1174 r.bottom = rect.top + sysMetrics[SM_CYMENU] - sysMetrics[SM_CYBORDER];
1175 r.top -= sysMetrics[SM_CYBORDER];
1176
1177 dprintf_nonclient(stddeb, "DoNCPaint95: Calling DrawMenuBar with "
1178 "rect (%d, %d)-(%d, %d)\n", r.left, r.top,
1179 r.right, r.bottom);
1180
1181 rect.top += MENU_DrawMenuBar( hdc, &r, hwnd, suppress_menupaint );
1182 }
1183
1184 dprintf_nonclient( stddeb, "After MenuBar, rect is (%d, %d)-(%d, %d).\n",
1185 rect.left, rect.top, rect.right, rect.bottom );
1186
1187 /* Draw the inner frames */
1188 GRAPH_DrawRectangle( hdc, rect.left, rect.top, rect.right - rect.left,
1189 rect.bottom - rect.top, TWEAK_PenC095 );
1190 InflateRect32(&rect, -1, -1);
1191 GRAPH_DrawGenericReliefRect( hdc, &rect, 1, 1, NC_WinShadow95,
1192 NC_WinHighlight95 );
1193
1194 InflateRect32(&rect, -1, -1);
1195
1196 /* Draw the scroll-bars */
1197
1198 if (wndPtr->dwStyle & WS_VSCROLL)
1199 SCROLL_DrawScrollBar( hwnd, hdc, SB_VERT, TRUE );
1200 if (wndPtr->dwStyle & WS_HSCROLL)
1201 SCROLL_DrawScrollBar( hwnd, hdc, SB_HORZ, TRUE );
1202
1203 /* Draw the "size-box" */
1204 if ((wndPtr->dwStyle & WS_VSCROLL) && (wndPtr->dwStyle & WS_HSCROLL))
1205 {
1206 RECT32 r = rect;
1207 r.left = r.right - SYSMETRICS_CXVSCROLL + 1;
1208 r.top = r.bottom - SYSMETRICS_CYHSCROLL + 1;
1209 FillRect32( hdc, &r, sysColorObjects.hbrushScrollbar );
1210 }
1211
1212 ReleaseDC32( hwnd, hdc );
1213}
1214
1215
1216
Alexandre Julliard988ca971994-06-21 16:15:21 +00001217
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001218/***********************************************************************
1219 * NC_HandleNCPaint
1220 *
1221 * Handle a WM_NCPAINT message. Called from DefWindowProc().
1222 */
Alexandre Julliard139a4b11996-11-02 14:24:07 +00001223LONG NC_HandleNCPaint( HWND32 hwnd , HRGN32 clip)
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001224{
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001225 WND* wndPtr = WIN_FindWndPtr( hwnd );
1226
1227 if( wndPtr && wndPtr->dwStyle & WS_VISIBLE )
1228 {
1229 if( wndPtr->dwStyle & WS_MINIMIZE )
1230 WINPOS_RedrawIconTitle( hwnd );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001231 else if(TWEAK_Win95Look)
1232 NC_DoNCPaint95( wndPtr, clip, FALSE );
1233 else
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001234 NC_DoNCPaint( wndPtr, clip, FALSE );
1235 }
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001236 return 0;
1237}
1238
1239
1240/***********************************************************************
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001241 * NC_HandleNCActivate
1242 *
1243 * Handle a WM_NCACTIVATE message. Called from DefWindowProc().
1244 */
Alexandre Julliard530ee841996-10-23 16:59:13 +00001245LONG NC_HandleNCActivate( WND *wndPtr, WPARAM16 wParam )
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001246{
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001247 WORD wStateChange;
Alexandre Julliardd4719651995-12-12 18:49:11 +00001248
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001249 if( wParam ) wStateChange = !(wndPtr->flags & WIN_NCACTIVATED);
1250 else wStateChange = wndPtr->flags & WIN_NCACTIVATED;
Alexandre Julliardd4719651995-12-12 18:49:11 +00001251
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001252 if( wStateChange )
1253 {
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001254 if (wParam) wndPtr->flags |= WIN_NCACTIVATED;
1255 else wndPtr->flags &= ~WIN_NCACTIVATED;
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001256
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001257 if( wndPtr->dwStyle & WS_MINIMIZE )
1258 WINPOS_RedrawIconTitle( wndPtr->hwndSelf );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001259 else if( TWEAK_Win95Look )
1260 NC_DoNCPaint95( wndPtr, (HRGN32)1, FALSE );
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001261 else
1262 NC_DoNCPaint( wndPtr, (HRGN32)1, FALSE );
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001263 }
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001264 return TRUE;
1265}
1266
1267
1268/***********************************************************************
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001269 * NC_HandleSetCursor
1270 *
1271 * Handle a WM_SETCURSOR message. Called from DefWindowProc().
1272 */
Alexandre Julliard139a4b11996-11-02 14:24:07 +00001273LONG NC_HandleSetCursor( HWND32 hwnd, WPARAM16 wParam, LPARAM lParam )
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001274{
Alexandre Julliard139a4b11996-11-02 14:24:07 +00001275 if (hwnd != (HWND32)wParam) return 0; /* Don't set the cursor for child windows */
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001276
1277 switch(LOWORD(lParam))
1278 {
1279 case HTERROR:
1280 {
1281 WORD msg = HIWORD( lParam );
1282 if ((msg == WM_LBUTTONDOWN) || (msg == WM_MBUTTONDOWN) ||
1283 (msg == WM_RBUTTONDOWN))
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001284 MessageBeep32(0);
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001285 }
1286 break;
1287
1288 case HTCLIENT:
1289 {
1290 WND *wndPtr;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001291 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) break;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +00001292 if (wndPtr->class->hCursor)
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001293 {
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001294 SetCursor16( wndPtr->class->hCursor );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001295 return TRUE;
1296 }
Alexandre Julliard940d58c1994-09-16 09:24:37 +00001297 else return FALSE;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001298 }
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001299
1300 case HTLEFT:
1301 case HTRIGHT:
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001302 return (LONG)SetCursor16( LoadCursor16( 0, IDC_SIZEWE ) );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001303
1304 case HTTOP:
1305 case HTBOTTOM:
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001306 return (LONG)SetCursor16( LoadCursor16( 0, IDC_SIZENS ) );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001307
1308 case HTTOPLEFT:
1309 case HTBOTTOMRIGHT:
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001310 return (LONG)SetCursor16( LoadCursor16( 0, IDC_SIZENWSE ) );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001311
1312 case HTTOPRIGHT:
1313 case HTBOTTOMLEFT:
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001314 return (LONG)SetCursor16( LoadCursor16( 0, IDC_SIZENESW ) );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001315 }
1316
1317 /* Default cursor: arrow */
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001318 return (LONG)SetCursor16( LoadCursor16( 0, IDC_ARROW ) );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001319}
1320
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001321/***********************************************************************
1322 * NC_GetSysPopupPos
1323 */
Alexandre Julliardc6c09441997-01-12 18:32:19 +00001324BOOL32 NC_GetSysPopupPos( WND* wndPtr, RECT32* rect )
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001325{
Alexandre Julliard9ea19e51997-01-01 17:29:55 +00001326 if( wndPtr->hSysMenu )
1327 {
1328 if( wndPtr->dwStyle & WS_MINIMIZE )
Alexandre Julliardc6c09441997-01-12 18:32:19 +00001329 GetWindowRect32( wndPtr->hwndSelf, rect );
Alexandre Julliard9ea19e51997-01-01 17:29:55 +00001330 else
1331 {
1332 NC_GetInsideRect( wndPtr->hwndSelf, rect );
Alexandre Julliardc6c09441997-01-12 18:32:19 +00001333 OffsetRect32( rect, wndPtr->rectWindow.left, wndPtr->rectWindow.top);
Alexandre Julliard9ea19e51997-01-01 17:29:55 +00001334 if (wndPtr->dwStyle & WS_CHILD)
Alexandre Julliardc6c09441997-01-12 18:32:19 +00001335 ClientToScreen32( wndPtr->parent->hwndSelf, (POINT32 *)rect );
Alexandre Julliard9ea19e51997-01-01 17:29:55 +00001336 rect->right = rect->left + SYSMETRICS_CXSIZE;
1337 rect->bottom = rect->top + SYSMETRICS_CYSIZE;
1338 }
1339 return TRUE;
1340 }
1341 return FALSE;
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001342}
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001343
1344/***********************************************************************
1345 * NC_StartSizeMove
1346 *
1347 * Initialisation of a move or resize, when initiatied from a menu choice.
1348 * Return hit test code for caption or sizing border.
1349 */
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001350static LONG NC_StartSizeMove( WND* wndPtr, WPARAM16 wParam,
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001351 POINT16 *capturePoint )
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001352{
1353 LONG hittest = 0;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001354 POINT16 pt;
Alexandre Julliardd90840e1996-06-11 16:02:08 +00001355 MSG16 msg;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001356
1357 if ((wParam & 0xfff0) == SC_MOVE)
1358 {
1359 /* Move pointer at the center of the caption */
Alexandre Julliardc6c09441997-01-12 18:32:19 +00001360 RECT32 rect;
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001361 NC_GetInsideRect( wndPtr->hwndSelf, &rect );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001362 if (wndPtr->dwStyle & WS_SYSMENU)
1363 rect.left += SYSMETRICS_CXSIZE + 1;
1364 if (wndPtr->dwStyle & WS_MINIMIZEBOX)
1365 rect.right -= SYSMETRICS_CXSIZE + 1;
1366 if (wndPtr->dwStyle & WS_MAXIMIZEBOX)
1367 rect.right -= SYSMETRICS_CXSIZE + 1;
1368 pt.x = wndPtr->rectWindow.left + (rect.right - rect.left) / 2;
1369 pt.y = wndPtr->rectWindow.top + rect.top + SYSMETRICS_CYSIZE/2;
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001370 hittest = HTCAPTION;
1371 *capturePoint = pt;
1372
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001373 if (wndPtr->dwStyle & WS_CHILD)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001374 ClientToScreen16( wndPtr->parent->hwndSelf, &pt );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001375 }
1376 else /* SC_SIZE */
1377 {
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001378 while(!hittest)
1379 {
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001380 MSG_InternalGetMessage( &msg, 0, 0, MSGF_SIZE, PM_REMOVE, FALSE );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001381 switch(msg.message)
1382 {
1383 case WM_MOUSEMOVE:
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001384 hittest = NC_HandleNCHitTest( wndPtr->hwndSelf, msg.pt );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001385 pt = msg.pt;
1386 if ((hittest < HTLEFT) || (hittest > HTBOTTOMRIGHT))
1387 hittest = 0;
1388 break;
1389
1390 case WM_LBUTTONUP:
1391 return 0;
1392
1393 case WM_KEYDOWN:
1394 switch(msg.wParam)
1395 {
1396 case VK_UP:
1397 hittest = HTTOP;
1398 pt.x =(wndPtr->rectWindow.left+wndPtr->rectWindow.right)/2;
1399 pt.y = wndPtr->rectWindow.top + SYSMETRICS_CYFRAME / 2;
1400 break;
1401 case VK_DOWN:
1402 hittest = HTBOTTOM;
1403 pt.x =(wndPtr->rectWindow.left+wndPtr->rectWindow.right)/2;
1404 pt.y = wndPtr->rectWindow.bottom - SYSMETRICS_CYFRAME / 2;
1405 break;
1406 case VK_LEFT:
1407 hittest = HTLEFT;
1408 pt.x = wndPtr->rectWindow.left + SYSMETRICS_CXFRAME / 2;
1409 pt.y =(wndPtr->rectWindow.top+wndPtr->rectWindow.bottom)/2;
1410 break;
1411 case VK_RIGHT:
1412 hittest = HTRIGHT;
1413 pt.x = wndPtr->rectWindow.right - SYSMETRICS_CXFRAME / 2;
1414 pt.y =(wndPtr->rectWindow.top+wndPtr->rectWindow.bottom)/2;
1415 break;
1416 case VK_RETURN:
1417 case VK_ESCAPE: return 0;
1418 }
1419 }
1420 }
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001421 *capturePoint = pt;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001422 }
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001423 SetCursorPos32( pt.x, pt.y );
1424 NC_HandleSetCursor( wndPtr->hwndSelf,
1425 wndPtr->hwndSelf, MAKELONG( hittest, WM_MOUSEMOVE ));
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001426 return hittest;
1427}
1428
1429
1430/***********************************************************************
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001431 * NC_DoSizeMove
1432 *
1433 * Perform SC_MOVE and SC_SIZE commands.
1434 */
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001435static void NC_DoSizeMove( HWND32 hwnd, WORD wParam, POINT16 pt )
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001436{
Alexandre Julliardd90840e1996-06-11 16:02:08 +00001437 MSG16 msg;
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001438 RECT32 sizingRect, mouseRect;
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001439 HDC32 hdc;
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001440 LONG hittest = (LONG)(wParam & 0x0f);
1441 HCURSOR16 hDragCursor = 0, hOldCursor = 0;
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001442 POINT32 minTrack, maxTrack;
1443 POINT16 capturePoint = pt;
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001444 WND * wndPtr = WIN_FindWndPtr( hwnd );
1445 BOOL32 thickframe = HAS_THICKFRAME( wndPtr->dwStyle );
1446 BOOL32 iconic = wndPtr->dwStyle & WS_MINIMIZE;
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001447 BOOL32 moved = FALSE;
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001448
Alexandre Julliard01d63461997-01-20 19:43:45 +00001449 if (IsZoomed32(hwnd) || !IsWindowVisible32(hwnd) ||
Alexandre Julliard0c126c71996-02-18 18:44:41 +00001450 (wndPtr->flags & WIN_MANAGED)) return;
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001451
1452 if ((wParam & 0xfff0) == SC_MOVE)
1453 {
1454 if (!(wndPtr->dwStyle & WS_CAPTION)) return;
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001455 if (!hittest)
1456 hittest = NC_StartSizeMove( wndPtr, wParam, &capturePoint );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001457 if (!hittest) return;
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001458 }
1459 else /* SC_SIZE */
1460 {
1461 if (!thickframe) return;
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001462 if ( hittest && hittest != HTSYSMENU ) hittest += 2;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001463 else
1464 {
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001465 SetCapture32(hwnd);
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001466 hittest = NC_StartSizeMove( wndPtr, wParam, &capturePoint );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001467 if (!hittest)
1468 {
1469 ReleaseCapture();
1470 return;
1471 }
1472 }
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001473 }
1474
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001475 /* Get min/max info */
1476
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001477 WINPOS_GetMinMaxInfo( wndPtr, NULL, NULL, &minTrack, &maxTrack );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001478 sizingRect = wndPtr->rectWindow;
1479 if (wndPtr->dwStyle & WS_CHILD)
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001480 GetClientRect32( wndPtr->parent->hwndSelf, &mouseRect );
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001481 else
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001482 SetRect32(&mouseRect, 0, 0, SYSMETRICS_CXSCREEN, SYSMETRICS_CYSCREEN);
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001483 if (ON_LEFT_BORDER(hittest))
1484 {
Alexandre Julliard902da691995-11-05 14:39:02 +00001485 mouseRect.left = MAX( mouseRect.left, sizingRect.right-maxTrack.x );
1486 mouseRect.right = MIN( mouseRect.right, sizingRect.right-minTrack.x );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001487 }
1488 else if (ON_RIGHT_BORDER(hittest))
1489 {
Alexandre Julliard902da691995-11-05 14:39:02 +00001490 mouseRect.left = MAX( mouseRect.left, sizingRect.left+minTrack.x );
1491 mouseRect.right = MIN( mouseRect.right, sizingRect.left+maxTrack.x );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001492 }
1493 if (ON_TOP_BORDER(hittest))
1494 {
Alexandre Julliard902da691995-11-05 14:39:02 +00001495 mouseRect.top = MAX( mouseRect.top, sizingRect.bottom-maxTrack.y );
1496 mouseRect.bottom = MIN( mouseRect.bottom,sizingRect.bottom-minTrack.y);
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001497 }
1498 else if (ON_BOTTOM_BORDER(hittest))
1499 {
Alexandre Julliard902da691995-11-05 14:39:02 +00001500 mouseRect.top = MAX( mouseRect.top, sizingRect.top+minTrack.y );
1501 mouseRect.bottom = MIN( mouseRect.bottom, sizingRect.top+maxTrack.y );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001502 }
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001503 SendMessage16( hwnd, WM_ENTERSIZEMOVE, 0, 0 );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001504
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001505 if (GetCapture32() != hwnd) SetCapture32( hwnd );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001506
Alexandre Julliard3ed37e01994-11-07 18:20:42 +00001507 if (wndPtr->dwStyle & WS_CHILD)
1508 {
1509 /* Retrieve a default cache DC (without using the window style) */
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001510 hdc = GetDCEx32( wndPtr->parent->hwndSelf, 0, DCX_CACHE );
Alexandre Julliard3ed37e01994-11-07 18:20:42 +00001511 }
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001512 else
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001513 { /* Grab the server only when moving top-level windows without desktop */
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001514 hdc = GetDC32( 0 );
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001515 if (rootWindow == DefaultRootWindow(display)) XGrabServer( display );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001516 }
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001517
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001518 if( iconic ) /* create a cursor for dragging */
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001519 {
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001520 HICON16 hIcon = (wndPtr->class->hIcon) ? wndPtr->class->hIcon
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001521 : (HICON16)SendMessage16( hwnd, WM_QUERYDRAGICON, 0, 0L);
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001522 if( hIcon ) hDragCursor = CURSORICON_IconToCursor( hIcon, TRUE );
1523 if( !hDragCursor ) iconic = FALSE;
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001524 }
1525
1526 if( !iconic ) NC_DrawMovingFrame( hdc, &sizingRect, thickframe );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001527
1528 while(1)
1529 {
Alexandre Julliard7d654eb1996-02-25 11:36:22 +00001530 int dx = 0, dy = 0;
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001531
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001532 MSG_InternalGetMessage( &msg, 0, 0, MSGF_SIZE, PM_REMOVE, FALSE );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001533
1534 /* Exit on button-up, Return, or Esc */
1535 if ((msg.message == WM_LBUTTONUP) ||
1536 ((msg.message == WM_KEYDOWN) &&
1537 ((msg.wParam == VK_RETURN) || (msg.wParam == VK_ESCAPE)))) break;
1538
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001539 if ((msg.message != WM_KEYDOWN) && (msg.message != WM_MOUSEMOVE))
1540 continue; /* We are not interested in other messages */
1541
1542 pt = msg.pt;
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001543 if (wndPtr->dwStyle & WS_CHILD)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001544 ScreenToClient16( wndPtr->parent->hwndSelf, &pt );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001545
1546 if (msg.message == WM_KEYDOWN) switch(msg.wParam)
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001547 {
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001548 case VK_UP: pt.y -= 8; break;
1549 case VK_DOWN: pt.y += 8; break;
1550 case VK_LEFT: pt.x -= 8; break;
1551 case VK_RIGHT: pt.x += 8; break;
1552 }
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001553
Alexandre Julliard902da691995-11-05 14:39:02 +00001554 pt.x = MAX( pt.x, mouseRect.left );
1555 pt.x = MIN( pt.x, mouseRect.right );
1556 pt.y = MAX( pt.y, mouseRect.top );
1557 pt.y = MIN( pt.y, mouseRect.bottom );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001558
1559 dx = pt.x - capturePoint.x;
1560 dy = pt.y - capturePoint.y;
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001561
1562 if (dx || dy)
1563 {
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001564 if( !moved )
1565 {
1566 moved = TRUE;
1567 if( iconic ) /* ok, no system popup tracking */
1568 {
1569 hOldCursor = SetCursor32(hDragCursor);
1570 ShowCursor32( TRUE );
1571 WINPOS_ShowIconTitle( wndPtr, FALSE );
1572 }
1573 }
1574
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001575 if (msg.message == WM_KEYDOWN) SetCursorPos32( pt.x, pt.y );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001576 else
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001577 {
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001578 RECT32 newRect = sizingRect;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001579
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001580 if (hittest == HTCAPTION) OffsetRect32( &newRect, dx, dy );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001581 if (ON_LEFT_BORDER(hittest)) newRect.left += dx;
1582 else if (ON_RIGHT_BORDER(hittest)) newRect.right += dx;
1583 if (ON_TOP_BORDER(hittest)) newRect.top += dy;
1584 else if (ON_BOTTOM_BORDER(hittest)) newRect.bottom += dy;
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001585 if( !iconic )
1586 {
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001587 NC_DrawMovingFrame( hdc, &sizingRect, thickframe );
1588 NC_DrawMovingFrame( hdc, &newRect, thickframe );
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001589 }
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001590 capturePoint = pt;
1591 sizingRect = newRect;
1592 }
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001593 }
1594 }
1595
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001596 ReleaseCapture();
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001597 if( iconic )
1598 {
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001599 if( moved ) /* restore cursors, show icon title later on */
1600 {
1601 ShowCursor32( FALSE );
1602 SetCursor32( hOldCursor );
1603 }
1604 DestroyCursor32( hDragCursor );
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001605 }
1606 else
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001607 NC_DrawMovingFrame( hdc, &sizingRect, thickframe );
Alexandre Julliard7d654eb1996-02-25 11:36:22 +00001608
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001609 if (wndPtr->dwStyle & WS_CHILD)
1610 ReleaseDC32( wndPtr->parent->hwndSelf, hdc );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001611 else
1612 {
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001613 ReleaseDC32( 0, hdc );
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001614 if (rootWindow == DefaultRootWindow(display)) XUngrabServer( display );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001615 }
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001616
Alexandre Julliard7e6ae4b1996-12-08 19:25:27 +00001617 if (HOOK_IsHooked( WH_CBT ))
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001618 {
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001619 RECT16* pr = SEGPTR_NEW(RECT16);
1620 if( pr )
1621 {
1622 CONV_RECT32TO16( &sizingRect, pr );
1623 if( HOOK_CallHooks16( WH_CBT, HCBT_MOVESIZE, hwnd,
Alexandre Julliard7e6ae4b1996-12-08 19:25:27 +00001624 (LPARAM)SEGPTR_GET(pr)) )
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001625 sizingRect = wndPtr->rectWindow;
1626 else
1627 CONV_RECT16TO32( pr, &sizingRect );
1628 SEGPTR_FREE(pr);
1629 }
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001630 }
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001631 SendMessage16( hwnd, WM_EXITSIZEMOVE, 0, 0 );
Alexandre Julliard01d63461997-01-20 19:43:45 +00001632 SendMessage16( hwnd, WM_SETVISIBLE, !IsIconic16(hwnd), 0L);
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001633
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001634 if( moved && !((msg.message == WM_KEYDOWN) && (msg.wParam == VK_ESCAPE)) )
Alexandre Julliard7d654eb1996-02-25 11:36:22 +00001635 {
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001636 /* NOTE: SWP_NOACTIVATE prevents document window activation in Word 6 */
Alexandre Julliard01d63461997-01-20 19:43:45 +00001637 SetWindowPos32( hwnd, 0, sizingRect.left, sizingRect.top,
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001638 sizingRect.right - sizingRect.left,
1639 sizingRect.bottom - sizingRect.top,
1640 ( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 );
1641 }
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001642
1643 if( IsWindow32(hwnd) )
1644 if( wndPtr->dwStyle & WS_MINIMIZE )
1645 {
1646 /* Single click brings up the system menu when iconized */
1647
1648 if( !moved )
1649 {
1650 if( wndPtr->dwStyle & WS_SYSMENU )
1651 SendMessage16( hwnd, WM_SYSCOMMAND,
1652 SC_MOUSEMENU + HTSYSMENU, *((LPARAM*)&pt));
1653 }
1654 else WINPOS_ShowIconTitle( wndPtr, TRUE );
1655 }
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001656}
1657
1658
1659/***********************************************************************
1660 * NC_TrackMinMaxBox
1661 *
1662 * Track a mouse button press on the minimize or maximize box.
1663 */
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001664static void NC_TrackMinMaxBox( HWND32 hwnd, WORD wParam )
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001665{
Alexandre Julliardd90840e1996-06-11 16:02:08 +00001666 MSG16 msg;
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001667 HDC32 hdc = GetWindowDC32( hwnd );
Alexandre Julliard21979011997-03-05 08:22:35 +00001668 BOOL32 pressed = TRUE;
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001669 void (*paintButton)(HWND32, HDC16, BOOL32);
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001670
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001671 SetCapture32( hwnd );
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001672 if (wParam == HTMINBUTTON)
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001673 paintButton = (TWEAK_Win95Look) ? &NC_DrawMinButton95 : &NC_DrawMinButton;
Alexandre Julliardd37eb361997-07-20 16:23:21 +00001674 else
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001675 paintButton = (TWEAK_Win95Look) ? &NC_DrawMaxButton95 : &NC_DrawMaxButton;
1676
1677 (*paintButton)( hwnd, hdc, TRUE );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001678
1679 do
1680 {
Alexandre Julliard21979011997-03-05 08:22:35 +00001681 BOOL32 oldstate = pressed;
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001682 MSG_InternalGetMessage( &msg, 0, 0, 0, PM_REMOVE, FALSE );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001683
Alexandre Julliard940d58c1994-09-16 09:24:37 +00001684 pressed = (NC_HandleNCHitTest( hwnd, msg.pt ) == wParam);
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001685 if (pressed != oldstate)
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001686 (*paintButton)( hwnd, hdc, pressed );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001687 } while (msg.message != WM_LBUTTONUP);
1688
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001689 (*paintButton)( hwnd, hdc, FALSE );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001690
1691 ReleaseCapture();
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001692 ReleaseDC32( hwnd, hdc );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001693 if (!pressed) return;
1694
1695 if (wParam == HTMINBUTTON)
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001696 SendMessage16( hwnd, WM_SYSCOMMAND, SC_MINIMIZE, *(LONG*)&msg.pt );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001697 else
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001698 SendMessage16( hwnd, WM_SYSCOMMAND,
Alexandre Julliard01d63461997-01-20 19:43:45 +00001699 IsZoomed32(hwnd) ? SC_RESTORE:SC_MAXIMIZE, *(LONG*)&msg.pt );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001700}
1701
1702
1703/***********************************************************************
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001704 * NC_TrackScrollBar
1705 *
1706 * Track a mouse button press on the horizontal or vertical scroll-bar.
1707 */
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001708static void NC_TrackScrollBar( HWND32 hwnd, WPARAM32 wParam, POINT32 pt )
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001709{
Alexandre Julliardd90840e1996-06-11 16:02:08 +00001710 MSG16 *msg;
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001711 INT32 scrollbar;
Alexandre Julliardecc37121994-11-22 16:31:29 +00001712 WND *wndPtr = WIN_FindWndPtr( hwnd );
1713
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001714 if ((wParam & 0xfff0) == SC_HSCROLL)
1715 {
1716 if ((wParam & 0x0f) != HTHSCROLL) return;
1717 scrollbar = SB_HORZ;
1718 }
1719 else /* SC_VSCROLL */
1720 {
1721 if ((wParam & 0x0f) != HTVSCROLL) return;
1722 scrollbar = SB_VERT;
1723 }
1724
Alexandre Julliardd90840e1996-06-11 16:02:08 +00001725 if (!(msg = SEGPTR_NEW(MSG16))) return;
Alexandre Julliardecc37121994-11-22 16:31:29 +00001726 pt.x -= wndPtr->rectWindow.left;
1727 pt.y -= wndPtr->rectWindow.top;
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001728 SetCapture32( hwnd );
Alexandre Julliardecc37121994-11-22 16:31:29 +00001729 SCROLL_HandleScrollEvent( hwnd, scrollbar, WM_LBUTTONDOWN, pt );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001730
1731 do
1732 {
Alexandre Julliard21979011997-03-05 08:22:35 +00001733 GetMessage16( SEGPTR_GET(msg), 0, 0, 0 );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001734 switch(msg->message)
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001735 {
1736 case WM_LBUTTONUP:
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001737 case WM_MOUSEMOVE:
Alexandre Julliardecc37121994-11-22 16:31:29 +00001738 case WM_SYSTIMER:
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001739 pt.x = LOWORD(msg->lParam) + wndPtr->rectClient.left -
Alexandre Julliard902da691995-11-05 14:39:02 +00001740 wndPtr->rectWindow.left;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001741 pt.y = HIWORD(msg->lParam) + wndPtr->rectClient.top -
Alexandre Julliard902da691995-11-05 14:39:02 +00001742 wndPtr->rectWindow.top;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001743 SCROLL_HandleScrollEvent( hwnd, scrollbar, msg->message, pt );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001744 break;
Alexandre Julliardecc37121994-11-22 16:31:29 +00001745 default:
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001746 TranslateMessage16( msg );
1747 DispatchMessage16( msg );
Alexandre Julliardecc37121994-11-22 16:31:29 +00001748 break;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001749 }
Alexandre Julliard21979011997-03-05 08:22:35 +00001750 if (!IsWindow32( hwnd ))
Alexandre Julliardecc37121994-11-22 16:31:29 +00001751 {
1752 ReleaseCapture();
1753 break;
1754 }
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001755 } while (msg->message != WM_LBUTTONUP);
1756 SEGPTR_FREE(msg);
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001757}
1758
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001759/***********************************************************************
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001760 * NC_HandleNCLButtonDown
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001761 *
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001762 * Handle a WM_NCLBUTTONDOWN message. Called from DefWindowProc().
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001763 */
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001764LONG NC_HandleNCLButtonDown( WND* pWnd, WPARAM16 wParam, LPARAM lParam )
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001765{
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001766 HWND32 hwnd = pWnd->hwndSelf;
1767
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001768 switch(wParam) /* Hit test */
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001769 {
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001770 case HTCAPTION:
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001771 hwnd = WIN_GetTopParent(hwnd);
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001772
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001773 if( WINPOS_SetActiveWindow(hwnd, TRUE, TRUE) || (GetActiveWindow32() == hwnd) )
1774 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, lParam );
1775 break;
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001776
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001777 case HTSYSMENU:
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001778 if( pWnd->dwStyle & WS_SYSMENU )
1779 {
1780 if( !(pWnd->dwStyle & WS_MINIMIZE) )
1781 {
1782 HDC32 hDC = GetWindowDC32(hwnd);
1783 if( TWEAK_Win95Look)
1784 NC_DrawSysButton95( hwnd, hDC, TRUE );
1785 else
1786 NC_DrawSysButton( hwnd, hDC, TRUE );
1787 ReleaseDC32( hwnd, hDC );
1788 }
1789 SendMessage16( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU + HTSYSMENU, lParam );
1790 }
1791 break;
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001792
1793 case HTMENU:
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001794 SendMessage16( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU, lParam );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001795 break;
1796
1797 case HTHSCROLL:
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001798 SendMessage16( hwnd, WM_SYSCOMMAND, SC_HSCROLL + HTHSCROLL, lParam );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001799 break;
1800
1801 case HTVSCROLL:
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001802 SendMessage16( hwnd, WM_SYSCOMMAND, SC_VSCROLL + HTVSCROLL, lParam );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001803 break;
1804
1805 case HTMINBUTTON:
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001806 case HTMAXBUTTON:
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001807 NC_TrackMinMaxBox( hwnd, wParam );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001808 break;
1809
1810 case HTLEFT:
1811 case HTRIGHT:
1812 case HTTOP:
1813 case HTTOPLEFT:
1814 case HTTOPRIGHT:
1815 case HTBOTTOM:
1816 case HTBOTTOMLEFT:
1817 case HTBOTTOMRIGHT:
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001818 /* make sure hittest fits into 0xf and doesn't overlap with HTSYSMENU */
1819 SendMessage16( hwnd, WM_SYSCOMMAND, SC_SIZE + wParam - 2, lParam);
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001820 break;
1821
1822 case HTBORDER:
1823 break;
1824 }
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001825 return 0;
1826}
1827
1828
1829/***********************************************************************
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001830 * NC_HandleNCLButtonDblClk
1831 *
1832 * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc().
1833 */
Alexandre Julliard530ee841996-10-23 16:59:13 +00001834LONG NC_HandleNCLButtonDblClk( WND *pWnd, WPARAM16 wParam, LPARAM lParam )
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001835{
Alexandre Julliard940d58c1994-09-16 09:24:37 +00001836 /*
1837 * if this is an icon, send a restore since we are handling
1838 * a double click
1839 */
Alexandre Julliard1285c2f1996-05-06 16:06:24 +00001840 if (pWnd->dwStyle & WS_MINIMIZE)
Alexandre Julliard940d58c1994-09-16 09:24:37 +00001841 {
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001842 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND, SC_RESTORE, lParam );
Alexandre Julliard1285c2f1996-05-06 16:06:24 +00001843 return 0;
Alexandre Julliard940d58c1994-09-16 09:24:37 +00001844 }
1845
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001846 switch(wParam) /* Hit test */
1847 {
1848 case HTCAPTION:
Alexandre Julliard902da691995-11-05 14:39:02 +00001849 /* stop processing if WS_MAXIMIZEBOX is missing */
Alexandre Julliard1285c2f1996-05-06 16:06:24 +00001850 if (pWnd->dwStyle & WS_MAXIMIZEBOX)
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001851 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND,
Alexandre Julliard1285c2f1996-05-06 16:06:24 +00001852 (pWnd->dwStyle & WS_MAXIMIZE) ? SC_RESTORE : SC_MAXIMIZE,
1853 lParam );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001854 break;
1855
1856 case HTSYSMENU:
Alexandre Julliard1285c2f1996-05-06 16:06:24 +00001857 if (!(pWnd->class->style & CS_NOCLOSE))
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001858 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND, SC_CLOSE, lParam );
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001859 break;
Alexandre Julliard491502b1997-11-01 19:08:16 +00001860
1861 case HTHSCROLL:
1862 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND, SC_HSCROLL + HTHSCROLL,
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001863 lParam );
Alexandre Julliard491502b1997-11-01 19:08:16 +00001864 break;
1865
1866 case HTVSCROLL:
1867 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND, SC_VSCROLL + HTVSCROLL,
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001868 lParam );
Alexandre Julliard491502b1997-11-01 19:08:16 +00001869 break;
Alexandre Julliardcdd09231994-01-12 11:12:51 +00001870 }
1871 return 0;
1872}
1873
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001874
1875/***********************************************************************
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001876 * NC_HandleSysCommand
1877 *
1878 * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
1879 */
Alexandre Julliard139a4b11996-11-02 14:24:07 +00001880LONG NC_HandleSysCommand( HWND32 hwnd, WPARAM16 wParam, POINT16 pt )
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001881{
1882 WND *wndPtr = WIN_FindWndPtr( hwnd );
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001883 POINT32 pt32;
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001884 UINT16 uCommand = wParam & 0xFFF0;
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001885
Alexandre Julliard59730ae1996-03-24 16:20:51 +00001886 dprintf_nonclient(stddeb, "Handling WM_SYSCOMMAND %x %d,%d\n",
1887 wParam, pt.x, pt.y );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001888
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001889 if (wndPtr->dwStyle & WS_CHILD && uCommand != SC_KEYMENU )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001890 ScreenToClient16( wndPtr->parent->hwndSelf, &pt );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001891
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001892 switch (uCommand)
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001893 {
1894 case SC_SIZE:
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001895 case SC_MOVE:
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001896 NC_DoSizeMove( hwnd, wParam, pt );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001897 break;
1898
1899 case SC_MINIMIZE:
Alexandre Julliard01d63461997-01-20 19:43:45 +00001900 ShowWindow32( hwnd, SW_MINIMIZE );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001901 break;
1902
1903 case SC_MAXIMIZE:
Alexandre Julliard01d63461997-01-20 19:43:45 +00001904 ShowWindow32( hwnd, SW_MAXIMIZE );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001905 break;
1906
1907 case SC_RESTORE:
Alexandre Julliard01d63461997-01-20 19:43:45 +00001908 ShowWindow32( hwnd, SW_RESTORE );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001909 break;
1910
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001911 case SC_CLOSE:
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001912 return SendMessage16( hwnd, WM_CLOSE, 0, 0 );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001913
1914 case SC_VSCROLL:
1915 case SC_HSCROLL:
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001916 CONV_POINT16TO32( &pt, &pt32 );
1917 NC_TrackScrollBar( hwnd, wParam, pt32 );
Alexandre Julliarddba420a1994-02-02 06:48:31 +00001918 break;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001919
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001920 case SC_MOUSEMENU:
Alexandre Julliardc6c09441997-01-12 18:32:19 +00001921 CONV_POINT16TO32( &pt, &pt32 );
1922 MENU_TrackMouseMenuBar( wndPtr, wParam & 0x000F, pt32 );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001923 break;
1924
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001925 case SC_KEYMENU:
Alexandre Julliardc981d0b1996-03-31 16:40:13 +00001926 MENU_TrackKbdMenuBar( wndPtr , wParam , pt.x );
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001927 break;
1928
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001929 case SC_TASKLIST:
Alexandre Julliard9ea19e51997-01-01 17:29:55 +00001930 WinExec32( "taskman.exe", SW_SHOWNORMAL );
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001931 break;
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +00001932
1933 case SC_SCREENSAVE:
1934 if (wParam == SC_ABOUTWINE)
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001935 ShellAbout32A(hwnd,"Wine", WINE_RELEASE_INFO, 0);
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +00001936 break;
Alexandre Julliard9ea19e51997-01-01 17:29:55 +00001937
1938 case SC_HOTKEY:
1939 case SC_ARRANGE:
1940 case SC_NEXTWINDOW:
1941 case SC_PREVWINDOW:
1942 /* FIXME: unimplemented */
1943 break;
Alexandre Julliard86a8d0f1994-01-18 23:04:40 +00001944 }
1945 return 0;
1946}