2 * Non-client area window functions
4 * Copyright 1994 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "wine/winuser16.h"
24 #include "wine/version.h"
29 #include "cursoricon.h"
32 #include "nonclient.h"
33 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(nonclient);
38 WINE_DECLARE_DEBUG_CHANNEL(shell);
40 BOOL NC_DrawGrayButton(HDC hdc, int x, int y);
42 static HBITMAP hbitmapClose;
44 static const BYTE lpGrayMask[] = { 0xAA, 0xA0,
55 #define SC_ABOUTWINE (SC_SCREENSAVE+1)
56 #define SC_PUTMARK (SC_SCREENSAVE+2)
58 /* Some useful macros */
59 #define HAS_DLGFRAME(style,exStyle) \
60 (((exStyle) & WS_EX_DLGMODALFRAME) || \
61 (((style) & WS_DLGFRAME) && !((style) & WS_THICKFRAME)))
63 #define HAS_THICKFRAME(style,exStyle) \
64 (((style) & WS_THICKFRAME) && \
65 !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
67 #define HAS_THINFRAME(style) \
68 (((style) & WS_BORDER) || !((style) & (WS_CHILD | WS_POPUP)))
70 #define HAS_BIGFRAME(style,exStyle) \
71 (((style) & (WS_THICKFRAME | WS_DLGFRAME)) || \
72 ((exStyle) & WS_EX_DLGMODALFRAME))
74 #define HAS_STATICOUTERFRAME(style,exStyle) \
75 (((exStyle) & (WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME)) == \
78 #define HAS_ANYFRAME(style,exStyle) \
79 (((style) & (WS_THICKFRAME | WS_DLGFRAME | WS_BORDER)) || \
80 ((exStyle) & WS_EX_DLGMODALFRAME) || \
81 !((style) & (WS_CHILD | WS_POPUP)))
83 #define HAS_MENU(w) (!((w)->dwStyle & WS_CHILD) && ((w)->wIDmenu != 0))
86 /***********************************************************************
89 * Compute the size of the window rectangle from the size of the
92 static void NC_AdjustRect( LPRECT rect, DWORD style, BOOL menu, DWORD exStyle )
94 if (TWEAK_WineLook > WIN31_LOOK)
95 ERR("Called in Win95 mode. Aiee! Please report this.\n" );
97 if(style & WS_ICONIC) return;
99 if (HAS_THICKFRAME( style, exStyle ))
100 InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
101 else if (HAS_DLGFRAME( style, exStyle ))
102 InflateRect( rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
103 else if (HAS_THINFRAME( style ))
104 InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
106 if ((style & WS_CAPTION) == WS_CAPTION)
107 rect->top -= GetSystemMetrics(SM_CYCAPTION) - GetSystemMetrics(SM_CYBORDER);
109 if (menu) rect->top -= GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CYBORDER);
111 if (style & WS_VSCROLL) {
112 rect->right += GetSystemMetrics(SM_CXVSCROLL) - 1;
113 if(!HAS_ANYFRAME( style, exStyle ))
117 if (style & WS_HSCROLL) {
118 rect->bottom += GetSystemMetrics(SM_CYHSCROLL) - 1;
119 if(!HAS_ANYFRAME( style, exStyle ))
125 /******************************************************************************
126 * NC_AdjustRectOuter95
128 * Computes the size of the "outside" parts of the window based on the
129 * parameters of the client area.
138 * "Outer" parts of a window means the whole window frame, caption and
139 * menu bar. It does not include "inner" parts of the frame like client
140 * edge, static edge or scroll bars.
143 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
144 * Original (NC_AdjustRect95) cut & paste from NC_AdjustRect
146 * 20-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
147 * Split NC_AdjustRect95 into NC_AdjustRectOuter95 and
148 * NC_AdjustRectInner95 and added handling of Win95 styles.
150 * 28-Jul-1999 Ove Kåven (ovek@arcticnet.no)
151 * Streamlined window style checks.
153 *****************************************************************************/
156 NC_AdjustRectOuter95 (LPRECT rect, DWORD style, BOOL menu, DWORD exStyle)
159 if(style & WS_ICONIC) return;
161 if ((exStyle & (WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME)) ==
164 adjust = 1; /* for the outer frame always present */
169 if ((exStyle & WS_EX_DLGMODALFRAME) ||
170 (style & (WS_THICKFRAME|WS_DLGFRAME))) adjust = 2; /* outer */
172 if (style & WS_THICKFRAME)
173 adjust += ( GetSystemMetrics (SM_CXFRAME)
174 - GetSystemMetrics (SM_CXDLGFRAME)); /* The resize border */
175 if ((style & (WS_BORDER|WS_DLGFRAME)) ||
176 (exStyle & WS_EX_DLGMODALFRAME))
177 adjust++; /* The other border */
179 InflateRect (rect, adjust, adjust);
181 if ((style & WS_CAPTION) == WS_CAPTION)
183 if (exStyle & WS_EX_TOOLWINDOW)
184 rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
186 rect->top -= GetSystemMetrics(SM_CYCAPTION);
188 if (menu) rect->top -= GetSystemMetrics(SM_CYMENU);
192 /******************************************************************************
193 * NC_AdjustRectInner95
195 * Computes the size of the "inside" part of the window based on the
196 * parameters of the client area.
204 * "Inner" part of a window means the window frame inside of the flat
205 * window frame. It includes the client edge, the static edge and the
209 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
210 * Original (NC_AdjustRect95) cut & paste from NC_AdjustRect
212 * 20-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
213 * Split NC_AdjustRect95 into NC_AdjustRectOuter95 and
214 * NC_AdjustRectInner95 and added handling of Win95 styles.
216 *****************************************************************************/
219 NC_AdjustRectInner95 (LPRECT rect, DWORD style, DWORD exStyle)
221 if(style & WS_ICONIC) return;
223 if (exStyle & WS_EX_CLIENTEDGE)
224 InflateRect(rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
226 if (style & WS_VSCROLL) rect->right += GetSystemMetrics(SM_CXVSCROLL);
227 if (style & WS_HSCROLL) rect->bottom += GetSystemMetrics(SM_CYHSCROLL);
232 static HICON NC_IconForWindow( HWND hwnd )
234 HICON hIcon = (HICON) GetClassLongA( hwnd, GCL_HICONSM );
235 if (!hIcon) hIcon = (HICON) GetClassLongA( hwnd, GCL_HICON );
237 /* If there is no hIcon specified and this is a modal dialog,
238 * get the default one.
240 if (!hIcon && (GetWindowLongA( hwnd, GWL_STYLE ) & DS_MODALFRAME))
241 hIcon = LoadImageA(0, IDI_WINLOGOA, IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
245 /***********************************************************************
246 * DrawCaption (USER32.@) Draws a caption bar
260 DrawCaption (HWND hwnd, HDC hdc, const RECT *lpRect, UINT uFlags)
262 return DrawCaptionTempA (hwnd, hdc, lpRect, 0, 0, NULL, uFlags & 0x1F);
266 /***********************************************************************
267 * DrawCaptionTempA (USER32.@)
269 BOOL WINAPI DrawCaptionTempA (HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont,
270 HICON hIcon, LPCSTR str, UINT uFlags)
276 if (!(uFlags & DC_TEXT) || !str)
277 return DrawCaptionTempW( hwnd, hdc, rect, hFont, hIcon, NULL, uFlags );
279 len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
280 if ((strW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
282 MultiByteToWideChar( CP_ACP, 0, str, -1, strW, len );
283 ret = DrawCaptionTempW (hwnd, hdc, rect, hFont, hIcon, strW, uFlags);
284 HeapFree( GetProcessHeap (), 0, strW );
290 /***********************************************************************
291 * DrawCaptionTempW (USER32.@)
293 BOOL WINAPI DrawCaptionTempW (HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont,
294 HICON hIcon, LPCWSTR str, UINT uFlags)
298 TRACE("(%08x,%08x,%p,%08x,%08x,%s,%08x)\n",
299 hwnd, hdc, rect, hFont, hIcon, debugstr_w(str), uFlags);
301 /* drawing background */
302 if (uFlags & DC_INBUTTON) {
303 FillRect (hdc, &rc, GetSysColorBrush (COLOR_3DFACE));
305 if (uFlags & DC_ACTIVE) {
306 HBRUSH hbr = SelectObject (hdc, CACHE_GetPattern55AABrush ());
307 PatBlt (hdc, rc.left, rc.top,
308 rc.right-rc.left, rc.bottom-rc.top, 0xFA0089);
309 SelectObject (hdc, hbr);
313 FillRect (hdc, &rc, GetSysColorBrush ((uFlags & DC_ACTIVE) ?
314 COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION));
319 if ((uFlags & DC_ICON) && !(uFlags & DC_SMALLCAP)) {
323 pt.y = (rc.bottom + rc.top - GetSystemMetrics(SM_CYSMICON)) / 2;
325 if (!hIcon) hIcon = NC_IconForWindow(hwnd);
326 DrawIconEx (hdc, pt.x, pt.y, hIcon, GetSystemMetrics(SM_CXSMICON),
327 GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL);
328 rc.left += (rc.bottom - rc.top);
332 if (uFlags & DC_TEXT) {
335 if (uFlags & DC_INBUTTON)
336 SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
337 else if (uFlags & DC_ACTIVE)
338 SetTextColor (hdc, GetSysColor (COLOR_CAPTIONTEXT));
340 SetTextColor (hdc, GetSysColor (COLOR_INACTIVECAPTIONTEXT));
342 SetBkMode (hdc, TRANSPARENT);
345 hOldFont = SelectObject (hdc, hFont);
347 NONCLIENTMETRICSA nclm;
349 nclm.cbSize = sizeof(NONCLIENTMETRICSA);
350 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
351 hNewFont = CreateFontIndirectA ((uFlags & DC_SMALLCAP) ?
352 &nclm.lfSmCaptionFont : &nclm.lfCaptionFont);
353 hOldFont = SelectObject (hdc, hNewFont);
357 DrawTextW (hdc, str, -1, &rc,
358 DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT);
362 nLen = GetWindowTextW (hwnd, szText, 128);
363 DrawTextW (hdc, szText, nLen, &rc,
364 DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT);
368 SelectObject (hdc, hOldFont);
370 DeleteObject (SelectObject (hdc, hOldFont));
373 /* drawing focus ??? */
375 FIXME("undocumented flag (0x2000)!\n");
381 /***********************************************************************
382 * AdjustWindowRect (USER.102)
384 BOOL16 WINAPI AdjustWindowRect16( LPRECT16 rect, DWORD style, BOOL16 menu )
386 return AdjustWindowRectEx16( rect, style, menu, 0 );
390 /***********************************************************************
391 * AdjustWindowRect (USER32.@)
393 BOOL WINAPI AdjustWindowRect( LPRECT rect, DWORD style, BOOL menu )
395 return AdjustWindowRectEx( rect, style, menu, 0 );
399 /***********************************************************************
400 * AdjustWindowRectEx (USER.454)
402 BOOL16 WINAPI AdjustWindowRectEx16( LPRECT16 rect, DWORD style,
403 BOOL16 menu, DWORD exStyle )
408 CONV_RECT16TO32( rect, &rect32 );
409 ret = AdjustWindowRectEx( &rect32, style, menu, exStyle );
410 CONV_RECT32TO16( &rect32, rect );
415 /***********************************************************************
416 * AdjustWindowRectEx (USER32.@)
418 BOOL WINAPI AdjustWindowRectEx( LPRECT rect, DWORD style, BOOL menu, DWORD exStyle )
420 /* Correct the window style */
421 style &= (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME | WS_CHILD);
422 exStyle &= (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE |
423 WS_EX_STATICEDGE | WS_EX_TOOLWINDOW);
424 if (exStyle & WS_EX_DLGMODALFRAME) style &= ~WS_THICKFRAME;
426 TRACE("(%d,%d)-(%d,%d) %08lx %d %08lx\n",
427 rect->left, rect->top, rect->right, rect->bottom,
428 style, menu, exStyle );
430 if (TWEAK_WineLook == WIN31_LOOK)
431 NC_AdjustRect( rect, style, menu, exStyle );
434 NC_AdjustRectOuter95( rect, style, menu, exStyle );
435 NC_AdjustRectInner95( rect, style, exStyle );
441 /***********************************************************************
442 * NC_HandleNCCalcSize
444 * Handle a WM_NCCALCSIZE message. Called from DefWindowProc().
446 LONG NC_HandleNCCalcSize( HWND hwnd, RECT *winRect )
448 RECT tmpRect = { 0, 0, 0, 0 };
450 LONG cls_style = GetClassLongA(hwnd, GCL_STYLE);
451 LONG style = GetWindowLongA( hwnd, GWL_STYLE );
452 LONG exStyle = GetWindowLongA( hwnd, GWL_EXSTYLE );
454 if (cls_style & CS_VREDRAW) result |= WVR_VREDRAW;
455 if (cls_style & CS_HREDRAW) result |= WVR_HREDRAW;
459 if (TWEAK_WineLook == WIN31_LOOK)
460 NC_AdjustRect( &tmpRect, style, FALSE, exStyle );
462 NC_AdjustRectOuter95( &tmpRect, style, FALSE, exStyle );
464 winRect->left -= tmpRect.left;
465 winRect->top -= tmpRect.top;
466 winRect->right -= tmpRect.right;
467 winRect->bottom -= tmpRect.bottom;
469 if (!(style & WS_CHILD) && GetMenu(hwnd))
471 TRACE("Calling GetMenuBarHeight with HWND 0x%x, width %d, "
472 "at (%d, %d).\n", hwnd,
473 winRect->right - winRect->left,
474 -tmpRect.left, -tmpRect.top );
477 MENU_GetMenuBarHeight( hwnd,
478 winRect->right - winRect->left,
479 -tmpRect.left, -tmpRect.top ) + 1;
482 if (TWEAK_WineLook > WIN31_LOOK) {
483 SetRect(&tmpRect, 0, 0, 0, 0);
484 NC_AdjustRectInner95 (&tmpRect, style, exStyle);
485 winRect->left -= tmpRect.left;
486 winRect->top -= tmpRect.top;
487 winRect->right -= tmpRect.right;
488 winRect->bottom -= tmpRect.bottom;
491 if (winRect->top > winRect->bottom)
492 winRect->bottom = winRect->top;
494 if (winRect->left > winRect->right)
495 winRect->right = winRect->left;
501 /***********************************************************************
504 * Get the 'inside' rectangle of a window, i.e. the whole window rectangle
505 * but without the borders (if any).
506 * The rectangle is in window coordinates (for drawing with GetWindowDC()).
508 void NC_GetInsideRect( HWND hwnd, RECT *rect )
510 WND * wndPtr = WIN_FindWndPtr( hwnd );
512 rect->top = rect->left = 0;
513 rect->right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
514 rect->bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
516 if (wndPtr->dwStyle & WS_ICONIC) goto END;
518 /* Remove frame from rectangle */
519 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
521 InflateRect( rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) );
523 else if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
525 InflateRect( rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
526 /* FIXME: this isn't in NC_AdjustRect? why not? */
527 if ((TWEAK_WineLook == WIN31_LOOK) && (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME))
528 InflateRect( rect, -1, 0 );
530 else if (HAS_THINFRAME( wndPtr->dwStyle ))
532 InflateRect( rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER) );
535 /* We have additional border information if the window
536 * is a child (but not an MDI child) */
537 if (TWEAK_WineLook != WIN31_LOOK)
539 if ( (wndPtr->dwStyle & WS_CHILD) &&
540 ( (wndPtr->dwExStyle & WS_EX_MDICHILD) == 0 ) )
542 if (wndPtr->dwExStyle & WS_EX_CLIENTEDGE)
543 InflateRect (rect, -GetSystemMetrics(SM_CXEDGE), -GetSystemMetrics(SM_CYEDGE));
544 if (wndPtr->dwExStyle & WS_EX_STATICEDGE)
545 InflateRect (rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
550 WIN_ReleaseWndPtr(wndPtr);
555 /***********************************************************************
558 * Handle a WM_NCHITTEST message. Called from NC_HandleNCHitTest().
561 static LONG NC_DoNCHitTest (WND *wndPtr, POINT pt )
565 TRACE("hwnd=%04x pt=%ld,%ld\n", wndPtr->hwndSelf, pt.x, pt.y );
567 GetWindowRect(wndPtr->hwndSelf, &rect );
568 if (!PtInRect( &rect, pt )) return HTNOWHERE;
570 if (wndPtr->dwStyle & WS_MINIMIZE) return HTCAPTION;
573 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
575 InflateRect( &rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) );
576 if (!PtInRect( &rect, pt ))
578 /* Check top sizing border */
581 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTTOPLEFT;
582 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTTOPRIGHT;
585 /* Check bottom sizing border */
586 if (pt.y >= rect.bottom)
588 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMLEFT;
589 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMRIGHT;
592 /* Check left sizing border */
593 if (pt.x < rect.left)
595 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPLEFT;
596 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMLEFT;
599 /* Check right sizing border */
600 if (pt.x >= rect.right)
602 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPRIGHT;
603 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMRIGHT;
608 else /* No thick frame */
610 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
611 InflateRect(&rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
612 else if (HAS_THINFRAME( wndPtr->dwStyle ))
613 InflateRect(&rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
614 if (!PtInRect( &rect, pt )) return HTBORDER;
619 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
621 rect.top += GetSystemMetrics(SM_CYCAPTION) - GetSystemMetrics(SM_CYBORDER);
622 if (!PtInRect( &rect, pt ))
624 /* Check system menu */
625 if ((wndPtr->dwStyle & WS_SYSMENU) && !(wndPtr->dwExStyle & WS_EX_TOOLWINDOW))
626 rect.left += GetSystemMetrics(SM_CXSIZE);
627 if (pt.x <= rect.left) return HTSYSMENU;
629 /* Check maximize box */
630 if (wndPtr->dwStyle & WS_MAXIMIZEBOX)
631 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
633 if (pt.x >= rect.right) return HTMAXBUTTON;
634 /* Check minimize box */
635 if (wndPtr->dwStyle & WS_MINIMIZEBOX)
636 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
637 if (pt.x >= rect.right) return HTMINBUTTON;
642 /* Check client area */
644 ScreenToClient( wndPtr->hwndSelf, &pt );
645 GetClientRect( wndPtr->hwndSelf, &rect );
646 if (PtInRect( &rect, pt )) return HTCLIENT;
648 /* Check vertical scroll bar */
650 if (wndPtr->dwStyle & WS_VSCROLL)
652 rect.right += GetSystemMetrics(SM_CXVSCROLL);
653 if (PtInRect( &rect, pt )) return HTVSCROLL;
656 /* Check horizontal scroll bar */
658 if (wndPtr->dwStyle & WS_HSCROLL)
660 rect.bottom += GetSystemMetrics(SM_CYHSCROLL);
661 if (PtInRect( &rect, pt ))
664 if ((wndPtr->dwStyle & WS_VSCROLL) &&
665 (pt.x >= rect.right - GetSystemMetrics(SM_CXVSCROLL)))
673 if (HAS_MENU(wndPtr))
675 if ((pt.y < 0) && (pt.x >= 0) && (pt.x < rect.right))
679 /* Has to return HTNOWHERE if nothing was found
680 Could happen when a window has a customized non client area */
685 /***********************************************************************
688 * Handle a WM_NCHITTEST message. Called from NC_HandleNCHitTest().
690 * FIXME: Just a modified copy of the Win 3.1 version.
693 static LONG NC_DoNCHitTest95 (WND *wndPtr, POINT pt )
697 TRACE("hwnd=%04x pt=%ld,%ld\n", wndPtr->hwndSelf, pt.x, pt.y );
699 GetWindowRect(wndPtr->hwndSelf, &rect );
700 if (!PtInRect( &rect, pt )) return HTNOWHERE;
702 if (wndPtr->dwStyle & WS_MINIMIZE) return HTCAPTION;
705 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
707 InflateRect( &rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) );
708 if (!PtInRect( &rect, pt ))
710 /* Check top sizing border */
713 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTTOPLEFT;
714 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTTOPRIGHT;
717 /* Check bottom sizing border */
718 if (pt.y >= rect.bottom)
720 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMLEFT;
721 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMRIGHT;
724 /* Check left sizing border */
725 if (pt.x < rect.left)
727 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPLEFT;
728 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMLEFT;
731 /* Check right sizing border */
732 if (pt.x >= rect.right)
734 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPRIGHT;
735 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMRIGHT;
740 else /* No thick frame */
742 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
743 InflateRect(&rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
744 else if (HAS_THINFRAME( wndPtr->dwStyle ))
745 InflateRect(&rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
746 if (!PtInRect( &rect, pt )) return HTBORDER;
751 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
753 if (wndPtr->dwExStyle & WS_EX_TOOLWINDOW)
754 rect.top += GetSystemMetrics(SM_CYSMCAPTION) - 1;
756 rect.top += GetSystemMetrics(SM_CYCAPTION) - 1;
757 if (!PtInRect( &rect, pt ))
759 /* Check system menu */
760 if ((wndPtr->dwStyle & WS_SYSMENU) && !(wndPtr->dwExStyle & WS_EX_TOOLWINDOW))
762 if (NC_IconForWindow(wndPtr->hwndSelf))
763 rect.left += GetSystemMetrics(SM_CYCAPTION) - 1;
765 if (pt.x < rect.left) return HTSYSMENU;
767 /* Check close button */
768 if (wndPtr->dwStyle & WS_SYSMENU)
769 rect.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
770 if (pt.x > rect.right) return HTCLOSE;
772 /* Check maximize box */
773 /* In win95 there is automatically a Maximize button when there is a minimize one*/
774 if ((wndPtr->dwStyle & WS_MAXIMIZEBOX)|| (wndPtr->dwStyle & WS_MINIMIZEBOX))
775 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
776 if (pt.x > rect.right) return HTMAXBUTTON;
778 /* Check minimize box */
779 /* In win95 there is automatically a Maximize button when there is a Maximize one*/
780 if ((wndPtr->dwStyle & WS_MINIMIZEBOX)||(wndPtr->dwStyle & WS_MAXIMIZEBOX))
781 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
783 if (pt.x > rect.right) return HTMINBUTTON;
788 /* Check client area */
790 ScreenToClient( wndPtr->hwndSelf, &pt );
791 GetClientRect( wndPtr->hwndSelf, &rect );
792 if (PtInRect( &rect, pt )) return HTCLIENT;
794 /* Check vertical scroll bar */
796 if (wndPtr->dwStyle & WS_VSCROLL)
798 rect.right += GetSystemMetrics(SM_CXVSCROLL);
799 if (PtInRect( &rect, pt )) return HTVSCROLL;
802 /* Check horizontal scroll bar */
804 if (wndPtr->dwStyle & WS_HSCROLL)
806 rect.bottom += GetSystemMetrics(SM_CYHSCROLL);
807 if (PtInRect( &rect, pt ))
810 if ((wndPtr->dwStyle & WS_VSCROLL) &&
811 (pt.x >= rect.right - GetSystemMetrics(SM_CXVSCROLL)))
819 if (HAS_MENU(wndPtr))
821 if ((pt.y < 0) && (pt.x >= 0) && (pt.x < rect.right))
825 /* Has to return HTNOWHERE if nothing was found
826 Could happen when a window has a customized non client area */
831 /***********************************************************************
834 * Handle a WM_NCHITTEST message. Called from DefWindowProc().
836 LONG NC_HandleNCHitTest (HWND hwnd , POINT pt)
839 WND *wndPtr = WIN_FindWndPtr (hwnd);
844 if (TWEAK_WineLook == WIN31_LOOK)
845 retvalue = NC_DoNCHitTest (wndPtr, pt);
847 retvalue = NC_DoNCHitTest95 (wndPtr, pt);
848 WIN_ReleaseWndPtr(wndPtr);
853 /***********************************************************************
856 void NC_DrawSysButton( HWND hwnd, HDC hdc, BOOL down )
862 NC_GetInsideRect( hwnd, &rect );
863 hdcMem = CreateCompatibleDC( hdc );
864 hbitmap = SelectObject( hdcMem, hbitmapClose );
865 BitBlt(hdc, rect.left, rect.top, GetSystemMetrics(SM_CXSIZE), GetSystemMetrics(SM_CYSIZE),
866 hdcMem, (GetWindowLongA(hwnd,GWL_STYLE) & WS_CHILD) ? GetSystemMetrics(SM_CXSIZE) : 0, 0,
867 down ? NOTSRCCOPY : SRCCOPY );
868 SelectObject( hdcMem, hbitmap );
873 /***********************************************************************
876 static void NC_DrawMaxButton( HWND hwnd, HDC16 hdc, BOOL down )
879 UINT flags = IsZoomed(hwnd) ? DFCS_CAPTIONRESTORE : DFCS_CAPTIONMAX;
881 NC_GetInsideRect( hwnd, &rect );
882 rect.left = rect.right - GetSystemMetrics(SM_CXSIZE) + 1;
883 rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) - 1;
886 if (down) flags |= DFCS_PUSHED;
887 DrawFrameControl( hdc, &rect, DFC_CAPTION, flags );
891 /***********************************************************************
894 static void NC_DrawMinButton( HWND hwnd, HDC16 hdc, BOOL down )
897 UINT flags = DFCS_CAPTIONMIN;
898 DWORD style = GetWindowLongA( hwnd, GWL_STYLE );
900 NC_GetInsideRect( hwnd, &rect );
901 if (style & (WS_MAXIMIZEBOX|WS_MINIMIZEBOX))
902 rect.right -= GetSystemMetrics(SM_CXSIZE) - 2;
903 rect.left = rect.right - GetSystemMetrics(SM_CXSIZE) + 1;
904 rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) - 1;
907 if (down) flags |= DFCS_PUSHED;
908 DrawFrameControl( hdc, &rect, DFC_CAPTION, flags );
912 /******************************************************************************
914 * void NC_DrawSysButton95(
919 * Draws the Win95 system icon.
922 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
923 * Original implementation from NC_DrawSysButton source.
924 * 11-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
927 *****************************************************************************/
930 NC_DrawSysButton95 (HWND hwnd, HDC hdc, BOOL down)
932 HICON hIcon = NC_IconForWindow( hwnd );
937 NC_GetInsideRect( hwnd, &rect );
938 DrawIconEx (hdc, rect.left + 2, rect.top + 2, hIcon,
939 GetSystemMetrics(SM_CXSMICON),
940 GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL);
946 /******************************************************************************
948 * void NC_DrawCloseButton95(
954 * Draws the Win95 close button.
956 * If bGrayed is true, then draw a disabled Close button
959 * 11-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
960 * Original implementation from NC_DrawSysButton95 source.
962 *****************************************************************************/
964 static void NC_DrawCloseButton95 (HWND hwnd, HDC hdc, BOOL down, BOOL bGrayed)
968 NC_GetInsideRect( hwnd, &rect );
970 /* A tool window has a smaller Close button */
971 if (GetWindowLongA( hwnd, GWL_EXSTYLE ) & WS_EX_TOOLWINDOW)
973 INT iBmpHeight = 11; /* Windows does not use SM_CXSMSIZE and SM_CYSMSIZE */
974 INT iBmpWidth = 11; /* it uses 11x11 for the close button in tool window */
975 INT iCaptionHeight = GetSystemMetrics(SM_CYSMCAPTION);
977 rect.top = rect.top + (iCaptionHeight - 1 - iBmpHeight) / 2;
978 rect.left = rect.right - (iCaptionHeight + 1 + iBmpWidth) / 2;
979 rect.bottom = rect.top + iBmpHeight;
980 rect.right = rect.left + iBmpWidth;
984 rect.left = rect.right - GetSystemMetrics(SM_CXSIZE) - 1;
985 rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) - 1;
989 DrawFrameControl( hdc, &rect, DFC_CAPTION,
991 (down ? DFCS_PUSHED : 0) |
992 (bGrayed ? DFCS_INACTIVE : 0)) );
995 /******************************************************************************
998 * Draws the maximize button for Win95 style windows.
999 * If bGrayed is true, then draw a disabled Maximize button
1001 static void NC_DrawMaxButton95(HWND hwnd,HDC16 hdc,BOOL down, BOOL bGrayed)
1004 UINT flags = IsZoomed(hwnd) ? DFCS_CAPTIONRESTORE : DFCS_CAPTIONMAX;
1006 NC_GetInsideRect( hwnd, &rect );
1007 if (GetWindowLongA( hwnd, GWL_STYLE) & WS_SYSMENU)
1008 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1009 rect.left = rect.right - GetSystemMetrics(SM_CXSIZE);
1010 rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) - 1;
1013 if (down) flags |= DFCS_PUSHED;
1014 if (bGrayed) flags |= DFCS_INACTIVE;
1015 DrawFrameControl( hdc, &rect, DFC_CAPTION, flags );
1018 /******************************************************************************
1019 * NC_DrawMinButton95
1021 * Draws the minimize button for Win95 style windows.
1022 * If bGrayed is true, then draw a disabled Minimize button
1024 static void NC_DrawMinButton95(HWND hwnd,HDC16 hdc,BOOL down, BOOL bGrayed)
1027 UINT flags = DFCS_CAPTIONMIN;
1028 DWORD style = GetWindowLongA( hwnd, GWL_STYLE );
1030 NC_GetInsideRect( hwnd, &rect );
1031 if (style & WS_SYSMENU)
1032 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1033 if (style & (WS_MAXIMIZEBOX|WS_MINIMIZEBOX))
1034 rect.right -= GetSystemMetrics(SM_CXSIZE) - 2;
1035 rect.left = rect.right - GetSystemMetrics(SM_CXSIZE);
1036 rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) - 1;
1039 if (down) flags |= DFCS_PUSHED;
1040 if (bGrayed) flags |= DFCS_INACTIVE;
1041 DrawFrameControl( hdc, &rect, DFC_CAPTION, flags );
1044 /***********************************************************************
1047 * Draw a window frame inside the given rectangle, and update the rectangle.
1048 * The correct pen for the frame must be selected in the DC.
1050 static void NC_DrawFrame( HDC hdc, RECT *rect, BOOL dlgFrame,
1055 if (TWEAK_WineLook != WIN31_LOOK)
1056 ERR("Called in Win95 mode. Aiee! Please report this.\n" );
1060 width = GetSystemMetrics(SM_CXDLGFRAME) - 1;
1061 height = GetSystemMetrics(SM_CYDLGFRAME) - 1;
1062 SelectObject( hdc, GetSysColorBrush(active ? COLOR_ACTIVECAPTION :
1063 COLOR_INACTIVECAPTION) );
1067 width = GetSystemMetrics(SM_CXFRAME) - 2;
1068 height = GetSystemMetrics(SM_CYFRAME) - 2;
1069 SelectObject( hdc, GetSysColorBrush(active ? COLOR_ACTIVEBORDER :
1070 COLOR_INACTIVEBORDER) );
1074 PatBlt( hdc, rect->left, rect->top,
1075 rect->right - rect->left, height, PATCOPY );
1076 PatBlt( hdc, rect->left, rect->top,
1077 width, rect->bottom - rect->top, PATCOPY );
1078 PatBlt( hdc, rect->left, rect->bottom - 1,
1079 rect->right - rect->left, -height, PATCOPY );
1080 PatBlt( hdc, rect->right - 1, rect->top,
1081 -width, rect->bottom - rect->top, PATCOPY );
1085 InflateRect( rect, -width, -height );
1089 INT decYOff = GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXSIZE) - 1;
1090 INT decXOff = GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYSIZE) - 1;
1092 /* Draw inner rectangle */
1094 SelectObject( hdc, GetStockObject(NULL_BRUSH) );
1095 Rectangle( hdc, rect->left + width, rect->top + height,
1096 rect->right - width , rect->bottom - height );
1098 /* Draw the decorations */
1100 MoveToEx( hdc, rect->left, rect->top + decYOff, NULL );
1101 LineTo( hdc, rect->left + width, rect->top + decYOff );
1102 MoveToEx( hdc, rect->right - 1, rect->top + decYOff, NULL );
1103 LineTo( hdc, rect->right - width - 1, rect->top + decYOff );
1104 MoveToEx( hdc, rect->left, rect->bottom - decYOff, NULL );
1105 LineTo( hdc, rect->left + width, rect->bottom - decYOff );
1106 MoveToEx( hdc, rect->right - 1, rect->bottom - decYOff, NULL );
1107 LineTo( hdc, rect->right - width - 1, rect->bottom - decYOff );
1109 MoveToEx( hdc, rect->left + decXOff, rect->top, NULL );
1110 LineTo( hdc, rect->left + decXOff, rect->top + height);
1111 MoveToEx( hdc, rect->left + decXOff, rect->bottom - 1, NULL );
1112 LineTo( hdc, rect->left + decXOff, rect->bottom - height - 1 );
1113 MoveToEx( hdc, rect->right - decXOff, rect->top, NULL );
1114 LineTo( hdc, rect->right - decXOff, rect->top + height );
1115 MoveToEx( hdc, rect->right - decXOff, rect->bottom - 1, NULL );
1116 LineTo( hdc, rect->right - decXOff, rect->bottom - height - 1 );
1118 InflateRect( rect, -width - 1, -height - 1 );
1123 /******************************************************************************
1125 * void NC_DrawFrame95(
1132 * Draw a window frame inside the given rectangle, and update the rectangle.
1135 * Many. First, just what IS a frame in Win95? Note that the 3D look
1136 * on the outer edge is handled by NC_DoNCPaint95. As is the inner
1137 * edge. The inner rectangle just inside the frame is handled by the
1140 * In short, for most people, this function should be a nop (unless
1141 * you LIKE thick borders in Win95/NT4.0 -- I've been working with
1142 * them lately, but just to get this code right). Even so, it doesn't
1143 * appear to be so. It's being worked on...
1146 * 06-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1147 * Original implementation (based on NC_DrawFrame)
1148 * 02-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1150 * 29-Jun-1999 Ove Kåven (ovek@arcticnet.no)
1151 * Fixed a fix or something.
1153 *****************************************************************************/
1155 static void NC_DrawFrame95(
1164 /* Firstly the "thick" frame */
1165 if (style & WS_THICKFRAME)
1167 width = GetSystemMetrics(SM_CXFRAME) - GetSystemMetrics(SM_CXDLGFRAME);
1168 height = GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYDLGFRAME);
1170 SelectObject( hdc, GetSysColorBrush(active ? COLOR_ACTIVEBORDER :
1171 COLOR_INACTIVEBORDER) );
1173 PatBlt( hdc, rect->left, rect->top,
1174 rect->right - rect->left, height, PATCOPY );
1175 PatBlt( hdc, rect->left, rect->top,
1176 width, rect->bottom - rect->top, PATCOPY );
1177 PatBlt( hdc, rect->left, rect->bottom - 1,
1178 rect->right - rect->left, -height, PATCOPY );
1179 PatBlt( hdc, rect->right - 1, rect->top,
1180 -width, rect->bottom - rect->top, PATCOPY );
1182 InflateRect( rect, -width, -height );
1185 /* Now the other bit of the frame */
1186 if ((style & (WS_BORDER|WS_DLGFRAME)) ||
1187 (exStyle & WS_EX_DLGMODALFRAME))
1189 width = GetSystemMetrics(SM_CXDLGFRAME) - GetSystemMetrics(SM_CXEDGE);
1190 height = GetSystemMetrics(SM_CYDLGFRAME) - GetSystemMetrics(SM_CYEDGE);
1191 /* This should give a value of 1 that should also work for a border */
1193 SelectObject( hdc, GetSysColorBrush(
1194 (exStyle & (WS_EX_DLGMODALFRAME|WS_EX_CLIENTEDGE)) ?
1196 (exStyle & WS_EX_STATICEDGE) ?
1198 (style & (WS_DLGFRAME|WS_THICKFRAME)) ?
1201 COLOR_WINDOWFRAME));
1204 PatBlt( hdc, rect->left, rect->top,
1205 rect->right - rect->left, height, PATCOPY );
1206 PatBlt( hdc, rect->left, rect->top,
1207 width, rect->bottom - rect->top, PATCOPY );
1208 PatBlt( hdc, rect->left, rect->bottom - 1,
1209 rect->right - rect->left, -height, PATCOPY );
1210 PatBlt( hdc, rect->right - 1, rect->top,
1211 -width, rect->bottom - rect->top, PATCOPY );
1213 InflateRect( rect, -width, -height );
1218 /***********************************************************************
1221 * Draw the window caption.
1222 * The correct pen for the window frame must be selected in the DC.
1224 static void NC_DrawCaption( HDC hdc, RECT *rect, HWND hwnd,
1225 DWORD style, BOOL active )
1232 if (!(hbitmapClose = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_OLD_CLOSE) ))) return;
1235 if (GetWindowLongA( hwnd, GWL_EXSTYLE) & WS_EX_DLGMODALFRAME)
1237 HBRUSH hbrushOld = SelectObject(hdc, GetSysColorBrush(COLOR_WINDOW) );
1238 PatBlt( hdc, r.left, r.top, 1, r.bottom-r.top+1,PATCOPY );
1239 PatBlt( hdc, r.right-1, r.top, 1, r.bottom-r.top+1, PATCOPY );
1240 PatBlt( hdc, r.left, r.top-1, r.right-r.left, 1, PATCOPY );
1243 SelectObject( hdc, hbrushOld );
1245 MoveToEx( hdc, r.left, r.bottom, NULL );
1246 LineTo( hdc, r.right, r.bottom );
1248 if (style & WS_SYSMENU)
1250 NC_DrawSysButton( hwnd, hdc, FALSE );
1251 r.left += GetSystemMetrics(SM_CXSIZE) + 1;
1252 MoveToEx( hdc, r.left - 1, r.top, NULL );
1253 LineTo( hdc, r.left - 1, r.bottom );
1255 FillRect( hdc, &r, GetSysColorBrush(active ? COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION) );
1256 if (style & WS_MAXIMIZEBOX)
1258 NC_DrawMaxButton( hwnd, hdc, FALSE );
1259 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1261 if (style & WS_MINIMIZEBOX)
1263 NC_DrawMinButton( hwnd, hdc, FALSE );
1264 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1267 if (GetWindowTextA( hwnd, buffer, sizeof(buffer) ))
1269 if (active) SetTextColor( hdc, GetSysColor( COLOR_CAPTIONTEXT ) );
1270 else SetTextColor( hdc, GetSysColor( COLOR_INACTIVECAPTIONTEXT ) );
1271 SetBkMode( hdc, TRANSPARENT );
1272 DrawTextA( hdc, buffer, -1, &r,
1273 DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_NOPREFIX );
1278 /******************************************************************************
1287 * Draw the window caption for Win95 style windows.
1288 * The correct pen for the window frame must be selected in the DC.
1291 * Hey, a function that finally works! Well, almost.
1292 * It's being worked on.
1295 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1296 * Original implementation.
1297 * 02-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1300 *****************************************************************************/
1302 static void NC_DrawCaption95(
1315 hPrevPen = SelectObject( hdc, GetSysColorPen(
1316 ((exStyle & (WS_EX_STATICEDGE|WS_EX_CLIENTEDGE|
1317 WS_EX_DLGMODALFRAME)) == WS_EX_STATICEDGE) ?
1318 COLOR_WINDOWFRAME : COLOR_3DFACE) );
1319 MoveToEx( hdc, r.left, r.bottom - 1, NULL );
1320 LineTo( hdc, r.right, r.bottom - 1 );
1321 SelectObject( hdc, hPrevPen );
1324 FillRect( hdc, &r, GetSysColorBrush(active ? COLOR_ACTIVECAPTION :
1325 COLOR_INACTIVECAPTION) );
1327 if ((style & WS_SYSMENU) && !(exStyle & WS_EX_TOOLWINDOW)) {
1328 if (NC_DrawSysButton95 (hwnd, hdc, FALSE))
1329 r.left += GetSystemMetrics(SM_CYCAPTION) - 1;
1332 if (style & WS_SYSMENU)
1336 /* Go get the sysmenu */
1337 hSysMenu = GetSystemMenu(hwnd, FALSE);
1338 state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
1340 /* Draw a grayed close button if disabled and a normal one if SC_CLOSE is not there */
1341 NC_DrawCloseButton95 (hwnd, hdc, FALSE,
1342 ((((state & MF_DISABLED) || (state & MF_GRAYED))) && (state != 0xFFFFFFFF)));
1343 r.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
1345 if ((style & WS_MAXIMIZEBOX) || (style & WS_MINIMIZEBOX))
1347 /* In win95 the two buttons are always there */
1348 /* But if the menu item is not in the menu they're disabled*/
1350 NC_DrawMaxButton95( hwnd, hdc, FALSE, (!(style & WS_MAXIMIZEBOX)));
1351 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1353 NC_DrawMinButton95( hwnd, hdc, FALSE, (!(style & WS_MINIMIZEBOX)));
1354 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1358 if (GetWindowTextA( hwnd, buffer, sizeof(buffer) )) {
1359 NONCLIENTMETRICSA nclm;
1360 HFONT hFont, hOldFont;
1361 nclm.cbSize = sizeof(NONCLIENTMETRICSA);
1362 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
1363 if (exStyle & WS_EX_TOOLWINDOW)
1364 hFont = CreateFontIndirectA (&nclm.lfSmCaptionFont);
1366 hFont = CreateFontIndirectA (&nclm.lfCaptionFont);
1367 hOldFont = SelectObject (hdc, hFont);
1368 if (active) SetTextColor( hdc, GetSysColor( COLOR_CAPTIONTEXT ) );
1369 else SetTextColor( hdc, GetSysColor( COLOR_INACTIVECAPTIONTEXT ) );
1370 SetBkMode( hdc, TRANSPARENT );
1372 DrawTextA( hdc, buffer, -1, &r,
1373 DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT );
1374 DeleteObject (SelectObject (hdc, hOldFont));
1380 /***********************************************************************
1383 * Paint the non-client area. clip is currently unused.
1385 static void NC_DoNCPaint( HWND hwnd, HRGN clip, BOOL suppress_menupaint )
1391 DWORD dwStyle, dwExStyle;
1393 RECT rectClient, rectWindow;
1396 if (!(wndPtr = WIN_GetPtr( hwnd )) || wndPtr == WND_OTHER_PROCESS) return;
1397 has_menu = HAS_MENU(wndPtr);
1398 dwStyle = wndPtr->dwStyle;
1399 dwExStyle = wndPtr->dwExStyle;
1400 flags = wndPtr->flags;
1401 rectClient = wndPtr->rectClient;
1402 rectWindow = wndPtr->rectWindow;
1403 WIN_ReleasePtr( wndPtr );
1405 if ( dwStyle & WS_MINIMIZE ||
1406 !WIN_IsWindowDrawable( hwnd, 0 )) return; /* Nothing to do */
1408 active = flags & WIN_NCACTIVATED;
1410 TRACE("%04x %d\n", hwnd, active );
1412 if (!(hdc = GetDCEx( hwnd, (clip > 1) ? clip : 0, DCX_USESTYLE | DCX_WINDOW |
1413 ((clip > 1) ? (DCX_INTERSECTRGN | DCX_KEEPCLIPRGN): 0) ))) return;
1415 if (ExcludeVisRect16( hdc, rectClient.left-rectWindow.left,
1416 rectClient.top-rectWindow.top,
1417 rectClient.right-rectWindow.left,
1418 rectClient.bottom-rectWindow.top )
1421 ReleaseDC( hwnd, hdc );
1425 rect.top = rect.left = 0;
1426 rect.right = rectWindow.right - rectWindow.left;
1427 rect.bottom = rectWindow.bottom - rectWindow.top;
1429 SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
1431 if (HAS_ANYFRAME( dwStyle, dwExStyle ))
1433 SelectObject( hdc, GetStockObject(NULL_BRUSH) );
1434 Rectangle( hdc, 0, 0, rect.right, rect.bottom );
1435 InflateRect( &rect, -1, -1 );
1438 if (HAS_THICKFRAME( dwStyle, dwExStyle ))
1439 NC_DrawFrame(hdc, &rect, FALSE, active );
1440 else if (HAS_DLGFRAME( dwStyle, dwExStyle ))
1441 NC_DrawFrame( hdc, &rect, TRUE, active );
1443 if ((dwStyle & WS_CAPTION) == WS_CAPTION)
1446 r.bottom = rect.top + GetSystemMetrics(SM_CYSIZE);
1447 rect.top += GetSystemMetrics(SM_CYSIZE) + GetSystemMetrics(SM_CYBORDER);
1448 NC_DrawCaption( hdc, &r, hwnd, dwStyle, active );
1454 r.bottom = rect.top + GetSystemMetrics(SM_CYMENU); /* default height */
1455 rect.top += MENU_DrawMenuBar( hdc, &r, hwnd, suppress_menupaint );
1458 /* Draw the scroll-bars */
1460 if (dwStyle & WS_VSCROLL)
1461 SCROLL_DrawScrollBar( hwnd, hdc, SB_VERT, TRUE, TRUE );
1462 if (dwStyle & WS_HSCROLL)
1463 SCROLL_DrawScrollBar( hwnd, hdc, SB_HORZ, TRUE, TRUE );
1465 /* Draw the "size-box" */
1467 if ((dwStyle & WS_VSCROLL) && (dwStyle & WS_HSCROLL))
1470 r.left = r.right - GetSystemMetrics(SM_CXVSCROLL) + 1;
1471 r.top = r.bottom - GetSystemMetrics(SM_CYHSCROLL) + 1;
1472 if(wndPtr->dwStyle & WS_BORDER) {
1476 FillRect( hdc, &r, GetSysColorBrush(COLOR_SCROLLBAR) );
1479 ReleaseDC( hwnd, hdc );
1483 /******************************************************************************
1485 * void NC_DoNCPaint95(
1488 * BOOL suppress_menupaint )
1490 * Paint the non-client area for Win95 windows. The clip region is
1491 * currently ignored.
1494 * grep -E -A10 -B5 \(95\)\|\(Bugs\)\|\(FIXME\) windows/nonclient.c \
1495 * misc/tweak.c controls/menu.c # :-)
1498 * 03-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1499 * Original implementation
1500 * 10-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1502 * 29-Jun-1999 Ove Kåven (ovek@arcticnet.no)
1503 * Streamlined window style checks.
1505 *****************************************************************************/
1507 static void NC_DoNCPaint95(
1510 BOOL suppress_menupaint )
1513 RECT rfuzz, rect, rectClip;
1516 DWORD dwStyle, dwExStyle;
1518 RECT rectClient, rectWindow;
1521 if (!(wndPtr = WIN_GetPtr( hwnd )) || wndPtr == WND_OTHER_PROCESS) return;
1522 has_menu = HAS_MENU(wndPtr);
1523 dwStyle = wndPtr->dwStyle;
1524 dwExStyle = wndPtr->dwExStyle;
1525 flags = wndPtr->flags;
1526 rectClient = wndPtr->rectClient;
1527 rectWindow = wndPtr->rectWindow;
1528 WIN_ReleasePtr( wndPtr );
1530 if ( dwStyle & WS_MINIMIZE ||
1531 !WIN_IsWindowDrawable( hwnd, 0 )) return; /* Nothing to do */
1533 active = flags & WIN_NCACTIVATED;
1535 TRACE("%04x %d\n", hwnd, active );
1537 /* MSDN docs are pretty idiotic here, they say app CAN use clipRgn in
1538 the call to GetDCEx implying that it is allowed not to use it either.
1539 However, the suggested GetDCEx( , DCX_WINDOW | DCX_INTERSECTRGN)
1540 will cause clipRgn to be deleted after ReleaseDC().
1541 Now, how is the "system" supposed to tell what happened?
1544 if (!(hdc = GetDCEx( hwnd, (clip > 1) ? clip : 0, DCX_USESTYLE | DCX_WINDOW |
1545 ((clip > 1) ?(DCX_INTERSECTRGN | DCX_KEEPCLIPRGN) : 0) ))) return;
1548 if (ExcludeVisRect16( hdc, rectClient.left-rectWindow.left,
1549 rectClient.top-rectWindow.top,
1550 rectClient.right-rectWindow.left,
1551 rectClient.bottom-rectWindow.top )
1554 ReleaseDC( hwnd, hdc );
1558 rect.top = rect.left = 0;
1559 rect.right = rectWindow.right - rectWindow.left;
1560 rect.bottom = rectWindow.bottom - rectWindow.top;
1563 GetRgnBox( clip, &rectClip );
1570 SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
1572 if (HAS_STATICOUTERFRAME(dwStyle, dwExStyle)) {
1573 DrawEdge (hdc, &rect, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
1575 else if (HAS_BIGFRAME( dwStyle, dwExStyle)) {
1576 DrawEdge (hdc, &rect, EDGE_RAISED, BF_RECT | BF_ADJUST);
1579 NC_DrawFrame95(hdc, &rect, active, dwStyle, dwExStyle );
1581 if ((dwStyle & WS_CAPTION) == WS_CAPTION)
1584 if (dwExStyle & WS_EX_TOOLWINDOW) {
1585 r.bottom = rect.top + GetSystemMetrics(SM_CYSMCAPTION);
1586 rect.top += GetSystemMetrics(SM_CYSMCAPTION);
1589 r.bottom = rect.top + GetSystemMetrics(SM_CYCAPTION);
1590 rect.top += GetSystemMetrics(SM_CYCAPTION);
1592 if( !clip || IntersectRect( &rfuzz, &r, &rectClip ) )
1593 NC_DrawCaption95 (hdc, &r, hwnd, dwStyle,
1600 r.bottom = rect.top + GetSystemMetrics(SM_CYMENU);
1602 TRACE("Calling DrawMenuBar with rect (%d, %d)-(%d, %d)\n",
1603 r.left, r.top, r.right, r.bottom);
1605 rect.top += MENU_DrawMenuBar( hdc, &r, hwnd, suppress_menupaint ) + 1;
1608 TRACE("After MenuBar, rect is (%d, %d)-(%d, %d).\n",
1609 rect.left, rect.top, rect.right, rect.bottom );
1611 if (dwExStyle & WS_EX_CLIENTEDGE)
1612 DrawEdge (hdc, &rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
1614 /* Draw the scroll-bars */
1616 if (dwStyle & WS_VSCROLL)
1617 SCROLL_DrawScrollBar( hwnd, hdc, SB_VERT, TRUE, TRUE );
1618 if (dwStyle & WS_HSCROLL)
1619 SCROLL_DrawScrollBar( hwnd, hdc, SB_HORZ, TRUE, TRUE );
1621 /* Draw the "size-box" */
1622 if ((dwStyle & WS_VSCROLL) && (dwStyle & WS_HSCROLL))
1625 r.left = r.right - GetSystemMetrics(SM_CXVSCROLL) + 1;
1626 r.top = r.bottom - GetSystemMetrics(SM_CYHSCROLL) + 1;
1627 FillRect( hdc, &r, GetSysColorBrush(COLOR_SCROLLBAR) );
1630 ReleaseDC( hwnd, hdc );
1636 /***********************************************************************
1639 * Handle a WM_NCPAINT message. Called from DefWindowProc().
1641 LONG NC_HandleNCPaint( HWND hwnd , HRGN clip)
1643 DWORD dwStyle = GetWindowLongW( hwnd, GWL_STYLE );
1645 if( dwStyle & WS_VISIBLE )
1647 if( dwStyle & WS_MINIMIZE )
1648 WINPOS_RedrawIconTitle( hwnd );
1649 else if (TWEAK_WineLook == WIN31_LOOK)
1650 NC_DoNCPaint( hwnd, clip, FALSE );
1652 NC_DoNCPaint95( hwnd, clip, FALSE );
1658 /***********************************************************************
1659 * NC_HandleNCActivate
1661 * Handle a WM_NCACTIVATE message. Called from DefWindowProc().
1663 LONG NC_HandleNCActivate( HWND hwnd, WPARAM wParam )
1665 WND* wndPtr = WIN_FindWndPtr( hwnd );
1667 /* Lotus Notes draws menu descriptions in the caption of its main
1668 * window. When it wants to restore original "system" view, it just
1669 * sends WM_NCACTIVATE message to itself. Any optimizations here in
1670 * attempt to minimize redrawings lead to a not restored caption.
1674 if (wParam) wndPtr->flags |= WIN_NCACTIVATED;
1675 else wndPtr->flags &= ~WIN_NCACTIVATED;
1676 WIN_ReleaseWndPtr(wndPtr);
1678 if (IsIconic(hwnd)) WINPOS_RedrawIconTitle( hwnd );
1679 else if (TWEAK_WineLook == WIN31_LOOK)
1680 NC_DoNCPaint( hwnd, (HRGN)1, FALSE );
1682 NC_DoNCPaint95( hwnd, (HRGN)1, FALSE );
1688 /***********************************************************************
1689 * NC_HandleSetCursor
1691 * Handle a WM_SETCURSOR message. Called from DefWindowProc().
1693 LONG NC_HandleSetCursor( HWND hwnd, WPARAM wParam, LPARAM lParam )
1695 hwnd = WIN_GetFullHandle( (HWND)wParam );
1697 switch(LOWORD(lParam))
1701 WORD msg = HIWORD( lParam );
1702 if ((msg == WM_LBUTTONDOWN) || (msg == WM_MBUTTONDOWN) ||
1703 (msg == WM_RBUTTONDOWN))
1710 HCURSOR hCursor = GetClassLongA(hwnd, GCL_HCURSOR);
1720 return (LONG)SetCursor( LoadCursorA( 0, IDC_SIZEWEA ) );
1724 return (LONG)SetCursor( LoadCursorA( 0, IDC_SIZENSA ) );
1728 return (LONG)SetCursor( LoadCursorA( 0, IDC_SIZENWSEA ) );
1732 return (LONG)SetCursor( LoadCursorA( 0, IDC_SIZENESWA ) );
1735 /* Default cursor: arrow */
1736 return (LONG)SetCursor( LoadCursorA( 0, IDC_ARROWA ) );
1739 /***********************************************************************
1742 void NC_GetSysPopupPos( HWND hwnd, RECT* rect )
1744 if (IsIconic(hwnd)) GetWindowRect( hwnd, rect );
1747 WND *wndPtr = WIN_FindWndPtr( hwnd );
1748 if (!wndPtr) return;
1750 NC_GetInsideRect( hwnd, rect );
1751 OffsetRect( rect, wndPtr->rectWindow.left, wndPtr->rectWindow.top);
1752 if (wndPtr->dwStyle & WS_CHILD)
1753 ClientToScreen( GetParent(hwnd), (POINT *)rect );
1754 if (TWEAK_WineLook == WIN31_LOOK) {
1755 rect->right = rect->left + GetSystemMetrics(SM_CXSIZE);
1756 rect->bottom = rect->top + GetSystemMetrics(SM_CYSIZE);
1759 rect->right = rect->left + GetSystemMetrics(SM_CYCAPTION) - 1;
1760 rect->bottom = rect->top + GetSystemMetrics(SM_CYCAPTION) - 1;
1762 WIN_ReleaseWndPtr( wndPtr );
1766 /***********************************************************************
1767 * NC_TrackMinMaxBox95
1769 * Track a mouse button press on the minimize or maximize box.
1771 * The big difference between 3.1 and 95 is the disabled button state.
1772 * In win95 the system button can be disabled, so it can ignore the mouse
1776 static void NC_TrackMinMaxBox95( HWND hwnd, WORD wParam )
1779 HDC hdc = GetWindowDC( hwnd );
1780 BOOL pressed = TRUE;
1782 DWORD wndStyle = GetWindowLongA( hwnd, GWL_STYLE);
1783 HMENU hSysMenu = GetSystemMenu(hwnd, FALSE);
1785 void (*paintButton)(HWND, HDC16, BOOL, BOOL);
1787 if (wParam == HTMINBUTTON)
1789 /* If the style is not present, do nothing */
1790 if (!(wndStyle & WS_MINIMIZEBOX))
1793 /* Check if the sysmenu item for minimize is there */
1794 state = GetMenuState(hSysMenu, SC_MINIMIZE, MF_BYCOMMAND);
1796 paintButton = &NC_DrawMinButton95;
1800 /* If the style is not present, do nothing */
1801 if (!(wndStyle & WS_MAXIMIZEBOX))
1804 /* Check if the sysmenu item for maximize is there */
1805 state = GetMenuState(hSysMenu, SC_MAXIMIZE, MF_BYCOMMAND);
1807 paintButton = &NC_DrawMaxButton95;
1812 (*paintButton)( hwnd, hdc, TRUE, FALSE);
1816 BOOL oldstate = pressed;
1818 if (!GetMessageW( &msg, 0, WM_MOUSEFIRST, WM_MOUSELAST )) break;
1819 if (CallMsgFilterW( &msg, MSGF_MAX )) continue;
1821 if(msg.message == WM_LBUTTONUP)
1824 if(msg.message != WM_MOUSEMOVE)
1827 pressed = (NC_HandleNCHitTest( hwnd, msg.pt ) == wParam);
1828 if (pressed != oldstate)
1829 (*paintButton)( hwnd, hdc, pressed, FALSE);
1833 (*paintButton)(hwnd, hdc, FALSE, FALSE);
1836 ReleaseDC( hwnd, hdc );
1838 /* If the item minimize or maximize of the sysmenu are not there */
1839 /* or if the style is not present, do nothing */
1840 if ((!pressed) || (state == 0xFFFFFFFF))
1843 if (wParam == HTMINBUTTON)
1844 SendMessageA( hwnd, WM_SYSCOMMAND, SC_MINIMIZE, MAKELONG(msg.pt.x,msg.pt.y) );
1846 SendMessageA( hwnd, WM_SYSCOMMAND,
1847 IsZoomed(hwnd) ? SC_RESTORE:SC_MAXIMIZE, MAKELONG(msg.pt.x,msg.pt.y) );
1850 /***********************************************************************
1853 * Track a mouse button press on the minimize or maximize box.
1855 static void NC_TrackMinMaxBox( HWND hwnd, WORD wParam )
1858 HDC hdc = GetWindowDC( hwnd );
1859 BOOL pressed = TRUE;
1860 void (*paintButton)(HWND, HDC16, BOOL);
1864 if (wParam == HTMINBUTTON)
1865 paintButton = &NC_DrawMinButton;
1867 paintButton = &NC_DrawMaxButton;
1869 (*paintButton)( hwnd, hdc, TRUE);
1873 BOOL oldstate = pressed;
1875 if (!GetMessageW( &msg, 0, WM_MOUSEFIRST, WM_MOUSELAST )) break;
1876 if (CallMsgFilterW( &msg, MSGF_MAX )) continue;
1878 if(msg.message == WM_LBUTTONUP)
1881 if(msg.message != WM_MOUSEMOVE)
1884 pressed = (NC_HandleNCHitTest( hwnd, msg.pt ) == wParam);
1885 if (pressed != oldstate)
1886 (*paintButton)( hwnd, hdc, pressed);
1890 (*paintButton)( hwnd, hdc, FALSE);
1893 ReleaseDC( hwnd, hdc );
1895 if (!pressed) return;
1897 if (wParam == HTMINBUTTON)
1898 SendMessageA( hwnd, WM_SYSCOMMAND, SC_MINIMIZE, MAKELONG(msg.pt.x,msg.pt.y) );
1900 SendMessageA( hwnd, WM_SYSCOMMAND,
1901 IsZoomed(hwnd) ? SC_RESTORE:SC_MAXIMIZE, MAKELONG(msg.pt.x,msg.pt.y) );
1905 /***********************************************************************
1906 * NC_TrackCloseButton95
1908 * Track a mouse button press on the Win95 close button.
1911 NC_TrackCloseButton95 (HWND hwnd, WORD wParam)
1915 BOOL pressed = TRUE;
1916 HMENU hSysMenu = GetSystemMenu(hwnd, FALSE);
1922 state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
1924 /* If the item close of the sysmenu is disabled or not there do nothing */
1925 if((state & MF_DISABLED) || (state & MF_GRAYED) || (state == 0xFFFFFFFF))
1928 hdc = GetWindowDC( hwnd );
1932 NC_DrawCloseButton95 (hwnd, hdc, TRUE, FALSE);
1936 BOOL oldstate = pressed;
1938 if (!GetMessageW( &msg, 0, WM_MOUSEFIRST, WM_MOUSELAST )) break;
1939 if (CallMsgFilterW( &msg, MSGF_MAX )) continue;
1941 if(msg.message == WM_LBUTTONUP)
1944 if(msg.message != WM_MOUSEMOVE)
1947 pressed = (NC_HandleNCHitTest( hwnd, msg.pt ) == wParam);
1948 if (pressed != oldstate)
1949 NC_DrawCloseButton95 (hwnd, hdc, pressed, FALSE);
1953 NC_DrawCloseButton95 (hwnd, hdc, FALSE, FALSE);
1956 ReleaseDC( hwnd, hdc );
1957 if (!pressed) return;
1959 SendMessageA( hwnd, WM_SYSCOMMAND, SC_CLOSE, MAKELONG(msg.pt.x,msg.pt.y) );
1963 /***********************************************************************
1966 * Track a mouse button press on the horizontal or vertical scroll-bar.
1968 static void NC_TrackScrollBar( HWND hwnd, WPARAM wParam, POINT pt )
1972 if ((wParam & 0xfff0) == SC_HSCROLL)
1974 if ((wParam & 0x0f) != HTHSCROLL) return;
1975 scrollbar = SB_HORZ;
1977 else /* SC_VSCROLL */
1979 if ((wParam & 0x0f) != HTVSCROLL) return;
1980 scrollbar = SB_VERT;
1982 SCROLL_TrackScrollBar( hwnd, scrollbar, pt );
1986 /***********************************************************************
1987 * NC_HandleNCLButtonDown
1989 * Handle a WM_NCLBUTTONDOWN message. Called from DefWindowProc().
1991 LONG NC_HandleNCLButtonDown( HWND hwnd, WPARAM wParam, LPARAM lParam )
1993 LONG style = GetWindowLongA( hwnd, GWL_STYLE );
1995 switch(wParam) /* Hit test */
1999 HWND top = GetAncestor( hwnd, GA_ROOT );
2001 if( WINPOS_SetActiveWindow(top, TRUE, TRUE) || (GetActiveWindow() == top) )
2002 SendMessageW( hwnd, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, lParam );
2007 if( style & WS_SYSMENU )
2009 if( !(style & WS_MINIMIZE) )
2011 HDC hDC = GetWindowDC(hwnd);
2012 if (TWEAK_WineLook == WIN31_LOOK)
2013 NC_DrawSysButton( hwnd, hDC, TRUE );
2015 NC_DrawSysButton95( hwnd, hDC, TRUE );
2016 ReleaseDC( hwnd, hDC );
2018 SendMessageW( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU + HTSYSMENU, lParam );
2023 SendMessageW( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU, lParam );
2027 SendMessageW( hwnd, WM_SYSCOMMAND, SC_HSCROLL + HTHSCROLL, lParam );
2031 SendMessageW( hwnd, WM_SYSCOMMAND, SC_VSCROLL + HTVSCROLL, lParam );
2036 if (TWEAK_WineLook == WIN31_LOOK)
2037 NC_TrackMinMaxBox( hwnd, wParam );
2039 NC_TrackMinMaxBox95( hwnd, wParam );
2043 if (TWEAK_WineLook >= WIN95_LOOK)
2044 NC_TrackCloseButton95 (hwnd, wParam);
2055 /* make sure hittest fits into 0xf and doesn't overlap with HTSYSMENU */
2056 SendMessageW( hwnd, WM_SYSCOMMAND, SC_SIZE + wParam - 2, lParam);
2066 /***********************************************************************
2067 * NC_HandleNCLButtonDblClk
2069 * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc().
2071 LONG NC_HandleNCLButtonDblClk( HWND hwnd, WPARAM wParam, LPARAM lParam )
2074 * if this is an icon, send a restore since we are handling
2079 SendMessageW( hwnd, WM_SYSCOMMAND, SC_RESTORE, lParam );
2083 switch(wParam) /* Hit test */
2086 /* stop processing if WS_MAXIMIZEBOX is missing */
2087 if (GetWindowLongA( hwnd, GWL_STYLE ) & WS_MAXIMIZEBOX)
2088 SendMessageW( hwnd, WM_SYSCOMMAND,
2089 IsZoomed(hwnd) ? SC_RESTORE : SC_MAXIMIZE, lParam );
2093 if (!(GetClassLongW(hwnd, GCL_STYLE) & CS_NOCLOSE))
2094 SendMessageW( hwnd, WM_SYSCOMMAND, SC_CLOSE, lParam );
2098 SendMessageW( hwnd, WM_SYSCOMMAND, SC_HSCROLL + HTHSCROLL, lParam );
2102 SendMessageW( hwnd, WM_SYSCOMMAND, SC_VSCROLL + HTVSCROLL, lParam );
2109 /***********************************************************************
2110 * NC_HandleSysCommand
2112 * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
2114 LONG NC_HandleSysCommand( HWND hwnd, WPARAM wParam, LPARAM lParam )
2116 TRACE("Handling WM_SYSCOMMAND %x %lx\n", wParam, lParam );
2118 switch (wParam & 0xfff0)
2122 if (USER_Driver.pSysCommandSizeMove)
2123 USER_Driver.pSysCommandSizeMove( hwnd, wParam );
2127 if (hwnd == GetForegroundWindow())
2128 ShowOwnedPopups(hwnd,FALSE);
2129 ShowWindow( hwnd, SW_MINIMIZE );
2133 if (IsIconic(hwnd) && hwnd == GetForegroundWindow())
2134 ShowOwnedPopups(hwnd,TRUE);
2135 ShowWindow( hwnd, SW_MAXIMIZE );
2139 if (IsIconic(hwnd) && hwnd == GetForegroundWindow())
2140 ShowOwnedPopups(hwnd,TRUE);
2141 ShowWindow( hwnd, SW_RESTORE );
2145 return SendMessageA( hwnd, WM_CLOSE, 0, 0 );
2151 pt.x = SLOWORD(lParam);
2152 pt.y = SHIWORD(lParam);
2153 NC_TrackScrollBar( hwnd, wParam, pt );
2160 pt.x = SLOWORD(lParam);
2161 pt.y = SHIWORD(lParam);
2162 MENU_TrackMouseMenuBar( hwnd, wParam & 0x000F, pt );
2167 MENU_TrackKbdMenuBar( hwnd, wParam, LOWORD(lParam) );
2171 WinExec( "taskman.exe", SW_SHOWNORMAL );
2175 if (wParam == SC_ABOUTWINE)
2177 HMODULE hmodule = LoadLibraryA( "shell32.dll" );
2180 FARPROC aboutproc = GetProcAddress( hmodule, "ShellAboutA" );
2181 if (aboutproc) aboutproc( hwnd, "Wine", WINE_RELEASE_INFO, 0 );
2182 FreeLibrary( hmodule );
2186 if (wParam == SC_PUTMARK)
2187 TRACE_(shell)("Mark requested by user\n");
2194 FIXME("unimplemented!\n");
2200 /*************************************************************
2203 * Stub for the grayed button of the caption
2205 *************************************************************/
2207 BOOL NC_DrawGrayButton(HDC hdc, int x, int y)
2210 HDC hdcMask = CreateCompatibleDC (0);
2213 hMaskBmp = CreateBitmap (12, 10, 1, 1, lpGrayMask);
2218 SelectObject (hdcMask, hMaskBmp);
2220 /* Draw the grayed bitmap using the mask */
2221 hOldBrush = SelectObject (hdc, RGB(128, 128, 128));
2222 BitBlt (hdc, x, y, 12, 10,
2223 hdcMask, 0, 0, 0xB8074A);
2226 SelectObject (hdc, hOldBrush);
2227 DeleteObject(hMaskBmp);