Release 950216
[wine.git] / windows / nonclient.c
blobc12e2932823951047af215c727c707420ca8841c
1 /*
2 * Non-client area window functions
4 * Copyright 1994 Alexandre Julliard
6 */
8 #include "win.h"
9 #include "class.h"
10 #include "message.h"
11 #include "sysmetrics.h"
12 #include "user.h"
13 #include "dialog.h"
14 #include "syscolor.h"
15 #include "library.h"
16 #include "menu.h"
17 #include "winpos.h"
18 #include "scroll.h"
19 #include "nonclient.h"
20 #include "graphics.h"
21 #include "stddebug.h"
22 /* #define DEBUG_NONCLIENT */
23 #include "debug.h"
26 static HBITMAP hbitmapClose = 0;
27 static HBITMAP hbitmapMinimize = 0;
28 static HBITMAP hbitmapMinimizeD = 0;
29 static HBITMAP hbitmapMaximize = 0;
30 static HBITMAP hbitmapMaximizeD = 0;
31 static HBITMAP hbitmapRestore = 0;
32 static HBITMAP hbitmapRestoreD = 0;
34 #define SC_ABOUTWINE (SC_SCREENSAVE+1)
35 extern BOOL AboutWine_Proc( HWND hDlg, WORD msg, WORD wParam, LONG lParam );
37 /* Some useful macros */
38 #define HAS_DLGFRAME(style,exStyle) \
39 (((exStyle) & WS_EX_DLGMODALFRAME) || \
40 (((style) & WS_DLGFRAME) && !((style) & WS_BORDER)))
42 #define HAS_THICKFRAME(style) \
43 (((style) & WS_THICKFRAME) && \
44 !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
46 #define HAS_MENU(w) (!((w)->dwStyle & WS_CHILD) && ((w)->wIDmenu != 0))
48 #define ON_LEFT_BORDER(hit) \
49 (((hit) == HTLEFT) || ((hit) == HTTOPLEFT) || ((hit) == HTBOTTOMLEFT))
50 #define ON_RIGHT_BORDER(hit) \
51 (((hit) == HTRIGHT) || ((hit) == HTTOPRIGHT) || ((hit) == HTBOTTOMRIGHT))
52 #define ON_TOP_BORDER(hit) \
53 (((hit) == HTTOP) || ((hit) == HTTOPLEFT) || ((hit) == HTTOPRIGHT))
54 #define ON_BOTTOM_BORDER(hit) \
55 (((hit) == HTBOTTOM) || ((hit) == HTBOTTOMLEFT) || ((hit) == HTBOTTOMRIGHT))
57 /***********************************************************************
58 * NC_AdjustRect
60 * Compute the size of the window rectangle from the size of the
61 * client rectangle.
63 static void NC_AdjustRect( LPRECT rect, DWORD style, BOOL menu, DWORD exStyle )
65 if (style & WS_ICONIC) return; /* Nothing to change for an icon */
66 if (HAS_DLGFRAME( style, exStyle ))
67 InflateRect( rect, SYSMETRICS_CXDLGFRAME, SYSMETRICS_CYDLGFRAME );
68 else
70 if (HAS_THICKFRAME(style))
71 InflateRect( rect, SYSMETRICS_CXFRAME, SYSMETRICS_CYFRAME );
72 if (style & WS_BORDER)
73 InflateRect( rect, SYSMETRICS_CXBORDER, SYSMETRICS_CYBORDER );
76 if ((style & WS_CAPTION) == WS_CAPTION)
77 rect->top -= SYSMETRICS_CYCAPTION - SYSMETRICS_CYBORDER;
78 if (menu) rect->top -= SYSMETRICS_CYMENU + SYSMETRICS_CYBORDER;
80 if (style & WS_VSCROLL) rect->right += SYSMETRICS_CXVSCROLL;
81 if (style & WS_HSCROLL) rect->bottom += SYSMETRICS_CYHSCROLL;
85 /***********************************************************************
86 * AdjustWindowRect (USER.102)
88 void AdjustWindowRect( LPRECT rect, DWORD style, BOOL menu )
90 AdjustWindowRectEx( rect, style, menu, 0 );
94 /***********************************************************************
95 * AdjustWindowRectEx (USER.454)
97 void AdjustWindowRectEx( LPRECT rect, DWORD style, BOOL menu, DWORD exStyle )
99 /* Correct the window style */
101 if (!(style & (WS_POPUP | WS_CHILD))) /* Overlapped window */
102 style |= WS_CAPTION;
103 if (exStyle & WS_EX_DLGMODALFRAME) style &= ~WS_THICKFRAME;
105 dprintf_nonclient(stddeb, "AdjustWindowRectEx: (%d,%d)-(%d,%d) %08lx %d %08lx\n",
106 rect->left, rect->top, rect->right, rect->bottom, style, menu, exStyle );
108 NC_AdjustRect( rect, style, menu, exStyle );
112 /*******************************************************************
113 * NC_GetMinMaxInfo
115 * Get the minimized and maximized information for a window.
117 void NC_GetMinMaxInfo( HWND hwnd, POINT *maxSize, POINT *maxPos,
118 POINT *minTrack, POINT *maxTrack )
120 HANDLE minmaxHandle;
121 MINMAXINFO MinMax, *pMinMax;
122 short xinc, yinc;
123 WND *wndPtr = WIN_FindWndPtr( hwnd );
125 /* Compute default values */
127 MinMax.ptMaxSize.x = SYSMETRICS_CXSCREEN;
128 MinMax.ptMaxSize.y = SYSMETRICS_CYSCREEN;
129 MinMax.ptMinTrackSize.x = SYSMETRICS_CXMINTRACK;
130 MinMax.ptMinTrackSize.y = SYSMETRICS_CYMINTRACK;
131 MinMax.ptMaxTrackSize.x = SYSMETRICS_CXSCREEN;
132 MinMax.ptMaxTrackSize.y = SYSMETRICS_CYSCREEN;
134 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
136 xinc = SYSMETRICS_CXDLGFRAME;
137 yinc = SYSMETRICS_CYDLGFRAME;
139 else
141 xinc = yinc = 0;
142 if (HAS_THICKFRAME(wndPtr->dwStyle))
144 xinc += SYSMETRICS_CXFRAME;
145 yinc += SYSMETRICS_CYFRAME;
147 if (wndPtr->dwStyle & WS_BORDER)
149 xinc += SYSMETRICS_CXBORDER;
150 yinc += SYSMETRICS_CYBORDER;
153 MinMax.ptMaxSize.x += 2 * xinc;
154 MinMax.ptMaxSize.y += 2 * yinc;
156 if ((wndPtr->ptMaxPos.x != -1) || (wndPtr->ptMaxPos.y != -1))
157 MinMax.ptMaxPosition = wndPtr->ptMaxPos;
158 else
160 MinMax.ptMaxPosition.x = -xinc;
161 MinMax.ptMaxPosition.y = -yinc;
164 minmaxHandle = USER_HEAP_ALLOC( LMEM_MOVEABLE, sizeof(MINMAXINFO) );
165 if (minmaxHandle)
167 pMinMax = (MINMAXINFO *) USER_HEAP_ADDR( minmaxHandle );
168 memcpy( pMinMax, &MinMax, sizeof(MinMax) );
169 SendMessage( hwnd, WM_GETMINMAXINFO, 0, (LONG)pMinMax );
171 else pMinMax = &MinMax;
173 /* Some sanity checks */
175 pMinMax->ptMaxTrackSize.x = max( pMinMax->ptMaxTrackSize.x,
176 pMinMax->ptMinTrackSize.x );
177 pMinMax->ptMaxTrackSize.y = max( pMinMax->ptMaxTrackSize.y,
178 pMinMax->ptMinTrackSize.y );
180 if (maxSize) *maxSize = pMinMax->ptMaxSize;
181 if (maxPos) *maxPos = pMinMax->ptMaxPosition;
182 if (minTrack) *minTrack = pMinMax->ptMinTrackSize;
183 if (maxTrack) *maxTrack = pMinMax->ptMaxTrackSize;
184 if (minmaxHandle) USER_HEAP_FREE( minmaxHandle );
188 /***********************************************************************
189 * NC_HandleNCCalcSize
191 * Handle a WM_NCCALCSIZE message. Called from DefWindowProc().
193 LONG NC_HandleNCCalcSize( HWND hwnd, NCCALCSIZE_PARAMS *params )
195 RECT tmpRect = { 0, 0, 0, 0 };
196 WND *wndPtr = WIN_FindWndPtr( hwnd );
198 if (!wndPtr) return 0;
199 NC_AdjustRect( &tmpRect, wndPtr->dwStyle, FALSE, wndPtr->dwExStyle );
200 params->rgrc[0].left -= tmpRect.left;
201 params->rgrc[0].top -= tmpRect.top;
202 params->rgrc[0].right -= tmpRect.right;
203 params->rgrc[0].bottom -= tmpRect.bottom;
205 if (HAS_MENU(wndPtr))
207 params->rgrc[0].top += MENU_GetMenuBarHeight( hwnd,
208 params->rgrc[0].right - params->rgrc[0].left,
209 -tmpRect.left, -tmpRect.top ) + 1;
211 return 0;
215 /***********************************************************************
216 * NC_GetInsideRect
218 * Get the 'inside' rectangle of a window, i.e. the whole window rectangle
219 * but without the borders (if any).
220 * The rectangle is in window coordinates (for drawing with GetWindowDC()).
222 void NC_GetInsideRect( HWND hwnd, RECT *rect )
224 WND * wndPtr = WIN_FindWndPtr( hwnd );
226 rect->top = rect->left = 0;
227 rect->right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
228 rect->bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
230 if (wndPtr->dwStyle & WS_ICONIC) return; /* No border to remove */
232 /* Remove frame from rectangle */
233 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
235 InflateRect( rect, -SYSMETRICS_CXDLGFRAME, -SYSMETRICS_CYDLGFRAME);
236 if (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME) InflateRect( rect, -1, 0);
238 else
240 if (HAS_THICKFRAME( wndPtr->dwStyle ))
241 InflateRect( rect, -SYSMETRICS_CXFRAME, -SYSMETRICS_CYFRAME );
242 if (wndPtr->dwStyle & WS_BORDER)
243 InflateRect( rect, -SYSMETRICS_CXBORDER, -SYSMETRICS_CYBORDER );
248 /***********************************************************************
249 * NC_HandleNCHitTest
251 * Handle a WM_NCHITTEST message. Called from DefWindowProc().
253 LONG NC_HandleNCHitTest( HWND hwnd, POINT pt )
255 RECT rect;
256 WND *wndPtr = WIN_FindWndPtr( hwnd );
257 if (!wndPtr) return HTERROR;
259 dprintf_nonclient(stddeb, "NC_HandleNCHitTest: hwnd=%x pt=%d,%d\n",
260 hwnd, pt.x, pt.y );
262 GetWindowRect( hwnd, &rect );
263 if (!PtInRect( &rect, pt )) return HTNOWHERE;
266 * if this is a iconic window, we don't care were the hit
267 * occured, only that it did occur, just return HTCAPTION
268 * so the caller knows the icon did get hit
270 if (IsIconic(hwnd))
272 return HTCAPTION; /* change this to something meaningful? */
275 /* Check borders */
276 if (HAS_THICKFRAME( wndPtr->dwStyle ))
278 InflateRect( &rect, -SYSMETRICS_CXFRAME, -SYSMETRICS_CYFRAME );
279 if (wndPtr->dwStyle & WS_BORDER)
280 InflateRect( &rect, -SYSMETRICS_CXBORDER, -SYSMETRICS_CYBORDER );
281 if (!PtInRect( &rect, pt ))
283 /* Check top sizing border */
284 if (pt.y < rect.top)
286 if (pt.x < rect.left+SYSMETRICS_CXSIZE) return HTTOPLEFT;
287 if (pt.x >= rect.right-SYSMETRICS_CXSIZE) return HTTOPRIGHT;
288 return HTTOP;
290 /* Check bottom sizing border */
291 if (pt.y >= rect.bottom)
293 if (pt.x < rect.left+SYSMETRICS_CXSIZE) return HTBOTTOMLEFT;
294 if (pt.x >= rect.right-SYSMETRICS_CXSIZE) return HTBOTTOMRIGHT;
295 return HTBOTTOM;
297 /* Check left sizing border */
298 if (pt.x < rect.left)
300 if (pt.y < rect.top+SYSMETRICS_CYSIZE) return HTTOPLEFT;
301 if (pt.y >= rect.bottom-SYSMETRICS_CYSIZE) return HTBOTTOMLEFT;
302 return HTLEFT;
304 /* Check right sizing border */
305 if (pt.x >= rect.right)
307 if (pt.y < rect.top+SYSMETRICS_CYSIZE) return HTTOPRIGHT;
308 if (pt.y >= rect.bottom-SYSMETRICS_CYSIZE) return HTBOTTOMRIGHT;
309 return HTRIGHT;
313 else /* No thick frame */
315 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
316 InflateRect(&rect, -SYSMETRICS_CXDLGFRAME, -SYSMETRICS_CYDLGFRAME);
317 else if (wndPtr->dwStyle & WS_BORDER)
318 InflateRect(&rect, -SYSMETRICS_CXBORDER, -SYSMETRICS_CYBORDER);
319 if (!PtInRect( &rect, pt )) return HTBORDER;
322 /* Check caption */
324 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
326 rect.top += SYSMETRICS_CYCAPTION - 1;
327 if (!PtInRect( &rect, pt ))
329 /* Check system menu */
330 if (wndPtr->dwStyle & WS_SYSMENU)
331 rect.left += SYSMETRICS_CXSIZE;
332 if (pt.x <= rect.left) return HTSYSMENU;
333 /* Check maximize box */
334 if (wndPtr->dwStyle & WS_MAXIMIZEBOX)
335 rect.right -= SYSMETRICS_CXSIZE + 1;
336 if (pt.x >= rect.right) return HTMAXBUTTON;
337 /* Check minimize box */
338 if (wndPtr->dwStyle & WS_MINIMIZEBOX)
339 rect.right -= SYSMETRICS_CXSIZE + 1;
340 if (pt.x >= rect.right) return HTMINBUTTON;
341 return HTCAPTION;
345 /* Check client area */
347 ScreenToClient( hwnd, &pt );
348 GetClientRect( hwnd, &rect );
349 if (PtInRect( &rect, pt )) return HTCLIENT;
351 /* Check vertical scroll bar */
353 if (wndPtr->dwStyle & WS_VSCROLL)
355 rect.right += SYSMETRICS_CXVSCROLL;
356 if (PtInRect( &rect, pt )) return HTVSCROLL;
359 /* Check horizontal scroll bar */
361 if (wndPtr->dwStyle & WS_HSCROLL)
363 rect.bottom += SYSMETRICS_CYHSCROLL;
364 if (PtInRect( &rect, pt ))
366 /* Check size box */
367 if ((wndPtr->dwStyle & WS_VSCROLL) &&
368 (pt.x >= rect.right - SYSMETRICS_CXVSCROLL))
369 return HTSIZE;
370 return HTHSCROLL;
374 /* Check menu bar */
376 if (HAS_MENU(wndPtr))
378 if ((pt.y < 0) && (pt.x >= 0) && (pt.x < rect.right))
379 return HTMENU;
382 /* Should never get here */
383 return HTERROR;
387 /***********************************************************************
388 * NC_DrawSysButton
390 void NC_DrawSysButton( HWND hwnd, HDC hdc, BOOL down )
392 RECT rect;
393 HDC hdcMem;
394 HBITMAP hbitmap;
395 WND *wndPtr = WIN_FindWndPtr( hwnd );
397 NC_GetInsideRect( hwnd, &rect );
398 hdcMem = CreateCompatibleDC( hdc );
399 hbitmap = SelectObject( hdcMem, hbitmapClose );
400 BitBlt( hdc, rect.left, rect.top, SYSMETRICS_CXSIZE, SYSMETRICS_CYSIZE,
401 hdcMem, (wndPtr->dwStyle & WS_CHILD) ? SYSMETRICS_CXSIZE : 0, 0,
402 down ? NOTSRCCOPY : SRCCOPY );
403 SelectObject( hdcMem, hbitmap );
404 DeleteDC( hdcMem );
408 /***********************************************************************
409 * NC_DrawMaxButton
411 static void NC_DrawMaxButton( HWND hwnd, HDC hdc, BOOL down )
413 RECT rect;
414 NC_GetInsideRect( hwnd, &rect );
415 GRAPH_DrawBitmap( hdc, (IsZoomed(hwnd) ?
416 (down ? hbitmapRestoreD : hbitmapRestore) :
417 (down ? hbitmapMaximizeD : hbitmapMaximize)),
418 rect.right - SYSMETRICS_CXSIZE - 1, rect.top,
419 0, 0, SYSMETRICS_CXSIZE+1, SYSMETRICS_CYSIZE );
423 /***********************************************************************
424 * NC_DrawMinButton
426 static void NC_DrawMinButton( HWND hwnd, HDC hdc, BOOL down )
428 RECT rect;
429 WND *wndPtr = WIN_FindWndPtr( hwnd );
430 NC_GetInsideRect( hwnd, &rect );
431 if (wndPtr->dwStyle & WS_MAXIMIZEBOX) rect.right -= SYSMETRICS_CXSIZE + 1;
432 GRAPH_DrawBitmap( hdc, (down ? hbitmapMinimizeD : hbitmapMinimize),
433 rect.right - SYSMETRICS_CXSIZE - 1, rect.top,
434 0, 0, SYSMETRICS_CXSIZE+1, SYSMETRICS_CYSIZE );
438 /***********************************************************************
439 * NC_DrawFrame
441 * Draw a window frame inside the given rectangle, and update the rectangle.
442 * The correct pen for the frame must be selected in the DC.
444 static void NC_DrawFrame( HDC hdc, RECT *rect, BOOL dlgFrame, BOOL active )
446 short width, height, tmp;
448 if (dlgFrame)
450 width = SYSMETRICS_CXDLGFRAME - 1;
451 height = SYSMETRICS_CYDLGFRAME - 1;
452 SelectObject( hdc, active ? sysColorObjects.hbrushActiveCaption :
453 sysColorObjects.hbrushInactiveCaption );
455 else
457 width = SYSMETRICS_CXFRAME - 1;
458 height = SYSMETRICS_CYFRAME - 1;
459 SelectObject( hdc, active ? sysColorObjects.hbrushActiveBorder :
460 sysColorObjects.hbrushInactiveBorder );
463 /* Draw frame */
464 PatBlt( hdc, rect->left, rect->top,
465 rect->right - rect->left, height, PATCOPY );
466 PatBlt( hdc, rect->left, rect->top,
467 width, rect->bottom - rect->top, PATCOPY );
468 PatBlt( hdc, rect->left, rect->bottom,
469 rect->right - rect->left, -height, PATCOPY );
470 PatBlt( hdc, rect->right, rect->top,
471 -width, rect->bottom - rect->top, PATCOPY );
473 if (dlgFrame)
475 InflateRect( rect, -width, -height );
476 return;
479 /* Draw inner rectangle */
480 MoveTo( hdc, rect->left+width, rect->top+height );
481 LineTo( hdc, rect->right-width-1, rect->top+height );
482 LineTo( hdc, rect->right-width-1, rect->bottom-height-1 );
483 LineTo( hdc, rect->left+width, rect->bottom-height-1 );
484 LineTo( hdc, rect->left+width, rect->top+height );
486 /* Draw the decorations */
487 tmp = rect->top + SYSMETRICS_CYFRAME + SYSMETRICS_CYSIZE;
488 MoveTo( hdc, rect->left, tmp);
489 LineTo( hdc, rect->left+width, tmp );
490 MoveTo( hdc, rect->right-width-1, tmp );
491 LineTo( hdc, rect->right-1, tmp );
493 tmp = rect->bottom - 1 - SYSMETRICS_CYFRAME - SYSMETRICS_CYSIZE;
494 MoveTo( hdc, rect->left, tmp );
495 LineTo( hdc, rect->left+width, tmp );
496 MoveTo( hdc, rect->right-width-1, tmp );
497 LineTo( hdc, rect->right-1, tmp );
499 tmp = rect->left + SYSMETRICS_CXFRAME + SYSMETRICS_CXSIZE;
500 MoveTo( hdc, tmp, rect->top );
501 LineTo( hdc, tmp, rect->top+height );
502 MoveTo( hdc, tmp, rect->bottom-height-1 );
503 LineTo( hdc, tmp, rect->bottom-1 );
505 tmp = rect->right - 1 - SYSMETRICS_CXFRAME - SYSMETRICS_CYSIZE;
506 MoveTo( hdc, tmp, rect->top );
507 LineTo( hdc, tmp, rect->top+height );
508 MoveTo( hdc, tmp, rect->bottom-height-1 );
509 LineTo( hdc, tmp, rect->bottom-1 );
511 InflateRect( rect, -width-1, -height-1 );
515 /***********************************************************************
516 * NC_DrawMovingFrame
518 * Draw the frame used when moving or resizing window.
520 static void NC_DrawMovingFrame( HDC hdc, RECT *rect, BOOL thickframe )
522 if (thickframe)
524 SelectObject( hdc, GetStockObject( GRAY_BRUSH ) );
525 PatBlt( hdc, rect->left, rect->top,
526 rect->right - rect->left - SYSMETRICS_CXFRAME,
527 SYSMETRICS_CYFRAME, PATINVERT );
528 PatBlt( hdc, rect->left, rect->top + SYSMETRICS_CYFRAME,
529 SYSMETRICS_CXFRAME,
530 rect->bottom - rect->top - SYSMETRICS_CYFRAME, PATINVERT );
531 PatBlt( hdc, rect->left + SYSMETRICS_CXFRAME, rect->bottom,
532 rect->right - rect->left - SYSMETRICS_CXFRAME,
533 -SYSMETRICS_CYFRAME, PATINVERT );
534 PatBlt( hdc, rect->right, rect->top, -SYSMETRICS_CXFRAME,
535 rect->bottom - rect->top - SYSMETRICS_CYFRAME, PATINVERT );
537 else DrawFocusRect( hdc, rect );
541 /***********************************************************************
542 * NC_DrawCaption
544 * Draw the window caption.
545 * The correct pen for the window frame must be selected in the DC.
547 static void NC_DrawCaption( HDC hdc, RECT *rect, HWND hwnd,
548 DWORD style, BOOL active )
550 RECT r = *rect;
551 WND * wndPtr = WIN_FindWndPtr( hwnd );
552 char buffer[256];
554 if (!hbitmapClose)
556 if (!(hbitmapClose = LoadBitmap( 0, MAKEINTRESOURCE(OBM_CLOSE) )))
557 return;
558 hbitmapMinimize = LoadBitmap( 0, MAKEINTRESOURCE(OBM_REDUCE) );
559 hbitmapMinimizeD = LoadBitmap( 0, MAKEINTRESOURCE(OBM_REDUCED) );
560 hbitmapMaximize = LoadBitmap( 0, MAKEINTRESOURCE(OBM_ZOOM) );
561 hbitmapMaximizeD = LoadBitmap( 0, MAKEINTRESOURCE(OBM_ZOOMD) );
562 hbitmapRestore = LoadBitmap( 0, MAKEINTRESOURCE(OBM_RESTORE) );
563 hbitmapRestoreD = LoadBitmap( 0, MAKEINTRESOURCE(OBM_RESTORED) );
566 if (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME)
568 HBRUSH hbrushOld = SelectObject( hdc, sysColorObjects.hbrushWindow );
569 PatBlt( hdc, r.left, r.top, 1, r.bottom-r.top+1,PATCOPY );
570 PatBlt( hdc, r.right-1, r.top, 1, r.bottom-r.top+1, PATCOPY );
571 PatBlt( hdc, r.left, r.top-1, r.right-r.left, 1, PATCOPY );
572 r.left++;
573 r.right--;
574 SelectObject( hdc, hbrushOld );
577 MoveTo( hdc, r.left, r.bottom );
578 LineTo( hdc, r.right-1, r.bottom );
580 if (style & WS_SYSMENU)
582 NC_DrawSysButton( hwnd, hdc, FALSE );
583 r.left += SYSMETRICS_CXSIZE + 1;
584 MoveTo( hdc, r.left - 1, r.top );
585 LineTo( hdc, r.left - 1, r.bottom );
587 if (style & WS_MAXIMIZEBOX)
589 NC_DrawMaxButton( hwnd, hdc, FALSE );
590 r.right -= SYSMETRICS_CXSIZE + 1;
592 if (style & WS_MINIMIZEBOX)
594 NC_DrawMinButton( hwnd, hdc, FALSE );
595 r.right -= SYSMETRICS_CXSIZE + 1;
598 FillRect( hdc, &r, active ? sysColorObjects.hbrushActiveCaption :
599 sysColorObjects.hbrushInactiveCaption );
601 if (GetWindowText( hwnd, buffer, 256 ))
603 if (active) SetTextColor( hdc, GetSysColor( COLOR_CAPTIONTEXT ) );
604 else SetTextColor( hdc, GetSysColor( COLOR_INACTIVECAPTIONTEXT ) );
605 SetBkMode( hdc, TRANSPARENT );
606 DrawText( hdc, buffer, -1, &r, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
611 /***********************************************************************
612 * NC_DoNCPaint
614 * Paint the non-client area.
616 void NC_DoNCPaint( HWND hwnd, BOOL active, BOOL suppress_menupaint )
618 HDC hdc;
619 RECT rect;
621 WND *wndPtr = WIN_FindWndPtr( hwnd );
623 dprintf_nonclient(stddeb, "NC_DoNCPaint: %x %d\n", hwnd, active );
624 if (!wndPtr || !(wndPtr->dwStyle & WS_VISIBLE)) return; /* Nothing to do */
626 if (!(hdc = GetDCEx( hwnd, 0, DCX_USESTYLE | DCX_WINDOW ))) return;
629 * If this is an icon, we don't want to do any more nonclient painting
630 * of the window manager.
631 * If there is a class icon to draw, draw it
633 if (IsIconic(hwnd))
635 HICON hIcon = WIN_CLASS_INFO(wndPtr).hIcon;
636 if (hIcon)
638 SendMessage(hwnd, WM_ICONERASEBKGND, hdc, 0);
639 DrawIcon(hdc, 0, 0, hIcon);
641 ReleaseDC(hwnd, hdc);
642 return;
645 if (ExcludeVisRect( hdc, wndPtr->rectClient.left-wndPtr->rectWindow.left,
646 wndPtr->rectClient.top-wndPtr->rectWindow.top,
647 wndPtr->rectClient.right-wndPtr->rectWindow.left,
648 wndPtr->rectClient.bottom-wndPtr->rectWindow.top )
649 == NULLREGION)
651 ReleaseDC( hwnd, hdc );
652 return;
655 rect.top = rect.left = 0;
656 rect.right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
657 rect.bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
659 SelectObject( hdc, sysColorObjects.hpenWindowFrame );
661 if ((wndPtr->dwStyle & WS_BORDER) || (wndPtr->dwStyle & WS_DLGFRAME) ||
662 (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME))
664 MoveTo( hdc, 0, 0 );
665 LineTo( hdc, rect.right-1, 0 );
666 LineTo( hdc, rect.right-1, rect.bottom-1 );
667 LineTo( hdc, 0, rect.bottom-1 );
668 LineTo( hdc, 0, 0 );
669 InflateRect( &rect, -1, -1 );
672 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
673 NC_DrawFrame( hdc, &rect, TRUE, active );
674 else if (wndPtr->dwStyle & WS_THICKFRAME)
675 NC_DrawFrame(hdc, &rect, FALSE, active );
677 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
679 RECT r = rect;
680 r.bottom = rect.top + SYSMETRICS_CYSIZE;
681 rect.top += SYSMETRICS_CYSIZE + SYSMETRICS_CYBORDER;
682 NC_DrawCaption( hdc, &r, hwnd, wndPtr->dwStyle, active );
685 if (HAS_MENU(wndPtr))
687 RECT r = rect;
688 r.bottom = rect.top + SYSMETRICS_CYMENU; /* default height */
689 rect.top += MENU_DrawMenuBar( hdc, &r, hwnd, suppress_menupaint );
692 /* Draw the scroll-bars */
694 if (wndPtr->dwStyle & WS_VSCROLL) SCROLL_DrawScrollBar(hwnd, hdc, SB_VERT);
695 if (wndPtr->dwStyle & WS_HSCROLL) SCROLL_DrawScrollBar(hwnd, hdc, SB_HORZ);
697 /* Draw the "size-box" */
699 if ((wndPtr->dwStyle & WS_VSCROLL) && (wndPtr->dwStyle & WS_HSCROLL))
701 RECT r = rect;
702 r.left = r.right - SYSMETRICS_CXVSCROLL + 1;
703 r.top = r.bottom - SYSMETRICS_CYHSCROLL + 1;
704 FillRect( hdc, &r, sysColorObjects.hbrushScrollbar );
707 ReleaseDC( hwnd, hdc );
712 /***********************************************************************
713 * NC_HandleNCPaint
715 * Handle a WM_NCPAINT message. Called from DefWindowProc().
717 LONG NC_HandleNCPaint( HWND hwnd )
719 NC_DoNCPaint( hwnd, hwnd == GetActiveWindow(), FALSE );
720 return 0;
724 /***********************************************************************
725 * NC_HandleNCActivate
727 * Handle a WM_NCACTIVATE message. Called from DefWindowProc().
729 LONG NC_HandleNCActivate( HWND hwnd, WORD wParam )
731 NC_DoNCPaint( hwnd, wParam, FALSE );
732 return TRUE;
736 /***********************************************************************
737 * NC_HandleSetCursor
739 * Handle a WM_SETCURSOR message. Called from DefWindowProc().
741 LONG NC_HandleSetCursor( HWND hwnd, WORD wParam, LONG lParam )
743 if (hwnd != wParam) return 0; /* Don't set the cursor for child windows */
745 switch(LOWORD(lParam))
747 case HTERROR:
749 WORD msg = HIWORD( lParam );
750 if ((msg == WM_LBUTTONDOWN) || (msg == WM_MBUTTONDOWN) ||
751 (msg == WM_RBUTTONDOWN))
752 MessageBeep(0);
754 break;
756 case HTCLIENT:
758 WND *wndPtr;
759 CLASS *classPtr;
760 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) break;
761 if (!(classPtr = CLASS_FindClassPtr( wndPtr->hClass ))) break;
762 if (classPtr->wc.hCursor)
764 SetCursor( classPtr->wc.hCursor );
765 return TRUE;
767 else return FALSE;
770 case HTLEFT:
771 case HTRIGHT:
772 return SetCursor( LoadCursor( 0, IDC_SIZEWE ) );
774 case HTTOP:
775 case HTBOTTOM:
776 return SetCursor( LoadCursor( 0, IDC_SIZENS ) );
778 case HTTOPLEFT:
779 case HTBOTTOMRIGHT:
780 return SetCursor( LoadCursor( 0, IDC_SIZENWSE ) );
782 case HTTOPRIGHT:
783 case HTBOTTOMLEFT:
784 return SetCursor( LoadCursor( 0, IDC_SIZENESW ) );
787 /* Default cursor: arrow */
788 return SetCursor( LoadCursor( 0, IDC_ARROW ) );
792 /***********************************************************************
793 * NC_StartSizeMove
795 * Initialisation of a move or resize, when initiatied from a menu choice.
796 * Return hit test code for caption or sizing border.
798 static LONG NC_StartSizeMove( HWND hwnd, WORD wParam, POINT *capturePoint )
800 LONG hittest = 0;
801 POINT pt;
802 MSG msg;
803 WND * wndPtr = WIN_FindWndPtr( hwnd );
805 if ((wParam & 0xfff0) == SC_MOVE)
807 /* Move pointer at the center of the caption */
808 RECT rect;
809 NC_GetInsideRect( hwnd, &rect );
810 if (wndPtr->dwStyle & WS_SYSMENU)
811 rect.left += SYSMETRICS_CXSIZE + 1;
812 if (wndPtr->dwStyle & WS_MINIMIZEBOX)
813 rect.right -= SYSMETRICS_CXSIZE + 1;
814 if (wndPtr->dwStyle & WS_MAXIMIZEBOX)
815 rect.right -= SYSMETRICS_CXSIZE + 1;
816 pt.x = wndPtr->rectWindow.left + (rect.right - rect.left) / 2;
817 pt.y = wndPtr->rectWindow.top + rect.top + SYSMETRICS_CYSIZE/2;
818 if (wndPtr->dwStyle & WS_CHILD)
819 ClientToScreen( wndPtr->hwndParent, &pt );
820 hittest = HTCAPTION;
822 else /* SC_SIZE */
824 SetCapture(hwnd);
825 while(!hittest)
827 MSG_GetHardwareMessage( &msg );
828 switch(msg.message)
830 case WM_MOUSEMOVE:
831 hittest = NC_HandleNCHitTest( hwnd, msg.pt );
832 pt = msg.pt;
833 if ((hittest < HTLEFT) || (hittest > HTBOTTOMRIGHT))
834 hittest = 0;
835 break;
837 case WM_LBUTTONUP:
838 return 0;
840 case WM_KEYDOWN:
841 switch(msg.wParam)
843 case VK_UP:
844 hittest = HTTOP;
845 pt.x =(wndPtr->rectWindow.left+wndPtr->rectWindow.right)/2;
846 pt.y = wndPtr->rectWindow.top + SYSMETRICS_CYFRAME / 2;
847 break;
848 case VK_DOWN:
849 hittest = HTBOTTOM;
850 pt.x =(wndPtr->rectWindow.left+wndPtr->rectWindow.right)/2;
851 pt.y = wndPtr->rectWindow.bottom - SYSMETRICS_CYFRAME / 2;
852 break;
853 case VK_LEFT:
854 hittest = HTLEFT;
855 pt.x = wndPtr->rectWindow.left + SYSMETRICS_CXFRAME / 2;
856 pt.y =(wndPtr->rectWindow.top+wndPtr->rectWindow.bottom)/2;
857 break;
858 case VK_RIGHT:
859 hittest = HTRIGHT;
860 pt.x = wndPtr->rectWindow.right - SYSMETRICS_CXFRAME / 2;
861 pt.y =(wndPtr->rectWindow.top+wndPtr->rectWindow.bottom)/2;
862 break;
863 case VK_RETURN:
864 case VK_ESCAPE: return 0;
869 *capturePoint = pt;
870 SetCursorPos( capturePoint->x, capturePoint->y );
871 NC_HandleSetCursor( hwnd, hwnd, MAKELONG( hittest, WM_MOUSEMOVE ));
872 return hittest;
876 /***********************************************************************
877 * NC_DoSizeMove
879 * Perform SC_MOVE and SC_SIZE commands.
881 static void NC_DoSizeMove( HWND hwnd, WORD wParam, POINT pt )
883 MSG msg;
884 LONG hittest;
885 RECT sizingRect, mouseRect;
886 HDC hdc;
887 BOOL thickframe;
888 POINT minTrack, maxTrack, capturePoint = pt;
889 WND * wndPtr = WIN_FindWndPtr( hwnd );
891 if (IsZoomed(hwnd) || !IsWindowVisible(hwnd)) return;
892 hittest = wParam & 0x0f;
893 thickframe = HAS_THICKFRAME( wndPtr->dwStyle );
895 if ((wParam & 0xfff0) == SC_MOVE)
897 if (!(wndPtr->dwStyle & WS_CAPTION)) return;
898 if (!hittest) hittest = NC_StartSizeMove( hwnd, wParam, &capturePoint );
899 if (!hittest) return;
901 else /* SC_SIZE */
903 if (!thickframe) return;
904 if (hittest) hittest += HTLEFT-1;
905 else
907 SetCapture(hwnd);
908 hittest = NC_StartSizeMove( hwnd, wParam, &capturePoint );
909 if (!hittest)
911 ReleaseCapture();
912 return;
917 /* Get min/max info */
919 NC_GetMinMaxInfo( hwnd, NULL, NULL, &minTrack, &maxTrack );
920 sizingRect = wndPtr->rectWindow;
921 if (wndPtr->dwStyle & WS_CHILD)
922 GetClientRect( wndPtr->hwndParent, &mouseRect );
923 else SetRect( &mouseRect, 0, 0, SYSMETRICS_CXSCREEN, SYSMETRICS_CYSCREEN );
924 if (ON_LEFT_BORDER(hittest))
926 mouseRect.left = max( mouseRect.left, sizingRect.right-maxTrack.x );
927 mouseRect.right = min( mouseRect.right, sizingRect.right-minTrack.x );
929 else if (ON_RIGHT_BORDER(hittest))
931 mouseRect.left = max( mouseRect.left, sizingRect.left+minTrack.x );
932 mouseRect.right = min( mouseRect.right, sizingRect.left+maxTrack.x );
934 if (ON_TOP_BORDER(hittest))
936 mouseRect.top = max( mouseRect.top, sizingRect.bottom-maxTrack.y );
937 mouseRect.bottom = min( mouseRect.bottom,sizingRect.bottom-minTrack.y);
939 else if (ON_BOTTOM_BORDER(hittest))
941 mouseRect.top = max( mouseRect.top, sizingRect.top+minTrack.y );
942 mouseRect.bottom = min( mouseRect.bottom, sizingRect.top+maxTrack.y );
944 SendMessage( hwnd, WM_ENTERSIZEMOVE, 0, 0 );
946 if (GetCapture() != hwnd) SetCapture( hwnd );
948 if (wndPtr->dwStyle & WS_CHILD)
950 /* Retrieve a default cache DC (without using the window style) */
951 hdc = GetDCEx( wndPtr->hwndParent, 0, DCX_CACHE );
953 else
954 { /* Grab the server only when moving top-level windows without desktop */
955 hdc = GetDC( 0 );
956 if (rootWindow == DefaultRootWindow(display)) XGrabServer( display );
958 NC_DrawMovingFrame( hdc, &sizingRect, thickframe );
960 while(1)
962 int dx = 0, dy = 0;
964 MSG_GetHardwareMessage( &msg );
966 /* Exit on button-up, Return, or Esc */
967 if ((msg.message == WM_LBUTTONUP) ||
968 ((msg.message == WM_KEYDOWN) &&
969 ((msg.wParam == VK_RETURN) || (msg.wParam == VK_ESCAPE)))) break;
971 if ((msg.message != WM_KEYDOWN) && (msg.message != WM_MOUSEMOVE))
972 continue; /* We are not interested in other messages */
974 pt = msg.pt;
975 if (wndPtr->dwStyle & WS_CHILD)
976 ScreenToClient( wndPtr->hwndParent, &pt );
979 if (msg.message == WM_KEYDOWN) switch(msg.wParam)
981 case VK_UP: pt.y -= 8; break;
982 case VK_DOWN: pt.y += 8; break;
983 case VK_LEFT: pt.x -= 8; break;
984 case VK_RIGHT: pt.x += 8; break;
987 pt.x = max( pt.x, mouseRect.left );
988 pt.x = min( pt.x, mouseRect.right );
989 pt.y = max( pt.y, mouseRect.top );
990 pt.y = min( pt.y, mouseRect.bottom );
992 dx = pt.x - capturePoint.x;
993 dy = pt.y - capturePoint.y;
995 if (dx || dy)
997 if (msg.message == WM_KEYDOWN) SetCursorPos( pt.x, pt.y );
998 else
1000 RECT newRect = sizingRect;
1002 if (hittest == HTCAPTION) OffsetRect( &newRect, dx, dy );
1003 if (ON_LEFT_BORDER(hittest)) newRect.left += dx;
1004 else if (ON_RIGHT_BORDER(hittest)) newRect.right += dx;
1005 if (ON_TOP_BORDER(hittest)) newRect.top += dy;
1006 else if (ON_BOTTOM_BORDER(hittest)) newRect.bottom += dy;
1007 NC_DrawMovingFrame( hdc, &sizingRect, thickframe );
1008 NC_DrawMovingFrame( hdc, &newRect, thickframe );
1009 capturePoint = pt;
1010 sizingRect = newRect;
1015 NC_DrawMovingFrame( hdc, &sizingRect, thickframe );
1016 ReleaseCapture();
1017 if (wndPtr->dwStyle & WS_CHILD) ReleaseDC( wndPtr->hwndParent, hdc );
1018 else
1020 ReleaseDC( 0, hdc );
1021 if (rootWindow == DefaultRootWindow(display)) XUngrabServer( display );
1023 SendMessage( hwnd, WM_EXITSIZEMOVE, 0, 0 );
1025 /* If Esc key, don't move the window */
1026 if ((msg.message == WM_KEYDOWN) && (msg.wParam == VK_ESCAPE)) return;
1028 if (hittest != HTCAPTION)
1029 SetWindowPos( hwnd, 0, sizingRect.left, sizingRect.top,
1030 sizingRect.right - sizingRect.left,
1031 sizingRect.bottom - sizingRect.top,
1032 SWP_NOACTIVATE | SWP_NOZORDER );
1033 else SetWindowPos( hwnd, 0, sizingRect.left, sizingRect.top, 0, 0,
1034 SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER );
1038 /***********************************************************************
1039 * NC_TrackMinMaxBox
1041 * Track a mouse button press on the minimize or maximize box.
1043 static void NC_TrackMinMaxBox( HWND hwnd, WORD wParam )
1045 MSG msg;
1046 HDC hdc = GetWindowDC( hwnd );
1047 BOOL pressed = TRUE;
1049 SetCapture( hwnd );
1050 if (wParam == HTMINBUTTON) NC_DrawMinButton( hwnd, hdc, TRUE );
1051 else NC_DrawMaxButton( hwnd, hdc, TRUE );
1055 BOOL oldstate = pressed;
1056 MSG_GetHardwareMessage( &msg );
1058 pressed = (NC_HandleNCHitTest( hwnd, msg.pt ) == wParam);
1059 if (pressed != oldstate)
1061 if (wParam == HTMINBUTTON) NC_DrawMinButton( hwnd, hdc, pressed );
1062 else NC_DrawMaxButton( hwnd, hdc, pressed );
1064 } while (msg.message != WM_LBUTTONUP);
1066 if (wParam == HTMINBUTTON) NC_DrawMinButton( hwnd, hdc, FALSE );
1067 else NC_DrawMaxButton( hwnd, hdc, FALSE );
1069 ReleaseCapture();
1070 ReleaseDC( hwnd, hdc );
1071 if (!pressed) return;
1073 if (wParam == HTMINBUTTON)
1074 SendMessage( hwnd, WM_SYSCOMMAND, SC_MINIMIZE, *(LONG*)&msg.pt );
1075 else
1076 SendMessage( hwnd, WM_SYSCOMMAND,
1077 IsZoomed(hwnd) ? SC_RESTORE : SC_MAXIMIZE, *(LONG*)&msg.pt );
1081 /***********************************************************************
1082 * NC_TrackScrollBar
1084 * Track a mouse button press on the horizontal or vertical scroll-bar.
1086 static void NC_TrackScrollBar( HWND hwnd, WORD wParam, POINT pt )
1088 MSG msg;
1089 WORD scrollbar;
1090 WND *wndPtr = WIN_FindWndPtr( hwnd );
1092 if ((wParam & 0xfff0) == SC_HSCROLL)
1094 if ((wParam & 0x0f) != HTHSCROLL) return;
1095 scrollbar = SB_HORZ;
1097 else /* SC_VSCROLL */
1099 if ((wParam & 0x0f) != HTVSCROLL) return;
1100 scrollbar = SB_VERT;
1103 pt.x -= wndPtr->rectWindow.left;
1104 pt.y -= wndPtr->rectWindow.top;
1105 SetCapture( hwnd );
1106 SCROLL_HandleScrollEvent( hwnd, scrollbar, WM_LBUTTONDOWN, pt );
1110 GetMessage( &msg, 0, 0, 0 );
1111 switch(msg.message)
1113 case WM_LBUTTONUP:
1114 case WM_MOUSEMOVE:
1115 case WM_SYSTIMER:
1116 pt = MAKEPOINT(msg.lParam);
1117 pt.x += wndPtr->rectClient.left - wndPtr->rectWindow.left;
1118 pt.y += wndPtr->rectClient.top - wndPtr->rectWindow.top;
1119 SCROLL_HandleScrollEvent( hwnd, scrollbar, msg.message, pt );
1120 break;
1121 default:
1122 TranslateMessage( &msg );
1123 DispatchMessage( &msg );
1124 break;
1126 if (!IsWindow( hwnd ))
1128 ReleaseCapture();
1129 break;
1131 } while (msg.message != WM_LBUTTONUP);
1134 /***********************************************************************
1135 * NC_TrackSysMenu
1137 * Track a mouse button press on the system menu.
1139 static void NC_TrackSysMenu( HWND hwnd, HDC hdc, POINT pt )
1141 RECT rect;
1142 WND *wndPtr = WIN_FindWndPtr( hwnd );
1144 if (!(wndPtr->dwStyle & WS_SYSMENU)) return;
1145 /* If window has a menu, track the menu bar normally */
1146 if (HAS_MENU(wndPtr)) MENU_TrackMouseMenuBar( hwnd, pt );
1147 else
1149 /* Otherwise track the system menu like a normal popup menu */
1150 NC_GetInsideRect( hwnd, &rect );
1151 OffsetRect( &rect, wndPtr->rectWindow.left, wndPtr->rectWindow.top );
1152 if (wndPtr->dwStyle & WS_CHILD)
1153 ClientToScreen( wndPtr->hwndParent, (POINT *)&rect );
1154 rect.right = rect.left + SYSMETRICS_CXSIZE;
1155 rect.bottom = rect.top + SYSMETRICS_CYSIZE;
1156 NC_DrawSysButton( hwnd, hdc, TRUE );
1157 TrackPopupMenu( wndPtr->hSysMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON,
1158 rect.left, rect.bottom, 0, hwnd, &rect );
1159 NC_DrawSysButton( hwnd, hdc, FALSE );
1164 /***********************************************************************
1165 * NC_HandleNCLButtonDown
1167 * Handle a WM_NCLBUTTONDOWN message. Called from DefWindowProc().
1169 LONG NC_HandleNCLButtonDown( HWND hwnd, WORD wParam, LONG lParam )
1171 HDC hdc = GetWindowDC( hwnd );
1173 switch(wParam) /* Hit test */
1175 case HTCAPTION:
1176 SendMessage( hwnd, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, lParam );
1177 break;
1179 case HTSYSMENU:
1180 NC_TrackSysMenu( hwnd, hdc, MAKEPOINT(lParam) );
1181 break;
1183 case HTMENU:
1184 SendMessage( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU, lParam );
1185 break;
1187 case HTHSCROLL:
1188 SendMessage( hwnd, WM_SYSCOMMAND, SC_HSCROLL + HTHSCROLL, lParam );
1189 break;
1191 case HTVSCROLL:
1192 SendMessage( hwnd, WM_SYSCOMMAND, SC_VSCROLL + HTVSCROLL, lParam );
1193 break;
1195 case HTMINBUTTON:
1196 case HTMAXBUTTON:
1197 NC_TrackMinMaxBox( hwnd, wParam );
1198 break;
1200 case HTLEFT:
1201 case HTRIGHT:
1202 case HTTOP:
1203 case HTTOPLEFT:
1204 case HTTOPRIGHT:
1205 case HTBOTTOM:
1206 case HTBOTTOMLEFT:
1207 case HTBOTTOMRIGHT:
1208 SendMessage( hwnd, WM_SYSCOMMAND, SC_SIZE + wParam - HTLEFT+1, lParam);
1209 break;
1211 case HTBORDER:
1212 break;
1215 ReleaseDC( hwnd, hdc );
1216 return 0;
1220 /***********************************************************************
1221 * NC_HandleNCLButtonDblClk
1223 * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc().
1225 LONG NC_HandleNCLButtonDblClk( HWND hwnd, WORD wParam, LONG lParam )
1228 * if this is an icon, send a restore since we are handling
1229 * a double click
1231 if (IsIconic(hwnd))
1233 SendMessage(hwnd, WM_SYSCOMMAND, SC_RESTORE, lParam);
1234 return 0;
1237 switch(wParam) /* Hit test */
1239 case HTCAPTION:
1240 SendMessage( hwnd, WM_SYSCOMMAND,
1241 IsZoomed(hwnd) ? SC_RESTORE : SC_MAXIMIZE, lParam );
1242 break;
1244 case HTSYSMENU:
1245 SendMessage( hwnd, WM_SYSCOMMAND, SC_CLOSE, lParam );
1246 break;
1248 return 0;
1252 /***********************************************************************
1253 * NC_HandleSysCommand
1255 * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
1257 LONG NC_HandleSysCommand( HWND hwnd, WORD wParam, POINT pt )
1259 WND *wndPtr = WIN_FindWndPtr( hwnd );
1261 dprintf_nonclient(stddeb, "Handling WM_SYSCOMMAND %x %d,%d\n",
1262 wParam, pt.x, pt.y );
1264 if (wndPtr->dwStyle & WS_CHILD) ScreenToClient( wndPtr->hwndParent, &pt );
1266 switch (wParam & 0xfff0)
1268 case SC_SIZE:
1269 case SC_MOVE:
1270 NC_DoSizeMove( hwnd, wParam, pt );
1271 break;
1273 case SC_MINIMIZE:
1274 ShowWindow( hwnd, SW_MINIMIZE );
1275 break;
1277 case SC_MAXIMIZE:
1278 ShowWindow( hwnd, SW_MAXIMIZE );
1279 break;
1281 case SC_RESTORE:
1282 ShowWindow( hwnd, SW_RESTORE );
1283 break;
1285 case SC_NEXTWINDOW:
1286 case SC_PREVWINDOW:
1287 break;
1289 case SC_CLOSE:
1290 return SendMessage( hwnd, WM_CLOSE, 0, 0 );
1292 case SC_VSCROLL:
1293 case SC_HSCROLL:
1294 NC_TrackScrollBar( hwnd, wParam, pt );
1295 break;
1297 case SC_MOUSEMENU:
1298 MENU_TrackMouseMenuBar( hwnd, pt );
1299 break;
1301 case SC_KEYMENU:
1302 MENU_TrackKbdMenuBar( hwnd, wParam );
1303 break;
1305 case SC_ARRANGE:
1306 break;
1308 case SC_TASKLIST:
1309 /* WinExec( "taskman.exe", SW_SHOWNORMAL ); */
1310 break;
1312 case SC_HOTKEY:
1313 break;
1315 case SC_SCREENSAVE:
1316 if (wParam == SC_ABOUTWINE)
1317 { extern char sysres_DIALOG_2[];
1318 DialogBoxIndirectPtr( wndPtr->hInstance, sysres_DIALOG_2,
1319 hwnd, (WNDPROC)AboutWine_Proc );
1321 break;
1323 return 0;