2 * Non-client area window functions
4 * Copyright 1994 Alexandre Julliard
11 #include "sysmetrics.h"
14 #include "cursoricon.h"
20 #include "nonclient.h"
23 #include "selectors.h"
29 static HBITMAP16 hbitmapClose
= 0;
30 static HBITMAP16 hbitmapCloseD
= 0;
31 static HBITMAP16 hbitmapMinimize
= 0;
32 static HBITMAP16 hbitmapMinimizeD
= 0;
33 static HBITMAP16 hbitmapMaximize
= 0;
34 static HBITMAP16 hbitmapMaximizeD
= 0;
35 static HBITMAP16 hbitmapRestore
= 0;
36 static HBITMAP16 hbitmapRestoreD
= 0;
38 #define SC_ABOUTWINE (SC_SCREENSAVE+1)
40 /* Some useful macros */
41 #define HAS_DLGFRAME(style,exStyle) \
42 (((exStyle) & WS_EX_DLGMODALFRAME) || \
43 (((style) & WS_DLGFRAME) && !((style) & WS_BORDER)))
45 #define HAS_THICKFRAME(style) \
46 (((style) & WS_THICKFRAME) && \
47 !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
49 #define HAS_FIXEDFRAME(style,exStyle) \
50 (((((exStyle) & WS_EX_DLGMODALFRAME) || \
51 ((style) & WS_DLGFRAME)) && ((style) & WS_BORDER)) && \
52 !((style) & WS_THICKFRAME))
54 #define HAS_SIZEFRAME(style) \
55 (((style) & WS_THICKFRAME) && \
56 !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
58 #define HAS_MENU(w) (!((w)->dwStyle & WS_CHILD) && ((w)->wIDmenu != 0))
60 #define ON_LEFT_BORDER(hit) \
61 (((hit) == HTLEFT) || ((hit) == HTTOPLEFT) || ((hit) == HTBOTTOMLEFT))
62 #define ON_RIGHT_BORDER(hit) \
63 (((hit) == HTRIGHT) || ((hit) == HTTOPRIGHT) || ((hit) == HTBOTTOMRIGHT))
64 #define ON_TOP_BORDER(hit) \
65 (((hit) == HTTOP) || ((hit) == HTTOPLEFT) || ((hit) == HTTOPRIGHT))
66 #define ON_BOTTOM_BORDER(hit) \
67 (((hit) == HTBOTTOM) || ((hit) == HTBOTTOMLEFT) || ((hit) == HTBOTTOMRIGHT))
69 /***********************************************************************
72 * Compute the size of the window rectangle from the size of the
75 static void NC_AdjustRect( LPRECT16 rect
, DWORD style
, BOOL32 menu
,
78 if (TWEAK_WineLook
> WIN31_LOOK
)
79 ERR(nonclient
, "Called in Win95 mode. Aiee! Please report this.\n" );
81 if(style
& WS_ICONIC
) return;
82 /* Decide if the window will be managed (see CreateWindowEx) */
83 if (!(Options
.managed
&& !(style
& WS_CHILD
) &&
84 ((style
& (WS_DLGFRAME
| WS_THICKFRAME
)) ||
85 (exStyle
& WS_EX_DLGMODALFRAME
))))
87 if (HAS_DLGFRAME( style
, exStyle
))
88 InflateRect16(rect
, SYSMETRICS_CXDLGFRAME
, SYSMETRICS_CYDLGFRAME
);
91 if (HAS_THICKFRAME(style
))
92 InflateRect16( rect
, SYSMETRICS_CXFRAME
, SYSMETRICS_CYFRAME
);
93 if (style
& WS_BORDER
)
94 InflateRect16( rect
, SYSMETRICS_CXBORDER
, SYSMETRICS_CYBORDER
);
97 if ((style
& WS_CAPTION
) == WS_CAPTION
)
98 rect
->top
-= SYSMETRICS_CYCAPTION
- SYSMETRICS_CYBORDER
;
100 if (menu
) rect
->top
-= SYSMETRICS_CYMENU
+ SYSMETRICS_CYBORDER
;
102 if (style
& WS_VSCROLL
) {
103 rect
->right
+= SYSMETRICS_CXVSCROLL
- 1;
104 if(!(style
& WS_BORDER
))
108 if (style
& WS_HSCROLL
) {
109 rect
->bottom
+= SYSMETRICS_CYHSCROLL
- 1;
110 if(!(style
& WS_BORDER
))
116 /******************************************************************************
117 * NC_AdjustRectOuter95
119 * Computes the size of the "outside" parts of the window based on the
120 * parameters of the client area.
129 * "Outer" parts of a window means the whole window frame, caption and
130 * menu bar. It does not include "inner" parts of the frame like client
131 * edge, static edge or scroll bars.
134 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
135 * Original (NC_AdjustRect95) cut & paste from NC_AdjustRect
137 * 20-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
138 * Split NC_AdjustRect95 into NC_AdjustRectOuter95 and
139 * NC_AdjustRectInner95 and added handling of Win95 styles.
141 *****************************************************************************/
144 NC_AdjustRectOuter95 (LPRECT16 rect
, DWORD style
, BOOL32 menu
, DWORD exStyle
)
146 if(style
& WS_ICONIC
) return;
148 /* Decide if the window will be managed (see CreateWindowEx) */
149 if (!(Options
.managed
&& !(style
& WS_CHILD
) &&
150 ((style
& (WS_DLGFRAME
| WS_THICKFRAME
)) ||
151 (exStyle
& WS_EX_DLGMODALFRAME
))))
153 if (HAS_FIXEDFRAME( style
, exStyle
))
154 InflateRect16(rect
, SYSMETRICS_CXDLGFRAME
, SYSMETRICS_CYDLGFRAME
);
157 if (HAS_SIZEFRAME(style
))
158 InflateRect16( rect
, SYSMETRICS_CXFRAME
, SYSMETRICS_CYFRAME
);
160 if (style
& WS_BORDER
)
161 InflateRect16( rect
, SYSMETRICS_CXBORDER
, SYSMETRICS_CYBORDER
);
165 if ((style
& WS_CAPTION
) == WS_CAPTION
)
166 if (exStyle
& WS_EX_TOOLWINDOW
)
167 rect
->top
-= SYSMETRICS_CYSMCAPTION
;
169 rect
->top
-= SYSMETRICS_CYCAPTION
;
173 rect
->top
-= sysMetrics
[SM_CYMENU
];
177 /******************************************************************************
178 * NC_AdjustRectInner95
180 * Computes the size of the "inside" part of the window based on the
181 * parameters of the client area.
189 * "Inner" part of a window means the window frame inside of the flat
190 * window frame. It includes the client edge, the static edge and the
194 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
195 * Original (NC_AdjustRect95) cut & paste from NC_AdjustRect
197 * 20-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
198 * Split NC_AdjustRect95 into NC_AdjustRectOuter95 and
199 * NC_AdjustRectInner95 and added handling of Win95 styles.
201 *****************************************************************************/
204 NC_AdjustRectInner95 (LPRECT16 rect
, DWORD style
, DWORD exStyle
)
206 if(style
& WS_ICONIC
) return;
208 if (exStyle
& WS_EX_CLIENTEDGE
)
209 InflateRect16 (rect
, sysMetrics
[SM_CXEDGE
], sysMetrics
[SM_CYEDGE
]);
211 if (exStyle
& WS_EX_STATICEDGE
)
212 InflateRect16 (rect
, sysMetrics
[SM_CXBORDER
], sysMetrics
[SM_CYBORDER
]);
214 if (style
& WS_VSCROLL
) rect
->right
+= SYSMETRICS_CXVSCROLL
;
215 if (style
& WS_HSCROLL
) rect
->bottom
+= SYSMETRICS_CYHSCROLL
;
219 /***********************************************************************
220 * DrawCaption16 [USER.660] Draws a caption bar
234 DrawCaption16 (HWND16 hwnd
, HDC16 hdc
, const RECT16
*rect
, UINT16 uFlags
)
239 CONV_RECT16TO32 (rect
, &rect32
);
241 return (BOOL16
)DrawCaptionTemp32A (hwnd
, hdc
, rect
? &rect32
: NULL
,
242 0, 0, NULL
, uFlags
& 0x1F);
246 /***********************************************************************
247 * DrawCaption32 [USER32.154] Draws a caption bar
261 DrawCaption32 (HWND32 hwnd
, HDC32 hdc
, const RECT32
*lpRect
, UINT32 uFlags
)
263 return DrawCaptionTemp32A (hwnd
, hdc
, lpRect
, 0, 0, NULL
, uFlags
& 0x1F);
267 /***********************************************************************
268 * DrawCaptionTemp16 [USER.657]
278 DrawCaptionTemp16 (HWND16 hwnd
, HDC16 hdc
, const RECT16
*rect
, HFONT16 hFont
,
279 HICON16 hIcon
, LPCSTR str
, UINT16 uFlags
)
284 CONV_RECT16TO32(rect
,&rect32
);
286 return (BOOL16
)DrawCaptionTemp32A (hwnd
, hdc
, rect
?&rect32
:NULL
, hFont
,
287 hIcon
, str
, uFlags
& 0x1F);
291 /***********************************************************************
292 * DrawCaptionTemp32A [USER32.599]
302 DrawCaptionTemp32A (HWND32 hwnd
, HDC32 hdc
, const RECT32
*rect
, HFONT32 hFont
,
303 HICON32 hIcon
, LPCSTR str
, UINT32 uFlags
)
307 TRACE (nonclient
, "(%08x,%08x,%p,%08x,%08x,\"%s\",%08x)\n",
308 hwnd
, hdc
, rect
, hFont
, hIcon
, str
, uFlags
);
310 /* drawing background */
311 if (uFlags
& DC_INBUTTON
) {
312 FillRect32 (hdc
, &rc
, GetSysColorBrush32 (COLOR_3DFACE
));
314 if (uFlags
& DC_ACTIVE
) {
315 HBRUSH32 hbr
= SelectObject32 (hdc
, CACHE_GetPattern55AABrush ());
316 PatBlt32 (hdc
, rc
.left
, rc
.top
,
317 rc
.right
-rc
.left
, rc
.bottom
-rc
.top
, 0xFA0089);
318 SelectObject32 (hdc
, hbr
);
322 FillRect32 (hdc
, &rc
, GetSysColorBrush32 ((uFlags
& DC_ACTIVE
) ?
323 COLOR_ACTIVECAPTION
: COLOR_INACTIVECAPTION
));
328 if ((uFlags
& DC_ICON
) && !(uFlags
& DC_SMALLCAP
)) {
332 pt
.y
= (rc
.bottom
+ rc
.top
- sysMetrics
[SM_CYSMICON
]) / 2;
335 DrawIconEx32 (hdc
, pt
.x
, pt
.y
, hIcon
, sysMetrics
[SM_CXSMICON
],
336 sysMetrics
[SM_CYSMICON
], 0, 0, DI_NORMAL
);
339 WND
*wndPtr
= WIN_FindWndPtr(hwnd
);
340 HICON32 hAppIcon
= 0;
342 if (wndPtr
->class->hIconSm
)
343 hAppIcon
= wndPtr
->class->hIconSm
;
344 else if (wndPtr
->class->hIcon
)
345 hAppIcon
= wndPtr
->class->hIcon
;
347 DrawIconEx32 (hdc
, pt
.x
, pt
.y
, hAppIcon
, sysMetrics
[SM_CXSMICON
],
348 sysMetrics
[SM_CYSMICON
], 0, 0, DI_NORMAL
);
351 rc
.left
+= (rc
.bottom
- rc
.top
);
355 if (uFlags
& DC_TEXT
) {
358 if (uFlags
& DC_INBUTTON
)
359 SetTextColor32 (hdc
, GetSysColor32 (COLOR_BTNTEXT
));
360 else if (uFlags
& DC_ACTIVE
)
361 SetTextColor32 (hdc
, GetSysColor32 (COLOR_CAPTIONTEXT
));
363 SetTextColor32 (hdc
, GetSysColor32 (COLOR_INACTIVECAPTIONTEXT
));
365 SetBkMode32 (hdc
, TRANSPARENT
);
368 hOldFont
= SelectObject32 (hdc
, hFont
);
370 NONCLIENTMETRICS32A nclm
;
372 nclm
.cbSize
= sizeof(NONCLIENTMETRICS32A
);
373 SystemParametersInfo32A (SPI_GETNONCLIENTMETRICS
, 0, &nclm
, 0);
374 hNewFont
= CreateFontIndirect32A ((uFlags
& DC_SMALLCAP
) ?
375 &nclm
.lfSmCaptionFont
: &nclm
.lfCaptionFont
);
376 hOldFont
= SelectObject32 (hdc
, hNewFont
);
380 DrawText32A (hdc
, str
, -1, &rc
,
381 DT_SINGLELINE
| DT_VCENTER
| DT_NOPREFIX
| DT_LEFT
);
385 nLen
= GetWindowText32A (hwnd
, szText
, 128);
386 DrawText32A (hdc
, szText
, nLen
, &rc
,
387 DT_SINGLELINE
| DT_VCENTER
| DT_NOPREFIX
| DT_LEFT
);
391 SelectObject32 (hdc
, hOldFont
);
393 DeleteObject32 (SelectObject32 (hdc
, hOldFont
));
396 /* drawing focus ??? */
398 FIXME (nonclient
, "undocumented flag (0x2000)!\n");
404 /***********************************************************************
405 * DrawCaptionTemp32W [USER32.602]
415 DrawCaptionTemp32W (HWND32 hwnd
, HDC32 hdc
, const RECT32
*rect
, HFONT32 hFont
,
416 HICON32 hIcon
, LPCWSTR str
, UINT32 uFlags
)
418 LPSTR p
= HEAP_strdupWtoA (GetProcessHeap (), 0, str
);
419 BOOL32 res
= DrawCaptionTemp32A (hwnd
, hdc
, rect
, hFont
, hIcon
, p
, uFlags
);
420 HeapFree (GetProcessHeap (), 0, p
);
425 /***********************************************************************
426 * AdjustWindowRect16 (USER.102)
428 BOOL16 WINAPI
AdjustWindowRect16( LPRECT16 rect
, DWORD style
, BOOL16 menu
)
430 return AdjustWindowRectEx16( rect
, style
, menu
, 0 );
434 /***********************************************************************
435 * AdjustWindowRect32 (USER32.2)
437 BOOL32 WINAPI
AdjustWindowRect32( LPRECT32 rect
, DWORD style
, BOOL32 menu
)
439 return AdjustWindowRectEx32( rect
, style
, menu
, 0 );
443 /***********************************************************************
444 * AdjustWindowRectEx16 (USER.454)
446 BOOL16 WINAPI
AdjustWindowRectEx16( LPRECT16 rect
, DWORD style
,
447 BOOL16 menu
, DWORD exStyle
)
449 /* Correct the window style */
451 if (!(style
& (WS_POPUP
| WS_CHILD
))) /* Overlapped window */
453 style
&= (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
| WS_CHILD
);
454 exStyle
&= (WS_EX_DLGMODALFRAME
| WS_EX_CLIENTEDGE
|
455 WS_EX_STATICEDGE
| WS_EX_TOOLWINDOW
);
456 if (exStyle
& WS_EX_DLGMODALFRAME
) style
&= ~WS_THICKFRAME
;
458 TRACE(nonclient
, "(%d,%d)-(%d,%d) %08lx %d %08lx\n",
459 rect
->left
, rect
->top
, rect
->right
, rect
->bottom
,
460 style
, menu
, exStyle
);
462 if (TWEAK_WineLook
== WIN31_LOOK
)
463 NC_AdjustRect( rect
, style
, menu
, exStyle
);
465 NC_AdjustRectOuter95( rect
, style
, menu
, exStyle
);
466 NC_AdjustRectInner95( rect
, style
, exStyle
);
473 /***********************************************************************
474 * AdjustWindowRectEx32 (USER32.3)
476 BOOL32 WINAPI
AdjustWindowRectEx32( LPRECT32 rect
, DWORD style
,
477 BOOL32 menu
, DWORD exStyle
)
482 CONV_RECT32TO16( rect
, &rect16
);
483 ret
= AdjustWindowRectEx16( &rect16
, style
, (BOOL16
)menu
, exStyle
);
484 CONV_RECT16TO32( &rect16
, rect
);
489 /***********************************************************************
490 * NC_HandleNCCalcSize
492 * Handle a WM_NCCALCSIZE message. Called from DefWindowProc().
494 LONG
NC_HandleNCCalcSize( WND
*pWnd
, RECT32
*winRect
)
496 RECT16 tmpRect
= { 0, 0, 0, 0 };
499 if (pWnd
->class->style
& CS_VREDRAW
) result
|= WVR_VREDRAW
;
500 if (pWnd
->class->style
& CS_HREDRAW
) result
|= WVR_HREDRAW
;
502 if( !( pWnd
->dwStyle
& WS_MINIMIZE
) ) {
503 if (TWEAK_WineLook
== WIN31_LOOK
)
504 NC_AdjustRect( &tmpRect
, pWnd
->dwStyle
, FALSE
, pWnd
->dwExStyle
);
506 NC_AdjustRectOuter95( &tmpRect
, pWnd
->dwStyle
, FALSE
, pWnd
->dwExStyle
);
508 winRect
->left
-= tmpRect
.left
;
509 winRect
->top
-= tmpRect
.top
;
510 winRect
->right
-= tmpRect
.right
;
511 winRect
->bottom
-= tmpRect
.bottom
;
513 if (HAS_MENU(pWnd
)) {
514 TRACE(nonclient
, "Calling "
515 "GetMenuBarHeight with HWND 0x%x, width %d, "
516 "at (%d, %d).\n", pWnd
->hwndSelf
,
517 winRect
->right
- winRect
->left
,
518 -tmpRect
.left
, -tmpRect
.top
);
521 MENU_GetMenuBarHeight( pWnd
->hwndSelf
,
522 winRect
->right
- winRect
->left
,
523 -tmpRect
.left
, -tmpRect
.top
) + 1;
526 if (TWEAK_WineLook
> WIN31_LOOK
) {
527 SetRect16 (&tmpRect
, 0, 0, 0, 0);
528 NC_AdjustRectInner95 (&tmpRect
, pWnd
->dwStyle
, pWnd
->dwExStyle
);
529 winRect
->left
-= tmpRect
.left
;
530 winRect
->top
-= tmpRect
.top
;
531 winRect
->right
-= tmpRect
.right
;
532 winRect
->bottom
-= tmpRect
.bottom
;
539 /***********************************************************************
542 * Get the 'inside' rectangle of a window, i.e. the whole window rectangle
543 * but without the borders (if any).
544 * The rectangle is in window coordinates (for drawing with GetWindowDC()).
546 static void NC_GetInsideRect( HWND32 hwnd
, RECT32
*rect
)
548 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
550 rect
->top
= rect
->left
= 0;
551 rect
->right
= wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
;
552 rect
->bottom
= wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
;
554 if ((wndPtr
->dwStyle
& WS_ICONIC
) || (wndPtr
->flags
& WIN_MANAGED
)) return;
556 /* Remove frame from rectangle */
557 if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
559 InflateRect32( rect
, -SYSMETRICS_CXDLGFRAME
, -SYSMETRICS_CYDLGFRAME
);
560 if (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
)
561 InflateRect32( rect
, -1, 0 );
565 if (HAS_THICKFRAME( wndPtr
->dwStyle
))
566 InflateRect32( rect
, -SYSMETRICS_CXFRAME
, -SYSMETRICS_CYFRAME
);
567 if (wndPtr
->dwStyle
& WS_BORDER
)
568 InflateRect32( rect
, -SYSMETRICS_CXBORDER
, -SYSMETRICS_CYBORDER
);
575 /***********************************************************************
578 * Get the 'inside' rectangle of a window, i.e. the whole window rectangle
579 * but without the borders (if any).
580 * The rectangle is in window coordinates (for drawing with GetWindowDC()).
584 NC_GetInsideRect95 (HWND32 hwnd
, RECT32
*rect
)
586 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
588 rect
->top
= rect
->left
= 0;
589 rect
->right
= wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
;
590 rect
->bottom
= wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
;
592 if ((wndPtr
->dwStyle
& WS_ICONIC
) || (wndPtr
->flags
& WIN_MANAGED
)) return;
594 /* Remove frame from rectangle */
595 if (HAS_FIXEDFRAME (wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
597 InflateRect32( rect
, -SYSMETRICS_CXFIXEDFRAME
, -SYSMETRICS_CYFIXEDFRAME
);
599 else if (HAS_SIZEFRAME (wndPtr
->dwStyle
))
601 InflateRect32( rect
, -SYSMETRICS_CXSIZEFRAME
, -SYSMETRICS_CYSIZEFRAME
);
603 /* if (wndPtr->dwStyle & WS_BORDER)
604 InflateRect32( rect, -SYSMETRICS_CXBORDER, -SYSMETRICS_CYBORDER );*/
607 if (wndPtr
->dwStyle
& WS_CHILD
) {
608 if (wndPtr
->dwExStyle
& WS_EX_CLIENTEDGE
)
609 InflateRect32 (rect
, -SYSMETRICS_CXEDGE
, -SYSMETRICS_CYEDGE
);
611 if (wndPtr
->dwExStyle
& WS_EX_STATICEDGE
)
612 InflateRect32 (rect
, -SYSMETRICS_CXBORDER
, -SYSMETRICS_CYBORDER
);
619 /***********************************************************************
622 * Handle a WM_NCHITTEST message. Called from NC_HandleNcHitTest().
625 LONG
NC_DoNCHitTest (WND
*wndPtr
, POINT16 pt
)
629 TRACE(nonclient
, "hwnd=%04x pt=%d,%d\n",
630 wndPtr
->hwndSelf
, pt
.x
, pt
.y
);
632 GetWindowRect16 (wndPtr
->hwndSelf
, &rect
);
633 if (!PtInRect16( &rect
, pt
)) return HTNOWHERE
;
635 if (wndPtr
->dwStyle
& WS_MINIMIZE
) return HTCAPTION
;
637 if (!(wndPtr
->flags
& WIN_MANAGED
))
640 if (HAS_THICKFRAME( wndPtr
->dwStyle
))
642 InflateRect16( &rect
, -SYSMETRICS_CXFRAME
, -SYSMETRICS_CYFRAME
);
643 if (wndPtr
->dwStyle
& WS_BORDER
)
644 InflateRect16(&rect
,-SYSMETRICS_CXBORDER
,-SYSMETRICS_CYBORDER
);
645 if (!PtInRect16( &rect
, pt
))
647 /* Check top sizing border */
650 if (pt
.x
< rect
.left
+SYSMETRICS_CXSIZE
) return HTTOPLEFT
;
651 if (pt
.x
>= rect
.right
-SYSMETRICS_CXSIZE
) return HTTOPRIGHT
;
654 /* Check bottom sizing border */
655 if (pt
.y
>= rect
.bottom
)
657 if (pt
.x
< rect
.left
+SYSMETRICS_CXSIZE
) return HTBOTTOMLEFT
;
658 if (pt
.x
>= rect
.right
-SYSMETRICS_CXSIZE
) return HTBOTTOMRIGHT
;
661 /* Check left sizing border */
662 if (pt
.x
< rect
.left
)
664 if (pt
.y
< rect
.top
+SYSMETRICS_CYSIZE
) return HTTOPLEFT
;
665 if (pt
.y
>= rect
.bottom
-SYSMETRICS_CYSIZE
) return HTBOTTOMLEFT
;
668 /* Check right sizing border */
669 if (pt
.x
>= rect
.right
)
671 if (pt
.y
< rect
.top
+SYSMETRICS_CYSIZE
) return HTTOPRIGHT
;
672 if (pt
.y
>= rect
.bottom
-SYSMETRICS_CYSIZE
) return HTBOTTOMRIGHT
;
677 else /* No thick frame */
679 if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
680 InflateRect16(&rect
, -SYSMETRICS_CXDLGFRAME
, -SYSMETRICS_CYDLGFRAME
);
681 else if (wndPtr
->dwStyle
& WS_BORDER
)
682 InflateRect16(&rect
, -SYSMETRICS_CXBORDER
, -SYSMETRICS_CYBORDER
);
683 if (!PtInRect16( &rect
, pt
)) return HTBORDER
;
688 if ((wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
690 rect
.top
+= sysMetrics
[SM_CYCAPTION
] - 1;
691 if (!PtInRect16( &rect
, pt
))
693 /* Check system menu */
694 if (wndPtr
->dwStyle
& WS_SYSMENU
)
695 rect
.left
+= SYSMETRICS_CXSIZE
;
696 if (pt
.x
<= rect
.left
) return HTSYSMENU
;
697 /* Check maximize box */
698 if (wndPtr
->dwStyle
& WS_MAXIMIZEBOX
)
699 rect
.right
-= SYSMETRICS_CXSIZE
+ 1;
700 if (pt
.x
>= rect
.right
) return HTMAXBUTTON
;
701 /* Check minimize box */
702 if (wndPtr
->dwStyle
& WS_MINIMIZEBOX
)
703 rect
.right
-= SYSMETRICS_CXSIZE
+ 1;
704 if (pt
.x
>= rect
.right
) return HTMINBUTTON
;
710 /* Check client area */
712 ScreenToClient16( wndPtr
->hwndSelf
, &pt
);
713 GetClientRect16( wndPtr
->hwndSelf
, &rect
);
714 if (PtInRect16( &rect
, pt
)) return HTCLIENT
;
716 /* Check vertical scroll bar */
718 if (wndPtr
->dwStyle
& WS_VSCROLL
)
720 rect
.right
+= SYSMETRICS_CXVSCROLL
;
721 if (PtInRect16( &rect
, pt
)) return HTVSCROLL
;
724 /* Check horizontal scroll bar */
726 if (wndPtr
->dwStyle
& WS_HSCROLL
)
728 rect
.bottom
+= SYSMETRICS_CYHSCROLL
;
729 if (PtInRect16( &rect
, pt
))
732 if ((wndPtr
->dwStyle
& WS_VSCROLL
) &&
733 (pt
.x
>= rect
.right
- SYSMETRICS_CXVSCROLL
))
741 if (HAS_MENU(wndPtr
))
743 if ((pt
.y
< 0) && (pt
.x
>= 0) && (pt
.x
< rect
.right
))
747 /* Should never get here */
752 /***********************************************************************
755 * Handle a WM_NCHITTEST message. Called from NC_HandleNCHitTest().
757 * FIXME: Just a modified copy of the Win 3.1 version.
761 NC_DoNCHitTest95 (WND
*wndPtr
, POINT16 pt
)
765 TRACE(nonclient
, "hwnd=%04x pt=%d,%d\n",
766 wndPtr
->hwndSelf
, pt
.x
, pt
.y
);
768 GetWindowRect16 (wndPtr
->hwndSelf
, &rect
);
769 if (!PtInRect16( &rect
, pt
)) return HTNOWHERE
;
771 if (wndPtr
->dwStyle
& WS_MINIMIZE
) return HTCAPTION
;
773 if (!(wndPtr
->flags
& WIN_MANAGED
))
776 if (HAS_SIZEFRAME( wndPtr
->dwStyle
))
778 InflateRect16( &rect
, -SYSMETRICS_CXFRAME
, -SYSMETRICS_CYFRAME
);
779 // if (wndPtr->dwStyle & WS_BORDER)
780 // InflateRect16(&rect,-SYSMETRICS_CXBORDER,-SYSMETRICS_CYBORDER);
781 if (!PtInRect16( &rect
, pt
))
783 /* Check top sizing border */
786 if (pt
.x
< rect
.left
+SYSMETRICS_CXSIZE
) return HTTOPLEFT
;
787 if (pt
.x
>= rect
.right
-SYSMETRICS_CXSIZE
) return HTTOPRIGHT
;
790 /* Check bottom sizing border */
791 if (pt
.y
>= rect
.bottom
)
793 if (pt
.x
< rect
.left
+SYSMETRICS_CXSIZE
) return HTBOTTOMLEFT
;
794 if (pt
.x
>= rect
.right
-SYSMETRICS_CXSIZE
) return HTBOTTOMRIGHT
;
797 /* Check left sizing border */
798 if (pt
.x
< rect
.left
)
800 if (pt
.y
< rect
.top
+SYSMETRICS_CYSIZE
) return HTTOPLEFT
;
801 if (pt
.y
>= rect
.bottom
-SYSMETRICS_CYSIZE
) return HTBOTTOMLEFT
;
804 /* Check right sizing border */
805 if (pt
.x
>= rect
.right
)
807 if (pt
.y
< rect
.top
+SYSMETRICS_CYSIZE
) return HTTOPRIGHT
;
808 if (pt
.y
>= rect
.bottom
-SYSMETRICS_CYSIZE
) return HTBOTTOMRIGHT
;
813 else /* No thick frame */
815 if (HAS_FIXEDFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
816 InflateRect16(&rect
, -SYSMETRICS_CXDLGFRAME
, -SYSMETRICS_CYDLGFRAME
);
817 // else if (wndPtr->dwStyle & WS_BORDER)
818 // InflateRect16(&rect, -SYSMETRICS_CXBORDER, -SYSMETRICS_CYBORDER);
819 if (!PtInRect16( &rect
, pt
)) return HTBORDER
;
824 if ((wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
826 if (wndPtr
->dwExStyle
& WS_EX_TOOLWINDOW
)
827 rect
.top
+= sysMetrics
[SM_CYSMCAPTION
] - 1;
829 rect
.top
+= sysMetrics
[SM_CYCAPTION
] - 1;
830 if (!PtInRect16( &rect
, pt
))
832 /* Check system menu */
833 if ((wndPtr
->dwStyle
& WS_SYSMENU
) &&
834 ((wndPtr
->class->hIconSm
) || (wndPtr
->class->hIcon
)))
835 rect
.left
+= sysMetrics
[SM_CYCAPTION
] - 1;
836 if (pt
.x
< rect
.left
) return HTSYSMENU
;
838 /* Check close button */
839 if (wndPtr
->dwStyle
& WS_SYSMENU
)
840 rect
.right
-= sysMetrics
[SM_CYCAPTION
] - 1;
841 if (pt
.x
> rect
.right
) return HTCLOSE
;
843 /* Check maximize box */
844 if (wndPtr
->dwStyle
& WS_MAXIMIZEBOX
)
845 rect
.right
-= SYSMETRICS_CXSIZE
+ 1;
846 if (pt
.x
> rect
.right
) return HTMAXBUTTON
;
848 /* Check minimize box */
849 if (wndPtr
->dwStyle
& WS_MINIMIZEBOX
)
850 rect
.right
-= SYSMETRICS_CXSIZE
+ 1;
851 if (pt
.x
> rect
.right
) return HTMINBUTTON
;
857 /* Check client area */
859 ScreenToClient16( wndPtr
->hwndSelf
, &pt
);
860 GetClientRect16( wndPtr
->hwndSelf
, &rect
);
861 if (PtInRect16( &rect
, pt
)) return HTCLIENT
;
863 /* Check vertical scroll bar */
865 if (wndPtr
->dwStyle
& WS_VSCROLL
)
867 rect
.right
+= SYSMETRICS_CXVSCROLL
;
868 if (PtInRect16( &rect
, pt
)) return HTVSCROLL
;
871 /* Check horizontal scroll bar */
873 if (wndPtr
->dwStyle
& WS_HSCROLL
)
875 rect
.bottom
+= SYSMETRICS_CYHSCROLL
;
876 if (PtInRect16( &rect
, pt
))
879 if ((wndPtr
->dwStyle
& WS_VSCROLL
) &&
880 (pt
.x
>= rect
.right
- SYSMETRICS_CXVSCROLL
))
888 if (HAS_MENU(wndPtr
))
890 if ((pt
.y
< 0) && (pt
.x
>= 0) && (pt
.x
< rect
.right
))
894 /* Should never get here */
899 /***********************************************************************
902 * Handle a WM_NCHITTEST message. Called from DefWindowProc().
905 NC_HandleNCHitTest (HWND32 hwnd
, POINT16 pt
)
907 WND
*wndPtr
= WIN_FindWndPtr (hwnd
);
912 if (TWEAK_WineLook
== WIN31_LOOK
)
913 return NC_DoNCHitTest (wndPtr
, pt
);
915 return NC_DoNCHitTest95 (wndPtr
, pt
);
919 /***********************************************************************
922 void NC_DrawSysButton( HWND32 hwnd
, HDC32 hdc
, BOOL32 down
)
927 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
929 if( !(wndPtr
->flags
& WIN_MANAGED
) )
931 NC_GetInsideRect( hwnd
, &rect
);
932 hdcMem
= CreateCompatibleDC32( hdc
);
933 hbitmap
= SelectObject32( hdcMem
, hbitmapClose
);
934 BitBlt32(hdc
, rect
.left
, rect
.top
, SYSMETRICS_CXSIZE
, SYSMETRICS_CYSIZE
,
935 hdcMem
, (wndPtr
->dwStyle
& WS_CHILD
) ? SYSMETRICS_CXSIZE
: 0, 0,
936 down
? NOTSRCCOPY
: SRCCOPY
);
937 SelectObject32( hdcMem
, hbitmap
);
938 DeleteDC32( hdcMem
);
943 /***********************************************************************
946 static void NC_DrawMaxButton( HWND32 hwnd
, HDC16 hdc
, BOOL32 down
)
949 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
951 if( !(wndPtr
->flags
& WIN_MANAGED
) )
953 NC_GetInsideRect( hwnd
, &rect
);
954 GRAPH_DrawBitmap( hdc
, (IsZoomed32(hwnd
)
955 ? (down
? hbitmapRestoreD
: hbitmapRestore
)
956 : (down
? hbitmapMaximizeD
: hbitmapMaximize
)),
957 rect
.right
- SYSMETRICS_CXSIZE
- 1, rect
.top
,
958 0, 0, SYSMETRICS_CXSIZE
+1, SYSMETRICS_CYSIZE
, FALSE
);
963 /***********************************************************************
966 static void NC_DrawMinButton( HWND32 hwnd
, HDC16 hdc
, BOOL32 down
)
969 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
971 if( !(wndPtr
->flags
& WIN_MANAGED
) )
973 NC_GetInsideRect( hwnd
, &rect
);
974 if (wndPtr
->dwStyle
& WS_MAXIMIZEBOX
) rect
.right
-= SYSMETRICS_CXSIZE
+1;
975 GRAPH_DrawBitmap( hdc
, (down
? hbitmapMinimizeD
: hbitmapMinimize
),
976 rect
.right
- SYSMETRICS_CXSIZE
- 1, rect
.top
,
977 0, 0, SYSMETRICS_CXSIZE
+1, SYSMETRICS_CYSIZE
, FALSE
);
982 /******************************************************************************
984 * void NC_DrawSysButton95(
989 * Draws the Win95 system icon.
992 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
993 * Original implementation from NC_DrawSysButton source.
994 * 11-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
997 *****************************************************************************/
1000 NC_DrawSysButton95 (HWND32 hwnd
, HDC32 hdc
, BOOL32 down
)
1002 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1004 if( !(wndPtr
->flags
& WIN_MANAGED
) )
1009 NC_GetInsideRect95( hwnd
, &rect
);
1011 if (wndPtr
->class->hIconSm
)
1012 hIcon
= wndPtr
->class->hIconSm
;
1013 else if (wndPtr
->class->hIcon
)
1014 hIcon
= wndPtr
->class->hIcon
;
1017 DrawIconEx32 (hdc
, rect
.left
+ 2, rect
.top
+ 2, hIcon
,
1018 sysMetrics
[SM_CXSMICON
],
1019 sysMetrics
[SM_CYSMICON
],
1022 return (hIcon
!= 0);
1028 /******************************************************************************
1030 * void NC_DrawCloseButton95(
1035 * Draws the Win95 close button.
1038 * 11-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1039 * Original implementation from NC_DrawSysButton95 source.
1041 *****************************************************************************/
1044 NC_DrawCloseButton95 (HWND32 hwnd
, HDC32 hdc
, BOOL32 down
)
1048 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1050 if( !(wndPtr
->flags
& WIN_MANAGED
) )
1053 HBITMAP32 hBmp
, hOldBmp
;
1055 NC_GetInsideRect95( hwnd
, &rect
);
1057 hdcMem
= CreateCompatibleDC32( hdc
);
1058 hBmp
= /*down ? hbitmapCloseD :*/ hbitmapClose
;
1059 hOldBmp
= SelectObject32 (hdcMem
, hBmp
);
1060 GetObject32A (hBmp
, sizeof(BITMAP32
), &bmp
);
1061 BitBlt32 (hdc
, rect
.right
- (sysMetrics
[SM_CYCAPTION
] + 1 + bmp
.bmWidth
) / 2,
1062 rect
.top
+ (sysMetrics
[SM_CYCAPTION
] - 1 - bmp
.bmHeight
) / 2,
1063 bmp
.bmWidth
, bmp
.bmHeight
, hdcMem
, 0, 0, down
? NOTSRCCOPY
: SRCCOPY
);
1065 SelectObject32 (hdcMem
, hOldBmp
);
1066 DeleteDC32 (hdcMem
);
1071 /******************************************************************************
1073 * NC_DrawMaxButton95(
1078 * Draws the maximize button for Win95 style windows.
1081 * Many. Spacing might still be incorrect. Need to fit a close
1082 * button between the max button and the edge.
1083 * Should scale the image with the title bar. And more...
1086 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1087 * Original implementation.
1089 *****************************************************************************/
1091 static void NC_DrawMaxButton95(
1097 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1101 if( !(wndPtr
->flags
& WIN_MANAGED
) &&
1102 GetBitmapDimensionEx32((bm
= IsZoomed32(hwnd
) ?
1103 (down
? hbitmapRestoreD
: hbitmapRestore
) :
1104 (down
? hbitmapMaximizeD
: hbitmapMaximize
)),
1107 NC_GetInsideRect95( hwnd
, &rect
);
1109 if (wndPtr
->dwStyle
& WS_SYSMENU
)
1110 rect
.right
-= sysMetrics
[SM_CYCAPTION
] + 1;
1112 GRAPH_DrawBitmap( hdc
, bm
, rect
.right
-
1113 (sysMetrics
[SM_CXSIZE
] + bmsz
.cx
) / 2,
1114 rect
.top
+ (sysMetrics
[SM_CYCAPTION
] - 1 - bmsz
.cy
) / 2,
1115 0, 0, bmsz
.cx
, bmsz
.cy
, FALSE
);
1122 /******************************************************************************
1124 * NC_DrawMinButton95(
1129 * Draws the minimize button for Win95 style windows.
1132 * Many. Spacing is still incorrect. Should scale the image with the
1133 * title bar. And more...
1136 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1137 * Original implementation.
1139 *****************************************************************************/
1141 static void NC_DrawMinButton95(
1147 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1151 if( !(wndPtr
->flags
& WIN_MANAGED
) &&
1152 GetBitmapDimensionEx32((bm
= down
? hbitmapMinimizeD
:
1153 hbitmapMinimize
), &bmsz
)) {
1155 NC_GetInsideRect95( hwnd
, &rect
);
1157 if (wndPtr
->dwStyle
& WS_SYSMENU
)
1158 rect
.right
-= sysMetrics
[SM_CYCAPTION
] + 1;
1160 if (wndPtr
->dwStyle
& WS_MAXIMIZEBOX
)
1162 (sysMetrics
[SM_CXSIZE
] + bmsz
.cx
) / 2;
1164 GRAPH_DrawBitmap( hdc
, bm
, rect
.right
-
1165 (sysMetrics
[SM_CXSIZE
] + bmsz
.cx
) / 2,
1166 rect
.top
+ (sysMetrics
[SM_CYCAPTION
] - 1 - bmsz
.cy
) / 2,
1167 0, 0, bmsz
.cx
, bmsz
.cy
, FALSE
);
1174 /***********************************************************************
1177 * Draw a window frame inside the given rectangle, and update the rectangle.
1178 * The correct pen for the frame must be selected in the DC.
1180 static void NC_DrawFrame( HDC32 hdc
, RECT32
*rect
, BOOL32 dlgFrame
,
1183 INT32 width
, height
;
1185 if (TWEAK_WineLook
!= WIN31_LOOK
)
1186 ERR (nonclient
, "Called in Win95 mode. Aiee! Please report this.\n" );
1190 width
= SYSMETRICS_CXDLGFRAME
- 1;
1191 height
= SYSMETRICS_CYDLGFRAME
- 1;
1192 SelectObject32( hdc
, GetSysColorBrush32(active
? COLOR_ACTIVECAPTION
:
1193 COLOR_INACTIVECAPTION
) );
1197 width
= SYSMETRICS_CXFRAME
- 1;
1198 height
= SYSMETRICS_CYFRAME
- 1;
1199 SelectObject32( hdc
, GetSysColorBrush32(active
? COLOR_ACTIVEBORDER
:
1200 COLOR_INACTIVEBORDER
) );
1204 PatBlt32( hdc
, rect
->left
, rect
->top
,
1205 rect
->right
- rect
->left
, height
, PATCOPY
);
1206 PatBlt32( hdc
, rect
->left
, rect
->top
,
1207 width
, rect
->bottom
- rect
->top
, PATCOPY
);
1208 PatBlt32( hdc
, rect
->left
, rect
->bottom
,
1209 rect
->right
- rect
->left
, -height
, PATCOPY
);
1210 PatBlt32( hdc
, rect
->right
, rect
->top
,
1211 -width
, rect
->bottom
- rect
->top
, PATCOPY
);
1215 InflateRect32( rect
, -width
, -height
);
1221 /* Draw inner rectangle */
1223 GRAPH_DrawRectangle( hdc
, rect
->left
+ width
,
1225 rect
->right
- rect
->left
- 2*width
,
1226 rect
->bottom
- rect
->top
- 2*height
,
1229 /* Draw the decorations */
1231 lpt
[4].x
= lpt
[0].x
= rect
->left
;
1232 lpt
[5].x
= lpt
[1].x
= rect
->left
+ width
;
1233 lpt
[6].x
= lpt
[2].x
= rect
->right
- 1;
1234 lpt
[7].x
= lpt
[3].x
= rect
->right
- width
- 1;
1236 lpt
[0].y
= lpt
[1].y
= lpt
[2].y
= lpt
[3].y
=
1237 rect
->top
+ SYSMETRICS_CYFRAME
+ SYSMETRICS_CYSIZE
;
1238 lpt
[4].y
= lpt
[5].y
= lpt
[6].y
= lpt
[7].y
=
1239 rect
->bottom
- SYSMETRICS_CYFRAME
- SYSMETRICS_CYSIZE
;
1241 lpt
[8].x
= lpt
[9].x
= lpt
[10].x
= lpt
[11].x
=
1242 rect
->left
+ SYSMETRICS_CXFRAME
+ SYSMETRICS_CXSIZE
;
1243 lpt
[12].x
= lpt
[13].x
= lpt
[14].x
= lpt
[15].x
=
1244 rect
->right
- SYSMETRICS_CXFRAME
- SYSMETRICS_CYSIZE
;
1246 lpt
[12].y
= lpt
[8].y
= rect
->top
;
1247 lpt
[13].y
= lpt
[9].y
= rect
->top
+ height
;
1248 lpt
[14].y
= lpt
[10].y
= rect
->bottom
- 1;
1249 lpt
[15].y
= lpt
[11].y
= rect
->bottom
- height
- 1;
1251 GRAPH_DrawLines( hdc
, lpt
, 8, (HPEN32
)0 ); /* 8 is the maximum */
1252 InflateRect32( rect
, -width
- 1, -height
- 1 );
1257 /******************************************************************************
1259 * void NC_DrawFrame95(
1265 * Draw a window frame inside the given rectangle, and update the rectangle.
1266 * The correct pen for the frame must be selected in the DC.
1269 * Many. First, just what IS a frame in Win95? Note that the 3D look
1270 * on the outer edge is handled by NC_DoNCPaint95. As is the inner
1271 * edge. The inner rectangle just inside the frame is handled by the
1274 * In short, for most people, this function should be a nop (unless
1275 * you LIKE thick borders in Win95/NT4.0 -- I've been working with
1276 * them lately, but just to get this code right). Even so, it doesn't
1277 * appear to be so. It's being worked on...
1280 * 06-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1281 * Original implementation (based on NC_DrawFrame)
1282 * 02-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1285 *****************************************************************************/
1287 static void NC_DrawFrame95(
1293 INT32 width
, height
;
1297 width
= sysMetrics
[SM_CXDLGFRAME
] - sysMetrics
[SM_CXEDGE
];
1298 height
= sysMetrics
[SM_CYDLGFRAME
] - sysMetrics
[SM_CYEDGE
];
1302 width
= sysMetrics
[SM_CXFRAME
] - sysMetrics
[SM_CXEDGE
];
1303 height
= sysMetrics
[SM_CYFRAME
] - sysMetrics
[SM_CYEDGE
];
1306 SelectObject32( hdc
, GetSysColorBrush32(active
? COLOR_ACTIVEBORDER
:
1307 COLOR_INACTIVEBORDER
) );
1310 PatBlt32( hdc
, rect
->left
, rect
->top
,
1311 rect
->right
- rect
->left
, height
, PATCOPY
);
1312 PatBlt32( hdc
, rect
->left
, rect
->top
,
1313 width
, rect
->bottom
- rect
->top
, PATCOPY
);
1314 PatBlt32( hdc
, rect
->left
, rect
->bottom
,
1315 rect
->right
- rect
->left
, -height
, PATCOPY
);
1316 PatBlt32( hdc
, rect
->right
, rect
->top
,
1317 -width
, rect
->bottom
- rect
->top
, PATCOPY
);
1319 InflateRect32( rect
, -width
, -height
);
1324 /***********************************************************************
1325 * NC_DrawMovingFrame
1327 * Draw the frame used when moving or resizing window.
1329 * FIXME: This causes problems in Win95 mode. (why?)
1331 static void NC_DrawMovingFrame( HDC32 hdc
, RECT32
*rect
, BOOL32 thickframe
)
1336 CONV_RECT32TO16( rect
, &r16
);
1337 FastWindowFrame( hdc
, &r16
, SYSMETRICS_CXFRAME
,
1338 SYSMETRICS_CYFRAME
, PATINVERT
);
1340 else DrawFocusRect32( hdc
, rect
);
1344 /***********************************************************************
1347 * Draw the window caption.
1348 * The correct pen for the window frame must be selected in the DC.
1350 static void NC_DrawCaption( HDC32 hdc
, RECT32
*rect
, HWND32 hwnd
,
1351 DWORD style
, BOOL32 active
)
1354 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
1357 if (wndPtr
->flags
& WIN_MANAGED
) return;
1361 if (!(hbitmapClose
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_CLOSE
) )))
1363 hbitmapCloseD
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_CLOSE
) );
1364 hbitmapMinimize
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_REDUCE
) );
1365 hbitmapMinimizeD
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_REDUCED
) );
1366 hbitmapMaximize
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_ZOOM
) );
1367 hbitmapMaximizeD
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_ZOOMD
) );
1368 hbitmapRestore
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_RESTORE
) );
1369 hbitmapRestoreD
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_RESTORED
) );
1372 if (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
)
1374 HBRUSH32 hbrushOld
= SelectObject32(hdc
, GetSysColorBrush32(COLOR_WINDOW
) );
1375 PatBlt32( hdc
, r
.left
, r
.top
, 1, r
.bottom
-r
.top
+1,PATCOPY
);
1376 PatBlt32( hdc
, r
.right
-1, r
.top
, 1, r
.bottom
-r
.top
+1, PATCOPY
);
1377 PatBlt32( hdc
, r
.left
, r
.top
-1, r
.right
-r
.left
, 1, PATCOPY
);
1380 SelectObject32( hdc
, hbrushOld
);
1383 MoveTo( hdc
, r
.left
, r
.bottom
);
1384 LineTo32( hdc
, r
.right
, r
.bottom
);
1386 if (style
& WS_SYSMENU
)
1388 NC_DrawSysButton( hwnd
, hdc
, FALSE
);
1389 r
.left
+= SYSMETRICS_CXSIZE
+ 1;
1390 MoveTo( hdc
, r
.left
- 1, r
.top
);
1391 LineTo32( hdc
, r
.left
- 1, r
.bottom
);
1393 if (style
& WS_MAXIMIZEBOX
)
1395 NC_DrawMaxButton( hwnd
, hdc
, FALSE
);
1396 r
.right
-= SYSMETRICS_CXSIZE
+ 1;
1398 if (style
& WS_MINIMIZEBOX
)
1400 NC_DrawMinButton( hwnd
, hdc
, FALSE
);
1401 r
.right
-= SYSMETRICS_CXSIZE
+ 1;
1404 FillRect32( hdc
, &r
, GetSysColorBrush32(active
? COLOR_ACTIVECAPTION
:
1405 COLOR_INACTIVECAPTION
) );
1407 if (GetWindowText32A( hwnd
, buffer
, sizeof(buffer
) ))
1409 if (active
) SetTextColor32( hdc
, GetSysColor32( COLOR_CAPTIONTEXT
) );
1410 else SetTextColor32( hdc
, GetSysColor32( COLOR_INACTIVECAPTIONTEXT
) );
1411 SetBkMode32( hdc
, TRANSPARENT
);
1412 DrawText32A( hdc
, buffer
, -1, &r
,
1413 DT_SINGLELINE
| DT_CENTER
| DT_VCENTER
| DT_NOPREFIX
);
1418 /******************************************************************************
1427 * Draw the window caption for Win95 style windows.
1428 * The correct pen for the window frame must be selected in the DC.
1431 * Hey, a function that finally works! Well, almost.
1432 * It's being worked on.
1435 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1436 * Original implementation.
1437 * 02-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1440 *****************************************************************************/
1442 static void NC_DrawCaption95(
1451 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1453 POINT32 sep
[2] = { { r
.left
, r
.bottom
- 1 },
1454 { r
.right
, r
.bottom
- 1 } };
1456 if (wndPtr
->flags
& WIN_MANAGED
) return;
1458 GRAPH_DrawLines( hdc
, sep
, 1, GetSysColorPen32(COLOR_3DFACE
) );
1461 FillRect32( hdc
, &r
, GetSysColorBrush32(active
? COLOR_ACTIVECAPTION
:
1462 COLOR_INACTIVECAPTION
) );
1464 if (!hbitmapClose
) {
1465 if (!(hbitmapClose
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_CLOSE
) )))
1467 hbitmapMinimize
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_REDUCE
) );
1468 hbitmapMinimizeD
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_REDUCED
) );
1469 hbitmapMaximize
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_ZOOM
) );
1470 hbitmapMaximizeD
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_ZOOMD
) );
1471 hbitmapRestore
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_RESTORE
) );
1472 hbitmapRestoreD
= LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_RESTORED
) );
1475 if ((style
& WS_SYSMENU
) && !(exStyle
& WS_EX_TOOLWINDOW
)) {
1476 if (NC_DrawSysButton95 (hwnd
, hdc
, FALSE
))
1477 r
.left
+= sysMetrics
[SM_CYCAPTION
] - 1;
1479 if (style
& WS_SYSMENU
) {
1480 NC_DrawCloseButton95 (hwnd
, hdc
, FALSE
);
1481 r
.right
-= sysMetrics
[SM_CYCAPTION
] - 1;
1483 if (style
& WS_MAXIMIZEBOX
) {
1484 NC_DrawMaxButton95( hwnd
, hdc
, FALSE
);
1485 r
.right
-= SYSMETRICS_CXSIZE
+ 1;
1487 if (style
& WS_MINIMIZEBOX
) {
1488 NC_DrawMinButton95( hwnd
, hdc
, FALSE
);
1489 r
.right
-= SYSMETRICS_CXSIZE
+ 1;
1492 if (GetWindowText32A( hwnd
, buffer
, sizeof(buffer
) )) {
1493 NONCLIENTMETRICS32A nclm
;
1494 HFONT32 hFont
, hOldFont
;
1495 nclm
.cbSize
= sizeof(NONCLIENTMETRICS32A
);
1496 SystemParametersInfo32A (SPI_GETNONCLIENTMETRICS
, 0, &nclm
, 0);
1497 if (exStyle
& WS_EX_TOOLWINDOW
)
1498 hFont
= CreateFontIndirect32A (&nclm
.lfSmCaptionFont
);
1500 hFont
= CreateFontIndirect32A (&nclm
.lfCaptionFont
);
1501 hOldFont
= SelectObject32 (hdc
, hFont
);
1502 if (active
) SetTextColor32( hdc
, GetSysColor32( COLOR_CAPTIONTEXT
) );
1503 else SetTextColor32( hdc
, GetSysColor32( COLOR_INACTIVECAPTIONTEXT
) );
1504 SetBkMode32( hdc
, TRANSPARENT
);
1506 DrawText32A( hdc
, buffer
, -1, &r
,
1507 DT_SINGLELINE
| DT_VCENTER
| DT_NOPREFIX
| DT_LEFT
);
1508 DeleteObject32 (SelectObject32 (hdc
, hOldFont
));
1514 /***********************************************************************
1517 * Paint the non-client area. clip is currently unused.
1519 void NC_DoNCPaint( WND
* wndPtr
, HRGN32 clip
, BOOL32 suppress_menupaint
)
1524 HWND32 hwnd
= wndPtr
->hwndSelf
;
1526 if ( wndPtr
->dwStyle
& WS_MINIMIZE
||
1527 !WIN_IsWindowDrawable( wndPtr
, 0 )) return; /* Nothing to do */
1529 active
= wndPtr
->flags
& WIN_NCACTIVATED
;
1531 TRACE(nonclient
, "%04x %d\n", hwnd
, active
);
1533 if (!(hdc
= GetDCEx32( hwnd
, 0, DCX_USESTYLE
| DCX_WINDOW
))) return;
1535 if (ExcludeVisRect( hdc
, wndPtr
->rectClient
.left
-wndPtr
->rectWindow
.left
,
1536 wndPtr
->rectClient
.top
-wndPtr
->rectWindow
.top
,
1537 wndPtr
->rectClient
.right
-wndPtr
->rectWindow
.left
,
1538 wndPtr
->rectClient
.bottom
-wndPtr
->rectWindow
.top
)
1541 ReleaseDC32( hwnd
, hdc
);
1545 rect
.top
= rect
.left
= 0;
1546 rect
.right
= wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
;
1547 rect
.bottom
= wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
;
1549 SelectObject32( hdc
, GetSysColorPen32(COLOR_WINDOWFRAME
) );
1551 if (!(wndPtr
->flags
& WIN_MANAGED
))
1553 if ((wndPtr
->dwStyle
& WS_BORDER
) || (wndPtr
->dwStyle
& WS_DLGFRAME
) ||
1554 (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
))
1556 GRAPH_DrawRectangle( hdc
, 0, 0,
1557 rect
.right
, rect
.bottom
, (HPEN32
)0 );
1558 InflateRect32( &rect
, -1, -1 );
1561 if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
1562 NC_DrawFrame( hdc
, &rect
, TRUE
, active
);
1563 else if (wndPtr
->dwStyle
& WS_THICKFRAME
)
1564 NC_DrawFrame(hdc
, &rect
, FALSE
, active
);
1566 if ((wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
1569 r
.bottom
= rect
.top
+ SYSMETRICS_CYSIZE
;
1570 rect
.top
+= SYSMETRICS_CYSIZE
+ SYSMETRICS_CYBORDER
;
1571 NC_DrawCaption( hdc
, &r
, hwnd
, wndPtr
->dwStyle
, active
);
1575 if (HAS_MENU(wndPtr
))
1578 r
.bottom
= rect
.top
+ SYSMETRICS_CYMENU
; /* default height */
1579 rect
.top
+= MENU_DrawMenuBar( hdc
, &r
, hwnd
, suppress_menupaint
);
1582 /* Draw the scroll-bars */
1584 if (wndPtr
->dwStyle
& WS_VSCROLL
)
1585 SCROLL_DrawScrollBar( hwnd
, hdc
, SB_VERT
, TRUE
, TRUE
);
1586 if (wndPtr
->dwStyle
& WS_HSCROLL
)
1587 SCROLL_DrawScrollBar( hwnd
, hdc
, SB_HORZ
, TRUE
, TRUE
);
1589 /* Draw the "size-box" */
1591 if ((wndPtr
->dwStyle
& WS_VSCROLL
) && (wndPtr
->dwStyle
& WS_HSCROLL
))
1594 r
.left
= r
.right
- SYSMETRICS_CXVSCROLL
+ 1;
1595 r
.top
= r
.bottom
- SYSMETRICS_CYHSCROLL
+ 1;
1596 if(wndPtr
->dwStyle
& WS_BORDER
) {
1600 FillRect32( hdc
, &r
, GetSysColorBrush32(COLOR_SCROLLBAR
) );
1603 ReleaseDC32( hwnd
, hdc
);
1607 /******************************************************************************
1609 * void NC_DoNCPaint95(
1612 * BOOL32 suppress_menupaint )
1614 * Paint the non-client area for Win95 windows. The clip region is
1615 * currently ignored.
1618 * grep -E -A10 -B5 \(95\)\|\(Bugs\)\|\(FIXME\) windows/nonclient.c \
1619 * misc/tweak.c controls/menu.c # :-)
1622 * 03-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1623 * Original implementation
1624 * 10-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1627 *****************************************************************************/
1629 void NC_DoNCPaint95(
1632 BOOL32 suppress_menupaint
)
1637 HWND32 hwnd
= wndPtr
->hwndSelf
;
1639 if ( wndPtr
->dwStyle
& WS_MINIMIZE
||
1640 !WIN_IsWindowDrawable( wndPtr
, 0 )) return; /* Nothing to do */
1642 active
= wndPtr
->flags
& WIN_NCACTIVATED
;
1644 TRACE(nonclient
, "%04x %d\n", hwnd
, active
);
1646 if (!(hdc
= GetDCEx32( hwnd
, 0, DCX_USESTYLE
| DCX_WINDOW
))) return;
1648 if (ExcludeVisRect( hdc
, wndPtr
->rectClient
.left
-wndPtr
->rectWindow
.left
,
1649 wndPtr
->rectClient
.top
-wndPtr
->rectWindow
.top
,
1650 wndPtr
->rectClient
.right
-wndPtr
->rectWindow
.left
,
1651 wndPtr
->rectClient
.bottom
-wndPtr
->rectWindow
.top
)
1654 ReleaseDC32( hwnd
, hdc
);
1658 rect
.top
= rect
.left
= 0;
1659 rect
.right
= wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
;
1660 rect
.bottom
= wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
;
1662 SelectObject32( hdc
, GetSysColorPen32(COLOR_WINDOWFRAME
) );
1664 if(!(wndPtr
->flags
& WIN_MANAGED
)) {
1665 if ((wndPtr
->dwStyle
& WS_BORDER
) && ((wndPtr
->dwStyle
& WS_DLGFRAME
) ||
1666 (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
) || (wndPtr
->dwStyle
& WS_THICKFRAME
))) {
1667 DrawEdge32 (hdc
, &rect
, EDGE_RAISED
, BF_RECT
| BF_ADJUST
);
1670 if (HAS_FIXEDFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
1671 NC_DrawFrame95( hdc
, &rect
, TRUE
, active
);
1672 else if (wndPtr
->dwStyle
& WS_THICKFRAME
)
1673 NC_DrawFrame95(hdc
, &rect
, FALSE
, active
);
1675 if ((wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
1678 if (wndPtr
->dwExStyle
& WS_EX_TOOLWINDOW
) {
1679 r
.bottom
= rect
.top
+ sysMetrics
[SM_CYSMCAPTION
];
1680 rect
.top
+= sysMetrics
[SM_CYSMCAPTION
];
1683 r
.bottom
= rect
.top
+ sysMetrics
[SM_CYCAPTION
];
1684 rect
.top
+= sysMetrics
[SM_CYCAPTION
];
1686 NC_DrawCaption95 (hdc
, &r
, hwnd
, wndPtr
->dwStyle
,
1687 wndPtr
->dwExStyle
, active
);
1691 if (HAS_MENU(wndPtr
))
1694 r
.bottom
= rect
.top
+ sysMetrics
[SM_CYMENU
];
1696 TRACE(nonclient
, "Calling DrawMenuBar with "
1697 "rect (%d, %d)-(%d, %d)\n", r
.left
, r
.top
,
1700 rect
.top
+= MENU_DrawMenuBar( hdc
, &r
, hwnd
, suppress_menupaint
) + 1;
1703 TRACE(nonclient
, "After MenuBar, rect is (%d, %d)-(%d, %d).\n",
1704 rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1706 if (wndPtr
->dwExStyle
& WS_EX_CLIENTEDGE
)
1707 DrawEdge32 (hdc
, &rect
, EDGE_SUNKEN
, BF_RECT
| BF_ADJUST
);
1709 if (wndPtr
->dwExStyle
& WS_EX_STATICEDGE
)
1710 DrawEdge32 (hdc
, &rect
, BDR_SUNKENOUTER
, BF_RECT
| BF_ADJUST
);
1712 /* Draw the scroll-bars */
1714 if (wndPtr
->dwStyle
& WS_VSCROLL
)
1715 SCROLL_DrawScrollBar( hwnd
, hdc
, SB_VERT
, TRUE
, TRUE
);
1716 if (wndPtr
->dwStyle
& WS_HSCROLL
)
1717 SCROLL_DrawScrollBar( hwnd
, hdc
, SB_HORZ
, TRUE
, TRUE
);
1719 /* Draw the "size-box" */
1720 if ((wndPtr
->dwStyle
& WS_VSCROLL
) && (wndPtr
->dwStyle
& WS_HSCROLL
))
1723 r
.left
= r
.right
- SYSMETRICS_CXVSCROLL
+ 1;
1724 r
.top
= r
.bottom
- SYSMETRICS_CYHSCROLL
+ 1;
1725 FillRect32( hdc
, &r
, GetSysColorBrush32(COLOR_SCROLLBAR
) );
1728 ReleaseDC32( hwnd
, hdc
);
1734 /***********************************************************************
1737 * Handle a WM_NCPAINT message. Called from DefWindowProc().
1739 LONG
NC_HandleNCPaint( HWND32 hwnd
, HRGN32 clip
)
1741 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
1743 if( wndPtr
&& wndPtr
->dwStyle
& WS_VISIBLE
)
1745 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
1746 WINPOS_RedrawIconTitle( hwnd
);
1747 else if (TWEAK_WineLook
== WIN31_LOOK
)
1748 NC_DoNCPaint( wndPtr
, clip
, FALSE
);
1750 NC_DoNCPaint95( wndPtr
, clip
, FALSE
);
1756 /***********************************************************************
1757 * NC_HandleNCActivate
1759 * Handle a WM_NCACTIVATE message. Called from DefWindowProc().
1761 LONG
NC_HandleNCActivate( WND
*wndPtr
, WPARAM16 wParam
)
1765 if( wParam
) wStateChange
= !(wndPtr
->flags
& WIN_NCACTIVATED
);
1766 else wStateChange
= wndPtr
->flags
& WIN_NCACTIVATED
;
1770 if (wParam
) wndPtr
->flags
|= WIN_NCACTIVATED
;
1771 else wndPtr
->flags
&= ~WIN_NCACTIVATED
;
1773 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
1774 WINPOS_RedrawIconTitle( wndPtr
->hwndSelf
);
1775 else if (TWEAK_WineLook
== WIN31_LOOK
)
1776 NC_DoNCPaint( wndPtr
, (HRGN32
)1, FALSE
);
1778 NC_DoNCPaint95( wndPtr
, (HRGN32
)1, FALSE
);
1784 /***********************************************************************
1785 * NC_HandleSetCursor
1787 * Handle a WM_SETCURSOR message. Called from DefWindowProc().
1789 LONG
NC_HandleSetCursor( HWND32 hwnd
, WPARAM16 wParam
, LPARAM lParam
)
1791 if (hwnd
!= (HWND32
)wParam
) return 0; /* Don't set the cursor for child windows */
1793 switch(LOWORD(lParam
))
1797 WORD msg
= HIWORD( lParam
);
1798 if ((msg
== WM_LBUTTONDOWN
) || (msg
== WM_MBUTTONDOWN
) ||
1799 (msg
== WM_RBUTTONDOWN
))
1807 if (!(wndPtr
= WIN_FindWndPtr( hwnd
))) break;
1808 if (wndPtr
->class->hCursor
)
1810 SetCursor16( wndPtr
->class->hCursor
);
1818 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZEWE16
) );
1822 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZENS16
) );
1826 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZENWSE16
) );
1830 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZENESW16
) );
1833 /* Default cursor: arrow */
1834 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_ARROW16
) );
1837 /***********************************************************************
1840 BOOL32
NC_GetSysPopupPos( WND
* wndPtr
, RECT32
* rect
)
1842 if( wndPtr
->hSysMenu
)
1844 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
1845 GetWindowRect32( wndPtr
->hwndSelf
, rect
);
1848 if (TWEAK_WineLook
== WIN31_LOOK
)
1849 NC_GetInsideRect( wndPtr
->hwndSelf
, rect
);
1851 NC_GetInsideRect95( wndPtr
->hwndSelf
, rect
);
1852 OffsetRect32( rect
, wndPtr
->rectWindow
.left
, wndPtr
->rectWindow
.top
);
1853 if (wndPtr
->dwStyle
& WS_CHILD
)
1854 ClientToScreen32( wndPtr
->parent
->hwndSelf
, (POINT32
*)rect
);
1855 if (TWEAK_WineLook
== WIN31_LOOK
) {
1856 rect
->right
= rect
->left
+ SYSMETRICS_CXSIZE
;
1857 rect
->bottom
= rect
->top
+ SYSMETRICS_CYSIZE
;
1860 rect
->right
= rect
->left
+ sysMetrics
[SM_CYCAPTION
] - 1;
1861 rect
->bottom
= rect
->top
+ sysMetrics
[SM_CYCAPTION
] - 1;
1869 /***********************************************************************
1872 * Initialisation of a move or resize, when initiatied from a menu choice.
1873 * Return hit test code for caption or sizing border.
1875 static LONG
NC_StartSizeMove( WND
* wndPtr
, WPARAM16 wParam
,
1876 POINT16
*capturePoint
)
1882 if ((wParam
& 0xfff0) == SC_MOVE
)
1884 /* Move pointer at the center of the caption */
1886 if (TWEAK_WineLook
== WIN31_LOOK
)
1887 NC_GetInsideRect( wndPtr
->hwndSelf
, &rect
);
1889 NC_GetInsideRect95( wndPtr
->hwndSelf
, &rect
);
1890 if (wndPtr
->dwStyle
& WS_SYSMENU
)
1891 rect
.left
+= SYSMETRICS_CXSIZE
+ 1;
1892 if (wndPtr
->dwStyle
& WS_MINIMIZEBOX
)
1893 rect
.right
-= SYSMETRICS_CXSIZE
+ 1;
1894 if (wndPtr
->dwStyle
& WS_MAXIMIZEBOX
)
1895 rect
.right
-= SYSMETRICS_CXSIZE
+ 1;
1896 pt
.x
= wndPtr
->rectWindow
.left
+ (rect
.right
- rect
.left
) / 2;
1897 pt
.y
= wndPtr
->rectWindow
.top
+ rect
.top
+ SYSMETRICS_CYSIZE
/2;
1898 hittest
= HTCAPTION
;
1905 MSG_InternalGetMessage( &msg
, 0, 0, MSGF_SIZE
, PM_REMOVE
, FALSE
);
1909 hittest
= NC_HandleNCHitTest( wndPtr
->hwndSelf
, msg
.pt
);
1911 if ((hittest
< HTLEFT
) || (hittest
> HTBOTTOMRIGHT
))
1923 pt
.x
=(wndPtr
->rectWindow
.left
+wndPtr
->rectWindow
.right
)/2;
1924 pt
.y
= wndPtr
->rectWindow
.top
+ SYSMETRICS_CYFRAME
/ 2;
1928 pt
.x
=(wndPtr
->rectWindow
.left
+wndPtr
->rectWindow
.right
)/2;
1929 pt
.y
= wndPtr
->rectWindow
.bottom
- SYSMETRICS_CYFRAME
/ 2;
1933 pt
.x
= wndPtr
->rectWindow
.left
+ SYSMETRICS_CXFRAME
/ 2;
1934 pt
.y
=(wndPtr
->rectWindow
.top
+wndPtr
->rectWindow
.bottom
)/2;
1938 pt
.x
= wndPtr
->rectWindow
.right
- SYSMETRICS_CXFRAME
/ 2;
1939 pt
.y
=(wndPtr
->rectWindow
.top
+wndPtr
->rectWindow
.bottom
)/2;
1942 case VK_ESCAPE
: return 0;
1948 SetCursorPos32( pt
.x
, pt
.y
);
1949 NC_HandleSetCursor( wndPtr
->hwndSelf
,
1950 wndPtr
->hwndSelf
, MAKELONG( hittest
, WM_MOUSEMOVE
));
1955 /***********************************************************************
1958 * Perform SC_MOVE and SC_SIZE commands.
1960 static void NC_DoSizeMove( HWND32 hwnd
, WORD wParam
)
1963 RECT32 sizingRect
, mouseRect
;
1965 LONG hittest
= (LONG
)(wParam
& 0x0f);
1966 HCURSOR16 hDragCursor
= 0, hOldCursor
= 0;
1967 POINT32 minTrack
, maxTrack
;
1968 POINT16 capturePoint
, pt
;
1969 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
1970 BOOL32 thickframe
= HAS_THICKFRAME( wndPtr
->dwStyle
);
1971 BOOL32 iconic
= wndPtr
->dwStyle
& WS_MINIMIZE
;
1972 BOOL32 moved
= FALSE
;
1973 DWORD dwPoint
= GetMessagePos ();
1975 capturePoint
= pt
= *(POINT16
*)&dwPoint
;
1977 if (IsZoomed32(hwnd
) || !IsWindowVisible32(hwnd
) ||
1978 (wndPtr
->flags
& WIN_MANAGED
)) return;
1980 if ((wParam
& 0xfff0) == SC_MOVE
)
1982 if (!(wndPtr
->dwStyle
& WS_CAPTION
)) return;
1984 hittest
= NC_StartSizeMove( wndPtr
, wParam
, &capturePoint
);
1985 if (!hittest
) return;
1989 if (!thickframe
) return;
1990 if ( hittest
&& hittest
!= HTSYSMENU
) hittest
+= 2;
1994 hittest
= NC_StartSizeMove( wndPtr
, wParam
, &capturePoint
);
2003 /* Get min/max info */
2005 WINPOS_GetMinMaxInfo( wndPtr
, NULL
, NULL
, &minTrack
, &maxTrack
);
2006 sizingRect
= wndPtr
->rectWindow
;
2007 if (wndPtr
->dwStyle
& WS_CHILD
)
2008 GetClientRect32( wndPtr
->parent
->hwndSelf
, &mouseRect
);
2010 SetRect32(&mouseRect
, 0, 0, SYSMETRICS_CXSCREEN
, SYSMETRICS_CYSCREEN
);
2011 if (ON_LEFT_BORDER(hittest
))
2013 mouseRect
.left
= MAX( mouseRect
.left
, sizingRect
.right
-maxTrack
.x
);
2014 mouseRect
.right
= MIN( mouseRect
.right
, sizingRect
.right
-minTrack
.x
);
2016 else if (ON_RIGHT_BORDER(hittest
))
2018 mouseRect
.left
= MAX( mouseRect
.left
, sizingRect
.left
+minTrack
.x
);
2019 mouseRect
.right
= MIN( mouseRect
.right
, sizingRect
.left
+maxTrack
.x
);
2021 if (ON_TOP_BORDER(hittest
))
2023 mouseRect
.top
= MAX( mouseRect
.top
, sizingRect
.bottom
-maxTrack
.y
);
2024 mouseRect
.bottom
= MIN( mouseRect
.bottom
,sizingRect
.bottom
-minTrack
.y
);
2026 else if (ON_BOTTOM_BORDER(hittest
))
2028 mouseRect
.top
= MAX( mouseRect
.top
, sizingRect
.top
+minTrack
.y
);
2029 mouseRect
.bottom
= MIN( mouseRect
.bottom
, sizingRect
.top
+maxTrack
.y
);
2031 if (wndPtr
->dwStyle
& WS_CHILD
)
2033 MapWindowPoints32( wndPtr
->parent
->hwndSelf
, 0,
2034 (LPPOINT32
)&mouseRect
, 2 );
2036 SendMessage16( hwnd
, WM_ENTERSIZEMOVE
, 0, 0 );
2038 if (GetCapture32() != hwnd
) SetCapture32( hwnd
);
2040 if (wndPtr
->dwStyle
& WS_CHILD
)
2042 /* Retrieve a default cache DC (without using the window style) */
2043 hdc
= GetDCEx32( wndPtr
->parent
->hwndSelf
, 0, DCX_CACHE
);
2046 { /* Grab the server only when moving top-level windows without desktop */
2048 if (rootWindow
== DefaultRootWindow(display
)) TSXGrabServer( display
);
2051 if( iconic
) /* create a cursor for dragging */
2053 HICON16 hIcon
= (wndPtr
->class->hIcon
) ? wndPtr
->class->hIcon
2054 : (HICON16
)SendMessage16( hwnd
, WM_QUERYDRAGICON
, 0, 0L);
2055 if( hIcon
) hDragCursor
= CURSORICON_IconToCursor( hIcon
, TRUE
);
2056 if( !hDragCursor
) iconic
= FALSE
;
2059 if( !iconic
) NC_DrawMovingFrame( hdc
, &sizingRect
, thickframe
);
2065 MSG_InternalGetMessage( &msg
, 0, 0, MSGF_SIZE
, PM_REMOVE
, FALSE
);
2067 /* Exit on button-up, Return, or Esc */
2068 if ((msg
.message
== WM_LBUTTONUP
) ||
2069 ((msg
.message
== WM_KEYDOWN
) &&
2070 ((msg
.wParam
== VK_RETURN
) || (msg
.wParam
== VK_ESCAPE
)))) break;
2072 if ((msg
.message
!= WM_KEYDOWN
) && (msg
.message
!= WM_MOUSEMOVE
))
2073 continue; /* We are not interested in other messages */
2075 dwPoint
= GetMessagePos ();
2076 pt
= *(POINT16
*)&dwPoint
;
2078 if (msg
.message
== WM_KEYDOWN
) switch(msg
.wParam
)
2080 case VK_UP
: pt
.y
-= 8; break;
2081 case VK_DOWN
: pt
.y
+= 8; break;
2082 case VK_LEFT
: pt
.x
-= 8; break;
2083 case VK_RIGHT
: pt
.x
+= 8; break;
2086 pt
.x
= MAX( pt
.x
, mouseRect
.left
);
2087 pt
.x
= MIN( pt
.x
, mouseRect
.right
);
2088 pt
.y
= MAX( pt
.y
, mouseRect
.top
);
2089 pt
.y
= MIN( pt
.y
, mouseRect
.bottom
);
2091 dx
= pt
.x
- capturePoint
.x
;
2092 dy
= pt
.y
- capturePoint
.y
;
2099 if( iconic
) /* ok, no system popup tracking */
2101 hOldCursor
= SetCursor32(hDragCursor
);
2102 ShowCursor32( TRUE
);
2103 WINPOS_ShowIconTitle( wndPtr
, FALSE
);
2107 if (msg
.message
== WM_KEYDOWN
) SetCursorPos32( pt
.x
, pt
.y
);
2110 RECT32 newRect
= sizingRect
;
2112 if (hittest
== HTCAPTION
) OffsetRect32( &newRect
, dx
, dy
);
2113 if (ON_LEFT_BORDER(hittest
)) newRect
.left
+= dx
;
2114 else if (ON_RIGHT_BORDER(hittest
)) newRect
.right
+= dx
;
2115 if (ON_TOP_BORDER(hittest
)) newRect
.top
+= dy
;
2116 else if (ON_BOTTOM_BORDER(hittest
)) newRect
.bottom
+= dy
;
2119 NC_DrawMovingFrame( hdc
, &sizingRect
, thickframe
);
2120 NC_DrawMovingFrame( hdc
, &newRect
, thickframe
);
2123 sizingRect
= newRect
;
2131 if( moved
) /* restore cursors, show icon title later on */
2133 ShowCursor32( FALSE
);
2134 SetCursor32( hOldCursor
);
2136 DestroyCursor32( hDragCursor
);
2139 NC_DrawMovingFrame( hdc
, &sizingRect
, thickframe
);
2141 if (wndPtr
->dwStyle
& WS_CHILD
)
2142 ReleaseDC32( wndPtr
->parent
->hwndSelf
, hdc
);
2145 ReleaseDC32( 0, hdc
);
2146 if (rootWindow
== DefaultRootWindow(display
)) TSXUngrabServer( display
);
2149 if (HOOK_IsHooked( WH_CBT
))
2151 RECT16
* pr
= SEGPTR_NEW(RECT16
);
2154 CONV_RECT32TO16( &sizingRect
, pr
);
2155 if( HOOK_CallHooks16( WH_CBT
, HCBT_MOVESIZE
, hwnd
,
2156 (LPARAM
)SEGPTR_GET(pr
)) )
2157 sizingRect
= wndPtr
->rectWindow
;
2159 CONV_RECT16TO32( pr
, &sizingRect
);
2163 SendMessage16( hwnd
, WM_EXITSIZEMOVE
, 0, 0 );
2164 SendMessage16( hwnd
, WM_SETVISIBLE
, !IsIconic16(hwnd
), 0L);
2166 if( moved
&& !((msg
.message
== WM_KEYDOWN
) && (msg
.wParam
== VK_ESCAPE
)) )
2168 /* NOTE: SWP_NOACTIVATE prevents document window activation in Word 6 */
2169 SetWindowPos32( hwnd
, 0, sizingRect
.left
, sizingRect
.top
,
2170 sizingRect
.right
- sizingRect
.left
,
2171 sizingRect
.bottom
- sizingRect
.top
,
2172 ( hittest
== HTCAPTION
) ? SWP_NOSIZE
: 0 );
2175 if( IsWindow32(hwnd
) )
2176 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
2178 /* Single click brings up the system menu when iconized */
2182 if( wndPtr
->dwStyle
& WS_SYSMENU
)
2183 SendMessage16( hwnd
, WM_SYSCOMMAND
,
2184 SC_MOUSEMENU
+ HTSYSMENU
, *((LPARAM
*)&pt
));
2186 else WINPOS_ShowIconTitle( wndPtr
, TRUE
);
2191 /***********************************************************************
2194 * Track a mouse button press on the minimize or maximize box.
2196 static void NC_TrackMinMaxBox( HWND32 hwnd
, WORD wParam
)
2199 HDC32 hdc
= GetWindowDC32( hwnd
);
2200 BOOL32 pressed
= TRUE
;
2201 void (*paintButton
)(HWND32
, HDC16
, BOOL32
);
2203 SetCapture32( hwnd
);
2204 if (wParam
== HTMINBUTTON
)
2206 (TWEAK_WineLook
== WIN31_LOOK
) ? &NC_DrawMinButton
: &NC_DrawMinButton95
;
2209 (TWEAK_WineLook
== WIN31_LOOK
) ? &NC_DrawMaxButton
: &NC_DrawMaxButton95
;
2211 (*paintButton
)( hwnd
, hdc
, TRUE
);
2215 BOOL32 oldstate
= pressed
;
2216 MSG_InternalGetMessage( &msg
, 0, 0, 0, PM_REMOVE
, FALSE
);
2218 pressed
= (NC_HandleNCHitTest( hwnd
, msg
.pt
) == wParam
);
2219 if (pressed
!= oldstate
)
2220 (*paintButton
)( hwnd
, hdc
, pressed
);
2221 } while (msg
.message
!= WM_LBUTTONUP
);
2223 (*paintButton
)( hwnd
, hdc
, FALSE
);
2226 ReleaseDC32( hwnd
, hdc
);
2227 if (!pressed
) return;
2229 if (wParam
== HTMINBUTTON
)
2230 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MINIMIZE
, *(LONG
*)&msg
.pt
);
2232 SendMessage16( hwnd
, WM_SYSCOMMAND
,
2233 IsZoomed32(hwnd
) ? SC_RESTORE
:SC_MAXIMIZE
, *(LONG
*)&msg
.pt
);
2237 /***********************************************************************
2238 * NC_TrackCloseButton95
2240 * Track a mouse button press on the Win95 close button.
2243 NC_TrackCloseButton95 (HWND32 hwnd
, WORD wParam
)
2246 HDC32 hdc
= GetWindowDC32( hwnd
);
2247 BOOL32 pressed
= TRUE
;
2249 SetCapture32( hwnd
);
2251 NC_DrawCloseButton95 (hwnd
, hdc
, TRUE
);
2255 BOOL32 oldstate
= pressed
;
2256 MSG_InternalGetMessage( &msg
, 0, 0, 0, PM_REMOVE
, FALSE
);
2258 pressed
= (NC_HandleNCHitTest( hwnd
, msg
.pt
) == wParam
);
2259 if (pressed
!= oldstate
)
2260 NC_DrawCloseButton95 (hwnd
, hdc
, pressed
);
2261 } while (msg
.message
!= WM_LBUTTONUP
);
2263 NC_DrawCloseButton95 (hwnd
, hdc
, FALSE
);
2266 ReleaseDC32( hwnd
, hdc
);
2267 if (!pressed
) return;
2269 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_CLOSE
, *(LONG
*)&msg
.pt
);
2273 /***********************************************************************
2276 * Track a mouse button press on the horizontal or vertical scroll-bar.
2278 static void NC_TrackScrollBar( HWND32 hwnd
, WPARAM32 wParam
, POINT32 pt
)
2282 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
2284 if ((wParam
& 0xfff0) == SC_HSCROLL
)
2286 if ((wParam
& 0x0f) != HTHSCROLL
) return;
2287 scrollbar
= SB_HORZ
;
2289 else /* SC_VSCROLL */
2291 if ((wParam
& 0x0f) != HTVSCROLL
) return;
2292 scrollbar
= SB_VERT
;
2295 if (!(msg
= SEGPTR_NEW(MSG16
))) return;
2296 pt
.x
-= wndPtr
->rectWindow
.left
;
2297 pt
.y
-= wndPtr
->rectWindow
.top
;
2298 SetCapture32( hwnd
);
2299 SCROLL_HandleScrollEvent( hwnd
, scrollbar
, WM_LBUTTONDOWN
, pt
);
2303 GetMessage16( SEGPTR_GET(msg
), 0, 0, 0 );
2304 switch(msg
->message
)
2309 pt
.x
= LOWORD(msg
->lParam
) + wndPtr
->rectClient
.left
-
2310 wndPtr
->rectWindow
.left
;
2311 pt
.y
= HIWORD(msg
->lParam
) + wndPtr
->rectClient
.top
-
2312 wndPtr
->rectWindow
.top
;
2313 SCROLL_HandleScrollEvent( hwnd
, scrollbar
, msg
->message
, pt
);
2316 TranslateMessage16( msg
);
2317 DispatchMessage16( msg
);
2320 if (!IsWindow32( hwnd
))
2325 } while (msg
->message
!= WM_LBUTTONUP
);
2329 /***********************************************************************
2330 * NC_HandleNCLButtonDown
2332 * Handle a WM_NCLBUTTONDOWN message. Called from DefWindowProc().
2334 LONG
NC_HandleNCLButtonDown( WND
* pWnd
, WPARAM16 wParam
, LPARAM lParam
)
2336 HWND32 hwnd
= pWnd
->hwndSelf
;
2338 switch(wParam
) /* Hit test */
2341 hwnd
= WIN_GetTopParent(hwnd
);
2343 if( WINPOS_SetActiveWindow(hwnd
, TRUE
, TRUE
) || (GetActiveWindow32() == hwnd
) )
2344 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_MOVE
+ HTCAPTION
, lParam
);
2348 if( pWnd
->dwStyle
& WS_SYSMENU
)
2350 if( !(pWnd
->dwStyle
& WS_MINIMIZE
) )
2352 HDC32 hDC
= GetWindowDC32(hwnd
);
2353 if (TWEAK_WineLook
== WIN31_LOOK
)
2354 NC_DrawSysButton( hwnd
, hDC
, TRUE
);
2356 NC_DrawSysButton95( hwnd
, hDC
, TRUE
);
2357 ReleaseDC32( hwnd
, hDC
);
2359 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MOUSEMENU
+ HTSYSMENU
, lParam
);
2364 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MOUSEMENU
, lParam
);
2368 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_HSCROLL
+ HTHSCROLL
, lParam
);
2372 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_VSCROLL
+ HTVSCROLL
, lParam
);
2377 NC_TrackMinMaxBox( hwnd
, wParam
);
2381 if (TWEAK_WineLook
>= WIN95_LOOK
)
2382 NC_TrackCloseButton95 (hwnd
, wParam
);
2393 /* make sure hittest fits into 0xf and doesn't overlap with HTSYSMENU */
2394 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_SIZE
+ wParam
- 2, lParam
);
2404 /***********************************************************************
2405 * NC_HandleNCLButtonDblClk
2407 * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc().
2409 LONG
NC_HandleNCLButtonDblClk( WND
*pWnd
, WPARAM16 wParam
, LPARAM lParam
)
2412 * if this is an icon, send a restore since we are handling
2415 if (pWnd
->dwStyle
& WS_MINIMIZE
)
2417 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_RESTORE
, lParam
);
2421 switch(wParam
) /* Hit test */
2424 /* stop processing if WS_MAXIMIZEBOX is missing */
2425 if (pWnd
->dwStyle
& WS_MAXIMIZEBOX
)
2426 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
,
2427 (pWnd
->dwStyle
& WS_MAXIMIZE
) ? SC_RESTORE
: SC_MAXIMIZE
,
2432 if (!(pWnd
->class->style
& CS_NOCLOSE
))
2433 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_CLOSE
, lParam
);
2437 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_HSCROLL
+ HTHSCROLL
,
2442 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_VSCROLL
+ HTVSCROLL
,
2450 /***********************************************************************
2451 * NC_HandleSysCommand
2453 * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
2455 LONG
NC_HandleSysCommand( HWND32 hwnd
, WPARAM16 wParam
, POINT16 pt
)
2457 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
2459 UINT16 uCommand
= wParam
& 0xFFF0;
2461 TRACE(nonclient
, "Handling WM_SYSCOMMAND %x %d,%d\n",
2462 wParam
, pt
.x
, pt
.y
);
2464 if (wndPtr
->dwStyle
& WS_CHILD
&& uCommand
!= SC_KEYMENU
)
2465 ScreenToClient16( wndPtr
->parent
->hwndSelf
, &pt
);
2471 NC_DoSizeMove( hwnd
, wParam
);
2475 ShowWindow32( hwnd
, SW_MINIMIZE
);
2479 ShowWindow32( hwnd
, SW_MAXIMIZE
);
2483 ShowWindow32( hwnd
, SW_RESTORE
);
2487 return SendMessage16( hwnd
, WM_CLOSE
, 0, 0 );
2491 CONV_POINT16TO32( &pt
, &pt32
);
2492 NC_TrackScrollBar( hwnd
, wParam
, pt32
);
2496 CONV_POINT16TO32( &pt
, &pt32
);
2497 MENU_TrackMouseMenuBar( wndPtr
, wParam
& 0x000F, pt32
);
2501 MENU_TrackKbdMenuBar( wndPtr
, wParam
, pt
.x
);
2505 WinExec32( "taskman.exe", SW_SHOWNORMAL
);
2509 if (wParam
== SC_ABOUTWINE
)
2510 ShellAbout32A(hwnd
,"Wine", WINE_RELEASE_INFO
, 0);
2517 FIXME (nonclient
, "unimplemented!\n");