2 * Non-client area window functions
4 * Copyright 1994 Alexandre Julliard
10 #include "sysmetrics.h"
20 #include "nonclient.h"
23 #include "selectors.h"
29 static HBITMAP16 hbitmapClose
= 0;
30 static HBITMAP16 hbitmapMinimize
= 0;
31 static HBITMAP16 hbitmapMinimizeD
= 0;
32 static HBITMAP16 hbitmapMaximize
= 0;
33 static HBITMAP16 hbitmapMaximizeD
= 0;
34 static HBITMAP16 hbitmapRestore
= 0;
35 static HBITMAP16 hbitmapRestoreD
= 0;
37 #define SC_ABOUTWINE (SC_SCREENSAVE+1)
39 /* Some useful macros */
40 #define HAS_DLGFRAME(style,exStyle) \
41 (((exStyle) & WS_EX_DLGMODALFRAME) || \
42 (((style) & WS_DLGFRAME) && !((style) & WS_BORDER)))
44 #define HAS_THICKFRAME(style) \
45 (((style) & WS_THICKFRAME) && \
46 !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
48 #define HAS_MENU(w) (!((w)->dwStyle & WS_CHILD) && ((w)->wIDmenu != 0))
50 #define ON_LEFT_BORDER(hit) \
51 (((hit) == HTLEFT) || ((hit) == HTTOPLEFT) || ((hit) == HTBOTTOMLEFT))
52 #define ON_RIGHT_BORDER(hit) \
53 (((hit) == HTRIGHT) || ((hit) == HTTOPRIGHT) || ((hit) == HTBOTTOMRIGHT))
54 #define ON_TOP_BORDER(hit) \
55 (((hit) == HTTOP) || ((hit) == HTTOPLEFT) || ((hit) == HTTOPRIGHT))
56 #define ON_BOTTOM_BORDER(hit) \
57 (((hit) == HTBOTTOM) || ((hit) == HTBOTTOMLEFT) || ((hit) == HTBOTTOMRIGHT))
59 extern HCURSOR16
CURSORICON_IconToCursor( HICON16
, BOOL32
);
61 /***********************************************************************
64 * Compute the size of the window rectangle from the size of the
67 static void NC_AdjustRect( LPRECT16 rect
, DWORD style
, BOOL32 menu
,
70 if(style
& WS_ICONIC
) return;
71 /* Decide if the window will be managed (see CreateWindowEx) */
72 if (!(Options
.managed
&& !(style
& WS_CHILD
) &&
73 ((style
& (WS_DLGFRAME
| WS_THICKFRAME
)) ||
74 (exStyle
& WS_EX_DLGMODALFRAME
))))
76 if (HAS_DLGFRAME( style
, exStyle
))
77 InflateRect16(rect
, SYSMETRICS_CXDLGFRAME
, SYSMETRICS_CYDLGFRAME
);
80 if (HAS_THICKFRAME(style
))
81 InflateRect16( rect
, SYSMETRICS_CXFRAME
, SYSMETRICS_CYFRAME
);
82 if (style
& WS_BORDER
)
83 InflateRect16( rect
, SYSMETRICS_CXBORDER
, SYSMETRICS_CYBORDER
);
86 if ((style
& WS_CAPTION
) == WS_CAPTION
)
87 rect
->top
-= SYSMETRICS_CYCAPTION
- SYSMETRICS_CYBORDER
;
89 if (menu
) rect
->top
-= SYSMETRICS_CYMENU
+ SYSMETRICS_CYBORDER
;
91 if (style
& WS_VSCROLL
) rect
->right
+= SYSMETRICS_CXVSCROLL
;
92 if (style
& WS_HSCROLL
) rect
->bottom
+= SYSMETRICS_CYHSCROLL
;
96 /***********************************************************************
97 * AdjustWindowRect16 (USER.102)
99 BOOL16
AdjustWindowRect16( LPRECT16 rect
, DWORD style
, BOOL16 menu
)
101 return AdjustWindowRectEx16( rect
, style
, menu
, 0 );
105 /***********************************************************************
106 * AdjustWindowRect32 (USER32.)
108 BOOL32
AdjustWindowRect32( LPRECT32 rect
, DWORD style
, BOOL32 menu
)
110 return AdjustWindowRectEx32( rect
, style
, menu
, 0 );
114 /***********************************************************************
115 * AdjustWindowRectEx16 (USER.454)
117 BOOL16
AdjustWindowRectEx16( LPRECT16 rect
, DWORD style
,
118 BOOL16 menu
, DWORD exStyle
)
120 /* Correct the window style */
122 if (!(style
& (WS_POPUP
| WS_CHILD
))) /* Overlapped window */
124 style
&= (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
);
125 exStyle
&= WS_EX_DLGMODALFRAME
;
126 if (exStyle
& WS_EX_DLGMODALFRAME
) style
&= ~WS_THICKFRAME
;
128 dprintf_nonclient(stddeb
, "AdjustWindowRectEx: (%d,%d)-(%d,%d) %08lx %d %08lx\n",
129 rect
->left
, rect
->top
, rect
->right
, rect
->bottom
,
130 style
, menu
, exStyle
);
132 NC_AdjustRect( rect
, style
, menu
, exStyle
);
137 /***********************************************************************
138 * AdjustWindowRectEx32 (USER32.)
140 BOOL32
AdjustWindowRectEx32( LPRECT32 rect
, DWORD style
,
141 BOOL32 menu
, DWORD exStyle
)
146 CONV_RECT32TO16( rect
, &rect16
);
147 ret
= AdjustWindowRectEx16( &rect16
, style
, (BOOL16
)menu
, exStyle
);
148 CONV_RECT16TO32( &rect16
, rect
);
153 /*******************************************************************
156 * Get the minimized and maximized information for a window.
158 void NC_GetMinMaxInfo( WND
*wndPtr
, POINT16
*maxSize
, POINT16
*maxPos
,
159 POINT16
*minTrack
, POINT16
*maxTrack
)
161 MINMAXINFO16
*MinMax
;
164 if (!(MinMax
= SEGPTR_NEW(MINMAXINFO16
))) return;
166 /* Compute default values */
168 MinMax
->ptMaxSize
.x
= SYSMETRICS_CXSCREEN
;
169 MinMax
->ptMaxSize
.y
= SYSMETRICS_CYSCREEN
;
170 MinMax
->ptMinTrackSize
.x
= SYSMETRICS_CXMINTRACK
;
171 MinMax
->ptMinTrackSize
.y
= SYSMETRICS_CYMINTRACK
;
172 MinMax
->ptMaxTrackSize
.x
= SYSMETRICS_CXSCREEN
;
173 MinMax
->ptMaxTrackSize
.y
= SYSMETRICS_CYSCREEN
;
175 if (wndPtr
->flags
& WIN_MANAGED
) xinc
= yinc
= 0;
176 else if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
178 xinc
= SYSMETRICS_CXDLGFRAME
;
179 yinc
= SYSMETRICS_CYDLGFRAME
;
184 if (HAS_THICKFRAME(wndPtr
->dwStyle
))
186 xinc
+= SYSMETRICS_CXFRAME
;
187 yinc
+= SYSMETRICS_CYFRAME
;
189 if (wndPtr
->dwStyle
& WS_BORDER
)
191 xinc
+= SYSMETRICS_CXBORDER
;
192 yinc
+= SYSMETRICS_CYBORDER
;
195 MinMax
->ptMaxSize
.x
+= 2 * xinc
;
196 MinMax
->ptMaxSize
.y
+= 2 * yinc
;
198 /* Note: The '+' in the following test should really be a ||, but
199 * that would cause gcc-2.7.0 to generate incorrect code.
201 if ((wndPtr
->ptMaxPos
.x
!= -1) + (wndPtr
->ptMaxPos
.y
!= -1))
202 MinMax
->ptMaxPosition
= wndPtr
->ptMaxPos
;
205 MinMax
->ptMaxPosition
.x
= -xinc
;
206 MinMax
->ptMaxPosition
.y
= -yinc
;
209 SendMessage16( wndPtr
->hwndSelf
, WM_GETMINMAXINFO
, 0,
210 (LPARAM
)SEGPTR_GET(MinMax
) );
212 /* Some sanity checks */
214 dprintf_nonclient(stddeb
,
215 "NC_GetMinMaxInfo: %d %d / %d %d / %d %d / %d %d\n",
216 MinMax
->ptMaxSize
.x
, MinMax
->ptMaxSize
.y
,
217 MinMax
->ptMaxPosition
.x
, MinMax
->ptMaxPosition
.y
,
218 MinMax
->ptMaxTrackSize
.x
, MinMax
->ptMaxTrackSize
.y
,
219 MinMax
->ptMinTrackSize
.x
, MinMax
->ptMinTrackSize
.y
);
220 MinMax
->ptMaxTrackSize
.x
= MAX( MinMax
->ptMaxTrackSize
.x
,
221 MinMax
->ptMinTrackSize
.x
);
222 MinMax
->ptMaxTrackSize
.y
= MAX( MinMax
->ptMaxTrackSize
.y
,
223 MinMax
->ptMinTrackSize
.y
);
225 if (maxSize
) *maxSize
= MinMax
->ptMaxSize
;
226 if (maxPos
) *maxPos
= MinMax
->ptMaxPosition
;
227 if (minTrack
) *minTrack
= MinMax
->ptMinTrackSize
;
228 if (maxTrack
) *maxTrack
= MinMax
->ptMaxTrackSize
;
233 /***********************************************************************
234 * NC_HandleNCCalcSize
236 * Handle a WM_NCCALCSIZE message. Called from DefWindowProc().
238 LONG
NC_HandleNCCalcSize( WND
*pWnd
, RECT16
*winRect
)
240 RECT16 tmpRect
= { 0, 0, 0, 0 };
243 if (pWnd
->class->style
& CS_VREDRAW
) result
|= WVR_VREDRAW
;
244 if (pWnd
->class->style
& CS_HREDRAW
) result
|= WVR_HREDRAW
;
246 if( !( pWnd
->dwStyle
& WS_MINIMIZE
) )
248 NC_AdjustRect( &tmpRect
, pWnd
->dwStyle
, FALSE
, pWnd
->dwExStyle
);
249 winRect
->left
-= tmpRect
.left
;
250 winRect
->top
-= tmpRect
.top
;
251 winRect
->right
-= tmpRect
.right
;
252 winRect
->bottom
-= tmpRect
.bottom
;
256 winRect
->top
+= MENU_GetMenuBarHeight( pWnd
->hwndSelf
,
257 winRect
->right
- winRect
->left
,
258 -tmpRect
.left
, -tmpRect
.top
) + 1;
265 /***********************************************************************
268 * Get the 'inside' rectangle of a window, i.e. the whole window rectangle
269 * but without the borders (if any).
270 * The rectangle is in window coordinates (for drawing with GetWindowDC()).
272 static void NC_GetInsideRect( HWND32 hwnd
, RECT32
*rect
)
274 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
276 rect
->top
= rect
->left
= 0;
277 rect
->right
= wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
;
278 rect
->bottom
= wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
;
280 if (wndPtr
->dwStyle
& WS_ICONIC
) return; /* No border to remove */
281 if (wndPtr
->flags
& WIN_MANAGED
) return;
283 /* Remove frame from rectangle */
284 if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
286 InflateRect32( rect
, -SYSMETRICS_CXDLGFRAME
, -SYSMETRICS_CYDLGFRAME
);
287 if (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
)
288 InflateRect32( rect
, -1, 0 );
292 if (HAS_THICKFRAME( wndPtr
->dwStyle
))
293 InflateRect32( rect
, -SYSMETRICS_CXFRAME
, -SYSMETRICS_CYFRAME
);
294 if (wndPtr
->dwStyle
& WS_BORDER
)
295 InflateRect32( rect
, -SYSMETRICS_CXBORDER
, -SYSMETRICS_CYBORDER
);
300 /***********************************************************************
303 * Handle a WM_NCHITTEST message. Called from DefWindowProc().
305 LONG
NC_HandleNCHitTest( HWND32 hwnd
, POINT16 pt
)
308 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
309 if (!wndPtr
) return HTERROR
;
311 dprintf_nonclient(stddeb
, "NC_HandleNCHitTest: hwnd=%04x pt=%d,%d\n",
314 GetWindowRect16( hwnd
, &rect
);
315 if (!PtInRect16( &rect
, pt
)) return HTNOWHERE
;
317 if (wndPtr
->dwStyle
& WS_MINIMIZE
) return HTCAPTION
;
319 if (!(wndPtr
->flags
& WIN_MANAGED
))
322 if (HAS_THICKFRAME( wndPtr
->dwStyle
))
324 InflateRect16( &rect
, -SYSMETRICS_CXFRAME
, -SYSMETRICS_CYFRAME
);
325 if (wndPtr
->dwStyle
& WS_BORDER
)
326 InflateRect16(&rect
,-SYSMETRICS_CXBORDER
,-SYSMETRICS_CYBORDER
);
327 if (!PtInRect16( &rect
, pt
))
329 /* Check top sizing border */
332 if (pt
.x
< rect
.left
+SYSMETRICS_CXSIZE
) return HTTOPLEFT
;
333 if (pt
.x
>= rect
.right
-SYSMETRICS_CXSIZE
) return HTTOPRIGHT
;
336 /* Check bottom sizing border */
337 if (pt
.y
>= rect
.bottom
)
339 if (pt
.x
< rect
.left
+SYSMETRICS_CXSIZE
) return HTBOTTOMLEFT
;
340 if (pt
.x
>= rect
.right
-SYSMETRICS_CXSIZE
) return HTBOTTOMRIGHT
;
343 /* Check left sizing border */
344 if (pt
.x
< rect
.left
)
346 if (pt
.y
< rect
.top
+SYSMETRICS_CYSIZE
) return HTTOPLEFT
;
347 if (pt
.y
>= rect
.bottom
-SYSMETRICS_CYSIZE
) return HTBOTTOMLEFT
;
350 /* Check right sizing border */
351 if (pt
.x
>= rect
.right
)
353 if (pt
.y
< rect
.top
+SYSMETRICS_CYSIZE
) return HTTOPRIGHT
;
354 if (pt
.y
>= rect
.bottom
-SYSMETRICS_CYSIZE
) return HTBOTTOMRIGHT
;
359 else /* No thick frame */
361 if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
362 InflateRect16(&rect
, -SYSMETRICS_CXDLGFRAME
, -SYSMETRICS_CYDLGFRAME
);
363 else if (wndPtr
->dwStyle
& WS_BORDER
)
364 InflateRect16(&rect
, -SYSMETRICS_CXBORDER
, -SYSMETRICS_CYBORDER
);
365 if (!PtInRect16( &rect
, pt
)) return HTBORDER
;
370 if ((wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
372 rect
.top
+= SYSMETRICS_CYCAPTION
- 1;
373 if (!PtInRect16( &rect
, pt
))
375 /* Check system menu */
376 if (wndPtr
->dwStyle
& WS_SYSMENU
)
377 rect
.left
+= SYSMETRICS_CXSIZE
;
378 if (pt
.x
<= rect
.left
) return HTSYSMENU
;
379 /* Check maximize box */
380 if (wndPtr
->dwStyle
& WS_MAXIMIZEBOX
)
381 rect
.right
-= SYSMETRICS_CXSIZE
+ 1;
382 if (pt
.x
>= rect
.right
) return HTMAXBUTTON
;
383 /* Check minimize box */
384 if (wndPtr
->dwStyle
& WS_MINIMIZEBOX
)
385 rect
.right
-= SYSMETRICS_CXSIZE
+ 1;
386 if (pt
.x
>= rect
.right
) return HTMINBUTTON
;
392 /* Check client area */
394 ScreenToClient16( hwnd
, &pt
);
395 GetClientRect16( hwnd
, &rect
);
396 if (PtInRect16( &rect
, pt
)) return HTCLIENT
;
398 /* Check vertical scroll bar */
400 if (wndPtr
->dwStyle
& WS_VSCROLL
)
402 rect
.right
+= SYSMETRICS_CXVSCROLL
;
403 if (PtInRect16( &rect
, pt
)) return HTVSCROLL
;
406 /* Check horizontal scroll bar */
408 if (wndPtr
->dwStyle
& WS_HSCROLL
)
410 rect
.bottom
+= SYSMETRICS_CYHSCROLL
;
411 if (PtInRect16( &rect
, pt
))
414 if ((wndPtr
->dwStyle
& WS_VSCROLL
) &&
415 (pt
.x
>= rect
.right
- SYSMETRICS_CXVSCROLL
))
423 if (HAS_MENU(wndPtr
))
425 if ((pt
.y
< 0) && (pt
.x
>= 0) && (pt
.x
< rect
.right
))
429 /* Should never get here */
434 /***********************************************************************
437 void NC_DrawSysButton( HWND32 hwnd
, HDC32 hdc
, BOOL32 down
)
442 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
444 if( !(wndPtr
->flags
& WIN_MANAGED
) )
446 NC_GetInsideRect( hwnd
, &rect
);
447 hdcMem
= CreateCompatibleDC32( hdc
);
448 hbitmap
= SelectObject32( hdcMem
, hbitmapClose
);
449 BitBlt32(hdc
, rect
.left
, rect
.top
, SYSMETRICS_CXSIZE
, SYSMETRICS_CYSIZE
,
450 hdcMem
, (wndPtr
->dwStyle
& WS_CHILD
) ? SYSMETRICS_CXSIZE
: 0, 0,
451 down
? NOTSRCCOPY
: SRCCOPY
);
452 SelectObject32( hdcMem
, hbitmap
);
453 DeleteDC32( hdcMem
);
458 /***********************************************************************
461 static void NC_DrawMaxButton( HWND32 hwnd
, HDC16 hdc
, BOOL32 down
)
464 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
466 if( !(wndPtr
->flags
& WIN_MANAGED
) )
468 NC_GetInsideRect( hwnd
, &rect
);
469 GRAPH_DrawBitmap( hdc
, (IsZoomed32(hwnd
) ?
470 (down
? hbitmapRestoreD
: hbitmapRestore
) :
471 (down
? hbitmapMaximizeD
: hbitmapMaximize
)),
472 rect
.right
- SYSMETRICS_CXSIZE
- 1, rect
.top
,
473 0, 0, SYSMETRICS_CXSIZE
+1, SYSMETRICS_CYSIZE
);
478 /***********************************************************************
481 static void NC_DrawMinButton( HWND32 hwnd
, HDC16 hdc
, BOOL32 down
)
484 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
486 if( !(wndPtr
->flags
& WIN_MANAGED
) )
488 NC_GetInsideRect( hwnd
, &rect
);
489 if (wndPtr
->dwStyle
& WS_MAXIMIZEBOX
) rect
.right
-= SYSMETRICS_CXSIZE
+1;
490 GRAPH_DrawBitmap( hdc
, (down
? hbitmapMinimizeD
: hbitmapMinimize
),
491 rect
.right
- SYSMETRICS_CXSIZE
- 1, rect
.top
,
492 0, 0, SYSMETRICS_CXSIZE
+1, SYSMETRICS_CYSIZE
);
497 /***********************************************************************
500 * Draw a window frame inside the given rectangle, and update the rectangle.
501 * The correct pen for the frame must be selected in the DC.
503 static void NC_DrawFrame( HDC16 hdc
, RECT16
*rect
, BOOL32 dlgFrame
,
506 short width
, height
, tmp
;
510 width
= SYSMETRICS_CXDLGFRAME
- 1;
511 height
= SYSMETRICS_CYDLGFRAME
- 1;
512 SelectObject32( hdc
, active
? sysColorObjects
.hbrushActiveCaption
:
513 sysColorObjects
.hbrushInactiveCaption
);
517 width
= SYSMETRICS_CXFRAME
- 1;
518 height
= SYSMETRICS_CYFRAME
- 1;
519 SelectObject32( hdc
, active
? sysColorObjects
.hbrushActiveBorder
:
520 sysColorObjects
.hbrushInactiveBorder
);
524 PatBlt32( hdc
, rect
->left
, rect
->top
,
525 rect
->right
- rect
->left
, height
, PATCOPY
);
526 PatBlt32( hdc
, rect
->left
, rect
->top
,
527 width
, rect
->bottom
- rect
->top
, PATCOPY
);
528 PatBlt32( hdc
, rect
->left
, rect
->bottom
,
529 rect
->right
- rect
->left
, -height
, PATCOPY
);
530 PatBlt32( hdc
, rect
->right
, rect
->top
,
531 -width
, rect
->bottom
- rect
->top
, PATCOPY
);
535 InflateRect16( rect
, -width
, -height
);
539 /* Draw inner rectangle */
540 MoveTo( hdc
, rect
->left
+width
, rect
->top
+height
);
541 LineTo32( hdc
, rect
->right
-width
-1, rect
->top
+height
);
542 LineTo32( hdc
, rect
->right
-width
-1, rect
->bottom
-height
-1 );
543 LineTo32( hdc
, rect
->left
+width
, rect
->bottom
-height
-1 );
544 LineTo32( hdc
, rect
->left
+width
, rect
->top
+height
);
546 /* Draw the decorations */
547 tmp
= rect
->top
+ SYSMETRICS_CYFRAME
+ SYSMETRICS_CYSIZE
;
548 MoveTo( hdc
, rect
->left
, tmp
);
549 LineTo32( hdc
, rect
->left
+width
, tmp
);
550 MoveTo( hdc
, rect
->right
-width
-1, tmp
);
551 LineTo32( hdc
, rect
->right
-1, tmp
);
553 tmp
= rect
->bottom
- 1 - SYSMETRICS_CYFRAME
- SYSMETRICS_CYSIZE
;
554 MoveTo( hdc
, rect
->left
, tmp
);
555 LineTo32( hdc
, rect
->left
+width
, tmp
);
556 MoveTo( hdc
, rect
->right
-width
-1, tmp
);
557 LineTo32( hdc
, rect
->right
-1, tmp
);
559 tmp
= rect
->left
+ SYSMETRICS_CXFRAME
+ SYSMETRICS_CXSIZE
;
560 MoveTo( hdc
, tmp
, rect
->top
);
561 LineTo32( hdc
, tmp
, rect
->top
+height
);
562 MoveTo( hdc
, tmp
, rect
->bottom
-height
-1 );
563 LineTo32( hdc
, tmp
, rect
->bottom
-1 );
565 tmp
= rect
->right
- 1 - SYSMETRICS_CXFRAME
- SYSMETRICS_CYSIZE
;
566 MoveTo( hdc
, tmp
, rect
->top
);
567 LineTo32( hdc
, tmp
, rect
->top
+height
);
568 MoveTo( hdc
, tmp
, rect
->bottom
-height
-1 );
569 LineTo32( hdc
, tmp
, rect
->bottom
-1 );
571 InflateRect16( rect
, -width
-1, -height
-1 );
575 /***********************************************************************
578 * Draw the frame used when moving or resizing window.
580 static void NC_DrawMovingFrame( HDC16 hdc
, RECT16
*rect
, BOOL32 thickframe
)
582 if (thickframe
) FastWindowFrame( hdc
, rect
, SYSMETRICS_CXFRAME
,
583 SYSMETRICS_CYFRAME
, PATINVERT
);
584 else DrawFocusRect16( hdc
, rect
);
588 /***********************************************************************
591 * Draw the window caption.
592 * The correct pen for the window frame must be selected in the DC.
594 static void NC_DrawCaption( HDC16 hdc
, RECT16
*rect
, HWND32 hwnd
,
595 DWORD style
, BOOL32 active
)
598 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
601 if (wndPtr
->flags
& WIN_MANAGED
) return;
605 if (!(hbitmapClose
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_CLOSE
) )))
607 hbitmapMinimize
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_REDUCE
) );
608 hbitmapMinimizeD
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_REDUCED
) );
609 hbitmapMaximize
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_ZOOM
) );
610 hbitmapMaximizeD
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_ZOOMD
) );
611 hbitmapRestore
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_RESTORE
) );
612 hbitmapRestoreD
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_RESTORED
) );
615 if (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
)
617 HBRUSH32 hbrushOld
= SelectObject32(hdc
, sysColorObjects
.hbrushWindow
);
618 PatBlt32( hdc
, r
.left
, r
.top
, 1, r
.bottom
-r
.top
+1,PATCOPY
);
619 PatBlt32( hdc
, r
.right
-1, r
.top
, 1, r
.bottom
-r
.top
+1, PATCOPY
);
620 PatBlt32( hdc
, r
.left
, r
.top
-1, r
.right
-r
.left
, 1, PATCOPY
);
623 SelectObject32( hdc
, hbrushOld
);
626 MoveTo( hdc
, r
.left
, r
.bottom
);
627 LineTo32( hdc
, r
.right
-1, r
.bottom
);
629 if (style
& WS_SYSMENU
)
631 NC_DrawSysButton( hwnd
, hdc
, FALSE
);
632 r
.left
+= SYSMETRICS_CXSIZE
+ 1;
633 MoveTo( hdc
, r
.left
- 1, r
.top
);
634 LineTo32( hdc
, r
.left
- 1, r
.bottom
);
636 if (style
& WS_MAXIMIZEBOX
)
638 NC_DrawMaxButton( hwnd
, hdc
, FALSE
);
639 r
.right
-= SYSMETRICS_CXSIZE
+ 1;
641 if (style
& WS_MINIMIZEBOX
)
643 NC_DrawMinButton( hwnd
, hdc
, FALSE
);
644 r
.right
-= SYSMETRICS_CXSIZE
+ 1;
647 FillRect16( hdc
, &r
, active
? sysColorObjects
.hbrushActiveCaption
:
648 sysColorObjects
.hbrushInactiveCaption
);
650 if (GetWindowText32A( hwnd
, buffer
, sizeof(buffer
) ))
652 if (active
) SetTextColor32( hdc
, GetSysColor32( COLOR_CAPTIONTEXT
) );
653 else SetTextColor32( hdc
, GetSysColor32( COLOR_INACTIVECAPTIONTEXT
) );
654 SetBkMode32( hdc
, TRANSPARENT
);
655 DrawText16( hdc
, buffer
, -1, &r
,
656 DT_SINGLELINE
| DT_CENTER
| DT_VCENTER
| DT_NOPREFIX
);
661 /***********************************************************************
664 * Paint the non-client area. clip is currently unused.
666 void NC_DoNCPaint( HWND32 hwnd
, HRGN32 clip
, BOOL32 suppress_menupaint
)
672 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
674 if (!wndPtr
|| wndPtr
->dwStyle
& WS_MINIMIZE
||
675 !WIN_IsWindowDrawable( wndPtr
, 0 )) return; /* Nothing to do */
677 active
= wndPtr
->flags
& WIN_NCACTIVATED
;
679 dprintf_nonclient(stddeb
, "NC_DoNCPaint: %04x %d\n", hwnd
, active
);
681 if (!(hdc
= GetDCEx32( hwnd
, 0, DCX_USESTYLE
| DCX_WINDOW
))) return;
683 if (ExcludeVisRect( hdc
, wndPtr
->rectClient
.left
-wndPtr
->rectWindow
.left
,
684 wndPtr
->rectClient
.top
-wndPtr
->rectWindow
.top
,
685 wndPtr
->rectClient
.right
-wndPtr
->rectWindow
.left
,
686 wndPtr
->rectClient
.bottom
-wndPtr
->rectWindow
.top
)
689 ReleaseDC32( hwnd
, hdc
);
693 rect
.top
= rect
.left
= 0;
694 rect
.right
= wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
;
695 rect
.bottom
= wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
;
697 SelectObject32( hdc
, sysColorObjects
.hpenWindowFrame
);
699 if (!(wndPtr
->flags
& WIN_MANAGED
))
701 if ((wndPtr
->dwStyle
& WS_BORDER
) || (wndPtr
->dwStyle
& WS_DLGFRAME
) ||
702 (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
))
705 LineTo32( hdc
, rect
.right
-1, 0 );
706 LineTo32( hdc
, rect
.right
-1, rect
.bottom
-1 );
707 LineTo32( hdc
, 0, rect
.bottom
-1 );
708 LineTo32( hdc
, 0, 0 );
709 InflateRect16( &rect
, -1, -1 );
712 if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
713 NC_DrawFrame( hdc
, &rect
, TRUE
, active
);
714 else if (wndPtr
->dwStyle
& WS_THICKFRAME
)
715 NC_DrawFrame(hdc
, &rect
, FALSE
, active
);
717 if ((wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
720 r
.bottom
= rect
.top
+ SYSMETRICS_CYSIZE
;
721 rect
.top
+= SYSMETRICS_CYSIZE
+ SYSMETRICS_CYBORDER
;
722 NC_DrawCaption( hdc
, &r
, hwnd
, wndPtr
->dwStyle
, active
);
726 if (HAS_MENU(wndPtr
))
729 CONV_RECT16TO32( &rect
, &r
);
730 r
.bottom
= rect
.top
+ SYSMETRICS_CYMENU
; /* default height */
731 rect
.top
+= MENU_DrawMenuBar( hdc
, &r
, hwnd
, suppress_menupaint
);
734 /* Draw the scroll-bars */
736 if (wndPtr
->dwStyle
& WS_VSCROLL
)
737 SCROLL_DrawScrollBar( hwnd
, hdc
, SB_VERT
, TRUE
);
738 if (wndPtr
->dwStyle
& WS_HSCROLL
)
739 SCROLL_DrawScrollBar( hwnd
, hdc
, SB_HORZ
, TRUE
);
741 /* Draw the "size-box" */
743 if ((wndPtr
->dwStyle
& WS_VSCROLL
) && (wndPtr
->dwStyle
& WS_HSCROLL
))
746 r
.left
= r
.right
- SYSMETRICS_CXVSCROLL
+ 1;
747 r
.top
= r
.bottom
- SYSMETRICS_CYHSCROLL
+ 1;
748 FillRect16( hdc
, &r
, sysColorObjects
.hbrushScrollbar
);
751 ReleaseDC32( hwnd
, hdc
);
756 /***********************************************************************
759 * Handle a WM_NCPAINT message. Called from DefWindowProc().
761 LONG
NC_HandleNCPaint( HWND32 hwnd
, HRGN32 clip
)
763 NC_DoNCPaint( hwnd
, clip
, FALSE
);
768 /***********************************************************************
769 * NC_HandleNCActivate
771 * Handle a WM_NCACTIVATE message. Called from DefWindowProc().
773 LONG
NC_HandleNCActivate( WND
*wndPtr
, WPARAM16 wParam
)
777 if( wParam
) wStateChange
= !(wndPtr
->flags
& WIN_NCACTIVATED
);
778 else wStateChange
= wndPtr
->flags
& WIN_NCACTIVATED
;
782 if (wParam
) wndPtr
->flags
|= WIN_NCACTIVATED
;
783 else wndPtr
->flags
&= ~WIN_NCACTIVATED
;
785 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
786 PAINT_RedrawWindow( wndPtr
->hwndSelf
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_ERASENOW
, 0 );
788 NC_DoNCPaint( wndPtr
->hwndSelf
, (HRGN32
)1, FALSE
);
794 /***********************************************************************
797 * Handle a WM_SETCURSOR message. Called from DefWindowProc().
799 LONG
NC_HandleSetCursor( HWND32 hwnd
, WPARAM16 wParam
, LPARAM lParam
)
801 if (hwnd
!= (HWND32
)wParam
) return 0; /* Don't set the cursor for child windows */
803 switch(LOWORD(lParam
))
807 WORD msg
= HIWORD( lParam
);
808 if ((msg
== WM_LBUTTONDOWN
) || (msg
== WM_MBUTTONDOWN
) ||
809 (msg
== WM_RBUTTONDOWN
))
817 if (!(wndPtr
= WIN_FindWndPtr( hwnd
))) break;
818 if (wndPtr
->class->hCursor
)
820 SetCursor16( wndPtr
->class->hCursor
);
828 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZEWE
) );
832 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZENS
) );
836 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZENWSE
) );
840 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZENESW
) );
843 /* Default cursor: arrow */
844 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_ARROW
) );
847 /***********************************************************************
850 BOOL32
NC_GetSysPopupPos( WND
* wndPtr
, RECT32
* rect
)
852 if( wndPtr
->hSysMenu
)
854 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
855 GetWindowRect32( wndPtr
->hwndSelf
, rect
);
858 NC_GetInsideRect( wndPtr
->hwndSelf
, rect
);
859 OffsetRect32( rect
, wndPtr
->rectWindow
.left
, wndPtr
->rectWindow
.top
);
860 if (wndPtr
->dwStyle
& WS_CHILD
)
861 ClientToScreen32( wndPtr
->parent
->hwndSelf
, (POINT32
*)rect
);
862 rect
->right
= rect
->left
+ SYSMETRICS_CXSIZE
;
863 rect
->bottom
= rect
->top
+ SYSMETRICS_CYSIZE
;
870 /***********************************************************************
873 * Track a mouse button press on the system menu.
875 static void NC_TrackSysMenu( HWND32 hwnd
, POINT16 pt
)
877 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
879 if (wndPtr
->dwStyle
& WS_SYSMENU
)
883 iconic
= wndPtr
->dwStyle
& WS_MINIMIZE
;
887 HDC16 hdc
= GetWindowDC32(hwnd
);
890 BOOL32 bNew
, bTrack
= TRUE
;
893 NC_GetSysPopupPos( wndPtr
, &rect
);
894 CONV_RECT32TO16( &rect
, &rTrack
);
895 MapWindowPoints16( 0, hwnd
, (LPPOINT16
)&rTrack
, 2 );
897 /* track mouse while waiting for WM_LBUTTONUP */
899 NC_DrawSysButton( hwnd
, hdc
, bTrack
);
903 msg
.message
= WM_NULL
;
904 PeekMessage16( &msg
, 0, WM_MOUSEFIRST
, WM_MOUSELAST
, PM_REMOVE
);
905 if( msg
.message
== WM_MOUSEMOVE
)
907 if( (bNew
= PtInRect16(&rTrack
, MAKEPOINT16(msg
.lParam
))) )
908 { if( bTrack
) continue; }
910 { if(!bTrack
) continue; }
911 NC_DrawSysButton( hwnd
, hdc
, bTrack
= bNew
);
913 } while( msg
.message
!= WM_LBUTTONUP
);
916 ReleaseDC32(hwnd
, hdc
);
917 on
= PtInRect16(&rTrack
, MAKEPOINT16(msg
.lParam
));
921 SendMessage16( hwnd
, WM_SYSCOMMAND
,
922 SC_MOUSEMENU
+ HTSYSMENU
, *((LPARAM
*)&pt
));
927 /***********************************************************************
930 * Initialisation of a move or resize, when initiatied from a menu choice.
931 * Return hit test code for caption or sizing border.
933 static LONG
NC_StartSizeMove( HWND32 hwnd
, WPARAM16 wParam
,
934 POINT16
*capturePoint
)
939 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
941 if ((wParam
& 0xfff0) == SC_MOVE
)
943 /* Move pointer at the center of the caption */
945 NC_GetInsideRect( hwnd
, &rect
);
946 if (wndPtr
->dwStyle
& WS_SYSMENU
)
947 rect
.left
+= SYSMETRICS_CXSIZE
+ 1;
948 if (wndPtr
->dwStyle
& WS_MINIMIZEBOX
)
949 rect
.right
-= SYSMETRICS_CXSIZE
+ 1;
950 if (wndPtr
->dwStyle
& WS_MAXIMIZEBOX
)
951 rect
.right
-= SYSMETRICS_CXSIZE
+ 1;
952 pt
.x
= wndPtr
->rectWindow
.left
+ (rect
.right
- rect
.left
) / 2;
953 pt
.y
= wndPtr
->rectWindow
.top
+ rect
.top
+ SYSMETRICS_CYSIZE
/2;
954 if (wndPtr
->dwStyle
& WS_CHILD
)
955 ClientToScreen16( wndPtr
->parent
->hwndSelf
, &pt
);
963 MSG_InternalGetMessage( &msg
, 0, 0, MSGF_SIZE
, PM_REMOVE
, FALSE
);
967 hittest
= NC_HandleNCHitTest( hwnd
, msg
.pt
);
969 if ((hittest
< HTLEFT
) || (hittest
> HTBOTTOMRIGHT
))
981 pt
.x
=(wndPtr
->rectWindow
.left
+wndPtr
->rectWindow
.right
)/2;
982 pt
.y
= wndPtr
->rectWindow
.top
+ SYSMETRICS_CYFRAME
/ 2;
986 pt
.x
=(wndPtr
->rectWindow
.left
+wndPtr
->rectWindow
.right
)/2;
987 pt
.y
= wndPtr
->rectWindow
.bottom
- SYSMETRICS_CYFRAME
/ 2;
991 pt
.x
= wndPtr
->rectWindow
.left
+ SYSMETRICS_CXFRAME
/ 2;
992 pt
.y
=(wndPtr
->rectWindow
.top
+wndPtr
->rectWindow
.bottom
)/2;
996 pt
.x
= wndPtr
->rectWindow
.right
- SYSMETRICS_CXFRAME
/ 2;
997 pt
.y
=(wndPtr
->rectWindow
.top
+wndPtr
->rectWindow
.bottom
)/2;
1000 case VK_ESCAPE
: return 0;
1006 SetCursorPos32( capturePoint
->x
, capturePoint
->y
);
1007 NC_HandleSetCursor( hwnd
, (WPARAM16
)hwnd
, MAKELONG( hittest
, WM_MOUSEMOVE
));
1012 /***********************************************************************
1015 * Perform SC_MOVE and SC_SIZE commands.
1017 static void NC_DoSizeMove( HWND32 hwnd
, WORD wParam
, POINT16 pt
)
1020 RECT16 sizingRect
, mouseRect
;
1022 LONG hittest
= (LONG
)(wParam
& 0x0f);
1023 HCURSOR16 hDragCursor
= 0, hOldCursor
= 0;
1024 POINT16 minTrack
, maxTrack
, capturePoint
= pt
;
1025 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
1026 BOOL32 thickframe
= HAS_THICKFRAME( wndPtr
->dwStyle
);
1027 BOOL32 iconic
= wndPtr
->dwStyle
& WS_MINIMIZE
;
1030 if (IsZoomed32(hwnd
) || !IsWindowVisible32(hwnd
) ||
1031 (wndPtr
->flags
& WIN_MANAGED
)) return;
1033 if ((wParam
& 0xfff0) == SC_MOVE
)
1035 if (!(wndPtr
->dwStyle
& WS_CAPTION
)) return;
1036 if (!hittest
) hittest
= NC_StartSizeMove( hwnd
, wParam
, &capturePoint
);
1037 if (!hittest
) return;
1041 if (!thickframe
) return;
1042 if (hittest
) hittest
+= HTLEFT
-1;
1046 hittest
= NC_StartSizeMove( hwnd
, wParam
, &capturePoint
);
1055 /* Get min/max info */
1057 NC_GetMinMaxInfo( wndPtr
, NULL
, NULL
, &minTrack
, &maxTrack
);
1058 sizingRect
= wndPtr
->rectWindow
;
1059 if (wndPtr
->dwStyle
& WS_CHILD
)
1060 GetClientRect16( wndPtr
->parent
->hwndSelf
, &mouseRect
);
1061 else SetRect16(&mouseRect
, 0, 0, SYSMETRICS_CXSCREEN
, SYSMETRICS_CYSCREEN
);
1062 if (ON_LEFT_BORDER(hittest
))
1064 mouseRect
.left
= MAX( mouseRect
.left
, sizingRect
.right
-maxTrack
.x
);
1065 mouseRect
.right
= MIN( mouseRect
.right
, sizingRect
.right
-minTrack
.x
);
1067 else if (ON_RIGHT_BORDER(hittest
))
1069 mouseRect
.left
= MAX( mouseRect
.left
, sizingRect
.left
+minTrack
.x
);
1070 mouseRect
.right
= MIN( mouseRect
.right
, sizingRect
.left
+maxTrack
.x
);
1072 if (ON_TOP_BORDER(hittest
))
1074 mouseRect
.top
= MAX( mouseRect
.top
, sizingRect
.bottom
-maxTrack
.y
);
1075 mouseRect
.bottom
= MIN( mouseRect
.bottom
,sizingRect
.bottom
-minTrack
.y
);
1077 else if (ON_BOTTOM_BORDER(hittest
))
1079 mouseRect
.top
= MAX( mouseRect
.top
, sizingRect
.top
+minTrack
.y
);
1080 mouseRect
.bottom
= MIN( mouseRect
.bottom
, sizingRect
.top
+maxTrack
.y
);
1082 SendMessage16( hwnd
, WM_ENTERSIZEMOVE
, 0, 0 );
1084 if (GetCapture32() != hwnd
) SetCapture32( hwnd
);
1086 if (wndPtr
->dwStyle
& WS_CHILD
)
1088 /* Retrieve a default cache DC (without using the window style) */
1089 hdc
= GetDCEx32( wndPtr
->parent
->hwndSelf
, 0, DCX_CACHE
);
1092 { /* Grab the server only when moving top-level windows without desktop */
1094 if (rootWindow
== DefaultRootWindow(display
)) XGrabServer( display
);
1099 HICON16 hIcon
= (wndPtr
->class->hIcon
)
1100 ? wndPtr
->class->hIcon
1101 : (HICON16
)SendMessage16( hwnd
, WM_QUERYDRAGICON
, 0, 0L);
1104 hDragCursor
= CURSORICON_IconToCursor( hIcon
, TRUE
);
1105 hOldCursor
= SetCursor32(hDragCursor
);
1106 ShowCursor32( TRUE
);
1107 } else iconic
= FALSE
;
1110 if( !iconic
) NC_DrawMovingFrame( hdc
, &sizingRect
, thickframe
);
1116 MSG_InternalGetMessage( &msg
, 0, 0, MSGF_SIZE
, PM_REMOVE
, FALSE
);
1118 /* Exit on button-up, Return, or Esc */
1119 if ((msg
.message
== WM_LBUTTONUP
) ||
1120 ((msg
.message
== WM_KEYDOWN
) &&
1121 ((msg
.wParam
== VK_RETURN
) || (msg
.wParam
== VK_ESCAPE
)))) break;
1123 if ((msg
.message
!= WM_KEYDOWN
) && (msg
.message
!= WM_MOUSEMOVE
))
1124 continue; /* We are not interested in other messages */
1127 if (wndPtr
->dwStyle
& WS_CHILD
)
1128 ScreenToClient16( wndPtr
->parent
->hwndSelf
, &pt
);
1130 if (msg
.message
== WM_KEYDOWN
) switch(msg
.wParam
)
1132 case VK_UP
: pt
.y
-= 8; break;
1133 case VK_DOWN
: pt
.y
+= 8; break;
1134 case VK_LEFT
: pt
.x
-= 8; break;
1135 case VK_RIGHT
: pt
.x
+= 8; break;
1138 pt
.x
= MAX( pt
.x
, mouseRect
.left
);
1139 pt
.x
= MIN( pt
.x
, mouseRect
.right
);
1140 pt
.y
= MAX( pt
.y
, mouseRect
.top
);
1141 pt
.y
= MIN( pt
.y
, mouseRect
.bottom
);
1143 dx
= pt
.x
- capturePoint
.x
;
1144 dy
= pt
.y
- capturePoint
.y
;
1149 if (msg
.message
== WM_KEYDOWN
) SetCursorPos32( pt
.x
, pt
.y
);
1152 RECT16 newRect
= sizingRect
;
1154 if (hittest
== HTCAPTION
) OffsetRect16( &newRect
, dx
, dy
);
1155 if (ON_LEFT_BORDER(hittest
)) newRect
.left
+= dx
;
1156 else if (ON_RIGHT_BORDER(hittest
)) newRect
.right
+= dx
;
1157 if (ON_TOP_BORDER(hittest
)) newRect
.top
+= dy
;
1158 else if (ON_BOTTOM_BORDER(hittest
)) newRect
.bottom
+= dy
;
1161 NC_DrawMovingFrame( hdc
, &sizingRect
, thickframe
);
1162 NC_DrawMovingFrame( hdc
, &newRect
, thickframe
);
1165 sizingRect
= newRect
;
1173 ShowCursor32( FALSE
);
1174 SetCursor32(hOldCursor
);
1175 if( hDragCursor
) DestroyCursor32( hDragCursor
);
1178 NC_DrawMovingFrame( hdc
, &sizingRect
, thickframe
);
1180 if (wndPtr
->dwStyle
& WS_CHILD
)
1181 ReleaseDC32( wndPtr
->parent
->hwndSelf
, hdc
);
1184 ReleaseDC32( 0, hdc
);
1185 if (rootWindow
== DefaultRootWindow(display
)) XUngrabServer( display
);
1188 if (HOOK_IsHooked( WH_CBT
))
1190 RECT16
* pr
= SEGPTR_NEW(RECT16
);
1194 if( HOOK_CallHooks16( WH_CBT
, HCBT_MOVESIZE
, hwnd
,
1195 (LPARAM
)SEGPTR_GET(pr
)) )
1196 sizingRect
= wndPtr
->rectWindow
;
1202 SendMessage16( hwnd
, WM_EXITSIZEMOVE
, 0, 0 );
1203 SendMessage16( hwnd
, WM_SETVISIBLE
, !IsIconic16(hwnd
), 0L);
1205 /* Single click brings up the system menu when iconized */
1207 if (!moved
&& (wndPtr
->dwStyle
& WS_MINIMIZE
))
1209 NC_TrackSysMenu( hwnd
, pt
);
1213 /* If Esc key, don't move the window */
1214 if ((msg
.message
== WM_KEYDOWN
) && (msg
.wParam
== VK_ESCAPE
)) return;
1216 if (hittest
!= HTCAPTION
)
1217 SetWindowPos32( hwnd
, 0, sizingRect
.left
, sizingRect
.top
,
1218 sizingRect
.right
- sizingRect
.left
,
1219 sizingRect
.bottom
- sizingRect
.top
,
1220 SWP_NOACTIVATE
| SWP_NOZORDER
);
1221 else SetWindowPos32( hwnd
, 0, sizingRect
.left
, sizingRect
.top
, 0, 0,
1222 SWP_NOACTIVATE
| SWP_NOSIZE
| SWP_NOZORDER
);
1226 /***********************************************************************
1229 * Track a mouse button press on the minimize or maximize box.
1231 static void NC_TrackMinMaxBox( HWND32 hwnd
, WORD wParam
)
1234 HDC32 hdc
= GetWindowDC32( hwnd
);
1235 BOOL32 pressed
= TRUE
;
1237 SetCapture32( hwnd
);
1238 if (wParam
== HTMINBUTTON
) NC_DrawMinButton( hwnd
, hdc
, TRUE
);
1239 else NC_DrawMaxButton( hwnd
, hdc
, TRUE
);
1243 BOOL32 oldstate
= pressed
;
1244 MSG_InternalGetMessage( &msg
, 0, 0, 0, PM_REMOVE
, FALSE
);
1246 pressed
= (NC_HandleNCHitTest( hwnd
, msg
.pt
) == wParam
);
1247 if (pressed
!= oldstate
)
1249 if (wParam
== HTMINBUTTON
) NC_DrawMinButton( hwnd
, hdc
, pressed
);
1250 else NC_DrawMaxButton( hwnd
, hdc
, pressed
);
1252 } while (msg
.message
!= WM_LBUTTONUP
);
1254 if (wParam
== HTMINBUTTON
) NC_DrawMinButton( hwnd
, hdc
, FALSE
);
1255 else NC_DrawMaxButton( hwnd
, hdc
, FALSE
);
1258 ReleaseDC32( hwnd
, hdc
);
1259 if (!pressed
) return;
1261 if (wParam
== HTMINBUTTON
)
1262 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MINIMIZE
, *(LONG
*)&msg
.pt
);
1264 SendMessage16( hwnd
, WM_SYSCOMMAND
,
1265 IsZoomed32(hwnd
) ? SC_RESTORE
:SC_MAXIMIZE
, *(LONG
*)&msg
.pt
);
1269 /***********************************************************************
1272 * Track a mouse button press on the horizontal or vertical scroll-bar.
1274 static void NC_TrackScrollBar( HWND32 hwnd
, WPARAM32 wParam
, POINT32 pt
)
1278 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1280 if ((wParam
& 0xfff0) == SC_HSCROLL
)
1282 if ((wParam
& 0x0f) != HTHSCROLL
) return;
1283 scrollbar
= SB_HORZ
;
1285 else /* SC_VSCROLL */
1287 if ((wParam
& 0x0f) != HTVSCROLL
) return;
1288 scrollbar
= SB_VERT
;
1291 if (!(msg
= SEGPTR_NEW(MSG16
))) return;
1292 pt
.x
-= wndPtr
->rectWindow
.left
;
1293 pt
.y
-= wndPtr
->rectWindow
.top
;
1294 SetCapture32( hwnd
);
1295 SCROLL_HandleScrollEvent( hwnd
, scrollbar
, WM_LBUTTONDOWN
, pt
);
1299 GetMessage16( SEGPTR_GET(msg
), 0, 0, 0 );
1300 switch(msg
->message
)
1305 pt
.x
= LOWORD(msg
->lParam
) + wndPtr
->rectClient
.left
-
1306 wndPtr
->rectWindow
.left
;
1307 pt
.y
= HIWORD(msg
->lParam
) + wndPtr
->rectClient
.top
-
1308 wndPtr
->rectWindow
.top
;
1309 SCROLL_HandleScrollEvent( hwnd
, scrollbar
, msg
->message
, pt
);
1312 TranslateMessage16( msg
);
1313 DispatchMessage16( msg
);
1316 if (!IsWindow32( hwnd
))
1321 } while (msg
->message
!= WM_LBUTTONUP
);
1325 /***********************************************************************
1326 * NC_HandleNCLButtonDown
1328 * Handle a WM_NCLBUTTONDOWN message. Called from DefWindowProc().
1330 LONG
NC_HandleNCLButtonDown( HWND32 hwnd
, WPARAM16 wParam
, LPARAM lParam
)
1332 switch(wParam
) /* Hit test */
1335 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MOVE
+ HTCAPTION
, lParam
);
1339 NC_TrackSysMenu( hwnd
, MAKEPOINT16(lParam
) );
1343 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MOUSEMENU
, lParam
);
1347 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_HSCROLL
+ HTHSCROLL
, lParam
);
1351 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_VSCROLL
+ HTVSCROLL
, lParam
);
1356 NC_TrackMinMaxBox( hwnd
, wParam
);
1367 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_SIZE
+ wParam
- HTLEFT
+1, lParam
);
1377 /***********************************************************************
1378 * NC_HandleNCLButtonDblClk
1380 * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc().
1382 LONG
NC_HandleNCLButtonDblClk( WND
*pWnd
, WPARAM16 wParam
, LPARAM lParam
)
1385 * if this is an icon, send a restore since we are handling
1388 if (pWnd
->dwStyle
& WS_MINIMIZE
)
1390 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_RESTORE
, lParam
);
1394 switch(wParam
) /* Hit test */
1397 /* stop processing if WS_MAXIMIZEBOX is missing */
1398 if (pWnd
->dwStyle
& WS_MAXIMIZEBOX
)
1399 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
,
1400 (pWnd
->dwStyle
& WS_MAXIMIZE
) ? SC_RESTORE
: SC_MAXIMIZE
,
1405 if (!(pWnd
->class->style
& CS_NOCLOSE
))
1406 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_CLOSE
, lParam
);
1413 /***********************************************************************
1414 * NC_HandleSysCommand
1416 * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
1418 LONG
NC_HandleSysCommand( HWND32 hwnd
, WPARAM16 wParam
, POINT16 pt
)
1420 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1423 dprintf_nonclient(stddeb
, "Handling WM_SYSCOMMAND %x %d,%d\n",
1424 wParam
, pt
.x
, pt
.y
);
1426 if (wndPtr
->dwStyle
& WS_CHILD
&& wParam
!= SC_KEYMENU
)
1427 ScreenToClient16( wndPtr
->parent
->hwndSelf
, &pt
);
1429 switch (wParam
& 0xfff0)
1433 NC_DoSizeMove( hwnd
, wParam
, pt
);
1437 ShowWindow32( hwnd
, SW_MINIMIZE
);
1441 ShowWindow32( hwnd
, SW_MAXIMIZE
);
1445 ShowWindow32( hwnd
, SW_RESTORE
);
1449 return SendMessage16( hwnd
, WM_CLOSE
, 0, 0 );
1453 CONV_POINT16TO32( &pt
, &pt32
);
1454 NC_TrackScrollBar( hwnd
, wParam
, pt32
);
1458 CONV_POINT16TO32( &pt
, &pt32
);
1459 MENU_TrackMouseMenuBar( wndPtr
, wParam
& 0x000F, pt32
);
1463 MENU_TrackKbdMenuBar( wndPtr
, wParam
, pt
.x
);
1467 WinExec32( "taskman.exe", SW_SHOWNORMAL
);
1471 if (wParam
== SC_ABOUTWINE
)
1473 extern const char people
[];
1474 ShellAbout32A(hwnd
,"Wine",people
,0);
1482 /* FIXME: unimplemented */