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
| WS_CHILD
);
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
) || (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
, BOOL32 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
, BOOL32 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( HDC32 hdc
, RECT32
*rect
, BOOL32 dlgFrame
,
509 width
= SYSMETRICS_CXDLGFRAME
- 1;
510 height
= SYSMETRICS_CYDLGFRAME
- 1;
511 SelectObject32( hdc
, active
? sysColorObjects
.hbrushActiveCaption
:
512 sysColorObjects
.hbrushInactiveCaption
);
516 width
= SYSMETRICS_CXFRAME
- 1;
517 height
= SYSMETRICS_CYFRAME
- 1;
518 SelectObject32( hdc
, active
? sysColorObjects
.hbrushActiveBorder
:
519 sysColorObjects
.hbrushInactiveBorder
);
523 PatBlt32( hdc
, rect
->left
, rect
->top
,
524 rect
->right
- rect
->left
, height
, PATCOPY
);
525 PatBlt32( hdc
, rect
->left
, rect
->top
,
526 width
, rect
->bottom
- rect
->top
, PATCOPY
);
527 PatBlt32( hdc
, rect
->left
, rect
->bottom
,
528 rect
->right
- rect
->left
, -height
, PATCOPY
);
529 PatBlt32( hdc
, rect
->right
, rect
->top
,
530 -width
, rect
->bottom
- rect
->top
, PATCOPY
);
534 InflateRect32( rect
, -width
, -height
);
540 /* Draw inner rectangle */
542 GRAPH_DrawRectangle( hdc
, rect
->left
+ width
,
544 rect
->right
- rect
->left
- 2*width
,
545 rect
->bottom
- rect
->top
- 2*height
,
548 /* Draw the decorations */
550 lpt
[4].x
= lpt
[0].x
= rect
->left
;
551 lpt
[5].x
= lpt
[1].x
= rect
->left
+ width
;
552 lpt
[6].x
= lpt
[2].x
= rect
->right
- width
- 1;
553 lpt
[7].x
= lpt
[3].x
= rect
->right
- 1;
555 lpt
[0].y
= lpt
[1].y
= lpt
[2].y
= lpt
[3].y
=
556 rect
->top
+ SYSMETRICS_CYFRAME
+ SYSMETRICS_CYSIZE
;
557 lpt
[4].y
= lpt
[5].y
= lpt
[6].y
= lpt
[7].y
=
558 rect
->bottom
- 1 - SYSMETRICS_CYFRAME
- SYSMETRICS_CYSIZE
;
560 lpt
[8].x
= lpt
[9].x
= lpt
[10].x
= lpt
[11].x
=
561 rect
->left
+ SYSMETRICS_CXFRAME
+ SYSMETRICS_CXSIZE
;
562 lpt
[12].x
= lpt
[13].x
= lpt
[14].x
= lpt
[15].x
=
563 rect
->right
- 1 - SYSMETRICS_CXFRAME
- SYSMETRICS_CYSIZE
;
565 lpt
[12].y
= lpt
[8].y
= rect
->top
;
566 lpt
[13].y
= lpt
[9].y
= rect
->top
+ height
;
567 lpt
[14].y
= lpt
[10].y
= rect
->bottom
- height
- 1;
568 lpt
[15].y
= lpt
[11].y
= rect
->bottom
- 1;
570 GRAPH_DrawLines( hdc
, lpt
, 8, (HPEN32
)0 ); /* 8 is the maximum */
571 InflateRect32( rect
, -width
- 1, -height
- 1 );
576 /***********************************************************************
579 * Draw the frame used when moving or resizing window.
581 static void NC_DrawMovingFrame( HDC16 hdc
, RECT16
*rect
, BOOL32 thickframe
)
583 if (thickframe
) FastWindowFrame( hdc
, rect
, SYSMETRICS_CXFRAME
,
584 SYSMETRICS_CYFRAME
, PATINVERT
);
585 else DrawFocusRect16( hdc
, rect
);
589 /***********************************************************************
592 * Draw the window caption.
593 * The correct pen for the window frame must be selected in the DC.
595 static void NC_DrawCaption( HDC32 hdc
, RECT32
*rect
, HWND32 hwnd
,
596 DWORD style
, BOOL32 active
)
599 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
602 if (wndPtr
->flags
& WIN_MANAGED
) return;
606 if (!(hbitmapClose
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_CLOSE
) )))
608 hbitmapMinimize
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_REDUCE
) );
609 hbitmapMinimizeD
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_REDUCED
) );
610 hbitmapMaximize
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_ZOOM
) );
611 hbitmapMaximizeD
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_ZOOMD
) );
612 hbitmapRestore
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_RESTORE
) );
613 hbitmapRestoreD
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_RESTORED
) );
616 if (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
)
618 HBRUSH32 hbrushOld
= SelectObject32(hdc
, sysColorObjects
.hbrushWindow
);
619 PatBlt32( hdc
, r
.left
, r
.top
, 1, r
.bottom
-r
.top
+1,PATCOPY
);
620 PatBlt32( hdc
, r
.right
-1, r
.top
, 1, r
.bottom
-r
.top
+1, PATCOPY
);
621 PatBlt32( hdc
, r
.left
, r
.top
-1, r
.right
-r
.left
, 1, PATCOPY
);
624 SelectObject32( hdc
, hbrushOld
);
627 MoveTo( hdc
, r
.left
, r
.bottom
);
628 LineTo32( hdc
, r
.right
-1, r
.bottom
);
630 if (style
& WS_SYSMENU
)
632 NC_DrawSysButton( hwnd
, hdc
, FALSE
);
633 r
.left
+= SYSMETRICS_CXSIZE
+ 1;
634 MoveTo( hdc
, r
.left
- 1, r
.top
);
635 LineTo32( hdc
, r
.left
- 1, r
.bottom
);
637 if (style
& WS_MAXIMIZEBOX
)
639 NC_DrawMaxButton( hwnd
, hdc
, FALSE
);
640 r
.right
-= SYSMETRICS_CXSIZE
+ 1;
642 if (style
& WS_MINIMIZEBOX
)
644 NC_DrawMinButton( hwnd
, hdc
, FALSE
);
645 r
.right
-= SYSMETRICS_CXSIZE
+ 1;
648 FillRect32( hdc
, &r
, active
? sysColorObjects
.hbrushActiveCaption
:
649 sysColorObjects
.hbrushInactiveCaption
);
651 if (GetWindowText32A( hwnd
, buffer
, sizeof(buffer
) ))
653 if (active
) SetTextColor32( hdc
, GetSysColor32( COLOR_CAPTIONTEXT
) );
654 else SetTextColor32( hdc
, GetSysColor32( COLOR_INACTIVECAPTIONTEXT
) );
655 SetBkMode32( hdc
, TRANSPARENT
);
656 DrawText32A( hdc
, buffer
, -1, &r
,
657 DT_SINGLELINE
| DT_CENTER
| DT_VCENTER
| DT_NOPREFIX
);
662 /***********************************************************************
665 * Paint the non-client area. clip is currently unused.
667 void NC_DoNCPaint( HWND32 hwnd
, HRGN32 clip
, BOOL32 suppress_menupaint
)
673 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
675 if (!wndPtr
|| wndPtr
->dwStyle
& WS_MINIMIZE
||
676 !WIN_IsWindowDrawable( wndPtr
, 0 )) return; /* Nothing to do */
678 active
= wndPtr
->flags
& WIN_NCACTIVATED
;
680 dprintf_nonclient(stddeb
, "NC_DoNCPaint: %04x %d\n", hwnd
, active
);
682 if (!(hdc
= GetDCEx32( hwnd
, 0, DCX_USESTYLE
| DCX_WINDOW
))) return;
684 if (ExcludeVisRect( hdc
, wndPtr
->rectClient
.left
-wndPtr
->rectWindow
.left
,
685 wndPtr
->rectClient
.top
-wndPtr
->rectWindow
.top
,
686 wndPtr
->rectClient
.right
-wndPtr
->rectWindow
.left
,
687 wndPtr
->rectClient
.bottom
-wndPtr
->rectWindow
.top
)
690 ReleaseDC32( hwnd
, hdc
);
694 rect
.top
= rect
.left
= 0;
695 rect
.right
= wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
;
696 rect
.bottom
= wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
;
698 SelectObject32( hdc
, sysColorObjects
.hpenWindowFrame
);
700 if (!(wndPtr
->flags
& WIN_MANAGED
))
702 if ((wndPtr
->dwStyle
& WS_BORDER
) || (wndPtr
->dwStyle
& WS_DLGFRAME
) ||
703 (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
))
705 GRAPH_DrawRectangle( hdc
, 0, 0,
706 rect
.right
, rect
.bottom
, (HPEN32
)0 );
707 InflateRect32( &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 r
.bottom
= rect
.top
+ SYSMETRICS_CYMENU
; /* default height */
728 rect
.top
+= MENU_DrawMenuBar( hdc
, &r
, hwnd
, suppress_menupaint
);
731 /* Draw the scroll-bars */
733 if (wndPtr
->dwStyle
& WS_VSCROLL
)
734 SCROLL_DrawScrollBar( hwnd
, hdc
, SB_VERT
, TRUE
);
735 if (wndPtr
->dwStyle
& WS_HSCROLL
)
736 SCROLL_DrawScrollBar( hwnd
, hdc
, SB_HORZ
, TRUE
);
738 /* Draw the "size-box" */
740 if ((wndPtr
->dwStyle
& WS_VSCROLL
) && (wndPtr
->dwStyle
& WS_HSCROLL
))
743 r
.left
= r
.right
- SYSMETRICS_CXVSCROLL
+ 1;
744 r
.top
= r
.bottom
- SYSMETRICS_CYHSCROLL
+ 1;
745 FillRect32( hdc
, &r
, sysColorObjects
.hbrushScrollbar
);
748 ReleaseDC32( hwnd
, hdc
);
753 /***********************************************************************
756 * Handle a WM_NCPAINT message. Called from DefWindowProc().
758 LONG
NC_HandleNCPaint( HWND32 hwnd
, HRGN32 clip
)
760 NC_DoNCPaint( hwnd
, clip
, FALSE
);
765 /***********************************************************************
766 * NC_HandleNCActivate
768 * Handle a WM_NCACTIVATE message. Called from DefWindowProc().
770 LONG
NC_HandleNCActivate( WND
*wndPtr
, WPARAM16 wParam
)
774 if( wParam
) wStateChange
= !(wndPtr
->flags
& WIN_NCACTIVATED
);
775 else wStateChange
= wndPtr
->flags
& WIN_NCACTIVATED
;
779 if (wParam
) wndPtr
->flags
|= WIN_NCACTIVATED
;
780 else wndPtr
->flags
&= ~WIN_NCACTIVATED
;
782 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
783 PAINT_RedrawWindow( wndPtr
->hwndSelf
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_ERASENOW
, 0 );
785 NC_DoNCPaint( wndPtr
->hwndSelf
, (HRGN32
)1, FALSE
);
791 /***********************************************************************
794 * Handle a WM_SETCURSOR message. Called from DefWindowProc().
796 LONG
NC_HandleSetCursor( HWND32 hwnd
, WPARAM16 wParam
, LPARAM lParam
)
798 if (hwnd
!= (HWND32
)wParam
) return 0; /* Don't set the cursor for child windows */
800 switch(LOWORD(lParam
))
804 WORD msg
= HIWORD( lParam
);
805 if ((msg
== WM_LBUTTONDOWN
) || (msg
== WM_MBUTTONDOWN
) ||
806 (msg
== WM_RBUTTONDOWN
))
814 if (!(wndPtr
= WIN_FindWndPtr( hwnd
))) break;
815 if (wndPtr
->class->hCursor
)
817 SetCursor16( wndPtr
->class->hCursor
);
825 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZEWE
) );
829 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZENS
) );
833 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZENWSE
) );
837 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZENESW
) );
840 /* Default cursor: arrow */
841 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_ARROW
) );
844 /***********************************************************************
847 BOOL32
NC_GetSysPopupPos( WND
* wndPtr
, RECT32
* rect
)
849 if( wndPtr
->hSysMenu
)
851 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
852 GetWindowRect32( wndPtr
->hwndSelf
, rect
);
855 NC_GetInsideRect( wndPtr
->hwndSelf
, rect
);
856 OffsetRect32( rect
, wndPtr
->rectWindow
.left
, wndPtr
->rectWindow
.top
);
857 if (wndPtr
->dwStyle
& WS_CHILD
)
858 ClientToScreen32( wndPtr
->parent
->hwndSelf
, (POINT32
*)rect
);
859 rect
->right
= rect
->left
+ SYSMETRICS_CXSIZE
;
860 rect
->bottom
= rect
->top
+ SYSMETRICS_CYSIZE
;
867 /***********************************************************************
870 * Track a mouse button press on the system menu.
872 static void NC_TrackSysMenu( HWND32 hwnd
, POINT16 pt
)
874 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
876 if (wndPtr
->dwStyle
& WS_SYSMENU
)
880 iconic
= wndPtr
->dwStyle
& WS_MINIMIZE
;
884 HDC16 hdc
= GetWindowDC32(hwnd
);
887 BOOL32 bNew
, bTrack
= TRUE
;
890 NC_GetSysPopupPos( wndPtr
, &rect
);
891 CONV_RECT32TO16( &rect
, &rTrack
);
892 MapWindowPoints16( 0, hwnd
, (LPPOINT16
)&rTrack
, 2 );
894 /* track mouse while waiting for WM_LBUTTONUP */
896 NC_DrawSysButton( hwnd
, hdc
, bTrack
);
900 msg
.message
= WM_NULL
;
901 PeekMessage16( &msg
, 0, WM_MOUSEFIRST
, WM_MOUSELAST
, PM_REMOVE
);
902 if( msg
.message
== WM_MOUSEMOVE
)
904 if( (bNew
= PtInRect16(&rTrack
, MAKEPOINT16(msg
.lParam
))) )
905 { if( bTrack
) continue; }
907 { if(!bTrack
) continue; }
908 NC_DrawSysButton( hwnd
, hdc
, bTrack
= bNew
);
910 } while( msg
.message
!= WM_LBUTTONUP
);
913 ReleaseDC32(hwnd
, hdc
);
914 on
= PtInRect16(&rTrack
, MAKEPOINT16(msg
.lParam
));
918 SendMessage16( hwnd
, WM_SYSCOMMAND
,
919 SC_MOUSEMENU
+ HTSYSMENU
, *((LPARAM
*)&pt
));
924 /***********************************************************************
927 * Initialisation of a move or resize, when initiatied from a menu choice.
928 * Return hit test code for caption or sizing border.
930 static LONG
NC_StartSizeMove( HWND32 hwnd
, WPARAM16 wParam
,
931 POINT16
*capturePoint
)
936 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
938 if ((wParam
& 0xfff0) == SC_MOVE
)
940 /* Move pointer at the center of the caption */
942 NC_GetInsideRect( hwnd
, &rect
);
943 if (wndPtr
->dwStyle
& WS_SYSMENU
)
944 rect
.left
+= SYSMETRICS_CXSIZE
+ 1;
945 if (wndPtr
->dwStyle
& WS_MINIMIZEBOX
)
946 rect
.right
-= SYSMETRICS_CXSIZE
+ 1;
947 if (wndPtr
->dwStyle
& WS_MAXIMIZEBOX
)
948 rect
.right
-= SYSMETRICS_CXSIZE
+ 1;
949 pt
.x
= wndPtr
->rectWindow
.left
+ (rect
.right
- rect
.left
) / 2;
950 pt
.y
= wndPtr
->rectWindow
.top
+ rect
.top
+ SYSMETRICS_CYSIZE
/2;
951 if (wndPtr
->dwStyle
& WS_CHILD
)
952 ClientToScreen16( wndPtr
->parent
->hwndSelf
, &pt
);
960 MSG_InternalGetMessage( &msg
, 0, 0, MSGF_SIZE
, PM_REMOVE
, FALSE
);
964 hittest
= NC_HandleNCHitTest( hwnd
, msg
.pt
);
966 if ((hittest
< HTLEFT
) || (hittest
> HTBOTTOMRIGHT
))
978 pt
.x
=(wndPtr
->rectWindow
.left
+wndPtr
->rectWindow
.right
)/2;
979 pt
.y
= wndPtr
->rectWindow
.top
+ SYSMETRICS_CYFRAME
/ 2;
983 pt
.x
=(wndPtr
->rectWindow
.left
+wndPtr
->rectWindow
.right
)/2;
984 pt
.y
= wndPtr
->rectWindow
.bottom
- SYSMETRICS_CYFRAME
/ 2;
988 pt
.x
= wndPtr
->rectWindow
.left
+ SYSMETRICS_CXFRAME
/ 2;
989 pt
.y
=(wndPtr
->rectWindow
.top
+wndPtr
->rectWindow
.bottom
)/2;
993 pt
.x
= wndPtr
->rectWindow
.right
- SYSMETRICS_CXFRAME
/ 2;
994 pt
.y
=(wndPtr
->rectWindow
.top
+wndPtr
->rectWindow
.bottom
)/2;
997 case VK_ESCAPE
: return 0;
1003 SetCursorPos32( capturePoint
->x
, capturePoint
->y
);
1004 NC_HandleSetCursor( hwnd
, (WPARAM16
)hwnd
, MAKELONG( hittest
, WM_MOUSEMOVE
));
1009 /***********************************************************************
1012 * Perform SC_MOVE and SC_SIZE commands.
1014 static void NC_DoSizeMove( HWND32 hwnd
, WORD wParam
, POINT16 pt
)
1017 RECT16 sizingRect
, mouseRect
;
1019 LONG hittest
= (LONG
)(wParam
& 0x0f);
1020 HCURSOR16 hDragCursor
= 0, hOldCursor
= 0;
1021 POINT16 minTrack
, maxTrack
, capturePoint
= pt
;
1022 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
1023 BOOL32 thickframe
= HAS_THICKFRAME( wndPtr
->dwStyle
);
1024 BOOL32 iconic
= wndPtr
->dwStyle
& WS_MINIMIZE
;
1027 if (IsZoomed32(hwnd
) || !IsWindowVisible32(hwnd
) ||
1028 (wndPtr
->flags
& WIN_MANAGED
)) return;
1030 if ((wParam
& 0xfff0) == SC_MOVE
)
1032 if (!(wndPtr
->dwStyle
& WS_CAPTION
)) return;
1033 if (!hittest
) hittest
= NC_StartSizeMove( hwnd
, wParam
, &capturePoint
);
1034 if (!hittest
) return;
1038 if (!thickframe
) return;
1039 if (hittest
) hittest
+= HTLEFT
-1;
1043 hittest
= NC_StartSizeMove( hwnd
, wParam
, &capturePoint
);
1052 /* Get min/max info */
1054 NC_GetMinMaxInfo( wndPtr
, NULL
, NULL
, &minTrack
, &maxTrack
);
1055 sizingRect
= wndPtr
->rectWindow
;
1056 if (wndPtr
->dwStyle
& WS_CHILD
)
1057 GetClientRect16( wndPtr
->parent
->hwndSelf
, &mouseRect
);
1058 else SetRect16(&mouseRect
, 0, 0, SYSMETRICS_CXSCREEN
, SYSMETRICS_CYSCREEN
);
1059 if (ON_LEFT_BORDER(hittest
))
1061 mouseRect
.left
= MAX( mouseRect
.left
, sizingRect
.right
-maxTrack
.x
);
1062 mouseRect
.right
= MIN( mouseRect
.right
, sizingRect
.right
-minTrack
.x
);
1064 else if (ON_RIGHT_BORDER(hittest
))
1066 mouseRect
.left
= MAX( mouseRect
.left
, sizingRect
.left
+minTrack
.x
);
1067 mouseRect
.right
= MIN( mouseRect
.right
, sizingRect
.left
+maxTrack
.x
);
1069 if (ON_TOP_BORDER(hittest
))
1071 mouseRect
.top
= MAX( mouseRect
.top
, sizingRect
.bottom
-maxTrack
.y
);
1072 mouseRect
.bottom
= MIN( mouseRect
.bottom
,sizingRect
.bottom
-minTrack
.y
);
1074 else if (ON_BOTTOM_BORDER(hittest
))
1076 mouseRect
.top
= MAX( mouseRect
.top
, sizingRect
.top
+minTrack
.y
);
1077 mouseRect
.bottom
= MIN( mouseRect
.bottom
, sizingRect
.top
+maxTrack
.y
);
1079 SendMessage16( hwnd
, WM_ENTERSIZEMOVE
, 0, 0 );
1081 if (GetCapture32() != hwnd
) SetCapture32( hwnd
);
1083 if (wndPtr
->dwStyle
& WS_CHILD
)
1085 /* Retrieve a default cache DC (without using the window style) */
1086 hdc
= GetDCEx32( wndPtr
->parent
->hwndSelf
, 0, DCX_CACHE
);
1089 { /* Grab the server only when moving top-level windows without desktop */
1091 if (rootWindow
== DefaultRootWindow(display
)) XGrabServer( display
);
1096 HICON16 hIcon
= (wndPtr
->class->hIcon
)
1097 ? wndPtr
->class->hIcon
1098 : (HICON16
)SendMessage16( hwnd
, WM_QUERYDRAGICON
, 0, 0L);
1101 hDragCursor
= CURSORICON_IconToCursor( hIcon
, TRUE
);
1102 hOldCursor
= SetCursor32(hDragCursor
);
1103 ShowCursor32( TRUE
);
1104 } else iconic
= FALSE
;
1107 if( !iconic
) NC_DrawMovingFrame( hdc
, &sizingRect
, thickframe
);
1113 MSG_InternalGetMessage( &msg
, 0, 0, MSGF_SIZE
, PM_REMOVE
, FALSE
);
1115 /* Exit on button-up, Return, or Esc */
1116 if ((msg
.message
== WM_LBUTTONUP
) ||
1117 ((msg
.message
== WM_KEYDOWN
) &&
1118 ((msg
.wParam
== VK_RETURN
) || (msg
.wParam
== VK_ESCAPE
)))) break;
1120 if ((msg
.message
!= WM_KEYDOWN
) && (msg
.message
!= WM_MOUSEMOVE
))
1121 continue; /* We are not interested in other messages */
1124 if (wndPtr
->dwStyle
& WS_CHILD
)
1125 ScreenToClient16( wndPtr
->parent
->hwndSelf
, &pt
);
1127 if (msg
.message
== WM_KEYDOWN
) switch(msg
.wParam
)
1129 case VK_UP
: pt
.y
-= 8; break;
1130 case VK_DOWN
: pt
.y
+= 8; break;
1131 case VK_LEFT
: pt
.x
-= 8; break;
1132 case VK_RIGHT
: pt
.x
+= 8; break;
1135 pt
.x
= MAX( pt
.x
, mouseRect
.left
);
1136 pt
.x
= MIN( pt
.x
, mouseRect
.right
);
1137 pt
.y
= MAX( pt
.y
, mouseRect
.top
);
1138 pt
.y
= MIN( pt
.y
, mouseRect
.bottom
);
1140 dx
= pt
.x
- capturePoint
.x
;
1141 dy
= pt
.y
- capturePoint
.y
;
1146 if (msg
.message
== WM_KEYDOWN
) SetCursorPos32( pt
.x
, pt
.y
);
1149 RECT16 newRect
= sizingRect
;
1151 if (hittest
== HTCAPTION
) OffsetRect16( &newRect
, dx
, dy
);
1152 if (ON_LEFT_BORDER(hittest
)) newRect
.left
+= dx
;
1153 else if (ON_RIGHT_BORDER(hittest
)) newRect
.right
+= dx
;
1154 if (ON_TOP_BORDER(hittest
)) newRect
.top
+= dy
;
1155 else if (ON_BOTTOM_BORDER(hittest
)) newRect
.bottom
+= dy
;
1158 NC_DrawMovingFrame( hdc
, &sizingRect
, thickframe
);
1159 NC_DrawMovingFrame( hdc
, &newRect
, thickframe
);
1162 sizingRect
= newRect
;
1170 ShowCursor32( FALSE
);
1171 SetCursor32(hOldCursor
);
1172 if( hDragCursor
) DestroyCursor32( hDragCursor
);
1175 NC_DrawMovingFrame( hdc
, &sizingRect
, thickframe
);
1177 if (wndPtr
->dwStyle
& WS_CHILD
)
1178 ReleaseDC32( wndPtr
->parent
->hwndSelf
, hdc
);
1181 ReleaseDC32( 0, hdc
);
1182 if (rootWindow
== DefaultRootWindow(display
)) XUngrabServer( display
);
1185 if (HOOK_IsHooked( WH_CBT
))
1187 RECT16
* pr
= SEGPTR_NEW(RECT16
);
1191 if( HOOK_CallHooks16( WH_CBT
, HCBT_MOVESIZE
, hwnd
,
1192 (LPARAM
)SEGPTR_GET(pr
)) )
1193 sizingRect
= wndPtr
->rectWindow
;
1199 SendMessage16( hwnd
, WM_EXITSIZEMOVE
, 0, 0 );
1200 SendMessage16( hwnd
, WM_SETVISIBLE
, !IsIconic16(hwnd
), 0L);
1202 /* Single click brings up the system menu when iconized */
1204 if (!moved
&& (wndPtr
->dwStyle
& WS_MINIMIZE
))
1206 NC_TrackSysMenu( hwnd
, pt
);
1210 /* If Esc key, don't move the window */
1211 if ((msg
.message
== WM_KEYDOWN
) && (msg
.wParam
== VK_ESCAPE
)) return;
1213 if (hittest
!= HTCAPTION
)
1214 SetWindowPos32( hwnd
, 0, sizingRect
.left
, sizingRect
.top
,
1215 sizingRect
.right
- sizingRect
.left
,
1216 sizingRect
.bottom
- sizingRect
.top
,
1217 SWP_NOACTIVATE
| SWP_NOZORDER
);
1218 else SetWindowPos32( hwnd
, 0, sizingRect
.left
, sizingRect
.top
, 0, 0,
1219 SWP_NOACTIVATE
| SWP_NOSIZE
| SWP_NOZORDER
);
1223 /***********************************************************************
1226 * Track a mouse button press on the minimize or maximize box.
1228 static void NC_TrackMinMaxBox( HWND32 hwnd
, WORD wParam
)
1231 HDC32 hdc
= GetWindowDC32( hwnd
);
1232 BOOL32 pressed
= TRUE
;
1234 SetCapture32( hwnd
);
1235 if (wParam
== HTMINBUTTON
) NC_DrawMinButton( hwnd
, hdc
, TRUE
);
1236 else NC_DrawMaxButton( hwnd
, hdc
, TRUE
);
1240 BOOL32 oldstate
= pressed
;
1241 MSG_InternalGetMessage( &msg
, 0, 0, 0, PM_REMOVE
, FALSE
);
1243 pressed
= (NC_HandleNCHitTest( hwnd
, msg
.pt
) == wParam
);
1244 if (pressed
!= oldstate
)
1246 if (wParam
== HTMINBUTTON
) NC_DrawMinButton( hwnd
, hdc
, pressed
);
1247 else NC_DrawMaxButton( hwnd
, hdc
, pressed
);
1249 } while (msg
.message
!= WM_LBUTTONUP
);
1251 if (wParam
== HTMINBUTTON
) NC_DrawMinButton( hwnd
, hdc
, FALSE
);
1252 else NC_DrawMaxButton( hwnd
, hdc
, FALSE
);
1255 ReleaseDC32( hwnd
, hdc
);
1256 if (!pressed
) return;
1258 if (wParam
== HTMINBUTTON
)
1259 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MINIMIZE
, *(LONG
*)&msg
.pt
);
1261 SendMessage16( hwnd
, WM_SYSCOMMAND
,
1262 IsZoomed32(hwnd
) ? SC_RESTORE
:SC_MAXIMIZE
, *(LONG
*)&msg
.pt
);
1266 /***********************************************************************
1269 * Track a mouse button press on the horizontal or vertical scroll-bar.
1271 static void NC_TrackScrollBar( HWND32 hwnd
, WPARAM32 wParam
, POINT32 pt
)
1275 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1277 if ((wParam
& 0xfff0) == SC_HSCROLL
)
1279 if ((wParam
& 0x0f) != HTHSCROLL
) return;
1280 scrollbar
= SB_HORZ
;
1282 else /* SC_VSCROLL */
1284 if ((wParam
& 0x0f) != HTVSCROLL
) return;
1285 scrollbar
= SB_VERT
;
1288 if (!(msg
= SEGPTR_NEW(MSG16
))) return;
1289 pt
.x
-= wndPtr
->rectWindow
.left
;
1290 pt
.y
-= wndPtr
->rectWindow
.top
;
1291 SetCapture32( hwnd
);
1292 SCROLL_HandleScrollEvent( hwnd
, scrollbar
, WM_LBUTTONDOWN
, pt
);
1296 GetMessage16( SEGPTR_GET(msg
), 0, 0, 0 );
1297 switch(msg
->message
)
1302 pt
.x
= LOWORD(msg
->lParam
) + wndPtr
->rectClient
.left
-
1303 wndPtr
->rectWindow
.left
;
1304 pt
.y
= HIWORD(msg
->lParam
) + wndPtr
->rectClient
.top
-
1305 wndPtr
->rectWindow
.top
;
1306 SCROLL_HandleScrollEvent( hwnd
, scrollbar
, msg
->message
, pt
);
1309 TranslateMessage16( msg
);
1310 DispatchMessage16( msg
);
1313 if (!IsWindow32( hwnd
))
1318 } while (msg
->message
!= WM_LBUTTONUP
);
1322 /***********************************************************************
1323 * NC_HandleNCLButtonDown
1325 * Handle a WM_NCLBUTTONDOWN message. Called from DefWindowProc().
1327 LONG
NC_HandleNCLButtonDown( HWND32 hwnd
, WPARAM16 wParam
, LPARAM lParam
)
1329 switch(wParam
) /* Hit test */
1332 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MOVE
+ HTCAPTION
, lParam
);
1336 NC_TrackSysMenu( hwnd
, MAKEPOINT16(lParam
) );
1340 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MOUSEMENU
, lParam
);
1344 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_HSCROLL
+ HTHSCROLL
, lParam
);
1348 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_VSCROLL
+ HTVSCROLL
, lParam
);
1353 NC_TrackMinMaxBox( hwnd
, wParam
);
1364 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_SIZE
+ wParam
- HTLEFT
+1, lParam
);
1374 /***********************************************************************
1375 * NC_HandleNCLButtonDblClk
1377 * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc().
1379 LONG
NC_HandleNCLButtonDblClk( WND
*pWnd
, WPARAM16 wParam
, LPARAM lParam
)
1382 * if this is an icon, send a restore since we are handling
1385 if (pWnd
->dwStyle
& WS_MINIMIZE
)
1387 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_RESTORE
, lParam
);
1391 switch(wParam
) /* Hit test */
1394 /* stop processing if WS_MAXIMIZEBOX is missing */
1395 if (pWnd
->dwStyle
& WS_MAXIMIZEBOX
)
1396 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
,
1397 (pWnd
->dwStyle
& WS_MAXIMIZE
) ? SC_RESTORE
: SC_MAXIMIZE
,
1402 if (!(pWnd
->class->style
& CS_NOCLOSE
))
1403 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_CLOSE
, lParam
);
1410 /***********************************************************************
1411 * NC_HandleSysCommand
1413 * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
1415 LONG
NC_HandleSysCommand( HWND32 hwnd
, WPARAM16 wParam
, POINT16 pt
)
1417 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1420 dprintf_nonclient(stddeb
, "Handling WM_SYSCOMMAND %x %d,%d\n",
1421 wParam
, pt
.x
, pt
.y
);
1423 if (wndPtr
->dwStyle
& WS_CHILD
&& wParam
!= SC_KEYMENU
)
1424 ScreenToClient16( wndPtr
->parent
->hwndSelf
, &pt
);
1426 switch (wParam
& 0xfff0)
1430 NC_DoSizeMove( hwnd
, wParam
, pt
);
1434 ShowWindow32( hwnd
, SW_MINIMIZE
);
1438 ShowWindow32( hwnd
, SW_MAXIMIZE
);
1442 ShowWindow32( hwnd
, SW_RESTORE
);
1446 return SendMessage16( hwnd
, WM_CLOSE
, 0, 0 );
1450 CONV_POINT16TO32( &pt
, &pt32
);
1451 NC_TrackScrollBar( hwnd
, wParam
, pt32
);
1455 CONV_POINT16TO32( &pt
, &pt32
);
1456 MENU_TrackMouseMenuBar( wndPtr
, wParam
& 0x000F, pt32
);
1460 MENU_TrackKbdMenuBar( wndPtr
, wParam
, pt
.x
);
1464 WinExec32( "taskman.exe", SW_SHOWNORMAL
);
1468 if (wParam
== SC_ABOUTWINE
)
1470 extern const char people
[];
1471 ShellAbout32A(hwnd
,"Wine",people
,0);
1479 /* FIXME: unimplemented */