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
, BOOL menu
, DWORD exStyle
)
69 if(style
& WS_ICONIC
) return;
70 /* Decide if the window will be managed (see CreateWindowEx) */
71 if (!(Options
.managed
&& !(style
& WS_CHILD
) &&
72 ((style
& (WS_DLGFRAME
| WS_THICKFRAME
)) ||
73 (exStyle
& WS_EX_DLGMODALFRAME
))))
75 if (HAS_DLGFRAME( style
, exStyle
))
76 InflateRect16(rect
, SYSMETRICS_CXDLGFRAME
, SYSMETRICS_CYDLGFRAME
);
79 if (HAS_THICKFRAME(style
))
80 InflateRect16( rect
, SYSMETRICS_CXFRAME
, SYSMETRICS_CYFRAME
);
81 if (style
& WS_BORDER
)
82 InflateRect16( rect
, SYSMETRICS_CXBORDER
, SYSMETRICS_CYBORDER
);
85 if ((style
& WS_CAPTION
) == WS_CAPTION
)
86 rect
->top
-= SYSMETRICS_CYCAPTION
- SYSMETRICS_CYBORDER
;
88 if (menu
) rect
->top
-= SYSMETRICS_CYMENU
+ SYSMETRICS_CYBORDER
;
90 if (style
& WS_VSCROLL
) rect
->right
+= SYSMETRICS_CXVSCROLL
;
91 if (style
& WS_HSCROLL
) rect
->bottom
+= SYSMETRICS_CYHSCROLL
;
95 /***********************************************************************
96 * AdjustWindowRect16 (USER.102)
98 BOOL16
AdjustWindowRect16( LPRECT16 rect
, DWORD style
, BOOL16 menu
)
100 return AdjustWindowRectEx16( rect
, style
, menu
, 0 );
104 /***********************************************************************
105 * AdjustWindowRect32 (USER32.)
107 BOOL32
AdjustWindowRect32( LPRECT32 rect
, DWORD style
, BOOL32 menu
)
109 return AdjustWindowRectEx32( rect
, style
, menu
, 0 );
113 /***********************************************************************
114 * AdjustWindowRectEx16 (USER.454)
116 BOOL16
AdjustWindowRectEx16( LPRECT16 rect
, DWORD style
,
117 BOOL16 menu
, DWORD exStyle
)
119 /* Correct the window style */
121 if (!(style
& (WS_POPUP
| WS_CHILD
))) /* Overlapped window */
123 style
&= (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
);
124 exStyle
&= WS_EX_DLGMODALFRAME
;
125 if (exStyle
& WS_EX_DLGMODALFRAME
) style
&= ~WS_THICKFRAME
;
127 dprintf_nonclient(stddeb
, "AdjustWindowRectEx: (%d,%d)-(%d,%d) %08lx %d %08lx\n",
128 rect
->left
, rect
->top
, rect
->right
, rect
->bottom
,
129 style
, menu
, exStyle
);
131 NC_AdjustRect( rect
, style
, menu
, exStyle
);
136 /***********************************************************************
137 * AdjustWindowRectEx32 (USER32.)
139 BOOL32
AdjustWindowRectEx32( LPRECT32 rect
, DWORD style
,
140 BOOL32 menu
, DWORD exStyle
)
145 CONV_RECT32TO16( rect
, &rect16
);
146 ret
= AdjustWindowRectEx16( &rect16
, style
, (BOOL16
)menu
, exStyle
);
147 CONV_RECT16TO32( &rect16
, rect
);
152 /*******************************************************************
155 * Get the minimized and maximized information for a window.
157 void NC_GetMinMaxInfo( WND
*wndPtr
, POINT16
*maxSize
, POINT16
*maxPos
,
158 POINT16
*minTrack
, POINT16
*maxTrack
)
160 MINMAXINFO16
*MinMax
;
163 if (!(MinMax
= SEGPTR_NEW(MINMAXINFO16
))) return;
165 /* Compute default values */
167 MinMax
->ptMaxSize
.x
= SYSMETRICS_CXSCREEN
;
168 MinMax
->ptMaxSize
.y
= SYSMETRICS_CYSCREEN
;
169 MinMax
->ptMinTrackSize
.x
= SYSMETRICS_CXMINTRACK
;
170 MinMax
->ptMinTrackSize
.y
= SYSMETRICS_CYMINTRACK
;
171 MinMax
->ptMaxTrackSize
.x
= SYSMETRICS_CXSCREEN
;
172 MinMax
->ptMaxTrackSize
.y
= SYSMETRICS_CYSCREEN
;
174 if (wndPtr
->flags
& WIN_MANAGED
) xinc
= yinc
= 0;
175 else if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
177 xinc
= SYSMETRICS_CXDLGFRAME
;
178 yinc
= SYSMETRICS_CYDLGFRAME
;
183 if (HAS_THICKFRAME(wndPtr
->dwStyle
))
185 xinc
+= SYSMETRICS_CXFRAME
;
186 yinc
+= SYSMETRICS_CYFRAME
;
188 if (wndPtr
->dwStyle
& WS_BORDER
)
190 xinc
+= SYSMETRICS_CXBORDER
;
191 yinc
+= SYSMETRICS_CYBORDER
;
194 MinMax
->ptMaxSize
.x
+= 2 * xinc
;
195 MinMax
->ptMaxSize
.y
+= 2 * yinc
;
197 /* Note: The '+' in the following test should really be a ||, but
198 * that would cause gcc-2.7.0 to generate incorrect code.
200 if ((wndPtr
->ptMaxPos
.x
!= -1) + (wndPtr
->ptMaxPos
.y
!= -1))
201 MinMax
->ptMaxPosition
= wndPtr
->ptMaxPos
;
204 MinMax
->ptMaxPosition
.x
= -xinc
;
205 MinMax
->ptMaxPosition
.y
= -yinc
;
208 SendMessage16( wndPtr
->hwndSelf
, WM_GETMINMAXINFO
, 0,
209 (LPARAM
)SEGPTR_GET(MinMax
) );
211 /* Some sanity checks */
213 dprintf_nonclient(stddeb
,
214 "NC_GetMinMaxInfo: %d %d / %d %d / %d %d / %d %d\n",
215 MinMax
->ptMaxSize
.x
, MinMax
->ptMaxSize
.y
,
216 MinMax
->ptMaxPosition
.x
, MinMax
->ptMaxPosition
.y
,
217 MinMax
->ptMaxTrackSize
.x
, MinMax
->ptMaxTrackSize
.y
,
218 MinMax
->ptMinTrackSize
.x
, MinMax
->ptMinTrackSize
.y
);
219 MinMax
->ptMaxTrackSize
.x
= MAX( MinMax
->ptMaxTrackSize
.x
,
220 MinMax
->ptMinTrackSize
.x
);
221 MinMax
->ptMaxTrackSize
.y
= MAX( MinMax
->ptMaxTrackSize
.y
,
222 MinMax
->ptMinTrackSize
.y
);
224 if (maxSize
) *maxSize
= MinMax
->ptMaxSize
;
225 if (maxPos
) *maxPos
= MinMax
->ptMaxPosition
;
226 if (minTrack
) *minTrack
= MinMax
->ptMinTrackSize
;
227 if (maxTrack
) *maxTrack
= MinMax
->ptMaxTrackSize
;
232 /***********************************************************************
233 * NC_HandleNCCalcSize
235 * Handle a WM_NCCALCSIZE message. Called from DefWindowProc().
237 LONG
NC_HandleNCCalcSize( WND
*pWnd
, RECT16
*winRect
)
239 RECT16 tmpRect
= { 0, 0, 0, 0 };
242 if (pWnd
->class->style
& CS_VREDRAW
) result
|= WVR_VREDRAW
;
243 if (pWnd
->class->style
& CS_HREDRAW
) result
|= WVR_HREDRAW
;
245 if( !( pWnd
->dwStyle
& WS_MINIMIZE
) )
247 NC_AdjustRect( &tmpRect
, pWnd
->dwStyle
, FALSE
, pWnd
->dwExStyle
);
248 winRect
->left
-= tmpRect
.left
;
249 winRect
->top
-= tmpRect
.top
;
250 winRect
->right
-= tmpRect
.right
;
251 winRect
->bottom
-= tmpRect
.bottom
;
255 winRect
->top
+= MENU_GetMenuBarHeight( pWnd
->hwndSelf
,
256 winRect
->right
- winRect
->left
,
257 -tmpRect
.left
, -tmpRect
.top
) + 1;
264 /***********************************************************************
267 * Get the 'inside' rectangle of a window, i.e. the whole window rectangle
268 * but without the borders (if any).
269 * The rectangle is in window coordinates (for drawing with GetWindowDC()).
271 static void NC_GetInsideRect( HWND32 hwnd
, RECT32
*rect
)
273 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
275 rect
->top
= rect
->left
= 0;
276 rect
->right
= wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
;
277 rect
->bottom
= wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
;
279 if (wndPtr
->dwStyle
& WS_ICONIC
) return; /* No border to remove */
280 if (wndPtr
->flags
& WIN_MANAGED
) return;
282 /* Remove frame from rectangle */
283 if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
285 InflateRect32( rect
, -SYSMETRICS_CXDLGFRAME
, -SYSMETRICS_CYDLGFRAME
);
286 if (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
)
287 InflateRect32( rect
, -1, 0 );
291 if (HAS_THICKFRAME( wndPtr
->dwStyle
))
292 InflateRect32( rect
, -SYSMETRICS_CXFRAME
, -SYSMETRICS_CYFRAME
);
293 if (wndPtr
->dwStyle
& WS_BORDER
)
294 InflateRect32( rect
, -SYSMETRICS_CXBORDER
, -SYSMETRICS_CYBORDER
);
299 /***********************************************************************
302 * Handle a WM_NCHITTEST message. Called from DefWindowProc().
304 LONG
NC_HandleNCHitTest( HWND32 hwnd
, POINT16 pt
)
307 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
308 if (!wndPtr
) return HTERROR
;
310 dprintf_nonclient(stddeb
, "NC_HandleNCHitTest: hwnd=%04x pt=%d,%d\n",
313 GetWindowRect16( hwnd
, &rect
);
314 if (!PtInRect16( &rect
, pt
)) return HTNOWHERE
;
316 if (wndPtr
->dwStyle
& WS_MINIMIZE
) return HTCAPTION
;
318 if (!(wndPtr
->flags
& WIN_MANAGED
))
321 if (HAS_THICKFRAME( wndPtr
->dwStyle
))
323 InflateRect16( &rect
, -SYSMETRICS_CXFRAME
, -SYSMETRICS_CYFRAME
);
324 if (wndPtr
->dwStyle
& WS_BORDER
)
325 InflateRect16(&rect
,-SYSMETRICS_CXBORDER
,-SYSMETRICS_CYBORDER
);
326 if (!PtInRect16( &rect
, pt
))
328 /* Check top sizing border */
331 if (pt
.x
< rect
.left
+SYSMETRICS_CXSIZE
) return HTTOPLEFT
;
332 if (pt
.x
>= rect
.right
-SYSMETRICS_CXSIZE
) return HTTOPRIGHT
;
335 /* Check bottom sizing border */
336 if (pt
.y
>= rect
.bottom
)
338 if (pt
.x
< rect
.left
+SYSMETRICS_CXSIZE
) return HTBOTTOMLEFT
;
339 if (pt
.x
>= rect
.right
-SYSMETRICS_CXSIZE
) return HTBOTTOMRIGHT
;
342 /* Check left sizing border */
343 if (pt
.x
< rect
.left
)
345 if (pt
.y
< rect
.top
+SYSMETRICS_CYSIZE
) return HTTOPLEFT
;
346 if (pt
.y
>= rect
.bottom
-SYSMETRICS_CYSIZE
) return HTBOTTOMLEFT
;
349 /* Check right sizing border */
350 if (pt
.x
>= rect
.right
)
352 if (pt
.y
< rect
.top
+SYSMETRICS_CYSIZE
) return HTTOPRIGHT
;
353 if (pt
.y
>= rect
.bottom
-SYSMETRICS_CYSIZE
) return HTBOTTOMRIGHT
;
358 else /* No thick frame */
360 if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
361 InflateRect16(&rect
, -SYSMETRICS_CXDLGFRAME
, -SYSMETRICS_CYDLGFRAME
);
362 else if (wndPtr
->dwStyle
& WS_BORDER
)
363 InflateRect16(&rect
, -SYSMETRICS_CXBORDER
, -SYSMETRICS_CYBORDER
);
364 if (!PtInRect16( &rect
, pt
)) return HTBORDER
;
369 if ((wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
371 rect
.top
+= SYSMETRICS_CYCAPTION
- 1;
372 if (!PtInRect16( &rect
, pt
))
374 /* Check system menu */
375 if (wndPtr
->dwStyle
& WS_SYSMENU
)
376 rect
.left
+= SYSMETRICS_CXSIZE
;
377 if (pt
.x
<= rect
.left
) return HTSYSMENU
;
378 /* Check maximize box */
379 if (wndPtr
->dwStyle
& WS_MAXIMIZEBOX
)
380 rect
.right
-= SYSMETRICS_CXSIZE
+ 1;
381 if (pt
.x
>= rect
.right
) return HTMAXBUTTON
;
382 /* Check minimize box */
383 if (wndPtr
->dwStyle
& WS_MINIMIZEBOX
)
384 rect
.right
-= SYSMETRICS_CXSIZE
+ 1;
385 if (pt
.x
>= rect
.right
) return HTMINBUTTON
;
391 /* Check client area */
393 ScreenToClient16( hwnd
, &pt
);
394 GetClientRect16( hwnd
, &rect
);
395 if (PtInRect16( &rect
, pt
)) return HTCLIENT
;
397 /* Check vertical scroll bar */
399 if (wndPtr
->dwStyle
& WS_VSCROLL
)
401 rect
.right
+= SYSMETRICS_CXVSCROLL
;
402 if (PtInRect16( &rect
, pt
)) return HTVSCROLL
;
405 /* Check horizontal scroll bar */
407 if (wndPtr
->dwStyle
& WS_HSCROLL
)
409 rect
.bottom
+= SYSMETRICS_CYHSCROLL
;
410 if (PtInRect16( &rect
, pt
))
413 if ((wndPtr
->dwStyle
& WS_VSCROLL
) &&
414 (pt
.x
>= rect
.right
- SYSMETRICS_CXVSCROLL
))
422 if (HAS_MENU(wndPtr
))
424 if ((pt
.y
< 0) && (pt
.x
>= 0) && (pt
.x
< rect
.right
))
428 /* Should never get here */
433 /***********************************************************************
436 void NC_DrawSysButton( HWND32 hwnd
, HDC32 hdc
, BOOL32 down
)
441 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
443 if( !(wndPtr
->flags
& WIN_MANAGED
) )
445 NC_GetInsideRect( hwnd
, &rect
);
446 hdcMem
= CreateCompatibleDC32( hdc
);
447 hbitmap
= SelectObject32( hdcMem
, hbitmapClose
);
448 BitBlt32(hdc
, rect
.left
, rect
.top
, SYSMETRICS_CXSIZE
, SYSMETRICS_CYSIZE
,
449 hdcMem
, (wndPtr
->dwStyle
& WS_CHILD
) ? SYSMETRICS_CXSIZE
: 0, 0,
450 down
? NOTSRCCOPY
: SRCCOPY
);
451 SelectObject32( hdcMem
, hbitmap
);
452 DeleteDC32( hdcMem
);
457 /***********************************************************************
460 static void NC_DrawMaxButton( HWND32 hwnd
, HDC16 hdc
, BOOL down
)
463 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
465 if( !(wndPtr
->flags
& WIN_MANAGED
) )
467 NC_GetInsideRect( hwnd
, &rect
);
468 GRAPH_DrawBitmap( hdc
, (IsZoomed32(hwnd
) ?
469 (down
? hbitmapRestoreD
: hbitmapRestore
) :
470 (down
? hbitmapMaximizeD
: hbitmapMaximize
)),
471 rect
.right
- SYSMETRICS_CXSIZE
- 1, rect
.top
,
472 0, 0, SYSMETRICS_CXSIZE
+1, SYSMETRICS_CYSIZE
);
477 /***********************************************************************
480 static void NC_DrawMinButton( HWND32 hwnd
, HDC16 hdc
, BOOL down
)
483 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
485 if( !(wndPtr
->flags
& WIN_MANAGED
) )
487 NC_GetInsideRect( hwnd
, &rect
);
488 if (wndPtr
->dwStyle
& WS_MAXIMIZEBOX
) rect
.right
-= SYSMETRICS_CXSIZE
+1;
489 GRAPH_DrawBitmap( hdc
, (down
? hbitmapMinimizeD
: hbitmapMinimize
),
490 rect
.right
- SYSMETRICS_CXSIZE
- 1, rect
.top
,
491 0, 0, SYSMETRICS_CXSIZE
+1, SYSMETRICS_CYSIZE
);
496 /***********************************************************************
499 * Draw a window frame inside the given rectangle, and update the rectangle.
500 * The correct pen for the frame must be selected in the DC.
502 static void NC_DrawFrame( HDC16 hdc
, RECT16
*rect
, BOOL dlgFrame
, BOOL active
)
504 short width
, height
, tmp
;
508 width
= SYSMETRICS_CXDLGFRAME
- 1;
509 height
= SYSMETRICS_CYDLGFRAME
- 1;
510 SelectObject32( hdc
, active
? sysColorObjects
.hbrushActiveCaption
:
511 sysColorObjects
.hbrushInactiveCaption
);
515 width
= SYSMETRICS_CXFRAME
- 1;
516 height
= SYSMETRICS_CYFRAME
- 1;
517 SelectObject32( hdc
, active
? sysColorObjects
.hbrushActiveBorder
:
518 sysColorObjects
.hbrushInactiveBorder
);
522 PatBlt32( hdc
, rect
->left
, rect
->top
,
523 rect
->right
- rect
->left
, height
, PATCOPY
);
524 PatBlt32( hdc
, rect
->left
, rect
->top
,
525 width
, rect
->bottom
- rect
->top
, PATCOPY
);
526 PatBlt32( hdc
, rect
->left
, rect
->bottom
,
527 rect
->right
- rect
->left
, -height
, PATCOPY
);
528 PatBlt32( hdc
, rect
->right
, rect
->top
,
529 -width
, rect
->bottom
- rect
->top
, PATCOPY
);
533 InflateRect16( rect
, -width
, -height
);
537 /* Draw inner rectangle */
538 MoveTo( hdc
, rect
->left
+width
, rect
->top
+height
);
539 LineTo32( hdc
, rect
->right
-width
-1, rect
->top
+height
);
540 LineTo32( hdc
, rect
->right
-width
-1, rect
->bottom
-height
-1 );
541 LineTo32( hdc
, rect
->left
+width
, rect
->bottom
-height
-1 );
542 LineTo32( hdc
, rect
->left
+width
, rect
->top
+height
);
544 /* Draw the decorations */
545 tmp
= rect
->top
+ SYSMETRICS_CYFRAME
+ SYSMETRICS_CYSIZE
;
546 MoveTo( hdc
, rect
->left
, tmp
);
547 LineTo32( hdc
, rect
->left
+width
, tmp
);
548 MoveTo( hdc
, rect
->right
-width
-1, tmp
);
549 LineTo32( hdc
, rect
->right
-1, tmp
);
551 tmp
= rect
->bottom
- 1 - SYSMETRICS_CYFRAME
- SYSMETRICS_CYSIZE
;
552 MoveTo( hdc
, rect
->left
, tmp
);
553 LineTo32( hdc
, rect
->left
+width
, tmp
);
554 MoveTo( hdc
, rect
->right
-width
-1, tmp
);
555 LineTo32( hdc
, rect
->right
-1, tmp
);
557 tmp
= rect
->left
+ SYSMETRICS_CXFRAME
+ SYSMETRICS_CXSIZE
;
558 MoveTo( hdc
, tmp
, rect
->top
);
559 LineTo32( hdc
, tmp
, rect
->top
+height
);
560 MoveTo( hdc
, tmp
, rect
->bottom
-height
-1 );
561 LineTo32( hdc
, tmp
, rect
->bottom
-1 );
563 tmp
= rect
->right
- 1 - SYSMETRICS_CXFRAME
- SYSMETRICS_CYSIZE
;
564 MoveTo( hdc
, tmp
, rect
->top
);
565 LineTo32( hdc
, tmp
, rect
->top
+height
);
566 MoveTo( hdc
, tmp
, rect
->bottom
-height
-1 );
567 LineTo32( hdc
, tmp
, rect
->bottom
-1 );
569 InflateRect16( rect
, -width
-1, -height
-1 );
573 /***********************************************************************
576 * Draw the frame used when moving or resizing window.
578 static void NC_DrawMovingFrame( HDC16 hdc
, RECT16
*rect
, BOOL thickframe
)
580 if (thickframe
) FastWindowFrame( hdc
, rect
, SYSMETRICS_CXFRAME
,
581 SYSMETRICS_CYFRAME
, PATINVERT
);
582 else DrawFocusRect16( hdc
, rect
);
586 /***********************************************************************
589 * Draw the window caption.
590 * The correct pen for the window frame must be selected in the DC.
592 static void NC_DrawCaption( HDC16 hdc
, RECT16
*rect
, HWND32 hwnd
,
593 DWORD style
, BOOL active
)
596 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
599 if (wndPtr
->flags
& WIN_MANAGED
) return;
603 if (!(hbitmapClose
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_CLOSE
) )))
605 hbitmapMinimize
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_REDUCE
) );
606 hbitmapMinimizeD
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_REDUCED
) );
607 hbitmapMaximize
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_ZOOM
) );
608 hbitmapMaximizeD
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_ZOOMD
) );
609 hbitmapRestore
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_RESTORE
) );
610 hbitmapRestoreD
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_RESTORED
) );
613 if (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
)
615 HBRUSH32 hbrushOld
= SelectObject32(hdc
, sysColorObjects
.hbrushWindow
);
616 PatBlt32( hdc
, r
.left
, r
.top
, 1, r
.bottom
-r
.top
+1,PATCOPY
);
617 PatBlt32( hdc
, r
.right
-1, r
.top
, 1, r
.bottom
-r
.top
+1, PATCOPY
);
618 PatBlt32( hdc
, r
.left
, r
.top
-1, r
.right
-r
.left
, 1, PATCOPY
);
621 SelectObject32( hdc
, hbrushOld
);
624 MoveTo( hdc
, r
.left
, r
.bottom
);
625 LineTo32( hdc
, r
.right
-1, r
.bottom
);
627 if (style
& WS_SYSMENU
)
629 NC_DrawSysButton( hwnd
, hdc
, FALSE
);
630 r
.left
+= SYSMETRICS_CXSIZE
+ 1;
631 MoveTo( hdc
, r
.left
- 1, r
.top
);
632 LineTo32( hdc
, r
.left
- 1, r
.bottom
);
634 if (style
& WS_MAXIMIZEBOX
)
636 NC_DrawMaxButton( hwnd
, hdc
, FALSE
);
637 r
.right
-= SYSMETRICS_CXSIZE
+ 1;
639 if (style
& WS_MINIMIZEBOX
)
641 NC_DrawMinButton( hwnd
, hdc
, FALSE
);
642 r
.right
-= SYSMETRICS_CXSIZE
+ 1;
645 FillRect16( hdc
, &r
, active
? sysColorObjects
.hbrushActiveCaption
:
646 sysColorObjects
.hbrushInactiveCaption
);
648 if (GetWindowText32A( hwnd
, buffer
, sizeof(buffer
) ))
650 if (active
) SetTextColor( hdc
, GetSysColor32( COLOR_CAPTIONTEXT
) );
651 else SetTextColor( hdc
, GetSysColor32( COLOR_INACTIVECAPTIONTEXT
) );
652 SetBkMode32( hdc
, TRANSPARENT
);
653 DrawText16( hdc
, buffer
, -1, &r
,
654 DT_SINGLELINE
| DT_CENTER
| DT_VCENTER
| DT_NOPREFIX
);
659 /***********************************************************************
662 * Paint the non-client area. clip is currently unused.
664 void NC_DoNCPaint( HWND32 hwnd
, HRGN32 clip
, BOOL32 suppress_menupaint
)
670 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
672 if (!wndPtr
|| wndPtr
->dwStyle
& WS_MINIMIZE
||
673 !WIN_IsWindowDrawable( wndPtr
, 0 )) return; /* Nothing to do */
675 active
= wndPtr
->flags
& WIN_NCACTIVATED
;
677 dprintf_nonclient(stddeb
, "NC_DoNCPaint: %04x %d\n", hwnd
, active
);
679 if (!(hdc
= GetDCEx32( hwnd
, 0, DCX_USESTYLE
| DCX_WINDOW
))) return;
681 if (ExcludeVisRect( hdc
, wndPtr
->rectClient
.left
-wndPtr
->rectWindow
.left
,
682 wndPtr
->rectClient
.top
-wndPtr
->rectWindow
.top
,
683 wndPtr
->rectClient
.right
-wndPtr
->rectWindow
.left
,
684 wndPtr
->rectClient
.bottom
-wndPtr
->rectWindow
.top
)
687 ReleaseDC32( hwnd
, hdc
);
691 rect
.top
= rect
.left
= 0;
692 rect
.right
= wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
;
693 rect
.bottom
= wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
;
695 SelectObject32( hdc
, sysColorObjects
.hpenWindowFrame
);
697 if (!(wndPtr
->flags
& WIN_MANAGED
))
699 if ((wndPtr
->dwStyle
& WS_BORDER
) || (wndPtr
->dwStyle
& WS_DLGFRAME
) ||
700 (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
))
703 LineTo32( hdc
, rect
.right
-1, 0 );
704 LineTo32( hdc
, rect
.right
-1, rect
.bottom
-1 );
705 LineTo32( hdc
, 0, rect
.bottom
-1 );
706 LineTo32( hdc
, 0, 0 );
707 InflateRect16( &rect
, -1, -1 );
710 if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
711 NC_DrawFrame( hdc
, &rect
, TRUE
, active
);
712 else if (wndPtr
->dwStyle
& WS_THICKFRAME
)
713 NC_DrawFrame(hdc
, &rect
, FALSE
, active
);
715 if ((wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
718 r
.bottom
= rect
.top
+ SYSMETRICS_CYSIZE
;
719 rect
.top
+= SYSMETRICS_CYSIZE
+ SYSMETRICS_CYBORDER
;
720 NC_DrawCaption( hdc
, &r
, hwnd
, wndPtr
->dwStyle
, active
);
724 if (HAS_MENU(wndPtr
))
727 CONV_RECT16TO32( &rect
, &r
);
728 r
.bottom
= rect
.top
+ SYSMETRICS_CYMENU
; /* default height */
729 rect
.top
+= MENU_DrawMenuBar( hdc
, &r
, hwnd
, suppress_menupaint
);
732 /* Draw the scroll-bars */
734 if (wndPtr
->dwStyle
& WS_VSCROLL
)
735 SCROLL_DrawScrollBar( hwnd
, hdc
, SB_VERT
, TRUE
);
736 if (wndPtr
->dwStyle
& WS_HSCROLL
)
737 SCROLL_DrawScrollBar( hwnd
, hdc
, SB_HORZ
, TRUE
);
739 /* Draw the "size-box" */
741 if ((wndPtr
->dwStyle
& WS_VSCROLL
) && (wndPtr
->dwStyle
& WS_HSCROLL
))
744 r
.left
= r
.right
- SYSMETRICS_CXVSCROLL
+ 1;
745 r
.top
= r
.bottom
- SYSMETRICS_CYHSCROLL
+ 1;
746 FillRect16( hdc
, &r
, sysColorObjects
.hbrushScrollbar
);
749 ReleaseDC32( hwnd
, hdc
);
754 /***********************************************************************
757 * Handle a WM_NCPAINT message. Called from DefWindowProc().
759 LONG
NC_HandleNCPaint( HWND32 hwnd
, HRGN32 clip
)
761 NC_DoNCPaint( hwnd
, clip
, FALSE
);
766 /***********************************************************************
767 * NC_HandleNCActivate
769 * Handle a WM_NCACTIVATE message. Called from DefWindowProc().
771 LONG
NC_HandleNCActivate( WND
*wndPtr
, WPARAM16 wParam
)
775 if( wParam
) wStateChange
= !(wndPtr
->flags
& WIN_NCACTIVATED
);
776 else wStateChange
= wndPtr
->flags
& WIN_NCACTIVATED
;
780 if (wParam
) wndPtr
->flags
|= WIN_NCACTIVATED
;
781 else wndPtr
->flags
&= ~WIN_NCACTIVATED
;
783 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
784 PAINT_RedrawWindow( wndPtr
->hwndSelf
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_ERASENOW
, 0 );
786 NC_DoNCPaint( wndPtr
->hwndSelf
, (HRGN32
)1, FALSE
);
792 /***********************************************************************
795 * Handle a WM_SETCURSOR message. Called from DefWindowProc().
797 LONG
NC_HandleSetCursor( HWND32 hwnd
, WPARAM16 wParam
, LPARAM lParam
)
799 if (hwnd
!= (HWND32
)wParam
) return 0; /* Don't set the cursor for child windows */
801 switch(LOWORD(lParam
))
805 WORD msg
= HIWORD( lParam
);
806 if ((msg
== WM_LBUTTONDOWN
) || (msg
== WM_MBUTTONDOWN
) ||
807 (msg
== WM_RBUTTONDOWN
))
815 if (!(wndPtr
= WIN_FindWndPtr( hwnd
))) break;
816 if (wndPtr
->class->hCursor
)
818 SetCursor16( wndPtr
->class->hCursor
);
826 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZEWE
) );
830 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZENS
) );
834 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZENWSE
) );
838 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZENESW
) );
841 /* Default cursor: arrow */
842 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_ARROW
) );
845 /***********************************************************************
848 BOOL32
NC_GetSysPopupPos( WND
* wndPtr
, RECT32
* rect
)
850 if( wndPtr
->hSysMenu
)
852 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
853 GetWindowRect32( wndPtr
->hwndSelf
, rect
);
856 NC_GetInsideRect( wndPtr
->hwndSelf
, rect
);
857 OffsetRect32( rect
, wndPtr
->rectWindow
.left
, wndPtr
->rectWindow
.top
);
858 if (wndPtr
->dwStyle
& WS_CHILD
)
859 ClientToScreen32( wndPtr
->parent
->hwndSelf
, (POINT32
*)rect
);
860 rect
->right
= rect
->left
+ SYSMETRICS_CXSIZE
;
861 rect
->bottom
= rect
->top
+ SYSMETRICS_CYSIZE
;
868 /***********************************************************************
871 * Track a mouse button press on the system menu.
873 static void NC_TrackSysMenu( HWND32 hwnd
, POINT16 pt
)
875 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
877 if (wndPtr
->dwStyle
& WS_SYSMENU
)
881 iconic
= wndPtr
->dwStyle
& WS_MINIMIZE
;
885 HDC16 hdc
= GetWindowDC32(hwnd
);
888 BOOL32 bNew
, bTrack
= TRUE
;
891 NC_GetSysPopupPos( wndPtr
, &rect
);
892 CONV_RECT32TO16( &rect
, &rTrack
);
893 MapWindowPoints16( 0, hwnd
, (LPPOINT16
)&rTrack
, 2 );
895 /* track mouse while waiting for WM_LBUTTONUP */
897 NC_DrawSysButton( hwnd
, hdc
, bTrack
);
901 msg
.message
= WM_NULL
;
902 PeekMessage16( &msg
, 0, WM_MOUSEFIRST
, WM_MOUSELAST
, PM_REMOVE
);
903 if( msg
.message
== WM_MOUSEMOVE
)
905 if( (bNew
= PtInRect16(&rTrack
, MAKEPOINT16(msg
.lParam
))) )
906 { if( bTrack
) continue; }
908 { if(!bTrack
) continue; }
909 NC_DrawSysButton( hwnd
, hdc
, bTrack
= bNew
);
911 } while( msg
.message
!= WM_LBUTTONUP
);
914 ReleaseDC32(hwnd
, hdc
);
915 on
= PtInRect16(&rTrack
, MAKEPOINT16(msg
.lParam
));
919 SendMessage16( hwnd
, WM_SYSCOMMAND
,
920 SC_MOUSEMENU
+ HTSYSMENU
, *((LPARAM
*)&pt
));
925 /***********************************************************************
928 * Initialisation of a move or resize, when initiatied from a menu choice.
929 * Return hit test code for caption or sizing border.
931 static LONG
NC_StartSizeMove( HWND32 hwnd
, WPARAM16 wParam
,
932 POINT16
*capturePoint
)
937 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
939 if ((wParam
& 0xfff0) == SC_MOVE
)
941 /* Move pointer at the center of the caption */
943 NC_GetInsideRect( hwnd
, &rect
);
944 if (wndPtr
->dwStyle
& WS_SYSMENU
)
945 rect
.left
+= SYSMETRICS_CXSIZE
+ 1;
946 if (wndPtr
->dwStyle
& WS_MINIMIZEBOX
)
947 rect
.right
-= SYSMETRICS_CXSIZE
+ 1;
948 if (wndPtr
->dwStyle
& WS_MAXIMIZEBOX
)
949 rect
.right
-= SYSMETRICS_CXSIZE
+ 1;
950 pt
.x
= wndPtr
->rectWindow
.left
+ (rect
.right
- rect
.left
) / 2;
951 pt
.y
= wndPtr
->rectWindow
.top
+ rect
.top
+ SYSMETRICS_CYSIZE
/2;
952 if (wndPtr
->dwStyle
& WS_CHILD
)
953 ClientToScreen16( wndPtr
->parent
->hwndSelf
, &pt
);
961 MSG_InternalGetMessage( &msg
, 0, 0, MSGF_SIZE
, PM_REMOVE
, FALSE
);
965 hittest
= NC_HandleNCHitTest( hwnd
, msg
.pt
);
967 if ((hittest
< HTLEFT
) || (hittest
> HTBOTTOMRIGHT
))
979 pt
.x
=(wndPtr
->rectWindow
.left
+wndPtr
->rectWindow
.right
)/2;
980 pt
.y
= wndPtr
->rectWindow
.top
+ SYSMETRICS_CYFRAME
/ 2;
984 pt
.x
=(wndPtr
->rectWindow
.left
+wndPtr
->rectWindow
.right
)/2;
985 pt
.y
= wndPtr
->rectWindow
.bottom
- SYSMETRICS_CYFRAME
/ 2;
989 pt
.x
= wndPtr
->rectWindow
.left
+ SYSMETRICS_CXFRAME
/ 2;
990 pt
.y
=(wndPtr
->rectWindow
.top
+wndPtr
->rectWindow
.bottom
)/2;
994 pt
.x
= wndPtr
->rectWindow
.right
- SYSMETRICS_CXFRAME
/ 2;
995 pt
.y
=(wndPtr
->rectWindow
.top
+wndPtr
->rectWindow
.bottom
)/2;
998 case VK_ESCAPE
: return 0;
1004 SetCursorPos32( capturePoint
->x
, capturePoint
->y
);
1005 NC_HandleSetCursor( hwnd
, (WPARAM16
)hwnd
, MAKELONG( hittest
, WM_MOUSEMOVE
));
1010 /***********************************************************************
1013 * Perform SC_MOVE and SC_SIZE commands.
1015 static void NC_DoSizeMove( HWND32 hwnd
, WORD wParam
, POINT16 pt
)
1018 RECT16 sizingRect
, mouseRect
;
1020 LONG hittest
= (LONG
)(wParam
& 0x0f);
1021 HCURSOR16 hDragCursor
= 0, hOldCursor
= 0;
1022 POINT16 minTrack
, maxTrack
, capturePoint
= pt
;
1023 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
1024 BOOL32 thickframe
= HAS_THICKFRAME( wndPtr
->dwStyle
);
1025 BOOL32 iconic
= wndPtr
->dwStyle
& WS_MINIMIZE
;
1028 if (IsZoomed32(hwnd
) || !IsWindowVisible32(hwnd
) ||
1029 (wndPtr
->flags
& WIN_MANAGED
)) return;
1031 if ((wParam
& 0xfff0) == SC_MOVE
)
1033 if (!(wndPtr
->dwStyle
& WS_CAPTION
)) return;
1034 if (!hittest
) hittest
= NC_StartSizeMove( hwnd
, wParam
, &capturePoint
);
1035 if (!hittest
) return;
1039 if (!thickframe
) return;
1040 if (hittest
) hittest
+= HTLEFT
-1;
1044 hittest
= NC_StartSizeMove( hwnd
, wParam
, &capturePoint
);
1053 /* Get min/max info */
1055 NC_GetMinMaxInfo( wndPtr
, NULL
, NULL
, &minTrack
, &maxTrack
);
1056 sizingRect
= wndPtr
->rectWindow
;
1057 if (wndPtr
->dwStyle
& WS_CHILD
)
1058 GetClientRect16( wndPtr
->parent
->hwndSelf
, &mouseRect
);
1059 else SetRect16(&mouseRect
, 0, 0, SYSMETRICS_CXSCREEN
, SYSMETRICS_CYSCREEN
);
1060 if (ON_LEFT_BORDER(hittest
))
1062 mouseRect
.left
= MAX( mouseRect
.left
, sizingRect
.right
-maxTrack
.x
);
1063 mouseRect
.right
= MIN( mouseRect
.right
, sizingRect
.right
-minTrack
.x
);
1065 else if (ON_RIGHT_BORDER(hittest
))
1067 mouseRect
.left
= MAX( mouseRect
.left
, sizingRect
.left
+minTrack
.x
);
1068 mouseRect
.right
= MIN( mouseRect
.right
, sizingRect
.left
+maxTrack
.x
);
1070 if (ON_TOP_BORDER(hittest
))
1072 mouseRect
.top
= MAX( mouseRect
.top
, sizingRect
.bottom
-maxTrack
.y
);
1073 mouseRect
.bottom
= MIN( mouseRect
.bottom
,sizingRect
.bottom
-minTrack
.y
);
1075 else if (ON_BOTTOM_BORDER(hittest
))
1077 mouseRect
.top
= MAX( mouseRect
.top
, sizingRect
.top
+minTrack
.y
);
1078 mouseRect
.bottom
= MIN( mouseRect
.bottom
, sizingRect
.top
+maxTrack
.y
);
1080 SendMessage16( hwnd
, WM_ENTERSIZEMOVE
, 0, 0 );
1082 if (GetCapture32() != hwnd
) SetCapture32( hwnd
);
1084 if (wndPtr
->dwStyle
& WS_CHILD
)
1086 /* Retrieve a default cache DC (without using the window style) */
1087 hdc
= GetDCEx32( wndPtr
->parent
->hwndSelf
, 0, DCX_CACHE
);
1090 { /* Grab the server only when moving top-level windows without desktop */
1092 if (rootWindow
== DefaultRootWindow(display
)) XGrabServer( display
);
1097 HICON16 hIcon
= (wndPtr
->class->hIcon
)
1098 ? wndPtr
->class->hIcon
1099 : (HICON16
)SendMessage16( hwnd
, WM_QUERYDRAGICON
, 0, 0L);
1102 hDragCursor
= CURSORICON_IconToCursor( hIcon
, TRUE
);
1103 hOldCursor
= SetCursor32(hDragCursor
);
1104 ShowCursor32( TRUE
);
1105 } else iconic
= FALSE
;
1108 if( !iconic
) NC_DrawMovingFrame( hdc
, &sizingRect
, thickframe
);
1114 MSG_InternalGetMessage( &msg
, 0, 0, MSGF_SIZE
, PM_REMOVE
, FALSE
);
1116 /* Exit on button-up, Return, or Esc */
1117 if ((msg
.message
== WM_LBUTTONUP
) ||
1118 ((msg
.message
== WM_KEYDOWN
) &&
1119 ((msg
.wParam
== VK_RETURN
) || (msg
.wParam
== VK_ESCAPE
)))) break;
1121 if ((msg
.message
!= WM_KEYDOWN
) && (msg
.message
!= WM_MOUSEMOVE
))
1122 continue; /* We are not interested in other messages */
1125 if (wndPtr
->dwStyle
& WS_CHILD
)
1126 ScreenToClient16( wndPtr
->parent
->hwndSelf
, &pt
);
1128 if (msg
.message
== WM_KEYDOWN
) switch(msg
.wParam
)
1130 case VK_UP
: pt
.y
-= 8; break;
1131 case VK_DOWN
: pt
.y
+= 8; break;
1132 case VK_LEFT
: pt
.x
-= 8; break;
1133 case VK_RIGHT
: pt
.x
+= 8; break;
1136 pt
.x
= MAX( pt
.x
, mouseRect
.left
);
1137 pt
.x
= MIN( pt
.x
, mouseRect
.right
);
1138 pt
.y
= MAX( pt
.y
, mouseRect
.top
);
1139 pt
.y
= MIN( pt
.y
, mouseRect
.bottom
);
1141 dx
= pt
.x
- capturePoint
.x
;
1142 dy
= pt
.y
- capturePoint
.y
;
1147 if (msg
.message
== WM_KEYDOWN
) SetCursorPos32( pt
.x
, pt
.y
);
1150 RECT16 newRect
= sizingRect
;
1152 if (hittest
== HTCAPTION
) OffsetRect16( &newRect
, dx
, dy
);
1153 if (ON_LEFT_BORDER(hittest
)) newRect
.left
+= dx
;
1154 else if (ON_RIGHT_BORDER(hittest
)) newRect
.right
+= dx
;
1155 if (ON_TOP_BORDER(hittest
)) newRect
.top
+= dy
;
1156 else if (ON_BOTTOM_BORDER(hittest
)) newRect
.bottom
+= dy
;
1159 NC_DrawMovingFrame( hdc
, &sizingRect
, thickframe
);
1160 NC_DrawMovingFrame( hdc
, &newRect
, thickframe
);
1163 sizingRect
= newRect
;
1171 ShowCursor32( FALSE
);
1172 SetCursor32(hOldCursor
);
1173 if( hDragCursor
) DestroyCursor32( hDragCursor
);
1176 NC_DrawMovingFrame( hdc
, &sizingRect
, thickframe
);
1178 if (wndPtr
->dwStyle
& WS_CHILD
)
1179 ReleaseDC32( wndPtr
->parent
->hwndSelf
, hdc
);
1182 ReleaseDC32( 0, hdc
);
1183 if (rootWindow
== DefaultRootWindow(display
)) XUngrabServer( display
);
1186 if (HOOK_IsHooked( WH_CBT
))
1188 RECT16
* pr
= SEGPTR_NEW(RECT16
);
1192 if( HOOK_CallHooks16( WH_CBT
, HCBT_MOVESIZE
, hwnd
,
1193 (LPARAM
)SEGPTR_GET(pr
)) )
1194 sizingRect
= wndPtr
->rectWindow
;
1200 SendMessage16( hwnd
, WM_EXITSIZEMOVE
, 0, 0 );
1201 SendMessage16( hwnd
, WM_SETVISIBLE
, !IsIconic16(hwnd
), 0L);
1203 /* Single click brings up the system menu when iconized */
1205 if (!moved
&& (wndPtr
->dwStyle
& WS_MINIMIZE
))
1207 NC_TrackSysMenu( hwnd
, pt
);
1211 /* If Esc key, don't move the window */
1212 if ((msg
.message
== WM_KEYDOWN
) && (msg
.wParam
== VK_ESCAPE
)) return;
1214 if (hittest
!= HTCAPTION
)
1215 SetWindowPos32( hwnd
, 0, sizingRect
.left
, sizingRect
.top
,
1216 sizingRect
.right
- sizingRect
.left
,
1217 sizingRect
.bottom
- sizingRect
.top
,
1218 SWP_NOACTIVATE
| SWP_NOZORDER
);
1219 else SetWindowPos32( hwnd
, 0, sizingRect
.left
, sizingRect
.top
, 0, 0,
1220 SWP_NOACTIVATE
| SWP_NOSIZE
| SWP_NOZORDER
);
1224 /***********************************************************************
1227 * Track a mouse button press on the minimize or maximize box.
1229 static void NC_TrackMinMaxBox( HWND32 hwnd
, WORD wParam
)
1232 HDC32 hdc
= GetWindowDC32( hwnd
);
1233 BOOL pressed
= TRUE
;
1235 SetCapture32( hwnd
);
1236 if (wParam
== HTMINBUTTON
) NC_DrawMinButton( hwnd
, hdc
, TRUE
);
1237 else NC_DrawMaxButton( hwnd
, hdc
, TRUE
);
1241 BOOL oldstate
= pressed
;
1242 MSG_InternalGetMessage( &msg
, 0, 0, 0, PM_REMOVE
, FALSE
);
1244 pressed
= (NC_HandleNCHitTest( hwnd
, msg
.pt
) == wParam
);
1245 if (pressed
!= oldstate
)
1247 if (wParam
== HTMINBUTTON
) NC_DrawMinButton( hwnd
, hdc
, pressed
);
1248 else NC_DrawMaxButton( hwnd
, hdc
, pressed
);
1250 } while (msg
.message
!= WM_LBUTTONUP
);
1252 if (wParam
== HTMINBUTTON
) NC_DrawMinButton( hwnd
, hdc
, FALSE
);
1253 else NC_DrawMaxButton( hwnd
, hdc
, FALSE
);
1256 ReleaseDC32( hwnd
, hdc
);
1257 if (!pressed
) return;
1259 if (wParam
== HTMINBUTTON
)
1260 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MINIMIZE
, *(LONG
*)&msg
.pt
);
1262 SendMessage16( hwnd
, WM_SYSCOMMAND
,
1263 IsZoomed32(hwnd
) ? SC_RESTORE
:SC_MAXIMIZE
, *(LONG
*)&msg
.pt
);
1267 /***********************************************************************
1270 * Track a mouse button press on the horizontal or vertical scroll-bar.
1272 static void NC_TrackScrollBar( HWND32 hwnd
, WPARAM32 wParam
, POINT32 pt
)
1276 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1278 if ((wParam
& 0xfff0) == SC_HSCROLL
)
1280 if ((wParam
& 0x0f) != HTHSCROLL
) return;
1281 scrollbar
= SB_HORZ
;
1283 else /* SC_VSCROLL */
1285 if ((wParam
& 0x0f) != HTVSCROLL
) return;
1286 scrollbar
= SB_VERT
;
1289 if (!(msg
= SEGPTR_NEW(MSG16
))) return;
1290 pt
.x
-= wndPtr
->rectWindow
.left
;
1291 pt
.y
-= wndPtr
->rectWindow
.top
;
1292 SetCapture32( hwnd
);
1293 SCROLL_HandleScrollEvent( hwnd
, scrollbar
, WM_LBUTTONDOWN
, pt
);
1297 GetMessage( SEGPTR_GET(msg
), 0, 0, 0 );
1298 switch(msg
->message
)
1303 pt
.x
= LOWORD(msg
->lParam
) + wndPtr
->rectClient
.left
-
1304 wndPtr
->rectWindow
.left
;
1305 pt
.y
= HIWORD(msg
->lParam
) + wndPtr
->rectClient
.top
-
1306 wndPtr
->rectWindow
.top
;
1307 SCROLL_HandleScrollEvent( hwnd
, scrollbar
, msg
->message
, pt
);
1310 TranslateMessage16( msg
);
1311 DispatchMessage16( msg
);
1314 if (!IsWindow( hwnd
))
1319 } while (msg
->message
!= WM_LBUTTONUP
);
1323 /***********************************************************************
1324 * NC_HandleNCLButtonDown
1326 * Handle a WM_NCLBUTTONDOWN message. Called from DefWindowProc().
1328 LONG
NC_HandleNCLButtonDown( HWND32 hwnd
, WPARAM16 wParam
, LPARAM lParam
)
1330 switch(wParam
) /* Hit test */
1333 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MOVE
+ HTCAPTION
, lParam
);
1337 NC_TrackSysMenu( hwnd
, MAKEPOINT16(lParam
) );
1341 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MOUSEMENU
, lParam
);
1345 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_HSCROLL
+ HTHSCROLL
, lParam
);
1349 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_VSCROLL
+ HTVSCROLL
, lParam
);
1354 NC_TrackMinMaxBox( hwnd
, wParam
);
1365 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_SIZE
+ wParam
- HTLEFT
+1, lParam
);
1375 /***********************************************************************
1376 * NC_HandleNCLButtonDblClk
1378 * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc().
1380 LONG
NC_HandleNCLButtonDblClk( WND
*pWnd
, WPARAM16 wParam
, LPARAM lParam
)
1383 * if this is an icon, send a restore since we are handling
1386 if (pWnd
->dwStyle
& WS_MINIMIZE
)
1388 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_RESTORE
, lParam
);
1392 switch(wParam
) /* Hit test */
1395 /* stop processing if WS_MAXIMIZEBOX is missing */
1396 if (pWnd
->dwStyle
& WS_MAXIMIZEBOX
)
1397 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
,
1398 (pWnd
->dwStyle
& WS_MAXIMIZE
) ? SC_RESTORE
: SC_MAXIMIZE
,
1403 if (!(pWnd
->class->style
& CS_NOCLOSE
))
1404 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_CLOSE
, lParam
);
1411 /***********************************************************************
1412 * NC_HandleSysCommand
1414 * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
1416 LONG
NC_HandleSysCommand( HWND32 hwnd
, WPARAM16 wParam
, POINT16 pt
)
1418 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1421 dprintf_nonclient(stddeb
, "Handling WM_SYSCOMMAND %x %d,%d\n",
1422 wParam
, pt
.x
, pt
.y
);
1424 if (wndPtr
->dwStyle
& WS_CHILD
&& wParam
!= SC_KEYMENU
)
1425 ScreenToClient16( wndPtr
->parent
->hwndSelf
, &pt
);
1427 switch (wParam
& 0xfff0)
1431 NC_DoSizeMove( hwnd
, wParam
, pt
);
1435 ShowWindow32( hwnd
, SW_MINIMIZE
);
1439 ShowWindow32( hwnd
, SW_MAXIMIZE
);
1443 ShowWindow32( hwnd
, SW_RESTORE
);
1447 return SendMessage16( hwnd
, WM_CLOSE
, 0, 0 );
1451 CONV_POINT16TO32( &pt
, &pt32
);
1452 NC_TrackScrollBar( hwnd
, wParam
, pt32
);
1456 CONV_POINT16TO32( &pt
, &pt32
);
1457 MENU_TrackMouseMenuBar( wndPtr
, wParam
& 0x000F, pt32
);
1461 MENU_TrackKbdMenuBar( wndPtr
, wParam
, pt
.x
);
1465 WinExec32( "taskman.exe", SW_SHOWNORMAL
);
1469 if (wParam
== SC_ABOUTWINE
)
1471 extern const char people
[];
1472 ShellAbout32A(hwnd
,"Wine",people
,0);
1480 /* FIXME: unimplemented */