2 * Non-client area window functions
4 * Copyright 1994 Alexandre Julliard
10 #include "sysmetrics.h"
19 #include "stackframe.h"
20 #include "nonclient.h"
23 #include "selectors.h"
29 static HBITMAP hbitmapClose
= 0;
30 static HBITMAP hbitmapMinimize
= 0;
31 static HBITMAP hbitmapMinimizeD
= 0;
32 static HBITMAP hbitmapMaximize
= 0;
33 static HBITMAP hbitmapMaximizeD
= 0;
34 static HBITMAP hbitmapRestore
= 0;
35 static HBITMAP 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 /***********************************************************************
62 * Compute the size of the window rectangle from the size of the
65 static void NC_AdjustRect(LPRECT16 rect
, DWORD style
, BOOL menu
, DWORD exStyle
)
67 if (style
& WS_ICONIC
) return; /* Nothing to change for an icon */
69 /* Decide if the window will be managed (see CreateWindowEx) */
70 if (!(Options
.managed
&& !(style
& WS_CHILD
) &&
71 ((style
& (WS_DLGFRAME
| WS_THICKFRAME
)) ||
72 (exStyle
& WS_EX_DLGMODALFRAME
))))
74 if (HAS_DLGFRAME( style
, exStyle
))
75 InflateRect16(rect
, SYSMETRICS_CXDLGFRAME
, SYSMETRICS_CYDLGFRAME
);
78 if (HAS_THICKFRAME(style
))
79 InflateRect16( rect
, SYSMETRICS_CXFRAME
, SYSMETRICS_CYFRAME
);
80 if (style
& WS_BORDER
)
81 InflateRect16( rect
, SYSMETRICS_CXBORDER
, SYSMETRICS_CYBORDER
);
84 if ((style
& WS_CAPTION
) == WS_CAPTION
)
85 rect
->top
-= SYSMETRICS_CYCAPTION
- SYSMETRICS_CYBORDER
;
87 if (menu
) rect
->top
-= SYSMETRICS_CYMENU
+ SYSMETRICS_CYBORDER
;
89 if (style
& WS_VSCROLL
) rect
->right
+= SYSMETRICS_CXVSCROLL
;
90 if (style
& WS_HSCROLL
) rect
->bottom
+= SYSMETRICS_CYHSCROLL
;
94 /***********************************************************************
95 * AdjustWindowRect16 (USER.102)
97 BOOL16
AdjustWindowRect16( LPRECT16 rect
, DWORD style
, BOOL16 menu
)
99 return AdjustWindowRectEx16( rect
, style
, menu
, 0 );
103 /***********************************************************************
104 * AdjustWindowRect32 (USER32.)
106 BOOL32
AdjustWindowRect32( LPRECT32 rect
, DWORD style
, BOOL32 menu
)
108 return AdjustWindowRectEx32( rect
, style
, menu
, 0 );
112 /***********************************************************************
113 * AdjustWindowRectEx16 (USER.454)
115 BOOL16
AdjustWindowRectEx16( LPRECT16 rect
, DWORD style
,
116 BOOL16 menu
, DWORD exStyle
)
118 /* Correct the window style */
120 if (!(style
& (WS_POPUP
| WS_CHILD
))) /* Overlapped window */
122 if (exStyle
& WS_EX_DLGMODALFRAME
) style
&= ~WS_THICKFRAME
;
124 dprintf_nonclient(stddeb
, "AdjustWindowRectEx: (%d,%d)-(%d,%d) %08lx %d %08lx\n",
125 rect
->left
, rect
->top
, rect
->right
, rect
->bottom
,
126 style
, menu
, exStyle
);
128 NC_AdjustRect( rect
, style
, menu
, exStyle
);
133 /***********************************************************************
134 * AdjustWindowRectEx32 (USER32.)
136 BOOL32
AdjustWindowRectEx32( LPRECT32 rect
, DWORD style
,
137 BOOL32 menu
, DWORD exStyle
)
142 CONV_RECT32TO16( rect
, &rect16
);
143 ret
= AdjustWindowRectEx16( &rect16
, style
, (BOOL16
)menu
, exStyle
);
144 CONV_RECT16TO32( &rect16
, rect
);
149 /*******************************************************************
152 * Get the minimized and maximized information for a window.
154 void NC_GetMinMaxInfo( HWND hwnd
, POINT16
*maxSize
, POINT16
*maxPos
,
155 POINT16
*minTrack
, POINT16
*maxTrack
)
157 MINMAXINFO16
*MinMax
;
159 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
161 if (!(MinMax
= SEGPTR_NEW(MINMAXINFO16
))) return;
163 /* Compute default values */
165 MinMax
->ptMaxSize
.x
= SYSMETRICS_CXSCREEN
;
166 MinMax
->ptMaxSize
.y
= SYSMETRICS_CYSCREEN
;
167 MinMax
->ptMinTrackSize
.x
= SYSMETRICS_CXMINTRACK
;
168 MinMax
->ptMinTrackSize
.y
= SYSMETRICS_CYMINTRACK
;
169 MinMax
->ptMaxTrackSize
.x
= SYSMETRICS_CXSCREEN
;
170 MinMax
->ptMaxTrackSize
.y
= SYSMETRICS_CYSCREEN
;
172 if (wndPtr
->flags
& WIN_MANAGED
) xinc
= yinc
= 0;
173 else if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
175 xinc
= SYSMETRICS_CXDLGFRAME
;
176 yinc
= SYSMETRICS_CYDLGFRAME
;
181 if (HAS_THICKFRAME(wndPtr
->dwStyle
))
183 xinc
+= SYSMETRICS_CXFRAME
;
184 yinc
+= SYSMETRICS_CYFRAME
;
186 if (wndPtr
->dwStyle
& WS_BORDER
)
188 xinc
+= SYSMETRICS_CXBORDER
;
189 yinc
+= SYSMETRICS_CYBORDER
;
192 MinMax
->ptMaxSize
.x
+= 2 * xinc
;
193 MinMax
->ptMaxSize
.y
+= 2 * yinc
;
195 /* Note: The '+' in the following test should really be a ||, but
196 * that would cause gcc-2.7.0 to generate incorrect code.
198 if ((wndPtr
->ptMaxPos
.x
!= -1) + (wndPtr
->ptMaxPos
.y
!= -1))
199 MinMax
->ptMaxPosition
= wndPtr
->ptMaxPos
;
202 MinMax
->ptMaxPosition
.x
= -xinc
;
203 MinMax
->ptMaxPosition
.y
= -yinc
;
206 SendMessage16( hwnd
, WM_GETMINMAXINFO
, 0, (LPARAM
)SEGPTR_GET(MinMax
) );
208 /* Some sanity checks */
210 dprintf_nonclient(stddeb
,
211 "NC_GetMinMaxInfo: %d %d / %d %d / %d %d / %d %d\n",
212 MinMax
->ptMaxSize
.x
, MinMax
->ptMaxSize
.y
,
213 MinMax
->ptMaxPosition
.x
, MinMax
->ptMaxPosition
.y
,
214 MinMax
->ptMaxTrackSize
.x
, MinMax
->ptMaxTrackSize
.y
,
215 MinMax
->ptMinTrackSize
.x
, MinMax
->ptMinTrackSize
.y
);
216 MinMax
->ptMaxTrackSize
.x
= MAX( MinMax
->ptMaxTrackSize
.x
,
217 MinMax
->ptMinTrackSize
.x
);
218 MinMax
->ptMaxTrackSize
.y
= MAX( MinMax
->ptMaxTrackSize
.y
,
219 MinMax
->ptMinTrackSize
.y
);
221 if (maxSize
) *maxSize
= MinMax
->ptMaxSize
;
222 if (maxPos
) *maxPos
= MinMax
->ptMaxPosition
;
223 if (minTrack
) *minTrack
= MinMax
->ptMinTrackSize
;
224 if (maxTrack
) *maxTrack
= MinMax
->ptMaxTrackSize
;
229 /***********************************************************************
230 * NC_HandleNCCalcSize
232 * Handle a WM_NCCALCSIZE message. Called from DefWindowProc().
234 LONG
NC_HandleNCCalcSize( WND
*pWnd
, RECT16
*winRect
)
236 RECT16 tmpRect
= { 0, 0, 0, 0 };
238 NC_AdjustRect( &tmpRect
, pWnd
->dwStyle
, FALSE
, pWnd
->dwExStyle
);
239 winRect
->left
-= tmpRect
.left
;
240 winRect
->top
-= tmpRect
.top
;
241 winRect
->right
-= tmpRect
.right
;
242 winRect
->bottom
-= tmpRect
.bottom
;
246 winRect
->top
+= MENU_GetMenuBarHeight( pWnd
->hwndSelf
,
247 winRect
->right
- winRect
->left
,
248 -tmpRect
.left
, -tmpRect
.top
) + 1;
254 /***********************************************************************
257 * Get the 'inside' rectangle of a window, i.e. the whole window rectangle
258 * but without the borders (if any).
259 * The rectangle is in window coordinates (for drawing with GetWindowDC()).
261 static void NC_GetInsideRect( HWND hwnd
, RECT16
*rect
)
263 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
265 rect
->top
= rect
->left
= 0;
266 rect
->right
= wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
;
267 rect
->bottom
= wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
;
269 if (wndPtr
->dwStyle
& WS_ICONIC
) return; /* No border to remove */
270 if (wndPtr
->flags
& WIN_MANAGED
) return;
272 /* Remove frame from rectangle */
273 if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
275 InflateRect16( rect
, -SYSMETRICS_CXDLGFRAME
, -SYSMETRICS_CYDLGFRAME
);
276 if (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
)
277 InflateRect16( rect
, -1, 0 );
281 if (HAS_THICKFRAME( wndPtr
->dwStyle
))
282 InflateRect16( rect
, -SYSMETRICS_CXFRAME
, -SYSMETRICS_CYFRAME
);
283 if (wndPtr
->dwStyle
& WS_BORDER
)
284 InflateRect16( rect
, -SYSMETRICS_CXBORDER
, -SYSMETRICS_CYBORDER
);
289 /***********************************************************************
292 * Handle a WM_NCHITTEST message. Called from DefWindowProc().
294 LONG
NC_HandleNCHitTest( HWND hwnd
, POINT16 pt
)
297 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
298 if (!wndPtr
) return HTERROR
;
300 dprintf_nonclient(stddeb
, "NC_HandleNCHitTest: hwnd=%04x pt=%d,%d\n",
303 GetWindowRect16( hwnd
, &rect
);
304 if (!PtInRect16( &rect
, pt
)) return HTNOWHERE
;
306 if (wndPtr
->dwStyle
& WS_MINIMIZE
) return HTCAPTION
;
308 if (!(wndPtr
->flags
& WIN_MANAGED
))
311 if (HAS_THICKFRAME( wndPtr
->dwStyle
))
313 InflateRect16( &rect
, -SYSMETRICS_CXFRAME
, -SYSMETRICS_CYFRAME
);
314 if (wndPtr
->dwStyle
& WS_BORDER
)
315 InflateRect16(&rect
,-SYSMETRICS_CXBORDER
,-SYSMETRICS_CYBORDER
);
316 if (!PtInRect16( &rect
, pt
))
318 /* Check top sizing border */
321 if (pt
.x
< rect
.left
+SYSMETRICS_CXSIZE
) return HTTOPLEFT
;
322 if (pt
.x
>= rect
.right
-SYSMETRICS_CXSIZE
) return HTTOPRIGHT
;
325 /* Check bottom sizing border */
326 if (pt
.y
>= rect
.bottom
)
328 if (pt
.x
< rect
.left
+SYSMETRICS_CXSIZE
) return HTBOTTOMLEFT
;
329 if (pt
.x
>= rect
.right
-SYSMETRICS_CXSIZE
) return HTBOTTOMRIGHT
;
332 /* Check left sizing border */
333 if (pt
.x
< rect
.left
)
335 if (pt
.y
< rect
.top
+SYSMETRICS_CYSIZE
) return HTTOPLEFT
;
336 if (pt
.y
>= rect
.bottom
-SYSMETRICS_CYSIZE
) return HTBOTTOMLEFT
;
339 /* Check right sizing border */
340 if (pt
.x
>= rect
.right
)
342 if (pt
.y
< rect
.top
+SYSMETRICS_CYSIZE
) return HTTOPRIGHT
;
343 if (pt
.y
>= rect
.bottom
-SYSMETRICS_CYSIZE
) return HTBOTTOMRIGHT
;
348 else /* No thick frame */
350 if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
351 InflateRect16(&rect
, -SYSMETRICS_CXDLGFRAME
, -SYSMETRICS_CYDLGFRAME
);
352 else if (wndPtr
->dwStyle
& WS_BORDER
)
353 InflateRect16(&rect
, -SYSMETRICS_CXBORDER
, -SYSMETRICS_CYBORDER
);
354 if (!PtInRect16( &rect
, pt
)) return HTBORDER
;
359 if ((wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
361 rect
.top
+= SYSMETRICS_CYCAPTION
- 1;
362 if (!PtInRect16( &rect
, pt
))
364 /* Check system menu */
365 if (wndPtr
->dwStyle
& WS_SYSMENU
)
366 rect
.left
+= SYSMETRICS_CXSIZE
;
367 if (pt
.x
<= rect
.left
) return HTSYSMENU
;
368 /* Check maximize box */
369 if (wndPtr
->dwStyle
& WS_MAXIMIZEBOX
)
370 rect
.right
-= SYSMETRICS_CXSIZE
+ 1;
371 if (pt
.x
>= rect
.right
) return HTMAXBUTTON
;
372 /* Check minimize box */
373 if (wndPtr
->dwStyle
& WS_MINIMIZEBOX
)
374 rect
.right
-= SYSMETRICS_CXSIZE
+ 1;
375 if (pt
.x
>= rect
.right
) return HTMINBUTTON
;
381 /* Check client area */
383 ScreenToClient16( hwnd
, &pt
);
384 GetClientRect16( hwnd
, &rect
);
385 if (PtInRect16( &rect
, pt
)) return HTCLIENT
;
387 /* Check vertical scroll bar */
389 if (wndPtr
->dwStyle
& WS_VSCROLL
)
391 rect
.right
+= SYSMETRICS_CXVSCROLL
;
392 if (PtInRect16( &rect
, pt
)) return HTVSCROLL
;
395 /* Check horizontal scroll bar */
397 if (wndPtr
->dwStyle
& WS_HSCROLL
)
399 rect
.bottom
+= SYSMETRICS_CYHSCROLL
;
400 if (PtInRect16( &rect
, pt
))
403 if ((wndPtr
->dwStyle
& WS_VSCROLL
) &&
404 (pt
.x
>= rect
.right
- SYSMETRICS_CXVSCROLL
))
412 if (HAS_MENU(wndPtr
))
414 if ((pt
.y
< 0) && (pt
.x
>= 0) && (pt
.x
< rect
.right
))
418 /* Should never get here */
423 /***********************************************************************
426 void NC_DrawSysButton( HWND hwnd
, HDC hdc
, BOOL down
)
431 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
433 NC_GetInsideRect( hwnd
, &rect
);
434 hdcMem
= CreateCompatibleDC( hdc
);
435 hbitmap
= SelectObject( hdcMem
, hbitmapClose
);
436 BitBlt( hdc
, rect
.left
, rect
.top
, SYSMETRICS_CXSIZE
, SYSMETRICS_CYSIZE
,
437 hdcMem
, (wndPtr
->dwStyle
& WS_CHILD
) ? SYSMETRICS_CXSIZE
: 0, 0,
438 down
? NOTSRCCOPY
: SRCCOPY
);
439 SelectObject( hdcMem
, hbitmap
);
444 /***********************************************************************
447 static void NC_DrawMaxButton( HWND hwnd
, HDC hdc
, BOOL down
)
450 NC_GetInsideRect( hwnd
, &rect
);
451 GRAPH_DrawBitmap( hdc
, (IsZoomed(hwnd
) ?
452 (down
? hbitmapRestoreD
: hbitmapRestore
) :
453 (down
? hbitmapMaximizeD
: hbitmapMaximize
)),
454 rect
.right
- SYSMETRICS_CXSIZE
- 1, rect
.top
,
455 0, 0, SYSMETRICS_CXSIZE
+1, SYSMETRICS_CYSIZE
);
459 /***********************************************************************
462 static void NC_DrawMinButton( HWND hwnd
, HDC hdc
, BOOL down
)
465 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
466 NC_GetInsideRect( hwnd
, &rect
);
467 if (wndPtr
->dwStyle
& WS_MAXIMIZEBOX
) rect
.right
-= SYSMETRICS_CXSIZE
+ 1;
468 GRAPH_DrawBitmap( hdc
, (down
? hbitmapMinimizeD
: hbitmapMinimize
),
469 rect
.right
- SYSMETRICS_CXSIZE
- 1, rect
.top
,
470 0, 0, SYSMETRICS_CXSIZE
+1, SYSMETRICS_CYSIZE
);
474 /***********************************************************************
477 * Draw a window frame inside the given rectangle, and update the rectangle.
478 * The correct pen for the frame must be selected in the DC.
480 static void NC_DrawFrame( HDC hdc
, RECT16
*rect
, BOOL dlgFrame
, BOOL active
)
482 short width
, height
, tmp
;
486 width
= SYSMETRICS_CXDLGFRAME
- 1;
487 height
= SYSMETRICS_CYDLGFRAME
- 1;
488 SelectObject( hdc
, active
? sysColorObjects
.hbrushActiveCaption
:
489 sysColorObjects
.hbrushInactiveCaption
);
493 width
= SYSMETRICS_CXFRAME
- 1;
494 height
= SYSMETRICS_CYFRAME
- 1;
495 SelectObject( hdc
, active
? sysColorObjects
.hbrushActiveBorder
:
496 sysColorObjects
.hbrushInactiveBorder
);
500 PatBlt( hdc
, rect
->left
, rect
->top
,
501 rect
->right
- rect
->left
, height
, PATCOPY
);
502 PatBlt( hdc
, rect
->left
, rect
->top
,
503 width
, rect
->bottom
- rect
->top
, PATCOPY
);
504 PatBlt( hdc
, rect
->left
, rect
->bottom
,
505 rect
->right
- rect
->left
, -height
, PATCOPY
);
506 PatBlt( hdc
, rect
->right
, rect
->top
,
507 -width
, rect
->bottom
- rect
->top
, PATCOPY
);
511 InflateRect16( rect
, -width
, -height
);
515 /* Draw inner rectangle */
516 MoveTo( hdc
, rect
->left
+width
, rect
->top
+height
);
517 LineTo( hdc
, rect
->right
-width
-1, rect
->top
+height
);
518 LineTo( hdc
, rect
->right
-width
-1, rect
->bottom
-height
-1 );
519 LineTo( hdc
, rect
->left
+width
, rect
->bottom
-height
-1 );
520 LineTo( hdc
, rect
->left
+width
, rect
->top
+height
);
522 /* Draw the decorations */
523 tmp
= rect
->top
+ SYSMETRICS_CYFRAME
+ SYSMETRICS_CYSIZE
;
524 MoveTo( hdc
, rect
->left
, tmp
);
525 LineTo( hdc
, rect
->left
+width
, tmp
);
526 MoveTo( hdc
, rect
->right
-width
-1, tmp
);
527 LineTo( hdc
, rect
->right
-1, tmp
);
529 tmp
= rect
->bottom
- 1 - SYSMETRICS_CYFRAME
- SYSMETRICS_CYSIZE
;
530 MoveTo( hdc
, rect
->left
, tmp
);
531 LineTo( hdc
, rect
->left
+width
, tmp
);
532 MoveTo( hdc
, rect
->right
-width
-1, tmp
);
533 LineTo( hdc
, rect
->right
-1, tmp
);
535 tmp
= rect
->left
+ SYSMETRICS_CXFRAME
+ SYSMETRICS_CXSIZE
;
536 MoveTo( hdc
, tmp
, rect
->top
);
537 LineTo( hdc
, tmp
, rect
->top
+height
);
538 MoveTo( hdc
, tmp
, rect
->bottom
-height
-1 );
539 LineTo( hdc
, tmp
, rect
->bottom
-1 );
541 tmp
= rect
->right
- 1 - SYSMETRICS_CXFRAME
- SYSMETRICS_CYSIZE
;
542 MoveTo( hdc
, tmp
, rect
->top
);
543 LineTo( hdc
, tmp
, rect
->top
+height
);
544 MoveTo( hdc
, tmp
, rect
->bottom
-height
-1 );
545 LineTo( hdc
, tmp
, rect
->bottom
-1 );
547 InflateRect16( rect
, -width
-1, -height
-1 );
551 /***********************************************************************
554 * Draw the frame used when moving or resizing window.
556 static void NC_DrawMovingFrame( HDC hdc
, RECT16
*rect
, BOOL thickframe
)
560 SelectObject( hdc
, GetStockObject( GRAY_BRUSH
) );
561 PatBlt( hdc
, rect
->left
, rect
->top
,
562 rect
->right
- rect
->left
- SYSMETRICS_CXFRAME
,
563 SYSMETRICS_CYFRAME
, PATINVERT
);
564 PatBlt( hdc
, rect
->left
, rect
->top
+ SYSMETRICS_CYFRAME
,
566 rect
->bottom
- rect
->top
- SYSMETRICS_CYFRAME
, PATINVERT
);
567 PatBlt( hdc
, rect
->left
+ SYSMETRICS_CXFRAME
, rect
->bottom
,
568 rect
->right
- rect
->left
- SYSMETRICS_CXFRAME
,
569 -SYSMETRICS_CYFRAME
, PATINVERT
);
570 PatBlt( hdc
, rect
->right
, rect
->top
, -SYSMETRICS_CXFRAME
,
571 rect
->bottom
- rect
->top
- SYSMETRICS_CYFRAME
, PATINVERT
);
573 else DrawFocusRect16( hdc
, rect
);
577 /***********************************************************************
580 * Draw the window caption.
581 * The correct pen for the window frame must be selected in the DC.
583 static void NC_DrawCaption( HDC hdc
, RECT16
*rect
, HWND hwnd
,
584 DWORD style
, BOOL active
)
587 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
592 if (!(hbitmapClose
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_CLOSE
) )))
594 hbitmapMinimize
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_REDUCE
) );
595 hbitmapMinimizeD
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_REDUCED
) );
596 hbitmapMaximize
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_ZOOM
) );
597 hbitmapMaximizeD
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_ZOOMD
) );
598 hbitmapRestore
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_RESTORE
) );
599 hbitmapRestoreD
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_RESTORED
) );
602 if (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
)
604 HBRUSH hbrushOld
= SelectObject( hdc
, sysColorObjects
.hbrushWindow
);
605 PatBlt( hdc
, r
.left
, r
.top
, 1, r
.bottom
-r
.top
+1,PATCOPY
);
606 PatBlt( hdc
, r
.right
-1, r
.top
, 1, r
.bottom
-r
.top
+1, PATCOPY
);
607 PatBlt( hdc
, r
.left
, r
.top
-1, r
.right
-r
.left
, 1, PATCOPY
);
610 SelectObject( hdc
, hbrushOld
);
613 MoveTo( hdc
, r
.left
, r
.bottom
);
614 LineTo( hdc
, r
.right
-1, r
.bottom
);
616 if (style
& WS_SYSMENU
)
618 NC_DrawSysButton( hwnd
, hdc
, FALSE
);
619 r
.left
+= SYSMETRICS_CXSIZE
+ 1;
620 MoveTo( hdc
, r
.left
- 1, r
.top
);
621 LineTo( hdc
, r
.left
- 1, r
.bottom
);
623 if (style
& WS_MAXIMIZEBOX
)
625 NC_DrawMaxButton( hwnd
, hdc
, FALSE
);
626 r
.right
-= SYSMETRICS_CXSIZE
+ 1;
628 if (style
& WS_MINIMIZEBOX
)
630 NC_DrawMinButton( hwnd
, hdc
, FALSE
);
631 r
.right
-= SYSMETRICS_CXSIZE
+ 1;
634 FillRect16( hdc
, &r
, active
? sysColorObjects
.hbrushActiveCaption
:
635 sysColorObjects
.hbrushInactiveCaption
);
637 if (GetWindowText32A( hwnd
, buffer
, sizeof(buffer
) ))
639 if (active
) SetTextColor( hdc
, GetSysColor( COLOR_CAPTIONTEXT
) );
640 else SetTextColor( hdc
, GetSysColor( COLOR_INACTIVECAPTIONTEXT
) );
641 SetBkMode( hdc
, TRANSPARENT
);
642 DrawText16( hdc
, buffer
, -1, &r
,
643 DT_SINGLELINE
| DT_CENTER
| DT_VCENTER
| DT_NOPREFIX
);
648 /***********************************************************************
651 * Paint the non-client area. clip is currently unused.
653 void NC_DoNCPaint( HWND hwnd
, HRGN clip
, BOOL suppress_menupaint
)
659 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
661 if (!wndPtr
|| !(wndPtr
->dwStyle
& WS_VISIBLE
)) return; /* Nothing to do */
663 active
= wndPtr
->flags
& WIN_NCACTIVATED
;
665 dprintf_nonclient(stddeb
, "NC_DoNCPaint: %04x %d\n", hwnd
, active
);
667 if (!(hdc
= GetDCEx( hwnd
, 0, DCX_USESTYLE
| DCX_WINDOW
))) return;
670 * If this is an icon, we don't want to do any more nonclient painting
671 * of the window manager.
672 * If there is a class icon to draw, draw it
676 if (wndPtr
->class->hIcon
)
678 SendMessage16(hwnd
, WM_ICONERASEBKGND
, (WPARAM
)hdc
, 0);
679 DrawIcon( hdc
, 0, 0, wndPtr
->class->hIcon
);
681 ReleaseDC(hwnd
, hdc
);
682 wndPtr
->flags
&= ~WIN_INTERNAL_PAINT
;
683 if( wndPtr
->hrgnUpdate
)
685 DeleteObject( wndPtr
->hrgnUpdate
);
686 QUEUE_DecPaintCount( wndPtr
->hmemTaskQ
);
687 wndPtr
->hrgnUpdate
= 0;
692 if (ExcludeVisRect( hdc
, wndPtr
->rectClient
.left
-wndPtr
->rectWindow
.left
,
693 wndPtr
->rectClient
.top
-wndPtr
->rectWindow
.top
,
694 wndPtr
->rectClient
.right
-wndPtr
->rectWindow
.left
,
695 wndPtr
->rectClient
.bottom
-wndPtr
->rectWindow
.top
)
698 ReleaseDC( hwnd
, hdc
);
702 rect
.top
= rect
.left
= 0;
703 rect
.right
= wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
;
704 rect
.bottom
= wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
;
706 SelectObject( hdc
, sysColorObjects
.hpenWindowFrame
);
708 if (!(wndPtr
->flags
& WIN_MANAGED
))
710 if ((wndPtr
->dwStyle
& WS_BORDER
) || (wndPtr
->dwStyle
& WS_DLGFRAME
) ||
711 (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
))
714 LineTo( hdc
, rect
.right
-1, 0 );
715 LineTo( hdc
, rect
.right
-1, rect
.bottom
-1 );
716 LineTo( hdc
, 0, rect
.bottom
-1 );
718 InflateRect16( &rect
, -1, -1 );
721 if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
722 NC_DrawFrame( hdc
, &rect
, TRUE
, active
);
723 else if (wndPtr
->dwStyle
& WS_THICKFRAME
)
724 NC_DrawFrame(hdc
, &rect
, FALSE
, active
);
726 if ((wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
729 r
.bottom
= rect
.top
+ SYSMETRICS_CYSIZE
;
730 rect
.top
+= SYSMETRICS_CYSIZE
+ SYSMETRICS_CYBORDER
;
731 NC_DrawCaption( hdc
, &r
, hwnd
, wndPtr
->dwStyle
, active
);
735 if (HAS_MENU(wndPtr
))
738 r
.bottom
= rect
.top
+ SYSMETRICS_CYMENU
; /* default height */
739 rect
.top
+= MENU_DrawMenuBar( hdc
, &r
, hwnd
, suppress_menupaint
);
742 /* Draw the scroll-bars */
744 if (wndPtr
->dwStyle
& WS_VSCROLL
) SCROLL_DrawScrollBar(hwnd
, hdc
, SB_VERT
);
745 if (wndPtr
->dwStyle
& WS_HSCROLL
) SCROLL_DrawScrollBar(hwnd
, hdc
, SB_HORZ
);
747 /* Draw the "size-box" */
749 if ((wndPtr
->dwStyle
& WS_VSCROLL
) && (wndPtr
->dwStyle
& WS_HSCROLL
))
752 r
.left
= r
.right
- SYSMETRICS_CXVSCROLL
+ 1;
753 r
.top
= r
.bottom
- SYSMETRICS_CYHSCROLL
+ 1;
754 FillRect16( hdc
, &r
, sysColorObjects
.hbrushScrollbar
);
757 ReleaseDC( hwnd
, hdc
);
762 /***********************************************************************
765 * Handle a WM_NCPAINT message. Called from DefWindowProc().
767 LONG
NC_HandleNCPaint( HWND hwnd
, HRGN clip
)
769 NC_DoNCPaint( hwnd
, clip
, FALSE
);
774 /***********************************************************************
775 * NC_HandleNCActivate
777 * Handle a WM_NCACTIVATE message. Called from DefWindowProc().
779 LONG
NC_HandleNCActivate( HWND hwnd
, WPARAM wParam
)
781 WND
*wndPtr
= WIN_FindWndPtr(hwnd
);
783 if (wParam
!= 0) wndPtr
->flags
|= WIN_NCACTIVATED
;
784 else wndPtr
->flags
&= ~WIN_NCACTIVATED
;
786 NC_DoNCPaint( hwnd
, (HRGN
)1, FALSE
);
791 /***********************************************************************
794 * Handle a WM_SETCURSOR message. Called from DefWindowProc().
796 LONG
NC_HandleSetCursor( HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
798 if (hwnd
!= (HWND
)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
) );
845 /***********************************************************************
848 * Track a mouse button press on the system menu.
850 static void NC_TrackSysMenu( HWND hwnd
, HDC hdc
, POINT16 pt
)
853 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
854 int iconic
= wndPtr
->dwStyle
& WS_MINIMIZE
;
856 if (!(wndPtr
->dwStyle
& WS_SYSMENU
)) return;
857 /* If window has a menu, track the menu bar normally if it not minimized */
858 if (HAS_MENU(wndPtr
) && !iconic
) MENU_TrackMouseMenuBar( hwnd
, pt
);
861 /* Otherwise track the system menu like a normal popup menu */
862 NC_GetInsideRect( hwnd
, &rect
);
863 OffsetRect16( &rect
, wndPtr
->rectWindow
.left
, wndPtr
->rectWindow
.top
);
864 if (wndPtr
->dwStyle
& WS_CHILD
)
865 ClientToScreen16( wndPtr
->parent
->hwndSelf
, (POINT16
*)&rect
);
866 rect
.right
= rect
.left
+ SYSMETRICS_CXSIZE
;
867 rect
.bottom
= rect
.top
+ SYSMETRICS_CYSIZE
;
868 if (!iconic
) NC_DrawSysButton( hwnd
, hdc
, TRUE
);
869 TrackPopupMenu16( wndPtr
->hSysMenu
, TPM_LEFTALIGN
| TPM_LEFTBUTTON
,
870 rect
.left
, rect
.bottom
, 0, hwnd
, &rect
);
871 if (!iconic
) NC_DrawSysButton( hwnd
, hdc
, FALSE
);
876 /***********************************************************************
879 * Initialisation of a move or resize, when initiatied from a menu choice.
880 * Return hit test code for caption or sizing border.
882 static LONG
NC_StartSizeMove( HWND hwnd
, WPARAM wParam
, POINT16
*capturePoint
)
887 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
889 if ((wParam
& 0xfff0) == SC_MOVE
)
891 /* Move pointer at the center of the caption */
893 NC_GetInsideRect( hwnd
, &rect
);
894 if (wndPtr
->dwStyle
& WS_SYSMENU
)
895 rect
.left
+= SYSMETRICS_CXSIZE
+ 1;
896 if (wndPtr
->dwStyle
& WS_MINIMIZEBOX
)
897 rect
.right
-= SYSMETRICS_CXSIZE
+ 1;
898 if (wndPtr
->dwStyle
& WS_MAXIMIZEBOX
)
899 rect
.right
-= SYSMETRICS_CXSIZE
+ 1;
900 pt
.x
= wndPtr
->rectWindow
.left
+ (rect
.right
- rect
.left
) / 2;
901 pt
.y
= wndPtr
->rectWindow
.top
+ rect
.top
+ SYSMETRICS_CYSIZE
/2;
902 if (wndPtr
->dwStyle
& WS_CHILD
)
903 ClientToScreen16( wndPtr
->parent
->hwndSelf
, &pt
);
911 MSG_InternalGetMessage( MAKE_SEGPTR(&msg
), 0, 0, MSGF_SIZE
,
916 hittest
= NC_HandleNCHitTest( hwnd
, msg
.pt
);
918 if ((hittest
< HTLEFT
) || (hittest
> HTBOTTOMRIGHT
))
930 pt
.x
=(wndPtr
->rectWindow
.left
+wndPtr
->rectWindow
.right
)/2;
931 pt
.y
= wndPtr
->rectWindow
.top
+ SYSMETRICS_CYFRAME
/ 2;
935 pt
.x
=(wndPtr
->rectWindow
.left
+wndPtr
->rectWindow
.right
)/2;
936 pt
.y
= wndPtr
->rectWindow
.bottom
- SYSMETRICS_CYFRAME
/ 2;
940 pt
.x
= wndPtr
->rectWindow
.left
+ SYSMETRICS_CXFRAME
/ 2;
941 pt
.y
=(wndPtr
->rectWindow
.top
+wndPtr
->rectWindow
.bottom
)/2;
945 pt
.x
= wndPtr
->rectWindow
.right
- SYSMETRICS_CXFRAME
/ 2;
946 pt
.y
=(wndPtr
->rectWindow
.top
+wndPtr
->rectWindow
.bottom
)/2;
949 case VK_ESCAPE
: return 0;
955 SetCursorPos( capturePoint
->x
, capturePoint
->y
);
956 NC_HandleSetCursor( hwnd
, (WPARAM
)hwnd
, MAKELONG( hittest
, WM_MOUSEMOVE
));
961 /***********************************************************************
964 * Perform SC_MOVE and SC_SIZE commands.
966 static void NC_DoSizeMove( HWND hwnd
, WORD wParam
, POINT16 pt
)
970 RECT16 sizingRect
, mouseRect
;
973 POINT16 minTrack
, maxTrack
, capturePoint
= pt
;
974 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
977 if (IsZoomed(hwnd
) || !IsWindowVisible(hwnd
) ||
978 (wndPtr
->flags
& WIN_MANAGED
)) return;
979 hittest
= wParam
& 0x0f;
980 thickframe
= HAS_THICKFRAME( wndPtr
->dwStyle
);
982 if ((wParam
& 0xfff0) == SC_MOVE
)
984 if (!(wndPtr
->dwStyle
& WS_CAPTION
)) return;
985 if (!hittest
) hittest
= NC_StartSizeMove( hwnd
, wParam
, &capturePoint
);
986 if (!hittest
) return;
990 if (!thickframe
) return;
991 if (hittest
) hittest
+= HTLEFT
-1;
995 hittest
= NC_StartSizeMove( hwnd
, wParam
, &capturePoint
);
1004 /* Get min/max info */
1006 NC_GetMinMaxInfo( hwnd
, NULL
, NULL
, &minTrack
, &maxTrack
);
1007 sizingRect
= wndPtr
->rectWindow
;
1008 if (wndPtr
->dwStyle
& WS_CHILD
)
1009 GetClientRect16( wndPtr
->parent
->hwndSelf
, &mouseRect
);
1010 else SetRect16(&mouseRect
, 0, 0, SYSMETRICS_CXSCREEN
, SYSMETRICS_CYSCREEN
);
1011 if (ON_LEFT_BORDER(hittest
))
1013 mouseRect
.left
= MAX( mouseRect
.left
, sizingRect
.right
-maxTrack
.x
);
1014 mouseRect
.right
= MIN( mouseRect
.right
, sizingRect
.right
-minTrack
.x
);
1016 else if (ON_RIGHT_BORDER(hittest
))
1018 mouseRect
.left
= MAX( mouseRect
.left
, sizingRect
.left
+minTrack
.x
);
1019 mouseRect
.right
= MIN( mouseRect
.right
, sizingRect
.left
+maxTrack
.x
);
1021 if (ON_TOP_BORDER(hittest
))
1023 mouseRect
.top
= MAX( mouseRect
.top
, sizingRect
.bottom
-maxTrack
.y
);
1024 mouseRect
.bottom
= MIN( mouseRect
.bottom
,sizingRect
.bottom
-minTrack
.y
);
1026 else if (ON_BOTTOM_BORDER(hittest
))
1028 mouseRect
.top
= MAX( mouseRect
.top
, sizingRect
.top
+minTrack
.y
);
1029 mouseRect
.bottom
= MIN( mouseRect
.bottom
, sizingRect
.top
+maxTrack
.y
);
1031 SendMessage16( hwnd
, WM_ENTERSIZEMOVE
, 0, 0 );
1033 if (GetCapture() != hwnd
) SetCapture( hwnd
);
1035 if (wndPtr
->dwStyle
& WS_CHILD
)
1037 /* Retrieve a default cache DC (without using the window style) */
1038 hdc
= GetDCEx( wndPtr
->parent
->hwndSelf
, 0, DCX_CACHE
);
1041 { /* Grab the server only when moving top-level windows without desktop */
1043 if (rootWindow
== DefaultRootWindow(display
)) XGrabServer( display
);
1045 NC_DrawMovingFrame( hdc
, &sizingRect
, thickframe
);
1051 MSG_InternalGetMessage( MAKE_SEGPTR(&msg
), 0, 0, MSGF_SIZE
,
1054 /* Exit on button-up, Return, or Esc */
1055 if ((msg
.message
== WM_LBUTTONUP
) ||
1056 ((msg
.message
== WM_KEYDOWN
) &&
1057 ((msg
.wParam
== VK_RETURN
) || (msg
.wParam
== VK_ESCAPE
)))) break;
1059 if ((msg
.message
!= WM_KEYDOWN
) && (msg
.message
!= WM_MOUSEMOVE
))
1060 continue; /* We are not interested in other messages */
1063 if (wndPtr
->dwStyle
& WS_CHILD
)
1064 ScreenToClient16( wndPtr
->parent
->hwndSelf
, &pt
);
1066 if (msg
.message
== WM_KEYDOWN
) switch(msg
.wParam
)
1068 case VK_UP
: pt
.y
-= 8; break;
1069 case VK_DOWN
: pt
.y
+= 8; break;
1070 case VK_LEFT
: pt
.x
-= 8; break;
1071 case VK_RIGHT
: pt
.x
+= 8; break;
1074 pt
.x
= MAX( pt
.x
, mouseRect
.left
);
1075 pt
.x
= MIN( pt
.x
, mouseRect
.right
);
1076 pt
.y
= MAX( pt
.y
, mouseRect
.top
);
1077 pt
.y
= MIN( pt
.y
, mouseRect
.bottom
);
1079 dx
= pt
.x
- capturePoint
.x
;
1080 dy
= pt
.y
- capturePoint
.y
;
1085 if (msg
.message
== WM_KEYDOWN
) SetCursorPos( pt
.x
, pt
.y
);
1088 RECT16 newRect
= sizingRect
;
1090 if (hittest
== HTCAPTION
) OffsetRect16( &newRect
, dx
, dy
);
1091 if (ON_LEFT_BORDER(hittest
)) newRect
.left
+= dx
;
1092 else if (ON_RIGHT_BORDER(hittest
)) newRect
.right
+= dx
;
1093 if (ON_TOP_BORDER(hittest
)) newRect
.top
+= dy
;
1094 else if (ON_BOTTOM_BORDER(hittest
)) newRect
.bottom
+= dy
;
1095 NC_DrawMovingFrame( hdc
, &sizingRect
, thickframe
);
1096 NC_DrawMovingFrame( hdc
, &newRect
, thickframe
);
1098 sizingRect
= newRect
;
1103 NC_DrawMovingFrame( hdc
, &sizingRect
, thickframe
);
1106 if (wndPtr
->dwStyle
& WS_CHILD
) ReleaseDC( wndPtr
->parent
->hwndSelf
, hdc
);
1109 ReleaseDC( 0, hdc
);
1110 if (rootWindow
== DefaultRootWindow(display
)) XUngrabServer( display
);
1112 SendMessage16( hwnd
, WM_EXITSIZEMOVE
, 0, 0 );
1113 SendMessage16( hwnd
, WM_SETVISIBLE
, !IsIconic(hwnd
), 0L);
1115 /* Single click brings up the system menu when iconized */
1117 if (!moved
&& (wndPtr
->dwStyle
& WS_MINIMIZE
))
1119 NC_TrackSysMenu( hwnd
, hdc
, pt
);
1123 /* If Esc key, don't move the window */
1124 if ((msg
.message
== WM_KEYDOWN
) && (msg
.wParam
== VK_ESCAPE
)) return;
1126 if (hittest
!= HTCAPTION
)
1127 SetWindowPos( hwnd
, 0, sizingRect
.left
, sizingRect
.top
,
1128 sizingRect
.right
- sizingRect
.left
,
1129 sizingRect
.bottom
- sizingRect
.top
,
1130 SWP_NOACTIVATE
| SWP_NOZORDER
);
1131 else SetWindowPos( hwnd
, 0, sizingRect
.left
, sizingRect
.top
, 0, 0,
1132 SWP_NOACTIVATE
| SWP_NOSIZE
| SWP_NOZORDER
);
1136 /***********************************************************************
1139 * Track a mouse button press on the minimize or maximize box.
1141 static void NC_TrackMinMaxBox( HWND hwnd
, WORD wParam
)
1144 HDC hdc
= GetWindowDC( hwnd
);
1145 BOOL pressed
= TRUE
;
1148 if (wParam
== HTMINBUTTON
) NC_DrawMinButton( hwnd
, hdc
, TRUE
);
1149 else NC_DrawMaxButton( hwnd
, hdc
, TRUE
);
1153 BOOL oldstate
= pressed
;
1154 MSG_InternalGetMessage( MAKE_SEGPTR(&msg
), 0, 0, 0, PM_REMOVE
, FALSE
);
1156 pressed
= (NC_HandleNCHitTest( hwnd
, msg
.pt
) == wParam
);
1157 if (pressed
!= oldstate
)
1159 if (wParam
== HTMINBUTTON
) NC_DrawMinButton( hwnd
, hdc
, pressed
);
1160 else NC_DrawMaxButton( hwnd
, hdc
, pressed
);
1162 } while (msg
.message
!= WM_LBUTTONUP
);
1164 if (wParam
== HTMINBUTTON
) NC_DrawMinButton( hwnd
, hdc
, FALSE
);
1165 else NC_DrawMaxButton( hwnd
, hdc
, FALSE
);
1168 ReleaseDC( hwnd
, hdc
);
1169 if (!pressed
) return;
1171 if (wParam
== HTMINBUTTON
)
1172 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MINIMIZE
, *(LONG
*)&msg
.pt
);
1174 SendMessage16( hwnd
, WM_SYSCOMMAND
,
1175 IsZoomed(hwnd
) ? SC_RESTORE
: SC_MAXIMIZE
, *(LONG
*)&msg
.pt
);
1179 /***********************************************************************
1182 * Track a mouse button press on the horizontal or vertical scroll-bar.
1184 static void NC_TrackScrollBar( HWND hwnd
, WORD wParam
, POINT16 pt
)
1188 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1190 if ((wParam
& 0xfff0) == SC_HSCROLL
)
1192 if ((wParam
& 0x0f) != HTHSCROLL
) return;
1193 scrollbar
= SB_HORZ
;
1195 else /* SC_VSCROLL */
1197 if ((wParam
& 0x0f) != HTVSCROLL
) return;
1198 scrollbar
= SB_VERT
;
1201 if (!(msg
= SEGPTR_NEW(MSG16
))) return;
1202 pt
.x
-= wndPtr
->rectWindow
.left
;
1203 pt
.y
-= wndPtr
->rectWindow
.top
;
1205 SCROLL_HandleScrollEvent( hwnd
, scrollbar
, WM_LBUTTONDOWN
, pt
);
1209 GetMessage( SEGPTR_GET(msg
), 0, 0, 0 );
1210 switch(msg
->message
)
1215 pt
.x
= LOWORD(msg
->lParam
) + wndPtr
->rectClient
.left
-
1216 wndPtr
->rectWindow
.left
;
1217 pt
.y
= HIWORD(msg
->lParam
) + wndPtr
->rectClient
.top
-
1218 wndPtr
->rectWindow
.top
;
1219 SCROLL_HandleScrollEvent( hwnd
, scrollbar
, msg
->message
, pt
);
1222 TranslateMessage( msg
);
1223 DispatchMessage( msg
);
1226 if (!IsWindow( hwnd
))
1231 } while (msg
->message
!= WM_LBUTTONUP
);
1235 /***********************************************************************
1236 * NC_HandleNCLButtonDown
1238 * Handle a WM_NCLBUTTONDOWN message. Called from DefWindowProc().
1240 LONG
NC_HandleNCLButtonDown( HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1242 HDC hdc
= GetWindowDC( hwnd
);
1244 switch(wParam
) /* Hit test */
1247 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MOVE
+ HTCAPTION
, lParam
);
1251 NC_TrackSysMenu( hwnd
, hdc
, MAKEPOINT16(lParam
) );
1255 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MOUSEMENU
, lParam
);
1259 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_HSCROLL
+ HTHSCROLL
, lParam
);
1263 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_VSCROLL
+ HTVSCROLL
, lParam
);
1268 NC_TrackMinMaxBox( hwnd
, wParam
);
1279 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_SIZE
+ wParam
- HTLEFT
+1, lParam
);
1286 ReleaseDC( hwnd
, hdc
);
1291 /***********************************************************************
1292 * NC_HandleNCLButtonDblClk
1294 * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc().
1296 LONG
NC_HandleNCLButtonDblClk( WND
*pWnd
, WPARAM wParam
, LPARAM lParam
)
1299 * if this is an icon, send a restore since we are handling
1302 if (pWnd
->dwStyle
& WS_MINIMIZE
)
1304 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_RESTORE
, lParam
);
1308 switch(wParam
) /* Hit test */
1311 /* stop processing if WS_MAXIMIZEBOX is missing */
1312 if (pWnd
->dwStyle
& WS_MAXIMIZEBOX
)
1313 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
,
1314 (pWnd
->dwStyle
& WS_MAXIMIZE
) ? SC_RESTORE
: SC_MAXIMIZE
,
1319 if (!(pWnd
->class->style
& CS_NOCLOSE
))
1320 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_CLOSE
, lParam
);
1327 /***********************************************************************
1328 * NC_HandleSysCommand
1330 * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
1332 LONG
NC_HandleSysCommand( HWND hwnd
, WPARAM wParam
, POINT16 pt
)
1334 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1336 dprintf_nonclient(stddeb
, "Handling WM_SYSCOMMAND %x %d,%d\n",
1337 wParam
, pt
.x
, pt
.y
);
1339 if (wndPtr
->dwStyle
& WS_CHILD
&& wParam
!= SC_KEYMENU
)
1340 ScreenToClient16( wndPtr
->parent
->hwndSelf
, &pt
);
1342 switch (wParam
& 0xfff0)
1346 NC_DoSizeMove( hwnd
, wParam
, pt
);
1350 ShowWindow( hwnd
, SW_MINIMIZE
);
1354 ShowWindow( hwnd
, SW_MAXIMIZE
);
1358 ShowWindow( hwnd
, SW_RESTORE
);
1366 return SendMessage16( hwnd
, WM_CLOSE
, 0, 0 );
1370 NC_TrackScrollBar( hwnd
, wParam
, pt
);
1374 MENU_TrackMouseMenuBar( hwnd
, pt
);
1378 MENU_TrackKbdMenuBar( wndPtr
, wParam
, pt
.x
);
1385 WinExec( "taskman.exe", SW_SHOWNORMAL
);
1392 if (wParam
== SC_ABOUTWINE
)
1394 extern const char people
[];
1395 ShellAbout(hwnd
,"WINE",people
,0);