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 !((exStyle) & WS_EX_DLGMODALFRAME))
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
) && Options
.managed
&&
100 (((style
& WS_CAPTION
) == WS_CAPTION
) ||
101 (style
& WS_THICKFRAME
)))
106 /***********************************************************************
109 * Compute the size of the window rectangle from the size of the
112 static void NC_AdjustRect( LPRECT16 rect
, DWORD style
, BOOL menu
,
115 if (TWEAK_WineLook
> WIN31_LOOK
)
116 ERR_(nonclient
)("Called in Win95 mode. Aiee! Please report this.\n" );
118 if(style
& WS_ICONIC
) return;
119 /* Decide if the window will be managed (see CreateWindowEx) */
120 if (!WIN_WindowNeedsWMBorder(style
, exStyle
))
122 if (HAS_THICKFRAME( style
, exStyle
))
123 InflateRect16( rect
, GetSystemMetrics(SM_CXFRAME
), GetSystemMetrics(SM_CYFRAME
) );
125 if (HAS_DLGFRAME( style
, exStyle
))
126 InflateRect16( rect
, GetSystemMetrics(SM_CXDLGFRAME
), GetSystemMetrics(SM_CYDLGFRAME
) );
128 if (HAS_THINFRAME( style
))
129 InflateRect16( rect
, GetSystemMetrics(SM_CXBORDER
), GetSystemMetrics(SM_CYBORDER
));
131 if ((style
& WS_CAPTION
) == WS_CAPTION
)
132 rect
->top
-= GetSystemMetrics(SM_CYCAPTION
) - GetSystemMetrics(SM_CYBORDER
);
134 if (menu
) rect
->top
-= GetSystemMetrics(SM_CYMENU
) + GetSystemMetrics(SM_CYBORDER
);
136 if (style
& WS_VSCROLL
) {
137 rect
->right
+= GetSystemMetrics(SM_CXVSCROLL
) - 1;
138 if(!HAS_ANYFRAME( style
, exStyle
))
142 if (style
& WS_HSCROLL
) {
143 rect
->bottom
+= GetSystemMetrics(SM_CYHSCROLL
) - 1;
144 if(!HAS_ANYFRAME( style
, exStyle
))
150 /******************************************************************************
151 * NC_AdjustRectOuter95
153 * Computes the size of the "outside" parts of the window based on the
154 * parameters of the client area.
163 * "Outer" parts of a window means the whole window frame, caption and
164 * menu bar. It does not include "inner" parts of the frame like client
165 * edge, static edge or scroll bars.
168 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
169 * Original (NC_AdjustRect95) cut & paste from NC_AdjustRect
171 * 20-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
172 * Split NC_AdjustRect95 into NC_AdjustRectOuter95 and
173 * NC_AdjustRectInner95 and added handling of Win95 styles.
175 * 28-Jul-1999 Ove Kåven (ovek@arcticnet.no)
176 * Streamlined window style checks.
178 *****************************************************************************/
181 NC_AdjustRectOuter95 (LPRECT16 rect
, DWORD style
, BOOL menu
, DWORD exStyle
)
183 if(style
& WS_ICONIC
) return;
185 /* Decide if the window will be managed (see CreateWindowEx) */
186 if (!WIN_WindowNeedsWMBorder(style
, exStyle
))
188 if (HAS_THICKFRAME( style
, exStyle
))
189 InflateRect16( rect
, GetSystemMetrics(SM_CXFRAME
), GetSystemMetrics(SM_CYFRAME
) );
191 if (HAS_DLGFRAME( style
, exStyle
))
192 InflateRect16(rect
, GetSystemMetrics(SM_CXDLGFRAME
), GetSystemMetrics(SM_CYDLGFRAME
) );
194 if (HAS_THINFRAME( style
))
195 InflateRect16( rect
, GetSystemMetrics(SM_CXBORDER
), GetSystemMetrics(SM_CYBORDER
));
197 if ((style
& WS_CAPTION
) == WS_CAPTION
)
199 if (exStyle
& WS_EX_TOOLWINDOW
)
200 rect
->top
-= GetSystemMetrics(SM_CYSMCAPTION
);
202 rect
->top
-= GetSystemMetrics(SM_CYCAPTION
);
207 rect
->top
-= GetSystemMetrics(SM_CYMENU
);
211 /******************************************************************************
212 * NC_AdjustRectInner95
214 * Computes the size of the "inside" part of the window based on the
215 * parameters of the client area.
223 * "Inner" part of a window means the window frame inside of the flat
224 * window frame. It includes the client edge, the static edge and the
228 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
229 * Original (NC_AdjustRect95) cut & paste from NC_AdjustRect
231 * 20-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
232 * Split NC_AdjustRect95 into NC_AdjustRectOuter95 and
233 * NC_AdjustRectInner95 and added handling of Win95 styles.
235 *****************************************************************************/
238 NC_AdjustRectInner95 (LPRECT16 rect
, DWORD style
, DWORD exStyle
)
240 if(style
& WS_ICONIC
) return;
242 if (exStyle
& WS_EX_CLIENTEDGE
)
243 InflateRect16 (rect
, GetSystemMetrics(SM_CXEDGE
), GetSystemMetrics(SM_CYEDGE
));
245 if (exStyle
& WS_EX_STATICEDGE
)
246 InflateRect16 (rect
, GetSystemMetrics(SM_CXBORDER
), GetSystemMetrics(SM_CYBORDER
));
248 if (style
& WS_VSCROLL
) rect
->right
+= GetSystemMetrics(SM_CXVSCROLL
);
249 if (style
& WS_HSCROLL
) rect
->bottom
+= GetSystemMetrics(SM_CYHSCROLL
);
253 /***********************************************************************
254 * DrawCaption16 [USER.660] Draws a caption bar
268 DrawCaption16 (HWND16 hwnd
, HDC16 hdc
, const RECT16
*rect
, UINT16 uFlags
)
273 CONV_RECT16TO32 (rect
, &rect32
);
275 return (BOOL16
)DrawCaptionTempA (hwnd
, hdc
, rect
? &rect32
: NULL
,
276 0, 0, NULL
, uFlags
& 0x1F);
280 /***********************************************************************
281 * DrawCaption32 [USER32.154] Draws a caption bar
295 DrawCaption (HWND hwnd
, HDC hdc
, const RECT
*lpRect
, UINT uFlags
)
297 return DrawCaptionTempA (hwnd
, hdc
, lpRect
, 0, 0, NULL
, uFlags
& 0x1F);
301 /***********************************************************************
302 * DrawCaptionTemp16 [USER.657]
312 DrawCaptionTemp16 (HWND16 hwnd
, HDC16 hdc
, const RECT16
*rect
, HFONT16 hFont
,
313 HICON16 hIcon
, LPCSTR str
, UINT16 uFlags
)
318 CONV_RECT16TO32(rect
,&rect32
);
320 return (BOOL16
)DrawCaptionTempA (hwnd
, hdc
, rect
?&rect32
:NULL
, hFont
,
321 hIcon
, str
, uFlags
& 0x1F);
325 /***********************************************************************
326 * DrawCaptionTemp32A [USER32.599]
336 DrawCaptionTempA (HWND hwnd
, HDC hdc
, const RECT
*rect
, HFONT hFont
,
337 HICON hIcon
, LPCSTR str
, UINT uFlags
)
341 TRACE_(nonclient
)("(%08x,%08x,%p,%08x,%08x,\"%s\",%08x)\n",
342 hwnd
, hdc
, rect
, hFont
, hIcon
, str
, uFlags
);
344 /* drawing background */
345 if (uFlags
& DC_INBUTTON
) {
346 FillRect (hdc
, &rc
, GetSysColorBrush (COLOR_3DFACE
));
348 if (uFlags
& DC_ACTIVE
) {
349 HBRUSH hbr
= SelectObject (hdc
, CACHE_GetPattern55AABrush ());
350 PatBlt (hdc
, rc
.left
, rc
.top
,
351 rc
.right
-rc
.left
, rc
.bottom
-rc
.top
, 0xFA0089);
352 SelectObject (hdc
, hbr
);
356 FillRect (hdc
, &rc
, GetSysColorBrush ((uFlags
& DC_ACTIVE
) ?
357 COLOR_ACTIVECAPTION
: COLOR_INACTIVECAPTION
));
362 if ((uFlags
& DC_ICON
) && !(uFlags
& DC_SMALLCAP
)) {
366 pt
.y
= (rc
.bottom
+ rc
.top
- GetSystemMetrics(SM_CYSMICON
)) / 2;
369 DrawIconEx (hdc
, pt
.x
, pt
.y
, hIcon
, GetSystemMetrics(SM_CXSMICON
),
370 GetSystemMetrics(SM_CYSMICON
), 0, 0, DI_NORMAL
);
373 HICON hAppIcon
= (HICON
) GetClassLongA(hwnd
, GCL_HICONSM
);
374 if(!hAppIcon
) hAppIcon
= (HICON
) GetClassLongA(hwnd
, GCL_HICON
);
376 DrawIconEx (hdc
, pt
.x
, pt
.y
, hAppIcon
, GetSystemMetrics(SM_CXSMICON
),
377 GetSystemMetrics(SM_CYSMICON
), 0, 0, DI_NORMAL
);
380 rc
.left
+= (rc
.bottom
- rc
.top
);
384 if (uFlags
& DC_TEXT
) {
387 if (uFlags
& DC_INBUTTON
)
388 SetTextColor (hdc
, GetSysColor (COLOR_BTNTEXT
));
389 else if (uFlags
& DC_ACTIVE
)
390 SetTextColor (hdc
, GetSysColor (COLOR_CAPTIONTEXT
));
392 SetTextColor (hdc
, GetSysColor (COLOR_INACTIVECAPTIONTEXT
));
394 SetBkMode (hdc
, TRANSPARENT
);
397 hOldFont
= SelectObject (hdc
, hFont
);
399 NONCLIENTMETRICSA nclm
;
401 nclm
.cbSize
= sizeof(NONCLIENTMETRICSA
);
402 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS
, 0, &nclm
, 0);
403 hNewFont
= CreateFontIndirectA ((uFlags
& DC_SMALLCAP
) ?
404 &nclm
.lfSmCaptionFont
: &nclm
.lfCaptionFont
);
405 hOldFont
= SelectObject (hdc
, hNewFont
);
409 DrawTextA (hdc
, str
, -1, &rc
,
410 DT_SINGLELINE
| DT_VCENTER
| DT_NOPREFIX
| DT_LEFT
);
414 nLen
= GetWindowTextA (hwnd
, szText
, 128);
415 DrawTextA (hdc
, szText
, nLen
, &rc
,
416 DT_SINGLELINE
| DT_VCENTER
| DT_NOPREFIX
| DT_LEFT
);
420 SelectObject (hdc
, hOldFont
);
422 DeleteObject (SelectObject (hdc
, hOldFont
));
425 /* drawing focus ??? */
427 FIXME_(nonclient
)("undocumented flag (0x2000)!\n");
433 /***********************************************************************
434 * DrawCaptionTemp32W [USER32.602]
444 DrawCaptionTempW (HWND hwnd
, HDC hdc
, const RECT
*rect
, HFONT hFont
,
445 HICON hIcon
, LPCWSTR str
, UINT uFlags
)
447 LPSTR p
= HEAP_strdupWtoA (GetProcessHeap (), 0, str
);
448 BOOL res
= DrawCaptionTempA (hwnd
, hdc
, rect
, hFont
, hIcon
, p
, uFlags
);
449 HeapFree (GetProcessHeap (), 0, p
);
454 /***********************************************************************
455 * AdjustWindowRect16 (USER.102)
457 BOOL16 WINAPI
AdjustWindowRect16( LPRECT16 rect
, DWORD style
, BOOL16 menu
)
459 return AdjustWindowRectEx16( rect
, style
, menu
, 0 );
463 /***********************************************************************
464 * AdjustWindowRect32 (USER32.2)
466 BOOL WINAPI
AdjustWindowRect( LPRECT rect
, DWORD style
, BOOL menu
)
468 return AdjustWindowRectEx( rect
, style
, menu
, 0 );
472 /***********************************************************************
473 * AdjustWindowRectEx16 (USER.454)
475 BOOL16 WINAPI
AdjustWindowRectEx16( LPRECT16 rect
, DWORD style
,
476 BOOL16 menu
, DWORD exStyle
)
478 /* Correct the window style */
480 if (!(style
& (WS_POPUP
| WS_CHILD
))) /* Overlapped window */
482 style
&= (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
| WS_CHILD
);
483 exStyle
&= (WS_EX_DLGMODALFRAME
| WS_EX_CLIENTEDGE
|
484 WS_EX_STATICEDGE
| WS_EX_TOOLWINDOW
);
485 if (exStyle
& WS_EX_DLGMODALFRAME
) style
&= ~WS_THICKFRAME
;
487 TRACE_(nonclient
)("(%d,%d)-(%d,%d) %08lx %d %08lx\n",
488 rect
->left
, rect
->top
, rect
->right
, rect
->bottom
,
489 style
, menu
, exStyle
);
491 if (TWEAK_WineLook
== WIN31_LOOK
)
492 NC_AdjustRect( rect
, style
, menu
, exStyle
);
494 NC_AdjustRectOuter95( rect
, style
, menu
, exStyle
);
495 NC_AdjustRectInner95( rect
, style
, exStyle
);
502 /***********************************************************************
503 * AdjustWindowRectEx32 (USER32.3)
505 BOOL WINAPI
AdjustWindowRectEx( LPRECT rect
, DWORD style
,
506 BOOL menu
, DWORD exStyle
)
511 CONV_RECT32TO16( rect
, &rect16
);
512 ret
= AdjustWindowRectEx16( &rect16
, style
, (BOOL16
)menu
, exStyle
);
513 CONV_RECT16TO32( &rect16
, rect
);
518 /***********************************************************************
519 * NC_HandleNCCalcSize
521 * Handle a WM_NCCALCSIZE message. Called from DefWindowProc().
523 LONG
NC_HandleNCCalcSize( WND
*pWnd
, RECT
*winRect
)
525 RECT16 tmpRect
= { 0, 0, 0, 0 };
527 UINT style
= (UINT
) GetClassLongA(pWnd
->hwndSelf
, GCL_STYLE
);
529 if (style
& CS_VREDRAW
) result
|= WVR_VREDRAW
;
530 if (style
& CS_HREDRAW
) result
|= WVR_HREDRAW
;
532 if( !( pWnd
->dwStyle
& WS_MINIMIZE
) ) {
533 if (TWEAK_WineLook
== WIN31_LOOK
)
534 NC_AdjustRect( &tmpRect
, pWnd
->dwStyle
, FALSE
, pWnd
->dwExStyle
);
536 NC_AdjustRectOuter95( &tmpRect
, pWnd
->dwStyle
, FALSE
, pWnd
->dwExStyle
);
538 winRect
->left
-= tmpRect
.left
;
539 winRect
->top
-= tmpRect
.top
;
540 winRect
->right
-= tmpRect
.right
;
541 winRect
->bottom
-= tmpRect
.bottom
;
543 if (HAS_MENU(pWnd
)) {
544 TRACE_(nonclient
)("Calling "
545 "GetMenuBarHeight with HWND 0x%x, width %d, "
546 "at (%d, %d).\n", pWnd
->hwndSelf
,
547 winRect
->right
- winRect
->left
,
548 -tmpRect
.left
, -tmpRect
.top
);
551 MENU_GetMenuBarHeight( pWnd
->hwndSelf
,
552 winRect
->right
- winRect
->left
,
553 -tmpRect
.left
, -tmpRect
.top
) + 1;
556 if (TWEAK_WineLook
> WIN31_LOOK
) {
557 SetRect16 (&tmpRect
, 0, 0, 0, 0);
558 NC_AdjustRectInner95 (&tmpRect
, pWnd
->dwStyle
, pWnd
->dwExStyle
);
559 winRect
->left
-= tmpRect
.left
;
560 winRect
->top
-= tmpRect
.top
;
561 winRect
->right
-= tmpRect
.right
;
562 winRect
->bottom
-= tmpRect
.bottom
;
569 /***********************************************************************
572 * Get the 'inside' rectangle of a window, i.e. the whole window rectangle
573 * but without the borders (if any).
574 * The rectangle is in window coordinates (for drawing with GetWindowDC()).
576 static void NC_GetInsideRect( HWND hwnd
, RECT
*rect
)
578 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
580 rect
->top
= rect
->left
= 0;
581 rect
->right
= wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
;
582 rect
->bottom
= wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
;
584 if ((wndPtr
->dwStyle
& WS_ICONIC
) || (wndPtr
->flags
& WIN_MANAGED
)) goto END
;
586 /* Remove frame from rectangle */
587 if (HAS_THICKFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
588 InflateRect( rect
, -GetSystemMetrics(SM_CXFRAME
), -GetSystemMetrics(SM_CYFRAME
) );
590 if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
592 InflateRect( rect
, -GetSystemMetrics(SM_CXDLGFRAME
), -GetSystemMetrics(SM_CYDLGFRAME
));
593 /* FIXME: this isn't in NC_AdjustRect? why not? */
594 if (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
)
595 InflateRect( rect
, -1, 0 );
598 if (HAS_THINFRAME( wndPtr
->dwStyle
))
599 InflateRect( rect
, -GetSystemMetrics(SM_CXBORDER
), -GetSystemMetrics(SM_CYBORDER
) );
601 WIN_ReleaseWndPtr(wndPtr
);
606 /***********************************************************************
609 * Get the 'inside' rectangle of a window, i.e. the whole window rectangle
610 * but without the borders (if any).
611 * The rectangle is in window coordinates (for drawing with GetWindowDC()).
615 NC_GetInsideRect95 (HWND hwnd
, RECT
*rect
)
617 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
619 rect
->top
= rect
->left
= 0;
620 rect
->right
= wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
;
621 rect
->bottom
= wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
;
623 if ((wndPtr
->dwStyle
& WS_ICONIC
) || (wndPtr
->flags
& WIN_MANAGED
)) goto END
;
625 /* Remove frame from rectangle */
626 if (HAS_THICKFRAME (wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
628 InflateRect( rect
, -GetSystemMetrics(SM_CXSIZEFRAME
), -GetSystemMetrics(SM_CYSIZEFRAME
) );
630 else if (HAS_DLGFRAME (wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
632 InflateRect( rect
, -GetSystemMetrics(SM_CXFIXEDFRAME
), -GetSystemMetrics(SM_CYFIXEDFRAME
));
634 else if (HAS_THINFRAME (wndPtr
->dwStyle
))
636 InflateRect( rect
, -GetSystemMetrics(SM_CXBORDER
), -GetSystemMetrics(SM_CYBORDER
) );
639 if (wndPtr
->dwStyle
& WS_CHILD
) {
640 if (wndPtr
->dwExStyle
& WS_EX_CLIENTEDGE
)
641 InflateRect (rect
, -GetSystemMetrics(SM_CXEDGE
), -GetSystemMetrics(SM_CYEDGE
));
643 if (wndPtr
->dwExStyle
& WS_EX_STATICEDGE
)
644 InflateRect (rect
, -GetSystemMetrics(SM_CXBORDER
), -GetSystemMetrics(SM_CYBORDER
));
647 WIN_ReleaseWndPtr(wndPtr
);
652 /***********************************************************************
655 * Handle a WM_NCHITTEST message. Called from NC_HandleNcHitTest().
658 static LONG
NC_DoNCHitTest (WND
*wndPtr
, POINT16 pt
)
662 TRACE_(nonclient
)("hwnd=%04x pt=%d,%d\n",
663 wndPtr
->hwndSelf
, pt
.x
, pt
.y
);
665 GetWindowRect16 (wndPtr
->hwndSelf
, &rect
);
666 if (!PtInRect16( &rect
, pt
)) return HTNOWHERE
;
668 if (wndPtr
->dwStyle
& WS_MINIMIZE
) return HTCAPTION
;
670 if (!(wndPtr
->flags
& WIN_MANAGED
))
673 if (HAS_THICKFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
675 InflateRect16( &rect
, -GetSystemMetrics(SM_CXFRAME
), -GetSystemMetrics(SM_CYFRAME
) );
676 if (!PtInRect16( &rect
, pt
))
678 /* Check top sizing border */
681 if (pt
.x
< rect
.left
+GetSystemMetrics(SM_CXSIZE
)) return HTTOPLEFT
;
682 if (pt
.x
>= rect
.right
-GetSystemMetrics(SM_CXSIZE
)) return HTTOPRIGHT
;
685 /* Check bottom sizing border */
686 if (pt
.y
>= rect
.bottom
)
688 if (pt
.x
< rect
.left
+GetSystemMetrics(SM_CXSIZE
)) return HTBOTTOMLEFT
;
689 if (pt
.x
>= rect
.right
-GetSystemMetrics(SM_CXSIZE
)) return HTBOTTOMRIGHT
;
692 /* Check left sizing border */
693 if (pt
.x
< rect
.left
)
695 if (pt
.y
< rect
.top
+GetSystemMetrics(SM_CYSIZE
)) return HTTOPLEFT
;
696 if (pt
.y
>= rect
.bottom
-GetSystemMetrics(SM_CYSIZE
)) return HTBOTTOMLEFT
;
699 /* Check right sizing border */
700 if (pt
.x
>= rect
.right
)
702 if (pt
.y
< rect
.top
+GetSystemMetrics(SM_CYSIZE
)) return HTTOPRIGHT
;
703 if (pt
.y
>= rect
.bottom
-GetSystemMetrics(SM_CYSIZE
)) return HTBOTTOMRIGHT
;
708 else /* No thick frame */
710 if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
711 InflateRect16(&rect
, -GetSystemMetrics(SM_CXDLGFRAME
), -GetSystemMetrics(SM_CYDLGFRAME
));
712 else if (HAS_THINFRAME( wndPtr
->dwStyle
))
713 InflateRect16(&rect
, -GetSystemMetrics(SM_CXBORDER
), -GetSystemMetrics(SM_CYBORDER
));
714 if (!PtInRect16( &rect
, pt
)) return HTBORDER
;
719 if ((wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
721 rect
.top
+= GetSystemMetrics(SM_CYCAPTION
) - GetSystemMetrics(SM_CYBORDER
);
722 if (!PtInRect16( &rect
, pt
))
724 /* Check system menu */
725 if (wndPtr
->dwStyle
& WS_SYSMENU
)
726 rect
.left
+= GetSystemMetrics(SM_CXSIZE
);
727 if (pt
.x
<= rect
.left
) return HTSYSMENU
;
729 /* Check maximize box */
730 if (wndPtr
->dwStyle
& WS_MAXIMIZEBOX
)
731 rect
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
733 if (pt
.x
>= rect
.right
) return HTMAXBUTTON
;
734 /* Check minimize box */
735 if (wndPtr
->dwStyle
& WS_MINIMIZEBOX
)
736 rect
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
737 if (pt
.x
>= rect
.right
) return HTMINBUTTON
;
743 /* Check client area */
745 ScreenToClient16( wndPtr
->hwndSelf
, &pt
);
746 GetClientRect16( wndPtr
->hwndSelf
, &rect
);
747 if (PtInRect16( &rect
, pt
)) return HTCLIENT
;
749 /* Check vertical scroll bar */
751 if (wndPtr
->dwStyle
& WS_VSCROLL
)
753 rect
.right
+= GetSystemMetrics(SM_CXVSCROLL
);
754 if (PtInRect16( &rect
, pt
)) return HTVSCROLL
;
757 /* Check horizontal scroll bar */
759 if (wndPtr
->dwStyle
& WS_HSCROLL
)
761 rect
.bottom
+= GetSystemMetrics(SM_CYHSCROLL
);
762 if (PtInRect16( &rect
, pt
))
765 if ((wndPtr
->dwStyle
& WS_VSCROLL
) &&
766 (pt
.x
>= rect
.right
- GetSystemMetrics(SM_CXVSCROLL
)))
774 if (HAS_MENU(wndPtr
))
776 if ((pt
.y
< 0) && (pt
.x
>= 0) && (pt
.x
< rect
.right
))
780 /* Should never get here */
785 /***********************************************************************
788 * Handle a WM_NCHITTEST message. Called from NC_HandleNCHitTest().
790 * FIXME: Just a modified copy of the Win 3.1 version.
794 NC_DoNCHitTest95 (WND
*wndPtr
, POINT16 pt
)
798 TRACE_(nonclient
)("hwnd=%04x pt=%d,%d\n",
799 wndPtr
->hwndSelf
, pt
.x
, pt
.y
);
801 GetWindowRect16 (wndPtr
->hwndSelf
, &rect
);
802 if (!PtInRect16( &rect
, pt
)) return HTNOWHERE
;
804 if (wndPtr
->dwStyle
& WS_MINIMIZE
) return HTCAPTION
;
806 if (!(wndPtr
->flags
& WIN_MANAGED
))
809 if (HAS_THICKFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
811 InflateRect16( &rect
, -GetSystemMetrics(SM_CXFRAME
), -GetSystemMetrics(SM_CYFRAME
) );
812 if (!PtInRect16( &rect
, pt
))
814 /* Check top sizing border */
817 if (pt
.x
< rect
.left
+GetSystemMetrics(SM_CXSIZE
)) return HTTOPLEFT
;
818 if (pt
.x
>= rect
.right
-GetSystemMetrics(SM_CXSIZE
)) return HTTOPRIGHT
;
821 /* Check bottom sizing border */
822 if (pt
.y
>= rect
.bottom
)
824 if (pt
.x
< rect
.left
+GetSystemMetrics(SM_CXSIZE
)) return HTBOTTOMLEFT
;
825 if (pt
.x
>= rect
.right
-GetSystemMetrics(SM_CXSIZE
)) return HTBOTTOMRIGHT
;
828 /* Check left sizing border */
829 if (pt
.x
< rect
.left
)
831 if (pt
.y
< rect
.top
+GetSystemMetrics(SM_CYSIZE
)) return HTTOPLEFT
;
832 if (pt
.y
>= rect
.bottom
-GetSystemMetrics(SM_CYSIZE
)) return HTBOTTOMLEFT
;
835 /* Check right sizing border */
836 if (pt
.x
>= rect
.right
)
838 if (pt
.y
< rect
.top
+GetSystemMetrics(SM_CYSIZE
)) return HTTOPRIGHT
;
839 if (pt
.y
>= rect
.bottom
-GetSystemMetrics(SM_CYSIZE
)) return HTBOTTOMRIGHT
;
844 else /* No thick frame */
846 if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
847 InflateRect16(&rect
, -GetSystemMetrics(SM_CXDLGFRAME
), -GetSystemMetrics(SM_CYDLGFRAME
));
848 else if (HAS_THINFRAME( wndPtr
->dwStyle
))
849 InflateRect16(&rect
, -GetSystemMetrics(SM_CXBORDER
), -GetSystemMetrics(SM_CYBORDER
));
850 if (!PtInRect16( &rect
, pt
)) return HTBORDER
;
855 if ((wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
857 if (wndPtr
->dwExStyle
& WS_EX_TOOLWINDOW
)
858 rect
.top
+= GetSystemMetrics(SM_CYSMCAPTION
) - 1;
860 rect
.top
+= GetSystemMetrics(SM_CYCAPTION
) - 1;
861 if (!PtInRect16( &rect
, pt
))
863 /* Check system menu */
864 if ((wndPtr
->dwStyle
& WS_SYSMENU
) && (!(wndPtr
->dwStyle
& DS_MODALFRAME
)))
865 rect
.left
+= GetSystemMetrics(SM_CYCAPTION
) - 1;
866 if (pt
.x
< rect
.left
) return HTSYSMENU
;
868 /* Check close button */
869 if (wndPtr
->dwStyle
& WS_SYSMENU
)
870 rect
.right
-= GetSystemMetrics(SM_CYCAPTION
) - 1;
871 if (pt
.x
> rect
.right
) return HTCLOSE
;
873 /* Check maximize box */
874 /* In win95 there is automatically a Maximize button when there is a minimize one*/
875 if ((wndPtr
->dwStyle
& WS_MAXIMIZEBOX
)|| (wndPtr
->dwStyle
& WS_MINIMIZEBOX
))
876 rect
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
877 if (pt
.x
> rect
.right
) return HTMAXBUTTON
;
879 /* Check minimize box */
880 /* In win95 there is automatically a Maximize button when there is a Maximize one*/
881 if ((wndPtr
->dwStyle
& WS_MINIMIZEBOX
)||(wndPtr
->dwStyle
& WS_MAXIMIZEBOX
))
882 rect
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
884 if (pt
.x
> rect
.right
) return HTMINBUTTON
;
890 /* Check client area */
892 ScreenToClient16( wndPtr
->hwndSelf
, &pt
);
893 GetClientRect16( wndPtr
->hwndSelf
, &rect
);
894 if (PtInRect16( &rect
, pt
)) return HTCLIENT
;
896 /* Check vertical scroll bar */
898 if (wndPtr
->dwStyle
& WS_VSCROLL
)
900 rect
.right
+= GetSystemMetrics(SM_CXVSCROLL
);
901 if (PtInRect16( &rect
, pt
)) return HTVSCROLL
;
904 /* Check horizontal scroll bar */
906 if (wndPtr
->dwStyle
& WS_HSCROLL
)
908 rect
.bottom
+= GetSystemMetrics(SM_CYHSCROLL
);
909 if (PtInRect16( &rect
, pt
))
912 if ((wndPtr
->dwStyle
& WS_VSCROLL
) &&
913 (pt
.x
>= rect
.right
- GetSystemMetrics(SM_CXVSCROLL
)))
921 if (HAS_MENU(wndPtr
))
923 if ((pt
.y
< 0) && (pt
.x
>= 0) && (pt
.x
< rect
.right
))
927 /* Should never get here */
932 /***********************************************************************
935 * Handle a WM_NCHITTEST message. Called from DefWindowProc().
938 NC_HandleNCHitTest (HWND hwnd
, POINT16 pt
)
941 WND
*wndPtr
= WIN_FindWndPtr (hwnd
);
946 if (TWEAK_WineLook
== WIN31_LOOK
)
947 retvalue
= NC_DoNCHitTest (wndPtr
, pt
);
949 retvalue
= NC_DoNCHitTest95 (wndPtr
, pt
);
950 WIN_ReleaseWndPtr(wndPtr
);
955 /***********************************************************************
958 void NC_DrawSysButton( HWND hwnd
, HDC hdc
, BOOL down
)
963 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
965 if( !(wndPtr
->flags
& WIN_MANAGED
) )
967 NC_GetInsideRect( hwnd
, &rect
);
968 hdcMem
= CreateCompatibleDC( hdc
);
969 hbitmap
= SelectObject( hdcMem
, hbitmapClose
);
970 BitBlt(hdc
, rect
.left
, rect
.top
, GetSystemMetrics(SM_CXSIZE
), GetSystemMetrics(SM_CYSIZE
),
971 hdcMem
, (wndPtr
->dwStyle
& WS_CHILD
) ? GetSystemMetrics(SM_CXSIZE
) : 0, 0,
972 down
? NOTSRCCOPY
: SRCCOPY
);
973 SelectObject( hdcMem
, hbitmap
);
976 WIN_ReleaseWndPtr(wndPtr
);
980 /***********************************************************************
983 static void NC_DrawMaxButton( HWND hwnd
, HDC16 hdc
, BOOL down
)
986 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
989 if( !(wndPtr
->flags
& WIN_MANAGED
) )
991 NC_GetInsideRect( hwnd
, &rect
);
992 hdcMem
= CreateCompatibleDC( hdc
);
993 SelectObject( hdcMem
, (IsZoomed(hwnd
)
994 ? (down
? hbitmapRestoreD
: hbitmapRestore
)
995 : (down
? hbitmapMaximizeD
: hbitmapMaximize
)) );
996 BitBlt( hdc
, rect
.right
- GetSystemMetrics(SM_CXSIZE
) - 1, rect
.top
,
997 GetSystemMetrics(SM_CXSIZE
) + 1, GetSystemMetrics(SM_CYSIZE
), hdcMem
, 0, 0,
1001 WIN_ReleaseWndPtr(wndPtr
);
1006 /***********************************************************************
1009 static void NC_DrawMinButton( HWND hwnd
, HDC16 hdc
, BOOL down
)
1012 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1015 if( !(wndPtr
->flags
& WIN_MANAGED
) )
1017 NC_GetInsideRect( hwnd
, &rect
);
1018 hdcMem
= CreateCompatibleDC( hdc
);
1019 SelectObject( hdcMem
, (down
? hbitmapMinimizeD
: hbitmapMinimize
) );
1020 if (wndPtr
->dwStyle
& WS_MAXIMIZEBOX
) rect
.right
-= GetSystemMetrics(SM_CXSIZE
)+1;
1021 BitBlt( hdc
, rect
.right
- GetSystemMetrics(SM_CXSIZE
) - 1, rect
.top
,
1022 GetSystemMetrics(SM_CXSIZE
) + 1, GetSystemMetrics(SM_CYSIZE
), hdcMem
, 0, 0,
1026 WIN_ReleaseWndPtr(wndPtr
);
1030 /******************************************************************************
1032 * void NC_DrawSysButton95(
1037 * Draws the Win95 system icon.
1040 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1041 * Original implementation from NC_DrawSysButton source.
1042 * 11-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1045 *****************************************************************************/
1048 NC_DrawSysButton95 (HWND hwnd
, HDC hdc
, BOOL down
)
1050 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1052 if( !(wndPtr
->flags
& WIN_MANAGED
) )
1057 NC_GetInsideRect95( hwnd
, &rect
);
1059 hIcon
= (HICON
) GetClassLongA(wndPtr
->hwndSelf
, GCL_HICONSM
);
1060 if(!hIcon
) hIcon
= (HICON
) GetClassLongA(wndPtr
->hwndSelf
, GCL_HICON
);
1062 /* If there is no hIcon specified or this is not a modal dialog, */
1063 /* get the default one. */
1065 if (!(wndPtr
->dwStyle
& DS_MODALFRAME
))
1066 hIcon
= LoadImageA(0, MAKEINTRESOURCEA(OIC_WINEICON
), IMAGE_ICON
, 0, 0, LR_DEFAULTCOLOR
);
1069 DrawIconEx (hdc
, rect
.left
+ 2, rect
.top
+ 2, hIcon
,
1070 GetSystemMetrics(SM_CXSMICON
),
1071 GetSystemMetrics(SM_CYSMICON
),
1074 WIN_ReleaseWndPtr(wndPtr
);
1075 return (hIcon
!= 0);
1077 WIN_ReleaseWndPtr(wndPtr
);
1082 /******************************************************************************
1084 * void NC_DrawCloseButton95(
1090 * Draws the Win95 close button.
1092 * If bGrayed is true, then draw a disabled Close button
1095 * 11-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1096 * Original implementation from NC_DrawSysButton95 source.
1098 *****************************************************************************/
1100 static void NC_DrawCloseButton95 (HWND hwnd
, HDC hdc
, BOOL down
, BOOL bGrayed
)
1104 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1106 if( !(wndPtr
->flags
& WIN_MANAGED
) )
1109 HBITMAP hBmp
, hOldBmp
;
1111 NC_GetInsideRect95( hwnd
, &rect
);
1113 hdcMem
= CreateCompatibleDC( hdc
);
1114 hBmp
= down
? hbitmapCloseD
: hbitmapClose
;
1115 hOldBmp
= SelectObject (hdcMem
, hBmp
);
1116 GetObjectA (hBmp
, sizeof(BITMAP
), &bmp
);
1118 BitBlt (hdc
, rect
.right
- (GetSystemMetrics(SM_CYCAPTION
) + 1 + bmp
.bmWidth
) / 2,
1119 rect
.top
+ (GetSystemMetrics(SM_CYCAPTION
) - 1 - bmp
.bmHeight
) / 2,
1120 bmp
.bmWidth
, bmp
.bmHeight
, hdcMem
, 0, 0, SRCCOPY
);
1123 NC_DrawGrayButton(hdc
,rect
.right
- (GetSystemMetrics(SM_CYCAPTION
) + 1 + bmp
.bmWidth
) / 2 + 2,
1124 rect
.top
+ (GetSystemMetrics(SM_CYCAPTION
) - 1 - bmp
.bmHeight
) / 2 + 2);
1126 SelectObject (hdcMem
, hOldBmp
);
1129 WIN_ReleaseWndPtr(wndPtr
);
1132 /******************************************************************************
1134 * NC_DrawMaxButton95(
1140 * Draws the maximize button for Win95 style windows.
1142 * If bGrayed is true, then draw a disabled Maximize button
1145 * Many. Spacing might still be incorrect. Need to fit a close
1146 * button between the max button and the edge.
1147 * Should scale the image with the title bar. And more...
1150 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1151 * Original implementation.
1153 *****************************************************************************/
1155 static void NC_DrawMaxButton95(HWND hwnd
,HDC16 hdc
,BOOL down
, BOOL bGrayed
)
1159 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1161 if( !(wndPtr
->flags
& WIN_MANAGED
))
1164 HBITMAP hBmp
,hOldBmp
;
1166 NC_GetInsideRect95( hwnd
, &rect
);
1167 hdcMem
= CreateCompatibleDC( hdc
);
1168 hBmp
= IsZoomed(hwnd
) ?
1169 (down
? hbitmapRestoreD
: hbitmapRestore
) :
1170 (down
? hbitmapMaximizeD
: hbitmapMaximize
);
1171 hOldBmp
=SelectObject( hdcMem
, hBmp
);
1172 GetObjectA (hBmp
, sizeof(BITMAP
), &bmp
);
1174 if (wndPtr
->dwStyle
& WS_SYSMENU
)
1175 rect
.right
-= GetSystemMetrics(SM_CYCAPTION
) + 1;
1177 BitBlt( hdc
, rect
.right
- (GetSystemMetrics(SM_CXSIZE
) + bmp
.bmWidth
) / 2,
1178 rect
.top
+ (GetSystemMetrics(SM_CYCAPTION
) - 1 - bmp
.bmHeight
) / 2,
1179 bmp
.bmWidth
, bmp
.bmHeight
, hdcMem
, 0, 0, SRCCOPY
);
1182 NC_DrawGrayButton(hdc
, rect
.right
- (GetSystemMetrics(SM_CXSIZE
) + bmp
.bmWidth
) / 2 + 2,
1183 rect
.top
+ (GetSystemMetrics(SM_CYCAPTION
) - 1 - bmp
.bmHeight
) / 2 + 2);
1186 SelectObject (hdcMem
, hOldBmp
);
1189 WIN_ReleaseWndPtr(wndPtr
);
1192 /******************************************************************************
1194 * NC_DrawMinButton95(
1200 * Draws the minimize button for Win95 style windows.
1202 * If bGrayed is true, then draw a disabled Minimize button
1205 * Many. Spacing is still incorrect. Should scale the image with the
1206 * title bar. And more...
1209 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1210 * Original implementation.
1212 *****************************************************************************/
1214 static void NC_DrawMinButton95(HWND hwnd
,HDC16 hdc
,BOOL down
, BOOL bGrayed
)
1218 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1220 if( !(wndPtr
->flags
& WIN_MANAGED
))
1224 HBITMAP hBmp
,hOldBmp
;
1226 NC_GetInsideRect95( hwnd
, &rect
);
1228 hdcMem
= CreateCompatibleDC( hdc
);
1229 hBmp
= down
? hbitmapMinimizeD
: hbitmapMinimize
;
1230 hOldBmp
= SelectObject( hdcMem
, hBmp
);
1231 GetObjectA (hBmp
, sizeof(BITMAP
), &bmp
);
1233 if (wndPtr
->dwStyle
& WS_SYSMENU
)
1234 rect
.right
-= GetSystemMetrics(SM_CYCAPTION
) + 1;
1236 /* In win 95 there is always a Maximize box when there is a Minimize one */
1237 if ((wndPtr
->dwStyle
& WS_MAXIMIZEBOX
) || (wndPtr
->dwStyle
& WS_MINIMIZEBOX
))
1238 rect
.right
+= -1 - (GetSystemMetrics(SM_CXSIZE
) + bmp
.bmWidth
) / 2;
1240 BitBlt( hdc
, rect
.right
- (GetSystemMetrics(SM_CXSIZE
) + bmp
.bmWidth
) / 2,
1241 rect
.top
+ (GetSystemMetrics(SM_CYCAPTION
) - 1 - bmp
.bmHeight
) / 2,
1242 bmp
.bmWidth
, bmp
.bmHeight
, hdcMem
, 0, 0, SRCCOPY
);
1245 NC_DrawGrayButton(hdc
, rect
.right
- (GetSystemMetrics(SM_CXSIZE
) + bmp
.bmWidth
) / 2 + 2,
1246 rect
.top
+ (GetSystemMetrics(SM_CYCAPTION
) - 1 - bmp
.bmHeight
) / 2 + 2);
1249 SelectObject (hdcMem
, hOldBmp
);
1252 WIN_ReleaseWndPtr(wndPtr
);
1255 /***********************************************************************
1258 * Draw a window frame inside the given rectangle, and update the rectangle.
1259 * The correct pen for the frame must be selected in the DC.
1261 static void NC_DrawFrame( HDC hdc
, RECT
*rect
, BOOL dlgFrame
,
1266 if (TWEAK_WineLook
!= WIN31_LOOK
)
1267 ERR_(nonclient
)("Called in Win95 mode. Aiee! Please report this.\n" );
1271 width
= GetSystemMetrics(SM_CXDLGFRAME
) - 1;
1272 height
= GetSystemMetrics(SM_CYDLGFRAME
) - 1;
1273 SelectObject( hdc
, GetSysColorBrush(active
? COLOR_ACTIVECAPTION
:
1274 COLOR_INACTIVECAPTION
) );
1278 width
= GetSystemMetrics(SM_CXFRAME
) - 2;
1279 height
= GetSystemMetrics(SM_CYFRAME
) - 2;
1280 SelectObject( hdc
, GetSysColorBrush(active
? COLOR_ACTIVEBORDER
:
1281 COLOR_INACTIVEBORDER
) );
1285 PatBlt( hdc
, rect
->left
, rect
->top
,
1286 rect
->right
- rect
->left
, height
, PATCOPY
);
1287 PatBlt( hdc
, rect
->left
, rect
->top
,
1288 width
, rect
->bottom
- rect
->top
, PATCOPY
);
1289 PatBlt( hdc
, rect
->left
, rect
->bottom
- 1,
1290 rect
->right
- rect
->left
, -height
, PATCOPY
);
1291 PatBlt( hdc
, rect
->right
- 1, rect
->top
,
1292 -width
, rect
->bottom
- rect
->top
, PATCOPY
);
1296 InflateRect( rect
, -width
, -height
);
1300 INT decYOff
= GetSystemMetrics(SM_CXFRAME
) + GetSystemMetrics(SM_CXSIZE
) - 1;
1301 INT decXOff
= GetSystemMetrics(SM_CYFRAME
) + GetSystemMetrics(SM_CYSIZE
) - 1;
1303 /* Draw inner rectangle */
1305 SelectObject( hdc
, GetStockObject(NULL_BRUSH
) );
1306 Rectangle( hdc
, rect
->left
+ width
, rect
->top
+ height
,
1307 rect
->right
- width
, rect
->bottom
- height
);
1309 /* Draw the decorations */
1311 MoveToEx( hdc
, rect
->left
, rect
->top
+ decYOff
, NULL
);
1312 LineTo( hdc
, rect
->left
+ width
, rect
->top
+ decYOff
);
1313 MoveToEx( hdc
, rect
->right
- 1, rect
->top
+ decYOff
, NULL
);
1314 LineTo( hdc
, rect
->right
- width
- 1, rect
->top
+ decYOff
);
1315 MoveToEx( hdc
, rect
->left
, rect
->bottom
- decYOff
, NULL
);
1316 LineTo( hdc
, rect
->left
+ width
, rect
->bottom
- decYOff
);
1317 MoveToEx( hdc
, rect
->right
- 1, rect
->bottom
- decYOff
, NULL
);
1318 LineTo( hdc
, rect
->right
- width
- 1, rect
->bottom
- decYOff
);
1320 MoveToEx( hdc
, rect
->left
+ decXOff
, rect
->top
, NULL
);
1321 LineTo( hdc
, rect
->left
+ decXOff
, rect
->top
+ height
);
1322 MoveToEx( hdc
, rect
->left
+ decXOff
, rect
->bottom
- 1, NULL
);
1323 LineTo( hdc
, rect
->left
+ decXOff
, rect
->bottom
- height
- 1 );
1324 MoveToEx( hdc
, rect
->right
- decXOff
, rect
->top
, NULL
);
1325 LineTo( hdc
, rect
->right
- decXOff
, rect
->top
+ height
);
1326 MoveToEx( hdc
, rect
->right
- decXOff
, rect
->bottom
- 1, NULL
);
1327 LineTo( hdc
, rect
->right
- decXOff
, rect
->bottom
- height
- 1 );
1329 InflateRect( rect
, -width
- 1, -height
- 1 );
1334 /******************************************************************************
1336 * void NC_DrawFrame95(
1342 * Draw a window frame inside the given rectangle, and update the rectangle.
1343 * The correct pen for the frame must be selected in the DC.
1346 * Many. First, just what IS a frame in Win95? Note that the 3D look
1347 * on the outer edge is handled by NC_DoNCPaint95. As is the inner
1348 * edge. The inner rectangle just inside the frame is handled by the
1351 * In short, for most people, this function should be a nop (unless
1352 * you LIKE thick borders in Win95/NT4.0 -- I've been working with
1353 * them lately, but just to get this code right). Even so, it doesn't
1354 * appear to be so. It's being worked on...
1357 * 06-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1358 * Original implementation (based on NC_DrawFrame)
1359 * 02-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1361 * 29-Jun-1999 Ove Kåven (ovek@arcticnet.no)
1362 * Fixed a fix or something.
1364 *****************************************************************************/
1366 static void NC_DrawFrame95(
1376 width
= GetSystemMetrics(SM_CXDLGFRAME
) - GetSystemMetrics(SM_CXEDGE
);
1377 height
= GetSystemMetrics(SM_CYDLGFRAME
) - GetSystemMetrics(SM_CYEDGE
);
1381 width
= GetSystemMetrics(SM_CXFRAME
) - GetSystemMetrics(SM_CXEDGE
);
1382 height
= GetSystemMetrics(SM_CYFRAME
) - GetSystemMetrics(SM_CYEDGE
);
1385 SelectObject( hdc
, GetSysColorBrush(active
? COLOR_ACTIVEBORDER
:
1386 COLOR_INACTIVEBORDER
) );
1389 PatBlt( hdc
, rect
->left
, rect
->top
,
1390 rect
->right
- rect
->left
, height
, PATCOPY
);
1391 PatBlt( hdc
, rect
->left
, rect
->top
,
1392 width
, rect
->bottom
- rect
->top
, PATCOPY
);
1393 PatBlt( hdc
, rect
->left
, rect
->bottom
- 1,
1394 rect
->right
- rect
->left
, -height
, PATCOPY
);
1395 PatBlt( hdc
, rect
->right
- 1, rect
->top
,
1396 -width
, rect
->bottom
- rect
->top
, PATCOPY
);
1398 InflateRect( rect
, -width
, -height
);
1401 /***********************************************************************
1402 * NC_DrawMovingFrame
1404 * Draw the frame used when moving or resizing window.
1406 * FIXME: This causes problems in Win95 mode. (why?)
1408 static void NC_DrawMovingFrame( HDC hdc
, RECT
*rect
, BOOL thickframe
)
1413 CONV_RECT32TO16( rect
, &r16
);
1414 FastWindowFrame16( hdc
, &r16
, GetSystemMetrics(SM_CXFRAME
),
1415 GetSystemMetrics(SM_CYFRAME
), PATINVERT
);
1417 else DrawFocusRect( hdc
, rect
);
1421 /***********************************************************************
1424 * Draw the window caption.
1425 * The correct pen for the window frame must be selected in the DC.
1427 static void NC_DrawCaption( HDC hdc
, RECT
*rect
, HWND hwnd
,
1428 DWORD style
, BOOL active
)
1431 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
1434 if (wndPtr
->flags
& WIN_MANAGED
)
1436 WIN_ReleaseWndPtr(wndPtr
);
1442 if (!(hbitmapClose
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_CLOSE
) )))
1444 WIN_ReleaseWndPtr(wndPtr
);
1447 hbitmapCloseD
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_CLOSED
) );
1448 hbitmapMinimize
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_REDUCE
) );
1449 hbitmapMinimizeD
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_REDUCED
) );
1450 hbitmapMaximize
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_ZOOM
) );
1451 hbitmapMaximizeD
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_ZOOMD
) );
1452 hbitmapRestore
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_RESTORE
) );
1453 hbitmapRestoreD
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_RESTORED
) );
1456 if (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
)
1458 HBRUSH hbrushOld
= SelectObject(hdc
, GetSysColorBrush(COLOR_WINDOW
) );
1459 PatBlt( hdc
, r
.left
, r
.top
, 1, r
.bottom
-r
.top
+1,PATCOPY
);
1460 PatBlt( hdc
, r
.right
-1, r
.top
, 1, r
.bottom
-r
.top
+1, PATCOPY
);
1461 PatBlt( hdc
, r
.left
, r
.top
-1, r
.right
-r
.left
, 1, PATCOPY
);
1464 SelectObject( hdc
, hbrushOld
);
1466 WIN_ReleaseWndPtr(wndPtr
);
1467 MoveTo16( hdc
, r
.left
, r
.bottom
);
1468 LineTo( hdc
, r
.right
, r
.bottom
);
1470 if (style
& WS_SYSMENU
)
1472 NC_DrawSysButton( hwnd
, hdc
, FALSE
);
1473 r
.left
+= GetSystemMetrics(SM_CXSIZE
) + 1;
1474 MoveTo16( hdc
, r
.left
- 1, r
.top
);
1475 LineTo( hdc
, r
.left
- 1, r
.bottom
);
1477 if (style
& WS_MAXIMIZEBOX
)
1479 NC_DrawMaxButton( hwnd
, hdc
, FALSE
);
1480 r
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
1482 if (style
& WS_MINIMIZEBOX
)
1484 NC_DrawMinButton( hwnd
, hdc
, FALSE
);
1485 r
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
1488 FillRect( hdc
, &r
, GetSysColorBrush(active
? COLOR_ACTIVECAPTION
:
1489 COLOR_INACTIVECAPTION
) );
1491 if (GetWindowTextA( hwnd
, buffer
, sizeof(buffer
) ))
1493 if (active
) SetTextColor( hdc
, GetSysColor( COLOR_CAPTIONTEXT
) );
1494 else SetTextColor( hdc
, GetSysColor( COLOR_INACTIVECAPTIONTEXT
) );
1495 SetBkMode( hdc
, TRANSPARENT
);
1496 DrawTextA( hdc
, buffer
, -1, &r
,
1497 DT_SINGLELINE
| DT_CENTER
| DT_VCENTER
| DT_NOPREFIX
);
1502 /******************************************************************************
1511 * Draw the window caption for Win95 style windows.
1512 * The correct pen for the window frame must be selected in the DC.
1515 * Hey, a function that finally works! Well, almost.
1516 * It's being worked on.
1519 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1520 * Original implementation.
1521 * 02-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1524 *****************************************************************************/
1526 static void NC_DrawCaption95(
1535 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1540 if (wndPtr
->flags
& WIN_MANAGED
)
1542 WIN_ReleaseWndPtr(wndPtr
);
1545 WIN_ReleaseWndPtr(wndPtr
);
1547 hPrevPen
= SelectObject( hdc
, GetSysColorPen(COLOR_3DFACE
) );
1548 MoveToEx( hdc
, r
.left
, r
.bottom
- 1, NULL
);
1549 LineTo( hdc
, r
.right
, r
.bottom
- 1 );
1550 SelectObject( hdc
, hPrevPen
);
1553 FillRect( hdc
, &r
, GetSysColorBrush(active
? COLOR_ACTIVECAPTION
:
1554 COLOR_INACTIVECAPTION
) );
1556 if (!hbitmapClose
) {
1557 if (!(hbitmapClose
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_CLOSE
) )))
1559 hbitmapCloseD
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_CLOSED
));
1560 hbitmapMinimize
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_REDUCE
) );
1561 hbitmapMinimizeD
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_REDUCED
) );
1562 hbitmapMaximize
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_ZOOM
) );
1563 hbitmapMaximizeD
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_ZOOMD
) );
1564 hbitmapRestore
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_RESTORE
) );
1565 hbitmapRestoreD
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_RESTORED
) );
1568 if ((style
& WS_SYSMENU
) && !(exStyle
& WS_EX_TOOLWINDOW
)) {
1569 if (NC_DrawSysButton95 (hwnd
, hdc
, FALSE
))
1570 r
.left
+= GetSystemMetrics(SM_CYCAPTION
) - 1;
1573 if (style
& WS_SYSMENU
)
1577 /* Go get the sysmenu */
1578 hSysMenu
= GetSystemMenu(hwnd
, FALSE
);
1579 state
= GetMenuState(hSysMenu
, SC_CLOSE
, MF_BYCOMMAND
);
1581 /* Draw a grayed close button if disabled and a normal one if SC_CLOSE is not there */
1582 NC_DrawCloseButton95 (hwnd
, hdc
, FALSE
,
1583 ((((state
& MF_DISABLED
) || (state
& MF_GRAYED
))) && (state
!= 0xFFFFFFFF)));
1584 r
.right
-= GetSystemMetrics(SM_CYCAPTION
) - 1;
1586 if ((style
& WS_MAXIMIZEBOX
) || (style
& WS_MINIMIZEBOX
))
1588 /* In win95 the two buttons are always there */
1589 /* But if the menu item is not in the menu they're disabled*/
1591 NC_DrawMaxButton95( hwnd
, hdc
, FALSE
, (!(style
& WS_MAXIMIZEBOX
)));
1592 r
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
1594 NC_DrawMinButton95( hwnd
, hdc
, FALSE
, (!(style
& WS_MINIMIZEBOX
)));
1595 r
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
1599 if (GetWindowTextA( hwnd
, buffer
, sizeof(buffer
) )) {
1600 NONCLIENTMETRICSA nclm
;
1601 HFONT hFont
, hOldFont
;
1602 nclm
.cbSize
= sizeof(NONCLIENTMETRICSA
);
1603 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS
, 0, &nclm
, 0);
1604 if (exStyle
& WS_EX_TOOLWINDOW
)
1605 hFont
= CreateFontIndirectA (&nclm
.lfSmCaptionFont
);
1607 hFont
= CreateFontIndirectA (&nclm
.lfCaptionFont
);
1608 hOldFont
= SelectObject (hdc
, hFont
);
1609 if (active
) SetTextColor( hdc
, GetSysColor( COLOR_CAPTIONTEXT
) );
1610 else SetTextColor( hdc
, GetSysColor( COLOR_INACTIVECAPTIONTEXT
) );
1611 SetBkMode( hdc
, TRANSPARENT
);
1613 DrawTextA( hdc
, buffer
, -1, &r
,
1614 DT_SINGLELINE
| DT_VCENTER
| DT_NOPREFIX
| DT_LEFT
);
1615 DeleteObject (SelectObject (hdc
, hOldFont
));
1621 /***********************************************************************
1624 * Paint the non-client area. clip is currently unused.
1626 static void NC_DoNCPaint( WND
* wndPtr
, HRGN clip
, BOOL suppress_menupaint
)
1631 HWND hwnd
= wndPtr
->hwndSelf
;
1633 if ( wndPtr
->dwStyle
& WS_MINIMIZE
||
1634 !WIN_IsWindowDrawable( wndPtr
, 0 )) return; /* Nothing to do */
1636 active
= wndPtr
->flags
& WIN_NCACTIVATED
;
1638 TRACE_(nonclient
)("%04x %d\n", hwnd
, active
);
1640 if (!(hdc
= GetDCEx( hwnd
, (clip
> 1) ? clip
: 0, DCX_USESTYLE
| DCX_WINDOW
|
1641 ((clip
> 1) ? (DCX_INTERSECTRGN
| DCX_KEEPCLIPRGN
): 0) ))) return;
1643 if (ExcludeVisRect16( hdc
, wndPtr
->rectClient
.left
-wndPtr
->rectWindow
.left
,
1644 wndPtr
->rectClient
.top
-wndPtr
->rectWindow
.top
,
1645 wndPtr
->rectClient
.right
-wndPtr
->rectWindow
.left
,
1646 wndPtr
->rectClient
.bottom
-wndPtr
->rectWindow
.top
)
1649 ReleaseDC( hwnd
, hdc
);
1653 rect
.top
= rect
.left
= 0;
1654 rect
.right
= wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
;
1655 rect
.bottom
= wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
;
1657 SelectObject( hdc
, GetSysColorPen(COLOR_WINDOWFRAME
) );
1659 if (!(wndPtr
->flags
& WIN_MANAGED
))
1661 if (HAS_ANYFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
1663 SelectObject( hdc
, GetStockObject(NULL_BRUSH
) );
1664 Rectangle( hdc
, 0, 0, rect
.right
, rect
.bottom
);
1665 InflateRect( &rect
, -1, -1 );
1668 if (HAS_THICKFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
1669 NC_DrawFrame(hdc
, &rect
, FALSE
, active
);
1670 else if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
1671 NC_DrawFrame( hdc
, &rect
, TRUE
, active
);
1673 if ((wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
1676 r
.bottom
= rect
.top
+ GetSystemMetrics(SM_CYSIZE
);
1677 rect
.top
+= GetSystemMetrics(SM_CYSIZE
) + GetSystemMetrics(SM_CYBORDER
);
1678 NC_DrawCaption( hdc
, &r
, hwnd
, wndPtr
->dwStyle
, active
);
1682 if (HAS_MENU(wndPtr
))
1685 r
.bottom
= rect
.top
+ GetSystemMetrics(SM_CYMENU
); /* default height */
1686 rect
.top
+= MENU_DrawMenuBar( hdc
, &r
, hwnd
, suppress_menupaint
);
1689 /* Draw the scroll-bars */
1691 if (wndPtr
->dwStyle
& WS_VSCROLL
)
1692 SCROLL_DrawScrollBar( hwnd
, hdc
, SB_VERT
, TRUE
, TRUE
);
1693 if (wndPtr
->dwStyle
& WS_HSCROLL
)
1694 SCROLL_DrawScrollBar( hwnd
, hdc
, SB_HORZ
, TRUE
, TRUE
);
1696 /* Draw the "size-box" */
1698 if ((wndPtr
->dwStyle
& WS_VSCROLL
) && (wndPtr
->dwStyle
& WS_HSCROLL
))
1701 r
.left
= r
.right
- GetSystemMetrics(SM_CXVSCROLL
) + 1;
1702 r
.top
= r
.bottom
- GetSystemMetrics(SM_CYHSCROLL
) + 1;
1703 if(wndPtr
->dwStyle
& WS_BORDER
) {
1707 FillRect( hdc
, &r
, GetSysColorBrush(COLOR_SCROLLBAR
) );
1710 ReleaseDC( hwnd
, hdc
);
1714 /******************************************************************************
1716 * void NC_DoNCPaint95(
1719 * BOOL32 suppress_menupaint )
1721 * Paint the non-client area for Win95 windows. The clip region is
1722 * currently ignored.
1725 * grep -E -A10 -B5 \(95\)\|\(Bugs\)\|\(FIXME\) windows/nonclient.c \
1726 * misc/tweak.c controls/menu.c # :-)
1729 * 03-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1730 * Original implementation
1731 * 10-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1733 * 29-Jun-1999 Ove Kåven (ovek@arcticnet.no)
1734 * Streamlined window style checks.
1736 *****************************************************************************/
1738 static void NC_DoNCPaint95(
1741 BOOL suppress_menupaint
)
1744 RECT rfuzz
, rect
, rectClip
;
1746 HWND hwnd
= wndPtr
->hwndSelf
;
1748 if ( wndPtr
->dwStyle
& WS_MINIMIZE
||
1749 !WIN_IsWindowDrawable( wndPtr
, 0 )) return; /* Nothing to do */
1751 active
= wndPtr
->flags
& WIN_NCACTIVATED
;
1753 TRACE_(nonclient
)("%04x %d\n", hwnd
, active
);
1755 /* MSDN docs are pretty idiotic here, they say app CAN use clipRgn in the call to
1756 * GetDCEx implying that it is allowed not to use it either. However, the suggested
1757 * GetDCEx( , DCX_WINDOW | DCX_INTERSECTRGN) will cause clipRgn to be deleted
1758 * after ReleaseDC(). Now, how is the "system" supposed to tell what happened?
1761 if (!(hdc
= GetDCEx( hwnd
, (clip
> 1) ? clip
: 0, DCX_USESTYLE
| DCX_WINDOW
|
1762 ((clip
> 1) ?(DCX_INTERSECTRGN
| DCX_KEEPCLIPRGN
) : 0) ))) return;
1765 if (ExcludeVisRect16( hdc
, wndPtr
->rectClient
.left
-wndPtr
->rectWindow
.left
,
1766 wndPtr
->rectClient
.top
-wndPtr
->rectWindow
.top
,
1767 wndPtr
->rectClient
.right
-wndPtr
->rectWindow
.left
,
1768 wndPtr
->rectClient
.bottom
-wndPtr
->rectWindow
.top
)
1771 ReleaseDC( hwnd
, hdc
);
1775 rect
.top
= rect
.left
= 0;
1776 rect
.right
= wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
;
1777 rect
.bottom
= wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
;
1780 GetRgnBox( clip
, &rectClip
);
1787 SelectObject( hdc
, GetSysColorPen(COLOR_WINDOWFRAME
) );
1789 if(!(wndPtr
->flags
& WIN_MANAGED
)) {
1790 if (HAS_BIGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
)) {
1791 DrawEdge (hdc
, &rect
, EDGE_RAISED
, BF_RECT
| BF_ADJUST
);
1793 if (HAS_THICKFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
1794 NC_DrawFrame95(hdc
, &rect
, FALSE
, active
);
1795 else if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
1796 NC_DrawFrame95( hdc
, &rect
, TRUE
, active
);
1797 else if (HAS_THINFRAME( wndPtr
->dwStyle
)) {
1798 SelectObject( hdc
, GetStockObject(NULL_BRUSH
) );
1799 Rectangle( hdc
, 0, 0, rect
.right
, rect
.bottom
);
1802 if ((wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
1805 if (wndPtr
->dwExStyle
& WS_EX_TOOLWINDOW
) {
1806 r
.bottom
= rect
.top
+ GetSystemMetrics(SM_CYSMCAPTION
);
1807 rect
.top
+= GetSystemMetrics(SM_CYSMCAPTION
);
1810 r
.bottom
= rect
.top
+ GetSystemMetrics(SM_CYCAPTION
);
1811 rect
.top
+= GetSystemMetrics(SM_CYCAPTION
);
1813 if( !clip
|| IntersectRect( &rfuzz
, &r
, &rectClip
) )
1814 NC_DrawCaption95 (hdc
, &r
, hwnd
, wndPtr
->dwStyle
,
1815 wndPtr
->dwExStyle
, active
);
1819 if (HAS_MENU(wndPtr
))
1822 r
.bottom
= rect
.top
+ GetSystemMetrics(SM_CYMENU
);
1824 TRACE_(nonclient
)("Calling DrawMenuBar with "
1825 "rect (%d, %d)-(%d, %d)\n", r
.left
, r
.top
,
1828 rect
.top
+= MENU_DrawMenuBar( hdc
, &r
, hwnd
, suppress_menupaint
) + 1;
1831 TRACE_(nonclient
)("After MenuBar, rect is (%d, %d)-(%d, %d).\n",
1832 rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1834 if (wndPtr
->dwExStyle
& WS_EX_CLIENTEDGE
)
1835 DrawEdge (hdc
, &rect
, EDGE_SUNKEN
, BF_RECT
| BF_ADJUST
);
1837 if (wndPtr
->dwExStyle
& WS_EX_STATICEDGE
)
1838 DrawEdge (hdc
, &rect
, BDR_SUNKENOUTER
, BF_RECT
| BF_ADJUST
);
1840 /* Draw the scroll-bars */
1842 if (wndPtr
->dwStyle
& WS_VSCROLL
)
1843 SCROLL_DrawScrollBar( hwnd
, hdc
, SB_VERT
, TRUE
, TRUE
);
1844 if (wndPtr
->dwStyle
& WS_HSCROLL
)
1845 SCROLL_DrawScrollBar( hwnd
, hdc
, SB_HORZ
, TRUE
, TRUE
);
1847 /* Draw the "size-box" */
1848 if ((wndPtr
->dwStyle
& WS_VSCROLL
) && (wndPtr
->dwStyle
& WS_HSCROLL
))
1851 r
.left
= r
.right
- GetSystemMetrics(SM_CXVSCROLL
) + 1;
1852 r
.top
= r
.bottom
- GetSystemMetrics(SM_CYHSCROLL
) + 1;
1853 FillRect( hdc
, &r
, GetSysColorBrush(COLOR_SCROLLBAR
) );
1856 ReleaseDC( hwnd
, hdc
);
1862 /***********************************************************************
1865 * Handle a WM_NCPAINT message. Called from DefWindowProc().
1867 LONG
NC_HandleNCPaint( HWND hwnd
, HRGN clip
)
1869 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
1871 if( wndPtr
&& wndPtr
->dwStyle
& WS_VISIBLE
)
1873 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
1874 WINPOS_RedrawIconTitle( hwnd
);
1875 else if (TWEAK_WineLook
== WIN31_LOOK
)
1876 NC_DoNCPaint( wndPtr
, clip
, FALSE
);
1878 NC_DoNCPaint95( wndPtr
, clip
, FALSE
);
1880 WIN_ReleaseWndPtr(wndPtr
);
1885 /***********************************************************************
1886 * NC_HandleNCActivate
1888 * Handle a WM_NCACTIVATE message. Called from DefWindowProc().
1890 LONG
NC_HandleNCActivate( WND
*wndPtr
, WPARAM16 wParam
)
1894 if( wParam
) wStateChange
= !(wndPtr
->flags
& WIN_NCACTIVATED
);
1895 else wStateChange
= wndPtr
->flags
& WIN_NCACTIVATED
;
1899 if (wParam
) wndPtr
->flags
|= WIN_NCACTIVATED
;
1900 else wndPtr
->flags
&= ~WIN_NCACTIVATED
;
1902 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
1903 WINPOS_RedrawIconTitle( wndPtr
->hwndSelf
);
1904 else if (TWEAK_WineLook
== WIN31_LOOK
)
1905 NC_DoNCPaint( wndPtr
, (HRGN
)1, FALSE
);
1907 NC_DoNCPaint95( wndPtr
, (HRGN
)1, FALSE
);
1913 /***********************************************************************
1914 * NC_HandleSetCursor
1916 * Handle a WM_SETCURSOR message. Called from DefWindowProc().
1918 LONG
NC_HandleSetCursor( HWND hwnd
, WPARAM16 wParam
, LPARAM lParam
)
1920 if (hwnd
!= (HWND
)wParam
) return 0; /* Don't set the cursor for child windows */
1922 switch(LOWORD(lParam
))
1926 WORD msg
= HIWORD( lParam
);
1927 if ((msg
== WM_LBUTTONDOWN
) || (msg
== WM_MBUTTONDOWN
) ||
1928 (msg
== WM_RBUTTONDOWN
))
1935 HICON16 hCursor
= (HICON16
) GetClassWord(hwnd
, GCW_HCURSOR
);
1937 SetCursor16(hCursor
);
1945 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZEWE16
) );
1949 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZENS16
) );
1953 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZENWSE16
) );
1957 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZENESW16
) );
1960 /* Default cursor: arrow */
1961 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_ARROW16
) );
1964 /***********************************************************************
1967 BOOL
NC_GetSysPopupPos( WND
* wndPtr
, RECT
* rect
)
1969 if( wndPtr
->hSysMenu
)
1971 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
1972 GetWindowRect( wndPtr
->hwndSelf
, rect
);
1975 if (TWEAK_WineLook
== WIN31_LOOK
)
1976 NC_GetInsideRect( wndPtr
->hwndSelf
, rect
);
1978 NC_GetInsideRect95( wndPtr
->hwndSelf
, rect
);
1979 OffsetRect( rect
, wndPtr
->rectWindow
.left
, wndPtr
->rectWindow
.top
);
1980 if (wndPtr
->dwStyle
& WS_CHILD
)
1981 ClientToScreen( wndPtr
->parent
->hwndSelf
, (POINT
*)rect
);
1982 if (TWEAK_WineLook
== WIN31_LOOK
) {
1983 rect
->right
= rect
->left
+ GetSystemMetrics(SM_CXSIZE
);
1984 rect
->bottom
= rect
->top
+ GetSystemMetrics(SM_CYSIZE
);
1987 rect
->right
= rect
->left
+ GetSystemMetrics(SM_CYCAPTION
) - 1;
1988 rect
->bottom
= rect
->top
+ GetSystemMetrics(SM_CYCAPTION
) - 1;
1996 /***********************************************************************
1999 * Initialisation of a move or resize, when initiatied from a menu choice.
2000 * Return hit test code for caption or sizing border.
2002 static LONG
NC_StartSizeMove( WND
* wndPtr
, WPARAM16 wParam
,
2003 POINT16
*capturePoint
)
2010 GetWindowRect(wndPtr
->hwndSelf
,&rectWindow
);
2012 if ((wParam
& 0xfff0) == SC_MOVE
)
2014 /* Move pointer at the center of the caption */
2016 if (TWEAK_WineLook
== WIN31_LOOK
)
2017 NC_GetInsideRect( wndPtr
->hwndSelf
, &rect
);
2019 NC_GetInsideRect95( wndPtr
->hwndSelf
, &rect
);
2020 if (wndPtr
->dwStyle
& WS_SYSMENU
)
2021 rect
.left
+= GetSystemMetrics(SM_CXSIZE
) + 1;
2022 if (wndPtr
->dwStyle
& WS_MINIMIZEBOX
)
2023 rect
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
2024 if (wndPtr
->dwStyle
& WS_MAXIMIZEBOX
)
2025 rect
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
2026 pt
.x
= rectWindow
.left
+ (rect
.right
- rect
.left
) / 2;
2027 pt
.y
= rectWindow
.top
+ rect
.top
+ GetSystemMetrics(SM_CYSIZE
)/2;
2028 hittest
= HTCAPTION
;
2035 MSG_InternalGetMessage( &msg
, 0, 0, MSGF_SIZE
, PM_REMOVE
, FALSE
);
2039 CONV_POINT32TO16(&msg
.pt
, &pt
);
2040 hittest
= NC_HandleNCHitTest( wndPtr
->hwndSelf
, pt
);
2041 if ((hittest
< HTLEFT
) || (hittest
> HTBOTTOMRIGHT
))
2053 pt
.x
=(rectWindow
.left
+rectWindow
.right
)/2;
2054 pt
.y
= rectWindow
.top
+ GetSystemMetrics(SM_CYFRAME
) / 2;
2058 pt
.x
=(rectWindow
.left
+rectWindow
.right
)/2;
2059 pt
.y
= rectWindow
.bottom
- GetSystemMetrics(SM_CYFRAME
) / 2;
2063 pt
.x
= rectWindow
.left
+ GetSystemMetrics(SM_CXFRAME
) / 2;
2064 pt
.y
=(rectWindow
.top
+rectWindow
.bottom
)/2;
2068 pt
.x
= rectWindow
.right
- GetSystemMetrics(SM_CXFRAME
) / 2;
2069 pt
.y
=(rectWindow
.top
+rectWindow
.bottom
)/2;
2072 case VK_ESCAPE
: return 0;
2078 SetCursorPos( pt
.x
, pt
.y
);
2079 NC_HandleSetCursor( wndPtr
->hwndSelf
,
2080 wndPtr
->hwndSelf
, MAKELONG( hittest
, WM_MOUSEMOVE
));
2085 /***********************************************************************
2088 * Perform SC_MOVE and SC_SIZE commands. `
2090 static void NC_DoSizeMove( HWND hwnd
, WORD wParam
)
2093 RECT sizingRect
, mouseRect
;
2095 LONG hittest
= (LONG
)(wParam
& 0x0f);
2096 HCURSOR16 hDragCursor
= 0, hOldCursor
= 0;
2097 POINT minTrack
, maxTrack
;
2098 POINT16 capturePoint
, pt
;
2099 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
2100 BOOL thickframe
= HAS_THICKFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
);
2101 BOOL iconic
= wndPtr
->dwStyle
& WS_MINIMIZE
;
2103 DWORD dwPoint
= GetMessagePos ();
2105 capturePoint
= pt
= *(POINT16
*)&dwPoint
;
2107 if (IsZoomed(hwnd
) || !IsWindowVisible(hwnd
) ||
2108 (wndPtr
->flags
& WIN_MANAGED
)) goto END
;
2110 if ((wParam
& 0xfff0) == SC_MOVE
)
2112 if (!(wndPtr
->dwStyle
& WS_CAPTION
)) goto END
;
2114 hittest
= NC_StartSizeMove( wndPtr
, wParam
, &capturePoint
);
2115 if (!hittest
) goto END
;
2119 if (!thickframe
) goto END
;
2120 if ( hittest
&& hittest
!= HTSYSMENU
) hittest
+= 2;
2124 hittest
= NC_StartSizeMove( wndPtr
, wParam
, &capturePoint
);
2133 /* Get min/max info */
2135 WINPOS_GetMinMaxInfo( wndPtr
, NULL
, NULL
, &minTrack
, &maxTrack
);
2136 sizingRect
= wndPtr
->rectWindow
;
2137 if (wndPtr
->dwStyle
& WS_CHILD
)
2138 GetClientRect( wndPtr
->parent
->hwndSelf
, &mouseRect
);
2140 SetRect(&mouseRect
, 0, 0, GetSystemMetrics(SM_CXSCREEN
), GetSystemMetrics(SM_CYSCREEN
));
2141 if (ON_LEFT_BORDER(hittest
))
2143 mouseRect
.left
= MAX( mouseRect
.left
, sizingRect
.right
-maxTrack
.x
);
2144 mouseRect
.right
= MIN( mouseRect
.right
, sizingRect
.right
-minTrack
.x
);
2146 else if (ON_RIGHT_BORDER(hittest
))
2148 mouseRect
.left
= MAX( mouseRect
.left
, sizingRect
.left
+minTrack
.x
);
2149 mouseRect
.right
= MIN( mouseRect
.right
, sizingRect
.left
+maxTrack
.x
);
2151 if (ON_TOP_BORDER(hittest
))
2153 mouseRect
.top
= MAX( mouseRect
.top
, sizingRect
.bottom
-maxTrack
.y
);
2154 mouseRect
.bottom
= MIN( mouseRect
.bottom
,sizingRect
.bottom
-minTrack
.y
);
2156 else if (ON_BOTTOM_BORDER(hittest
))
2158 mouseRect
.top
= MAX( mouseRect
.top
, sizingRect
.top
+minTrack
.y
);
2159 mouseRect
.bottom
= MIN( mouseRect
.bottom
, sizingRect
.top
+maxTrack
.y
);
2161 if (wndPtr
->dwStyle
& WS_CHILD
)
2163 MapWindowPoints( wndPtr
->parent
->hwndSelf
, 0,
2164 (LPPOINT
)&mouseRect
, 2 );
2166 SendMessage16( hwnd
, WM_ENTERSIZEMOVE
, 0, 0 );
2168 if (GetCapture() != hwnd
) SetCapture( hwnd
);
2170 if (wndPtr
->dwStyle
& WS_CHILD
)
2172 /* Retrieve a default cache DC (without using the window style) */
2173 hdc
= GetDCEx( wndPtr
->parent
->hwndSelf
, 0, DCX_CACHE
);
2176 { /* Grab the server only when moving top-level windows without desktop */
2180 wndPtr
->pDriver
->pPreSizeMove(wndPtr
);
2182 if( iconic
) /* create a cursor for dragging */
2184 HICON16 hIcon
= GetClassWord(wndPtr
->hwndSelf
, GCW_HICON
);
2185 if(!hIcon
) hIcon
= (HICON16
) SendMessage16( hwnd
, WM_QUERYDRAGICON
, 0, 0L);
2186 if( hIcon
) hDragCursor
= CURSORICON_IconToCursor( hIcon
, TRUE
);
2187 if( !hDragCursor
) iconic
= FALSE
;
2190 if( !iconic
) NC_DrawMovingFrame( hdc
, &sizingRect
, thickframe
);
2196 MSG_InternalGetMessage( &msg
, 0, 0, MSGF_SIZE
, PM_REMOVE
, FALSE
);
2198 /* Exit on button-up, Return, or Esc */
2199 if ((msg
.message
== WM_LBUTTONUP
) ||
2200 ((msg
.message
== WM_KEYDOWN
) &&
2201 ((msg
.wParam
== VK_RETURN
) || (msg
.wParam
== VK_ESCAPE
)))) break;
2203 if ((msg
.message
!= WM_KEYDOWN
) && (msg
.message
!= WM_MOUSEMOVE
))
2204 continue; /* We are not interested in other messages */
2206 dwPoint
= GetMessagePos ();
2207 pt
= *(POINT16
*)&dwPoint
;
2209 if (msg
.message
== WM_KEYDOWN
) switch(msg
.wParam
)
2211 case VK_UP
: pt
.y
-= 8; break;
2212 case VK_DOWN
: pt
.y
+= 8; break;
2213 case VK_LEFT
: pt
.x
-= 8; break;
2214 case VK_RIGHT
: pt
.x
+= 8; break;
2217 pt
.x
= MAX( pt
.x
, mouseRect
.left
);
2218 pt
.x
= MIN( pt
.x
, mouseRect
.right
);
2219 pt
.y
= MAX( pt
.y
, mouseRect
.top
);
2220 pt
.y
= MIN( pt
.y
, mouseRect
.bottom
);
2222 dx
= pt
.x
- capturePoint
.x
;
2223 dy
= pt
.y
- capturePoint
.y
;
2230 if( iconic
) /* ok, no system popup tracking */
2232 hOldCursor
= SetCursor(hDragCursor
);
2234 WINPOS_ShowIconTitle( wndPtr
, FALSE
);
2238 if (msg
.message
== WM_KEYDOWN
) SetCursorPos( pt
.x
, pt
.y
);
2241 RECT newRect
= sizingRect
;
2243 if (hittest
== HTCAPTION
) OffsetRect( &newRect
, dx
, dy
);
2244 if (ON_LEFT_BORDER(hittest
)) newRect
.left
+= dx
;
2245 else if (ON_RIGHT_BORDER(hittest
)) newRect
.right
+= dx
;
2246 if (ON_TOP_BORDER(hittest
)) newRect
.top
+= dy
;
2247 else if (ON_BOTTOM_BORDER(hittest
)) newRect
.bottom
+= dy
;
2250 NC_DrawMovingFrame( hdc
, &sizingRect
, thickframe
);
2251 NC_DrawMovingFrame( hdc
, &newRect
, thickframe
);
2254 sizingRect
= newRect
;
2262 if( moved
) /* restore cursors, show icon title later on */
2264 ShowCursor( FALSE
);
2265 SetCursor( hOldCursor
);
2267 DestroyCursor( hDragCursor
);
2270 NC_DrawMovingFrame( hdc
, &sizingRect
, thickframe
);
2272 if (wndPtr
->dwStyle
& WS_CHILD
)
2273 ReleaseDC( wndPtr
->parent
->hwndSelf
, hdc
);
2276 ReleaseDC( 0, hdc
);
2279 wndPtr
->pDriver
->pPostSizeMove(wndPtr
);
2281 if (HOOK_IsHooked( WH_CBT
))
2283 RECT16
* pr
= SEGPTR_NEW(RECT16
);
2286 CONV_RECT32TO16( &sizingRect
, pr
);
2287 if( HOOK_CallHooks16( WH_CBT
, HCBT_MOVESIZE
, hwnd
,
2288 (LPARAM
)SEGPTR_GET(pr
)) )
2289 sizingRect
= wndPtr
->rectWindow
;
2291 CONV_RECT16TO32( pr
, &sizingRect
);
2295 SendMessage16( hwnd
, WM_EXITSIZEMOVE
, 0, 0 );
2296 SendMessage16( hwnd
, WM_SETVISIBLE
, !IsIconic16(hwnd
), 0L);
2298 /* window moved or resized */
2301 /* if the moving/resizing isn't canceled call SetWindowPos
2302 * with the new position or the new size of the window
2304 if (!((msg
.message
== WM_KEYDOWN
) && (msg
.wParam
== VK_ESCAPE
)) )
2306 /* NOTE: SWP_NOACTIVATE prevents document window activation in Word 6 */
2307 SetWindowPos( hwnd
, 0, sizingRect
.left
, sizingRect
.top
,
2308 sizingRect
.right
- sizingRect
.left
,
2309 sizingRect
.bottom
- sizingRect
.top
,
2310 ( hittest
== HTCAPTION
) ? SWP_NOSIZE
: 0 );
2314 if( IsWindow(hwnd
) )
2315 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
2317 /* Single click brings up the system menu when iconized */
2321 if( wndPtr
->dwStyle
& WS_SYSMENU
)
2322 SendMessage16( hwnd
, WM_SYSCOMMAND
,
2323 SC_MOUSEMENU
+ HTSYSMENU
, *((LPARAM
*)&pt
));
2325 else WINPOS_ShowIconTitle( wndPtr
, TRUE
);
2329 WIN_ReleaseWndPtr(wndPtr
);
2333 /***********************************************************************
2334 * NC_TrackMinMaxBox95
2336 * Track a mouse button press on the minimize or maximize box.
2338 * The big difference between 3.1 and 95 is the disabled button state.
2339 * In win95 the system button can be disabled, so it can ignore the mouse
2343 static void NC_TrackMinMaxBox95( HWND hwnd
, WORD wParam
)
2347 HDC hdc
= GetWindowDC( hwnd
);
2348 BOOL pressed
= TRUE
;
2350 DWORD wndStyle
= GetWindowLongA( hwnd
, GWL_STYLE
);
2351 HMENU hSysMenu
= GetSystemMenu(hwnd
, FALSE
);
2353 void (*paintButton
)(HWND
, HDC16
, BOOL
, BOOL
);
2355 if (wParam
== HTMINBUTTON
)
2357 /* If the style is not present, do nothing */
2358 if (!(wndStyle
& WS_MINIMIZEBOX
))
2361 /* Check if the sysmenu item for minimize is there */
2362 state
= GetMenuState(hSysMenu
, SC_MINIMIZE
, MF_BYCOMMAND
);
2364 paintButton
= &NC_DrawMinButton95
;
2368 /* If the style is not present, do nothing */
2369 if (!(wndStyle
& WS_MAXIMIZEBOX
))
2372 /* Check if the sysmenu item for maximize is there */
2373 state
= GetMenuState(hSysMenu
, SC_MAXIMIZE
, MF_BYCOMMAND
);
2375 paintButton
= &NC_DrawMaxButton95
;
2380 (*paintButton
)( hwnd
, hdc
, TRUE
, FALSE
);
2384 BOOL oldstate
= pressed
;
2385 MSG_InternalGetMessage( &msg
, 0, 0, 0, PM_REMOVE
, FALSE
);
2386 CONV_POINT32TO16( &msg
.pt
, &pt16
);
2388 pressed
= (NC_HandleNCHitTest( hwnd
, pt16
) == wParam
);
2389 if (pressed
!= oldstate
)
2390 (*paintButton
)( hwnd
, hdc
, pressed
, FALSE
);
2391 } while (msg
.message
!= WM_LBUTTONUP
);
2393 (*paintButton
)( hwnd
, hdc
, FALSE
, FALSE
);
2396 ReleaseDC( hwnd
, hdc
);
2398 /* If the item minimize or maximize of the sysmenu are not there */
2399 /* or if the style is not present, do nothing */
2400 if ((!pressed
) || (state
== 0xFFFFFFFF))
2403 if (wParam
== HTMINBUTTON
)
2404 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MINIMIZE
, *(LONG
*)&pt16
);
2406 SendMessage16( hwnd
, WM_SYSCOMMAND
,
2407 IsZoomed(hwnd
) ? SC_RESTORE
:SC_MAXIMIZE
, *(LONG
*)&pt16
);
2410 /***********************************************************************
2413 * Track a mouse button press on the minimize or maximize box.
2415 static void NC_TrackMinMaxBox( HWND hwnd
, WORD wParam
)
2419 HDC hdc
= GetWindowDC( hwnd
);
2420 BOOL pressed
= TRUE
;
2421 void (*paintButton
)(HWND
, HDC16
, BOOL
);
2425 if (wParam
== HTMINBUTTON
)
2426 paintButton
= &NC_DrawMinButton
;
2428 paintButton
= &NC_DrawMaxButton
;
2430 (*paintButton
)( hwnd
, hdc
, TRUE
);
2434 BOOL oldstate
= pressed
;
2435 MSG_InternalGetMessage( &msg
, 0, 0, 0, PM_REMOVE
, FALSE
);
2436 CONV_POINT32TO16( &msg
.pt
, &pt16
);
2438 pressed
= (NC_HandleNCHitTest( hwnd
, pt16
) == wParam
);
2439 if (pressed
!= oldstate
)
2440 (*paintButton
)( hwnd
, hdc
, pressed
);
2441 } while (msg
.message
!= WM_LBUTTONUP
);
2443 (*paintButton
)( hwnd
, hdc
, FALSE
);
2446 ReleaseDC( hwnd
, hdc
);
2448 if (!pressed
) return;
2450 if (wParam
== HTMINBUTTON
)
2451 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MINIMIZE
, *(LONG
*)&pt16
);
2453 SendMessage16( hwnd
, WM_SYSCOMMAND
,
2454 IsZoomed(hwnd
) ? SC_RESTORE
:SC_MAXIMIZE
, *(LONG
*)&pt16
);
2458 /***********************************************************************
2459 * NC_TrackCloseButton95
2461 * Track a mouse button press on the Win95 close button.
2464 NC_TrackCloseButton95 (HWND hwnd
, WORD wParam
)
2469 BOOL pressed
= TRUE
;
2470 HMENU hSysMenu
= GetSystemMenu(hwnd
, FALSE
);
2476 state
= GetMenuState(hSysMenu
, SC_CLOSE
, MF_BYCOMMAND
);
2478 /* If the item close of the sysmenu is disabled or not there do nothing */
2479 if((state
& MF_DISABLED
) || (state
& MF_GRAYED
) || (state
== 0xFFFFFFFF))
2482 hdc
= GetWindowDC( hwnd
);
2486 NC_DrawCloseButton95 (hwnd
, hdc
, TRUE
, FALSE
);
2490 BOOL oldstate
= pressed
;
2491 MSG_InternalGetMessage( &msg
, 0, 0, 0, PM_REMOVE
, FALSE
);
2492 CONV_POINT32TO16( &msg
.pt
, &pt16
);
2494 pressed
= (NC_HandleNCHitTest( hwnd
, pt16
) == wParam
);
2495 if (pressed
!= oldstate
)
2496 NC_DrawCloseButton95 (hwnd
, hdc
, pressed
, FALSE
);
2497 } while (msg
.message
!= WM_LBUTTONUP
);
2499 NC_DrawCloseButton95 (hwnd
, hdc
, FALSE
, FALSE
);
2502 ReleaseDC( hwnd
, hdc
);
2503 if (!pressed
) return;
2505 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_CLOSE
, *(LONG
*)&pt16
);
2509 /***********************************************************************
2512 * Track a mouse button press on the horizontal or vertical scroll-bar.
2514 static void NC_TrackScrollBar( HWND hwnd
, WPARAM wParam
, POINT pt
)
2518 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
2520 if ((wParam
& 0xfff0) == SC_HSCROLL
)
2522 if ((wParam
& 0x0f) != HTHSCROLL
) goto END
;
2523 scrollbar
= SB_HORZ
;
2525 else /* SC_VSCROLL */
2527 if ((wParam
& 0x0f) != HTVSCROLL
) goto END
;
2528 scrollbar
= SB_VERT
;
2531 if (!(msg
= SEGPTR_NEW(MSG16
))) goto END
;
2532 pt
.x
-= wndPtr
->rectWindow
.left
;
2533 pt
.y
-= wndPtr
->rectWindow
.top
;
2535 SCROLL_HandleScrollEvent( hwnd
, scrollbar
, WM_LBUTTONDOWN
, pt
);
2539 GetMessage16( SEGPTR_GET(msg
), 0, 0, 0 );
2540 switch(msg
->message
)
2545 pt
.x
= LOWORD(msg
->lParam
) + wndPtr
->rectClient
.left
-
2546 wndPtr
->rectWindow
.left
;
2547 pt
.y
= HIWORD(msg
->lParam
) + wndPtr
->rectClient
.top
-
2548 wndPtr
->rectWindow
.top
;
2549 SCROLL_HandleScrollEvent( hwnd
, scrollbar
, msg
->message
, pt
);
2552 TranslateMessage16( msg
);
2553 DispatchMessage16( msg
);
2556 if (!IsWindow( hwnd
))
2561 } while (msg
->message
!= WM_LBUTTONUP
);
2564 WIN_ReleaseWndPtr(wndPtr
);
2567 /***********************************************************************
2568 * NC_HandleNCLButtonDown
2570 * Handle a WM_NCLBUTTONDOWN message. Called from DefWindowProc().
2572 LONG
NC_HandleNCLButtonDown( WND
* pWnd
, WPARAM16 wParam
, LPARAM lParam
)
2574 HWND hwnd
= pWnd
->hwndSelf
;
2576 if(GetForegroundWindow() != hwnd
)
2577 SetWindowPos( hwnd
, 0, 0, 0,0,0,SWP_NOSIZE
| SWP_NOMOVE
| SWP_DRAWFRAME
);
2579 switch(wParam
) /* Hit test */
2582 hwnd
= WIN_GetTopParent(hwnd
);
2584 if( WINPOS_SetActiveWindow(hwnd
, TRUE
, TRUE
) || (GetActiveWindow() == hwnd
) )
2585 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_MOVE
+ HTCAPTION
, lParam
);
2589 if( pWnd
->dwStyle
& WS_SYSMENU
)
2591 if( !(pWnd
->dwStyle
& WS_MINIMIZE
) )
2593 HDC hDC
= GetWindowDC(hwnd
);
2594 if (TWEAK_WineLook
== WIN31_LOOK
)
2595 NC_DrawSysButton( hwnd
, hDC
, TRUE
);
2597 NC_DrawSysButton95( hwnd
, hDC
, TRUE
);
2598 ReleaseDC( hwnd
, hDC
);
2600 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MOUSEMENU
+ HTSYSMENU
, lParam
);
2605 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MOUSEMENU
, lParam
);
2609 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_HSCROLL
+ HTHSCROLL
, lParam
);
2613 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_VSCROLL
+ HTVSCROLL
, lParam
);
2618 if (TWEAK_WineLook
== WIN31_LOOK
)
2619 NC_TrackMinMaxBox( hwnd
, wParam
);
2621 NC_TrackMinMaxBox95( hwnd
, wParam
);
2625 if (TWEAK_WineLook
>= WIN95_LOOK
)
2626 NC_TrackCloseButton95 (hwnd
, wParam
);
2637 /* make sure hittest fits into 0xf and doesn't overlap with HTSYSMENU */
2638 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_SIZE
+ wParam
- 2, lParam
);
2648 /***********************************************************************
2649 * NC_HandleNCLButtonDblClk
2651 * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc().
2653 LONG
NC_HandleNCLButtonDblClk( WND
*pWnd
, WPARAM16 wParam
, LPARAM lParam
)
2656 * if this is an icon, send a restore since we are handling
2659 if (pWnd
->dwStyle
& WS_MINIMIZE
)
2661 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_RESTORE
, lParam
);
2665 switch(wParam
) /* Hit test */
2668 /* stop processing if WS_MAXIMIZEBOX is missing */
2669 if (pWnd
->dwStyle
& WS_MAXIMIZEBOX
)
2670 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
,
2671 (pWnd
->dwStyle
& WS_MAXIMIZE
) ? SC_RESTORE
: SC_MAXIMIZE
,
2676 if (!(GetClassWord(pWnd
->hwndSelf
, GCW_STYLE
) & CS_NOCLOSE
))
2677 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_CLOSE
, lParam
);
2681 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_HSCROLL
+ HTHSCROLL
,
2686 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_VSCROLL
+ HTVSCROLL
,
2694 /***********************************************************************
2695 * NC_HandleSysCommand
2697 * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
2699 LONG
NC_HandleSysCommand( HWND hwnd
, WPARAM16 wParam
, POINT16 pt
)
2701 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
2703 UINT16 uCommand
= wParam
& 0xFFF0;
2705 TRACE_(nonclient
)("Handling WM_SYSCOMMAND %x %d,%d\n",
2706 wParam
, pt
.x
, pt
.y
);
2708 if (wndPtr
->dwStyle
& WS_CHILD
&& uCommand
!= SC_KEYMENU
)
2709 ScreenToClient16( wndPtr
->parent
->hwndSelf
, &pt
);
2715 NC_DoSizeMove( hwnd
, wParam
);
2719 ShowWindow( hwnd
, SW_MINIMIZE
);
2723 ShowWindow( hwnd
, SW_MAXIMIZE
);
2727 ShowWindow( hwnd
, SW_RESTORE
);
2731 WIN_ReleaseWndPtr(wndPtr
);
2732 return SendMessage16( hwnd
, WM_CLOSE
, 0, 0 );
2736 CONV_POINT16TO32( &pt
, &pt32
);
2737 NC_TrackScrollBar( hwnd
, wParam
, pt32
);
2741 CONV_POINT16TO32( &pt
, &pt32
);
2742 MENU_TrackMouseMenuBar( wndPtr
, wParam
& 0x000F, pt32
);
2746 MENU_TrackKbdMenuBar( wndPtr
, wParam
, pt
.x
);
2750 WinExec( "taskman.exe", SW_SHOWNORMAL
);
2754 if (wParam
== SC_ABOUTWINE
)
2755 ShellAboutA(hwnd
,"Wine", WINE_RELEASE_INFO
, 0);
2757 if (wParam
== SC_PUTMARK
)
2758 TRACE_(shell
)("Mark requested by user\n");
2765 FIXME_(nonclient
)("unimplemented!\n");
2768 WIN_ReleaseWndPtr(wndPtr
);
2772 /*************************************************************
2775 * Stub for the grayed button of the caption
2777 *************************************************************/
2779 BOOL
NC_DrawGrayButton(HDC hdc
, int x
, int y
)
2782 HDC hdcMask
= CreateCompatibleDC (0);
2785 hMaskBmp
= CreateBitmap (12, 10, 1, 1, lpGrayMask
);
2790 SelectObject (hdcMask
, hMaskBmp
);
2792 /* Draw the grayed bitmap using the mask */
2793 hOldBrush
= SelectObject (hdc
, RGB(128, 128, 128));
2794 BitBlt (hdc
, x
, y
, 12, 10,
2795 hdcMask
, 0, 0, 0xB8074A);
2798 SelectObject (hdc
, hOldBrush
);
2799 DeleteObject(hMaskBmp
);