2 * Non-client area window functions
4 * Copyright 1994 Alexandre Julliard
10 #include "wine/winuser16.h"
18 #include "cursoricon.h"
21 #include "nonclient.h"
23 #include "debugtools.h"
28 DEFAULT_DEBUG_CHANNEL(nonclient);
29 DECLARE_DEBUG_CHANNEL(shell);
31 BOOL NC_DrawGrayButton(HDC hdc, int x, int y);
33 static HBITMAP hbitmapClose;
34 static HBITMAP hbitmapMinimize;
35 static HBITMAP hbitmapMinimizeD;
36 static HBITMAP hbitmapMaximize;
37 static HBITMAP hbitmapMaximizeD;
38 static HBITMAP hbitmapRestore;
39 static HBITMAP hbitmapRestoreD;
41 static const BYTE lpGrayMask[] = { 0xAA, 0xA0,
52 #define SC_ABOUTWINE (SC_SCREENSAVE+1)
53 #define SC_PUTMARK (SC_SCREENSAVE+2)
55 /* Some useful macros */
56 #define HAS_DLGFRAME(style,exStyle) \
57 (((exStyle) & WS_EX_DLGMODALFRAME) || \
58 (((style) & WS_DLGFRAME) && !((style) & WS_THICKFRAME)))
60 #define HAS_THICKFRAME(style,exStyle) \
61 (((style) & WS_THICKFRAME) && \
62 !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
64 #define HAS_THINFRAME(style) \
65 (((style) & WS_BORDER) || !((style) & (WS_CHILD | WS_POPUP)))
67 #define HAS_BIGFRAME(style,exStyle) \
68 (((style) & (WS_THICKFRAME | WS_DLGFRAME)) || \
69 ((exStyle) & WS_EX_DLGMODALFRAME))
71 #define HAS_ANYFRAME(style,exStyle) \
72 (((style) & (WS_THICKFRAME | WS_DLGFRAME | WS_BORDER)) || \
73 ((exStyle) & WS_EX_DLGMODALFRAME) || \
74 !((style) & (WS_CHILD | WS_POPUP)))
76 #define HAS_MENU(w) (!((w)->dwStyle & WS_CHILD) && ((w)->wIDmenu != 0))
78 /***********************************************************************
79 * WIN_WindowNeedsWMBorder
81 * This method defines the rules for a window to have a WM border,
82 * caption... It is used for consistency purposes.
84 BOOL WIN_WindowNeedsWMBorder( DWORD style, DWORD exStyle )
86 if (!(style & WS_CHILD) &&
88 !(exStyle & WS_EX_TOOLWINDOW) &&
89 ( ((style & WS_CAPTION) == WS_CAPTION) ||
90 (style & WS_THICKFRAME)))
92 if (exStyle & WS_EX_TRAYWINDOW)
97 /***********************************************************************
100 * Compute the size of the window rectangle from the size of the
103 static void NC_AdjustRect( LPRECT rect, DWORD style, BOOL menu, DWORD exStyle )
105 if (TWEAK_WineLook > WIN31_LOOK)
106 ERR("Called in Win95 mode. Aiee! Please report this.\n" );
108 if(style & WS_ICONIC) return;
109 /* Decide if the window will be managed (see CreateWindowEx) */
110 if (!WIN_WindowNeedsWMBorder(style, exStyle))
112 if (HAS_THICKFRAME( style, exStyle ))
113 InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
115 if (HAS_DLGFRAME( style, exStyle ))
116 InflateRect( rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
118 if (HAS_THINFRAME( style ))
119 InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
121 if ((style & WS_CAPTION) == WS_CAPTION)
122 rect->top -= GetSystemMetrics(SM_CYCAPTION) - GetSystemMetrics(SM_CYBORDER);
124 if (menu) rect->top -= GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CYBORDER);
126 if (style & WS_VSCROLL) {
127 rect->right += GetSystemMetrics(SM_CXVSCROLL) - 1;
128 if(!HAS_ANYFRAME( style, exStyle ))
132 if (style & WS_HSCROLL) {
133 rect->bottom += GetSystemMetrics(SM_CYHSCROLL) - 1;
134 if(!HAS_ANYFRAME( style, exStyle ))
140 /******************************************************************************
141 * NC_AdjustRectOuter95
143 * Computes the size of the "outside" parts of the window based on the
144 * parameters of the client area.
153 * "Outer" parts of a window means the whole window frame, caption and
154 * menu bar. It does not include "inner" parts of the frame like client
155 * edge, static edge or scroll bars.
158 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
159 * Original (NC_AdjustRect95) cut & paste from NC_AdjustRect
161 * 20-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
162 * Split NC_AdjustRect95 into NC_AdjustRectOuter95 and
163 * NC_AdjustRectInner95 and added handling of Win95 styles.
165 * 28-Jul-1999 Ove Kåven (ovek@arcticnet.no)
166 * Streamlined window style checks.
168 *****************************************************************************/
171 NC_AdjustRectOuter95 (LPRECT rect, DWORD style, BOOL menu, DWORD exStyle)
173 if(style & WS_ICONIC) return;
175 /* Decide if the window will be managed (see CreateWindowEx) */
176 if (!WIN_WindowNeedsWMBorder(style, exStyle))
178 if (HAS_THICKFRAME( style, exStyle ))
179 InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
181 if (HAS_DLGFRAME( style, exStyle ))
182 InflateRect(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
184 if (HAS_THINFRAME( style ))
185 InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
187 if ((style & WS_CAPTION) == WS_CAPTION)
189 if (exStyle & WS_EX_TOOLWINDOW)
190 rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
192 rect->top -= GetSystemMetrics(SM_CYCAPTION);
197 rect->top -= GetSystemMetrics(SM_CYMENU);
201 /******************************************************************************
202 * NC_AdjustRectInner95
204 * Computes the size of the "inside" part of the window based on the
205 * parameters of the client area.
213 * "Inner" part of a window means the window frame inside of the flat
214 * window frame. It includes the client edge, the static edge and the
218 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
219 * Original (NC_AdjustRect95) cut & paste from NC_AdjustRect
221 * 20-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
222 * Split NC_AdjustRect95 into NC_AdjustRectOuter95 and
223 * NC_AdjustRectInner95 and added handling of Win95 styles.
225 *****************************************************************************/
228 NC_AdjustRectInner95 (LPRECT rect, DWORD style, DWORD exStyle)
230 if(style & WS_ICONIC) return;
232 if (exStyle & WS_EX_CLIENTEDGE)
233 InflateRect(rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
235 if (exStyle & WS_EX_STATICEDGE)
236 InflateRect(rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
238 if (style & WS_VSCROLL) rect->right += GetSystemMetrics(SM_CXVSCROLL);
239 if (style & WS_HSCROLL) rect->bottom += GetSystemMetrics(SM_CYHSCROLL);
243 /***********************************************************************
244 * DrawCaption (USER.660) Draws a caption bar
258 DrawCaption16 (HWND16 hwnd, HDC16 hdc, const RECT16 *rect, UINT16 uFlags)
263 CONV_RECT16TO32 (rect, &rect32);
265 return (BOOL16)DrawCaptionTempA (hwnd, hdc, rect ? &rect32 : NULL,
266 0, 0, NULL, uFlags & 0x1F);
270 /***********************************************************************
271 * DrawCaption (USER32.@) Draws a caption bar
285 DrawCaption (HWND hwnd, HDC hdc, const RECT *lpRect, UINT uFlags)
287 return DrawCaptionTempA (hwnd, hdc, lpRect, 0, 0, NULL, uFlags & 0x1F);
291 /***********************************************************************
292 * DrawCaptionTemp (USER.657)
302 DrawCaptionTemp16 (HWND16 hwnd, HDC16 hdc, const RECT16 *rect, HFONT16 hFont,
303 HICON16 hIcon, LPCSTR str, UINT16 uFlags)
308 CONV_RECT16TO32(rect,&rect32);
310 return (BOOL16)DrawCaptionTempA (hwnd, hdc, rect?&rect32:NULL, hFont,
311 hIcon, str, uFlags & 0x1F);
315 /***********************************************************************
316 * DrawCaptionTempA (USER32.@)
326 DrawCaptionTempA (HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont,
327 HICON hIcon, LPCSTR str, UINT uFlags)
331 TRACE("(%08x,%08x,%p,%08x,%08x,\"%s\",%08x)\n",
332 hwnd, hdc, rect, hFont, hIcon, str, uFlags);
334 /* drawing background */
335 if (uFlags & DC_INBUTTON) {
336 FillRect (hdc, &rc, GetSysColorBrush (COLOR_3DFACE));
338 if (uFlags & DC_ACTIVE) {
339 HBRUSH hbr = SelectObject (hdc, CACHE_GetPattern55AABrush ());
340 PatBlt (hdc, rc.left, rc.top,
341 rc.right-rc.left, rc.bottom-rc.top, 0xFA0089);
342 SelectObject (hdc, hbr);
346 FillRect (hdc, &rc, GetSysColorBrush ((uFlags & DC_ACTIVE) ?
347 COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION));
352 if ((uFlags & DC_ICON) && !(uFlags & DC_SMALLCAP)) {
356 pt.y = (rc.bottom + rc.top - GetSystemMetrics(SM_CYSMICON)) / 2;
359 DrawIconEx (hdc, pt.x, pt.y, hIcon, GetSystemMetrics(SM_CXSMICON),
360 GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL);
363 WND* wndPtr = WIN_FindWndPtr(hwnd);
364 HICON hAppIcon = (HICON) NC_IconForWindow(wndPtr);
365 DrawIconEx (hdc, pt.x, pt.y, hAppIcon, GetSystemMetrics(SM_CXSMICON),
366 GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL);
367 WIN_ReleaseWndPtr(wndPtr);
370 rc.left += (rc.bottom - rc.top);
374 if (uFlags & DC_TEXT) {
377 if (uFlags & DC_INBUTTON)
378 SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
379 else if (uFlags & DC_ACTIVE)
380 SetTextColor (hdc, GetSysColor (COLOR_CAPTIONTEXT));
382 SetTextColor (hdc, GetSysColor (COLOR_INACTIVECAPTIONTEXT));
384 SetBkMode (hdc, TRANSPARENT);
387 hOldFont = SelectObject (hdc, hFont);
389 NONCLIENTMETRICSA nclm;
391 nclm.cbSize = sizeof(NONCLIENTMETRICSA);
392 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
393 hNewFont = CreateFontIndirectA ((uFlags & DC_SMALLCAP) ?
394 &nclm.lfSmCaptionFont : &nclm.lfCaptionFont);
395 hOldFont = SelectObject (hdc, hNewFont);
399 DrawTextA (hdc, str, -1, &rc,
400 DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT);
404 nLen = GetWindowTextA (hwnd, szText, 128);
405 DrawTextA (hdc, szText, nLen, &rc,
406 DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT);
410 SelectObject (hdc, hOldFont);
412 DeleteObject (SelectObject (hdc, hOldFont));
415 /* drawing focus ??? */
417 FIXME("undocumented flag (0x2000)!\n");
423 /***********************************************************************
424 * DrawCaptionTempW (USER32.@)
434 DrawCaptionTempW (HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont,
435 HICON hIcon, LPCWSTR str, UINT uFlags)
437 LPSTR p = HEAP_strdupWtoA (GetProcessHeap (), 0, str);
438 BOOL res = DrawCaptionTempA (hwnd, hdc, rect, hFont, hIcon, p, uFlags);
439 HeapFree (GetProcessHeap (), 0, p);
444 /***********************************************************************
445 * AdjustWindowRect (USER.102)
447 BOOL16 WINAPI AdjustWindowRect16( LPRECT16 rect, DWORD style, BOOL16 menu )
449 return AdjustWindowRectEx16( rect, style, menu, 0 );
453 /***********************************************************************
454 * AdjustWindowRect (USER32.@)
456 BOOL WINAPI AdjustWindowRect( LPRECT rect, DWORD style, BOOL menu )
458 return AdjustWindowRectEx( rect, style, menu, 0 );
462 /***********************************************************************
463 * AdjustWindowRectEx (USER.454)
465 BOOL16 WINAPI AdjustWindowRectEx16( LPRECT16 rect, DWORD style,
466 BOOL16 menu, DWORD exStyle )
471 CONV_RECT16TO32( rect, &rect32 );
472 ret = AdjustWindowRectEx( &rect32, style, menu, exStyle );
473 CONV_RECT32TO16( &rect32, rect );
478 /***********************************************************************
479 * AdjustWindowRectEx (USER32.@)
481 BOOL WINAPI AdjustWindowRectEx( LPRECT rect, DWORD style, BOOL menu, DWORD exStyle )
483 /* Correct the window style */
485 if (!(style & (WS_POPUP | WS_CHILD))) style |= WS_CAPTION; /* Overlapped window */
486 style &= (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME | WS_CHILD);
487 exStyle &= (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE |
488 WS_EX_STATICEDGE | WS_EX_TOOLWINDOW);
489 if (exStyle & WS_EX_DLGMODALFRAME) style &= ~WS_THICKFRAME;
491 TRACE("(%d,%d)-(%d,%d) %08lx %d %08lx\n",
492 rect->left, rect->top, rect->right, rect->bottom,
493 style, menu, exStyle );
495 if (TWEAK_WineLook == WIN31_LOOK)
496 NC_AdjustRect( rect, style, menu, exStyle );
499 NC_AdjustRectOuter95( rect, style, menu, exStyle );
500 NC_AdjustRectInner95( rect, style, exStyle );
506 /***********************************************************************
507 * NC_HandleNCCalcSize
509 * Handle a WM_NCCALCSIZE message. Called from DefWindowProc().
511 LONG NC_HandleNCCalcSize( WND *pWnd, RECT *winRect )
513 RECT tmpRect = { 0, 0, 0, 0 };
515 UINT style = (UINT) GetClassLongA(pWnd->hwndSelf, GCL_STYLE);
517 if (style & CS_VREDRAW) result |= WVR_VREDRAW;
518 if (style & CS_HREDRAW) result |= WVR_HREDRAW;
520 if( !( pWnd->dwStyle & WS_MINIMIZE ) ) {
521 if (TWEAK_WineLook == WIN31_LOOK)
522 NC_AdjustRect( &tmpRect, pWnd->dwStyle, FALSE, pWnd->dwExStyle );
524 NC_AdjustRectOuter95( &tmpRect, pWnd->dwStyle, FALSE, pWnd->dwExStyle );
526 winRect->left -= tmpRect.left;
527 winRect->top -= tmpRect.top;
528 winRect->right -= tmpRect.right;
529 winRect->bottom -= tmpRect.bottom;
531 if (HAS_MENU(pWnd)) {
532 TRACE("Calling GetMenuBarHeight with HWND 0x%x, width %d, "
533 "at (%d, %d).\n", pWnd->hwndSelf,
534 winRect->right - winRect->left,
535 -tmpRect.left, -tmpRect.top );
538 MENU_GetMenuBarHeight( pWnd->hwndSelf,
539 winRect->right - winRect->left,
540 -tmpRect.left, -tmpRect.top ) + 1;
543 if (TWEAK_WineLook > WIN31_LOOK) {
544 SetRect(&tmpRect, 0, 0, 0, 0);
545 NC_AdjustRectInner95 (&tmpRect, pWnd->dwStyle, pWnd->dwExStyle);
546 winRect->left -= tmpRect.left;
547 winRect->top -= tmpRect.top;
548 winRect->right -= tmpRect.right;
549 winRect->bottom -= tmpRect.bottom;
552 if (winRect->top > winRect->bottom)
553 winRect->bottom = winRect->top;
555 if (winRect->left > winRect->right)
556 winRect->right = winRect->left;
562 /***********************************************************************
565 * Get the 'inside' rectangle of a window, i.e. the whole window rectangle
566 * but without the borders (if any).
567 * The rectangle is in window coordinates (for drawing with GetWindowDC()).
569 void NC_GetInsideRect( HWND hwnd, RECT *rect )
571 WND * wndPtr = WIN_FindWndPtr( hwnd );
573 rect->top = rect->left = 0;
574 rect->right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
575 rect->bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
577 if ((wndPtr->dwStyle & WS_ICONIC) || (wndPtr->dwExStyle & WS_EX_MANAGED)) goto END;
579 /* Remove frame from rectangle */
580 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
582 InflateRect( rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) );
584 else if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
586 InflateRect( rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
587 /* FIXME: this isn't in NC_AdjustRect? why not? */
588 if ((TWEAK_WineLook == WIN31_LOOK) && (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME))
589 InflateRect( rect, -1, 0 );
591 else if (HAS_THINFRAME( wndPtr->dwStyle ))
593 InflateRect( rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER) );
596 /* We have additional border information if the window
597 * is a child (but not an MDI child) */
598 if (TWEAK_WineLook != WIN31_LOOK)
600 if ( (wndPtr->dwStyle & WS_CHILD) &&
601 ( (wndPtr->dwExStyle & WS_EX_MDICHILD) == 0 ) )
603 if (wndPtr->dwExStyle & WS_EX_CLIENTEDGE)
604 InflateRect (rect, -GetSystemMetrics(SM_CXEDGE), -GetSystemMetrics(SM_CYEDGE));
605 if (wndPtr->dwExStyle & WS_EX_STATICEDGE)
606 InflateRect (rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
611 WIN_ReleaseWndPtr(wndPtr);
616 /***********************************************************************
619 * Handle a WM_NCHITTEST message. Called from NC_HandleNCHitTest().
622 static LONG NC_DoNCHitTest (WND *wndPtr, POINT pt )
626 TRACE("hwnd=%04x pt=%ld,%ld\n", wndPtr->hwndSelf, pt.x, pt.y );
628 GetWindowRect(wndPtr->hwndSelf, &rect );
629 if (!PtInRect( &rect, pt )) return HTNOWHERE;
631 if (wndPtr->dwStyle & WS_MINIMIZE) return HTCAPTION;
633 if (!(wndPtr->dwExStyle & WS_EX_MANAGED))
636 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
638 InflateRect( &rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) );
639 if (!PtInRect( &rect, pt ))
641 /* Check top sizing border */
644 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTTOPLEFT;
645 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTTOPRIGHT;
648 /* Check bottom sizing border */
649 if (pt.y >= rect.bottom)
651 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMLEFT;
652 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMRIGHT;
655 /* Check left sizing border */
656 if (pt.x < rect.left)
658 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPLEFT;
659 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMLEFT;
662 /* Check right sizing border */
663 if (pt.x >= rect.right)
665 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPRIGHT;
666 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMRIGHT;
671 else /* No thick frame */
673 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
674 InflateRect(&rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
675 else if (HAS_THINFRAME( wndPtr->dwStyle ))
676 InflateRect(&rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
677 if (!PtInRect( &rect, pt )) return HTBORDER;
682 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
684 rect.top += GetSystemMetrics(SM_CYCAPTION) - GetSystemMetrics(SM_CYBORDER);
685 if (!PtInRect( &rect, pt ))
687 /* Check system menu */
688 if ((wndPtr->dwStyle & WS_SYSMENU) && !(wndPtr->dwExStyle & WS_EX_TOOLWINDOW))
689 rect.left += GetSystemMetrics(SM_CXSIZE);
690 if (pt.x <= rect.left) return HTSYSMENU;
692 /* Check maximize box */
693 if (wndPtr->dwStyle & WS_MAXIMIZEBOX)
694 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
696 if (pt.x >= rect.right) return HTMAXBUTTON;
697 /* Check minimize box */
698 if (wndPtr->dwStyle & WS_MINIMIZEBOX)
699 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
700 if (pt.x >= rect.right) return HTMINBUTTON;
706 /* Check client area */
708 ScreenToClient( wndPtr->hwndSelf, &pt );
709 GetClientRect( wndPtr->hwndSelf, &rect );
710 if (PtInRect( &rect, pt )) return HTCLIENT;
712 /* Check vertical scroll bar */
714 if (wndPtr->dwStyle & WS_VSCROLL)
716 rect.right += GetSystemMetrics(SM_CXVSCROLL);
717 if (PtInRect( &rect, pt )) return HTVSCROLL;
720 /* Check horizontal scroll bar */
722 if (wndPtr->dwStyle & WS_HSCROLL)
724 rect.bottom += GetSystemMetrics(SM_CYHSCROLL);
725 if (PtInRect( &rect, pt ))
728 if ((wndPtr->dwStyle & WS_VSCROLL) &&
729 (pt.x >= rect.right - GetSystemMetrics(SM_CXVSCROLL)))
737 if (HAS_MENU(wndPtr))
739 if ((pt.y < 0) && (pt.x >= 0) && (pt.x < rect.right))
743 /* Has to return HTNOWHERE if nothing was found
744 Could happen when a window has a customized non client area */
749 /***********************************************************************
752 * Handle a WM_NCHITTEST message. Called from NC_HandleNCHitTest().
754 * FIXME: Just a modified copy of the Win 3.1 version.
757 static LONG NC_DoNCHitTest95 (WND *wndPtr, POINT pt )
761 TRACE("hwnd=%04x pt=%ld,%ld\n", wndPtr->hwndSelf, pt.x, pt.y );
763 GetWindowRect(wndPtr->hwndSelf, &rect );
764 if (!PtInRect( &rect, pt )) return HTNOWHERE;
766 if (wndPtr->dwStyle & WS_MINIMIZE) return HTCAPTION;
768 if (!(wndPtr->dwExStyle & WS_EX_MANAGED))
771 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
773 InflateRect( &rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) );
774 if (!PtInRect( &rect, pt ))
776 /* Check top sizing border */
779 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTTOPLEFT;
780 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTTOPRIGHT;
783 /* Check bottom sizing border */
784 if (pt.y >= rect.bottom)
786 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMLEFT;
787 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMRIGHT;
790 /* Check left sizing border */
791 if (pt.x < rect.left)
793 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPLEFT;
794 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMLEFT;
797 /* Check right sizing border */
798 if (pt.x >= rect.right)
800 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPRIGHT;
801 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMRIGHT;
806 else /* No thick frame */
808 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
809 InflateRect(&rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
810 else if (HAS_THINFRAME( wndPtr->dwStyle ))
811 InflateRect(&rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
812 if (!PtInRect( &rect, pt )) return HTBORDER;
817 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
819 if (wndPtr->dwExStyle & WS_EX_TOOLWINDOW)
820 rect.top += GetSystemMetrics(SM_CYSMCAPTION) - 1;
822 rect.top += GetSystemMetrics(SM_CYCAPTION) - 1;
823 if (!PtInRect( &rect, pt ))
825 /* Check system menu */
826 if ((wndPtr->dwStyle & WS_SYSMENU) && !(wndPtr->dwExStyle & WS_EX_TOOLWINDOW))
828 if (NC_IconForWindow(wndPtr))
829 rect.left += GetSystemMetrics(SM_CYCAPTION) - 1;
831 if (pt.x < rect.left) return HTSYSMENU;
833 /* Check close button */
834 if (wndPtr->dwStyle & WS_SYSMENU)
835 rect.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
836 if (pt.x > rect.right) return HTCLOSE;
838 /* Check maximize box */
839 /* In win95 there is automatically a Maximize button when there is a minimize one*/
840 if ((wndPtr->dwStyle & WS_MAXIMIZEBOX)|| (wndPtr->dwStyle & WS_MINIMIZEBOX))
841 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
842 if (pt.x > rect.right) return HTMAXBUTTON;
844 /* Check minimize box */
845 /* In win95 there is automatically a Maximize button when there is a Maximize one*/
846 if ((wndPtr->dwStyle & WS_MINIMIZEBOX)||(wndPtr->dwStyle & WS_MAXIMIZEBOX))
847 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
849 if (pt.x > rect.right) return HTMINBUTTON;
855 /* Check client area */
857 ScreenToClient( wndPtr->hwndSelf, &pt );
858 GetClientRect( wndPtr->hwndSelf, &rect );
859 if (PtInRect( &rect, pt )) return HTCLIENT;
861 /* Check vertical scroll bar */
863 if (wndPtr->dwStyle & WS_VSCROLL)
865 rect.right += GetSystemMetrics(SM_CXVSCROLL);
866 if (PtInRect( &rect, pt )) return HTVSCROLL;
869 /* Check horizontal scroll bar */
871 if (wndPtr->dwStyle & WS_HSCROLL)
873 rect.bottom += GetSystemMetrics(SM_CYHSCROLL);
874 if (PtInRect( &rect, pt ))
877 if ((wndPtr->dwStyle & WS_VSCROLL) &&
878 (pt.x >= rect.right - GetSystemMetrics(SM_CXVSCROLL)))
886 if (HAS_MENU(wndPtr))
888 if ((pt.y < 0) && (pt.x >= 0) && (pt.x < rect.right))
892 /* Has to return HTNOWHERE if nothing was found
893 Could happen when a window has a customized non client area */
898 /***********************************************************************
901 * Handle a WM_NCHITTEST message. Called from DefWindowProc().
903 LONG NC_HandleNCHitTest (HWND hwnd , POINT pt)
906 WND *wndPtr = WIN_FindWndPtr (hwnd);
911 if (TWEAK_WineLook == WIN31_LOOK)
912 retvalue = NC_DoNCHitTest (wndPtr, pt);
914 retvalue = NC_DoNCHitTest95 (wndPtr, pt);
915 WIN_ReleaseWndPtr(wndPtr);
920 /***********************************************************************
923 void NC_DrawSysButton( HWND hwnd, HDC hdc, BOOL down )
928 WND *wndPtr = WIN_FindWndPtr( hwnd );
930 if( !(wndPtr->dwExStyle & WS_EX_MANAGED) )
932 NC_GetInsideRect( hwnd, &rect );
933 hdcMem = CreateCompatibleDC( hdc );
934 hbitmap = SelectObject( hdcMem, hbitmapClose );
935 BitBlt(hdc, rect.left, rect.top, GetSystemMetrics(SM_CXSIZE), GetSystemMetrics(SM_CYSIZE),
936 hdcMem, (wndPtr->dwStyle & WS_CHILD) ? GetSystemMetrics(SM_CXSIZE) : 0, 0,
937 down ? NOTSRCCOPY : SRCCOPY );
938 SelectObject( hdcMem, hbitmap );
941 WIN_ReleaseWndPtr(wndPtr);
945 /***********************************************************************
948 static void NC_DrawMaxButton( HWND hwnd, HDC16 hdc, BOOL down )
951 WND *wndPtr = WIN_FindWndPtr( hwnd );
954 if( !(wndPtr->dwExStyle & WS_EX_MANAGED) )
956 NC_GetInsideRect( hwnd, &rect );
957 hdcMem = CreateCompatibleDC( hdc );
958 SelectObject( hdcMem, (IsZoomed(hwnd)
959 ? (down ? hbitmapRestoreD : hbitmapRestore)
960 : (down ? hbitmapMaximizeD : hbitmapMaximize)) );
961 BitBlt( hdc, rect.right - GetSystemMetrics(SM_CXSIZE) - 1, rect.top,
962 GetSystemMetrics(SM_CXSIZE) + 1, GetSystemMetrics(SM_CYSIZE), hdcMem, 0, 0,
966 WIN_ReleaseWndPtr(wndPtr);
971 /***********************************************************************
974 static void NC_DrawMinButton( HWND hwnd, HDC16 hdc, BOOL down )
977 WND *wndPtr = WIN_FindWndPtr( hwnd );
980 if( !(wndPtr->dwExStyle & WS_EX_MANAGED) )
982 NC_GetInsideRect( hwnd, &rect );
983 hdcMem = CreateCompatibleDC( hdc );
984 SelectObject( hdcMem, (down ? hbitmapMinimizeD : hbitmapMinimize) );
985 if (wndPtr->dwStyle & WS_MAXIMIZEBOX) rect.right -= GetSystemMetrics(SM_CXSIZE)+1;
986 BitBlt( hdc, rect.right - GetSystemMetrics(SM_CXSIZE) - 1, rect.top,
987 GetSystemMetrics(SM_CXSIZE) + 1, GetSystemMetrics(SM_CYSIZE), hdcMem, 0, 0,
991 WIN_ReleaseWndPtr(wndPtr);
995 /******************************************************************************
997 * void NC_DrawSysButton95(
1002 * Draws the Win95 system icon.
1005 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1006 * Original implementation from NC_DrawSysButton source.
1007 * 11-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1010 *****************************************************************************/
1013 NC_DrawSysButton95 (HWND hwnd, HDC hdc, BOOL down)
1015 WND *wndPtr = WIN_FindWndPtr( hwnd );
1017 if( !(wndPtr->dwExStyle & WS_EX_MANAGED) )
1022 NC_GetInsideRect( hwnd, &rect );
1024 hIcon = NC_IconForWindow( wndPtr );
1027 DrawIconEx (hdc, rect.left + 2, rect.top + 2, hIcon,
1028 GetSystemMetrics(SM_CXSMICON),
1029 GetSystemMetrics(SM_CYSMICON),
1032 WIN_ReleaseWndPtr(wndPtr);
1033 return (hIcon != 0);
1035 WIN_ReleaseWndPtr(wndPtr);
1040 /******************************************************************************
1042 * void NC_DrawCloseButton95(
1048 * Draws the Win95 close button.
1050 * If bGrayed is true, then draw a disabled Close button
1053 * 11-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1054 * Original implementation from NC_DrawSysButton95 source.
1056 *****************************************************************************/
1058 static void NC_DrawCloseButton95 (HWND hwnd, HDC hdc, BOOL down, BOOL bGrayed)
1061 WND *wndPtr = WIN_FindWndPtr( hwnd );
1063 if( !(wndPtr->dwExStyle & WS_EX_MANAGED) )
1065 NC_GetInsideRect( hwnd, &rect );
1067 /* A tool window has a smaller Close button */
1068 if(wndPtr->dwExStyle & WS_EX_TOOLWINDOW)
1070 INT iBmpHeight = 11; /* Windows does not use SM_CXSMSIZE and SM_CYSMSIZE */
1071 INT iBmpWidth = 11; /* it uses 11x11 for the close button in tool window */
1072 INT iCaptionHeight = GetSystemMetrics(SM_CYSMCAPTION);
1074 rect.top = rect.top + (iCaptionHeight - 1 - iBmpHeight) / 2;
1075 rect.left = rect.right - (iCaptionHeight + 1 + iBmpWidth) / 2;
1076 rect.bottom = rect.top + iBmpHeight;
1077 rect.right = rect.left + iBmpWidth;
1081 rect.left = rect.right - GetSystemMetrics(SM_CXSIZE) - 1;
1082 rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) - 1;
1086 DrawFrameControl( hdc, &rect, DFC_CAPTION,
1087 (DFCS_CAPTIONCLOSE |
1088 (down ? DFCS_PUSHED : 0) |
1089 (bGrayed ? DFCS_INACTIVE : 0)) );
1091 WIN_ReleaseWndPtr(wndPtr);
1094 /******************************************************************************
1095 * NC_DrawMaxButton95
1097 * Draws the maximize button for Win95 style windows.
1098 * If bGrayed is true, then draw a disabled Maximize button
1100 static void NC_DrawMaxButton95(HWND hwnd,HDC16 hdc,BOOL down, BOOL bGrayed)
1103 WND *wndPtr = WIN_FindWndPtr( hwnd );
1105 if( !(wndPtr->dwExStyle & WS_EX_MANAGED))
1107 UINT flags = IsZoomed(hwnd) ? DFCS_CAPTIONRESTORE : DFCS_CAPTIONMAX;
1108 NC_GetInsideRect( hwnd, &rect );
1109 if (wndPtr->dwStyle & WS_SYSMENU)
1110 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1111 rect.left = rect.right - GetSystemMetrics(SM_CXSIZE);
1112 rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) - 1;
1115 if (down) flags |= DFCS_PUSHED;
1116 if (bGrayed) flags |= DFCS_INACTIVE;
1117 DrawFrameControl( hdc, &rect, DFC_CAPTION, flags );
1119 WIN_ReleaseWndPtr(wndPtr);
1122 /******************************************************************************
1123 * NC_DrawMinButton95
1125 * Draws the minimize button for Win95 style windows.
1126 * If bGrayed is true, then draw a disabled Minimize button
1128 static void NC_DrawMinButton95(HWND hwnd,HDC16 hdc,BOOL down, BOOL bGrayed)
1131 WND *wndPtr = WIN_FindWndPtr( hwnd );
1133 if( !(wndPtr->dwExStyle & WS_EX_MANAGED))
1135 UINT flags = DFCS_CAPTIONMIN;
1136 NC_GetInsideRect( hwnd, &rect );
1137 if (wndPtr->dwStyle & WS_SYSMENU)
1138 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1139 if (wndPtr->dwStyle & (WS_MAXIMIZEBOX|WS_MINIMIZEBOX))
1140 rect.right -= GetSystemMetrics(SM_CXSIZE) - 2;
1141 rect.left = rect.right - GetSystemMetrics(SM_CXSIZE);
1142 rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) - 1;
1145 if (down) flags |= DFCS_PUSHED;
1146 if (bGrayed) flags |= DFCS_INACTIVE;
1147 DrawFrameControl( hdc, &rect, DFC_CAPTION, flags );
1149 WIN_ReleaseWndPtr(wndPtr);
1152 /***********************************************************************
1155 * Draw a window frame inside the given rectangle, and update the rectangle.
1156 * The correct pen for the frame must be selected in the DC.
1158 static void NC_DrawFrame( HDC hdc, RECT *rect, BOOL dlgFrame,
1163 if (TWEAK_WineLook != WIN31_LOOK)
1164 ERR("Called in Win95 mode. Aiee! Please report this.\n" );
1168 width = GetSystemMetrics(SM_CXDLGFRAME) - 1;
1169 height = GetSystemMetrics(SM_CYDLGFRAME) - 1;
1170 SelectObject( hdc, GetSysColorBrush(active ? COLOR_ACTIVECAPTION :
1171 COLOR_INACTIVECAPTION) );
1175 width = GetSystemMetrics(SM_CXFRAME) - 2;
1176 height = GetSystemMetrics(SM_CYFRAME) - 2;
1177 SelectObject( hdc, GetSysColorBrush(active ? COLOR_ACTIVEBORDER :
1178 COLOR_INACTIVEBORDER) );
1182 PatBlt( hdc, rect->left, rect->top,
1183 rect->right - rect->left, height, PATCOPY );
1184 PatBlt( hdc, rect->left, rect->top,
1185 width, rect->bottom - rect->top, PATCOPY );
1186 PatBlt( hdc, rect->left, rect->bottom - 1,
1187 rect->right - rect->left, -height, PATCOPY );
1188 PatBlt( hdc, rect->right - 1, rect->top,
1189 -width, rect->bottom - rect->top, PATCOPY );
1193 InflateRect( rect, -width, -height );
1197 INT decYOff = GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXSIZE) - 1;
1198 INT decXOff = GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYSIZE) - 1;
1200 /* Draw inner rectangle */
1202 SelectObject( hdc, GetStockObject(NULL_BRUSH) );
1203 Rectangle( hdc, rect->left + width, rect->top + height,
1204 rect->right - width , rect->bottom - height );
1206 /* Draw the decorations */
1208 MoveToEx( hdc, rect->left, rect->top + decYOff, NULL );
1209 LineTo( hdc, rect->left + width, rect->top + decYOff );
1210 MoveToEx( hdc, rect->right - 1, rect->top + decYOff, NULL );
1211 LineTo( hdc, rect->right - width - 1, rect->top + decYOff );
1212 MoveToEx( hdc, rect->left, rect->bottom - decYOff, NULL );
1213 LineTo( hdc, rect->left + width, rect->bottom - decYOff );
1214 MoveToEx( hdc, rect->right - 1, rect->bottom - decYOff, NULL );
1215 LineTo( hdc, rect->right - width - 1, rect->bottom - decYOff );
1217 MoveToEx( hdc, rect->left + decXOff, rect->top, NULL );
1218 LineTo( hdc, rect->left + decXOff, rect->top + height);
1219 MoveToEx( hdc, rect->left + decXOff, rect->bottom - 1, NULL );
1220 LineTo( hdc, rect->left + decXOff, rect->bottom - height - 1 );
1221 MoveToEx( hdc, rect->right - decXOff, rect->top, NULL );
1222 LineTo( hdc, rect->right - decXOff, rect->top + height );
1223 MoveToEx( hdc, rect->right - decXOff, rect->bottom - 1, NULL );
1224 LineTo( hdc, rect->right - decXOff, rect->bottom - height - 1 );
1226 InflateRect( rect, -width - 1, -height - 1 );
1231 /******************************************************************************
1233 * void NC_DrawFrame95(
1239 * Draw a window frame inside the given rectangle, and update the rectangle.
1240 * The correct pen for the frame must be selected in the DC.
1243 * Many. First, just what IS a frame in Win95? Note that the 3D look
1244 * on the outer edge is handled by NC_DoNCPaint95. As is the inner
1245 * edge. The inner rectangle just inside the frame is handled by the
1248 * In short, for most people, this function should be a nop (unless
1249 * you LIKE thick borders in Win95/NT4.0 -- I've been working with
1250 * them lately, but just to get this code right). Even so, it doesn't
1251 * appear to be so. It's being worked on...
1254 * 06-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1255 * Original implementation (based on NC_DrawFrame)
1256 * 02-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1258 * 29-Jun-1999 Ove Kåven (ovek@arcticnet.no)
1259 * Fixed a fix or something.
1261 *****************************************************************************/
1263 static void NC_DrawFrame95(
1273 width = GetSystemMetrics(SM_CXDLGFRAME) - GetSystemMetrics(SM_CXEDGE);
1274 height = GetSystemMetrics(SM_CYDLGFRAME) - GetSystemMetrics(SM_CYEDGE);
1278 width = GetSystemMetrics(SM_CXFRAME) - GetSystemMetrics(SM_CXEDGE);
1279 height = GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYEDGE);
1282 SelectObject( hdc, GetSysColorBrush(active ? COLOR_ACTIVEBORDER :
1283 COLOR_INACTIVEBORDER) );
1286 PatBlt( hdc, rect->left, rect->top,
1287 rect->right - rect->left, height, PATCOPY );
1288 PatBlt( hdc, rect->left, rect->top,
1289 width, rect->bottom - rect->top, PATCOPY );
1290 PatBlt( hdc, rect->left, rect->bottom - 1,
1291 rect->right - rect->left, -height, PATCOPY );
1292 PatBlt( hdc, rect->right - 1, rect->top,
1293 -width, rect->bottom - rect->top, PATCOPY );
1295 InflateRect( rect, -width, -height );
1299 /***********************************************************************
1302 * Draw the window caption.
1303 * The correct pen for the window frame must be selected in the DC.
1305 static void NC_DrawCaption( HDC hdc, RECT *rect, HWND hwnd,
1306 DWORD style, BOOL active )
1309 WND * wndPtr = WIN_FindWndPtr( hwnd );
1312 if (wndPtr->dwExStyle & WS_EX_MANAGED)
1314 WIN_ReleaseWndPtr(wndPtr);
1320 if (!(hbitmapClose = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_CLOSE) )))
1322 WIN_ReleaseWndPtr(wndPtr);
1325 hbitmapMinimize = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_REDUCE) );
1326 hbitmapMinimizeD = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_REDUCED) );
1327 hbitmapMaximize = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_ZOOM) );
1328 hbitmapMaximizeD = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_ZOOMD) );
1329 hbitmapRestore = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_RESTORE) );
1330 hbitmapRestoreD = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_RESTORED) );
1333 if (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME)
1335 HBRUSH hbrushOld = SelectObject(hdc, GetSysColorBrush(COLOR_WINDOW) );
1336 PatBlt( hdc, r.left, r.top, 1, r.bottom-r.top+1,PATCOPY );
1337 PatBlt( hdc, r.right-1, r.top, 1, r.bottom-r.top+1, PATCOPY );
1338 PatBlt( hdc, r.left, r.top-1, r.right-r.left, 1, PATCOPY );
1341 SelectObject( hdc, hbrushOld );
1343 WIN_ReleaseWndPtr(wndPtr);
1344 MoveToEx( hdc, r.left, r.bottom, NULL );
1345 LineTo( hdc, r.right, r.bottom );
1347 if (style & WS_SYSMENU)
1349 NC_DrawSysButton( hwnd, hdc, FALSE );
1350 r.left += GetSystemMetrics(SM_CXSIZE) + 1;
1351 MoveToEx( hdc, r.left - 1, r.top, NULL );
1352 LineTo( hdc, r.left - 1, r.bottom );
1354 if (style & WS_MAXIMIZEBOX)
1356 NC_DrawMaxButton( hwnd, hdc, FALSE );
1357 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1359 if (style & WS_MINIMIZEBOX)
1361 NC_DrawMinButton( hwnd, hdc, FALSE );
1362 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1365 FillRect( hdc, &r, GetSysColorBrush(active ? COLOR_ACTIVECAPTION :
1366 COLOR_INACTIVECAPTION) );
1368 if (GetWindowTextA( hwnd, buffer, sizeof(buffer) ))
1370 if (active) SetTextColor( hdc, GetSysColor( COLOR_CAPTIONTEXT ) );
1371 else SetTextColor( hdc, GetSysColor( COLOR_INACTIVECAPTIONTEXT ) );
1372 SetBkMode( hdc, TRANSPARENT );
1373 DrawTextA( hdc, buffer, -1, &r,
1374 DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_NOPREFIX );
1379 /******************************************************************************
1388 * Draw the window caption for Win95 style windows.
1389 * The correct pen for the window frame must be selected in the DC.
1392 * Hey, a function that finally works! Well, almost.
1393 * It's being worked on.
1396 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1397 * Original implementation.
1398 * 02-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1401 *****************************************************************************/
1403 static void NC_DrawCaption95(
1412 WND *wndPtr = WIN_FindWndPtr( hwnd );
1417 if (wndPtr->dwExStyle & WS_EX_MANAGED)
1419 WIN_ReleaseWndPtr(wndPtr);
1422 WIN_ReleaseWndPtr(wndPtr);
1424 hPrevPen = SelectObject( hdc, GetSysColorPen(COLOR_3DFACE) );
1425 MoveToEx( hdc, r.left, r.bottom - 1, NULL );
1426 LineTo( hdc, r.right, r.bottom - 1 );
1427 SelectObject( hdc, hPrevPen );
1430 FillRect( hdc, &r, GetSysColorBrush(active ? COLOR_ACTIVECAPTION :
1431 COLOR_INACTIVECAPTION) );
1433 if ((style & WS_SYSMENU) && !(exStyle & WS_EX_TOOLWINDOW)) {
1434 if (NC_DrawSysButton95 (hwnd, hdc, FALSE))
1435 r.left += GetSystemMetrics(SM_CYCAPTION) - 1;
1438 if (style & WS_SYSMENU)
1442 /* Go get the sysmenu */
1443 hSysMenu = GetSystemMenu(hwnd, FALSE);
1444 state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
1446 /* Draw a grayed close button if disabled and a normal one if SC_CLOSE is not there */
1447 NC_DrawCloseButton95 (hwnd, hdc, FALSE,
1448 ((((state & MF_DISABLED) || (state & MF_GRAYED))) && (state != 0xFFFFFFFF)));
1449 r.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
1451 if ((style & WS_MAXIMIZEBOX) || (style & WS_MINIMIZEBOX))
1453 /* In win95 the two buttons are always there */
1454 /* But if the menu item is not in the menu they're disabled*/
1456 NC_DrawMaxButton95( hwnd, hdc, FALSE, (!(style & WS_MAXIMIZEBOX)));
1457 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1459 NC_DrawMinButton95( hwnd, hdc, FALSE, (!(style & WS_MINIMIZEBOX)));
1460 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1464 if (GetWindowTextA( hwnd, buffer, sizeof(buffer) )) {
1465 NONCLIENTMETRICSA nclm;
1466 HFONT hFont, hOldFont;
1467 nclm.cbSize = sizeof(NONCLIENTMETRICSA);
1468 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
1469 if (exStyle & WS_EX_TOOLWINDOW)
1470 hFont = CreateFontIndirectA (&nclm.lfSmCaptionFont);
1472 hFont = CreateFontIndirectA (&nclm.lfCaptionFont);
1473 hOldFont = SelectObject (hdc, hFont);
1474 if (active) SetTextColor( hdc, GetSysColor( COLOR_CAPTIONTEXT ) );
1475 else SetTextColor( hdc, GetSysColor( COLOR_INACTIVECAPTIONTEXT ) );
1476 SetBkMode( hdc, TRANSPARENT );
1478 DrawTextA( hdc, buffer, -1, &r,
1479 DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT );
1480 DeleteObject (SelectObject (hdc, hOldFont));
1486 /***********************************************************************
1489 * Paint the non-client area. clip is currently unused.
1491 static void NC_DoNCPaint( WND* wndPtr, HRGN clip, BOOL suppress_menupaint )
1496 HWND hwnd = wndPtr->hwndSelf;
1498 if ( wndPtr->dwStyle & WS_MINIMIZE ||
1499 !WIN_IsWindowDrawable( wndPtr, 0 )) return; /* Nothing to do */
1501 active = wndPtr->flags & WIN_NCACTIVATED;
1503 TRACE("%04x %d\n", hwnd, active );
1505 if (!(hdc = GetDCEx( hwnd, (clip > 1) ? clip : 0, DCX_USESTYLE | DCX_WINDOW |
1506 ((clip > 1) ? (DCX_INTERSECTRGN | DCX_KEEPCLIPRGN): 0) ))) return;
1508 if (ExcludeVisRect16( hdc, wndPtr->rectClient.left-wndPtr->rectWindow.left,
1509 wndPtr->rectClient.top-wndPtr->rectWindow.top,
1510 wndPtr->rectClient.right-wndPtr->rectWindow.left,
1511 wndPtr->rectClient.bottom-wndPtr->rectWindow.top )
1514 ReleaseDC( hwnd, hdc );
1518 rect.top = rect.left = 0;
1519 rect.right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
1520 rect.bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
1522 SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
1524 if (!(wndPtr->dwExStyle & WS_EX_MANAGED))
1526 if (HAS_ANYFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
1528 SelectObject( hdc, GetStockObject(NULL_BRUSH) );
1529 Rectangle( hdc, 0, 0, rect.right, rect.bottom );
1530 InflateRect( &rect, -1, -1 );
1533 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
1534 NC_DrawFrame(hdc, &rect, FALSE, active );
1535 else if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
1536 NC_DrawFrame( hdc, &rect, TRUE, active );
1538 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
1541 r.bottom = rect.top + GetSystemMetrics(SM_CYSIZE);
1542 rect.top += GetSystemMetrics(SM_CYSIZE) + GetSystemMetrics(SM_CYBORDER);
1543 NC_DrawCaption( hdc, &r, hwnd, wndPtr->dwStyle, active );
1547 if (HAS_MENU(wndPtr))
1550 r.bottom = rect.top + GetSystemMetrics(SM_CYMENU); /* default height */
1551 rect.top += MENU_DrawMenuBar( hdc, &r, hwnd, suppress_menupaint );
1554 /* Draw the scroll-bars */
1556 if (wndPtr->dwStyle & WS_VSCROLL)
1557 SCROLL_DrawScrollBar( hwnd, hdc, SB_VERT, TRUE, TRUE );
1558 if (wndPtr->dwStyle & WS_HSCROLL)
1559 SCROLL_DrawScrollBar( hwnd, hdc, SB_HORZ, TRUE, TRUE );
1561 /* Draw the "size-box" */
1563 if ((wndPtr->dwStyle & WS_VSCROLL) && (wndPtr->dwStyle & WS_HSCROLL))
1566 r.left = r.right - GetSystemMetrics(SM_CXVSCROLL) + 1;
1567 r.top = r.bottom - GetSystemMetrics(SM_CYHSCROLL) + 1;
1568 if(wndPtr->dwStyle & WS_BORDER) {
1572 FillRect( hdc, &r, GetSysColorBrush(COLOR_SCROLLBAR) );
1575 ReleaseDC( hwnd, hdc );
1579 /******************************************************************************
1581 * void NC_DoNCPaint95(
1584 * BOOL suppress_menupaint )
1586 * Paint the non-client area for Win95 windows. The clip region is
1587 * currently ignored.
1590 * grep -E -A10 -B5 \(95\)\|\(Bugs\)\|\(FIXME\) windows/nonclient.c \
1591 * misc/tweak.c controls/menu.c # :-)
1594 * 03-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1595 * Original implementation
1596 * 10-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1598 * 29-Jun-1999 Ove Kåven (ovek@arcticnet.no)
1599 * Streamlined window style checks.
1601 *****************************************************************************/
1603 static void NC_DoNCPaint95(
1606 BOOL suppress_menupaint )
1609 RECT rfuzz, rect, rectClip;
1611 HWND hwnd = wndPtr->hwndSelf;
1613 if ( wndPtr->dwStyle & WS_MINIMIZE ||
1614 !WIN_IsWindowDrawable( wndPtr, 0 )) return; /* Nothing to do */
1616 active = wndPtr->flags & WIN_NCACTIVATED;
1618 TRACE("%04x %d\n", hwnd, active );
1620 /* MSDN docs are pretty idiotic here, they say app CAN use clipRgn in
1621 the call to GetDCEx implying that it is allowed not to use it either.
1622 However, the suggested GetDCEx( , DCX_WINDOW | DCX_INTERSECTRGN)
1623 will cause clipRgn to be deleted after ReleaseDC().
1624 Now, how is the "system" supposed to tell what happened?
1627 if (!(hdc = GetDCEx( hwnd, (clip > 1) ? clip : 0, DCX_USESTYLE | DCX_WINDOW |
1628 ((clip > 1) ?(DCX_INTERSECTRGN | DCX_KEEPCLIPRGN) : 0) ))) return;
1631 if (ExcludeVisRect16( hdc, wndPtr->rectClient.left-wndPtr->rectWindow.left,
1632 wndPtr->rectClient.top-wndPtr->rectWindow.top,
1633 wndPtr->rectClient.right-wndPtr->rectWindow.left,
1634 wndPtr->rectClient.bottom-wndPtr->rectWindow.top )
1637 ReleaseDC( hwnd, hdc );
1641 rect.top = rect.left = 0;
1642 rect.right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
1643 rect.bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
1646 GetRgnBox( clip, &rectClip );
1653 SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
1655 if(!(wndPtr->dwExStyle & WS_EX_MANAGED)) {
1656 if (HAS_BIGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle)) {
1657 DrawEdge (hdc, &rect, EDGE_RAISED, BF_RECT | BF_ADJUST);
1659 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
1660 NC_DrawFrame95(hdc, &rect, FALSE, active );
1661 else if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
1662 NC_DrawFrame95( hdc, &rect, TRUE, active );
1663 else if (HAS_THINFRAME( wndPtr->dwStyle )) {
1664 SelectObject( hdc, GetStockObject(NULL_BRUSH) );
1665 Rectangle( hdc, 0, 0, rect.right, rect.bottom );
1668 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
1671 if (wndPtr->dwExStyle & WS_EX_TOOLWINDOW) {
1672 r.bottom = rect.top + GetSystemMetrics(SM_CYSMCAPTION);
1673 rect.top += GetSystemMetrics(SM_CYSMCAPTION);
1676 r.bottom = rect.top + GetSystemMetrics(SM_CYCAPTION);
1677 rect.top += GetSystemMetrics(SM_CYCAPTION);
1679 if( !clip || IntersectRect( &rfuzz, &r, &rectClip ) )
1680 NC_DrawCaption95 (hdc, &r, hwnd, wndPtr->dwStyle,
1681 wndPtr->dwExStyle, active);
1685 if (HAS_MENU(wndPtr))
1688 r.bottom = rect.top + GetSystemMetrics(SM_CYMENU);
1690 TRACE("Calling DrawMenuBar with rect (%d, %d)-(%d, %d)\n",
1691 r.left, r.top, r.right, r.bottom);
1693 rect.top += MENU_DrawMenuBar( hdc, &r, hwnd, suppress_menupaint ) + 1;
1696 TRACE("After MenuBar, rect is (%d, %d)-(%d, %d).\n",
1697 rect.left, rect.top, rect.right, rect.bottom );
1699 if (wndPtr->dwExStyle & WS_EX_CLIENTEDGE)
1700 DrawEdge (hdc, &rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
1702 if (wndPtr->dwExStyle & WS_EX_STATICEDGE)
1703 DrawEdge (hdc, &rect, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
1705 /* Draw the scroll-bars */
1707 if (wndPtr->dwStyle & WS_VSCROLL)
1708 SCROLL_DrawScrollBar( hwnd, hdc, SB_VERT, TRUE, TRUE );
1709 if (wndPtr->dwStyle & WS_HSCROLL)
1710 SCROLL_DrawScrollBar( hwnd, hdc, SB_HORZ, TRUE, TRUE );
1712 /* Draw the "size-box" */
1713 if ((wndPtr->dwStyle & WS_VSCROLL) && (wndPtr->dwStyle & WS_HSCROLL))
1716 r.left = r.right - GetSystemMetrics(SM_CXVSCROLL) + 1;
1717 r.top = r.bottom - GetSystemMetrics(SM_CYHSCROLL) + 1;
1718 FillRect( hdc, &r, GetSysColorBrush(COLOR_SCROLLBAR) );
1721 ReleaseDC( hwnd, hdc );
1727 /***********************************************************************
1730 * Handle a WM_NCPAINT message. Called from DefWindowProc().
1732 LONG NC_HandleNCPaint( HWND hwnd , HRGN clip)
1734 WND* wndPtr = WIN_FindWndPtr( hwnd );
1736 if( wndPtr && wndPtr->dwStyle & WS_VISIBLE )
1738 if( wndPtr->dwStyle & WS_MINIMIZE )
1739 WINPOS_RedrawIconTitle( hwnd );
1740 else if (TWEAK_WineLook == WIN31_LOOK)
1741 NC_DoNCPaint( wndPtr, clip, FALSE );
1743 NC_DoNCPaint95( wndPtr, clip, FALSE );
1745 WIN_ReleaseWndPtr(wndPtr);
1750 /***********************************************************************
1751 * NC_HandleNCActivate
1753 * Handle a WM_NCACTIVATE message. Called from DefWindowProc().
1755 LONG NC_HandleNCActivate( WND *wndPtr, WPARAM16 wParam )
1759 if( wParam ) wStateChange = !(wndPtr->flags & WIN_NCACTIVATED);
1760 else wStateChange = wndPtr->flags & WIN_NCACTIVATED;
1764 if (wParam) wndPtr->flags |= WIN_NCACTIVATED;
1765 else wndPtr->flags &= ~WIN_NCACTIVATED;
1767 if( wndPtr->dwStyle & WS_MINIMIZE )
1768 WINPOS_RedrawIconTitle( wndPtr->hwndSelf );
1769 else if (TWEAK_WineLook == WIN31_LOOK)
1770 NC_DoNCPaint( wndPtr, (HRGN)1, FALSE );
1772 NC_DoNCPaint95( wndPtr, (HRGN)1, FALSE );
1778 /***********************************************************************
1779 * NC_HandleSetCursor
1781 * Handle a WM_SETCURSOR message. Called from DefWindowProc().
1783 LONG NC_HandleSetCursor( HWND hwnd, WPARAM16 wParam, LPARAM lParam )
1785 if (hwnd != (HWND)wParam) return 0; /* Don't set the cursor for child windows */
1787 switch(LOWORD(lParam))
1791 WORD msg = HIWORD( lParam );
1792 if ((msg == WM_LBUTTONDOWN) || (msg == WM_MBUTTONDOWN) ||
1793 (msg == WM_RBUTTONDOWN))
1800 HICON16 hCursor = (HICON16) GetClassWord(hwnd, GCW_HCURSOR);
1802 SetCursor16(hCursor);
1810 return (LONG)SetCursor( LoadCursorA( 0, IDC_SIZEWEA ) );
1814 return (LONG)SetCursor( LoadCursorA( 0, IDC_SIZENSA ) );
1818 return (LONG)SetCursor( LoadCursorA( 0, IDC_SIZENWSEA ) );
1822 return (LONG)SetCursor( LoadCursorA( 0, IDC_SIZENESWA ) );
1825 /* Default cursor: arrow */
1826 return (LONG)SetCursor( LoadCursorA( 0, IDC_ARROWA ) );
1829 /***********************************************************************
1832 BOOL NC_GetSysPopupPos( WND* wndPtr, RECT* rect )
1834 if( wndPtr->hSysMenu )
1836 if( wndPtr->dwStyle & WS_MINIMIZE )
1837 GetWindowRect( wndPtr->hwndSelf, rect );
1840 NC_GetInsideRect( wndPtr->hwndSelf, rect );
1841 OffsetRect( rect, wndPtr->rectWindow.left, wndPtr->rectWindow.top);
1842 if (wndPtr->dwStyle & WS_CHILD)
1843 ClientToScreen( wndPtr->parent->hwndSelf, (POINT *)rect );
1844 if (TWEAK_WineLook == WIN31_LOOK) {
1845 rect->right = rect->left + GetSystemMetrics(SM_CXSIZE);
1846 rect->bottom = rect->top + GetSystemMetrics(SM_CYSIZE);
1849 rect->right = rect->left + GetSystemMetrics(SM_CYCAPTION) - 1;
1850 rect->bottom = rect->top + GetSystemMetrics(SM_CYCAPTION) - 1;
1858 /***********************************************************************
1859 * NC_TrackMinMaxBox95
1861 * Track a mouse button press on the minimize or maximize box.
1863 * The big difference between 3.1 and 95 is the disabled button state.
1864 * In win95 the system button can be disabled, so it can ignore the mouse
1868 static void NC_TrackMinMaxBox95( HWND hwnd, WORD wParam )
1871 HDC hdc = GetWindowDC( hwnd );
1872 BOOL pressed = TRUE;
1874 DWORD wndStyle = GetWindowLongA( hwnd, GWL_STYLE);
1875 HMENU hSysMenu = GetSystemMenu(hwnd, FALSE);
1877 void (*paintButton)(HWND, HDC16, BOOL, BOOL);
1879 if (wParam == HTMINBUTTON)
1881 /* If the style is not present, do nothing */
1882 if (!(wndStyle & WS_MINIMIZEBOX))
1885 /* Check if the sysmenu item for minimize is there */
1886 state = GetMenuState(hSysMenu, SC_MINIMIZE, MF_BYCOMMAND);
1888 paintButton = &NC_DrawMinButton95;
1892 /* If the style is not present, do nothing */
1893 if (!(wndStyle & WS_MAXIMIZEBOX))
1896 /* Check if the sysmenu item for maximize is there */
1897 state = GetMenuState(hSysMenu, SC_MAXIMIZE, MF_BYCOMMAND);
1899 paintButton = &NC_DrawMaxButton95;
1904 (*paintButton)( hwnd, hdc, TRUE, FALSE);
1908 BOOL oldstate = pressed;
1909 MSG_InternalGetMessage( &msg, 0, 0, WM_MOUSEFIRST, WM_MOUSELAST,
1910 0, PM_REMOVE, FALSE, NULL );
1912 if(msg.message == WM_LBUTTONUP)
1915 if(msg.message != WM_MOUSEMOVE)
1918 pressed = (NC_HandleNCHitTest( hwnd, msg.pt ) == wParam);
1919 if (pressed != oldstate)
1920 (*paintButton)( hwnd, hdc, pressed, FALSE);
1924 (*paintButton)(hwnd, hdc, FALSE, FALSE);
1927 ReleaseDC( hwnd, hdc );
1929 /* If the item minimize or maximize of the sysmenu are not there */
1930 /* or if the style is not present, do nothing */
1931 if ((!pressed) || (state == 0xFFFFFFFF))
1934 if (wParam == HTMINBUTTON)
1935 SendMessageA( hwnd, WM_SYSCOMMAND, SC_MINIMIZE, MAKELONG(msg.pt.x,msg.pt.y) );
1937 SendMessageA( hwnd, WM_SYSCOMMAND,
1938 IsZoomed(hwnd) ? SC_RESTORE:SC_MAXIMIZE, MAKELONG(msg.pt.x,msg.pt.y) );
1941 /***********************************************************************
1944 * Track a mouse button press on the minimize or maximize box.
1946 static void NC_TrackMinMaxBox( HWND hwnd, WORD wParam )
1949 HDC hdc = GetWindowDC( hwnd );
1950 BOOL pressed = TRUE;
1951 void (*paintButton)(HWND, HDC16, BOOL);
1955 if (wParam == HTMINBUTTON)
1956 paintButton = &NC_DrawMinButton;
1958 paintButton = &NC_DrawMaxButton;
1960 (*paintButton)( hwnd, hdc, TRUE);
1964 BOOL oldstate = pressed;
1965 MSG_InternalGetMessage( &msg, 0, 0, WM_MOUSEFIRST, WM_MOUSELAST,
1966 0, PM_REMOVE, FALSE, NULL );
1968 if(msg.message == WM_LBUTTONUP)
1971 if(msg.message != WM_MOUSEMOVE)
1974 pressed = (NC_HandleNCHitTest( hwnd, msg.pt ) == wParam);
1975 if (pressed != oldstate)
1976 (*paintButton)( hwnd, hdc, pressed);
1980 (*paintButton)( hwnd, hdc, FALSE);
1983 ReleaseDC( hwnd, hdc );
1985 if (!pressed) return;
1987 if (wParam == HTMINBUTTON)
1988 SendMessageA( hwnd, WM_SYSCOMMAND, SC_MINIMIZE, MAKELONG(msg.pt.x,msg.pt.y) );
1990 SendMessageA( hwnd, WM_SYSCOMMAND,
1991 IsZoomed(hwnd) ? SC_RESTORE:SC_MAXIMIZE, MAKELONG(msg.pt.x,msg.pt.y) );
1995 /***********************************************************************
1996 * NC_TrackCloseButton95
1998 * Track a mouse button press on the Win95 close button.
2001 NC_TrackCloseButton95 (HWND hwnd, WORD wParam)
2005 BOOL pressed = TRUE;
2006 HMENU hSysMenu = GetSystemMenu(hwnd, FALSE);
2012 state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
2014 /* If the item close of the sysmenu is disabled or not there do nothing */
2015 if((state & MF_DISABLED) || (state & MF_GRAYED) || (state == 0xFFFFFFFF))
2018 hdc = GetWindowDC( hwnd );
2022 NC_DrawCloseButton95 (hwnd, hdc, TRUE, FALSE);
2026 BOOL oldstate = pressed;
2027 MSG_InternalGetMessage( &msg, 0, 0, WM_MOUSEFIRST, WM_MOUSELAST,
2028 0, PM_REMOVE, FALSE, NULL );
2030 if(msg.message == WM_LBUTTONUP)
2033 if(msg.message != WM_MOUSEMOVE)
2036 pressed = (NC_HandleNCHitTest( hwnd, msg.pt ) == wParam);
2037 if (pressed != oldstate)
2038 NC_DrawCloseButton95 (hwnd, hdc, pressed, FALSE);
2042 NC_DrawCloseButton95 (hwnd, hdc, FALSE, FALSE);
2045 ReleaseDC( hwnd, hdc );
2046 if (!pressed) return;
2048 SendMessageA( hwnd, WM_SYSCOMMAND, SC_CLOSE, MAKELONG(msg.pt.x,msg.pt.y) );
2052 /***********************************************************************
2055 * Track a mouse button press on the horizontal or vertical scroll-bar.
2057 static void NC_TrackScrollBar( HWND hwnd, WPARAM wParam, POINT pt )
2061 WND *wndPtr = WIN_FindWndPtr( hwnd );
2063 if ((wParam & 0xfff0) == SC_HSCROLL)
2065 if ((wParam & 0x0f) != HTHSCROLL) goto END;
2066 scrollbar = SB_HORZ;
2068 else /* SC_VSCROLL */
2070 if ((wParam & 0x0f) != HTVSCROLL) goto END;
2071 scrollbar = SB_VERT;
2074 if (!(msg = SEGPTR_NEW(MSG16))) goto END;
2075 pt.x -= wndPtr->rectWindow.left;
2076 pt.y -= wndPtr->rectWindow.top;
2078 SCROLL_HandleScrollEvent( hwnd, scrollbar, WM_LBUTTONDOWN, pt );
2082 GetMessage16( SEGPTR_GET(msg), 0, 0, 0 );
2083 switch(msg->message)
2088 pt.x = LOWORD(msg->lParam) + wndPtr->rectClient.left -
2089 wndPtr->rectWindow.left;
2090 pt.y = HIWORD(msg->lParam) + wndPtr->rectClient.top -
2091 wndPtr->rectWindow.top;
2092 SCROLL_HandleScrollEvent( hwnd, scrollbar, msg->message, pt );
2095 TranslateMessage16( msg );
2096 DispatchMessage16( msg );
2099 if (!IsWindow( hwnd ))
2104 } while (msg->message != WM_LBUTTONUP);
2107 WIN_ReleaseWndPtr(wndPtr);
2110 /***********************************************************************
2111 * NC_HandleNCLButtonDown
2113 * Handle a WM_NCLBUTTONDOWN message. Called from DefWindowProc().
2115 LONG NC_HandleNCLButtonDown( WND* pWnd, WPARAM16 wParam, LPARAM lParam )
2117 HWND hwnd = pWnd->hwndSelf;
2119 switch(wParam) /* Hit test */
2122 hwnd = WIN_GetTopParent(hwnd);
2124 if( WINPOS_SetActiveWindow(hwnd, TRUE, TRUE) || (GetActiveWindow() == hwnd) )
2125 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, lParam );
2129 if( pWnd->dwStyle & WS_SYSMENU )
2131 if( !(pWnd->dwStyle & WS_MINIMIZE) )
2133 HDC hDC = GetWindowDC(hwnd);
2134 if (TWEAK_WineLook == WIN31_LOOK)
2135 NC_DrawSysButton( hwnd, hDC, TRUE );
2137 NC_DrawSysButton95( hwnd, hDC, TRUE );
2138 ReleaseDC( hwnd, hDC );
2140 SendMessage16( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU + HTSYSMENU, lParam );
2145 SendMessage16( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU, lParam );
2149 SendMessage16( hwnd, WM_SYSCOMMAND, SC_HSCROLL + HTHSCROLL, lParam );
2153 SendMessage16( hwnd, WM_SYSCOMMAND, SC_VSCROLL + HTVSCROLL, lParam );
2158 if (TWEAK_WineLook == WIN31_LOOK)
2159 NC_TrackMinMaxBox( hwnd, wParam );
2161 NC_TrackMinMaxBox95( hwnd, wParam );
2165 if (TWEAK_WineLook >= WIN95_LOOK)
2166 NC_TrackCloseButton95 (hwnd, wParam);
2177 /* make sure hittest fits into 0xf and doesn't overlap with HTSYSMENU */
2178 SendMessage16( hwnd, WM_SYSCOMMAND, SC_SIZE + wParam - 2, lParam);
2188 /***********************************************************************
2189 * NC_HandleNCLButtonDblClk
2191 * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc().
2193 LONG NC_HandleNCLButtonDblClk( WND *pWnd, WPARAM16 wParam, LPARAM lParam )
2196 * if this is an icon, send a restore since we are handling
2199 if (pWnd->dwStyle & WS_MINIMIZE)
2201 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND, SC_RESTORE, lParam );
2205 switch(wParam) /* Hit test */
2208 /* stop processing if WS_MAXIMIZEBOX is missing */
2209 if (pWnd->dwStyle & WS_MAXIMIZEBOX)
2210 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND,
2211 (pWnd->dwStyle & WS_MAXIMIZE) ? SC_RESTORE : SC_MAXIMIZE,
2216 if (!(GetClassWord(pWnd->hwndSelf, GCW_STYLE) & CS_NOCLOSE))
2217 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND, SC_CLOSE, lParam );
2221 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND, SC_HSCROLL + HTHSCROLL,
2226 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND, SC_VSCROLL + HTVSCROLL,
2234 /***********************************************************************
2235 * NC_HandleSysCommand
2237 * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
2239 LONG NC_HandleSysCommand( HWND hwnd, WPARAM wParam, POINT pt )
2241 WND *wndPtr = WIN_FindWndPtr( hwnd );
2242 UINT16 uCommand = wParam & 0xFFF0;
2244 TRACE("Handling WM_SYSCOMMAND %x %ld,%ld\n", wParam, pt.x, pt.y );
2246 if (wndPtr->parent && (uCommand != SC_KEYMENU))
2247 ScreenToClient( wndPtr->parent->hwndSelf, &pt );
2253 if (USER_Driver.pSysCommandSizeMove)
2254 USER_Driver.pSysCommandSizeMove( hwnd, wParam );
2258 if (hwnd == GetForegroundWindow())
2259 ShowOwnedPopups(hwnd,FALSE);
2260 ShowWindow( hwnd, SW_MINIMIZE );
2264 if (IsIconic(hwnd) && hwnd == GetForegroundWindow())
2265 ShowOwnedPopups(hwnd,TRUE);
2266 ShowWindow( hwnd, SW_MAXIMIZE );
2270 if (IsIconic(hwnd) && hwnd == GetForegroundWindow())
2271 ShowOwnedPopups(hwnd,TRUE);
2272 ShowWindow( hwnd, SW_RESTORE );
2276 WIN_ReleaseWndPtr(wndPtr);
2277 return SendMessageA( hwnd, WM_CLOSE, 0, 0 );
2281 NC_TrackScrollBar( hwnd, wParam, pt );
2285 MENU_TrackMouseMenuBar( wndPtr, wParam & 0x000F, pt );
2289 MENU_TrackKbdMenuBar( wndPtr , wParam , pt.x );
2293 WinExec( "taskman.exe", SW_SHOWNORMAL );
2297 if (wParam == SC_ABOUTWINE)
2299 HMODULE hmodule = LoadLibraryA( "shell32.dll" );
2302 FARPROC aboutproc = GetProcAddress( hmodule, "ShellAboutA" );
2303 if (aboutproc) aboutproc( hwnd, "Wine", WINE_RELEASE_INFO, 0 );
2304 FreeLibrary( hmodule );
2308 if (wParam == SC_PUTMARK)
2309 TRACE_(shell)("Mark requested by user\n");
2316 FIXME("unimplemented!\n");
2319 WIN_ReleaseWndPtr(wndPtr);
2323 /*************************************************************
2326 * Stub for the grayed button of the caption
2328 *************************************************************/
2330 BOOL NC_DrawGrayButton(HDC hdc, int x, int y)
2333 HDC hdcMask = CreateCompatibleDC (0);
2336 hMaskBmp = CreateBitmap (12, 10, 1, 1, lpGrayMask);
2341 SelectObject (hdcMask, hMaskBmp);
2343 /* Draw the grayed bitmap using the mask */
2344 hOldBrush = SelectObject (hdc, RGB(128, 128, 128));
2345 BitBlt (hdc, x, y, 12, 10,
2346 hdcMask, 0, 0, 0xB8074A);
2349 SelectObject (hdc, hOldBrush);
2350 DeleteObject(hMaskBmp);
2356 HICON16 NC_IconForWindow(WND *wndPtr)
2358 HICON16 hIcon = (HICON) GetClassLongA(wndPtr->hwndSelf, GCL_HICONSM);
2359 if(!hIcon) hIcon = (HICON) GetClassLongA(wndPtr->hwndSelf, GCL_HICON);
2361 /* If there is no hIcon specified and this is a modal dialog, */
2362 /* get the default one. */
2363 if (!hIcon && (wndPtr->dwStyle & DS_MODALFRAME))
2364 hIcon = LoadImageA(0, IDI_WINLOGOA, IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);