2 * Non-client area window functions
4 * Copyright 1994 Alexandre Julliard
10 #include "wine/winuser16.h"
18 #include "cursoricon.h"
21 #include "nonclient.h"
22 #include "debugtools.h"
26 DEFAULT_DEBUG_CHANNEL(nonclient);
27 DECLARE_DEBUG_CHANNEL(shell);
29 BOOL NC_DrawGrayButton(HDC hdc, int x, int y);
31 static HBITMAP hbitmapClose;
32 static HBITMAP hbitmapMinimize;
33 static HBITMAP hbitmapMinimizeD;
34 static HBITMAP hbitmapMaximize;
35 static HBITMAP hbitmapMaximizeD;
36 static HBITMAP hbitmapRestore;
37 static HBITMAP hbitmapRestoreD;
39 static const BYTE lpGrayMask[] = { 0xAA, 0xA0,
50 #define SC_ABOUTWINE (SC_SCREENSAVE+1)
51 #define SC_PUTMARK (SC_SCREENSAVE+2)
53 /* Some useful macros */
54 #define HAS_DLGFRAME(style,exStyle) \
55 (((exStyle) & WS_EX_DLGMODALFRAME) || \
56 (((style) & WS_DLGFRAME) && !((style) & WS_THICKFRAME)))
58 #define HAS_THICKFRAME(style,exStyle) \
59 (((style) & WS_THICKFRAME) && \
60 !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
62 #define HAS_THINFRAME(style) \
63 (((style) & WS_BORDER) || !((style) & (WS_CHILD | WS_POPUP)))
65 #define HAS_BIGFRAME(style,exStyle) \
66 (((style) & (WS_THICKFRAME | WS_DLGFRAME)) || \
67 ((exStyle) & WS_EX_DLGMODALFRAME))
69 #define HAS_ANYFRAME(style,exStyle) \
70 (((style) & (WS_THICKFRAME | WS_DLGFRAME | WS_BORDER)) || \
71 ((exStyle) & WS_EX_DLGMODALFRAME) || \
72 !((style) & (WS_CHILD | WS_POPUP)))
74 #define HAS_MENU(w) (!((w)->dwStyle & WS_CHILD) && ((w)->wIDmenu != 0))
77 /***********************************************************************
80 * Compute the size of the window rectangle from the size of the
83 static void NC_AdjustRect( LPRECT rect, DWORD style, BOOL menu, DWORD exStyle )
85 if (TWEAK_WineLook > WIN31_LOOK)
86 ERR("Called in Win95 mode. Aiee! Please report this.\n" );
88 if(style & WS_ICONIC) return;
90 if (HAS_THICKFRAME( style, exStyle ))
91 InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
92 else if (HAS_DLGFRAME( style, exStyle ))
93 InflateRect( rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
94 else if (HAS_THINFRAME( style ))
95 InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
97 if ((style & WS_CAPTION) == WS_CAPTION)
98 rect->top -= GetSystemMetrics(SM_CYCAPTION) - GetSystemMetrics(SM_CYBORDER);
100 if (menu) rect->top -= GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CYBORDER);
102 if (style & WS_VSCROLL) {
103 rect->right += GetSystemMetrics(SM_CXVSCROLL) - 1;
104 if(!HAS_ANYFRAME( style, exStyle ))
108 if (style & WS_HSCROLL) {
109 rect->bottom += GetSystemMetrics(SM_CYHSCROLL) - 1;
110 if(!HAS_ANYFRAME( style, exStyle ))
116 /******************************************************************************
117 * NC_AdjustRectOuter95
119 * Computes the size of the "outside" parts of the window based on the
120 * parameters of the client area.
129 * "Outer" parts of a window means the whole window frame, caption and
130 * menu bar. It does not include "inner" parts of the frame like client
131 * edge, static edge or scroll bars.
134 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
135 * Original (NC_AdjustRect95) cut & paste from NC_AdjustRect
137 * 20-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
138 * Split NC_AdjustRect95 into NC_AdjustRectOuter95 and
139 * NC_AdjustRectInner95 and added handling of Win95 styles.
141 * 28-Jul-1999 Ove Kåven (ovek@arcticnet.no)
142 * Streamlined window style checks.
144 *****************************************************************************/
147 NC_AdjustRectOuter95 (LPRECT rect, DWORD style, BOOL menu, DWORD exStyle)
149 if(style & WS_ICONIC) return;
151 if (HAS_THICKFRAME( style, exStyle ))
152 InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
153 else if (HAS_DLGFRAME( style, exStyle ))
154 InflateRect(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
155 else if (HAS_THINFRAME( style ))
156 InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
158 if ((style & WS_CAPTION) == WS_CAPTION)
160 if (exStyle & WS_EX_TOOLWINDOW)
161 rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
163 rect->top -= GetSystemMetrics(SM_CYCAPTION);
165 if (menu) rect->top -= GetSystemMetrics(SM_CYMENU);
169 /******************************************************************************
170 * NC_AdjustRectInner95
172 * Computes the size of the "inside" part of the window based on the
173 * parameters of the client area.
181 * "Inner" part of a window means the window frame inside of the flat
182 * window frame. It includes the client edge, the static edge and the
186 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
187 * Original (NC_AdjustRect95) cut & paste from NC_AdjustRect
189 * 20-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
190 * Split NC_AdjustRect95 into NC_AdjustRectOuter95 and
191 * NC_AdjustRectInner95 and added handling of Win95 styles.
193 *****************************************************************************/
196 NC_AdjustRectInner95 (LPRECT rect, DWORD style, DWORD exStyle)
198 if(style & WS_ICONIC) return;
200 if (exStyle & WS_EX_CLIENTEDGE)
201 InflateRect(rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
203 if (exStyle & WS_EX_STATICEDGE)
204 InflateRect(rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
206 if (style & WS_VSCROLL) rect->right += GetSystemMetrics(SM_CXVSCROLL);
207 if (style & WS_HSCROLL) rect->bottom += GetSystemMetrics(SM_CYHSCROLL);
212 static HICON NC_IconForWindow( HWND hwnd )
214 HICON hIcon = (HICON) GetClassLongA( hwnd, GCL_HICONSM );
215 if (!hIcon) hIcon = (HICON) GetClassLongA( hwnd, GCL_HICON );
217 /* If there is no hIcon specified and this is a modal dialog,
218 * get the default one.
220 if (!hIcon && (GetWindowLongA( hwnd, GWL_STYLE ) & DS_MODALFRAME))
221 hIcon = LoadImageA(0, IDI_WINLOGOA, IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
225 /***********************************************************************
226 * DrawCaption (USER.660) Draws a caption bar
240 DrawCaption16 (HWND16 hwnd, HDC16 hdc, const RECT16 *rect, UINT16 uFlags)
245 CONV_RECT16TO32 (rect, &rect32);
247 return (BOOL16)DrawCaptionTempA (hwnd, hdc, rect ? &rect32 : NULL,
248 0, 0, NULL, uFlags & 0x1F);
252 /***********************************************************************
253 * DrawCaption (USER32.@) Draws a caption bar
267 DrawCaption (HWND hwnd, HDC hdc, const RECT *lpRect, UINT uFlags)
269 return DrawCaptionTempA (hwnd, hdc, lpRect, 0, 0, NULL, uFlags & 0x1F);
273 /***********************************************************************
274 * DrawCaptionTemp (USER.657)
284 DrawCaptionTemp16 (HWND16 hwnd, HDC16 hdc, const RECT16 *rect, HFONT16 hFont,
285 HICON16 hIcon, LPCSTR str, UINT16 uFlags)
290 CONV_RECT16TO32(rect,&rect32);
292 return (BOOL16)DrawCaptionTempA (hwnd, hdc, rect?&rect32:NULL, hFont,
293 hIcon, str, uFlags & 0x1F);
297 /***********************************************************************
298 * DrawCaptionTempA (USER32.@)
308 DrawCaptionTempA (HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont,
309 HICON hIcon, LPCSTR str, UINT uFlags)
313 TRACE("(%08x,%08x,%p,%08x,%08x,\"%s\",%08x)\n",
314 hwnd, hdc, rect, hFont, hIcon, str, uFlags);
316 /* drawing background */
317 if (uFlags & DC_INBUTTON) {
318 FillRect (hdc, &rc, GetSysColorBrush (COLOR_3DFACE));
320 if (uFlags & DC_ACTIVE) {
321 HBRUSH hbr = SelectObject (hdc, CACHE_GetPattern55AABrush ());
322 PatBlt (hdc, rc.left, rc.top,
323 rc.right-rc.left, rc.bottom-rc.top, 0xFA0089);
324 SelectObject (hdc, hbr);
328 FillRect (hdc, &rc, GetSysColorBrush ((uFlags & DC_ACTIVE) ?
329 COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION));
334 if ((uFlags & DC_ICON) && !(uFlags & DC_SMALLCAP)) {
338 pt.y = (rc.bottom + rc.top - GetSystemMetrics(SM_CYSMICON)) / 2;
340 if (!hIcon) hIcon = NC_IconForWindow(hwnd);
341 DrawIconEx (hdc, pt.x, pt.y, hIcon, GetSystemMetrics(SM_CXSMICON),
342 GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL);
343 rc.left += (rc.bottom - rc.top);
347 if (uFlags & DC_TEXT) {
350 if (uFlags & DC_INBUTTON)
351 SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
352 else if (uFlags & DC_ACTIVE)
353 SetTextColor (hdc, GetSysColor (COLOR_CAPTIONTEXT));
355 SetTextColor (hdc, GetSysColor (COLOR_INACTIVECAPTIONTEXT));
357 SetBkMode (hdc, TRANSPARENT);
360 hOldFont = SelectObject (hdc, hFont);
362 NONCLIENTMETRICSA nclm;
364 nclm.cbSize = sizeof(NONCLIENTMETRICSA);
365 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
366 hNewFont = CreateFontIndirectA ((uFlags & DC_SMALLCAP) ?
367 &nclm.lfSmCaptionFont : &nclm.lfCaptionFont);
368 hOldFont = SelectObject (hdc, hNewFont);
372 DrawTextA (hdc, str, -1, &rc,
373 DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT);
377 nLen = GetWindowTextA (hwnd, szText, 128);
378 DrawTextA (hdc, szText, nLen, &rc,
379 DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT);
383 SelectObject (hdc, hOldFont);
385 DeleteObject (SelectObject (hdc, hOldFont));
388 /* drawing focus ??? */
390 FIXME("undocumented flag (0x2000)!\n");
396 /***********************************************************************
397 * DrawCaptionTempW (USER32.@)
407 DrawCaptionTempW (HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont,
408 HICON hIcon, LPCWSTR str, UINT uFlags)
410 LPSTR p = HEAP_strdupWtoA (GetProcessHeap (), 0, str);
411 BOOL res = DrawCaptionTempA (hwnd, hdc, rect, hFont, hIcon, p, uFlags);
412 HeapFree (GetProcessHeap (), 0, p);
417 /***********************************************************************
418 * AdjustWindowRect (USER.102)
420 BOOL16 WINAPI AdjustWindowRect16( LPRECT16 rect, DWORD style, BOOL16 menu )
422 return AdjustWindowRectEx16( rect, style, menu, 0 );
426 /***********************************************************************
427 * AdjustWindowRect (USER32.@)
429 BOOL WINAPI AdjustWindowRect( LPRECT rect, DWORD style, BOOL menu )
431 return AdjustWindowRectEx( rect, style, menu, 0 );
435 /***********************************************************************
436 * AdjustWindowRectEx (USER.454)
438 BOOL16 WINAPI AdjustWindowRectEx16( LPRECT16 rect, DWORD style,
439 BOOL16 menu, DWORD exStyle )
444 CONV_RECT16TO32( rect, &rect32 );
445 ret = AdjustWindowRectEx( &rect32, style, menu, exStyle );
446 CONV_RECT32TO16( &rect32, rect );
451 /***********************************************************************
452 * AdjustWindowRectEx (USER32.@)
454 BOOL WINAPI AdjustWindowRectEx( LPRECT rect, DWORD style, BOOL menu, DWORD exStyle )
456 /* Correct the window style */
458 if (!(style & (WS_POPUP | WS_CHILD))) style |= WS_CAPTION; /* Overlapped window */
459 style &= (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME | WS_CHILD);
460 exStyle &= (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE |
461 WS_EX_STATICEDGE | WS_EX_TOOLWINDOW);
462 if (exStyle & WS_EX_DLGMODALFRAME) style &= ~WS_THICKFRAME;
464 TRACE("(%d,%d)-(%d,%d) %08lx %d %08lx\n",
465 rect->left, rect->top, rect->right, rect->bottom,
466 style, menu, exStyle );
468 if (TWEAK_WineLook == WIN31_LOOK)
469 NC_AdjustRect( rect, style, menu, exStyle );
472 NC_AdjustRectOuter95( rect, style, menu, exStyle );
473 NC_AdjustRectInner95( rect, style, exStyle );
479 /***********************************************************************
480 * NC_HandleNCCalcSize
482 * Handle a WM_NCCALCSIZE message. Called from DefWindowProc().
484 LONG NC_HandleNCCalcSize( WND *pWnd, RECT *winRect )
486 RECT tmpRect = { 0, 0, 0, 0 };
488 UINT style = (UINT) GetClassLongA(pWnd->hwndSelf, GCL_STYLE);
490 if (style & CS_VREDRAW) result |= WVR_VREDRAW;
491 if (style & CS_HREDRAW) result |= WVR_HREDRAW;
493 if( !( pWnd->dwStyle & WS_MINIMIZE ) ) {
494 if (TWEAK_WineLook == WIN31_LOOK)
495 NC_AdjustRect( &tmpRect, pWnd->dwStyle, FALSE, pWnd->dwExStyle );
497 NC_AdjustRectOuter95( &tmpRect, pWnd->dwStyle, FALSE, pWnd->dwExStyle );
499 winRect->left -= tmpRect.left;
500 winRect->top -= tmpRect.top;
501 winRect->right -= tmpRect.right;
502 winRect->bottom -= tmpRect.bottom;
504 if (HAS_MENU(pWnd)) {
505 TRACE("Calling GetMenuBarHeight with HWND 0x%x, width %d, "
506 "at (%d, %d).\n", pWnd->hwndSelf,
507 winRect->right - winRect->left,
508 -tmpRect.left, -tmpRect.top );
511 MENU_GetMenuBarHeight( pWnd->hwndSelf,
512 winRect->right - winRect->left,
513 -tmpRect.left, -tmpRect.top ) + 1;
516 if (TWEAK_WineLook > WIN31_LOOK) {
517 SetRect(&tmpRect, 0, 0, 0, 0);
518 NC_AdjustRectInner95 (&tmpRect, pWnd->dwStyle, pWnd->dwExStyle);
519 winRect->left -= tmpRect.left;
520 winRect->top -= tmpRect.top;
521 winRect->right -= tmpRect.right;
522 winRect->bottom -= tmpRect.bottom;
525 if (winRect->top > winRect->bottom)
526 winRect->bottom = winRect->top;
528 if (winRect->left > winRect->right)
529 winRect->right = winRect->left;
535 /***********************************************************************
538 * Get the 'inside' rectangle of a window, i.e. the whole window rectangle
539 * but without the borders (if any).
540 * The rectangle is in window coordinates (for drawing with GetWindowDC()).
542 void NC_GetInsideRect( HWND hwnd, RECT *rect )
544 WND * wndPtr = WIN_FindWndPtr( hwnd );
546 rect->top = rect->left = 0;
547 rect->right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
548 rect->bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
550 if (wndPtr->dwStyle & WS_ICONIC) goto END;
552 /* Remove frame from rectangle */
553 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
555 InflateRect( rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) );
557 else if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
559 InflateRect( rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
560 /* FIXME: this isn't in NC_AdjustRect? why not? */
561 if ((TWEAK_WineLook == WIN31_LOOK) && (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME))
562 InflateRect( rect, -1, 0 );
564 else if (HAS_THINFRAME( wndPtr->dwStyle ))
566 InflateRect( rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER) );
569 /* We have additional border information if the window
570 * is a child (but not an MDI child) */
571 if (TWEAK_WineLook != WIN31_LOOK)
573 if ( (wndPtr->dwStyle & WS_CHILD) &&
574 ( (wndPtr->dwExStyle & WS_EX_MDICHILD) == 0 ) )
576 if (wndPtr->dwExStyle & WS_EX_CLIENTEDGE)
577 InflateRect (rect, -GetSystemMetrics(SM_CXEDGE), -GetSystemMetrics(SM_CYEDGE));
578 if (wndPtr->dwExStyle & WS_EX_STATICEDGE)
579 InflateRect (rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
584 WIN_ReleaseWndPtr(wndPtr);
589 /***********************************************************************
592 * Handle a WM_NCHITTEST message. Called from NC_HandleNCHitTest().
595 static LONG NC_DoNCHitTest (WND *wndPtr, POINT pt )
599 TRACE("hwnd=%04x pt=%ld,%ld\n", wndPtr->hwndSelf, pt.x, pt.y );
601 GetWindowRect(wndPtr->hwndSelf, &rect );
602 if (!PtInRect( &rect, pt )) return HTNOWHERE;
604 if (wndPtr->dwStyle & WS_MINIMIZE) return HTCAPTION;
607 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
609 InflateRect( &rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) );
610 if (!PtInRect( &rect, pt ))
612 /* Check top sizing border */
615 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTTOPLEFT;
616 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTTOPRIGHT;
619 /* Check bottom sizing border */
620 if (pt.y >= rect.bottom)
622 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMLEFT;
623 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMRIGHT;
626 /* Check left sizing border */
627 if (pt.x < rect.left)
629 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPLEFT;
630 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMLEFT;
633 /* Check right sizing border */
634 if (pt.x >= rect.right)
636 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPRIGHT;
637 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMRIGHT;
642 else /* No thick frame */
644 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
645 InflateRect(&rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
646 else if (HAS_THINFRAME( wndPtr->dwStyle ))
647 InflateRect(&rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
648 if (!PtInRect( &rect, pt )) return HTBORDER;
653 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
655 rect.top += GetSystemMetrics(SM_CYCAPTION) - GetSystemMetrics(SM_CYBORDER);
656 if (!PtInRect( &rect, pt ))
658 /* Check system menu */
659 if ((wndPtr->dwStyle & WS_SYSMENU) && !(wndPtr->dwExStyle & WS_EX_TOOLWINDOW))
660 rect.left += GetSystemMetrics(SM_CXSIZE);
661 if (pt.x <= rect.left) return HTSYSMENU;
663 /* Check maximize box */
664 if (wndPtr->dwStyle & WS_MAXIMIZEBOX)
665 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
667 if (pt.x >= rect.right) return HTMAXBUTTON;
668 /* Check minimize box */
669 if (wndPtr->dwStyle & WS_MINIMIZEBOX)
670 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
671 if (pt.x >= rect.right) return HTMINBUTTON;
676 /* Check client area */
678 ScreenToClient( wndPtr->hwndSelf, &pt );
679 GetClientRect( wndPtr->hwndSelf, &rect );
680 if (PtInRect( &rect, pt )) return HTCLIENT;
682 /* Check vertical scroll bar */
684 if (wndPtr->dwStyle & WS_VSCROLL)
686 rect.right += GetSystemMetrics(SM_CXVSCROLL);
687 if (PtInRect( &rect, pt )) return HTVSCROLL;
690 /* Check horizontal scroll bar */
692 if (wndPtr->dwStyle & WS_HSCROLL)
694 rect.bottom += GetSystemMetrics(SM_CYHSCROLL);
695 if (PtInRect( &rect, pt ))
698 if ((wndPtr->dwStyle & WS_VSCROLL) &&
699 (pt.x >= rect.right - GetSystemMetrics(SM_CXVSCROLL)))
707 if (HAS_MENU(wndPtr))
709 if ((pt.y < 0) && (pt.x >= 0) && (pt.x < rect.right))
713 /* Has to return HTNOWHERE if nothing was found
714 Could happen when a window has a customized non client area */
719 /***********************************************************************
722 * Handle a WM_NCHITTEST message. Called from NC_HandleNCHitTest().
724 * FIXME: Just a modified copy of the Win 3.1 version.
727 static LONG NC_DoNCHitTest95 (WND *wndPtr, POINT pt )
731 TRACE("hwnd=%04x pt=%ld,%ld\n", wndPtr->hwndSelf, pt.x, pt.y );
733 GetWindowRect(wndPtr->hwndSelf, &rect );
734 if (!PtInRect( &rect, pt )) return HTNOWHERE;
736 if (wndPtr->dwStyle & WS_MINIMIZE) return HTCAPTION;
739 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
741 InflateRect( &rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) );
742 if (!PtInRect( &rect, pt ))
744 /* Check top sizing border */
747 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTTOPLEFT;
748 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTTOPRIGHT;
751 /* Check bottom sizing border */
752 if (pt.y >= rect.bottom)
754 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMLEFT;
755 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMRIGHT;
758 /* Check left sizing border */
759 if (pt.x < rect.left)
761 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPLEFT;
762 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMLEFT;
765 /* Check right sizing border */
766 if (pt.x >= rect.right)
768 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPRIGHT;
769 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMRIGHT;
774 else /* No thick frame */
776 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
777 InflateRect(&rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
778 else if (HAS_THINFRAME( wndPtr->dwStyle ))
779 InflateRect(&rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
780 if (!PtInRect( &rect, pt )) return HTBORDER;
785 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
787 if (wndPtr->dwExStyle & WS_EX_TOOLWINDOW)
788 rect.top += GetSystemMetrics(SM_CYSMCAPTION) - 1;
790 rect.top += GetSystemMetrics(SM_CYCAPTION) - 1;
791 if (!PtInRect( &rect, pt ))
793 /* Check system menu */
794 if ((wndPtr->dwStyle & WS_SYSMENU) && !(wndPtr->dwExStyle & WS_EX_TOOLWINDOW))
796 if (NC_IconForWindow(wndPtr->hwndSelf))
797 rect.left += GetSystemMetrics(SM_CYCAPTION) - 1;
799 if (pt.x < rect.left) return HTSYSMENU;
801 /* Check close button */
802 if (wndPtr->dwStyle & WS_SYSMENU)
803 rect.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
804 if (pt.x > rect.right) return HTCLOSE;
806 /* Check maximize box */
807 /* In win95 there is automatically a Maximize button when there is a minimize one*/
808 if ((wndPtr->dwStyle & WS_MAXIMIZEBOX)|| (wndPtr->dwStyle & WS_MINIMIZEBOX))
809 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
810 if (pt.x > rect.right) return HTMAXBUTTON;
812 /* Check minimize box */
813 /* In win95 there is automatically a Maximize button when there is a Maximize one*/
814 if ((wndPtr->dwStyle & WS_MINIMIZEBOX)||(wndPtr->dwStyle & WS_MAXIMIZEBOX))
815 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
817 if (pt.x > rect.right) return HTMINBUTTON;
822 /* Check client area */
824 ScreenToClient( wndPtr->hwndSelf, &pt );
825 GetClientRect( wndPtr->hwndSelf, &rect );
826 if (PtInRect( &rect, pt )) return HTCLIENT;
828 /* Check vertical scroll bar */
830 if (wndPtr->dwStyle & WS_VSCROLL)
832 rect.right += GetSystemMetrics(SM_CXVSCROLL);
833 if (PtInRect( &rect, pt )) return HTVSCROLL;
836 /* Check horizontal scroll bar */
838 if (wndPtr->dwStyle & WS_HSCROLL)
840 rect.bottom += GetSystemMetrics(SM_CYHSCROLL);
841 if (PtInRect( &rect, pt ))
844 if ((wndPtr->dwStyle & WS_VSCROLL) &&
845 (pt.x >= rect.right - GetSystemMetrics(SM_CXVSCROLL)))
853 if (HAS_MENU(wndPtr))
855 if ((pt.y < 0) && (pt.x >= 0) && (pt.x < rect.right))
859 /* Has to return HTNOWHERE if nothing was found
860 Could happen when a window has a customized non client area */
865 /***********************************************************************
868 * Handle a WM_NCHITTEST message. Called from DefWindowProc().
870 LONG NC_HandleNCHitTest (HWND hwnd , POINT pt)
873 WND *wndPtr = WIN_FindWndPtr (hwnd);
878 if (TWEAK_WineLook == WIN31_LOOK)
879 retvalue = NC_DoNCHitTest (wndPtr, pt);
881 retvalue = NC_DoNCHitTest95 (wndPtr, pt);
882 WIN_ReleaseWndPtr(wndPtr);
887 /***********************************************************************
890 void NC_DrawSysButton( HWND hwnd, HDC hdc, BOOL down )
896 NC_GetInsideRect( hwnd, &rect );
897 hdcMem = CreateCompatibleDC( hdc );
898 hbitmap = SelectObject( hdcMem, hbitmapClose );
899 BitBlt(hdc, rect.left, rect.top, GetSystemMetrics(SM_CXSIZE), GetSystemMetrics(SM_CYSIZE),
900 hdcMem, (GetWindowLongA(hwnd,GWL_STYLE) & WS_CHILD) ? GetSystemMetrics(SM_CXSIZE) : 0, 0,
901 down ? NOTSRCCOPY : SRCCOPY );
902 SelectObject( hdcMem, hbitmap );
907 /***********************************************************************
910 static void NC_DrawMaxButton( HWND hwnd, HDC16 hdc, BOOL down )
915 NC_GetInsideRect( hwnd, &rect );
916 hdcMem = CreateCompatibleDC( hdc );
917 SelectObject( hdcMem, (IsZoomed(hwnd)
918 ? (down ? hbitmapRestoreD : hbitmapRestore)
919 : (down ? hbitmapMaximizeD : hbitmapMaximize)) );
920 BitBlt( hdc, rect.right - GetSystemMetrics(SM_CXSIZE) - 1, rect.top,
921 GetSystemMetrics(SM_CXSIZE) + 1, GetSystemMetrics(SM_CYSIZE), hdcMem, 0, 0,
928 /***********************************************************************
931 static void NC_DrawMinButton( HWND hwnd, HDC16 hdc, BOOL down )
936 NC_GetInsideRect( hwnd, &rect );
937 hdcMem = CreateCompatibleDC( hdc );
938 SelectObject( hdcMem, (down ? hbitmapMinimizeD : hbitmapMinimize) );
939 if (GetWindowLongA(hwnd,GWL_STYLE) & WS_MAXIMIZEBOX)
940 rect.right -= GetSystemMetrics(SM_CXSIZE)+1;
941 BitBlt( hdc, rect.right - GetSystemMetrics(SM_CXSIZE) - 1, rect.top,
942 GetSystemMetrics(SM_CXSIZE) + 1, GetSystemMetrics(SM_CYSIZE), hdcMem, 0, 0,
948 /******************************************************************************
950 * void NC_DrawSysButton95(
955 * Draws the Win95 system icon.
958 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
959 * Original implementation from NC_DrawSysButton source.
960 * 11-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
963 *****************************************************************************/
966 NC_DrawSysButton95 (HWND hwnd, HDC hdc, BOOL down)
968 HICON hIcon = NC_IconForWindow( hwnd );
973 NC_GetInsideRect( hwnd, &rect );
974 DrawIconEx (hdc, rect.left + 2, rect.top + 2, hIcon,
975 GetSystemMetrics(SM_CXSMICON),
976 GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL);
982 /******************************************************************************
984 * void NC_DrawCloseButton95(
990 * Draws the Win95 close button.
992 * If bGrayed is true, then draw a disabled Close button
995 * 11-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
996 * Original implementation from NC_DrawSysButton95 source.
998 *****************************************************************************/
1000 static void NC_DrawCloseButton95 (HWND hwnd, HDC hdc, BOOL down, BOOL bGrayed)
1004 NC_GetInsideRect( hwnd, &rect );
1006 /* A tool window has a smaller Close button */
1007 if (GetWindowLongA( hwnd, GWL_EXSTYLE ) & WS_EX_TOOLWINDOW)
1009 INT iBmpHeight = 11; /* Windows does not use SM_CXSMSIZE and SM_CYSMSIZE */
1010 INT iBmpWidth = 11; /* it uses 11x11 for the close button in tool window */
1011 INT iCaptionHeight = GetSystemMetrics(SM_CYSMCAPTION);
1013 rect.top = rect.top + (iCaptionHeight - 1 - iBmpHeight) / 2;
1014 rect.left = rect.right - (iCaptionHeight + 1 + iBmpWidth) / 2;
1015 rect.bottom = rect.top + iBmpHeight;
1016 rect.right = rect.left + iBmpWidth;
1020 rect.left = rect.right - GetSystemMetrics(SM_CXSIZE) - 1;
1021 rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) - 1;
1025 DrawFrameControl( hdc, &rect, DFC_CAPTION,
1026 (DFCS_CAPTIONCLOSE |
1027 (down ? DFCS_PUSHED : 0) |
1028 (bGrayed ? DFCS_INACTIVE : 0)) );
1031 /******************************************************************************
1032 * NC_DrawMaxButton95
1034 * Draws the maximize button for Win95 style windows.
1035 * If bGrayed is true, then draw a disabled Maximize button
1037 static void NC_DrawMaxButton95(HWND hwnd,HDC16 hdc,BOOL down, BOOL bGrayed)
1040 UINT flags = IsZoomed(hwnd) ? DFCS_CAPTIONRESTORE : DFCS_CAPTIONMAX;
1042 NC_GetInsideRect( hwnd, &rect );
1043 if (GetWindowLongA( hwnd, GWL_STYLE) & WS_SYSMENU)
1044 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1045 rect.left = rect.right - GetSystemMetrics(SM_CXSIZE);
1046 rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) - 1;
1049 if (down) flags |= DFCS_PUSHED;
1050 if (bGrayed) flags |= DFCS_INACTIVE;
1051 DrawFrameControl( hdc, &rect, DFC_CAPTION, flags );
1054 /******************************************************************************
1055 * NC_DrawMinButton95
1057 * Draws the minimize button for Win95 style windows.
1058 * If bGrayed is true, then draw a disabled Minimize button
1060 static void NC_DrawMinButton95(HWND hwnd,HDC16 hdc,BOOL down, BOOL bGrayed)
1063 UINT flags = DFCS_CAPTIONMIN;
1064 DWORD style = GetWindowLongA( hwnd, GWL_STYLE );
1066 NC_GetInsideRect( hwnd, &rect );
1067 if (style & WS_SYSMENU)
1068 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1069 if (style & (WS_MAXIMIZEBOX|WS_MINIMIZEBOX))
1070 rect.right -= GetSystemMetrics(SM_CXSIZE) - 2;
1071 rect.left = rect.right - GetSystemMetrics(SM_CXSIZE);
1072 rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) - 1;
1075 if (down) flags |= DFCS_PUSHED;
1076 if (bGrayed) flags |= DFCS_INACTIVE;
1077 DrawFrameControl( hdc, &rect, DFC_CAPTION, flags );
1080 /***********************************************************************
1083 * Draw a window frame inside the given rectangle, and update the rectangle.
1084 * The correct pen for the frame must be selected in the DC.
1086 static void NC_DrawFrame( HDC hdc, RECT *rect, BOOL dlgFrame,
1091 if (TWEAK_WineLook != WIN31_LOOK)
1092 ERR("Called in Win95 mode. Aiee! Please report this.\n" );
1096 width = GetSystemMetrics(SM_CXDLGFRAME) - 1;
1097 height = GetSystemMetrics(SM_CYDLGFRAME) - 1;
1098 SelectObject( hdc, GetSysColorBrush(active ? COLOR_ACTIVECAPTION :
1099 COLOR_INACTIVECAPTION) );
1103 width = GetSystemMetrics(SM_CXFRAME) - 2;
1104 height = GetSystemMetrics(SM_CYFRAME) - 2;
1105 SelectObject( hdc, GetSysColorBrush(active ? COLOR_ACTIVEBORDER :
1106 COLOR_INACTIVEBORDER) );
1110 PatBlt( hdc, rect->left, rect->top,
1111 rect->right - rect->left, height, PATCOPY );
1112 PatBlt( hdc, rect->left, rect->top,
1113 width, rect->bottom - rect->top, PATCOPY );
1114 PatBlt( hdc, rect->left, rect->bottom - 1,
1115 rect->right - rect->left, -height, PATCOPY );
1116 PatBlt( hdc, rect->right - 1, rect->top,
1117 -width, rect->bottom - rect->top, PATCOPY );
1121 InflateRect( rect, -width, -height );
1125 INT decYOff = GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXSIZE) - 1;
1126 INT decXOff = GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYSIZE) - 1;
1128 /* Draw inner rectangle */
1130 SelectObject( hdc, GetStockObject(NULL_BRUSH) );
1131 Rectangle( hdc, rect->left + width, rect->top + height,
1132 rect->right - width , rect->bottom - height );
1134 /* Draw the decorations */
1136 MoveToEx( hdc, rect->left, rect->top + decYOff, NULL );
1137 LineTo( hdc, rect->left + width, rect->top + decYOff );
1138 MoveToEx( hdc, rect->right - 1, rect->top + decYOff, NULL );
1139 LineTo( hdc, rect->right - width - 1, rect->top + decYOff );
1140 MoveToEx( hdc, rect->left, rect->bottom - decYOff, NULL );
1141 LineTo( hdc, rect->left + width, rect->bottom - decYOff );
1142 MoveToEx( hdc, rect->right - 1, rect->bottom - decYOff, NULL );
1143 LineTo( hdc, rect->right - width - 1, rect->bottom - decYOff );
1145 MoveToEx( hdc, rect->left + decXOff, rect->top, NULL );
1146 LineTo( hdc, rect->left + decXOff, rect->top + height);
1147 MoveToEx( hdc, rect->left + decXOff, rect->bottom - 1, NULL );
1148 LineTo( hdc, rect->left + decXOff, rect->bottom - height - 1 );
1149 MoveToEx( hdc, rect->right - decXOff, rect->top, NULL );
1150 LineTo( hdc, rect->right - decXOff, rect->top + height );
1151 MoveToEx( hdc, rect->right - decXOff, rect->bottom - 1, NULL );
1152 LineTo( hdc, rect->right - decXOff, rect->bottom - height - 1 );
1154 InflateRect( rect, -width - 1, -height - 1 );
1159 /******************************************************************************
1161 * void NC_DrawFrame95(
1167 * Draw a window frame inside the given rectangle, and update the rectangle.
1168 * The correct pen for the frame must be selected in the DC.
1171 * Many. First, just what IS a frame in Win95? Note that the 3D look
1172 * on the outer edge is handled by NC_DoNCPaint95. As is the inner
1173 * edge. The inner rectangle just inside the frame is handled by the
1176 * In short, for most people, this function should be a nop (unless
1177 * you LIKE thick borders in Win95/NT4.0 -- I've been working with
1178 * them lately, but just to get this code right). Even so, it doesn't
1179 * appear to be so. It's being worked on...
1182 * 06-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1183 * Original implementation (based on NC_DrawFrame)
1184 * 02-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1186 * 29-Jun-1999 Ove Kåven (ovek@arcticnet.no)
1187 * Fixed a fix or something.
1189 *****************************************************************************/
1191 static void NC_DrawFrame95(
1201 width = GetSystemMetrics(SM_CXDLGFRAME) - GetSystemMetrics(SM_CXEDGE);
1202 height = GetSystemMetrics(SM_CYDLGFRAME) - GetSystemMetrics(SM_CYEDGE);
1206 width = GetSystemMetrics(SM_CXFRAME) - GetSystemMetrics(SM_CXEDGE);
1207 height = GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYEDGE);
1210 SelectObject( hdc, GetSysColorBrush(active ? COLOR_ACTIVEBORDER :
1211 COLOR_INACTIVEBORDER) );
1214 PatBlt( hdc, rect->left, rect->top,
1215 rect->right - rect->left, height, PATCOPY );
1216 PatBlt( hdc, rect->left, rect->top,
1217 width, rect->bottom - rect->top, PATCOPY );
1218 PatBlt( hdc, rect->left, rect->bottom - 1,
1219 rect->right - rect->left, -height, PATCOPY );
1220 PatBlt( hdc, rect->right - 1, rect->top,
1221 -width, rect->bottom - rect->top, PATCOPY );
1223 InflateRect( rect, -width, -height );
1227 /***********************************************************************
1230 * Draw the window caption.
1231 * The correct pen for the window frame must be selected in the DC.
1233 static void NC_DrawCaption( HDC hdc, RECT *rect, HWND hwnd,
1234 DWORD style, BOOL active )
1241 if (!(hbitmapClose = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_CLOSE) ))) return;
1242 hbitmapMinimize = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_REDUCE) );
1243 hbitmapMinimizeD = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_REDUCED) );
1244 hbitmapMaximize = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_ZOOM) );
1245 hbitmapMaximizeD = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_ZOOMD) );
1246 hbitmapRestore = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_RESTORE) );
1247 hbitmapRestoreD = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_RESTORED) );
1250 if (GetWindowLongA( hwnd, GWL_EXSTYLE) & WS_EX_DLGMODALFRAME)
1252 HBRUSH hbrushOld = SelectObject(hdc, GetSysColorBrush(COLOR_WINDOW) );
1253 PatBlt( hdc, r.left, r.top, 1, r.bottom-r.top+1,PATCOPY );
1254 PatBlt( hdc, r.right-1, r.top, 1, r.bottom-r.top+1, PATCOPY );
1255 PatBlt( hdc, r.left, r.top-1, r.right-r.left, 1, PATCOPY );
1258 SelectObject( hdc, hbrushOld );
1260 MoveToEx( hdc, r.left, r.bottom, NULL );
1261 LineTo( hdc, r.right, r.bottom );
1263 if (style & WS_SYSMENU)
1265 NC_DrawSysButton( hwnd, hdc, FALSE );
1266 r.left += GetSystemMetrics(SM_CXSIZE) + 1;
1267 MoveToEx( hdc, r.left - 1, r.top, NULL );
1268 LineTo( hdc, r.left - 1, r.bottom );
1270 if (style & WS_MAXIMIZEBOX)
1272 NC_DrawMaxButton( hwnd, hdc, FALSE );
1273 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1275 if (style & WS_MINIMIZEBOX)
1277 NC_DrawMinButton( hwnd, hdc, FALSE );
1278 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1281 FillRect( hdc, &r, GetSysColorBrush(active ? COLOR_ACTIVECAPTION :
1282 COLOR_INACTIVECAPTION) );
1284 if (GetWindowTextA( hwnd, buffer, sizeof(buffer) ))
1286 if (active) SetTextColor( hdc, GetSysColor( COLOR_CAPTIONTEXT ) );
1287 else SetTextColor( hdc, GetSysColor( COLOR_INACTIVECAPTIONTEXT ) );
1288 SetBkMode( hdc, TRANSPARENT );
1289 DrawTextA( hdc, buffer, -1, &r,
1290 DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_NOPREFIX );
1295 /******************************************************************************
1304 * Draw the window caption for Win95 style windows.
1305 * The correct pen for the window frame must be selected in the DC.
1308 * Hey, a function that finally works! Well, almost.
1309 * It's being worked on.
1312 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1313 * Original implementation.
1314 * 02-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1317 *****************************************************************************/
1319 static void NC_DrawCaption95(
1332 hPrevPen = SelectObject( hdc, GetSysColorPen(COLOR_3DFACE) );
1333 MoveToEx( hdc, r.left, r.bottom - 1, NULL );
1334 LineTo( hdc, r.right, r.bottom - 1 );
1335 SelectObject( hdc, hPrevPen );
1338 FillRect( hdc, &r, GetSysColorBrush(active ? COLOR_ACTIVECAPTION :
1339 COLOR_INACTIVECAPTION) );
1341 if ((style & WS_SYSMENU) && !(exStyle & WS_EX_TOOLWINDOW)) {
1342 if (NC_DrawSysButton95 (hwnd, hdc, FALSE))
1343 r.left += GetSystemMetrics(SM_CYCAPTION) - 1;
1346 if (style & WS_SYSMENU)
1350 /* Go get the sysmenu */
1351 hSysMenu = GetSystemMenu(hwnd, FALSE);
1352 state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
1354 /* Draw a grayed close button if disabled and a normal one if SC_CLOSE is not there */
1355 NC_DrawCloseButton95 (hwnd, hdc, FALSE,
1356 ((((state & MF_DISABLED) || (state & MF_GRAYED))) && (state != 0xFFFFFFFF)));
1357 r.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
1359 if ((style & WS_MAXIMIZEBOX) || (style & WS_MINIMIZEBOX))
1361 /* In win95 the two buttons are always there */
1362 /* But if the menu item is not in the menu they're disabled*/
1364 NC_DrawMaxButton95( hwnd, hdc, FALSE, (!(style & WS_MAXIMIZEBOX)));
1365 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1367 NC_DrawMinButton95( hwnd, hdc, FALSE, (!(style & WS_MINIMIZEBOX)));
1368 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1372 if (GetWindowTextA( hwnd, buffer, sizeof(buffer) )) {
1373 NONCLIENTMETRICSA nclm;
1374 HFONT hFont, hOldFont;
1375 nclm.cbSize = sizeof(NONCLIENTMETRICSA);
1376 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
1377 if (exStyle & WS_EX_TOOLWINDOW)
1378 hFont = CreateFontIndirectA (&nclm.lfSmCaptionFont);
1380 hFont = CreateFontIndirectA (&nclm.lfCaptionFont);
1381 hOldFont = SelectObject (hdc, hFont);
1382 if (active) SetTextColor( hdc, GetSysColor( COLOR_CAPTIONTEXT ) );
1383 else SetTextColor( hdc, GetSysColor( COLOR_INACTIVECAPTIONTEXT ) );
1384 SetBkMode( hdc, TRANSPARENT );
1386 DrawTextA( hdc, buffer, -1, &r,
1387 DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT );
1388 DeleteObject (SelectObject (hdc, hOldFont));
1394 /***********************************************************************
1397 * Paint the non-client area. clip is currently unused.
1399 static void NC_DoNCPaint( WND* wndPtr, HRGN clip, BOOL suppress_menupaint )
1404 HWND hwnd = wndPtr->hwndSelf;
1406 if ( wndPtr->dwStyle & WS_MINIMIZE ||
1407 !WIN_IsWindowDrawable( wndPtr, 0 )) return; /* Nothing to do */
1409 active = wndPtr->flags & WIN_NCACTIVATED;
1411 TRACE("%04x %d\n", hwnd, active );
1413 if (!(hdc = GetDCEx( hwnd, (clip > 1) ? clip : 0, DCX_USESTYLE | DCX_WINDOW |
1414 ((clip > 1) ? (DCX_INTERSECTRGN | DCX_KEEPCLIPRGN): 0) ))) return;
1416 if (ExcludeVisRect16( hdc, wndPtr->rectClient.left-wndPtr->rectWindow.left,
1417 wndPtr->rectClient.top-wndPtr->rectWindow.top,
1418 wndPtr->rectClient.right-wndPtr->rectWindow.left,
1419 wndPtr->rectClient.bottom-wndPtr->rectWindow.top )
1422 ReleaseDC( hwnd, hdc );
1426 rect.top = rect.left = 0;
1427 rect.right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
1428 rect.bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
1430 SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
1432 if (HAS_ANYFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
1434 SelectObject( hdc, GetStockObject(NULL_BRUSH) );
1435 Rectangle( hdc, 0, 0, rect.right, rect.bottom );
1436 InflateRect( &rect, -1, -1 );
1439 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
1440 NC_DrawFrame(hdc, &rect, FALSE, active );
1441 else if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
1442 NC_DrawFrame( hdc, &rect, TRUE, active );
1444 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
1447 r.bottom = rect.top + GetSystemMetrics(SM_CYSIZE);
1448 rect.top += GetSystemMetrics(SM_CYSIZE) + GetSystemMetrics(SM_CYBORDER);
1449 NC_DrawCaption( hdc, &r, hwnd, wndPtr->dwStyle, active );
1452 if (HAS_MENU(wndPtr))
1455 r.bottom = rect.top + GetSystemMetrics(SM_CYMENU); /* default height */
1456 rect.top += MENU_DrawMenuBar( hdc, &r, hwnd, suppress_menupaint );
1459 /* Draw the scroll-bars */
1461 if (wndPtr->dwStyle & WS_VSCROLL)
1462 SCROLL_DrawScrollBar( hwnd, hdc, SB_VERT, TRUE, TRUE );
1463 if (wndPtr->dwStyle & WS_HSCROLL)
1464 SCROLL_DrawScrollBar( hwnd, hdc, SB_HORZ, TRUE, TRUE );
1466 /* Draw the "size-box" */
1468 if ((wndPtr->dwStyle & WS_VSCROLL) && (wndPtr->dwStyle & WS_HSCROLL))
1471 r.left = r.right - GetSystemMetrics(SM_CXVSCROLL) + 1;
1472 r.top = r.bottom - GetSystemMetrics(SM_CYHSCROLL) + 1;
1473 if(wndPtr->dwStyle & WS_BORDER) {
1477 FillRect( hdc, &r, GetSysColorBrush(COLOR_SCROLLBAR) );
1480 ReleaseDC( hwnd, hdc );
1484 /******************************************************************************
1486 * void NC_DoNCPaint95(
1489 * BOOL suppress_menupaint )
1491 * Paint the non-client area for Win95 windows. The clip region is
1492 * currently ignored.
1495 * grep -E -A10 -B5 \(95\)\|\(Bugs\)\|\(FIXME\) windows/nonclient.c \
1496 * misc/tweak.c controls/menu.c # :-)
1499 * 03-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1500 * Original implementation
1501 * 10-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1503 * 29-Jun-1999 Ove Kåven (ovek@arcticnet.no)
1504 * Streamlined window style checks.
1506 *****************************************************************************/
1508 static void NC_DoNCPaint95(
1511 BOOL suppress_menupaint )
1514 RECT rfuzz, rect, rectClip;
1516 HWND hwnd = wndPtr->hwndSelf;
1518 if ( wndPtr->dwStyle & WS_MINIMIZE ||
1519 !WIN_IsWindowDrawable( wndPtr, 0 )) return; /* Nothing to do */
1521 active = wndPtr->flags & WIN_NCACTIVATED;
1523 TRACE("%04x %d\n", hwnd, active );
1525 /* MSDN docs are pretty idiotic here, they say app CAN use clipRgn in
1526 the call to GetDCEx implying that it is allowed not to use it either.
1527 However, the suggested GetDCEx( , DCX_WINDOW | DCX_INTERSECTRGN)
1528 will cause clipRgn to be deleted after ReleaseDC().
1529 Now, how is the "system" supposed to tell what happened?
1532 if (!(hdc = GetDCEx( hwnd, (clip > 1) ? clip : 0, DCX_USESTYLE | DCX_WINDOW |
1533 ((clip > 1) ?(DCX_INTERSECTRGN | DCX_KEEPCLIPRGN) : 0) ))) return;
1536 if (ExcludeVisRect16( hdc, wndPtr->rectClient.left-wndPtr->rectWindow.left,
1537 wndPtr->rectClient.top-wndPtr->rectWindow.top,
1538 wndPtr->rectClient.right-wndPtr->rectWindow.left,
1539 wndPtr->rectClient.bottom-wndPtr->rectWindow.top )
1542 ReleaseDC( hwnd, hdc );
1546 rect.top = rect.left = 0;
1547 rect.right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
1548 rect.bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
1551 GetRgnBox( clip, &rectClip );
1558 SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
1560 if (HAS_BIGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle)) {
1561 DrawEdge (hdc, &rect, EDGE_RAISED, BF_RECT | BF_ADJUST);
1563 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
1564 NC_DrawFrame95(hdc, &rect, FALSE, active );
1565 else if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
1566 NC_DrawFrame95( hdc, &rect, TRUE, active );
1567 else if (HAS_THINFRAME( wndPtr->dwStyle )) {
1568 SelectObject( hdc, GetStockObject(NULL_BRUSH) );
1569 Rectangle( hdc, 0, 0, rect.right, rect.bottom );
1572 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
1575 if (wndPtr->dwExStyle & WS_EX_TOOLWINDOW) {
1576 r.bottom = rect.top + GetSystemMetrics(SM_CYSMCAPTION);
1577 rect.top += GetSystemMetrics(SM_CYSMCAPTION);
1580 r.bottom = rect.top + GetSystemMetrics(SM_CYCAPTION);
1581 rect.top += GetSystemMetrics(SM_CYCAPTION);
1583 if( !clip || IntersectRect( &rfuzz, &r, &rectClip ) )
1584 NC_DrawCaption95 (hdc, &r, hwnd, wndPtr->dwStyle,
1585 wndPtr->dwExStyle, active);
1588 if (HAS_MENU(wndPtr))
1591 r.bottom = rect.top + GetSystemMetrics(SM_CYMENU);
1593 TRACE("Calling DrawMenuBar with rect (%d, %d)-(%d, %d)\n",
1594 r.left, r.top, r.right, r.bottom);
1596 rect.top += MENU_DrawMenuBar( hdc, &r, hwnd, suppress_menupaint ) + 1;
1599 TRACE("After MenuBar, rect is (%d, %d)-(%d, %d).\n",
1600 rect.left, rect.top, rect.right, rect.bottom );
1602 if (wndPtr->dwExStyle & WS_EX_CLIENTEDGE)
1603 DrawEdge (hdc, &rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
1605 if (wndPtr->dwExStyle & WS_EX_STATICEDGE)
1606 DrawEdge (hdc, &rect, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
1608 /* Draw the scroll-bars */
1610 if (wndPtr->dwStyle & WS_VSCROLL)
1611 SCROLL_DrawScrollBar( hwnd, hdc, SB_VERT, TRUE, TRUE );
1612 if (wndPtr->dwStyle & WS_HSCROLL)
1613 SCROLL_DrawScrollBar( hwnd, hdc, SB_HORZ, TRUE, TRUE );
1615 /* Draw the "size-box" */
1616 if ((wndPtr->dwStyle & WS_VSCROLL) && (wndPtr->dwStyle & WS_HSCROLL))
1619 r.left = r.right - GetSystemMetrics(SM_CXVSCROLL) + 1;
1620 r.top = r.bottom - GetSystemMetrics(SM_CYHSCROLL) + 1;
1621 FillRect( hdc, &r, GetSysColorBrush(COLOR_SCROLLBAR) );
1624 ReleaseDC( hwnd, hdc );
1630 /***********************************************************************
1633 * Handle a WM_NCPAINT message. Called from DefWindowProc().
1635 LONG NC_HandleNCPaint( HWND hwnd , HRGN clip)
1637 WND* wndPtr = WIN_FindWndPtr( hwnd );
1639 if( wndPtr && wndPtr->dwStyle & WS_VISIBLE )
1641 if( wndPtr->dwStyle & WS_MINIMIZE )
1642 WINPOS_RedrawIconTitle( hwnd );
1643 else if (TWEAK_WineLook == WIN31_LOOK)
1644 NC_DoNCPaint( wndPtr, clip, FALSE );
1646 NC_DoNCPaint95( wndPtr, clip, FALSE );
1648 WIN_ReleaseWndPtr(wndPtr);
1653 /***********************************************************************
1654 * NC_HandleNCActivate
1656 * Handle a WM_NCACTIVATE message. Called from DefWindowProc().
1658 LONG NC_HandleNCActivate( WND *wndPtr, WPARAM16 wParam )
1660 /* Lotus Notes draws menu descriptions in the caption of its main
1661 * window. When it wants to restore original "system" view, it just
1662 * sends WM_NCACTIVATE message to itself. Any optimizations here in
1663 * attempt to minimize redrawings lead to a not restored caption.
1666 if (wParam) wndPtr->flags |= WIN_NCACTIVATED;
1667 else wndPtr->flags &= ~WIN_NCACTIVATED;
1669 if( wndPtr->dwStyle & WS_MINIMIZE )
1670 WINPOS_RedrawIconTitle( wndPtr->hwndSelf );
1671 else if (TWEAK_WineLook == WIN31_LOOK)
1672 NC_DoNCPaint( wndPtr, (HRGN)1, FALSE );
1674 NC_DoNCPaint95( wndPtr, (HRGN)1, FALSE );
1680 /***********************************************************************
1681 * NC_HandleSetCursor
1683 * Handle a WM_SETCURSOR message. Called from DefWindowProc().
1685 LONG NC_HandleSetCursor( HWND hwnd, WPARAM16 wParam, LPARAM lParam )
1687 if (hwnd != (HWND)wParam) return 0; /* Don't set the cursor for child windows */
1689 switch(LOWORD(lParam))
1693 WORD msg = HIWORD( lParam );
1694 if ((msg == WM_LBUTTONDOWN) || (msg == WM_MBUTTONDOWN) ||
1695 (msg == WM_RBUTTONDOWN))
1702 HICON16 hCursor = (HICON16) GetClassWord(hwnd, GCW_HCURSOR);
1704 SetCursor16(hCursor);
1712 return (LONG)SetCursor( LoadCursorA( 0, IDC_SIZEWEA ) );
1716 return (LONG)SetCursor( LoadCursorA( 0, IDC_SIZENSA ) );
1720 return (LONG)SetCursor( LoadCursorA( 0, IDC_SIZENWSEA ) );
1724 return (LONG)SetCursor( LoadCursorA( 0, IDC_SIZENESWA ) );
1727 /* Default cursor: arrow */
1728 return (LONG)SetCursor( LoadCursorA( 0, IDC_ARROWA ) );
1731 /***********************************************************************
1734 BOOL NC_GetSysPopupPos( WND* wndPtr, RECT* rect )
1736 if( wndPtr->hSysMenu )
1738 if( wndPtr->dwStyle & WS_MINIMIZE )
1739 GetWindowRect( wndPtr->hwndSelf, rect );
1742 NC_GetInsideRect( wndPtr->hwndSelf, rect );
1743 OffsetRect( rect, wndPtr->rectWindow.left, wndPtr->rectWindow.top);
1744 if (wndPtr->dwStyle & WS_CHILD)
1745 ClientToScreen( wndPtr->parent->hwndSelf, (POINT *)rect );
1746 if (TWEAK_WineLook == WIN31_LOOK) {
1747 rect->right = rect->left + GetSystemMetrics(SM_CXSIZE);
1748 rect->bottom = rect->top + GetSystemMetrics(SM_CYSIZE);
1751 rect->right = rect->left + GetSystemMetrics(SM_CYCAPTION) - 1;
1752 rect->bottom = rect->top + GetSystemMetrics(SM_CYCAPTION) - 1;
1760 /***********************************************************************
1761 * NC_TrackMinMaxBox95
1763 * Track a mouse button press on the minimize or maximize box.
1765 * The big difference between 3.1 and 95 is the disabled button state.
1766 * In win95 the system button can be disabled, so it can ignore the mouse
1770 static void NC_TrackMinMaxBox95( HWND hwnd, WORD wParam )
1773 HDC hdc = GetWindowDC( hwnd );
1774 BOOL pressed = TRUE;
1776 DWORD wndStyle = GetWindowLongA( hwnd, GWL_STYLE);
1777 HMENU hSysMenu = GetSystemMenu(hwnd, FALSE);
1779 void (*paintButton)(HWND, HDC16, BOOL, BOOL);
1781 if (wParam == HTMINBUTTON)
1783 /* If the style is not present, do nothing */
1784 if (!(wndStyle & WS_MINIMIZEBOX))
1787 /* Check if the sysmenu item for minimize is there */
1788 state = GetMenuState(hSysMenu, SC_MINIMIZE, MF_BYCOMMAND);
1790 paintButton = &NC_DrawMinButton95;
1794 /* If the style is not present, do nothing */
1795 if (!(wndStyle & WS_MAXIMIZEBOX))
1798 /* Check if the sysmenu item for maximize is there */
1799 state = GetMenuState(hSysMenu, SC_MAXIMIZE, MF_BYCOMMAND);
1801 paintButton = &NC_DrawMaxButton95;
1806 (*paintButton)( hwnd, hdc, TRUE, FALSE);
1810 BOOL oldstate = pressed;
1811 MSG_InternalGetMessage( &msg, 0, 0, WM_MOUSEFIRST, WM_MOUSELAST,
1812 0, PM_REMOVE, FALSE, NULL );
1814 if(msg.message == WM_LBUTTONUP)
1817 if(msg.message != WM_MOUSEMOVE)
1820 pressed = (NC_HandleNCHitTest( hwnd, msg.pt ) == wParam);
1821 if (pressed != oldstate)
1822 (*paintButton)( hwnd, hdc, pressed, FALSE);
1826 (*paintButton)(hwnd, hdc, FALSE, FALSE);
1829 ReleaseDC( hwnd, hdc );
1831 /* If the item minimize or maximize of the sysmenu are not there */
1832 /* or if the style is not present, do nothing */
1833 if ((!pressed) || (state == 0xFFFFFFFF))
1836 if (wParam == HTMINBUTTON)
1837 SendMessageA( hwnd, WM_SYSCOMMAND, SC_MINIMIZE, MAKELONG(msg.pt.x,msg.pt.y) );
1839 SendMessageA( hwnd, WM_SYSCOMMAND,
1840 IsZoomed(hwnd) ? SC_RESTORE:SC_MAXIMIZE, MAKELONG(msg.pt.x,msg.pt.y) );
1843 /***********************************************************************
1846 * Track a mouse button press on the minimize or maximize box.
1848 static void NC_TrackMinMaxBox( HWND hwnd, WORD wParam )
1851 HDC hdc = GetWindowDC( hwnd );
1852 BOOL pressed = TRUE;
1853 void (*paintButton)(HWND, HDC16, BOOL);
1857 if (wParam == HTMINBUTTON)
1858 paintButton = &NC_DrawMinButton;
1860 paintButton = &NC_DrawMaxButton;
1862 (*paintButton)( hwnd, hdc, TRUE);
1866 BOOL oldstate = pressed;
1867 MSG_InternalGetMessage( &msg, 0, 0, WM_MOUSEFIRST, WM_MOUSELAST,
1868 0, PM_REMOVE, FALSE, NULL );
1870 if(msg.message == WM_LBUTTONUP)
1873 if(msg.message != WM_MOUSEMOVE)
1876 pressed = (NC_HandleNCHitTest( hwnd, msg.pt ) == wParam);
1877 if (pressed != oldstate)
1878 (*paintButton)( hwnd, hdc, pressed);
1882 (*paintButton)( hwnd, hdc, FALSE);
1885 ReleaseDC( hwnd, hdc );
1887 if (!pressed) return;
1889 if (wParam == HTMINBUTTON)
1890 SendMessageA( hwnd, WM_SYSCOMMAND, SC_MINIMIZE, MAKELONG(msg.pt.x,msg.pt.y) );
1892 SendMessageA( hwnd, WM_SYSCOMMAND,
1893 IsZoomed(hwnd) ? SC_RESTORE:SC_MAXIMIZE, MAKELONG(msg.pt.x,msg.pt.y) );
1897 /***********************************************************************
1898 * NC_TrackCloseButton95
1900 * Track a mouse button press on the Win95 close button.
1903 NC_TrackCloseButton95 (HWND hwnd, WORD wParam)
1907 BOOL pressed = TRUE;
1908 HMENU hSysMenu = GetSystemMenu(hwnd, FALSE);
1914 state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
1916 /* If the item close of the sysmenu is disabled or not there do nothing */
1917 if((state & MF_DISABLED) || (state & MF_GRAYED) || (state == 0xFFFFFFFF))
1920 hdc = GetWindowDC( hwnd );
1924 NC_DrawCloseButton95 (hwnd, hdc, TRUE, FALSE);
1928 BOOL oldstate = pressed;
1929 MSG_InternalGetMessage( &msg, 0, 0, WM_MOUSEFIRST, WM_MOUSELAST,
1930 0, PM_REMOVE, FALSE, NULL );
1932 if(msg.message == WM_LBUTTONUP)
1935 if(msg.message != WM_MOUSEMOVE)
1938 pressed = (NC_HandleNCHitTest( hwnd, msg.pt ) == wParam);
1939 if (pressed != oldstate)
1940 NC_DrawCloseButton95 (hwnd, hdc, pressed, FALSE);
1944 NC_DrawCloseButton95 (hwnd, hdc, FALSE, FALSE);
1947 ReleaseDC( hwnd, hdc );
1948 if (!pressed) return;
1950 SendMessageA( hwnd, WM_SYSCOMMAND, SC_CLOSE, MAKELONG(msg.pt.x,msg.pt.y) );
1954 /***********************************************************************
1957 * Track a mouse button press on the horizontal or vertical scroll-bar.
1959 static void NC_TrackScrollBar( HWND hwnd, WPARAM wParam, POINT pt )
1963 WND *wndPtr = WIN_FindWndPtr( hwnd );
1965 if ((wParam & 0xfff0) == SC_HSCROLL)
1967 if ((wParam & 0x0f) != HTHSCROLL) goto END;
1968 scrollbar = SB_HORZ;
1970 else /* SC_VSCROLL */
1972 if ((wParam & 0x0f) != HTVSCROLL) goto END;
1973 scrollbar = SB_VERT;
1976 if (!(msg = SEGPTR_NEW(MSG16))) goto END;
1977 pt.x -= wndPtr->rectWindow.left;
1978 pt.y -= wndPtr->rectWindow.top;
1980 SCROLL_HandleScrollEvent( hwnd, scrollbar, WM_LBUTTONDOWN, pt );
1984 GetMessage16( SEGPTR_GET(msg), 0, 0, 0 );
1985 switch(msg->message)
1990 pt.x = LOWORD(msg->lParam) + wndPtr->rectClient.left -
1991 wndPtr->rectWindow.left;
1992 pt.y = HIWORD(msg->lParam) + wndPtr->rectClient.top -
1993 wndPtr->rectWindow.top;
1994 SCROLL_HandleScrollEvent( hwnd, scrollbar, msg->message, pt );
1997 TranslateMessage16( msg );
1998 DispatchMessage16( msg );
2001 if (!IsWindow( hwnd ))
2006 } while (msg->message != WM_LBUTTONUP);
2009 WIN_ReleaseWndPtr(wndPtr);
2012 /***********************************************************************
2013 * NC_HandleNCLButtonDown
2015 * Handle a WM_NCLBUTTONDOWN message. Called from DefWindowProc().
2017 LONG NC_HandleNCLButtonDown( WND* pWnd, WPARAM16 wParam, LPARAM lParam )
2019 HWND hwnd = pWnd->hwndSelf;
2021 switch(wParam) /* Hit test */
2024 hwnd = WIN_GetTopParent(hwnd);
2026 if( WINPOS_SetActiveWindow(hwnd, TRUE, TRUE) || (GetActiveWindow() == hwnd) )
2027 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, lParam );
2031 if( pWnd->dwStyle & WS_SYSMENU )
2033 if( !(pWnd->dwStyle & WS_MINIMIZE) )
2035 HDC hDC = GetWindowDC(hwnd);
2036 if (TWEAK_WineLook == WIN31_LOOK)
2037 NC_DrawSysButton( hwnd, hDC, TRUE );
2039 NC_DrawSysButton95( hwnd, hDC, TRUE );
2040 ReleaseDC( hwnd, hDC );
2042 SendMessage16( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU + HTSYSMENU, lParam );
2047 SendMessage16( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU, lParam );
2051 SendMessage16( hwnd, WM_SYSCOMMAND, SC_HSCROLL + HTHSCROLL, lParam );
2055 SendMessage16( hwnd, WM_SYSCOMMAND, SC_VSCROLL + HTVSCROLL, lParam );
2060 if (TWEAK_WineLook == WIN31_LOOK)
2061 NC_TrackMinMaxBox( hwnd, wParam );
2063 NC_TrackMinMaxBox95( hwnd, wParam );
2067 if (TWEAK_WineLook >= WIN95_LOOK)
2068 NC_TrackCloseButton95 (hwnd, wParam);
2079 /* make sure hittest fits into 0xf and doesn't overlap with HTSYSMENU */
2080 SendMessage16( hwnd, WM_SYSCOMMAND, SC_SIZE + wParam - 2, lParam);
2090 /***********************************************************************
2091 * NC_HandleNCLButtonDblClk
2093 * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc().
2095 LONG NC_HandleNCLButtonDblClk( WND *pWnd, WPARAM16 wParam, LPARAM lParam )
2098 * if this is an icon, send a restore since we are handling
2101 if (pWnd->dwStyle & WS_MINIMIZE)
2103 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND, SC_RESTORE, lParam );
2107 switch(wParam) /* Hit test */
2110 /* stop processing if WS_MAXIMIZEBOX is missing */
2111 if (pWnd->dwStyle & WS_MAXIMIZEBOX)
2112 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND,
2113 (pWnd->dwStyle & WS_MAXIMIZE) ? SC_RESTORE : SC_MAXIMIZE,
2118 if (!(GetClassWord(pWnd->hwndSelf, GCW_STYLE) & CS_NOCLOSE))
2119 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND, SC_CLOSE, lParam );
2123 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND, SC_HSCROLL + HTHSCROLL,
2128 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND, SC_VSCROLL + HTVSCROLL,
2136 /***********************************************************************
2137 * NC_HandleSysCommand
2139 * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
2141 LONG NC_HandleSysCommand( HWND hwnd, WPARAM wParam, POINT pt )
2143 WND *wndPtr = WIN_FindWndPtr( hwnd );
2144 UINT16 uCommand = wParam & 0xFFF0;
2146 TRACE("Handling WM_SYSCOMMAND %x %ld,%ld\n", wParam, pt.x, pt.y );
2148 if (wndPtr->parent && (uCommand != SC_KEYMENU))
2149 ScreenToClient( wndPtr->parent->hwndSelf, &pt );
2155 if (USER_Driver.pSysCommandSizeMove)
2156 USER_Driver.pSysCommandSizeMove( hwnd, wParam );
2160 if (hwnd == GetForegroundWindow())
2161 ShowOwnedPopups(hwnd,FALSE);
2162 ShowWindow( hwnd, SW_MINIMIZE );
2166 if (IsIconic(hwnd) && hwnd == GetForegroundWindow())
2167 ShowOwnedPopups(hwnd,TRUE);
2168 ShowWindow( hwnd, SW_MAXIMIZE );
2172 if (IsIconic(hwnd) && hwnd == GetForegroundWindow())
2173 ShowOwnedPopups(hwnd,TRUE);
2174 ShowWindow( hwnd, SW_RESTORE );
2178 WIN_ReleaseWndPtr(wndPtr);
2179 return SendMessageA( hwnd, WM_CLOSE, 0, 0 );
2183 NC_TrackScrollBar( hwnd, wParam, pt );
2187 MENU_TrackMouseMenuBar( wndPtr, wParam & 0x000F, pt );
2191 MENU_TrackKbdMenuBar( wndPtr , wParam , pt.x );
2195 WinExec( "taskman.exe", SW_SHOWNORMAL );
2199 if (wParam == SC_ABOUTWINE)
2201 HMODULE hmodule = LoadLibraryA( "shell32.dll" );
2204 FARPROC aboutproc = GetProcAddress( hmodule, "ShellAboutA" );
2205 if (aboutproc) aboutproc( hwnd, "Wine", WINE_RELEASE_INFO, 0 );
2206 FreeLibrary( hmodule );
2210 if (wParam == SC_PUTMARK)
2211 TRACE_(shell)("Mark requested by user\n");
2218 FIXME("unimplemented!\n");
2221 WIN_ReleaseWndPtr(wndPtr);
2225 /*************************************************************
2228 * Stub for the grayed button of the caption
2230 *************************************************************/
2232 BOOL NC_DrawGrayButton(HDC hdc, int x, int y)
2235 HDC hdcMask = CreateCompatibleDC (0);
2238 hMaskBmp = CreateBitmap (12, 10, 1, 1, lpGrayMask);
2243 SelectObject (hdcMask, hMaskBmp);
2245 /* Draw the grayed bitmap using the mask */
2246 hOldBrush = SelectObject (hdc, RGB(128, 128, 128));
2247 BitBlt (hdc, x, y, 12, 10,
2248 hdcMask, 0, 0, 0xB8074A);
2251 SelectObject (hdc, hOldBrush);
2252 DeleteObject(hMaskBmp);