2 * Non-client area window functions
4 * Copyright 1994 Alexandre Julliard
8 #include "wine/winuser16.h"
15 #include "cursoricon.h"
21 #include "nonclient.h"
23 #include "selectors.h"
25 #include "debugtools.h"
31 DECLARE_DEBUG_CHANNEL(nonclient
)
32 DECLARE_DEBUG_CHANNEL(shell
)
34 BOOL
NC_DrawGrayButton(HDC hdc
, int x
, int y
);
36 static HBITMAP16 hbitmapClose
= 0;
37 static HBITMAP16 hbitmapCloseD
= 0;
38 static HBITMAP16 hbitmapMinimize
= 0;
39 static HBITMAP16 hbitmapMinimizeD
= 0;
40 static HBITMAP16 hbitmapMaximize
= 0;
41 static HBITMAP16 hbitmapMaximizeD
= 0;
42 static HBITMAP16 hbitmapRestore
= 0;
43 static HBITMAP16 hbitmapRestoreD
= 0;
45 BYTE lpGrayMask
[] = { 0xAA, 0xA0,
56 #define SC_ABOUTWINE (SC_SCREENSAVE+1)
57 #define SC_PUTMARK (SC_SCREENSAVE+2)
59 /* Some useful macros */
60 #define HAS_DLGFRAME(style,exStyle) \
61 (((exStyle) & WS_EX_DLGMODALFRAME) || \
62 (((style) & WS_DLGFRAME) && !((style) & WS_THICKFRAME)))
64 #define HAS_THICKFRAME(style,exStyle) \
65 (((style) & WS_THICKFRAME) && \
66 !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
68 #define HAS_THINFRAME(style) \
69 (((style) & WS_BORDER) || !((style) & (WS_CHILD | WS_POPUP)))
71 #define HAS_BIGFRAME(style,exStyle) \
72 (((style) & (WS_THICKFRAME | WS_DLGFRAME)) || \
73 ((exStyle) & WS_EX_DLGMODALFRAME))
75 #define HAS_ANYFRAME(style,exStyle) \
76 (((style) & (WS_THICKFRAME | WS_DLGFRAME | WS_BORDER)) || \
77 ((exStyle) & WS_EX_DLGMODALFRAME) || \
78 !((style) & (WS_CHILD | WS_POPUP)))
80 #define HAS_MENU(w) (!((w)->dwStyle & WS_CHILD) && ((w)->wIDmenu != 0))
82 #define ON_LEFT_BORDER(hit) \
83 (((hit) == HTLEFT) || ((hit) == HTTOPLEFT) || ((hit) == HTBOTTOMLEFT))
84 #define ON_RIGHT_BORDER(hit) \
85 (((hit) == HTRIGHT) || ((hit) == HTTOPRIGHT) || ((hit) == HTBOTTOMRIGHT))
86 #define ON_TOP_BORDER(hit) \
87 (((hit) == HTTOP) || ((hit) == HTTOPLEFT) || ((hit) == HTTOPRIGHT))
88 #define ON_BOTTOM_BORDER(hit) \
89 (((hit) == HTBOTTOM) || ((hit) == HTBOTTOMLEFT) || ((hit) == HTBOTTOMRIGHT))
91 /***********************************************************************
92 * WIN_WindowNeedsWMBorder
94 * This method defines the rules for a window to have a WM border,
95 * caption... It is used for consitency purposes.
97 BOOL
WIN_WindowNeedsWMBorder( DWORD style
, DWORD exStyle
)
99 if (!(style
& WS_CHILD
) &&
101 !(exStyle
& WS_EX_TOOLWINDOW
) &&
102 ( ((style
& WS_CAPTION
) == WS_CAPTION
) ||
103 (style
& WS_THICKFRAME
)))
108 /***********************************************************************
111 * Compute the size of the window rectangle from the size of the
114 static void NC_AdjustRect( LPRECT16 rect
, DWORD style
, BOOL menu
,
117 if (TWEAK_WineLook
> WIN31_LOOK
)
118 ERR_(nonclient
)("Called in Win95 mode. Aiee! Please report this.\n" );
120 if(style
& WS_ICONIC
) return;
121 /* Decide if the window will be managed (see CreateWindowEx) */
122 if (!WIN_WindowNeedsWMBorder(style
, exStyle
))
124 if (HAS_THICKFRAME( style
, exStyle
))
125 InflateRect16( rect
, GetSystemMetrics(SM_CXFRAME
), GetSystemMetrics(SM_CYFRAME
) );
127 if (HAS_DLGFRAME( style
, exStyle
))
128 InflateRect16( rect
, GetSystemMetrics(SM_CXDLGFRAME
), GetSystemMetrics(SM_CYDLGFRAME
) );
130 if (HAS_THINFRAME( style
))
131 InflateRect16( rect
, GetSystemMetrics(SM_CXBORDER
), GetSystemMetrics(SM_CYBORDER
));
133 if ((style
& WS_CAPTION
) == WS_CAPTION
)
134 rect
->top
-= GetSystemMetrics(SM_CYCAPTION
) - GetSystemMetrics(SM_CYBORDER
);
136 if (menu
) rect
->top
-= GetSystemMetrics(SM_CYMENU
) + GetSystemMetrics(SM_CYBORDER
);
138 if (style
& WS_VSCROLL
) {
139 rect
->right
+= GetSystemMetrics(SM_CXVSCROLL
) - 1;
140 if(!HAS_ANYFRAME( style
, exStyle
))
144 if (style
& WS_HSCROLL
) {
145 rect
->bottom
+= GetSystemMetrics(SM_CYHSCROLL
) - 1;
146 if(!HAS_ANYFRAME( style
, exStyle
))
152 /******************************************************************************
153 * NC_AdjustRectOuter95
155 * Computes the size of the "outside" parts of the window based on the
156 * parameters of the client area.
165 * "Outer" parts of a window means the whole window frame, caption and
166 * menu bar. It does not include "inner" parts of the frame like client
167 * edge, static edge or scroll bars.
170 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
171 * Original (NC_AdjustRect95) cut & paste from NC_AdjustRect
173 * 20-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
174 * Split NC_AdjustRect95 into NC_AdjustRectOuter95 and
175 * NC_AdjustRectInner95 and added handling of Win95 styles.
177 * 28-Jul-1999 Ove Kåven (ovek@arcticnet.no)
178 * Streamlined window style checks.
180 *****************************************************************************/
183 NC_AdjustRectOuter95 (LPRECT16 rect
, DWORD style
, BOOL menu
, DWORD exStyle
)
185 if(style
& WS_ICONIC
) return;
187 /* Decide if the window will be managed (see CreateWindowEx) */
188 if (!WIN_WindowNeedsWMBorder(style
, exStyle
))
190 if (HAS_THICKFRAME( style
, exStyle
))
191 InflateRect16( rect
, GetSystemMetrics(SM_CXFRAME
), GetSystemMetrics(SM_CYFRAME
) );
193 if (HAS_DLGFRAME( style
, exStyle
))
194 InflateRect16(rect
, GetSystemMetrics(SM_CXDLGFRAME
), GetSystemMetrics(SM_CYDLGFRAME
) );
196 if (HAS_THINFRAME( style
))
197 InflateRect16( rect
, GetSystemMetrics(SM_CXBORDER
), GetSystemMetrics(SM_CYBORDER
));
199 if ((style
& WS_CAPTION
) == WS_CAPTION
)
201 if (exStyle
& WS_EX_TOOLWINDOW
)
202 rect
->top
-= GetSystemMetrics(SM_CYSMCAPTION
);
204 rect
->top
-= GetSystemMetrics(SM_CYCAPTION
);
209 rect
->top
-= GetSystemMetrics(SM_CYMENU
);
213 /******************************************************************************
214 * NC_AdjustRectInner95
216 * Computes the size of the "inside" part of the window based on the
217 * parameters of the client area.
225 * "Inner" part of a window means the window frame inside of the flat
226 * window frame. It includes the client edge, the static edge and the
230 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
231 * Original (NC_AdjustRect95) cut & paste from NC_AdjustRect
233 * 20-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
234 * Split NC_AdjustRect95 into NC_AdjustRectOuter95 and
235 * NC_AdjustRectInner95 and added handling of Win95 styles.
237 *****************************************************************************/
240 NC_AdjustRectInner95 (LPRECT16 rect
, DWORD style
, DWORD exStyle
)
242 if(style
& WS_ICONIC
) return;
244 if (exStyle
& WS_EX_CLIENTEDGE
)
245 InflateRect16 (rect
, GetSystemMetrics(SM_CXEDGE
), GetSystemMetrics(SM_CYEDGE
));
247 if (exStyle
& WS_EX_STATICEDGE
)
248 InflateRect16 (rect
, GetSystemMetrics(SM_CXBORDER
), GetSystemMetrics(SM_CYBORDER
));
250 if (style
& WS_VSCROLL
) rect
->right
+= GetSystemMetrics(SM_CXVSCROLL
);
251 if (style
& WS_HSCROLL
) rect
->bottom
+= GetSystemMetrics(SM_CYHSCROLL
);
255 /***********************************************************************
256 * DrawCaption16 [USER.660] Draws a caption bar
270 DrawCaption16 (HWND16 hwnd
, HDC16 hdc
, const RECT16
*rect
, UINT16 uFlags
)
275 CONV_RECT16TO32 (rect
, &rect32
);
277 return (BOOL16
)DrawCaptionTempA (hwnd
, hdc
, rect
? &rect32
: NULL
,
278 0, 0, NULL
, uFlags
& 0x1F);
282 /***********************************************************************
283 * DrawCaption32 [USER32.154] Draws a caption bar
297 DrawCaption (HWND hwnd
, HDC hdc
, const RECT
*lpRect
, UINT uFlags
)
299 return DrawCaptionTempA (hwnd
, hdc
, lpRect
, 0, 0, NULL
, uFlags
& 0x1F);
303 /***********************************************************************
304 * DrawCaptionTemp16 [USER.657]
314 DrawCaptionTemp16 (HWND16 hwnd
, HDC16 hdc
, const RECT16
*rect
, HFONT16 hFont
,
315 HICON16 hIcon
, LPCSTR str
, UINT16 uFlags
)
320 CONV_RECT16TO32(rect
,&rect32
);
322 return (BOOL16
)DrawCaptionTempA (hwnd
, hdc
, rect
?&rect32
:NULL
, hFont
,
323 hIcon
, str
, uFlags
& 0x1F);
327 /***********************************************************************
328 * DrawCaptionTemp32A [USER32.599]
338 DrawCaptionTempA (HWND hwnd
, HDC hdc
, const RECT
*rect
, HFONT hFont
,
339 HICON hIcon
, LPCSTR str
, UINT uFlags
)
343 TRACE_(nonclient
)("(%08x,%08x,%p,%08x,%08x,\"%s\",%08x)\n",
344 hwnd
, hdc
, rect
, hFont
, hIcon
, str
, uFlags
);
346 /* drawing background */
347 if (uFlags
& DC_INBUTTON
) {
348 FillRect (hdc
, &rc
, GetSysColorBrush (COLOR_3DFACE
));
350 if (uFlags
& DC_ACTIVE
) {
351 HBRUSH hbr
= SelectObject (hdc
, CACHE_GetPattern55AABrush ());
352 PatBlt (hdc
, rc
.left
, rc
.top
,
353 rc
.right
-rc
.left
, rc
.bottom
-rc
.top
, 0xFA0089);
354 SelectObject (hdc
, hbr
);
358 FillRect (hdc
, &rc
, GetSysColorBrush ((uFlags
& DC_ACTIVE
) ?
359 COLOR_ACTIVECAPTION
: COLOR_INACTIVECAPTION
));
364 if ((uFlags
& DC_ICON
) && !(uFlags
& DC_SMALLCAP
)) {
368 pt
.y
= (rc
.bottom
+ rc
.top
- GetSystemMetrics(SM_CYSMICON
)) / 2;
371 DrawIconEx (hdc
, pt
.x
, pt
.y
, hIcon
, GetSystemMetrics(SM_CXSMICON
),
372 GetSystemMetrics(SM_CYSMICON
), 0, 0, DI_NORMAL
);
375 HICON hAppIcon
= (HICON
) GetClassLongA(hwnd
, GCL_HICONSM
);
376 if(!hAppIcon
) hAppIcon
= (HICON
) GetClassLongA(hwnd
, GCL_HICON
);
378 DrawIconEx (hdc
, pt
.x
, pt
.y
, hAppIcon
, GetSystemMetrics(SM_CXSMICON
),
379 GetSystemMetrics(SM_CYSMICON
), 0, 0, DI_NORMAL
);
382 rc
.left
+= (rc
.bottom
- rc
.top
);
386 if (uFlags
& DC_TEXT
) {
389 if (uFlags
& DC_INBUTTON
)
390 SetTextColor (hdc
, GetSysColor (COLOR_BTNTEXT
));
391 else if (uFlags
& DC_ACTIVE
)
392 SetTextColor (hdc
, GetSysColor (COLOR_CAPTIONTEXT
));
394 SetTextColor (hdc
, GetSysColor (COLOR_INACTIVECAPTIONTEXT
));
396 SetBkMode (hdc
, TRANSPARENT
);
399 hOldFont
= SelectObject (hdc
, hFont
);
401 NONCLIENTMETRICSA nclm
;
403 nclm
.cbSize
= sizeof(NONCLIENTMETRICSA
);
404 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS
, 0, &nclm
, 0);
405 hNewFont
= CreateFontIndirectA ((uFlags
& DC_SMALLCAP
) ?
406 &nclm
.lfSmCaptionFont
: &nclm
.lfCaptionFont
);
407 hOldFont
= SelectObject (hdc
, hNewFont
);
411 DrawTextA (hdc
, str
, -1, &rc
,
412 DT_SINGLELINE
| DT_VCENTER
| DT_NOPREFIX
| DT_LEFT
);
416 nLen
= GetWindowTextA (hwnd
, szText
, 128);
417 DrawTextA (hdc
, szText
, nLen
, &rc
,
418 DT_SINGLELINE
| DT_VCENTER
| DT_NOPREFIX
| DT_LEFT
);
422 SelectObject (hdc
, hOldFont
);
424 DeleteObject (SelectObject (hdc
, hOldFont
));
427 /* drawing focus ??? */
429 FIXME_(nonclient
)("undocumented flag (0x2000)!\n");
435 /***********************************************************************
436 * DrawCaptionTemp32W [USER32.602]
446 DrawCaptionTempW (HWND hwnd
, HDC hdc
, const RECT
*rect
, HFONT hFont
,
447 HICON hIcon
, LPCWSTR str
, UINT uFlags
)
449 LPSTR p
= HEAP_strdupWtoA (GetProcessHeap (), 0, str
);
450 BOOL res
= DrawCaptionTempA (hwnd
, hdc
, rect
, hFont
, hIcon
, p
, uFlags
);
451 HeapFree (GetProcessHeap (), 0, p
);
456 /***********************************************************************
457 * AdjustWindowRect16 (USER.102)
459 BOOL16 WINAPI
AdjustWindowRect16( LPRECT16 rect
, DWORD style
, BOOL16 menu
)
461 return AdjustWindowRectEx16( rect
, style
, menu
, 0 );
465 /***********************************************************************
466 * AdjustWindowRect32 (USER32.2)
468 BOOL WINAPI
AdjustWindowRect( LPRECT rect
, DWORD style
, BOOL menu
)
470 return AdjustWindowRectEx( rect
, style
, menu
, 0 );
474 /***********************************************************************
475 * AdjustWindowRectEx16 (USER.454)
477 BOOL16 WINAPI
AdjustWindowRectEx16( LPRECT16 rect
, DWORD style
,
478 BOOL16 menu
, DWORD exStyle
)
480 /* Correct the window style */
482 if (!(style
& (WS_POPUP
| WS_CHILD
))) /* Overlapped window */
484 style
&= (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
| WS_CHILD
);
485 exStyle
&= (WS_EX_DLGMODALFRAME
| WS_EX_CLIENTEDGE
|
486 WS_EX_STATICEDGE
| WS_EX_TOOLWINDOW
);
487 if (exStyle
& WS_EX_DLGMODALFRAME
) style
&= ~WS_THICKFRAME
;
489 TRACE_(nonclient
)("(%d,%d)-(%d,%d) %08lx %d %08lx\n",
490 rect
->left
, rect
->top
, rect
->right
, rect
->bottom
,
491 style
, menu
, exStyle
);
493 if (TWEAK_WineLook
== WIN31_LOOK
)
494 NC_AdjustRect( rect
, style
, menu
, exStyle
);
496 NC_AdjustRectOuter95( rect
, style
, menu
, exStyle
);
497 NC_AdjustRectInner95( rect
, style
, exStyle
);
504 /***********************************************************************
505 * AdjustWindowRectEx32 (USER32.3)
507 BOOL WINAPI
AdjustWindowRectEx( LPRECT rect
, DWORD style
,
508 BOOL menu
, DWORD exStyle
)
513 CONV_RECT32TO16( rect
, &rect16
);
514 ret
= AdjustWindowRectEx16( &rect16
, style
, (BOOL16
)menu
, exStyle
);
515 CONV_RECT16TO32( &rect16
, rect
);
520 /***********************************************************************
521 * NC_HandleNCCalcSize
523 * Handle a WM_NCCALCSIZE message. Called from DefWindowProc().
525 LONG
NC_HandleNCCalcSize( WND
*pWnd
, RECT
*winRect
)
527 RECT16 tmpRect
= { 0, 0, 0, 0 };
529 UINT style
= (UINT
) GetClassLongA(pWnd
->hwndSelf
, GCL_STYLE
);
531 if (style
& CS_VREDRAW
) result
|= WVR_VREDRAW
;
532 if (style
& CS_HREDRAW
) result
|= WVR_HREDRAW
;
534 if( !( pWnd
->dwStyle
& WS_MINIMIZE
) ) {
535 if (TWEAK_WineLook
== WIN31_LOOK
)
536 NC_AdjustRect( &tmpRect
, pWnd
->dwStyle
, FALSE
, pWnd
->dwExStyle
);
538 NC_AdjustRectOuter95( &tmpRect
, pWnd
->dwStyle
, FALSE
, pWnd
->dwExStyle
);
540 winRect
->left
-= tmpRect
.left
;
541 winRect
->top
-= tmpRect
.top
;
542 winRect
->right
-= tmpRect
.right
;
543 winRect
->bottom
-= tmpRect
.bottom
;
545 if (HAS_MENU(pWnd
)) {
546 TRACE_(nonclient
)("Calling "
547 "GetMenuBarHeight with HWND 0x%x, width %d, "
548 "at (%d, %d).\n", pWnd
->hwndSelf
,
549 winRect
->right
- winRect
->left
,
550 -tmpRect
.left
, -tmpRect
.top
);
553 MENU_GetMenuBarHeight( pWnd
->hwndSelf
,
554 winRect
->right
- winRect
->left
,
555 -tmpRect
.left
, -tmpRect
.top
) + 1;
558 if (TWEAK_WineLook
> WIN31_LOOK
) {
559 SetRect16 (&tmpRect
, 0, 0, 0, 0);
560 NC_AdjustRectInner95 (&tmpRect
, pWnd
->dwStyle
, pWnd
->dwExStyle
);
561 winRect
->left
-= tmpRect
.left
;
562 winRect
->top
-= tmpRect
.top
;
563 winRect
->right
-= tmpRect
.right
;
564 winRect
->bottom
-= tmpRect
.bottom
;
571 /***********************************************************************
574 * Get the 'inside' rectangle of a window, i.e. the whole window rectangle
575 * but without the borders (if any).
576 * The rectangle is in window coordinates (for drawing with GetWindowDC()).
578 static void NC_GetInsideRect( HWND hwnd
, RECT
*rect
)
580 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
582 rect
->top
= rect
->left
= 0;
583 rect
->right
= wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
;
584 rect
->bottom
= wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
;
586 if ((wndPtr
->dwStyle
& WS_ICONIC
) || (wndPtr
->flags
& WIN_MANAGED
)) goto END
;
588 /* Remove frame from rectangle */
589 if (HAS_THICKFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
590 InflateRect( rect
, -GetSystemMetrics(SM_CXFRAME
), -GetSystemMetrics(SM_CYFRAME
) );
592 if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
594 InflateRect( rect
, -GetSystemMetrics(SM_CXDLGFRAME
), -GetSystemMetrics(SM_CYDLGFRAME
));
595 /* FIXME: this isn't in NC_AdjustRect? why not? */
596 if (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
)
597 InflateRect( rect
, -1, 0 );
600 if (HAS_THINFRAME( wndPtr
->dwStyle
))
601 InflateRect( rect
, -GetSystemMetrics(SM_CXBORDER
), -GetSystemMetrics(SM_CYBORDER
) );
603 WIN_ReleaseWndPtr(wndPtr
);
608 /***********************************************************************
611 * Get the 'inside' rectangle of a window, i.e. the whole window rectangle
612 * but without the borders (if any).
613 * The rectangle is in window coordinates (for drawing with GetWindowDC()).
617 NC_GetInsideRect95 (HWND hwnd
, RECT
*rect
)
619 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
621 rect
->top
= rect
->left
= 0;
622 rect
->right
= wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
;
623 rect
->bottom
= wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
;
625 if ((wndPtr
->dwStyle
& WS_ICONIC
) || (wndPtr
->flags
& WIN_MANAGED
)) goto END
;
627 /* Remove frame from rectangle */
628 if (HAS_THICKFRAME (wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
630 InflateRect( rect
, -GetSystemMetrics(SM_CXSIZEFRAME
), -GetSystemMetrics(SM_CYSIZEFRAME
) );
632 else if (HAS_DLGFRAME (wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
634 InflateRect( rect
, -GetSystemMetrics(SM_CXFIXEDFRAME
), -GetSystemMetrics(SM_CYFIXEDFRAME
));
636 else if (HAS_THINFRAME (wndPtr
->dwStyle
))
638 InflateRect( rect
, -GetSystemMetrics(SM_CXBORDER
), -GetSystemMetrics(SM_CYBORDER
) );
641 /* We have additional border information if the window
642 * is a child (but not an MDI child) */
643 if ( (wndPtr
->dwStyle
& WS_CHILD
) &&
644 ( (wndPtr
->dwExStyle
& WS_EX_MDICHILD
) == 0 ) )
646 if (wndPtr
->dwExStyle
& WS_EX_CLIENTEDGE
)
647 InflateRect (rect
, -GetSystemMetrics(SM_CXEDGE
), -GetSystemMetrics(SM_CYEDGE
));
649 if (wndPtr
->dwExStyle
& WS_EX_STATICEDGE
)
650 InflateRect (rect
, -GetSystemMetrics(SM_CXBORDER
), -GetSystemMetrics(SM_CYBORDER
));
653 WIN_ReleaseWndPtr(wndPtr
);
658 /***********************************************************************
661 * Handle a WM_NCHITTEST message. Called from NC_HandleNcHitTest().
664 static LONG
NC_DoNCHitTest (WND
*wndPtr
, POINT16 pt
)
668 TRACE_(nonclient
)("hwnd=%04x pt=%d,%d\n",
669 wndPtr
->hwndSelf
, pt
.x
, pt
.y
);
671 GetWindowRect16 (wndPtr
->hwndSelf
, &rect
);
672 if (!PtInRect16( &rect
, pt
)) return HTNOWHERE
;
674 if (wndPtr
->dwStyle
& WS_MINIMIZE
) return HTCAPTION
;
676 if (!(wndPtr
->flags
& WIN_MANAGED
))
679 if (HAS_THICKFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
681 InflateRect16( &rect
, -GetSystemMetrics(SM_CXFRAME
), -GetSystemMetrics(SM_CYFRAME
) );
682 if (!PtInRect16( &rect
, pt
))
684 /* Check top sizing border */
687 if (pt
.x
< rect
.left
+GetSystemMetrics(SM_CXSIZE
)) return HTTOPLEFT
;
688 if (pt
.x
>= rect
.right
-GetSystemMetrics(SM_CXSIZE
)) return HTTOPRIGHT
;
691 /* Check bottom sizing border */
692 if (pt
.y
>= rect
.bottom
)
694 if (pt
.x
< rect
.left
+GetSystemMetrics(SM_CXSIZE
)) return HTBOTTOMLEFT
;
695 if (pt
.x
>= rect
.right
-GetSystemMetrics(SM_CXSIZE
)) return HTBOTTOMRIGHT
;
698 /* Check left sizing border */
699 if (pt
.x
< rect
.left
)
701 if (pt
.y
< rect
.top
+GetSystemMetrics(SM_CYSIZE
)) return HTTOPLEFT
;
702 if (pt
.y
>= rect
.bottom
-GetSystemMetrics(SM_CYSIZE
)) return HTBOTTOMLEFT
;
705 /* Check right sizing border */
706 if (pt
.x
>= rect
.right
)
708 if (pt
.y
< rect
.top
+GetSystemMetrics(SM_CYSIZE
)) return HTTOPRIGHT
;
709 if (pt
.y
>= rect
.bottom
-GetSystemMetrics(SM_CYSIZE
)) return HTBOTTOMRIGHT
;
714 else /* No thick frame */
716 if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
717 InflateRect16(&rect
, -GetSystemMetrics(SM_CXDLGFRAME
), -GetSystemMetrics(SM_CYDLGFRAME
));
718 else if (HAS_THINFRAME( wndPtr
->dwStyle
))
719 InflateRect16(&rect
, -GetSystemMetrics(SM_CXBORDER
), -GetSystemMetrics(SM_CYBORDER
));
720 if (!PtInRect16( &rect
, pt
)) return HTBORDER
;
725 if ((wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
727 rect
.top
+= GetSystemMetrics(SM_CYCAPTION
) - GetSystemMetrics(SM_CYBORDER
);
728 if (!PtInRect16( &rect
, pt
))
730 /* Check system menu */
731 if (wndPtr
->dwStyle
& WS_SYSMENU
)
732 rect
.left
+= GetSystemMetrics(SM_CXSIZE
);
733 if (pt
.x
<= rect
.left
) return HTSYSMENU
;
735 /* Check maximize box */
736 if (wndPtr
->dwStyle
& WS_MAXIMIZEBOX
)
737 rect
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
739 if (pt
.x
>= rect
.right
) return HTMAXBUTTON
;
740 /* Check minimize box */
741 if (wndPtr
->dwStyle
& WS_MINIMIZEBOX
)
742 rect
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
743 if (pt
.x
>= rect
.right
) return HTMINBUTTON
;
749 /* Check client area */
751 ScreenToClient16( wndPtr
->hwndSelf
, &pt
);
752 GetClientRect16( wndPtr
->hwndSelf
, &rect
);
753 if (PtInRect16( &rect
, pt
)) return HTCLIENT
;
755 /* Check vertical scroll bar */
757 if (wndPtr
->dwStyle
& WS_VSCROLL
)
759 rect
.right
+= GetSystemMetrics(SM_CXVSCROLL
);
760 if (PtInRect16( &rect
, pt
)) return HTVSCROLL
;
763 /* Check horizontal scroll bar */
765 if (wndPtr
->dwStyle
& WS_HSCROLL
)
767 rect
.bottom
+= GetSystemMetrics(SM_CYHSCROLL
);
768 if (PtInRect16( &rect
, pt
))
771 if ((wndPtr
->dwStyle
& WS_VSCROLL
) &&
772 (pt
.x
>= rect
.right
- GetSystemMetrics(SM_CXVSCROLL
)))
780 if (HAS_MENU(wndPtr
))
782 if ((pt
.y
< 0) && (pt
.x
>= 0) && (pt
.x
< rect
.right
))
786 /* Should never get here */
791 /***********************************************************************
794 * Handle a WM_NCHITTEST message. Called from NC_HandleNCHitTest().
796 * FIXME: Just a modified copy of the Win 3.1 version.
800 NC_DoNCHitTest95 (WND
*wndPtr
, POINT16 pt
)
804 TRACE_(nonclient
)("hwnd=%04x pt=%d,%d\n",
805 wndPtr
->hwndSelf
, pt
.x
, pt
.y
);
807 GetWindowRect16 (wndPtr
->hwndSelf
, &rect
);
808 if (!PtInRect16( &rect
, pt
)) return HTNOWHERE
;
810 if (wndPtr
->dwStyle
& WS_MINIMIZE
) return HTCAPTION
;
812 if (!(wndPtr
->flags
& WIN_MANAGED
))
815 if (HAS_THICKFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
817 InflateRect16( &rect
, -GetSystemMetrics(SM_CXFRAME
), -GetSystemMetrics(SM_CYFRAME
) );
818 if (!PtInRect16( &rect
, pt
))
820 /* Check top sizing border */
823 if (pt
.x
< rect
.left
+GetSystemMetrics(SM_CXSIZE
)) return HTTOPLEFT
;
824 if (pt
.x
>= rect
.right
-GetSystemMetrics(SM_CXSIZE
)) return HTTOPRIGHT
;
827 /* Check bottom sizing border */
828 if (pt
.y
>= rect
.bottom
)
830 if (pt
.x
< rect
.left
+GetSystemMetrics(SM_CXSIZE
)) return HTBOTTOMLEFT
;
831 if (pt
.x
>= rect
.right
-GetSystemMetrics(SM_CXSIZE
)) return HTBOTTOMRIGHT
;
834 /* Check left sizing border */
835 if (pt
.x
< rect
.left
)
837 if (pt
.y
< rect
.top
+GetSystemMetrics(SM_CYSIZE
)) return HTTOPLEFT
;
838 if (pt
.y
>= rect
.bottom
-GetSystemMetrics(SM_CYSIZE
)) return HTBOTTOMLEFT
;
841 /* Check right sizing border */
842 if (pt
.x
>= rect
.right
)
844 if (pt
.y
< rect
.top
+GetSystemMetrics(SM_CYSIZE
)) return HTTOPRIGHT
;
845 if (pt
.y
>= rect
.bottom
-GetSystemMetrics(SM_CYSIZE
)) return HTBOTTOMRIGHT
;
850 else /* No thick frame */
852 if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
853 InflateRect16(&rect
, -GetSystemMetrics(SM_CXDLGFRAME
), -GetSystemMetrics(SM_CYDLGFRAME
));
854 else if (HAS_THINFRAME( wndPtr
->dwStyle
))
855 InflateRect16(&rect
, -GetSystemMetrics(SM_CXBORDER
), -GetSystemMetrics(SM_CYBORDER
));
856 if (!PtInRect16( &rect
, pt
)) return HTBORDER
;
861 if ((wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
863 if (wndPtr
->dwExStyle
& WS_EX_TOOLWINDOW
)
864 rect
.top
+= GetSystemMetrics(SM_CYSMCAPTION
) - 1;
866 rect
.top
+= GetSystemMetrics(SM_CYCAPTION
) - 1;
867 if (!PtInRect16( &rect
, pt
))
869 /* Check system menu */
870 if(wndPtr
->dwStyle
& WS_SYSMENU
)
872 /* Check if there is an user icon */
873 HICON hIcon
= (HICON
) GetClassLongA(wndPtr
->hwndSelf
, GCL_HICONSM
);
874 if(!hIcon
) hIcon
= (HICON
) GetClassLongA(wndPtr
->hwndSelf
, GCL_HICON
);
876 /* If there is an icon associated with the window OR */
877 /* If there is no hIcon specified and this is not a modal dialog, */
878 /* there is a system menu icon. */
879 if((hIcon
!= 0) || (!(wndPtr
->dwStyle
& DS_MODALFRAME
)))
880 rect
.left
+= GetSystemMetrics(SM_CYCAPTION
) - 1;
882 if (pt
.x
< rect
.left
) return HTSYSMENU
;
884 /* Check close button */
885 if (wndPtr
->dwStyle
& WS_SYSMENU
)
886 rect
.right
-= GetSystemMetrics(SM_CYCAPTION
) - 1;
887 if (pt
.x
> rect
.right
) return HTCLOSE
;
889 /* Check maximize box */
890 /* In win95 there is automatically a Maximize button when there is a minimize one*/
891 if ((wndPtr
->dwStyle
& WS_MAXIMIZEBOX
)|| (wndPtr
->dwStyle
& WS_MINIMIZEBOX
))
892 rect
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
893 if (pt
.x
> rect
.right
) return HTMAXBUTTON
;
895 /* Check minimize box */
896 /* In win95 there is automatically a Maximize button when there is a Maximize one*/
897 if ((wndPtr
->dwStyle
& WS_MINIMIZEBOX
)||(wndPtr
->dwStyle
& WS_MAXIMIZEBOX
))
898 rect
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
900 if (pt
.x
> rect
.right
) return HTMINBUTTON
;
906 /* Check client area */
908 ScreenToClient16( wndPtr
->hwndSelf
, &pt
);
909 GetClientRect16( wndPtr
->hwndSelf
, &rect
);
910 if (PtInRect16( &rect
, pt
)) return HTCLIENT
;
912 /* Check vertical scroll bar */
914 if (wndPtr
->dwStyle
& WS_VSCROLL
)
916 rect
.right
+= GetSystemMetrics(SM_CXVSCROLL
);
917 if (PtInRect16( &rect
, pt
)) return HTVSCROLL
;
920 /* Check horizontal scroll bar */
922 if (wndPtr
->dwStyle
& WS_HSCROLL
)
924 rect
.bottom
+= GetSystemMetrics(SM_CYHSCROLL
);
925 if (PtInRect16( &rect
, pt
))
928 if ((wndPtr
->dwStyle
& WS_VSCROLL
) &&
929 (pt
.x
>= rect
.right
- GetSystemMetrics(SM_CXVSCROLL
)))
937 if (HAS_MENU(wndPtr
))
939 if ((pt
.y
< 0) && (pt
.x
>= 0) && (pt
.x
< rect
.right
))
943 /* Should never get here */
948 /***********************************************************************
951 * Handle a WM_NCHITTEST message. Called from DefWindowProc().
954 NC_HandleNCHitTest (HWND hwnd
, POINT16 pt
)
957 WND
*wndPtr
= WIN_FindWndPtr (hwnd
);
962 if (TWEAK_WineLook
== WIN31_LOOK
)
963 retvalue
= NC_DoNCHitTest (wndPtr
, pt
);
965 retvalue
= NC_DoNCHitTest95 (wndPtr
, pt
);
966 WIN_ReleaseWndPtr(wndPtr
);
971 /***********************************************************************
974 void NC_DrawSysButton( HWND hwnd
, HDC hdc
, BOOL down
)
979 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
981 if( !(wndPtr
->flags
& WIN_MANAGED
) )
983 NC_GetInsideRect( hwnd
, &rect
);
984 hdcMem
= CreateCompatibleDC( hdc
);
985 hbitmap
= SelectObject( hdcMem
, hbitmapClose
);
986 BitBlt(hdc
, rect
.left
, rect
.top
, GetSystemMetrics(SM_CXSIZE
), GetSystemMetrics(SM_CYSIZE
),
987 hdcMem
, (wndPtr
->dwStyle
& WS_CHILD
) ? GetSystemMetrics(SM_CXSIZE
) : 0, 0,
988 down
? NOTSRCCOPY
: SRCCOPY
);
989 SelectObject( hdcMem
, hbitmap
);
992 WIN_ReleaseWndPtr(wndPtr
);
996 /***********************************************************************
999 static void NC_DrawMaxButton( HWND hwnd
, HDC16 hdc
, BOOL down
)
1002 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1005 if( !(wndPtr
->flags
& WIN_MANAGED
) )
1007 NC_GetInsideRect( hwnd
, &rect
);
1008 hdcMem
= CreateCompatibleDC( hdc
);
1009 SelectObject( hdcMem
, (IsZoomed(hwnd
)
1010 ? (down
? hbitmapRestoreD
: hbitmapRestore
)
1011 : (down
? hbitmapMaximizeD
: hbitmapMaximize
)) );
1012 BitBlt( hdc
, rect
.right
- GetSystemMetrics(SM_CXSIZE
) - 1, rect
.top
,
1013 GetSystemMetrics(SM_CXSIZE
) + 1, GetSystemMetrics(SM_CYSIZE
), hdcMem
, 0, 0,
1017 WIN_ReleaseWndPtr(wndPtr
);
1022 /***********************************************************************
1025 static void NC_DrawMinButton( HWND hwnd
, HDC16 hdc
, BOOL down
)
1028 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1031 if( !(wndPtr
->flags
& WIN_MANAGED
) )
1033 NC_GetInsideRect( hwnd
, &rect
);
1034 hdcMem
= CreateCompatibleDC( hdc
);
1035 SelectObject( hdcMem
, (down
? hbitmapMinimizeD
: hbitmapMinimize
) );
1036 if (wndPtr
->dwStyle
& WS_MAXIMIZEBOX
) rect
.right
-= GetSystemMetrics(SM_CXSIZE
)+1;
1037 BitBlt( hdc
, rect
.right
- GetSystemMetrics(SM_CXSIZE
) - 1, rect
.top
,
1038 GetSystemMetrics(SM_CXSIZE
) + 1, GetSystemMetrics(SM_CYSIZE
), hdcMem
, 0, 0,
1042 WIN_ReleaseWndPtr(wndPtr
);
1046 /******************************************************************************
1048 * void NC_DrawSysButton95(
1053 * Draws the Win95 system icon.
1056 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1057 * Original implementation from NC_DrawSysButton source.
1058 * 11-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1061 *****************************************************************************/
1064 NC_DrawSysButton95 (HWND hwnd
, HDC hdc
, BOOL down
)
1066 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1068 if( !(wndPtr
->flags
& WIN_MANAGED
) )
1073 NC_GetInsideRect95( hwnd
, &rect
);
1075 hIcon
= (HICON
) GetClassLongA(wndPtr
->hwndSelf
, GCL_HICONSM
);
1076 if(!hIcon
) hIcon
= (HICON
) GetClassLongA(wndPtr
->hwndSelf
, GCL_HICON
);
1078 /* If there is no hIcon specified or this is not a modal dialog, */
1079 /* get the default one. */
1081 if (!(wndPtr
->dwStyle
& DS_MODALFRAME
))
1082 hIcon
= LoadImageA(0, MAKEINTRESOURCEA(OIC_WINEICON
), IMAGE_ICON
, 0, 0, LR_DEFAULTCOLOR
);
1085 DrawIconEx (hdc
, rect
.left
+ 2, rect
.top
+ 2, hIcon
,
1086 GetSystemMetrics(SM_CXSMICON
),
1087 GetSystemMetrics(SM_CYSMICON
),
1090 WIN_ReleaseWndPtr(wndPtr
);
1091 return (hIcon
!= 0);
1093 WIN_ReleaseWndPtr(wndPtr
);
1098 /******************************************************************************
1100 * void NC_DrawCloseButton95(
1106 * Draws the Win95 close button.
1108 * If bGrayed is true, then draw a disabled Close button
1111 * 11-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1112 * Original implementation from NC_DrawSysButton95 source.
1114 *****************************************************************************/
1116 static void NC_DrawCloseButton95 (HWND hwnd
, HDC hdc
, BOOL down
, BOOL bGrayed
)
1120 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1122 if( !(wndPtr
->flags
& WIN_MANAGED
) )
1125 HBITMAP hBmp
, hOldBmp
;
1127 NC_GetInsideRect95( hwnd
, &rect
);
1129 hdcMem
= CreateCompatibleDC( hdc
);
1130 hBmp
= down
? hbitmapCloseD
: hbitmapClose
;
1131 hOldBmp
= SelectObject (hdcMem
, hBmp
);
1132 GetObjectA (hBmp
, sizeof(BITMAP
), &bmp
);
1134 BitBlt (hdc
, rect
.right
- (GetSystemMetrics(SM_CYCAPTION
) + 1 + bmp
.bmWidth
) / 2,
1135 rect
.top
+ (GetSystemMetrics(SM_CYCAPTION
) - 1 - bmp
.bmHeight
) / 2,
1136 bmp
.bmWidth
, bmp
.bmHeight
, hdcMem
, 0, 0, SRCCOPY
);
1139 NC_DrawGrayButton(hdc
,rect
.right
- (GetSystemMetrics(SM_CYCAPTION
) + 1 + bmp
.bmWidth
) / 2 + 2,
1140 rect
.top
+ (GetSystemMetrics(SM_CYCAPTION
) - 1 - bmp
.bmHeight
) / 2 + 2);
1142 SelectObject (hdcMem
, hOldBmp
);
1145 WIN_ReleaseWndPtr(wndPtr
);
1148 /******************************************************************************
1150 * NC_DrawMaxButton95(
1156 * Draws the maximize button for Win95 style windows.
1158 * If bGrayed is true, then draw a disabled Maximize button
1161 * Many. Spacing might still be incorrect. Need to fit a close
1162 * button between the max button and the edge.
1163 * Should scale the image with the title bar. And more...
1166 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1167 * Original implementation.
1169 *****************************************************************************/
1171 static void NC_DrawMaxButton95(HWND hwnd
,HDC16 hdc
,BOOL down
, BOOL bGrayed
)
1175 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1177 if( !(wndPtr
->flags
& WIN_MANAGED
))
1180 HBITMAP hBmp
,hOldBmp
;
1182 NC_GetInsideRect95( hwnd
, &rect
);
1183 hdcMem
= CreateCompatibleDC( hdc
);
1184 hBmp
= IsZoomed(hwnd
) ?
1185 (down
? hbitmapRestoreD
: hbitmapRestore
) :
1186 (down
? hbitmapMaximizeD
: hbitmapMaximize
);
1187 hOldBmp
=SelectObject( hdcMem
, hBmp
);
1188 GetObjectA (hBmp
, sizeof(BITMAP
), &bmp
);
1190 if (wndPtr
->dwStyle
& WS_SYSMENU
)
1191 rect
.right
-= GetSystemMetrics(SM_CYCAPTION
) + 1;
1193 BitBlt( hdc
, rect
.right
- (GetSystemMetrics(SM_CXSIZE
) + bmp
.bmWidth
) / 2,
1194 rect
.top
+ (GetSystemMetrics(SM_CYCAPTION
) - 1 - bmp
.bmHeight
) / 2,
1195 bmp
.bmWidth
, bmp
.bmHeight
, hdcMem
, 0, 0, SRCCOPY
);
1198 NC_DrawGrayButton(hdc
, rect
.right
- (GetSystemMetrics(SM_CXSIZE
) + bmp
.bmWidth
) / 2 + 2,
1199 rect
.top
+ (GetSystemMetrics(SM_CYCAPTION
) - 1 - bmp
.bmHeight
) / 2 + 2);
1202 SelectObject (hdcMem
, hOldBmp
);
1205 WIN_ReleaseWndPtr(wndPtr
);
1208 /******************************************************************************
1210 * NC_DrawMinButton95(
1216 * Draws the minimize button for Win95 style windows.
1218 * If bGrayed is true, then draw a disabled Minimize button
1221 * Many. Spacing is still incorrect. Should scale the image with the
1222 * title bar. And more...
1225 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1226 * Original implementation.
1228 *****************************************************************************/
1230 static void NC_DrawMinButton95(HWND hwnd
,HDC16 hdc
,BOOL down
, BOOL bGrayed
)
1234 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1236 if( !(wndPtr
->flags
& WIN_MANAGED
))
1240 HBITMAP hBmp
,hOldBmp
;
1242 NC_GetInsideRect95( hwnd
, &rect
);
1244 hdcMem
= CreateCompatibleDC( hdc
);
1245 hBmp
= down
? hbitmapMinimizeD
: hbitmapMinimize
;
1246 hOldBmp
= SelectObject( hdcMem
, hBmp
);
1247 GetObjectA (hBmp
, sizeof(BITMAP
), &bmp
);
1249 if (wndPtr
->dwStyle
& WS_SYSMENU
)
1250 rect
.right
-= GetSystemMetrics(SM_CYCAPTION
) + 1;
1252 /* In win 95 there is always a Maximize box when there is a Minimize one */
1253 if ((wndPtr
->dwStyle
& WS_MAXIMIZEBOX
) || (wndPtr
->dwStyle
& WS_MINIMIZEBOX
))
1254 rect
.right
+= -1 - (GetSystemMetrics(SM_CXSIZE
) + bmp
.bmWidth
) / 2;
1256 BitBlt( hdc
, rect
.right
- (GetSystemMetrics(SM_CXSIZE
) + bmp
.bmWidth
) / 2,
1257 rect
.top
+ (GetSystemMetrics(SM_CYCAPTION
) - 1 - bmp
.bmHeight
) / 2,
1258 bmp
.bmWidth
, bmp
.bmHeight
, hdcMem
, 0, 0, SRCCOPY
);
1261 NC_DrawGrayButton(hdc
, rect
.right
- (GetSystemMetrics(SM_CXSIZE
) + bmp
.bmWidth
) / 2 + 2,
1262 rect
.top
+ (GetSystemMetrics(SM_CYCAPTION
) - 1 - bmp
.bmHeight
) / 2 + 2);
1265 SelectObject (hdcMem
, hOldBmp
);
1268 WIN_ReleaseWndPtr(wndPtr
);
1271 /***********************************************************************
1274 * Draw a window frame inside the given rectangle, and update the rectangle.
1275 * The correct pen for the frame must be selected in the DC.
1277 static void NC_DrawFrame( HDC hdc
, RECT
*rect
, BOOL dlgFrame
,
1282 if (TWEAK_WineLook
!= WIN31_LOOK
)
1283 ERR_(nonclient
)("Called in Win95 mode. Aiee! Please report this.\n" );
1287 width
= GetSystemMetrics(SM_CXDLGFRAME
) - 1;
1288 height
= GetSystemMetrics(SM_CYDLGFRAME
) - 1;
1289 SelectObject( hdc
, GetSysColorBrush(active
? COLOR_ACTIVECAPTION
:
1290 COLOR_INACTIVECAPTION
) );
1294 width
= GetSystemMetrics(SM_CXFRAME
) - 2;
1295 height
= GetSystemMetrics(SM_CYFRAME
) - 2;
1296 SelectObject( hdc
, GetSysColorBrush(active
? COLOR_ACTIVEBORDER
:
1297 COLOR_INACTIVEBORDER
) );
1301 PatBlt( hdc
, rect
->left
, rect
->top
,
1302 rect
->right
- rect
->left
, height
, PATCOPY
);
1303 PatBlt( hdc
, rect
->left
, rect
->top
,
1304 width
, rect
->bottom
- rect
->top
, PATCOPY
);
1305 PatBlt( hdc
, rect
->left
, rect
->bottom
- 1,
1306 rect
->right
- rect
->left
, -height
, PATCOPY
);
1307 PatBlt( hdc
, rect
->right
- 1, rect
->top
,
1308 -width
, rect
->bottom
- rect
->top
, PATCOPY
);
1312 InflateRect( rect
, -width
, -height
);
1316 INT decYOff
= GetSystemMetrics(SM_CXFRAME
) + GetSystemMetrics(SM_CXSIZE
) - 1;
1317 INT decXOff
= GetSystemMetrics(SM_CYFRAME
) + GetSystemMetrics(SM_CYSIZE
) - 1;
1319 /* Draw inner rectangle */
1321 SelectObject( hdc
, GetStockObject(NULL_BRUSH
) );
1322 Rectangle( hdc
, rect
->left
+ width
, rect
->top
+ height
,
1323 rect
->right
- width
, rect
->bottom
- height
);
1325 /* Draw the decorations */
1327 MoveToEx( hdc
, rect
->left
, rect
->top
+ decYOff
, NULL
);
1328 LineTo( hdc
, rect
->left
+ width
, rect
->top
+ decYOff
);
1329 MoveToEx( hdc
, rect
->right
- 1, rect
->top
+ decYOff
, NULL
);
1330 LineTo( hdc
, rect
->right
- width
- 1, rect
->top
+ decYOff
);
1331 MoveToEx( hdc
, rect
->left
, rect
->bottom
- decYOff
, NULL
);
1332 LineTo( hdc
, rect
->left
+ width
, rect
->bottom
- decYOff
);
1333 MoveToEx( hdc
, rect
->right
- 1, rect
->bottom
- decYOff
, NULL
);
1334 LineTo( hdc
, rect
->right
- width
- 1, rect
->bottom
- decYOff
);
1336 MoveToEx( hdc
, rect
->left
+ decXOff
, rect
->top
, NULL
);
1337 LineTo( hdc
, rect
->left
+ decXOff
, rect
->top
+ height
);
1338 MoveToEx( hdc
, rect
->left
+ decXOff
, rect
->bottom
- 1, NULL
);
1339 LineTo( hdc
, rect
->left
+ decXOff
, rect
->bottom
- height
- 1 );
1340 MoveToEx( hdc
, rect
->right
- decXOff
, rect
->top
, NULL
);
1341 LineTo( hdc
, rect
->right
- decXOff
, rect
->top
+ height
);
1342 MoveToEx( hdc
, rect
->right
- decXOff
, rect
->bottom
- 1, NULL
);
1343 LineTo( hdc
, rect
->right
- decXOff
, rect
->bottom
- height
- 1 );
1345 InflateRect( rect
, -width
- 1, -height
- 1 );
1350 /******************************************************************************
1352 * void NC_DrawFrame95(
1358 * Draw a window frame inside the given rectangle, and update the rectangle.
1359 * The correct pen for the frame must be selected in the DC.
1362 * Many. First, just what IS a frame in Win95? Note that the 3D look
1363 * on the outer edge is handled by NC_DoNCPaint95. As is the inner
1364 * edge. The inner rectangle just inside the frame is handled by the
1367 * In short, for most people, this function should be a nop (unless
1368 * you LIKE thick borders in Win95/NT4.0 -- I've been working with
1369 * them lately, but just to get this code right). Even so, it doesn't
1370 * appear to be so. It's being worked on...
1373 * 06-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1374 * Original implementation (based on NC_DrawFrame)
1375 * 02-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1377 * 29-Jun-1999 Ove Kåven (ovek@arcticnet.no)
1378 * Fixed a fix or something.
1380 *****************************************************************************/
1382 static void NC_DrawFrame95(
1392 width
= GetSystemMetrics(SM_CXDLGFRAME
) - GetSystemMetrics(SM_CXEDGE
);
1393 height
= GetSystemMetrics(SM_CYDLGFRAME
) - GetSystemMetrics(SM_CYEDGE
);
1397 width
= GetSystemMetrics(SM_CXFRAME
) - GetSystemMetrics(SM_CXEDGE
);
1398 height
= GetSystemMetrics(SM_CYFRAME
) - GetSystemMetrics(SM_CYEDGE
);
1401 SelectObject( hdc
, GetSysColorBrush(active
? COLOR_ACTIVEBORDER
:
1402 COLOR_INACTIVEBORDER
) );
1405 PatBlt( hdc
, rect
->left
, rect
->top
,
1406 rect
->right
- rect
->left
, height
, PATCOPY
);
1407 PatBlt( hdc
, rect
->left
, rect
->top
,
1408 width
, rect
->bottom
- rect
->top
, PATCOPY
);
1409 PatBlt( hdc
, rect
->left
, rect
->bottom
- 1,
1410 rect
->right
- rect
->left
, -height
, PATCOPY
);
1411 PatBlt( hdc
, rect
->right
- 1, rect
->top
,
1412 -width
, rect
->bottom
- rect
->top
, PATCOPY
);
1414 InflateRect( rect
, -width
, -height
);
1417 /***********************************************************************
1418 * NC_DrawMovingFrame
1420 * Draw the frame used when moving or resizing window.
1422 * FIXME: This causes problems in Win95 mode. (why?)
1424 static void NC_DrawMovingFrame( HDC hdc
, RECT
*rect
, BOOL thickframe
)
1429 CONV_RECT32TO16( rect
, &r16
);
1430 FastWindowFrame16( hdc
, &r16
, GetSystemMetrics(SM_CXFRAME
),
1431 GetSystemMetrics(SM_CYFRAME
), PATINVERT
);
1433 else DrawFocusRect( hdc
, rect
);
1437 /***********************************************************************
1440 * Draw the window caption.
1441 * The correct pen for the window frame must be selected in the DC.
1443 static void NC_DrawCaption( HDC hdc
, RECT
*rect
, HWND hwnd
,
1444 DWORD style
, BOOL active
)
1447 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
1450 if (wndPtr
->flags
& WIN_MANAGED
)
1452 WIN_ReleaseWndPtr(wndPtr
);
1458 if (!(hbitmapClose
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_CLOSE
) )))
1460 WIN_ReleaseWndPtr(wndPtr
);
1463 hbitmapCloseD
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_CLOSED
) );
1464 hbitmapMinimize
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_REDUCE
) );
1465 hbitmapMinimizeD
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_REDUCED
) );
1466 hbitmapMaximize
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_ZOOM
) );
1467 hbitmapMaximizeD
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_ZOOMD
) );
1468 hbitmapRestore
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_RESTORE
) );
1469 hbitmapRestoreD
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_RESTORED
) );
1472 if (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
)
1474 HBRUSH hbrushOld
= SelectObject(hdc
, GetSysColorBrush(COLOR_WINDOW
) );
1475 PatBlt( hdc
, r
.left
, r
.top
, 1, r
.bottom
-r
.top
+1,PATCOPY
);
1476 PatBlt( hdc
, r
.right
-1, r
.top
, 1, r
.bottom
-r
.top
+1, PATCOPY
);
1477 PatBlt( hdc
, r
.left
, r
.top
-1, r
.right
-r
.left
, 1, PATCOPY
);
1480 SelectObject( hdc
, hbrushOld
);
1482 WIN_ReleaseWndPtr(wndPtr
);
1483 MoveTo16( hdc
, r
.left
, r
.bottom
);
1484 LineTo( hdc
, r
.right
, r
.bottom
);
1486 if (style
& WS_SYSMENU
)
1488 NC_DrawSysButton( hwnd
, hdc
, FALSE
);
1489 r
.left
+= GetSystemMetrics(SM_CXSIZE
) + 1;
1490 MoveTo16( hdc
, r
.left
- 1, r
.top
);
1491 LineTo( hdc
, r
.left
- 1, r
.bottom
);
1493 if (style
& WS_MAXIMIZEBOX
)
1495 NC_DrawMaxButton( hwnd
, hdc
, FALSE
);
1496 r
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
1498 if (style
& WS_MINIMIZEBOX
)
1500 NC_DrawMinButton( hwnd
, hdc
, FALSE
);
1501 r
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
1504 FillRect( hdc
, &r
, GetSysColorBrush(active
? COLOR_ACTIVECAPTION
:
1505 COLOR_INACTIVECAPTION
) );
1507 if (GetWindowTextA( hwnd
, buffer
, sizeof(buffer
) ))
1509 if (active
) SetTextColor( hdc
, GetSysColor( COLOR_CAPTIONTEXT
) );
1510 else SetTextColor( hdc
, GetSysColor( COLOR_INACTIVECAPTIONTEXT
) );
1511 SetBkMode( hdc
, TRANSPARENT
);
1512 DrawTextA( hdc
, buffer
, -1, &r
,
1513 DT_SINGLELINE
| DT_CENTER
| DT_VCENTER
| DT_NOPREFIX
);
1518 /******************************************************************************
1527 * Draw the window caption for Win95 style windows.
1528 * The correct pen for the window frame must be selected in the DC.
1531 * Hey, a function that finally works! Well, almost.
1532 * It's being worked on.
1535 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1536 * Original implementation.
1537 * 02-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1540 *****************************************************************************/
1542 static void NC_DrawCaption95(
1551 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1556 if (wndPtr
->flags
& WIN_MANAGED
)
1558 WIN_ReleaseWndPtr(wndPtr
);
1561 WIN_ReleaseWndPtr(wndPtr
);
1563 hPrevPen
= SelectObject( hdc
, GetSysColorPen(COLOR_3DFACE
) );
1564 MoveToEx( hdc
, r
.left
, r
.bottom
- 1, NULL
);
1565 LineTo( hdc
, r
.right
, r
.bottom
- 1 );
1566 SelectObject( hdc
, hPrevPen
);
1569 FillRect( hdc
, &r
, GetSysColorBrush(active
? COLOR_ACTIVECAPTION
:
1570 COLOR_INACTIVECAPTION
) );
1572 if (!hbitmapClose
) {
1573 if (!(hbitmapClose
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_CLOSE
) )))
1575 hbitmapCloseD
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_CLOSED
));
1576 hbitmapMinimize
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_REDUCE
) );
1577 hbitmapMinimizeD
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_REDUCED
) );
1578 hbitmapMaximize
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_ZOOM
) );
1579 hbitmapMaximizeD
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_ZOOMD
) );
1580 hbitmapRestore
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_RESTORE
) );
1581 hbitmapRestoreD
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_RESTORED
) );
1584 if ((style
& WS_SYSMENU
) && !(exStyle
& WS_EX_TOOLWINDOW
)) {
1585 if (NC_DrawSysButton95 (hwnd
, hdc
, FALSE
))
1586 r
.left
+= GetSystemMetrics(SM_CYCAPTION
) - 1;
1589 if (style
& WS_SYSMENU
)
1593 /* Go get the sysmenu */
1594 hSysMenu
= GetSystemMenu(hwnd
, FALSE
);
1595 state
= GetMenuState(hSysMenu
, SC_CLOSE
, MF_BYCOMMAND
);
1597 /* Draw a grayed close button if disabled and a normal one if SC_CLOSE is not there */
1598 NC_DrawCloseButton95 (hwnd
, hdc
, FALSE
,
1599 ((((state
& MF_DISABLED
) || (state
& MF_GRAYED
))) && (state
!= 0xFFFFFFFF)));
1600 r
.right
-= GetSystemMetrics(SM_CYCAPTION
) - 1;
1602 if ((style
& WS_MAXIMIZEBOX
) || (style
& WS_MINIMIZEBOX
))
1604 /* In win95 the two buttons are always there */
1605 /* But if the menu item is not in the menu they're disabled*/
1607 NC_DrawMaxButton95( hwnd
, hdc
, FALSE
, (!(style
& WS_MAXIMIZEBOX
)));
1608 r
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
1610 NC_DrawMinButton95( hwnd
, hdc
, FALSE
, (!(style
& WS_MINIMIZEBOX
)));
1611 r
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
1615 if (GetWindowTextA( hwnd
, buffer
, sizeof(buffer
) )) {
1616 NONCLIENTMETRICSA nclm
;
1617 HFONT hFont
, hOldFont
;
1618 nclm
.cbSize
= sizeof(NONCLIENTMETRICSA
);
1619 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS
, 0, &nclm
, 0);
1620 if (exStyle
& WS_EX_TOOLWINDOW
)
1621 hFont
= CreateFontIndirectA (&nclm
.lfSmCaptionFont
);
1623 hFont
= CreateFontIndirectA (&nclm
.lfCaptionFont
);
1624 hOldFont
= SelectObject (hdc
, hFont
);
1625 if (active
) SetTextColor( hdc
, GetSysColor( COLOR_CAPTIONTEXT
) );
1626 else SetTextColor( hdc
, GetSysColor( COLOR_INACTIVECAPTIONTEXT
) );
1627 SetBkMode( hdc
, TRANSPARENT
);
1629 DrawTextA( hdc
, buffer
, -1, &r
,
1630 DT_SINGLELINE
| DT_VCENTER
| DT_NOPREFIX
| DT_LEFT
);
1631 DeleteObject (SelectObject (hdc
, hOldFont
));
1637 /***********************************************************************
1640 * Paint the non-client area. clip is currently unused.
1642 static void NC_DoNCPaint( WND
* wndPtr
, HRGN clip
, BOOL suppress_menupaint
)
1647 HWND hwnd
= wndPtr
->hwndSelf
;
1649 if ( wndPtr
->dwStyle
& WS_MINIMIZE
||
1650 !WIN_IsWindowDrawable( wndPtr
, 0 )) return; /* Nothing to do */
1652 active
= wndPtr
->flags
& WIN_NCACTIVATED
;
1654 TRACE_(nonclient
)("%04x %d\n", hwnd
, active
);
1656 if (!(hdc
= GetDCEx( hwnd
, (clip
> 1) ? clip
: 0, DCX_USESTYLE
| DCX_WINDOW
|
1657 ((clip
> 1) ? (DCX_INTERSECTRGN
| DCX_KEEPCLIPRGN
): 0) ))) return;
1659 if (ExcludeVisRect16( hdc
, wndPtr
->rectClient
.left
-wndPtr
->rectWindow
.left
,
1660 wndPtr
->rectClient
.top
-wndPtr
->rectWindow
.top
,
1661 wndPtr
->rectClient
.right
-wndPtr
->rectWindow
.left
,
1662 wndPtr
->rectClient
.bottom
-wndPtr
->rectWindow
.top
)
1665 ReleaseDC( hwnd
, hdc
);
1669 rect
.top
= rect
.left
= 0;
1670 rect
.right
= wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
;
1671 rect
.bottom
= wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
;
1673 SelectObject( hdc
, GetSysColorPen(COLOR_WINDOWFRAME
) );
1675 if (!(wndPtr
->flags
& WIN_MANAGED
))
1677 if (HAS_ANYFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
1679 SelectObject( hdc
, GetStockObject(NULL_BRUSH
) );
1680 Rectangle( hdc
, 0, 0, rect
.right
, rect
.bottom
);
1681 InflateRect( &rect
, -1, -1 );
1684 if (HAS_THICKFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
1685 NC_DrawFrame(hdc
, &rect
, FALSE
, active
);
1686 else if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
1687 NC_DrawFrame( hdc
, &rect
, TRUE
, active
);
1689 if ((wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
1692 r
.bottom
= rect
.top
+ GetSystemMetrics(SM_CYSIZE
);
1693 rect
.top
+= GetSystemMetrics(SM_CYSIZE
) + GetSystemMetrics(SM_CYBORDER
);
1694 NC_DrawCaption( hdc
, &r
, hwnd
, wndPtr
->dwStyle
, active
);
1698 if (HAS_MENU(wndPtr
))
1701 r
.bottom
= rect
.top
+ GetSystemMetrics(SM_CYMENU
); /* default height */
1702 rect
.top
+= MENU_DrawMenuBar( hdc
, &r
, hwnd
, suppress_menupaint
);
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" */
1714 if ((wndPtr
->dwStyle
& WS_VSCROLL
) && (wndPtr
->dwStyle
& WS_HSCROLL
))
1717 r
.left
= r
.right
- GetSystemMetrics(SM_CXVSCROLL
) + 1;
1718 r
.top
= r
.bottom
- GetSystemMetrics(SM_CYHSCROLL
) + 1;
1719 if(wndPtr
->dwStyle
& WS_BORDER
) {
1723 FillRect( hdc
, &r
, GetSysColorBrush(COLOR_SCROLLBAR
) );
1726 ReleaseDC( hwnd
, hdc
);
1730 /******************************************************************************
1732 * void NC_DoNCPaint95(
1735 * BOOL32 suppress_menupaint )
1737 * Paint the non-client area for Win95 windows. The clip region is
1738 * currently ignored.
1741 * grep -E -A10 -B5 \(95\)\|\(Bugs\)\|\(FIXME\) windows/nonclient.c \
1742 * misc/tweak.c controls/menu.c # :-)
1745 * 03-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1746 * Original implementation
1747 * 10-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1749 * 29-Jun-1999 Ove Kåven (ovek@arcticnet.no)
1750 * Streamlined window style checks.
1752 *****************************************************************************/
1754 static void NC_DoNCPaint95(
1757 BOOL suppress_menupaint
)
1760 RECT rfuzz
, rect
, rectClip
;
1762 HWND hwnd
= wndPtr
->hwndSelf
;
1764 if ( wndPtr
->dwStyle
& WS_MINIMIZE
||
1765 !WIN_IsWindowDrawable( wndPtr
, 0 )) return; /* Nothing to do */
1767 active
= wndPtr
->flags
& WIN_NCACTIVATED
;
1769 TRACE_(nonclient
)("%04x %d\n", hwnd
, active
);
1771 /* MSDN docs are pretty idiotic here, they say app CAN use clipRgn in the call to
1772 * GetDCEx implying that it is allowed not to use it either. However, the suggested
1773 * GetDCEx( , DCX_WINDOW | DCX_INTERSECTRGN) will cause clipRgn to be deleted
1774 * after ReleaseDC(). Now, how is the "system" supposed to tell what happened?
1777 if (!(hdc
= GetDCEx( hwnd
, (clip
> 1) ? clip
: 0, DCX_USESTYLE
| DCX_WINDOW
|
1778 ((clip
> 1) ?(DCX_INTERSECTRGN
| DCX_KEEPCLIPRGN
) : 0) ))) return;
1781 if (ExcludeVisRect16( hdc
, wndPtr
->rectClient
.left
-wndPtr
->rectWindow
.left
,
1782 wndPtr
->rectClient
.top
-wndPtr
->rectWindow
.top
,
1783 wndPtr
->rectClient
.right
-wndPtr
->rectWindow
.left
,
1784 wndPtr
->rectClient
.bottom
-wndPtr
->rectWindow
.top
)
1787 ReleaseDC( hwnd
, hdc
);
1791 rect
.top
= rect
.left
= 0;
1792 rect
.right
= wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
;
1793 rect
.bottom
= wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
;
1796 GetRgnBox( clip
, &rectClip
);
1803 SelectObject( hdc
, GetSysColorPen(COLOR_WINDOWFRAME
) );
1805 if(!(wndPtr
->flags
& WIN_MANAGED
)) {
1806 if (HAS_BIGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
)) {
1807 DrawEdge (hdc
, &rect
, EDGE_RAISED
, BF_RECT
| BF_ADJUST
);
1809 if (HAS_THICKFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
1810 NC_DrawFrame95(hdc
, &rect
, FALSE
, active
);
1811 else if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
1812 NC_DrawFrame95( hdc
, &rect
, TRUE
, active
);
1813 else if (HAS_THINFRAME( wndPtr
->dwStyle
)) {
1814 SelectObject( hdc
, GetStockObject(NULL_BRUSH
) );
1815 Rectangle( hdc
, 0, 0, rect
.right
, rect
.bottom
);
1818 if ((wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
1821 if (wndPtr
->dwExStyle
& WS_EX_TOOLWINDOW
) {
1822 r
.bottom
= rect
.top
+ GetSystemMetrics(SM_CYSMCAPTION
);
1823 rect
.top
+= GetSystemMetrics(SM_CYSMCAPTION
);
1826 r
.bottom
= rect
.top
+ GetSystemMetrics(SM_CYCAPTION
);
1827 rect
.top
+= GetSystemMetrics(SM_CYCAPTION
);
1829 if( !clip
|| IntersectRect( &rfuzz
, &r
, &rectClip
) )
1830 NC_DrawCaption95 (hdc
, &r
, hwnd
, wndPtr
->dwStyle
,
1831 wndPtr
->dwExStyle
, active
);
1835 if (HAS_MENU(wndPtr
))
1838 r
.bottom
= rect
.top
+ GetSystemMetrics(SM_CYMENU
);
1840 TRACE_(nonclient
)("Calling DrawMenuBar with "
1841 "rect (%d, %d)-(%d, %d)\n", r
.left
, r
.top
,
1844 rect
.top
+= MENU_DrawMenuBar( hdc
, &r
, hwnd
, suppress_menupaint
) + 1;
1847 TRACE_(nonclient
)("After MenuBar, rect is (%d, %d)-(%d, %d).\n",
1848 rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1850 if (wndPtr
->dwExStyle
& WS_EX_CLIENTEDGE
)
1851 DrawEdge (hdc
, &rect
, EDGE_SUNKEN
, BF_RECT
| BF_ADJUST
);
1853 if (wndPtr
->dwExStyle
& WS_EX_STATICEDGE
)
1854 DrawEdge (hdc
, &rect
, BDR_SUNKENOUTER
, BF_RECT
| BF_ADJUST
);
1856 /* Draw the scroll-bars */
1858 if (wndPtr
->dwStyle
& WS_VSCROLL
)
1859 SCROLL_DrawScrollBar( hwnd
, hdc
, SB_VERT
, TRUE
, TRUE
);
1860 if (wndPtr
->dwStyle
& WS_HSCROLL
)
1861 SCROLL_DrawScrollBar( hwnd
, hdc
, SB_HORZ
, TRUE
, TRUE
);
1863 /* Draw the "size-box" */
1864 if ((wndPtr
->dwStyle
& WS_VSCROLL
) && (wndPtr
->dwStyle
& WS_HSCROLL
))
1867 r
.left
= r
.right
- GetSystemMetrics(SM_CXVSCROLL
) + 1;
1868 r
.top
= r
.bottom
- GetSystemMetrics(SM_CYHSCROLL
) + 1;
1869 FillRect( hdc
, &r
, GetSysColorBrush(COLOR_SCROLLBAR
) );
1872 ReleaseDC( hwnd
, hdc
);
1878 /***********************************************************************
1881 * Handle a WM_NCPAINT message. Called from DefWindowProc().
1883 LONG
NC_HandleNCPaint( HWND hwnd
, HRGN clip
)
1885 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
1887 if( wndPtr
&& wndPtr
->dwStyle
& WS_VISIBLE
)
1889 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
1890 WINPOS_RedrawIconTitle( hwnd
);
1891 else if (TWEAK_WineLook
== WIN31_LOOK
)
1892 NC_DoNCPaint( wndPtr
, clip
, FALSE
);
1894 NC_DoNCPaint95( wndPtr
, clip
, FALSE
);
1896 WIN_ReleaseWndPtr(wndPtr
);
1901 /***********************************************************************
1902 * NC_HandleNCActivate
1904 * Handle a WM_NCACTIVATE message. Called from DefWindowProc().
1906 LONG
NC_HandleNCActivate( WND
*wndPtr
, WPARAM16 wParam
)
1910 if( wParam
) wStateChange
= !(wndPtr
->flags
& WIN_NCACTIVATED
);
1911 else wStateChange
= wndPtr
->flags
& WIN_NCACTIVATED
;
1915 if (wParam
) wndPtr
->flags
|= WIN_NCACTIVATED
;
1916 else wndPtr
->flags
&= ~WIN_NCACTIVATED
;
1918 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
1919 WINPOS_RedrawIconTitle( wndPtr
->hwndSelf
);
1920 else if (TWEAK_WineLook
== WIN31_LOOK
)
1921 NC_DoNCPaint( wndPtr
, (HRGN
)1, FALSE
);
1923 NC_DoNCPaint95( wndPtr
, (HRGN
)1, FALSE
);
1929 /***********************************************************************
1930 * NC_HandleSetCursor
1932 * Handle a WM_SETCURSOR message. Called from DefWindowProc().
1934 LONG
NC_HandleSetCursor( HWND hwnd
, WPARAM16 wParam
, LPARAM lParam
)
1936 if (hwnd
!= (HWND
)wParam
) return 0; /* Don't set the cursor for child windows */
1938 switch(LOWORD(lParam
))
1942 WORD msg
= HIWORD( lParam
);
1943 if ((msg
== WM_LBUTTONDOWN
) || (msg
== WM_MBUTTONDOWN
) ||
1944 (msg
== WM_RBUTTONDOWN
))
1951 HICON16 hCursor
= (HICON16
) GetClassWord(hwnd
, GCW_HCURSOR
);
1953 SetCursor16(hCursor
);
1961 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZEWE16
) );
1965 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZENS16
) );
1969 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZENWSE16
) );
1973 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZENESW16
) );
1976 /* Default cursor: arrow */
1977 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_ARROW16
) );
1980 /***********************************************************************
1983 BOOL
NC_GetSysPopupPos( WND
* wndPtr
, RECT
* rect
)
1985 if( wndPtr
->hSysMenu
)
1987 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
1988 GetWindowRect( wndPtr
->hwndSelf
, rect
);
1991 if (TWEAK_WineLook
== WIN31_LOOK
)
1992 NC_GetInsideRect( wndPtr
->hwndSelf
, rect
);
1994 NC_GetInsideRect95( wndPtr
->hwndSelf
, rect
);
1995 OffsetRect( rect
, wndPtr
->rectWindow
.left
, wndPtr
->rectWindow
.top
);
1996 if (wndPtr
->dwStyle
& WS_CHILD
)
1997 ClientToScreen( wndPtr
->parent
->hwndSelf
, (POINT
*)rect
);
1998 if (TWEAK_WineLook
== WIN31_LOOK
) {
1999 rect
->right
= rect
->left
+ GetSystemMetrics(SM_CXSIZE
);
2000 rect
->bottom
= rect
->top
+ GetSystemMetrics(SM_CYSIZE
);
2003 rect
->right
= rect
->left
+ GetSystemMetrics(SM_CYCAPTION
) - 1;
2004 rect
->bottom
= rect
->top
+ GetSystemMetrics(SM_CYCAPTION
) - 1;
2012 /***********************************************************************
2015 * Initialisation of a move or resize, when initiatied from a menu choice.
2016 * Return hit test code for caption or sizing border.
2018 static LONG
NC_StartSizeMove( WND
* wndPtr
, WPARAM16 wParam
,
2019 POINT16
*capturePoint
)
2026 GetWindowRect(wndPtr
->hwndSelf
,&rectWindow
);
2028 if ((wParam
& 0xfff0) == SC_MOVE
)
2030 /* Move pointer at the center of the caption */
2032 if (TWEAK_WineLook
== WIN31_LOOK
)
2033 NC_GetInsideRect( wndPtr
->hwndSelf
, &rect
);
2035 NC_GetInsideRect95( wndPtr
->hwndSelf
, &rect
);
2036 if (wndPtr
->dwStyle
& WS_SYSMENU
)
2037 rect
.left
+= GetSystemMetrics(SM_CXSIZE
) + 1;
2038 if (wndPtr
->dwStyle
& WS_MINIMIZEBOX
)
2039 rect
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
2040 if (wndPtr
->dwStyle
& WS_MAXIMIZEBOX
)
2041 rect
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
2042 pt
.x
= rectWindow
.left
+ (rect
.right
- rect
.left
) / 2;
2043 pt
.y
= rectWindow
.top
+ rect
.top
+ GetSystemMetrics(SM_CYSIZE
)/2;
2044 hittest
= HTCAPTION
;
2051 MSG_InternalGetMessage( &msg
, 0, 0, MSGF_SIZE
, PM_REMOVE
, FALSE
, NULL
);
2055 CONV_POINT32TO16(&msg
.pt
, &pt
);
2056 hittest
= NC_HandleNCHitTest( wndPtr
->hwndSelf
, pt
);
2057 if ((hittest
< HTLEFT
) || (hittest
> HTBOTTOMRIGHT
))
2069 pt
.x
=(rectWindow
.left
+rectWindow
.right
)/2;
2070 pt
.y
= rectWindow
.top
+ GetSystemMetrics(SM_CYFRAME
) / 2;
2074 pt
.x
=(rectWindow
.left
+rectWindow
.right
)/2;
2075 pt
.y
= rectWindow
.bottom
- GetSystemMetrics(SM_CYFRAME
) / 2;
2079 pt
.x
= rectWindow
.left
+ GetSystemMetrics(SM_CXFRAME
) / 2;
2080 pt
.y
=(rectWindow
.top
+rectWindow
.bottom
)/2;
2084 pt
.x
= rectWindow
.right
- GetSystemMetrics(SM_CXFRAME
) / 2;
2085 pt
.y
=(rectWindow
.top
+rectWindow
.bottom
)/2;
2088 case VK_ESCAPE
: return 0;
2094 SetCursorPos( pt
.x
, pt
.y
);
2095 NC_HandleSetCursor( wndPtr
->hwndSelf
,
2096 wndPtr
->hwndSelf
, MAKELONG( hittest
, WM_MOUSEMOVE
));
2101 /***********************************************************************
2104 * Perform SC_MOVE and SC_SIZE commands. `
2106 static void NC_DoSizeMove( HWND hwnd
, WORD wParam
)
2109 RECT sizingRect
, mouseRect
;
2111 LONG hittest
= (LONG
)(wParam
& 0x0f);
2112 HCURSOR16 hDragCursor
= 0, hOldCursor
= 0;
2113 POINT minTrack
, maxTrack
;
2114 POINT16 capturePoint
, pt
;
2115 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
2116 BOOL thickframe
= HAS_THICKFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
);
2117 BOOL iconic
= wndPtr
->dwStyle
& WS_MINIMIZE
;
2119 DWORD dwPoint
= GetMessagePos ();
2121 capturePoint
= pt
= *(POINT16
*)&dwPoint
;
2123 if (IsZoomed(hwnd
) || !IsWindowVisible(hwnd
) ||
2124 (wndPtr
->flags
& WIN_MANAGED
)) goto END
;
2126 if ((wParam
& 0xfff0) == SC_MOVE
)
2128 if (!(wndPtr
->dwStyle
& WS_CAPTION
)) goto END
;
2130 hittest
= NC_StartSizeMove( wndPtr
, wParam
, &capturePoint
);
2131 if (!hittest
) goto END
;
2135 if (!thickframe
) goto END
;
2136 if ( hittest
&& hittest
!= HTSYSMENU
) hittest
+= 2;
2140 hittest
= NC_StartSizeMove( wndPtr
, wParam
, &capturePoint
);
2149 /* Get min/max info */
2151 WINPOS_GetMinMaxInfo( wndPtr
, NULL
, NULL
, &minTrack
, &maxTrack
);
2152 sizingRect
= wndPtr
->rectWindow
;
2153 if (wndPtr
->dwStyle
& WS_CHILD
)
2154 GetClientRect( wndPtr
->parent
->hwndSelf
, &mouseRect
);
2156 SetRect(&mouseRect
, 0, 0, GetSystemMetrics(SM_CXSCREEN
), GetSystemMetrics(SM_CYSCREEN
));
2157 if (ON_LEFT_BORDER(hittest
))
2159 mouseRect
.left
= MAX( mouseRect
.left
, sizingRect
.right
-maxTrack
.x
);
2160 mouseRect
.right
= MIN( mouseRect
.right
, sizingRect
.right
-minTrack
.x
);
2162 else if (ON_RIGHT_BORDER(hittest
))
2164 mouseRect
.left
= MAX( mouseRect
.left
, sizingRect
.left
+minTrack
.x
);
2165 mouseRect
.right
= MIN( mouseRect
.right
, sizingRect
.left
+maxTrack
.x
);
2167 if (ON_TOP_BORDER(hittest
))
2169 mouseRect
.top
= MAX( mouseRect
.top
, sizingRect
.bottom
-maxTrack
.y
);
2170 mouseRect
.bottom
= MIN( mouseRect
.bottom
,sizingRect
.bottom
-minTrack
.y
);
2172 else if (ON_BOTTOM_BORDER(hittest
))
2174 mouseRect
.top
= MAX( mouseRect
.top
, sizingRect
.top
+minTrack
.y
);
2175 mouseRect
.bottom
= MIN( mouseRect
.bottom
, sizingRect
.top
+maxTrack
.y
);
2177 if (wndPtr
->dwStyle
& WS_CHILD
)
2179 MapWindowPoints( wndPtr
->parent
->hwndSelf
, 0,
2180 (LPPOINT
)&mouseRect
, 2 );
2182 SendMessage16( hwnd
, WM_ENTERSIZEMOVE
, 0, 0 );
2184 if (GetCapture() != hwnd
) SetCapture( hwnd
);
2186 if (wndPtr
->dwStyle
& WS_CHILD
)
2188 /* Retrieve a default cache DC (without using the window style) */
2189 hdc
= GetDCEx( wndPtr
->parent
->hwndSelf
, 0, DCX_CACHE
);
2192 { /* Grab the server only when moving top-level windows without desktop */
2196 wndPtr
->pDriver
->pPreSizeMove(wndPtr
);
2198 if( iconic
) /* create a cursor for dragging */
2200 HICON16 hIcon
= GetClassWord(wndPtr
->hwndSelf
, GCW_HICON
);
2201 if(!hIcon
) hIcon
= (HICON16
) SendMessage16( hwnd
, WM_QUERYDRAGICON
, 0, 0L);
2202 if( hIcon
) hDragCursor
= CURSORICON_IconToCursor( hIcon
, TRUE
);
2203 if( !hDragCursor
) iconic
= FALSE
;
2206 if( !iconic
) NC_DrawMovingFrame( hdc
, &sizingRect
, thickframe
);
2212 MSG_InternalGetMessage( &msg
, 0, 0, MSGF_SIZE
, PM_REMOVE
, FALSE
, NULL
);
2214 /* Exit on button-up, Return, or Esc */
2215 if ((msg
.message
== WM_LBUTTONUP
) ||
2216 ((msg
.message
== WM_KEYDOWN
) &&
2217 ((msg
.wParam
== VK_RETURN
) || (msg
.wParam
== VK_ESCAPE
)))) break;
2219 if ((msg
.message
!= WM_KEYDOWN
) && (msg
.message
!= WM_MOUSEMOVE
))
2220 continue; /* We are not interested in other messages */
2222 dwPoint
= GetMessagePos ();
2223 pt
= *(POINT16
*)&dwPoint
;
2225 if (msg
.message
== WM_KEYDOWN
) switch(msg
.wParam
)
2227 case VK_UP
: pt
.y
-= 8; break;
2228 case VK_DOWN
: pt
.y
+= 8; break;
2229 case VK_LEFT
: pt
.x
-= 8; break;
2230 case VK_RIGHT
: pt
.x
+= 8; break;
2233 pt
.x
= MAX( pt
.x
, mouseRect
.left
);
2234 pt
.x
= MIN( pt
.x
, mouseRect
.right
);
2235 pt
.y
= MAX( pt
.y
, mouseRect
.top
);
2236 pt
.y
= MIN( pt
.y
, mouseRect
.bottom
);
2238 dx
= pt
.x
- capturePoint
.x
;
2239 dy
= pt
.y
- capturePoint
.y
;
2246 if( iconic
) /* ok, no system popup tracking */
2248 hOldCursor
= SetCursor(hDragCursor
);
2250 WINPOS_ShowIconTitle( wndPtr
, FALSE
);
2254 if (msg
.message
== WM_KEYDOWN
) SetCursorPos( pt
.x
, pt
.y
);
2257 RECT newRect
= sizingRect
;
2259 if (hittest
== HTCAPTION
) OffsetRect( &newRect
, dx
, dy
);
2260 if (ON_LEFT_BORDER(hittest
)) newRect
.left
+= dx
;
2261 else if (ON_RIGHT_BORDER(hittest
)) newRect
.right
+= dx
;
2262 if (ON_TOP_BORDER(hittest
)) newRect
.top
+= dy
;
2263 else if (ON_BOTTOM_BORDER(hittest
)) newRect
.bottom
+= dy
;
2266 NC_DrawMovingFrame( hdc
, &sizingRect
, thickframe
);
2267 NC_DrawMovingFrame( hdc
, &newRect
, thickframe
);
2270 sizingRect
= newRect
;
2278 if( moved
) /* restore cursors, show icon title later on */
2280 ShowCursor( FALSE
);
2281 SetCursor( hOldCursor
);
2283 DestroyCursor( hDragCursor
);
2286 NC_DrawMovingFrame( hdc
, &sizingRect
, thickframe
);
2288 if (wndPtr
->dwStyle
& WS_CHILD
)
2289 ReleaseDC( wndPtr
->parent
->hwndSelf
, hdc
);
2292 ReleaseDC( 0, hdc
);
2295 wndPtr
->pDriver
->pPostSizeMove(wndPtr
);
2297 if (HOOK_IsHooked( WH_CBT
))
2299 RECT16
* pr
= SEGPTR_NEW(RECT16
);
2302 CONV_RECT32TO16( &sizingRect
, pr
);
2303 if( HOOK_CallHooks16( WH_CBT
, HCBT_MOVESIZE
, hwnd
,
2304 (LPARAM
)SEGPTR_GET(pr
)) )
2305 sizingRect
= wndPtr
->rectWindow
;
2307 CONV_RECT16TO32( pr
, &sizingRect
);
2311 SendMessage16( hwnd
, WM_EXITSIZEMOVE
, 0, 0 );
2312 SendMessage16( hwnd
, WM_SETVISIBLE
, !IsIconic16(hwnd
), 0L);
2314 /* window moved or resized */
2317 /* if the moving/resizing isn't canceled call SetWindowPos
2318 * with the new position or the new size of the window
2320 if (!((msg
.message
== WM_KEYDOWN
) && (msg
.wParam
== VK_ESCAPE
)) )
2322 /* NOTE: SWP_NOACTIVATE prevents document window activation in Word 6 */
2323 SetWindowPos( hwnd
, 0, sizingRect
.left
, sizingRect
.top
,
2324 sizingRect
.right
- sizingRect
.left
,
2325 sizingRect
.bottom
- sizingRect
.top
,
2326 ( hittest
== HTCAPTION
) ? SWP_NOSIZE
: 0 );
2330 if( IsWindow(hwnd
) )
2331 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
2333 /* Single click brings up the system menu when iconized */
2337 if( wndPtr
->dwStyle
& WS_SYSMENU
)
2338 SendMessage16( hwnd
, WM_SYSCOMMAND
,
2339 SC_MOUSEMENU
+ HTSYSMENU
, *((LPARAM
*)&pt
));
2341 else WINPOS_ShowIconTitle( wndPtr
, TRUE
);
2345 WIN_ReleaseWndPtr(wndPtr
);
2349 /***********************************************************************
2350 * NC_TrackMinMaxBox95
2352 * Track a mouse button press on the minimize or maximize box.
2354 * The big difference between 3.1 and 95 is the disabled button state.
2355 * In win95 the system button can be disabled, so it can ignore the mouse
2359 static void NC_TrackMinMaxBox95( HWND hwnd
, WORD wParam
)
2363 HDC hdc
= GetWindowDC( hwnd
);
2364 BOOL pressed
= TRUE
;
2366 DWORD wndStyle
= GetWindowLongA( hwnd
, GWL_STYLE
);
2367 HMENU hSysMenu
= GetSystemMenu(hwnd
, FALSE
);
2369 void (*paintButton
)(HWND
, HDC16
, BOOL
, BOOL
);
2371 if (wParam
== HTMINBUTTON
)
2373 /* If the style is not present, do nothing */
2374 if (!(wndStyle
& WS_MINIMIZEBOX
))
2377 /* Check if the sysmenu item for minimize is there */
2378 state
= GetMenuState(hSysMenu
, SC_MINIMIZE
, MF_BYCOMMAND
);
2380 paintButton
= &NC_DrawMinButton95
;
2384 /* If the style is not present, do nothing */
2385 if (!(wndStyle
& WS_MAXIMIZEBOX
))
2388 /* Check if the sysmenu item for maximize is there */
2389 state
= GetMenuState(hSysMenu
, SC_MAXIMIZE
, MF_BYCOMMAND
);
2391 paintButton
= &NC_DrawMaxButton95
;
2396 (*paintButton
)( hwnd
, hdc
, TRUE
, FALSE
);
2400 BOOL oldstate
= pressed
;
2401 MSG_InternalGetMessage( &msg
, 0, 0, 0, PM_REMOVE
, FALSE
, NULL
);
2402 CONV_POINT32TO16( &msg
.pt
, &pt16
);
2404 pressed
= (NC_HandleNCHitTest( hwnd
, pt16
) == wParam
);
2405 if (pressed
!= oldstate
)
2406 (*paintButton
)( hwnd
, hdc
, pressed
, FALSE
);
2407 } while (msg
.message
!= WM_LBUTTONUP
);
2409 (*paintButton
)( hwnd
, hdc
, FALSE
, FALSE
);
2412 ReleaseDC( hwnd
, hdc
);
2414 /* If the item minimize or maximize of the sysmenu are not there */
2415 /* or if the style is not present, do nothing */
2416 if ((!pressed
) || (state
== 0xFFFFFFFF))
2419 if (wParam
== HTMINBUTTON
)
2420 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MINIMIZE
, *(LONG
*)&pt16
);
2422 SendMessage16( hwnd
, WM_SYSCOMMAND
,
2423 IsZoomed(hwnd
) ? SC_RESTORE
:SC_MAXIMIZE
, *(LONG
*)&pt16
);
2426 /***********************************************************************
2429 * Track a mouse button press on the minimize or maximize box.
2431 static void NC_TrackMinMaxBox( HWND hwnd
, WORD wParam
)
2435 HDC hdc
= GetWindowDC( hwnd
);
2436 BOOL pressed
= TRUE
;
2437 void (*paintButton
)(HWND
, HDC16
, BOOL
);
2441 if (wParam
== HTMINBUTTON
)
2442 paintButton
= &NC_DrawMinButton
;
2444 paintButton
= &NC_DrawMaxButton
;
2446 (*paintButton
)( hwnd
, hdc
, TRUE
);
2450 BOOL oldstate
= pressed
;
2451 MSG_InternalGetMessage( &msg
, 0, 0, 0, PM_REMOVE
, FALSE
, NULL
);
2452 CONV_POINT32TO16( &msg
.pt
, &pt16
);
2454 pressed
= (NC_HandleNCHitTest( hwnd
, pt16
) == wParam
);
2455 if (pressed
!= oldstate
)
2456 (*paintButton
)( hwnd
, hdc
, pressed
);
2457 } while (msg
.message
!= WM_LBUTTONUP
);
2459 (*paintButton
)( hwnd
, hdc
, FALSE
);
2462 ReleaseDC( hwnd
, hdc
);
2464 if (!pressed
) return;
2466 if (wParam
== HTMINBUTTON
)
2467 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MINIMIZE
, *(LONG
*)&pt16
);
2469 SendMessage16( hwnd
, WM_SYSCOMMAND
,
2470 IsZoomed(hwnd
) ? SC_RESTORE
:SC_MAXIMIZE
, *(LONG
*)&pt16
);
2474 /***********************************************************************
2475 * NC_TrackCloseButton95
2477 * Track a mouse button press on the Win95 close button.
2480 NC_TrackCloseButton95 (HWND hwnd
, WORD wParam
)
2485 BOOL pressed
= TRUE
;
2486 HMENU hSysMenu
= GetSystemMenu(hwnd
, FALSE
);
2492 state
= GetMenuState(hSysMenu
, SC_CLOSE
, MF_BYCOMMAND
);
2494 /* If the item close of the sysmenu is disabled or not there do nothing */
2495 if((state
& MF_DISABLED
) || (state
& MF_GRAYED
) || (state
== 0xFFFFFFFF))
2498 hdc
= GetWindowDC( hwnd
);
2502 NC_DrawCloseButton95 (hwnd
, hdc
, TRUE
, FALSE
);
2506 BOOL oldstate
= pressed
;
2507 MSG_InternalGetMessage( &msg
, 0, 0, 0, PM_REMOVE
, FALSE
, NULL
);
2508 CONV_POINT32TO16( &msg
.pt
, &pt16
);
2510 pressed
= (NC_HandleNCHitTest( hwnd
, pt16
) == wParam
);
2511 if (pressed
!= oldstate
)
2512 NC_DrawCloseButton95 (hwnd
, hdc
, pressed
, FALSE
);
2513 } while (msg
.message
!= WM_LBUTTONUP
);
2515 NC_DrawCloseButton95 (hwnd
, hdc
, FALSE
, FALSE
);
2518 ReleaseDC( hwnd
, hdc
);
2519 if (!pressed
) return;
2521 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_CLOSE
, *(LONG
*)&pt16
);
2525 /***********************************************************************
2528 * Track a mouse button press on the horizontal or vertical scroll-bar.
2530 static void NC_TrackScrollBar( HWND hwnd
, WPARAM wParam
, POINT pt
)
2534 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
2536 if ((wParam
& 0xfff0) == SC_HSCROLL
)
2538 if ((wParam
& 0x0f) != HTHSCROLL
) goto END
;
2539 scrollbar
= SB_HORZ
;
2541 else /* SC_VSCROLL */
2543 if ((wParam
& 0x0f) != HTVSCROLL
) goto END
;
2544 scrollbar
= SB_VERT
;
2547 if (!(msg
= SEGPTR_NEW(MSG16
))) goto END
;
2548 pt
.x
-= wndPtr
->rectWindow
.left
;
2549 pt
.y
-= wndPtr
->rectWindow
.top
;
2551 SCROLL_HandleScrollEvent( hwnd
, scrollbar
, WM_LBUTTONDOWN
, pt
);
2555 GetMessage16( SEGPTR_GET(msg
), 0, 0, 0 );
2556 switch(msg
->message
)
2561 pt
.x
= LOWORD(msg
->lParam
) + wndPtr
->rectClient
.left
-
2562 wndPtr
->rectWindow
.left
;
2563 pt
.y
= HIWORD(msg
->lParam
) + wndPtr
->rectClient
.top
-
2564 wndPtr
->rectWindow
.top
;
2565 SCROLL_HandleScrollEvent( hwnd
, scrollbar
, msg
->message
, pt
);
2568 TranslateMessage16( msg
);
2569 DispatchMessage16( msg
);
2572 if (!IsWindow( hwnd
))
2577 } while (msg
->message
!= WM_LBUTTONUP
);
2580 WIN_ReleaseWndPtr(wndPtr
);
2583 /***********************************************************************
2584 * NC_HandleNCLButtonDown
2586 * Handle a WM_NCLBUTTONDOWN message. Called from DefWindowProc().
2588 LONG
NC_HandleNCLButtonDown( WND
* pWnd
, WPARAM16 wParam
, LPARAM lParam
)
2590 HWND hwnd
= pWnd
->hwndSelf
;
2592 switch(wParam
) /* Hit test */
2595 hwnd
= WIN_GetTopParent(hwnd
);
2597 if( WINPOS_SetActiveWindow(hwnd
, TRUE
, TRUE
) || (GetActiveWindow() == hwnd
) )
2598 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_MOVE
+ HTCAPTION
, lParam
);
2602 if( pWnd
->dwStyle
& WS_SYSMENU
)
2604 if( !(pWnd
->dwStyle
& WS_MINIMIZE
) )
2606 HDC hDC
= GetWindowDC(hwnd
);
2607 if (TWEAK_WineLook
== WIN31_LOOK
)
2608 NC_DrawSysButton( hwnd
, hDC
, TRUE
);
2610 NC_DrawSysButton95( hwnd
, hDC
, TRUE
);
2611 ReleaseDC( hwnd
, hDC
);
2613 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MOUSEMENU
+ HTSYSMENU
, lParam
);
2618 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MOUSEMENU
, lParam
);
2622 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_HSCROLL
+ HTHSCROLL
, lParam
);
2626 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_VSCROLL
+ HTVSCROLL
, lParam
);
2631 if (TWEAK_WineLook
== WIN31_LOOK
)
2632 NC_TrackMinMaxBox( hwnd
, wParam
);
2634 NC_TrackMinMaxBox95( hwnd
, wParam
);
2638 if (TWEAK_WineLook
>= WIN95_LOOK
)
2639 NC_TrackCloseButton95 (hwnd
, wParam
);
2650 /* make sure hittest fits into 0xf and doesn't overlap with HTSYSMENU */
2651 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_SIZE
+ wParam
- 2, lParam
);
2661 /***********************************************************************
2662 * NC_HandleNCLButtonDblClk
2664 * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc().
2666 LONG
NC_HandleNCLButtonDblClk( WND
*pWnd
, WPARAM16 wParam
, LPARAM lParam
)
2669 * if this is an icon, send a restore since we are handling
2672 if (pWnd
->dwStyle
& WS_MINIMIZE
)
2674 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_RESTORE
, lParam
);
2678 switch(wParam
) /* Hit test */
2681 /* stop processing if WS_MAXIMIZEBOX is missing */
2682 if (pWnd
->dwStyle
& WS_MAXIMIZEBOX
)
2683 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
,
2684 (pWnd
->dwStyle
& WS_MAXIMIZE
) ? SC_RESTORE
: SC_MAXIMIZE
,
2689 if (!(GetClassWord(pWnd
->hwndSelf
, GCW_STYLE
) & CS_NOCLOSE
))
2690 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_CLOSE
, lParam
);
2694 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_HSCROLL
+ HTHSCROLL
,
2699 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_VSCROLL
+ HTVSCROLL
,
2707 /***********************************************************************
2708 * NC_HandleSysCommand
2710 * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
2712 LONG
NC_HandleSysCommand( HWND hwnd
, WPARAM16 wParam
, POINT16 pt
)
2714 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
2716 UINT16 uCommand
= wParam
& 0xFFF0;
2718 TRACE_(nonclient
)("Handling WM_SYSCOMMAND %x %d,%d\n",
2719 wParam
, pt
.x
, pt
.y
);
2721 if (wndPtr
->dwStyle
& WS_CHILD
&& uCommand
!= SC_KEYMENU
)
2722 ScreenToClient16( wndPtr
->parent
->hwndSelf
, &pt
);
2728 NC_DoSizeMove( hwnd
, wParam
);
2732 if (hwnd
== GetForegroundWindow())
2733 ShowOwnedPopups(hwnd
,FALSE
);
2734 ShowWindow( hwnd
, SW_MINIMIZE
);
2738 if (IsIconic(hwnd
) && hwnd
== GetForegroundWindow())
2739 ShowOwnedPopups(hwnd
,TRUE
);
2740 ShowWindow( hwnd
, SW_MAXIMIZE
);
2744 if (IsIconic(hwnd
) && hwnd
== GetForegroundWindow())
2745 ShowOwnedPopups(hwnd
,TRUE
);
2746 ShowWindow( hwnd
, SW_RESTORE
);
2750 WIN_ReleaseWndPtr(wndPtr
);
2751 return SendMessage16( hwnd
, WM_CLOSE
, 0, 0 );
2755 CONV_POINT16TO32( &pt
, &pt32
);
2756 NC_TrackScrollBar( hwnd
, wParam
, pt32
);
2760 CONV_POINT16TO32( &pt
, &pt32
);
2761 MENU_TrackMouseMenuBar( wndPtr
, wParam
& 0x000F, pt32
);
2765 MENU_TrackKbdMenuBar( wndPtr
, wParam
, pt
.x
);
2769 WinExec( "taskman.exe", SW_SHOWNORMAL
);
2773 if (wParam
== SC_ABOUTWINE
)
2774 ShellAboutA(hwnd
,"Wine", WINE_RELEASE_INFO
, 0);
2776 if (wParam
== SC_PUTMARK
)
2777 TRACE_(shell
)("Mark requested by user\n");
2784 FIXME_(nonclient
)("unimplemented!\n");
2787 WIN_ReleaseWndPtr(wndPtr
);
2791 /*************************************************************
2794 * Stub for the grayed button of the caption
2796 *************************************************************/
2798 BOOL
NC_DrawGrayButton(HDC hdc
, int x
, int y
)
2801 HDC hdcMask
= CreateCompatibleDC (0);
2804 hMaskBmp
= CreateBitmap (12, 10, 1, 1, lpGrayMask
);
2809 SelectObject (hdcMask
, hMaskBmp
);
2811 /* Draw the grayed bitmap using the mask */
2812 hOldBrush
= SelectObject (hdc
, RGB(128, 128, 128));
2813 BitBlt (hdc
, x
, y
, 12, 10,
2814 hdcMask
, 0, 0, 0xB8074A);
2817 SelectObject (hdc
, hOldBrush
);
2818 DeleteObject(hMaskBmp
);