Release 960506
[wine/multimedia.git] / windows / nonclient.c
blob2538eb18f7e3970374b42f2a4396dceeb94204d7
1 /*
2 * Non-client area window functions
4 * Copyright 1994 Alexandre Julliard
6 */
8 #include "win.h"
9 #include "message.h"
10 #include "sysmetrics.h"
11 #include "user.h"
12 #include "shell.h"
13 #include "dialog.h"
14 #include "syscolor.h"
15 #include "menu.h"
16 #include "winpos.h"
17 #include "scroll.h"
18 #include "nonclient.h"
19 #include "graphics.h"
20 #include "queue.h"
21 #include "selectors.h"
22 #include "stackframe.h"
23 #include "stddebug.h"
24 /* #define DEBUG_NONCLIENT */
25 #include "debug.h"
26 #include "options.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 /***********************************************************************
60 * NC_AdjustRect
62 * Compute the size of the window rectangle from the size of the
63 * client rectangle.
65 static void NC_AdjustRect( LPRECT 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_DLGFRAME | WS_THICKFRAME)) ||
71 (exStyle & WS_EX_DLGMODALFRAME))))
73 if (HAS_DLGFRAME( style, exStyle ))
74 InflateRect( rect, SYSMETRICS_CXDLGFRAME, SYSMETRICS_CYDLGFRAME );
75 else
77 if (HAS_THICKFRAME(style))
78 InflateRect( rect, SYSMETRICS_CXFRAME, SYSMETRICS_CYFRAME );
79 if (style & WS_BORDER)
80 InflateRect( rect, SYSMETRICS_CXBORDER, SYSMETRICS_CYBORDER );
83 if ((style & WS_CAPTION) == WS_CAPTION)
84 rect->top -= SYSMETRICS_CYCAPTION - SYSMETRICS_CYBORDER;
86 if (menu) rect->top -= SYSMETRICS_CYMENU + SYSMETRICS_CYBORDER;
88 if (style & WS_VSCROLL) rect->right += SYSMETRICS_CXVSCROLL;
89 if (style & WS_HSCROLL) rect->bottom += SYSMETRICS_CYHSCROLL;
93 /***********************************************************************
94 * AdjustWindowRect (USER.102)
96 BOOL AdjustWindowRect( LPRECT rect, DWORD style, BOOL menu )
98 return AdjustWindowRectEx( rect, style, menu, 0 );
102 /***********************************************************************
103 * AdjustWindowRectEx (USER.454)
105 BOOL AdjustWindowRectEx( LPRECT rect, DWORD style, BOOL menu, DWORD exStyle )
107 /* Correct the window style */
109 if (!(style & (WS_POPUP | WS_CHILD))) /* Overlapped window */
110 style |= WS_CAPTION;
111 if (exStyle & WS_EX_DLGMODALFRAME) style &= ~WS_THICKFRAME;
113 dprintf_nonclient(stddeb, "AdjustWindowRectEx: (%d,%d)-(%d,%d) %08lx %d %08lx\n",
114 rect->left, rect->top, rect->right, rect->bottom,
115 style, menu, exStyle );
117 NC_AdjustRect( rect, style, menu, exStyle );
118 return TRUE;
122 /*******************************************************************
123 * NC_GetMinMaxInfo
125 * Get the minimized and maximized information for a window.
127 void NC_GetMinMaxInfo( HWND hwnd, POINT *maxSize, POINT *maxPos,
128 POINT *minTrack, POINT *maxTrack )
130 MINMAXINFO MinMax;
131 short xinc, yinc;
132 WND *wndPtr = WIN_FindWndPtr( hwnd );
134 /* Compute default values */
136 MinMax.ptMaxSize.x = SYSMETRICS_CXSCREEN;
137 MinMax.ptMaxSize.y = SYSMETRICS_CYSCREEN;
138 MinMax.ptMinTrackSize.x = SYSMETRICS_CXMINTRACK;
139 MinMax.ptMinTrackSize.y = SYSMETRICS_CYMINTRACK;
140 MinMax.ptMaxTrackSize.x = SYSMETRICS_CXSCREEN;
141 MinMax.ptMaxTrackSize.y = SYSMETRICS_CYSCREEN;
143 if (wndPtr->flags & WIN_MANAGED) xinc = yinc = 0;
144 else if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
146 xinc = SYSMETRICS_CXDLGFRAME;
147 yinc = SYSMETRICS_CYDLGFRAME;
149 else
151 xinc = yinc = 0;
152 if (HAS_THICKFRAME(wndPtr->dwStyle))
154 xinc += SYSMETRICS_CXFRAME;
155 yinc += SYSMETRICS_CYFRAME;
157 if (wndPtr->dwStyle & WS_BORDER)
159 xinc += SYSMETRICS_CXBORDER;
160 yinc += SYSMETRICS_CYBORDER;
163 MinMax.ptMaxSize.x += 2 * xinc;
164 MinMax.ptMaxSize.y += 2 * yinc;
166 /* Note: The '+' in the following test should really be a ||, but
167 * that would cause gcc-2.7.0 to generate incorrect code.
169 if ((wndPtr->ptMaxPos.x != -1) + (wndPtr->ptMaxPos.y != -1))
170 MinMax.ptMaxPosition = wndPtr->ptMaxPos;
171 else
173 MinMax.ptMaxPosition.x = -xinc;
174 MinMax.ptMaxPosition.y = -yinc;
177 SendMessage( hwnd, WM_GETMINMAXINFO, 0, (LPARAM)MAKE_SEGPTR(&MinMax) );
179 /* Some sanity checks */
181 dprintf_nonclient(stddeb,
182 "NC_GetMinMaxInfo: %d %d / %d %d / %d %d / %d %d\n",
183 (int)MinMax.ptMaxSize.x,(int)MinMax.ptMaxSize.y,
184 (int)MinMax.ptMaxPosition.x,(int)MinMax.ptMaxPosition.y,
185 (int)MinMax.ptMaxTrackSize.x,(int)MinMax.ptMaxTrackSize.y,
186 (int)MinMax.ptMinTrackSize.x,(int)MinMax.ptMinTrackSize.y);
187 MinMax.ptMaxTrackSize.x = MAX( MinMax.ptMaxTrackSize.x,
188 MinMax.ptMinTrackSize.x );
189 MinMax.ptMaxTrackSize.y = MAX( MinMax.ptMaxTrackSize.y,
190 MinMax.ptMinTrackSize.y );
192 if (maxSize) *maxSize = MinMax.ptMaxSize;
193 if (maxPos) *maxPos = MinMax.ptMaxPosition;
194 if (minTrack) *minTrack = MinMax.ptMinTrackSize;
195 if (maxTrack) *maxTrack = MinMax.ptMaxTrackSize;
199 /***********************************************************************
200 * NC_HandleNCCalcSize
202 * Handle a WM_NCCALCSIZE message. Called from DefWindowProc().
204 LONG NC_HandleNCCalcSize( HWND hwnd, NCCALCSIZE_PARAMS *params )
206 RECT tmpRect = { 0, 0, 0, 0 };
207 WND *wndPtr = WIN_FindWndPtr( hwnd );
209 if (!wndPtr) return 0;
210 NC_AdjustRect( &tmpRect, wndPtr->dwStyle, FALSE, wndPtr->dwExStyle );
211 params->rgrc[0].left -= tmpRect.left;
212 params->rgrc[0].top -= tmpRect.top;
213 params->rgrc[0].right -= tmpRect.right;
214 params->rgrc[0].bottom -= tmpRect.bottom;
216 if (HAS_MENU(wndPtr))
218 params->rgrc[0].top += MENU_GetMenuBarHeight( hwnd,
219 params->rgrc[0].right - params->rgrc[0].left,
220 -tmpRect.left, -tmpRect.top ) + 1;
222 return 0;
226 /***********************************************************************
227 * NC_GetInsideRect
229 * Get the 'inside' rectangle of a window, i.e. the whole window rectangle
230 * but without the borders (if any).
231 * The rectangle is in window coordinates (for drawing with GetWindowDC()).
233 void NC_GetInsideRect( HWND hwnd, RECT *rect )
235 WND * wndPtr = WIN_FindWndPtr( hwnd );
237 rect->top = rect->left = 0;
238 rect->right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
239 rect->bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
241 if (wndPtr->dwStyle & WS_ICONIC) return; /* No border to remove */
242 if (wndPtr->flags & WIN_MANAGED) return;
244 /* Remove frame from rectangle */
245 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
247 InflateRect( rect, -SYSMETRICS_CXDLGFRAME, -SYSMETRICS_CYDLGFRAME);
248 if (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME) InflateRect( rect, -1, 0);
250 else
252 if (HAS_THICKFRAME( wndPtr->dwStyle ))
253 InflateRect( rect, -SYSMETRICS_CXFRAME, -SYSMETRICS_CYFRAME );
254 if (wndPtr->dwStyle & WS_BORDER)
255 InflateRect( rect, -SYSMETRICS_CXBORDER, -SYSMETRICS_CYBORDER );
260 /***********************************************************************
261 * NC_HandleNCHitTest
263 * Handle a WM_NCHITTEST message. Called from DefWindowProc().
265 LONG NC_HandleNCHitTest( HWND hwnd, POINT pt )
267 RECT rect;
268 WND *wndPtr = WIN_FindWndPtr( hwnd );
269 if (!wndPtr) return HTERROR;
271 dprintf_nonclient(stddeb, "NC_HandleNCHitTest: hwnd=%04x pt=%d,%d\n",
272 hwnd, pt.x, pt.y );
274 GetWindowRect( hwnd, &rect );
275 if (!PtInRect( &rect, pt )) return HTNOWHERE;
277 if (wndPtr->dwStyle & WS_MINIMIZE) return HTCAPTION;
279 if (!(wndPtr->flags & WIN_MANAGED))
281 /* Check borders */
282 if (HAS_THICKFRAME( wndPtr->dwStyle ))
284 InflateRect( &rect, -SYSMETRICS_CXFRAME, -SYSMETRICS_CYFRAME );
285 if (wndPtr->dwStyle & WS_BORDER)
286 InflateRect(&rect, -SYSMETRICS_CXBORDER, -SYSMETRICS_CYBORDER);
287 if (!PtInRect( &rect, pt ))
289 /* Check top sizing border */
290 if (pt.y < rect.top)
292 if (pt.x < rect.left+SYSMETRICS_CXSIZE) return HTTOPLEFT;
293 if (pt.x >= rect.right-SYSMETRICS_CXSIZE) return HTTOPRIGHT;
294 return HTTOP;
296 /* Check bottom sizing border */
297 if (pt.y >= rect.bottom)
299 if (pt.x < rect.left+SYSMETRICS_CXSIZE) return HTBOTTOMLEFT;
300 if (pt.x >= rect.right-SYSMETRICS_CXSIZE) return HTBOTTOMRIGHT;
301 return HTBOTTOM;
303 /* Check left sizing border */
304 if (pt.x < rect.left)
306 if (pt.y < rect.top+SYSMETRICS_CYSIZE) return HTTOPLEFT;
307 if (pt.y >= rect.bottom-SYSMETRICS_CYSIZE) return HTBOTTOMLEFT;
308 return HTLEFT;
310 /* Check right sizing border */
311 if (pt.x >= rect.right)
313 if (pt.y < rect.top+SYSMETRICS_CYSIZE) return HTTOPRIGHT;
314 if (pt.y >= rect.bottom-SYSMETRICS_CYSIZE) return HTBOTTOMRIGHT;
315 return HTRIGHT;
319 else /* No thick frame */
321 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
322 InflateRect(&rect, -SYSMETRICS_CXDLGFRAME, -SYSMETRICS_CYDLGFRAME);
323 else if (wndPtr->dwStyle & WS_BORDER)
324 InflateRect(&rect, -SYSMETRICS_CXBORDER, -SYSMETRICS_CYBORDER);
325 if (!PtInRect( &rect, pt )) return HTBORDER;
328 /* Check caption */
330 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
332 rect.top += SYSMETRICS_CYCAPTION - 1;
333 if (!PtInRect( &rect, pt ))
335 /* Check system menu */
336 if (wndPtr->dwStyle & WS_SYSMENU)
337 rect.left += SYSMETRICS_CXSIZE;
338 if (pt.x <= rect.left) return HTSYSMENU;
339 /* Check maximize box */
340 if (wndPtr->dwStyle & WS_MAXIMIZEBOX)
341 rect.right -= SYSMETRICS_CXSIZE + 1;
342 if (pt.x >= rect.right) return HTMAXBUTTON;
343 /* Check minimize box */
344 if (wndPtr->dwStyle & WS_MINIMIZEBOX)
345 rect.right -= SYSMETRICS_CXSIZE + 1;
346 if (pt.x >= rect.right) return HTMINBUTTON;
347 return HTCAPTION;
352 /* Check client area */
354 ScreenToClient( hwnd, &pt );
355 GetClientRect( hwnd, &rect );
356 if (PtInRect( &rect, pt )) return HTCLIENT;
358 /* Check vertical scroll bar */
360 if (wndPtr->dwStyle & WS_VSCROLL)
362 rect.right += SYSMETRICS_CXVSCROLL;
363 if (PtInRect( &rect, pt )) return HTVSCROLL;
366 /* Check horizontal scroll bar */
368 if (wndPtr->dwStyle & WS_HSCROLL)
370 rect.bottom += SYSMETRICS_CYHSCROLL;
371 if (PtInRect( &rect, pt ))
373 /* Check size box */
374 if ((wndPtr->dwStyle & WS_VSCROLL) &&
375 (pt.x >= rect.right - SYSMETRICS_CXVSCROLL))
376 return HTSIZE;
377 return HTHSCROLL;
381 /* Check menu bar */
383 if (HAS_MENU(wndPtr))
385 if ((pt.y < 0) && (pt.x >= 0) && (pt.x < rect.right))
386 return HTMENU;
389 /* Should never get here */
390 return HTERROR;
394 /***********************************************************************
395 * NC_DrawSysButton
397 void NC_DrawSysButton( HWND hwnd, HDC hdc, BOOL down )
399 RECT rect;
400 HDC hdcMem;
401 HBITMAP hbitmap;
402 WND *wndPtr = WIN_FindWndPtr( hwnd );
404 NC_GetInsideRect( hwnd, &rect );
405 hdcMem = CreateCompatibleDC( hdc );
406 hbitmap = SelectObject( hdcMem, hbitmapClose );
407 BitBlt( hdc, rect.left, rect.top, SYSMETRICS_CXSIZE, SYSMETRICS_CYSIZE,
408 hdcMem, (wndPtr->dwStyle & WS_CHILD) ? SYSMETRICS_CXSIZE : 0, 0,
409 down ? NOTSRCCOPY : SRCCOPY );
410 SelectObject( hdcMem, hbitmap );
411 DeleteDC( hdcMem );
415 /***********************************************************************
416 * NC_DrawMaxButton
418 static void NC_DrawMaxButton( HWND hwnd, HDC hdc, BOOL down )
420 RECT rect;
421 NC_GetInsideRect( hwnd, &rect );
422 GRAPH_DrawBitmap( hdc, (IsZoomed(hwnd) ?
423 (down ? hbitmapRestoreD : hbitmapRestore) :
424 (down ? hbitmapMaximizeD : hbitmapMaximize)),
425 rect.right - SYSMETRICS_CXSIZE - 1, rect.top,
426 0, 0, SYSMETRICS_CXSIZE+1, SYSMETRICS_CYSIZE );
430 /***********************************************************************
431 * NC_DrawMinButton
433 static void NC_DrawMinButton( HWND hwnd, HDC hdc, BOOL down )
435 RECT rect;
436 WND *wndPtr = WIN_FindWndPtr( hwnd );
437 NC_GetInsideRect( hwnd, &rect );
438 if (wndPtr->dwStyle & WS_MAXIMIZEBOX) rect.right -= SYSMETRICS_CXSIZE + 1;
439 GRAPH_DrawBitmap( hdc, (down ? hbitmapMinimizeD : hbitmapMinimize),
440 rect.right - SYSMETRICS_CXSIZE - 1, rect.top,
441 0, 0, SYSMETRICS_CXSIZE+1, SYSMETRICS_CYSIZE );
445 /***********************************************************************
446 * NC_DrawFrame
448 * Draw a window frame inside the given rectangle, and update the rectangle.
449 * The correct pen for the frame must be selected in the DC.
451 static void NC_DrawFrame( HDC hdc, RECT *rect, BOOL dlgFrame, BOOL active )
453 short width, height, tmp;
455 if (dlgFrame)
457 width = SYSMETRICS_CXDLGFRAME - 1;
458 height = SYSMETRICS_CYDLGFRAME - 1;
459 SelectObject( hdc, active ? sysColorObjects.hbrushActiveCaption :
460 sysColorObjects.hbrushInactiveCaption );
462 else
464 width = SYSMETRICS_CXFRAME - 1;
465 height = SYSMETRICS_CYFRAME - 1;
466 SelectObject( hdc, active ? sysColorObjects.hbrushActiveBorder :
467 sysColorObjects.hbrushInactiveBorder );
470 /* Draw frame */
471 PatBlt( hdc, rect->left, rect->top,
472 rect->right - rect->left, height, PATCOPY );
473 PatBlt( hdc, rect->left, rect->top,
474 width, rect->bottom - rect->top, PATCOPY );
475 PatBlt( hdc, rect->left, rect->bottom,
476 rect->right - rect->left, -height, PATCOPY );
477 PatBlt( hdc, rect->right, rect->top,
478 -width, rect->bottom - rect->top, PATCOPY );
480 if (dlgFrame)
482 InflateRect( rect, -width, -height );
483 return;
486 /* Draw inner rectangle */
487 MoveTo( hdc, rect->left+width, rect->top+height );
488 LineTo( hdc, rect->right-width-1, rect->top+height );
489 LineTo( hdc, rect->right-width-1, rect->bottom-height-1 );
490 LineTo( hdc, rect->left+width, rect->bottom-height-1 );
491 LineTo( hdc, rect->left+width, rect->top+height );
493 /* Draw the decorations */
494 tmp = rect->top + SYSMETRICS_CYFRAME + SYSMETRICS_CYSIZE;
495 MoveTo( hdc, rect->left, tmp);
496 LineTo( hdc, rect->left+width, tmp );
497 MoveTo( hdc, rect->right-width-1, tmp );
498 LineTo( hdc, rect->right-1, tmp );
500 tmp = rect->bottom - 1 - SYSMETRICS_CYFRAME - SYSMETRICS_CYSIZE;
501 MoveTo( hdc, rect->left, tmp );
502 LineTo( hdc, rect->left+width, tmp );
503 MoveTo( hdc, rect->right-width-1, tmp );
504 LineTo( hdc, rect->right-1, tmp );
506 tmp = rect->left + SYSMETRICS_CXFRAME + SYSMETRICS_CXSIZE;
507 MoveTo( hdc, tmp, rect->top );
508 LineTo( hdc, tmp, rect->top+height );
509 MoveTo( hdc, tmp, rect->bottom-height-1 );
510 LineTo( hdc, tmp, rect->bottom-1 );
512 tmp = rect->right - 1 - SYSMETRICS_CXFRAME - SYSMETRICS_CYSIZE;
513 MoveTo( hdc, tmp, rect->top );
514 LineTo( hdc, tmp, rect->top+height );
515 MoveTo( hdc, tmp, rect->bottom-height-1 );
516 LineTo( hdc, tmp, rect->bottom-1 );
518 InflateRect( rect, -width-1, -height-1 );
522 /***********************************************************************
523 * NC_DrawMovingFrame
525 * Draw the frame used when moving or resizing window.
527 static void NC_DrawMovingFrame( HDC hdc, RECT *rect, BOOL thickframe )
529 if (thickframe)
531 SelectObject( hdc, GetStockObject( GRAY_BRUSH ) );
532 PatBlt( hdc, rect->left, rect->top,
533 rect->right - rect->left - SYSMETRICS_CXFRAME,
534 SYSMETRICS_CYFRAME, PATINVERT );
535 PatBlt( hdc, rect->left, rect->top + SYSMETRICS_CYFRAME,
536 SYSMETRICS_CXFRAME,
537 rect->bottom - rect->top - SYSMETRICS_CYFRAME, PATINVERT );
538 PatBlt( hdc, rect->left + SYSMETRICS_CXFRAME, rect->bottom,
539 rect->right - rect->left - SYSMETRICS_CXFRAME,
540 -SYSMETRICS_CYFRAME, PATINVERT );
541 PatBlt( hdc, rect->right, rect->top, -SYSMETRICS_CXFRAME,
542 rect->bottom - rect->top - SYSMETRICS_CYFRAME, PATINVERT );
544 else DrawFocusRect( hdc, rect );
548 /***********************************************************************
549 * NC_DrawCaption
551 * Draw the window caption.
552 * The correct pen for the window frame must be selected in the DC.
554 static void NC_DrawCaption( HDC hdc, RECT *rect, HWND hwnd,
555 DWORD style, BOOL active )
557 RECT r = *rect;
558 WND * wndPtr = WIN_FindWndPtr( hwnd );
559 char buffer[256];
561 if (!hbitmapClose)
563 if (!(hbitmapClose = LoadBitmap( 0, MAKEINTRESOURCE(OBM_CLOSE) )))
564 return;
565 hbitmapMinimize = LoadBitmap( 0, MAKEINTRESOURCE(OBM_REDUCE) );
566 hbitmapMinimizeD = LoadBitmap( 0, MAKEINTRESOURCE(OBM_REDUCED) );
567 hbitmapMaximize = LoadBitmap( 0, MAKEINTRESOURCE(OBM_ZOOM) );
568 hbitmapMaximizeD = LoadBitmap( 0, MAKEINTRESOURCE(OBM_ZOOMD) );
569 hbitmapRestore = LoadBitmap( 0, MAKEINTRESOURCE(OBM_RESTORE) );
570 hbitmapRestoreD = LoadBitmap( 0, MAKEINTRESOURCE(OBM_RESTORED) );
573 if (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME)
575 HBRUSH hbrushOld = SelectObject( hdc, sysColorObjects.hbrushWindow );
576 PatBlt( hdc, r.left, r.top, 1, r.bottom-r.top+1,PATCOPY );
577 PatBlt( hdc, r.right-1, r.top, 1, r.bottom-r.top+1, PATCOPY );
578 PatBlt( hdc, r.left, r.top-1, r.right-r.left, 1, PATCOPY );
579 r.left++;
580 r.right--;
581 SelectObject( hdc, hbrushOld );
584 MoveTo( hdc, r.left, r.bottom );
585 LineTo( hdc, r.right-1, r.bottom );
587 if (style & WS_SYSMENU)
589 NC_DrawSysButton( hwnd, hdc, FALSE );
590 r.left += SYSMETRICS_CXSIZE + 1;
591 MoveTo( hdc, r.left - 1, r.top );
592 LineTo( hdc, r.left - 1, r.bottom );
594 if (style & WS_MAXIMIZEBOX)
596 NC_DrawMaxButton( hwnd, hdc, FALSE );
597 r.right -= SYSMETRICS_CXSIZE + 1;
599 if (style & WS_MINIMIZEBOX)
601 NC_DrawMinButton( hwnd, hdc, FALSE );
602 r.right -= SYSMETRICS_CXSIZE + 1;
605 FillRect( hdc, &r, active ? sysColorObjects.hbrushActiveCaption :
606 sysColorObjects.hbrushInactiveCaption );
608 if (GetWindowText( hwnd, buffer, 256 ))
610 if (active) SetTextColor( hdc, GetSysColor( COLOR_CAPTIONTEXT ) );
611 else SetTextColor( hdc, GetSysColor( COLOR_INACTIVECAPTIONTEXT ) );
612 SetBkMode( hdc, TRANSPARENT );
613 DrawText( hdc, buffer, -1, &r, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
618 /***********************************************************************
619 * NC_DoNCPaint
621 * Paint the non-client area. clip is currently unused.
623 void NC_DoNCPaint( HWND hwnd, HRGN clip, BOOL suppress_menupaint )
625 HDC hdc;
626 RECT rect;
627 BOOL active;
629 WND *wndPtr = WIN_FindWndPtr( hwnd );
631 if (!wndPtr || !(wndPtr->dwStyle & WS_VISIBLE)) return; /* Nothing to do */
633 active = wndPtr->flags & WIN_NCACTIVATED;
635 dprintf_nonclient(stddeb, "NC_DoNCPaint: %04x %d\n", hwnd, active );
637 if (!(hdc = GetDCEx( hwnd, 0, DCX_USESTYLE | DCX_WINDOW ))) return;
640 * If this is an icon, we don't want to do any more nonclient painting
641 * of the window manager.
642 * If there is a class icon to draw, draw it
644 if (IsIconic(hwnd))
646 if (wndPtr->class->hIcon)
648 SendMessage(hwnd, WM_ICONERASEBKGND, (WPARAM)hdc, 0);
649 DrawIcon( hdc, 0, 0, wndPtr->class->hIcon );
651 ReleaseDC(hwnd, hdc);
652 wndPtr->flags &= ~WIN_INTERNAL_PAINT;
653 if( wndPtr->hrgnUpdate )
655 DeleteObject( wndPtr->hrgnUpdate );
656 QUEUE_DecPaintCount( wndPtr->hmemTaskQ );
657 wndPtr->hrgnUpdate = 0;
659 return;
662 if (ExcludeVisRect( hdc, wndPtr->rectClient.left-wndPtr->rectWindow.left,
663 wndPtr->rectClient.top-wndPtr->rectWindow.top,
664 wndPtr->rectClient.right-wndPtr->rectWindow.left,
665 wndPtr->rectClient.bottom-wndPtr->rectWindow.top )
666 == NULLREGION)
668 ReleaseDC( hwnd, hdc );
669 return;
672 rect.top = rect.left = 0;
673 rect.right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
674 rect.bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
676 SelectObject( hdc, sysColorObjects.hpenWindowFrame );
678 if (!(wndPtr->flags & WIN_MANAGED))
680 if ((wndPtr->dwStyle & WS_BORDER) || (wndPtr->dwStyle & WS_DLGFRAME) ||
681 (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME))
683 MoveTo( hdc, 0, 0 );
684 LineTo( hdc, rect.right-1, 0 );
685 LineTo( hdc, rect.right-1, rect.bottom-1 );
686 LineTo( hdc, 0, rect.bottom-1 );
687 LineTo( hdc, 0, 0 );
688 InflateRect( &rect, -1, -1 );
691 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
692 NC_DrawFrame( hdc, &rect, TRUE, active );
693 else if (wndPtr->dwStyle & WS_THICKFRAME)
694 NC_DrawFrame(hdc, &rect, FALSE, active );
696 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
698 RECT r = rect;
699 r.bottom = rect.top + SYSMETRICS_CYSIZE;
700 rect.top += SYSMETRICS_CYSIZE + SYSMETRICS_CYBORDER;
701 NC_DrawCaption( hdc, &r, hwnd, wndPtr->dwStyle, active );
705 if (HAS_MENU(wndPtr))
707 RECT r = rect;
708 r.bottom = rect.top + SYSMETRICS_CYMENU; /* default height */
709 rect.top += MENU_DrawMenuBar( hdc, &r, hwnd, suppress_menupaint );
712 /* Draw the scroll-bars */
714 if (wndPtr->dwStyle & WS_VSCROLL) SCROLL_DrawScrollBar(hwnd, hdc, SB_VERT);
715 if (wndPtr->dwStyle & WS_HSCROLL) SCROLL_DrawScrollBar(hwnd, hdc, SB_HORZ);
717 /* Draw the "size-box" */
719 if ((wndPtr->dwStyle & WS_VSCROLL) && (wndPtr->dwStyle & WS_HSCROLL))
721 RECT r = rect;
722 r.left = r.right - SYSMETRICS_CXVSCROLL + 1;
723 r.top = r.bottom - SYSMETRICS_CYHSCROLL + 1;
724 FillRect( hdc, &r, sysColorObjects.hbrushScrollbar );
727 ReleaseDC( hwnd, hdc );
732 /***********************************************************************
733 * NC_HandleNCPaint
735 * Handle a WM_NCPAINT message. Called from DefWindowProc().
737 LONG NC_HandleNCPaint( HWND hwnd , HRGN clip)
739 NC_DoNCPaint( hwnd, clip, FALSE );
740 return 0;
744 /***********************************************************************
745 * NC_HandleNCActivate
747 * Handle a WM_NCACTIVATE message. Called from DefWindowProc().
749 LONG NC_HandleNCActivate( HWND hwnd, WPARAM wParam )
751 WND *wndPtr = WIN_FindWndPtr(hwnd);
753 if (wParam != 0) wndPtr->flags |= WIN_NCACTIVATED;
754 else wndPtr->flags &= ~WIN_NCACTIVATED;
756 NC_DoNCPaint( hwnd, (HRGN)1, FALSE );
757 return TRUE;
761 /***********************************************************************
762 * NC_HandleSetCursor
764 * Handle a WM_SETCURSOR message. Called from DefWindowProc().
766 LONG NC_HandleSetCursor( HWND hwnd, WPARAM wParam, LPARAM lParam )
768 if (hwnd != (HWND)wParam) return 0; /* Don't set the cursor for child windows */
770 switch(LOWORD(lParam))
772 case HTERROR:
774 WORD msg = HIWORD( lParam );
775 if ((msg == WM_LBUTTONDOWN) || (msg == WM_MBUTTONDOWN) ||
776 (msg == WM_RBUTTONDOWN))
777 MessageBeep(0);
779 break;
781 case HTCLIENT:
783 WND *wndPtr;
784 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) break;
785 if (wndPtr->class->hCursor)
787 SetCursor( wndPtr->class->hCursor );
788 return TRUE;
790 else return FALSE;
793 case HTLEFT:
794 case HTRIGHT:
795 return (LONG)SetCursor( LoadCursor( 0, IDC_SIZEWE ) );
797 case HTTOP:
798 case HTBOTTOM:
799 return (LONG)SetCursor( LoadCursor( 0, IDC_SIZENS ) );
801 case HTTOPLEFT:
802 case HTBOTTOMRIGHT:
803 return (LONG)SetCursor( LoadCursor( 0, IDC_SIZENWSE ) );
805 case HTTOPRIGHT:
806 case HTBOTTOMLEFT:
807 return (LONG)SetCursor( LoadCursor( 0, IDC_SIZENESW ) );
810 /* Default cursor: arrow */
811 return (LONG)SetCursor( LoadCursor( 0, IDC_ARROW ) );
815 /***********************************************************************
816 * NC_TrackSysMenu
818 * Track a mouse button press on the system menu.
820 static void NC_TrackSysMenu( HWND hwnd, HDC hdc, POINT pt )
822 RECT rect;
823 WND *wndPtr = WIN_FindWndPtr( hwnd );
824 int iconic = wndPtr->dwStyle & WS_MINIMIZE;
826 if (!(wndPtr->dwStyle & WS_SYSMENU)) return;
827 /* If window has a menu, track the menu bar normally if it not minimized */
828 if (HAS_MENU(wndPtr) && !iconic) MENU_TrackMouseMenuBar( hwnd, pt );
829 else
831 /* Otherwise track the system menu like a normal popup menu */
832 NC_GetInsideRect( hwnd, &rect );
833 OffsetRect( &rect, wndPtr->rectWindow.left, wndPtr->rectWindow.top );
834 if (wndPtr->dwStyle & WS_CHILD)
835 ClientToScreen( wndPtr->parent->hwndSelf, (POINT *)&rect );
836 rect.right = rect.left + SYSMETRICS_CXSIZE;
837 rect.bottom = rect.top + SYSMETRICS_CYSIZE;
838 if (!iconic) NC_DrawSysButton( hwnd, hdc, TRUE );
839 TrackPopupMenu( wndPtr->hSysMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON,
840 rect.left, rect.bottom, 0, hwnd, &rect );
841 if (!iconic) NC_DrawSysButton( hwnd, hdc, FALSE );
846 /***********************************************************************
847 * NC_StartSizeMove
849 * Initialisation of a move or resize, when initiatied from a menu choice.
850 * Return hit test code for caption or sizing border.
852 static LONG NC_StartSizeMove( HWND hwnd, WPARAM wParam, POINT *capturePoint )
854 LONG hittest = 0;
855 POINT pt;
856 MSG msg;
857 WND * wndPtr = WIN_FindWndPtr( hwnd );
859 if ((wParam & 0xfff0) == SC_MOVE)
861 /* Move pointer at the center of the caption */
862 RECT rect;
863 NC_GetInsideRect( hwnd, &rect );
864 if (wndPtr->dwStyle & WS_SYSMENU)
865 rect.left += SYSMETRICS_CXSIZE + 1;
866 if (wndPtr->dwStyle & WS_MINIMIZEBOX)
867 rect.right -= SYSMETRICS_CXSIZE + 1;
868 if (wndPtr->dwStyle & WS_MAXIMIZEBOX)
869 rect.right -= SYSMETRICS_CXSIZE + 1;
870 pt.x = wndPtr->rectWindow.left + (rect.right - rect.left) / 2;
871 pt.y = wndPtr->rectWindow.top + rect.top + SYSMETRICS_CYSIZE/2;
872 if (wndPtr->dwStyle & WS_CHILD)
873 ClientToScreen( wndPtr->parent->hwndSelf, &pt );
874 hittest = HTCAPTION;
876 else /* SC_SIZE */
878 SetCapture(hwnd);
879 while(!hittest)
881 MSG_GetHardwareMessage( &msg );
882 switch(msg.message)
884 case WM_MOUSEMOVE:
885 hittest = NC_HandleNCHitTest( hwnd, msg.pt );
886 pt = msg.pt;
887 if ((hittest < HTLEFT) || (hittest > HTBOTTOMRIGHT))
888 hittest = 0;
889 break;
891 case WM_LBUTTONUP:
892 return 0;
894 case WM_KEYDOWN:
895 switch(msg.wParam)
897 case VK_UP:
898 hittest = HTTOP;
899 pt.x =(wndPtr->rectWindow.left+wndPtr->rectWindow.right)/2;
900 pt.y = wndPtr->rectWindow.top + SYSMETRICS_CYFRAME / 2;
901 break;
902 case VK_DOWN:
903 hittest = HTBOTTOM;
904 pt.x =(wndPtr->rectWindow.left+wndPtr->rectWindow.right)/2;
905 pt.y = wndPtr->rectWindow.bottom - SYSMETRICS_CYFRAME / 2;
906 break;
907 case VK_LEFT:
908 hittest = HTLEFT;
909 pt.x = wndPtr->rectWindow.left + SYSMETRICS_CXFRAME / 2;
910 pt.y =(wndPtr->rectWindow.top+wndPtr->rectWindow.bottom)/2;
911 break;
912 case VK_RIGHT:
913 hittest = HTRIGHT;
914 pt.x = wndPtr->rectWindow.right - SYSMETRICS_CXFRAME / 2;
915 pt.y =(wndPtr->rectWindow.top+wndPtr->rectWindow.bottom)/2;
916 break;
917 case VK_RETURN:
918 case VK_ESCAPE: return 0;
923 *capturePoint = pt;
924 SetCursorPos( capturePoint->x, capturePoint->y );
925 NC_HandleSetCursor( hwnd, (WPARAM)hwnd, MAKELONG( hittest, WM_MOUSEMOVE ));
926 return hittest;
930 /***********************************************************************
931 * NC_DoSizeMove
933 * Perform SC_MOVE and SC_SIZE commands.
935 static void NC_DoSizeMove( HWND hwnd, WORD wParam, POINT pt )
937 MSG msg;
938 LONG hittest;
939 RECT sizingRect, mouseRect;
940 HDC hdc;
941 BOOL thickframe;
942 POINT minTrack, maxTrack, capturePoint = pt;
943 WND * wndPtr = WIN_FindWndPtr( hwnd );
944 int moved = 0;
946 if (IsZoomed(hwnd) || !IsWindowVisible(hwnd) ||
947 (wndPtr->flags & WIN_MANAGED)) return;
948 hittest = wParam & 0x0f;
949 thickframe = HAS_THICKFRAME( wndPtr->dwStyle );
951 if ((wParam & 0xfff0) == SC_MOVE)
953 if (!(wndPtr->dwStyle & WS_CAPTION)) return;
954 if (!hittest) hittest = NC_StartSizeMove( hwnd, wParam, &capturePoint );
955 if (!hittest) return;
957 else /* SC_SIZE */
959 if (!thickframe) return;
960 if (hittest) hittest += HTLEFT-1;
961 else
963 SetCapture(hwnd);
964 hittest = NC_StartSizeMove( hwnd, wParam, &capturePoint );
965 if (!hittest)
967 ReleaseCapture();
968 return;
973 /* Get min/max info */
975 NC_GetMinMaxInfo( hwnd, NULL, NULL, &minTrack, &maxTrack );
976 sizingRect = wndPtr->rectWindow;
977 if (wndPtr->dwStyle & WS_CHILD)
978 GetClientRect( wndPtr->parent->hwndSelf, &mouseRect );
979 else SetRect( &mouseRect, 0, 0, SYSMETRICS_CXSCREEN, SYSMETRICS_CYSCREEN );
980 if (ON_LEFT_BORDER(hittest))
982 mouseRect.left = MAX( mouseRect.left, sizingRect.right-maxTrack.x );
983 mouseRect.right = MIN( mouseRect.right, sizingRect.right-minTrack.x );
985 else if (ON_RIGHT_BORDER(hittest))
987 mouseRect.left = MAX( mouseRect.left, sizingRect.left+minTrack.x );
988 mouseRect.right = MIN( mouseRect.right, sizingRect.left+maxTrack.x );
990 if (ON_TOP_BORDER(hittest))
992 mouseRect.top = MAX( mouseRect.top, sizingRect.bottom-maxTrack.y );
993 mouseRect.bottom = MIN( mouseRect.bottom,sizingRect.bottom-minTrack.y);
995 else if (ON_BOTTOM_BORDER(hittest))
997 mouseRect.top = MAX( mouseRect.top, sizingRect.top+minTrack.y );
998 mouseRect.bottom = MIN( mouseRect.bottom, sizingRect.top+maxTrack.y );
1000 SendMessage( hwnd, WM_ENTERSIZEMOVE, 0, 0 );
1002 if (GetCapture() != hwnd) SetCapture( hwnd );
1004 if (wndPtr->dwStyle & WS_CHILD)
1006 /* Retrieve a default cache DC (without using the window style) */
1007 hdc = GetDCEx( wndPtr->parent->hwndSelf, 0, DCX_CACHE );
1009 else
1010 { /* Grab the server only when moving top-level windows without desktop */
1011 hdc = GetDC( 0 );
1012 if (rootWindow == DefaultRootWindow(display)) XGrabServer( display );
1014 NC_DrawMovingFrame( hdc, &sizingRect, thickframe );
1016 while(1)
1018 int dx = 0, dy = 0;
1020 MSG_GetHardwareMessage( &msg );
1022 /* Exit on button-up, Return, or Esc */
1023 if ((msg.message == WM_LBUTTONUP) ||
1024 ((msg.message == WM_KEYDOWN) &&
1025 ((msg.wParam == VK_RETURN) || (msg.wParam == VK_ESCAPE)))) break;
1027 if ((msg.message != WM_KEYDOWN) && (msg.message != WM_MOUSEMOVE))
1028 continue; /* We are not interested in other messages */
1030 pt = msg.pt;
1031 if (wndPtr->dwStyle & WS_CHILD)
1032 ScreenToClient( wndPtr->parent->hwndSelf, &pt );
1035 if (msg.message == WM_KEYDOWN) switch(msg.wParam)
1037 case VK_UP: pt.y -= 8; break;
1038 case VK_DOWN: pt.y += 8; break;
1039 case VK_LEFT: pt.x -= 8; break;
1040 case VK_RIGHT: pt.x += 8; break;
1043 pt.x = MAX( pt.x, mouseRect.left );
1044 pt.x = MIN( pt.x, mouseRect.right );
1045 pt.y = MAX( pt.y, mouseRect.top );
1046 pt.y = MIN( pt.y, mouseRect.bottom );
1048 dx = pt.x - capturePoint.x;
1049 dy = pt.y - capturePoint.y;
1051 if (dx || dy)
1053 moved = 1;
1054 if (msg.message == WM_KEYDOWN) SetCursorPos( pt.x, pt.y );
1055 else
1057 RECT newRect = sizingRect;
1059 if (hittest == HTCAPTION) OffsetRect( &newRect, dx, dy );
1060 if (ON_LEFT_BORDER(hittest)) newRect.left += dx;
1061 else if (ON_RIGHT_BORDER(hittest)) newRect.right += dx;
1062 if (ON_TOP_BORDER(hittest)) newRect.top += dy;
1063 else if (ON_BOTTOM_BORDER(hittest)) newRect.bottom += dy;
1064 NC_DrawMovingFrame( hdc, &sizingRect, thickframe );
1065 NC_DrawMovingFrame( hdc, &newRect, thickframe );
1066 capturePoint = pt;
1067 sizingRect = newRect;
1072 NC_DrawMovingFrame( hdc, &sizingRect, thickframe );
1073 ReleaseCapture();
1075 if (wndPtr->dwStyle & WS_CHILD) ReleaseDC( wndPtr->parent->hwndSelf, hdc );
1076 else
1078 ReleaseDC( 0, hdc );
1079 if (rootWindow == DefaultRootWindow(display)) XUngrabServer( display );
1081 SendMessage( hwnd, WM_EXITSIZEMOVE, 0, 0 );
1082 SendMessage( hwnd, WM_SETVISIBLE, !IsIconic(hwnd), 0L);
1084 /* Single click brings up the system menu when iconized */
1086 if (!moved && (wndPtr->dwStyle & WS_MINIMIZE))
1088 NC_TrackSysMenu( hwnd, hdc, pt );
1089 return;
1092 /* If Esc key, don't move the window */
1093 if ((msg.message == WM_KEYDOWN) && (msg.wParam == VK_ESCAPE)) return;
1095 if (hittest != HTCAPTION)
1096 SetWindowPos( hwnd, 0, sizingRect.left, sizingRect.top,
1097 sizingRect.right - sizingRect.left,
1098 sizingRect.bottom - sizingRect.top,
1099 SWP_NOACTIVATE | SWP_NOZORDER );
1100 else SetWindowPos( hwnd, 0, sizingRect.left, sizingRect.top, 0, 0,
1101 SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER );
1105 /***********************************************************************
1106 * NC_TrackMinMaxBox
1108 * Track a mouse button press on the minimize or maximize box.
1110 static void NC_TrackMinMaxBox( HWND hwnd, WORD wParam )
1112 MSG msg;
1113 HDC hdc = GetWindowDC( hwnd );
1114 BOOL pressed = TRUE;
1116 SetCapture( hwnd );
1117 if (wParam == HTMINBUTTON) NC_DrawMinButton( hwnd, hdc, TRUE );
1118 else NC_DrawMaxButton( hwnd, hdc, TRUE );
1122 BOOL oldstate = pressed;
1123 MSG_GetHardwareMessage( &msg );
1125 pressed = (NC_HandleNCHitTest( hwnd, msg.pt ) == wParam);
1126 if (pressed != oldstate)
1128 if (wParam == HTMINBUTTON) NC_DrawMinButton( hwnd, hdc, pressed );
1129 else NC_DrawMaxButton( hwnd, hdc, pressed );
1131 } while (msg.message != WM_LBUTTONUP);
1133 if (wParam == HTMINBUTTON) NC_DrawMinButton( hwnd, hdc, FALSE );
1134 else NC_DrawMaxButton( hwnd, hdc, FALSE );
1136 ReleaseCapture();
1137 ReleaseDC( hwnd, hdc );
1138 if (!pressed) return;
1140 if (wParam == HTMINBUTTON)
1141 SendMessage( hwnd, WM_SYSCOMMAND, SC_MINIMIZE, *(LONG*)&msg.pt );
1142 else
1143 SendMessage( hwnd, WM_SYSCOMMAND,
1144 IsZoomed(hwnd) ? SC_RESTORE : SC_MAXIMIZE, *(LONG*)&msg.pt );
1148 /***********************************************************************
1149 * NC_TrackScrollBar
1151 * Track a mouse button press on the horizontal or vertical scroll-bar.
1153 static void NC_TrackScrollBar( HWND hwnd, WORD wParam, POINT pt )
1155 MSG msg;
1156 WORD scrollbar;
1157 WND *wndPtr = WIN_FindWndPtr( hwnd );
1159 if ((wParam & 0xfff0) == SC_HSCROLL)
1161 if ((wParam & 0x0f) != HTHSCROLL) return;
1162 scrollbar = SB_HORZ;
1164 else /* SC_VSCROLL */
1166 if ((wParam & 0x0f) != HTVSCROLL) return;
1167 scrollbar = SB_VERT;
1170 pt.x -= wndPtr->rectWindow.left;
1171 pt.y -= wndPtr->rectWindow.top;
1172 SetCapture( hwnd );
1173 SCROLL_HandleScrollEvent( hwnd, scrollbar, WM_LBUTTONDOWN, pt );
1177 GetMessage( MAKE_SEGPTR(&msg), 0, 0, 0 );
1178 switch(msg.message)
1180 case WM_LBUTTONUP:
1181 case WM_MOUSEMOVE:
1182 case WM_SYSTIMER:
1183 pt.x = LOWORD(msg.lParam) + wndPtr->rectClient.left -
1184 wndPtr->rectWindow.left;
1185 pt.y = HIWORD(msg.lParam) + wndPtr->rectClient.top -
1186 wndPtr->rectWindow.top;
1187 SCROLL_HandleScrollEvent( hwnd, scrollbar, msg.message, pt );
1188 break;
1189 default:
1190 TranslateMessage( &msg );
1191 DispatchMessage( &msg );
1192 break;
1194 if (!IsWindow( hwnd ))
1196 ReleaseCapture();
1197 break;
1199 } while (msg.message != WM_LBUTTONUP);
1202 /***********************************************************************
1203 * NC_HandleNCLButtonDown
1205 * Handle a WM_NCLBUTTONDOWN message. Called from DefWindowProc().
1207 LONG NC_HandleNCLButtonDown( HWND hwnd, WPARAM wParam, LPARAM lParam )
1209 HDC hdc = GetWindowDC( hwnd );
1210 POINT pt = { LOWORD(lParam), HIWORD(lParam) };
1212 switch(wParam) /* Hit test */
1214 case HTCAPTION:
1215 SendMessage( hwnd, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, lParam );
1216 break;
1218 case HTSYSMENU:
1219 NC_TrackSysMenu( hwnd, hdc, pt );
1220 break;
1222 case HTMENU:
1223 SendMessage( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU, lParam );
1224 break;
1226 case HTHSCROLL:
1227 SendMessage( hwnd, WM_SYSCOMMAND, SC_HSCROLL + HTHSCROLL, lParam );
1228 break;
1230 case HTVSCROLL:
1231 SendMessage( hwnd, WM_SYSCOMMAND, SC_VSCROLL + HTVSCROLL, lParam );
1232 break;
1234 case HTMINBUTTON:
1235 case HTMAXBUTTON:
1236 NC_TrackMinMaxBox( hwnd, wParam );
1237 break;
1239 case HTLEFT:
1240 case HTRIGHT:
1241 case HTTOP:
1242 case HTTOPLEFT:
1243 case HTTOPRIGHT:
1244 case HTBOTTOM:
1245 case HTBOTTOMLEFT:
1246 case HTBOTTOMRIGHT:
1247 SendMessage( hwnd, WM_SYSCOMMAND, SC_SIZE + wParam - HTLEFT+1, lParam);
1248 break;
1250 case HTBORDER:
1251 break;
1254 ReleaseDC( hwnd, hdc );
1255 return 0;
1259 /***********************************************************************
1260 * NC_HandleNCLButtonDblClk
1262 * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc().
1264 LONG NC_HandleNCLButtonDblClk( WND *pWnd, WPARAM wParam, LPARAM lParam )
1267 * if this is an icon, send a restore since we are handling
1268 * a double click
1270 if (pWnd->dwStyle & WS_MINIMIZE)
1272 SendMessage( pWnd->hwndSelf, WM_SYSCOMMAND, SC_RESTORE, lParam );
1273 return 0;
1276 switch(wParam) /* Hit test */
1278 case HTCAPTION:
1279 /* stop processing if WS_MAXIMIZEBOX is missing */
1280 if (pWnd->dwStyle & WS_MAXIMIZEBOX)
1281 SendMessage( pWnd->hwndSelf, WM_SYSCOMMAND,
1282 (pWnd->dwStyle & WS_MAXIMIZE) ? SC_RESTORE : SC_MAXIMIZE,
1283 lParam );
1284 break;
1286 case HTSYSMENU:
1287 if (!(pWnd->class->style & CS_NOCLOSE))
1288 SendMessage( pWnd->hwndSelf, WM_SYSCOMMAND, SC_CLOSE, lParam );
1289 break;
1291 return 0;
1295 /***********************************************************************
1296 * NC_HandleSysCommand
1298 * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
1300 LONG NC_HandleSysCommand( HWND hwnd, WPARAM wParam, POINT pt )
1302 WND *wndPtr = WIN_FindWndPtr( hwnd );
1304 dprintf_nonclient(stddeb, "Handling WM_SYSCOMMAND %x %d,%d\n",
1305 wParam, pt.x, pt.y );
1307 if (wndPtr->dwStyle & WS_CHILD && wParam != SC_KEYMENU )
1308 ScreenToClient( wndPtr->parent->hwndSelf, &pt );
1310 switch (wParam & 0xfff0)
1312 case SC_SIZE:
1313 case SC_MOVE:
1314 NC_DoSizeMove( hwnd, wParam, pt );
1315 break;
1317 case SC_MINIMIZE:
1318 ShowWindow( hwnd, SW_MINIMIZE );
1319 break;
1321 case SC_MAXIMIZE:
1322 ShowWindow( hwnd, SW_MAXIMIZE );
1323 break;
1325 case SC_RESTORE:
1326 ShowWindow( hwnd, SW_RESTORE );
1327 break;
1329 case SC_NEXTWINDOW:
1330 case SC_PREVWINDOW:
1331 break;
1333 case SC_CLOSE:
1334 return SendMessage( hwnd, WM_CLOSE, 0, 0 );
1336 case SC_VSCROLL:
1337 case SC_HSCROLL:
1338 NC_TrackScrollBar( hwnd, wParam, pt );
1339 break;
1341 case SC_MOUSEMENU:
1342 MENU_TrackMouseMenuBar( hwnd, pt );
1343 break;
1345 case SC_KEYMENU:
1346 MENU_TrackKbdMenuBar( wndPtr , wParam , pt.x );
1347 break;
1349 case SC_ARRANGE:
1350 break;
1352 case SC_TASKLIST:
1353 WinExec( "taskman.exe", SW_SHOWNORMAL );
1354 break;
1356 case SC_HOTKEY:
1357 break;
1359 case SC_SCREENSAVE:
1360 if (wParam == SC_ABOUTWINE)
1362 extern const char people[];
1363 ShellAbout(hwnd,"WINE",people,0);
1365 break;
1367 return 0;