Release 941030
[wine/multimedia.git] / windows / nonclient.c
blobe76e79cfee098472c3407c494c99d8a6e84abc5e
1 /*
2 * Non-client area window functions
4 * Copyright 1994 Alexandre Julliard
5 */
7 static char Copyright[] = "Copyright Alexandre Julliard, 1994";
9 #include "win.h"
10 #include "class.h"
11 #include "message.h"
12 #include "sysmetrics.h"
13 #include "user.h"
14 #include "scroll.h"
15 #include "syscolor.h"
16 #include "stddebug.h"
17 /* #define DEBUG_NONCLIENT /* */
18 /* #undef DEBUG_NONCLIENT /* */
19 #include "debug.h"
22 static HBITMAP hbitmapClose = 0;
23 static HBITMAP hbitmapMDIClose = 0;
24 static HBITMAP hbitmapMinimize = 0;
25 static HBITMAP hbitmapMinimizeD = 0;
26 static HBITMAP hbitmapMaximize = 0;
27 static HBITMAP hbitmapMaximizeD = 0;
28 static HBITMAP hbitmapRestore = 0;
29 static HBITMAP hbitmapRestoreD = 0;
31 #define SC_ABOUTWINE (SC_SCREENSAVE+1)
32 extern HINSTANCE hSysRes;
33 extern BOOL AboutWine_Proc( HWND hDlg, WORD msg, WORD wParam, LONG lParam );
35 extern void WINPOS_GetMinMaxInfo( HWND hwnd, POINT *maxSize, POINT *maxPos,
36 POINT *minTrack, POINT *maxTrack ); /* winpos.c */
37 extern BOOL GRAPH_DrawBitmap( HDC hdc, HBITMAP hbitmap, int xdest, int ydest,
38 int xsrc, int ysrc, int width, int height,
39 int rop ); /* graphics.c */
40 extern WORD MENU_GetMenuBarHeight( HWND hwnd, WORD menubarWidth,
41 int orgX, int orgY ); /* menu.c */
42 extern void MENU_TrackMouseMenuBar( HWND hwnd, POINT pt ); /* menu.c */
43 extern void MENU_TrackKbdMenuBar( HWND hwnd, WORD wParam ); /* menu.c */
44 extern WORD MENU_DrawMenuBar( HDC hDC, LPRECT lprect,
45 HWND hwnd, BOOL suppress_draw ); /* menu.c */
48 /* Some useful macros */
49 #define HAS_DLGFRAME(style,exStyle) \
50 (((style) & WS_DLGFRAME) && \
51 (((exStyle) & WS_EX_DLGMODALFRAME) || !((style) & WS_BORDER)))
53 #define HAS_THICKFRAME(style) \
54 (((style) & WS_THICKFRAME) && \
55 !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
57 #define HAS_MENU(w) (!((w)->dwStyle & WS_CHILD) && ((w)->wIDmenu != 0))
59 #define ON_LEFT_BORDER(hit) \
60 (((hit) == HTLEFT) || ((hit) == HTTOPLEFT) || ((hit) == HTBOTTOMLEFT))
61 #define ON_RIGHT_BORDER(hit) \
62 (((hit) == HTRIGHT) || ((hit) == HTTOPRIGHT) || ((hit) == HTBOTTOMRIGHT))
63 #define ON_TOP_BORDER(hit) \
64 (((hit) == HTTOP) || ((hit) == HTTOPLEFT) || ((hit) == HTTOPRIGHT))
65 #define ON_BOTTOM_BORDER(hit) \
66 (((hit) == HTBOTTOM) || ((hit) == HTBOTTOMLEFT) || ((hit) == HTBOTTOMRIGHT))
68 /***********************************************************************
69 * NC_AdjustRect
71 * Compute the size of the window rectangle from the size of the
72 * client rectangle.
74 static void NC_AdjustRect( LPRECT rect, DWORD style, BOOL menu, DWORD exStyle )
76 if (HAS_DLGFRAME( style, exStyle ))
77 InflateRect( rect, SYSMETRICS_CXDLGFRAME, SYSMETRICS_CYDLGFRAME );
78 else
80 if (HAS_THICKFRAME(style))
81 InflateRect( rect, SYSMETRICS_CXFRAME, SYSMETRICS_CYFRAME );
82 if (style & WS_BORDER)
83 InflateRect( rect, SYSMETRICS_CXBORDER, SYSMETRICS_CYBORDER );
86 if ((style & WS_CAPTION) == WS_CAPTION)
87 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 * AdjustWindowRect (USER.102)
98 void AdjustWindowRect( LPRECT rect, DWORD style, BOOL menu )
100 AdjustWindowRectEx( rect, style, menu, 0 );
104 /***********************************************************************
105 * AdjustWindowRectEx (USER.454)
107 void AdjustWindowRectEx( LPRECT rect, DWORD style, BOOL menu, DWORD exStyle )
109 /* Correct the window style */
111 if (!(style & (WS_POPUP | WS_CHILD))) /* Overlapped window */
112 style |= WS_CAPTION;
113 if (exStyle & WS_EX_DLGMODALFRAME) style &= ~WS_THICKFRAME;
115 dprintf_nonclient(stddeb, "AdjustWindowRectEx: (%d,%d)-(%d,%d) %08lx %d %08lx\n",
116 rect->left, rect->top, rect->right, rect->bottom, style, menu, exStyle );
118 NC_AdjustRect( rect, style, menu, exStyle );
122 /***********************************************************************
123 * NC_HandleNCCalcSize
125 * Handle a WM_NCCALCSIZE message. Called from DefWindowProc().
127 LONG NC_HandleNCCalcSize( HWND hwnd, NCCALCSIZE_PARAMS *params )
129 RECT tmpRect = { 0, 0, 0, 0 };
130 WND *wndPtr = WIN_FindWndPtr( hwnd );
132 if (!wndPtr) return 0;
135 * we don't want to change the size if hwnd is an icon since
136 * there are no window manager handles on an icon
138 if(IsIconic(hwnd)) return 0;
140 NC_AdjustRect( &tmpRect, wndPtr->dwStyle, FALSE, wndPtr->dwExStyle );
141 params->rgrc[0].left -= tmpRect.left;
142 params->rgrc[0].top -= tmpRect.top;
143 params->rgrc[0].right -= tmpRect.right;
144 params->rgrc[0].bottom -= tmpRect.bottom;
146 if (HAS_MENU(wndPtr))
148 params->rgrc[0].top += MENU_GetMenuBarHeight( hwnd,
149 params->rgrc[0].right - params->rgrc[0].left,
150 -tmpRect.left, -tmpRect.top ) + 1;
152 return 0;
156 /***********************************************************************
157 * NC_GetInsideRect
159 * Get the 'inside' rectangle of a window, i.e. the whole window rectangle
160 * but without the borders (if any).
161 * The rectangle is in window coordinates (for drawing with GetWindowDC()).
163 void NC_GetInsideRect( HWND hwnd, RECT *rect )
165 WND * wndPtr = WIN_FindWndPtr( hwnd );
167 rect->top = rect->left = 0;
168 rect->right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
169 rect->bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
171 /* Remove frame from rectangle */
172 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
174 InflateRect( rect, -SYSMETRICS_CXDLGFRAME, -SYSMETRICS_CYDLGFRAME);
175 if (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME) InflateRect( rect, -1, 0);
177 else
179 if (HAS_THICKFRAME( wndPtr->dwStyle ))
180 InflateRect( rect, -SYSMETRICS_CXFRAME, -SYSMETRICS_CYFRAME );
181 if (wndPtr->dwStyle & WS_BORDER)
182 InflateRect( rect, -SYSMETRICS_CXBORDER, -SYSMETRICS_CYBORDER );
187 /***********************************************************************
188 * NC_HandleNCHitTest
190 * Handle a WM_NCHITTEST message. Called from DefWindowProc().
192 LONG NC_HandleNCHitTest( HWND hwnd, POINT pt )
194 RECT rect;
195 WND *wndPtr = WIN_FindWndPtr( hwnd );
196 if (!wndPtr) return HTERROR;
198 dprintf_nonclient(stddeb, "NC_HandleNCHitTest: hwnd=%x pt=%d,%d\n",
199 hwnd, pt.x, pt.y );
201 GetWindowRect( hwnd, &rect );
202 if (!PtInRect( &rect, pt )) return HTNOWHERE;
205 * if this is a iconic window, we don't care were the hit
206 * occured, only that it did occur, just return HTCAPTION
207 * so the caller knows the icon did get hit
209 if (IsIconic(hwnd))
211 return HTCAPTION; /* change this to something meaningful? */
214 /* Check borders */
215 if (HAS_THICKFRAME( wndPtr->dwStyle ))
217 InflateRect( &rect, -SYSMETRICS_CXFRAME, -SYSMETRICS_CYFRAME );
218 if (wndPtr->dwStyle & WS_BORDER)
219 InflateRect( &rect, -SYSMETRICS_CXBORDER, -SYSMETRICS_CYBORDER );
220 if (!PtInRect( &rect, pt ))
222 /* Check top sizing border */
223 if (pt.y < rect.top)
225 if (pt.x < rect.left+SYSMETRICS_CXSIZE) return HTTOPLEFT;
226 if (pt.x >= rect.right-SYSMETRICS_CXSIZE) return HTTOPRIGHT;
227 return HTTOP;
229 /* Check bottom sizing border */
230 if (pt.y >= rect.bottom)
232 if (pt.x < rect.left+SYSMETRICS_CXSIZE) return HTBOTTOMLEFT;
233 if (pt.x >= rect.right-SYSMETRICS_CXSIZE) return HTBOTTOMRIGHT;
234 return HTBOTTOM;
236 /* Check left sizing border */
237 if (pt.x < rect.left)
239 if (pt.y < rect.top+SYSMETRICS_CYSIZE) return HTTOPLEFT;
240 if (pt.y >= rect.bottom-SYSMETRICS_CYSIZE) return HTBOTTOMLEFT;
241 return HTLEFT;
243 /* Check right sizing border */
244 if (pt.x >= rect.right)
246 if (pt.y < rect.top+SYSMETRICS_CYSIZE) return HTTOPRIGHT;
247 if (pt.y >= rect.bottom-SYSMETRICS_CYSIZE) return HTBOTTOMRIGHT;
248 return HTRIGHT;
252 else /* No thick frame */
254 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
255 InflateRect(&rect, -SYSMETRICS_CXDLGFRAME, -SYSMETRICS_CYDLGFRAME);
256 else if (wndPtr->dwStyle & WS_BORDER)
257 InflateRect(&rect, -SYSMETRICS_CXBORDER, -SYSMETRICS_CYBORDER);
258 if (!PtInRect( &rect, pt )) return HTBORDER;
261 /* Check caption */
263 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
265 rect.top += SYSMETRICS_CYCAPTION - 1;
266 if (!PtInRect( &rect, pt ))
268 /* Check system menu */
269 if (wndPtr->dwStyle & WS_SYSMENU)
270 rect.left += SYSMETRICS_CXSIZE;
271 if (pt.x <= rect.left) return HTSYSMENU;
272 /* Check maximize box */
273 if (wndPtr->dwStyle & WS_MAXIMIZEBOX)
274 rect.right -= SYSMETRICS_CXSIZE + 1;
275 if (pt.x >= rect.right) return HTMAXBUTTON;
276 /* Check minimize box */
277 if (wndPtr->dwStyle & WS_MINIMIZEBOX)
278 rect.right -= SYSMETRICS_CXSIZE + 1;
279 if (pt.x >= rect.right) return HTMINBUTTON;
280 return HTCAPTION;
284 /* Check client area */
286 ScreenToClient( hwnd, &pt );
287 GetClientRect( hwnd, &rect );
288 if (PtInRect( &rect, pt )) return HTCLIENT;
290 /* Check vertical scroll bar */
292 if (wndPtr->dwStyle & WS_VSCROLL)
294 rect.right += SYSMETRICS_CXVSCROLL;
295 if (PtInRect( &rect, pt )) return HTVSCROLL;
298 /* Check horizontal scroll bar */
300 if (wndPtr->dwStyle & WS_HSCROLL)
302 rect.bottom += SYSMETRICS_CYHSCROLL;
303 if (PtInRect( &rect, pt ))
305 /* Check size box */
306 if ((wndPtr->dwStyle & WS_VSCROLL) &&
307 (pt.x >= rect.right - SYSMETRICS_CXVSCROLL))
308 return HTSIZE;
309 return HTHSCROLL;
313 /* Check menu bar */
315 if (HAS_MENU(wndPtr))
317 if ((pt.y < 0) && (pt.x >= 0) && (pt.x < rect.right))
318 return HTMENU;
321 /* Should never get here */
322 return HTERROR;
326 /***********************************************************************
327 * NC_DrawSysButton
329 void NC_DrawSysButton( HWND hwnd, HDC hdc, BOOL down )
331 RECT rect;
332 WND *wndPtr = WIN_FindWndPtr( hwnd );
333 NC_GetInsideRect( hwnd, &rect );
334 GRAPH_DrawBitmap( hdc, (wndPtr->dwStyle & WS_CHILD) ?
335 hbitmapMDIClose : hbitmapClose,
336 rect.left, rect.top,
337 1, 1, SYSMETRICS_CXSIZE, SYSMETRICS_CYSIZE,
338 down ? NOTSRCCOPY : SRCCOPY );
342 /***********************************************************************
343 * NC_DrawMaxButton
345 static void NC_DrawMaxButton( HWND hwnd, HDC hdc, BOOL down )
347 RECT rect;
348 NC_GetInsideRect( hwnd, &rect );
349 GRAPH_DrawBitmap( hdc, (IsZoomed(hwnd) ?
350 (down ? hbitmapRestoreD : hbitmapRestore) :
351 (down ? hbitmapMaximizeD : hbitmapMaximize)),
352 rect.right - SYSMETRICS_CXSIZE - 1, rect.top - 1,
353 0, 0, SYSMETRICS_CXSIZE+2, SYSMETRICS_CYSIZE+2, SRCCOPY );
357 /***********************************************************************
358 * NC_DrawMinButton
360 static void NC_DrawMinButton( HWND hwnd, HDC hdc, BOOL down )
362 RECT rect;
363 WND *wndPtr = WIN_FindWndPtr( hwnd );
364 NC_GetInsideRect( hwnd, &rect );
365 if (wndPtr->dwStyle & WS_MAXIMIZEBOX) rect.right -= SYSMETRICS_CXSIZE + 1;
366 GRAPH_DrawBitmap( hdc, (down ? hbitmapMinimizeD : hbitmapMinimize),
367 rect.right - SYSMETRICS_CXSIZE - 1, rect.top - 1,
368 0, 0, SYSMETRICS_CXSIZE+2, SYSMETRICS_CYSIZE+2, SRCCOPY );
372 /***********************************************************************
373 * NC_DrawFrame
375 * Draw a window frame inside the given rectangle, and update the rectangle.
376 * The correct pen for the frame must be selected in the DC.
378 static void NC_DrawFrame( HDC hdc, RECT *rect, BOOL dlgFrame, BOOL active )
380 short width, height, tmp;
382 if (dlgFrame)
384 width = SYSMETRICS_CXDLGFRAME - 1;
385 height = SYSMETRICS_CYDLGFRAME - 1;
386 SelectObject( hdc, active ? sysColorObjects.hbrushActiveCaption :
387 sysColorObjects.hbrushInactiveCaption );
389 else
391 width = SYSMETRICS_CXFRAME - 1;
392 height = SYSMETRICS_CYFRAME - 1;
393 SelectObject( hdc, active ? sysColorObjects.hbrushActiveBorder :
394 sysColorObjects.hbrushInactiveBorder );
397 /* Draw frame */
398 PatBlt( hdc, rect->left, rect->top,
399 rect->right - rect->left, height, PATCOPY );
400 PatBlt( hdc, rect->left, rect->top,
401 width, rect->bottom - rect->top, PATCOPY );
402 PatBlt( hdc, rect->left, rect->bottom,
403 rect->right - rect->left, -height, PATCOPY );
404 PatBlt( hdc, rect->right, rect->top,
405 -width, rect->bottom - rect->top, PATCOPY );
407 if (dlgFrame)
409 InflateRect( rect, -width, -height );
410 return;
413 /* Draw inner rectangle */
414 MoveTo( hdc, rect->left+width, rect->top+height );
415 LineTo( hdc, rect->right-width-1, rect->top+height );
416 LineTo( hdc, rect->right-width-1, rect->bottom-height-1 );
417 LineTo( hdc, rect->left+width, rect->bottom-height-1 );
418 LineTo( hdc, rect->left+width, rect->top+height );
420 /* Draw the decorations */
421 tmp = rect->top + SYSMETRICS_CYFRAME + SYSMETRICS_CYSIZE;
422 MoveTo( hdc, rect->left, tmp);
423 LineTo( hdc, rect->left+width, tmp );
424 MoveTo( hdc, rect->right-width-1, tmp );
425 LineTo( hdc, rect->right-1, tmp );
427 tmp = rect->bottom - 1 - SYSMETRICS_CYFRAME - SYSMETRICS_CYSIZE;
428 MoveTo( hdc, rect->left, tmp );
429 LineTo( hdc, rect->left+width, tmp );
430 MoveTo( hdc, rect->right-width-1, tmp );
431 LineTo( hdc, rect->right-1, tmp );
433 tmp = rect->left + SYSMETRICS_CXFRAME + SYSMETRICS_CXSIZE;
434 MoveTo( hdc, tmp, rect->top );
435 LineTo( hdc, tmp, rect->top+height );
436 MoveTo( hdc, tmp, rect->bottom-height-1 );
437 LineTo( hdc, tmp, rect->bottom-1 );
439 tmp = rect->right - 1 - SYSMETRICS_CXFRAME - SYSMETRICS_CYSIZE;
440 MoveTo( hdc, tmp, rect->top );
441 LineTo( hdc, tmp, rect->top+height );
442 MoveTo( hdc, tmp, rect->bottom-height-1 );
443 LineTo( hdc, tmp, rect->bottom-1 );
445 InflateRect( rect, -width-1, -height-1 );
449 /***********************************************************************
450 * NC_DrawMovingFrame
452 * Draw the frame used when moving or resizing window.
454 static void NC_DrawMovingFrame( HDC hdc, RECT *rect, BOOL thickframe )
456 if (thickframe)
458 SelectObject( hdc, GetStockObject( GRAY_BRUSH ) );
459 PatBlt( hdc, rect->left, rect->top,
460 rect->right - rect->left - SYSMETRICS_CXFRAME,
461 SYSMETRICS_CYFRAME, PATINVERT );
462 PatBlt( hdc, rect->left, rect->top + SYSMETRICS_CYFRAME,
463 SYSMETRICS_CXFRAME,
464 rect->bottom - rect->top - SYSMETRICS_CYFRAME, PATINVERT );
465 PatBlt( hdc, rect->left + SYSMETRICS_CXFRAME, rect->bottom,
466 rect->right - rect->left - SYSMETRICS_CXFRAME,
467 -SYSMETRICS_CYFRAME, PATINVERT );
468 PatBlt( hdc, rect->right, rect->top, -SYSMETRICS_CXFRAME,
469 rect->bottom - rect->top - SYSMETRICS_CYFRAME, PATINVERT );
471 else DrawFocusRect( hdc, rect );
475 /***********************************************************************
476 * NC_DrawCaption
478 * Draw the window caption.
479 * The correct pen for the window frame must be selected in the DC.
481 static void NC_DrawCaption( HDC hdc, RECT *rect, HWND hwnd,
482 DWORD style, BOOL active )
484 RECT r = *rect;
485 WND * wndPtr = WIN_FindWndPtr( hwnd );
486 char buffer[256];
488 if (!hbitmapClose)
490 if (!(hbitmapClose = LoadBitmap( 0, MAKEINTRESOURCE(OBM_CLOSE) )))
491 return;
492 if (!(hbitmapMDIClose = LoadBitmap( 0, MAKEINTRESOURCE(OBM_OLD_CLOSE) )))
493 return;
494 hbitmapMinimize = LoadBitmap( 0, MAKEINTRESOURCE(OBM_REDUCE) );
495 hbitmapMinimizeD = LoadBitmap( 0, MAKEINTRESOURCE(OBM_REDUCED) );
496 hbitmapMaximize = LoadBitmap( 0, MAKEINTRESOURCE(OBM_ZOOM) );
497 hbitmapMaximizeD = LoadBitmap( 0, MAKEINTRESOURCE(OBM_ZOOMD) );
498 hbitmapRestore = LoadBitmap( 0, MAKEINTRESOURCE(OBM_RESTORE) );
499 hbitmapRestoreD = LoadBitmap( 0, MAKEINTRESOURCE(OBM_RESTORED) );
502 if (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME)
504 HBRUSH hbrushOld = SelectObject( hdc, sysColorObjects.hbrushWindow );
505 PatBlt( hdc, r.left, r.top, 1, r.bottom-r.top+1,PATCOPY );
506 PatBlt( hdc, r.right-1, r.top, 1, r.bottom-r.top+1, PATCOPY );
507 PatBlt( hdc, r.left, r.top-1, r.right-r.left, 1, PATCOPY );
508 r.left++;
509 r.right--;
510 SelectObject( hdc, hbrushOld );
513 MoveTo( hdc, r.left, r.bottom );
514 LineTo( hdc, r.right-1, r.bottom );
516 if (style & WS_SYSMENU)
518 NC_DrawSysButton( hwnd, hdc, FALSE );
519 r.left += SYSMETRICS_CXSIZE + 1;
520 MoveTo( hdc, r.left - 1, r.top );
521 LineTo( hdc, r.left - 1, r.bottom );
523 if (style & WS_MAXIMIZEBOX)
525 NC_DrawMaxButton( hwnd, hdc, FALSE );
526 r.right -= SYSMETRICS_CXSIZE + 1;
528 if (style & WS_MINIMIZEBOX)
530 NC_DrawMinButton( hwnd, hdc, FALSE );
531 r.right -= SYSMETRICS_CXSIZE + 1;
534 FillRect( hdc, &r, active ? sysColorObjects.hbrushActiveCaption :
535 sysColorObjects.hbrushInactiveCaption );
537 if (GetWindowText( hwnd, buffer, 256 ))
539 if (active) SetTextColor( hdc, GetSysColor( COLOR_CAPTIONTEXT ) );
540 else SetTextColor( hdc, GetSysColor( COLOR_INACTIVECAPTIONTEXT ) );
541 SetBkMode( hdc, TRANSPARENT );
542 DrawText( hdc, buffer, -1, &r, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
547 /***********************************************************************
548 * NC_DoNCPaint
550 * Paint the non-client area.
551 * 'hrgn' is the update rgn to use (in client coords) or 1 if no update rgn.
553 void NC_DoNCPaint( HWND hwnd, HRGN hrgn, BOOL active, BOOL suppress_menupaint )
555 HDC hdc;
556 RECT rect, rect2;
558 WND *wndPtr = WIN_FindWndPtr( hwnd );
560 dprintf_nonclient(stddeb, "NC_DoNCPaint: %d %d\n", hwnd, hrgn );
561 if (!wndPtr || !hrgn) return;
562 if ((!(wndPtr->dwStyle & (WS_BORDER | WS_DLGFRAME | WS_THICKFRAME))) ||
563 (!(wndPtr->dwStyle & WS_VISIBLE)))
564 return; /* Nothing to do! */
566 if (hrgn == 1) hdc = GetDCEx( hwnd, 0, DCX_USESTYLE | DCX_WINDOW );
567 else
569 /* Make region relative to window area */
570 int xoffset = wndPtr->rectWindow.left - wndPtr->rectClient.left;
571 int yoffset = wndPtr->rectWindow.top - wndPtr->rectClient.top;
572 OffsetRgn( hrgn, -xoffset, -yoffset );
573 hdc = GetDCEx( hwnd, hrgn, DCX_USESTYLE|DCX_WINDOW|DCX_INTERSECTRGN );
574 OffsetRgn( hrgn, xoffset, yoffset ); /* Restore region */
576 if (!hdc) return;
580 * If this is an icon, we don't want to do any more nonclient painting
581 * of the window manager.
582 * If there is a class icon to draw, draw it
584 if (IsIconic(hwnd))
586 HICON hIcon = WIN_CLASS_INFO(wndPtr).hIcon;
587 if (hIcon)
589 SendMessage(hwnd, WM_ICONERASEBKGND, hdc, 0);
590 DrawIcon(hdc, 0, 0, hIcon);
592 ReleaseDC(hwnd, hdc);
593 return;
596 if (ExcludeVisRect( hdc, wndPtr->rectClient.left-wndPtr->rectWindow.left,
597 wndPtr->rectClient.top-wndPtr->rectWindow.top,
598 wndPtr->rectClient.right-wndPtr->rectWindow.left,
599 wndPtr->rectClient.bottom-wndPtr->rectWindow.top )
600 == NULLREGION)
602 ReleaseDC( hwnd, hdc );
603 return;
606 rect.top = rect.left = 0;
607 rect.right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
608 rect.bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
610 SelectObject( hdc, sysColorObjects.hpenWindowFrame );
612 if ((wndPtr->dwStyle & WS_BORDER) || (wndPtr->dwStyle & WS_DLGFRAME))
614 MoveTo( hdc, 0, 0 );
615 LineTo( hdc, rect.right-1, 0 );
616 LineTo( hdc, rect.right-1, rect.bottom-1 );
617 LineTo( hdc, 0, rect.bottom-1 );
618 LineTo( hdc, 0, 0 );
619 InflateRect( &rect, -1, -1 );
622 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
623 NC_DrawFrame( hdc, &rect, TRUE, active );
624 else if (wndPtr->dwStyle & WS_THICKFRAME)
625 NC_DrawFrame(hdc, &rect, FALSE, active );
627 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
629 RECT r = rect;
630 r.bottom = rect.top + SYSMETRICS_CYSIZE;
631 rect.top += SYSMETRICS_CYSIZE + SYSMETRICS_CYBORDER;
632 NC_DrawCaption( hdc, &r, hwnd, wndPtr->dwStyle, active );
635 if (HAS_MENU(wndPtr))
637 RECT r = rect;
638 r.bottom = rect.top + SYSMETRICS_CYMENU; /* default height */
639 rect.top += MENU_DrawMenuBar( hdc, &r, hwnd, suppress_menupaint );
642 if (wndPtr->dwStyle & (WS_VSCROLL | WS_HSCROLL)) {
643 if ((wndPtr->dwStyle & WS_VSCROLL) && (wndPtr->VScroll != NULL) &&
644 (wndPtr->scroll_flags & 0x0001)) {
645 int bottom = rect.bottom;
646 if ((wndPtr->dwStyle & WS_HSCROLL) && (wndPtr->scroll_flags & 0x0001))
647 bottom -= SYSMETRICS_CYHSCROLL;
648 SetRect(&rect2, rect.right - SYSMETRICS_CXVSCROLL,
649 rect.top, rect.right, bottom);
650 StdDrawScrollBar(hwnd, hdc, SB_VERT, &rect2, (LPHEADSCROLL)wndPtr->VScroll);
652 if ((wndPtr->dwStyle & WS_HSCROLL) && wndPtr->HScroll != NULL &&
653 (wndPtr->scroll_flags & 0x0002)) {
654 int right = rect.right;
655 if ((wndPtr->dwStyle & WS_VSCROLL) && (wndPtr->scroll_flags & 0x0001))
656 right -= SYSMETRICS_CYVSCROLL;
657 SetRect(&rect2, rect.left, rect.bottom - SYSMETRICS_CYHSCROLL,
658 right, rect.bottom);
659 StdDrawScrollBar(hwnd, hdc, SB_HORZ, &rect2, (LPHEADSCROLL)wndPtr->HScroll);
662 if ((wndPtr->dwStyle & WS_VSCROLL) && (wndPtr->dwStyle & WS_HSCROLL) &&
663 (wndPtr->scroll_flags & 0x0003) == 0x0003) {
664 RECT r = rect;
665 r.left = r.right - SYSMETRICS_CXVSCROLL;
666 r.top = r.bottom - SYSMETRICS_CYHSCROLL;
667 FillRect( hdc, &r, sysColorObjects.hbrushScrollbar );
671 ReleaseDC( hwnd, hdc );
676 /***********************************************************************
677 * NC_HandleNCPaint
679 * Handle a WM_NCPAINT message. Called from DefWindowProc().
681 LONG NC_HandleNCPaint( HWND hwnd, HRGN hrgn )
683 NC_DoNCPaint( hwnd, hrgn, hwnd == GetActiveWindow(), FALSE );
684 return 0;
688 /***********************************************************************
689 * NC_HandleNCActivate
691 * Handle a WM_NCACTIVATE message. Called from DefWindowProc().
693 LONG NC_HandleNCActivate( HWND hwnd, WORD wParam )
695 NC_DoNCPaint( hwnd, (HRGN)1, wParam, FALSE );
696 return TRUE;
700 /***********************************************************************
701 * NC_HandleSetCursor
703 * Handle a WM_SETCURSOR message. Called from DefWindowProc().
705 LONG NC_HandleSetCursor( HWND hwnd, WORD wParam, LONG lParam )
707 if (hwnd != wParam) return 0; /* Don't set the cursor for child windows */
709 switch(LOWORD(lParam))
711 case HTERROR:
713 WORD msg = HIWORD( lParam );
714 if ((msg == WM_LBUTTONDOWN) || (msg == WM_MBUTTONDOWN) ||
715 (msg == WM_RBUTTONDOWN))
716 MessageBeep(0);
718 break;
720 case HTCLIENT:
722 WND *wndPtr;
723 CLASS *classPtr;
724 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) break;
725 if (!(classPtr = CLASS_FindClassPtr( wndPtr->hClass ))) break;
726 if (classPtr->wc.hCursor)
728 SetCursor( classPtr->wc.hCursor );
729 return TRUE;
731 else return FALSE;
734 case HTLEFT:
735 case HTRIGHT:
736 return SetCursor( LoadCursor( 0, IDC_SIZEWE ) );
738 case HTTOP:
739 case HTBOTTOM:
740 return SetCursor( LoadCursor( 0, IDC_SIZENS ) );
742 case HTTOPLEFT:
743 case HTBOTTOMRIGHT:
744 return SetCursor( LoadCursor( 0, IDC_SIZENWSE ) );
746 case HTTOPRIGHT:
747 case HTBOTTOMLEFT:
748 return SetCursor( LoadCursor( 0, IDC_SIZENESW ) );
751 /* Default cursor: arrow */
752 return SetCursor( LoadCursor( 0, IDC_ARROW ) );
756 /***********************************************************************
757 * NC_StartSizeMove
759 * Initialisation of a move or resize, when initiatied from a menu choice.
760 * Return hit test code for caption or sizing border.
762 static LONG NC_StartSizeMove( HWND hwnd, WORD wParam, POINT *capturePoint )
764 LONG hittest = 0;
765 POINT pt;
766 MSG msg;
767 WND * wndPtr = WIN_FindWndPtr( hwnd );
769 if ((wParam & 0xfff0) == SC_MOVE)
771 /* Move pointer at the center of the caption */
772 RECT rect;
773 NC_GetInsideRect( hwnd, &rect );
774 if (wndPtr->dwStyle & WS_SYSMENU)
775 rect.left += SYSMETRICS_CXSIZE + 1;
776 if (wndPtr->dwStyle & WS_MINIMIZEBOX)
777 rect.right -= SYSMETRICS_CXSIZE + 1;
778 if (wndPtr->dwStyle & WS_MAXIMIZEBOX)
779 rect.right -= SYSMETRICS_CXSIZE + 1;
780 pt.x = wndPtr->rectWindow.left + (rect.right - rect.left) / 2;
781 pt.y = wndPtr->rectWindow.top + rect.top + SYSMETRICS_CYSIZE/2;
782 if (wndPtr->dwStyle & WS_CHILD)
783 ClientToScreen( wndPtr->hwndParent, &pt );
784 hittest = HTCAPTION;
786 else /* SC_SIZE */
788 SetCapture(hwnd);
789 while(!hittest)
791 MSG_GetHardwareMessage( &msg );
792 switch(msg.message)
794 case WM_MOUSEMOVE:
795 hittest = NC_HandleNCHitTest( hwnd, msg.pt );
796 pt = msg.pt;
797 if ((hittest < HTLEFT) || (hittest > HTBOTTOMRIGHT))
798 hittest = 0;
799 break;
801 case WM_LBUTTONUP:
802 return 0;
804 case WM_KEYDOWN:
805 switch(msg.wParam)
807 case VK_UP:
808 hittest = HTTOP;
809 pt.x =(wndPtr->rectWindow.left+wndPtr->rectWindow.right)/2;
810 pt.y = wndPtr->rectWindow.top + SYSMETRICS_CYFRAME / 2;
811 break;
812 case VK_DOWN:
813 hittest = HTBOTTOM;
814 pt.x =(wndPtr->rectWindow.left+wndPtr->rectWindow.right)/2;
815 pt.y = wndPtr->rectWindow.bottom - SYSMETRICS_CYFRAME / 2;
816 break;
817 case VK_LEFT:
818 hittest = HTLEFT;
819 pt.x = wndPtr->rectWindow.left + SYSMETRICS_CXFRAME / 2;
820 pt.y =(wndPtr->rectWindow.top+wndPtr->rectWindow.bottom)/2;
821 break;
822 case VK_RIGHT:
823 hittest = HTRIGHT;
824 pt.x = wndPtr->rectWindow.right - SYSMETRICS_CXFRAME / 2;
825 pt.y =(wndPtr->rectWindow.top+wndPtr->rectWindow.bottom)/2;
826 break;
827 case VK_RETURN:
828 case VK_ESCAPE: return 0;
833 *capturePoint = pt;
834 SetCursorPos( capturePoint->x, capturePoint->y );
835 NC_HandleSetCursor( hwnd, hwnd, MAKELONG( hittest, WM_MOUSEMOVE ));
836 return hittest;
840 /***********************************************************************
841 * NC_DoSizeMove
843 * Perform SC_MOVE and SC_SIZE commands.
845 static void NC_DoSizeMove( HWND hwnd, WORD wParam, POINT pt )
847 MSG msg;
848 LONG hittest;
849 RECT sizingRect, mouseRect;
850 HDC hdc;
851 BOOL thickframe;
852 POINT minTrack, maxTrack, capturePoint = pt;
853 WND * wndPtr = WIN_FindWndPtr( hwnd );
855 if (IsZoomed(hwnd) || !IsWindowVisible(hwnd)) return;
856 hittest = wParam & 0x0f;
857 thickframe = HAS_THICKFRAME( wndPtr->dwStyle );
859 if ((wParam & 0xfff0) == SC_MOVE)
861 if (!(wndPtr->dwStyle & WS_CAPTION)) return;
862 if (!hittest) hittest = NC_StartSizeMove( hwnd, wParam, &capturePoint );
863 if (!hittest) return;
865 else /* SC_SIZE */
867 if (!thickframe) return;
868 if (hittest) hittest += HTLEFT-1;
869 else
871 SetCapture(hwnd);
872 hittest = NC_StartSizeMove( hwnd, wParam, &capturePoint );
873 if (!hittest)
875 ReleaseCapture();
876 return;
881 /* Get min/max info */
883 WINPOS_GetMinMaxInfo( hwnd, NULL, NULL, &minTrack, &maxTrack );
884 sizingRect = wndPtr->rectWindow;
885 if (wndPtr->dwStyle & WS_CHILD)
886 GetClientRect( wndPtr->hwndParent, &mouseRect );
887 else SetRect( &mouseRect, 0, 0, SYSMETRICS_CXSCREEN, SYSMETRICS_CYSCREEN );
888 if (ON_LEFT_BORDER(hittest))
890 mouseRect.left = max( mouseRect.left, sizingRect.right-maxTrack.x );
891 mouseRect.right = min( mouseRect.right, sizingRect.right-minTrack.x );
893 else if (ON_RIGHT_BORDER(hittest))
895 mouseRect.left = max( mouseRect.left, sizingRect.left+minTrack.x );
896 mouseRect.right = min( mouseRect.right, sizingRect.left+maxTrack.x );
898 if (ON_TOP_BORDER(hittest))
900 mouseRect.top = max( mouseRect.top, sizingRect.bottom-maxTrack.y );
901 mouseRect.bottom = min( mouseRect.bottom,sizingRect.bottom-minTrack.y);
903 else if (ON_BOTTOM_BORDER(hittest))
905 mouseRect.top = max( mouseRect.top, sizingRect.top+minTrack.y );
906 mouseRect.bottom = min( mouseRect.bottom, sizingRect.top+maxTrack.y );
908 SendMessage( hwnd, WM_ENTERSIZEMOVE, 0, 0 );
910 if (GetCapture() != hwnd) SetCapture( hwnd );
912 if (wndPtr->dwStyle & WS_CHILD) hdc = GetDC( wndPtr->hwndParent );
913 else
914 { /* Grab the server only when moving top-level windows without desktop */
915 hdc = GetDC( 0 );
916 if (rootWindow == DefaultRootWindow(display)) XGrabServer( display );
918 NC_DrawMovingFrame( hdc, &sizingRect, thickframe );
920 while(1)
922 int dx = 0, dy = 0;
924 MSG_GetHardwareMessage( &msg );
926 /* Exit on button-up, Return, or Esc */
927 if ((msg.message == WM_LBUTTONUP) ||
928 ((msg.message == WM_KEYDOWN) &&
929 ((msg.wParam == VK_RETURN) || (msg.wParam == VK_ESCAPE)))) break;
931 if ((msg.message != WM_KEYDOWN) && (msg.message != WM_MOUSEMOVE))
932 continue; /* We are not interested in other messages */
934 pt = msg.pt;
935 if (wndPtr->dwStyle & WS_CHILD)
936 ScreenToClient( wndPtr->hwndParent, &pt );
939 if (msg.message == WM_KEYDOWN) switch(msg.wParam)
941 case VK_UP: pt.y -= 8; break;
942 case VK_DOWN: pt.y += 8; break;
943 case VK_LEFT: pt.x -= 8; break;
944 case VK_RIGHT: pt.x += 8; break;
947 pt.x = max( pt.x, mouseRect.left );
948 pt.x = min( pt.x, mouseRect.right );
949 pt.y = max( pt.y, mouseRect.top );
950 pt.y = min( pt.y, mouseRect.bottom );
952 dx = pt.x - capturePoint.x;
953 dy = pt.y - capturePoint.y;
955 if (dx || dy)
957 if (msg.message == WM_KEYDOWN) SetCursorPos( pt.x, pt.y );
958 else
960 RECT newRect = sizingRect;
962 if (hittest == HTCAPTION) OffsetRect( &newRect, dx, dy );
963 if (ON_LEFT_BORDER(hittest)) newRect.left += dx;
964 else if (ON_RIGHT_BORDER(hittest)) newRect.right += dx;
965 if (ON_TOP_BORDER(hittest)) newRect.top += dy;
966 else if (ON_BOTTOM_BORDER(hittest)) newRect.bottom += dy;
967 NC_DrawMovingFrame( hdc, &sizingRect, thickframe );
968 NC_DrawMovingFrame( hdc, &newRect, thickframe );
969 capturePoint = pt;
970 sizingRect = newRect;
975 NC_DrawMovingFrame( hdc, &sizingRect, thickframe );
976 ReleaseCapture();
977 if (wndPtr->dwStyle & WS_CHILD) ReleaseDC( wndPtr->hwndParent, hdc );
978 else
980 ReleaseDC( 0, hdc );
981 if (rootWindow == DefaultRootWindow(display)) XUngrabServer( display );
983 SendMessage( hwnd, WM_EXITSIZEMOVE, 0, 0 );
985 /* If Esc key, don't move the window */
986 if ((msg.message == WM_KEYDOWN) && (msg.wParam == VK_ESCAPE)) return;
988 if (hittest != HTCAPTION)
989 SetWindowPos( hwnd, 0, sizingRect.left, sizingRect.top,
990 sizingRect.right - sizingRect.left,
991 sizingRect.bottom - sizingRect.top,
992 SWP_NOACTIVATE | SWP_NOZORDER );
993 else SetWindowPos( hwnd, 0, sizingRect.left, sizingRect.top, 0, 0,
994 SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER );
998 /***********************************************************************
999 * NC_TrackMinMaxBox
1001 * Track a mouse button press on the minimize or maximize box.
1003 static void NC_TrackMinMaxBox( HWND hwnd, WORD wParam )
1005 MSG msg;
1006 HDC hdc = GetWindowDC( hwnd );
1007 BOOL pressed = TRUE;
1009 SetCapture( hwnd );
1010 if (wParam == HTMINBUTTON) NC_DrawMinButton( hwnd, hdc, TRUE );
1011 else NC_DrawMaxButton( hwnd, hdc, TRUE );
1015 BOOL oldstate = pressed;
1016 MSG_GetHardwareMessage( &msg );
1018 pressed = (NC_HandleNCHitTest( hwnd, msg.pt ) == wParam);
1019 if (pressed != oldstate)
1021 if (wParam == HTMINBUTTON) NC_DrawMinButton( hwnd, hdc, pressed );
1022 else NC_DrawMaxButton( hwnd, hdc, pressed );
1024 } while (msg.message != WM_LBUTTONUP);
1026 if (wParam == HTMINBUTTON) NC_DrawMinButton( hwnd, hdc, FALSE );
1027 else NC_DrawMaxButton( hwnd, hdc, FALSE );
1029 ReleaseCapture();
1030 ReleaseDC( hwnd, hdc );
1031 if (!pressed) return;
1033 if (wParam == HTMINBUTTON)
1034 SendMessage( hwnd, WM_SYSCOMMAND, SC_MINIMIZE, *(LONG*)&msg.pt );
1035 else
1036 SendMessage( hwnd, WM_SYSCOMMAND,
1037 IsZoomed(hwnd) ? SC_RESTORE : SC_MAXIMIZE, *(LONG*)&msg.pt );
1041 /***********************************************************************
1042 * NC_TrackScrollBar
1044 * Track a mouse button press on the horizontal or vertical scroll-bar.
1046 static void NC_TrackScrollBar( HWND hwnd, WORD wParam, POINT pt )
1048 MSG msg;
1049 WORD scrollbar;
1050 if ((wParam & 0xfff0) == SC_HSCROLL)
1052 if ((wParam & 0x0f) != HTHSCROLL) return;
1053 scrollbar = SB_HORZ;
1055 else /* SC_VSCROLL */
1057 if ((wParam & 0x0f) != HTVSCROLL) return;
1058 scrollbar = SB_VERT;
1061 ScreenToClient( hwnd, &pt );
1062 ScrollBarButtonDown( hwnd, scrollbar, pt.x, pt.y );
1063 SetCapture( hwnd );
1067 MSG_GetHardwareMessage( &msg );
1068 ScreenToClient( hwnd, &msg.pt );
1069 switch(msg.message)
1071 case WM_LBUTTONUP:
1072 ScrollBarButtonUp( hwnd, scrollbar, msg.pt.x, msg.pt.y );
1073 break;
1074 case WM_MOUSEMOVE:
1075 ScrollBarMouseMove(hwnd, scrollbar, msg.wParam, msg.pt.x,msg.pt.y);
1076 break;
1078 } while (msg.message != WM_LBUTTONUP);
1079 ReleaseCapture();
1082 /***********************************************************************
1083 * NC_TrackSysMenu
1085 * Track a mouse button press on the system menu.
1087 static void NC_TrackSysMenu( HWND hwnd, HDC hdc, POINT pt )
1089 RECT rect;
1090 WND *wndPtr = WIN_FindWndPtr( hwnd );
1092 if (!(wndPtr->dwStyle & WS_SYSMENU)) return;
1093 /* If window has a menu, track the menu bar normally */
1094 if (HAS_MENU(wndPtr)) MENU_TrackMouseMenuBar( hwnd, pt );
1095 else
1097 /* Otherwise track the system menu like a normal popup menu */
1098 NC_GetInsideRect( hwnd, &rect );
1099 OffsetRect( &rect, wndPtr->rectWindow.left, wndPtr->rectWindow.top );
1100 if (wndPtr->dwStyle & WS_CHILD)
1101 ClientToScreen( wndPtr->hwndParent, (POINT *)&rect );
1102 rect.right = rect.left + SYSMETRICS_CXSIZE;
1103 rect.bottom = rect.top + SYSMETRICS_CYSIZE;
1104 NC_DrawSysButton( hwnd, hdc, TRUE );
1105 TrackPopupMenu( wndPtr->hSysMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON,
1106 rect.left, rect.bottom, 0, hwnd, &rect );
1107 NC_DrawSysButton( hwnd, hdc, FALSE );
1112 /***********************************************************************
1113 * NC_HandleNCLButtonDown
1115 * Handle a WM_NCLBUTTONDOWN message. Called from DefWindowProc().
1117 LONG NC_HandleNCLButtonDown( HWND hwnd, WORD wParam, LONG lParam )
1119 HDC hdc = GetWindowDC( hwnd );
1121 switch(wParam) /* Hit test */
1123 case HTCAPTION:
1124 SendMessage( hwnd, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, lParam );
1125 break;
1127 case HTSYSMENU:
1128 NC_TrackSysMenu( hwnd, hdc, MAKEPOINT(lParam) );
1129 break;
1131 case HTMENU:
1132 SendMessage( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU, lParam );
1133 break;
1135 case HTHSCROLL:
1136 SendMessage( hwnd, WM_SYSCOMMAND, SC_HSCROLL + HTHSCROLL, lParam );
1137 break;
1139 case HTVSCROLL:
1140 SendMessage( hwnd, WM_SYSCOMMAND, SC_VSCROLL + HTVSCROLL, lParam );
1141 break;
1143 case HTMINBUTTON:
1144 case HTMAXBUTTON:
1145 NC_TrackMinMaxBox( hwnd, wParam );
1146 break;
1148 case HTLEFT:
1149 case HTRIGHT:
1150 case HTTOP:
1151 case HTTOPLEFT:
1152 case HTTOPRIGHT:
1153 case HTBOTTOM:
1154 case HTBOTTOMLEFT:
1155 case HTBOTTOMRIGHT:
1156 SendMessage( hwnd, WM_SYSCOMMAND, SC_SIZE + wParam - HTLEFT+1, lParam);
1157 break;
1159 case HTBORDER:
1160 break;
1163 ReleaseDC( hwnd, hdc );
1164 return 0;
1168 /***********************************************************************
1169 * NC_HandleNCLButtonDblClk
1171 * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc().
1173 LONG NC_HandleNCLButtonDblClk( HWND hwnd, WORD wParam, LONG lParam )
1176 * if this is an icon, send a restore since we are handling
1177 * a double click
1179 if (IsIconic(hwnd))
1181 SendMessage(hwnd, WM_SYSCOMMAND, SC_RESTORE, lParam);
1182 return 0;
1185 switch(wParam) /* Hit test */
1187 case HTCAPTION:
1188 SendMessage( hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, lParam );
1189 break;
1191 case HTSYSMENU:
1192 SendMessage( hwnd, WM_SYSCOMMAND, SC_CLOSE, lParam );
1193 break;
1195 return 0;
1199 /***********************************************************************
1200 * NC_HandleSysCommand
1202 * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
1204 LONG NC_HandleSysCommand( HWND hwnd, WORD wParam, POINT pt )
1206 WND *wndPtr = WIN_FindWndPtr( hwnd );
1208 dprintf_nonclient(stddeb, "Handling WM_SYSCOMMAND %x %d,%d\n",
1209 wParam, pt.x, pt.y );
1211 if (wndPtr->dwStyle & WS_CHILD) ScreenToClient( wndPtr->hwndParent, &pt );
1213 switch (wParam & 0xfff0)
1215 case SC_SIZE:
1216 case SC_MOVE:
1217 NC_DoSizeMove( hwnd, wParam, pt );
1218 break;
1220 case SC_MINIMIZE:
1221 ShowWindow( hwnd, SW_MINIMIZE );
1222 break;
1224 case SC_MAXIMIZE:
1225 ShowWindow( hwnd, SW_MAXIMIZE );
1226 break;
1228 case SC_RESTORE:
1229 ShowWindow( hwnd, SW_RESTORE );
1230 break;
1232 case SC_NEXTWINDOW:
1233 case SC_PREVWINDOW:
1234 break;
1236 case SC_CLOSE:
1237 return SendMessage( hwnd, WM_CLOSE, 0, 0 );
1239 case SC_VSCROLL:
1240 case SC_HSCROLL:
1241 if (wndPtr->dwStyle & WS_CHILD) ClientToScreen(wndPtr->hwndParent, &pt);
1242 NC_TrackScrollBar( hwnd, wParam, pt );
1243 break;
1245 case SC_MOUSEMENU:
1246 MENU_TrackMouseMenuBar( hwnd, pt );
1247 break;
1249 case SC_KEYMENU:
1250 MENU_TrackKbdMenuBar( hwnd, wParam );
1251 break;
1253 case SC_ARRANGE:
1254 break;
1256 case SC_TASKLIST:
1257 /* WinExec( "taskman.exe", SW_SHOWNORMAL ); */
1258 break;
1260 case SC_HOTKEY:
1261 break;
1263 case SC_SCREENSAVE:
1264 if (wParam == SC_ABOUTWINE)
1265 DialogBox( hSysRes, MAKEINTRESOURCE(2),
1266 hwnd, (WNDPROC)AboutWine_Proc );
1267 break;
1269 return 0;