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( HWND hwnd
, RECT16
*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 InflateRect16( rect
, -SYSMETRICS_CXDLGFRAME
, -SYSMETRICS_CYDLGFRAME
);
286 if (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
)
287 InflateRect16( rect
, -1, 0 );
291 if (HAS_THICKFRAME( wndPtr
->dwStyle
))
292 InflateRect16( rect
, -SYSMETRICS_CXFRAME
, -SYSMETRICS_CYFRAME
);
293 if (wndPtr
->dwStyle
& WS_BORDER
)
294 InflateRect16( 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( HWND hwnd
, HDC16 hdc
, BOOL 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( HWND 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
, (IsZoomed(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( HWND 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
, HWND 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
, GetSysColor( COLOR_CAPTIONTEXT
) );
651 else SetTextColor( hdc
, GetSysColor( 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 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 FillRect16( 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 SetCursor( wndPtr
->class->hCursor
);
825 return (LONG
)SetCursor( LoadCursor16( 0, IDC_SIZEWE
) );
829 return (LONG
)SetCursor( LoadCursor16( 0, IDC_SIZENS
) );
833 return (LONG
)SetCursor( LoadCursor16( 0, IDC_SIZENWSE
) );
837 return (LONG
)SetCursor( LoadCursor16( 0, IDC_SIZENESW
) );
840 /* Default cursor: arrow */
841 return (LONG
)SetCursor( LoadCursor16( 0, IDC_ARROW
) );
844 /***********************************************************************
847 BOOL
NC_GetSysPopupPos( WND
* wndPtr
, RECT16
* rect
)
849 if( !wndPtr
->hSysMenu
) return FALSE
;
851 NC_GetInsideRect( wndPtr
->hwndSelf
, rect
);
852 OffsetRect16( rect
, wndPtr
->rectWindow
.left
, wndPtr
->rectWindow
.top
);
853 if (wndPtr
->dwStyle
& WS_CHILD
)
854 ClientToScreen16( wndPtr
->parent
->hwndSelf
, (POINT16
*)rect
);
855 rect
->right
= rect
->left
+ SYSMETRICS_CXSIZE
;
856 rect
->bottom
= rect
->top
+ SYSMETRICS_CYSIZE
;
860 /***********************************************************************
863 * Track a mouse button press on the system menu.
865 static void NC_TrackSysMenu( HWND hwnd
, HDC16 hdc
, POINT16 pt
)
868 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
869 int iconic
= wndPtr
->dwStyle
& WS_MINIMIZE
;
872 if (!(wndPtr
->dwStyle
& WS_SYSMENU
)) return;
874 /* If window has a menu, track the menu bar normally if it not minimized */
875 if (HAS_MENU(wndPtr
) && !iconic
) MENU_TrackMouseMenuBar( hwnd
, pt
);
878 /* Otherwise track the system menu like a normal popup menu */
880 NC_GetSysPopupPos( wndPtr
, &rect
);
881 if (!iconic
) NC_DrawSysButton( hwnd
, hdc
, TRUE
);
882 hmenu
= GetSystemMenu(hwnd
, 0);
883 MENU_InitSysMenuPopup(hmenu
, wndPtr
->dwStyle
,
884 wndPtr
->class->style
);
885 TrackPopupMenu16( hmenu
, TPM_LEFTALIGN
| TPM_LEFTBUTTON
,
886 rect
.left
, rect
.bottom
, 0, hwnd
, &rect
);
887 if (!iconic
) NC_DrawSysButton( hwnd
, hdc
, FALSE
);
892 /***********************************************************************
895 * Initialisation of a move or resize, when initiatied from a menu choice.
896 * Return hit test code for caption or sizing border.
898 static LONG
NC_StartSizeMove( HWND hwnd
, WPARAM16 wParam
, POINT16
*capturePoint
)
903 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
905 if ((wParam
& 0xfff0) == SC_MOVE
)
907 /* Move pointer at the center of the caption */
909 NC_GetInsideRect( hwnd
, &rect
);
910 if (wndPtr
->dwStyle
& WS_SYSMENU
)
911 rect
.left
+= SYSMETRICS_CXSIZE
+ 1;
912 if (wndPtr
->dwStyle
& WS_MINIMIZEBOX
)
913 rect
.right
-= SYSMETRICS_CXSIZE
+ 1;
914 if (wndPtr
->dwStyle
& WS_MAXIMIZEBOX
)
915 rect
.right
-= SYSMETRICS_CXSIZE
+ 1;
916 pt
.x
= wndPtr
->rectWindow
.left
+ (rect
.right
- rect
.left
) / 2;
917 pt
.y
= wndPtr
->rectWindow
.top
+ rect
.top
+ SYSMETRICS_CYSIZE
/2;
918 if (wndPtr
->dwStyle
& WS_CHILD
)
919 ClientToScreen16( wndPtr
->parent
->hwndSelf
, &pt
);
927 MSG_InternalGetMessage( &msg
, 0, 0, MSGF_SIZE
, PM_REMOVE
, FALSE
);
931 hittest
= NC_HandleNCHitTest( hwnd
, msg
.pt
);
933 if ((hittest
< HTLEFT
) || (hittest
> HTBOTTOMRIGHT
))
945 pt
.x
=(wndPtr
->rectWindow
.left
+wndPtr
->rectWindow
.right
)/2;
946 pt
.y
= wndPtr
->rectWindow
.top
+ SYSMETRICS_CYFRAME
/ 2;
950 pt
.x
=(wndPtr
->rectWindow
.left
+wndPtr
->rectWindow
.right
)/2;
951 pt
.y
= wndPtr
->rectWindow
.bottom
- SYSMETRICS_CYFRAME
/ 2;
955 pt
.x
= wndPtr
->rectWindow
.left
+ SYSMETRICS_CXFRAME
/ 2;
956 pt
.y
=(wndPtr
->rectWindow
.top
+wndPtr
->rectWindow
.bottom
)/2;
960 pt
.x
= wndPtr
->rectWindow
.right
- SYSMETRICS_CXFRAME
/ 2;
961 pt
.y
=(wndPtr
->rectWindow
.top
+wndPtr
->rectWindow
.bottom
)/2;
964 case VK_ESCAPE
: return 0;
970 SetCursorPos( capturePoint
->x
, capturePoint
->y
);
971 NC_HandleSetCursor( hwnd
, (WPARAM16
)hwnd
, MAKELONG( hittest
, WM_MOUSEMOVE
));
976 /***********************************************************************
979 * Perform SC_MOVE and SC_SIZE commands.
981 static void NC_DoSizeMove( HWND hwnd
, WORD wParam
, POINT16 pt
)
984 RECT16 sizingRect
, mouseRect
;
986 LONG hittest
= (LONG
)(wParam
& 0x0f);
987 HCURSOR16 hDragCursor
= 0, hOldCursor
= 0;
988 POINT16 minTrack
, maxTrack
, capturePoint
= pt
;
989 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
990 BOOL32 thickframe
= HAS_THICKFRAME( wndPtr
->dwStyle
);
991 BOOL32 iconic
= wndPtr
->dwStyle
& WS_MINIMIZE
;
994 if (IsZoomed(hwnd
) || !IsWindowVisible(hwnd
) ||
995 (wndPtr
->flags
& WIN_MANAGED
)) return;
997 if ((wParam
& 0xfff0) == SC_MOVE
)
999 if (!(wndPtr
->dwStyle
& WS_CAPTION
)) return;
1000 if (!hittest
) hittest
= NC_StartSizeMove( hwnd
, wParam
, &capturePoint
);
1001 if (!hittest
) return;
1005 if (!thickframe
) return;
1006 if (hittest
) hittest
+= HTLEFT
-1;
1010 hittest
= NC_StartSizeMove( hwnd
, wParam
, &capturePoint
);
1019 /* Get min/max info */
1021 NC_GetMinMaxInfo( wndPtr
, NULL
, NULL
, &minTrack
, &maxTrack
);
1022 sizingRect
= wndPtr
->rectWindow
;
1023 if (wndPtr
->dwStyle
& WS_CHILD
)
1024 GetClientRect16( wndPtr
->parent
->hwndSelf
, &mouseRect
);
1025 else SetRect16(&mouseRect
, 0, 0, SYSMETRICS_CXSCREEN
, SYSMETRICS_CYSCREEN
);
1026 if (ON_LEFT_BORDER(hittest
))
1028 mouseRect
.left
= MAX( mouseRect
.left
, sizingRect
.right
-maxTrack
.x
);
1029 mouseRect
.right
= MIN( mouseRect
.right
, sizingRect
.right
-minTrack
.x
);
1031 else if (ON_RIGHT_BORDER(hittest
))
1033 mouseRect
.left
= MAX( mouseRect
.left
, sizingRect
.left
+minTrack
.x
);
1034 mouseRect
.right
= MIN( mouseRect
.right
, sizingRect
.left
+maxTrack
.x
);
1036 if (ON_TOP_BORDER(hittest
))
1038 mouseRect
.top
= MAX( mouseRect
.top
, sizingRect
.bottom
-maxTrack
.y
);
1039 mouseRect
.bottom
= MIN( mouseRect
.bottom
,sizingRect
.bottom
-minTrack
.y
);
1041 else if (ON_BOTTOM_BORDER(hittest
))
1043 mouseRect
.top
= MAX( mouseRect
.top
, sizingRect
.top
+minTrack
.y
);
1044 mouseRect
.bottom
= MIN( mouseRect
.bottom
, sizingRect
.top
+maxTrack
.y
);
1046 SendMessage16( hwnd
, WM_ENTERSIZEMOVE
, 0, 0 );
1048 if (GetCapture32() != hwnd
) SetCapture32( hwnd
);
1050 if (wndPtr
->dwStyle
& WS_CHILD
)
1052 /* Retrieve a default cache DC (without using the window style) */
1053 hdc
= GetDCEx32( wndPtr
->parent
->hwndSelf
, 0, DCX_CACHE
);
1056 { /* Grab the server only when moving top-level windows without desktop */
1058 if (rootWindow
== DefaultRootWindow(display
)) XGrabServer( display
);
1063 HICON16 hIcon
= (wndPtr
->class->hIcon
)
1064 ? wndPtr
->class->hIcon
1065 : (HICON16
)SendMessage16( hwnd
, WM_QUERYDRAGICON
, 0, 0L);
1068 hDragCursor
= CURSORICON_IconToCursor( hIcon
, TRUE
);
1069 hOldCursor
= SetCursor(hDragCursor
);
1071 } else iconic
= FALSE
;
1074 if( !iconic
) NC_DrawMovingFrame( hdc
, &sizingRect
, thickframe
);
1080 MSG_InternalGetMessage( &msg
, 0, 0, MSGF_SIZE
, PM_REMOVE
, FALSE
);
1082 /* Exit on button-up, Return, or Esc */
1083 if ((msg
.message
== WM_LBUTTONUP
) ||
1084 ((msg
.message
== WM_KEYDOWN
) &&
1085 ((msg
.wParam
== VK_RETURN
) || (msg
.wParam
== VK_ESCAPE
)))) break;
1087 if ((msg
.message
!= WM_KEYDOWN
) && (msg
.message
!= WM_MOUSEMOVE
))
1088 continue; /* We are not interested in other messages */
1091 if (wndPtr
->dwStyle
& WS_CHILD
)
1092 ScreenToClient16( wndPtr
->parent
->hwndSelf
, &pt
);
1094 if (msg
.message
== WM_KEYDOWN
) switch(msg
.wParam
)
1096 case VK_UP
: pt
.y
-= 8; break;
1097 case VK_DOWN
: pt
.y
+= 8; break;
1098 case VK_LEFT
: pt
.x
-= 8; break;
1099 case VK_RIGHT
: pt
.x
+= 8; break;
1102 pt
.x
= MAX( pt
.x
, mouseRect
.left
);
1103 pt
.x
= MIN( pt
.x
, mouseRect
.right
);
1104 pt
.y
= MAX( pt
.y
, mouseRect
.top
);
1105 pt
.y
= MIN( pt
.y
, mouseRect
.bottom
);
1107 dx
= pt
.x
- capturePoint
.x
;
1108 dy
= pt
.y
- capturePoint
.y
;
1113 if (msg
.message
== WM_KEYDOWN
) SetCursorPos( pt
.x
, pt
.y
);
1116 RECT16 newRect
= sizingRect
;
1118 if (hittest
== HTCAPTION
) OffsetRect16( &newRect
, dx
, dy
);
1119 if (ON_LEFT_BORDER(hittest
)) newRect
.left
+= dx
;
1120 else if (ON_RIGHT_BORDER(hittest
)) newRect
.right
+= dx
;
1121 if (ON_TOP_BORDER(hittest
)) newRect
.top
+= dy
;
1122 else if (ON_BOTTOM_BORDER(hittest
)) newRect
.bottom
+= dy
;
1125 NC_DrawMovingFrame( hdc
, &sizingRect
, thickframe
);
1126 NC_DrawMovingFrame( hdc
, &newRect
, thickframe
);
1129 sizingRect
= newRect
;
1138 SetCursor(hOldCursor
);
1139 if( hDragCursor
) DestroyCursor(hDragCursor
);
1142 NC_DrawMovingFrame( hdc
, &sizingRect
, thickframe
);
1144 if (wndPtr
->dwStyle
& WS_CHILD
)
1145 ReleaseDC32( wndPtr
->parent
->hwndSelf
, hdc
);
1148 ReleaseDC32( 0, hdc
);
1149 if (rootWindow
== DefaultRootWindow(display
)) XUngrabServer( display
);
1152 if (HOOK_IsHooked( WH_CBT
))
1154 RECT16
* pr
= SEGPTR_NEW(RECT16
);
1158 if( HOOK_CallHooks16( WH_CBT
, HCBT_MOVESIZE
, hwnd
,
1159 (LPARAM
)SEGPTR_GET(pr
)) )
1160 sizingRect
= wndPtr
->rectWindow
;
1166 SendMessage16( hwnd
, WM_EXITSIZEMOVE
, 0, 0 );
1167 SendMessage16( hwnd
, WM_SETVISIBLE
, !IsIconic(hwnd
), 0L);
1169 /* Single click brings up the system menu when iconized */
1171 if (!moved
&& (wndPtr
->dwStyle
& WS_MINIMIZE
))
1173 NC_TrackSysMenu( hwnd
, hdc
, pt
);
1177 /* If Esc key, don't move the window */
1178 if ((msg
.message
== WM_KEYDOWN
) && (msg
.wParam
== VK_ESCAPE
)) return;
1180 if (hittest
!= HTCAPTION
)
1181 SetWindowPos( hwnd
, 0, sizingRect
.left
, sizingRect
.top
,
1182 sizingRect
.right
- sizingRect
.left
,
1183 sizingRect
.bottom
- sizingRect
.top
,
1184 SWP_NOACTIVATE
| SWP_NOZORDER
);
1185 else SetWindowPos( hwnd
, 0, sizingRect
.left
, sizingRect
.top
, 0, 0,
1186 SWP_NOACTIVATE
| SWP_NOSIZE
| SWP_NOZORDER
);
1190 /***********************************************************************
1193 * Track a mouse button press on the minimize or maximize box.
1195 static void NC_TrackMinMaxBox( HWND hwnd
, WORD wParam
)
1198 HDC32 hdc
= GetWindowDC32( hwnd
);
1199 BOOL pressed
= TRUE
;
1201 SetCapture32( hwnd
);
1202 if (wParam
== HTMINBUTTON
) NC_DrawMinButton( hwnd
, hdc
, TRUE
);
1203 else NC_DrawMaxButton( hwnd
, hdc
, TRUE
);
1207 BOOL oldstate
= pressed
;
1208 MSG_InternalGetMessage( &msg
, 0, 0, 0, PM_REMOVE
, FALSE
);
1210 pressed
= (NC_HandleNCHitTest( hwnd
, msg
.pt
) == wParam
);
1211 if (pressed
!= oldstate
)
1213 if (wParam
== HTMINBUTTON
) NC_DrawMinButton( hwnd
, hdc
, pressed
);
1214 else NC_DrawMaxButton( hwnd
, hdc
, pressed
);
1216 } while (msg
.message
!= WM_LBUTTONUP
);
1218 if (wParam
== HTMINBUTTON
) NC_DrawMinButton( hwnd
, hdc
, FALSE
);
1219 else NC_DrawMaxButton( hwnd
, hdc
, FALSE
);
1222 ReleaseDC32( hwnd
, hdc
);
1223 if (!pressed
) return;
1225 if (wParam
== HTMINBUTTON
)
1226 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MINIMIZE
, *(LONG
*)&msg
.pt
);
1228 SendMessage16( hwnd
, WM_SYSCOMMAND
,
1229 IsZoomed(hwnd
) ? SC_RESTORE
: SC_MAXIMIZE
, *(LONG
*)&msg
.pt
);
1233 /***********************************************************************
1236 * Track a mouse button press on the horizontal or vertical scroll-bar.
1238 static void NC_TrackScrollBar( HWND32 hwnd
, WPARAM32 wParam
, POINT32 pt
)
1242 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1244 if ((wParam
& 0xfff0) == SC_HSCROLL
)
1246 if ((wParam
& 0x0f) != HTHSCROLL
) return;
1247 scrollbar
= SB_HORZ
;
1249 else /* SC_VSCROLL */
1251 if ((wParam
& 0x0f) != HTVSCROLL
) return;
1252 scrollbar
= SB_VERT
;
1255 if (!(msg
= SEGPTR_NEW(MSG16
))) return;
1256 pt
.x
-= wndPtr
->rectWindow
.left
;
1257 pt
.y
-= wndPtr
->rectWindow
.top
;
1258 SetCapture32( hwnd
);
1259 SCROLL_HandleScrollEvent( hwnd
, scrollbar
, WM_LBUTTONDOWN
, pt
);
1263 GetMessage( SEGPTR_GET(msg
), 0, 0, 0 );
1264 switch(msg
->message
)
1269 pt
.x
= LOWORD(msg
->lParam
) + wndPtr
->rectClient
.left
-
1270 wndPtr
->rectWindow
.left
;
1271 pt
.y
= HIWORD(msg
->lParam
) + wndPtr
->rectClient
.top
-
1272 wndPtr
->rectWindow
.top
;
1273 SCROLL_HandleScrollEvent( hwnd
, scrollbar
, msg
->message
, pt
);
1276 TranslateMessage( msg
);
1277 DispatchMessage( msg
);
1280 if (!IsWindow( hwnd
))
1285 } while (msg
->message
!= WM_LBUTTONUP
);
1289 /***********************************************************************
1290 * NC_HandleNCLButtonDown
1292 * Handle a WM_NCLBUTTONDOWN message. Called from DefWindowProc().
1294 LONG
NC_HandleNCLButtonDown( HWND32 hwnd
, WPARAM16 wParam
, LPARAM lParam
)
1298 switch(wParam
) /* Hit test */
1301 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MOVE
+ HTCAPTION
, lParam
);
1305 hdc
= GetWindowDC32( hwnd
);
1306 NC_TrackSysMenu( hwnd
, hdc
, MAKEPOINT16(lParam
) );
1307 ReleaseDC32( hwnd
, hdc
);
1311 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MOUSEMENU
, lParam
);
1315 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_HSCROLL
+ HTHSCROLL
, lParam
);
1319 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_VSCROLL
+ HTVSCROLL
, lParam
);
1324 NC_TrackMinMaxBox( hwnd
, wParam
);
1335 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_SIZE
+ wParam
- HTLEFT
+1, lParam
);
1345 /***********************************************************************
1346 * NC_HandleNCLButtonDblClk
1348 * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc().
1350 LONG
NC_HandleNCLButtonDblClk( WND
*pWnd
, WPARAM16 wParam
, LPARAM lParam
)
1353 * if this is an icon, send a restore since we are handling
1356 if (pWnd
->dwStyle
& WS_MINIMIZE
)
1358 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_RESTORE
, lParam
);
1362 switch(wParam
) /* Hit test */
1365 /* stop processing if WS_MAXIMIZEBOX is missing */
1366 if (pWnd
->dwStyle
& WS_MAXIMIZEBOX
)
1367 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
,
1368 (pWnd
->dwStyle
& WS_MAXIMIZE
) ? SC_RESTORE
: SC_MAXIMIZE
,
1373 if (!(pWnd
->class->style
& CS_NOCLOSE
))
1374 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_CLOSE
, lParam
);
1381 /***********************************************************************
1382 * NC_HandleSysCommand
1384 * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
1386 LONG
NC_HandleSysCommand( HWND32 hwnd
, WPARAM16 wParam
, POINT16 pt
)
1388 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1391 dprintf_nonclient(stddeb
, "Handling WM_SYSCOMMAND %x %d,%d\n",
1392 wParam
, pt
.x
, pt
.y
);
1394 if (wndPtr
->dwStyle
& WS_CHILD
&& wParam
!= SC_KEYMENU
)
1395 ScreenToClient16( wndPtr
->parent
->hwndSelf
, &pt
);
1397 switch (wParam
& 0xfff0)
1401 NC_DoSizeMove( hwnd
, wParam
, pt
);
1405 ShowWindow( hwnd
, SW_MINIMIZE
);
1409 ShowWindow( hwnd
, SW_MAXIMIZE
);
1413 ShowWindow( hwnd
, SW_RESTORE
);
1421 return SendMessage16( hwnd
, WM_CLOSE
, 0, 0 );
1425 CONV_POINT16TO32( &pt
, &pt32
);
1426 NC_TrackScrollBar( hwnd
, wParam
, pt32
);
1430 MENU_TrackMouseMenuBar( hwnd
, pt
);
1434 MENU_TrackKbdMenuBar( wndPtr
, wParam
, pt
.x
);
1441 WinExec( "taskman.exe", SW_SHOWNORMAL
);
1448 if (wParam
== SC_ABOUTWINE
)
1450 extern const char people
[];
1451 ShellAbout(hwnd
,"WINE",people
,0);