Implemented SHCreateShellFolderViewEx.
[wine.git] / windows / nonclient.c
blob8e37d09225cad89a19009c68b6d1774fc9a541f5
1 /*
2 * Non-client area window functions
4 * Copyright 1994 Alexandre Julliard
6 */
8 #include "wine/winuser16.h"
9 #include "version.h"
10 #include "win.h"
11 #include "message.h"
12 #include "user.h"
13 #include "heap.h"
14 #include "dce.h"
15 #include "cursoricon.h"
16 #include "dialog.h"
17 #include "menu.h"
18 #include "winpos.h"
19 #include "hook.h"
20 #include "scroll.h"
21 #include "nonclient.h"
22 #include "queue.h"
23 #include "selectors.h"
24 #include "tweak.h"
25 #include "debugtools.h"
26 #include "options.h"
27 #include "shellapi.h"
28 #include "cache.h"
30 DECLARE_DEBUG_CHANNEL(nonclient)
31 DECLARE_DEBUG_CHANNEL(shell)
33 static HBITMAP16 hbitmapClose = 0;
34 static HBITMAP16 hbitmapCloseD = 0;
35 static HBITMAP16 hbitmapMinimize = 0;
36 static HBITMAP16 hbitmapMinimizeD = 0;
37 static HBITMAP16 hbitmapMaximize = 0;
38 static HBITMAP16 hbitmapMaximizeD = 0;
39 static HBITMAP16 hbitmapRestore = 0;
40 static HBITMAP16 hbitmapRestoreD = 0;
42 #define SC_ABOUTWINE (SC_SCREENSAVE+1)
43 #define SC_PUTMARK (SC_SCREENSAVE+2)
45 /* Some useful macros */
46 #define HAS_DLGFRAME(style,exStyle) \
47 (((exStyle) & WS_EX_DLGMODALFRAME) || \
48 (((style) & WS_DLGFRAME) && !((style) & WS_THICKFRAME)))
50 #define HAS_THICKFRAME(style,exStyle) \
51 (((style) & WS_THICKFRAME) && \
52 !((exStyle) & WS_EX_DLGMODALFRAME))
54 #define HAS_THINFRAME(style) \
55 (((style) & WS_BORDER) || !((style) & (WS_CHILD | WS_POPUP)))
57 #define HAS_BIGFRAME(style,exStyle) \
58 (((style) & (WS_THICKFRAME | WS_DLGFRAME)) || \
59 ((exStyle) & WS_EX_DLGMODALFRAME))
61 #define HAS_ANYFRAME(style,exStyle) \
62 (((style) & (WS_THICKFRAME | WS_DLGFRAME | WS_BORDER)) || \
63 ((exStyle) & WS_EX_DLGMODALFRAME) || \
64 !((style) & (WS_CHILD | WS_POPUP)))
66 #define HAS_MENU(w) (!((w)->dwStyle & WS_CHILD) && ((w)->wIDmenu != 0))
68 #define ON_LEFT_BORDER(hit) \
69 (((hit) == HTLEFT) || ((hit) == HTTOPLEFT) || ((hit) == HTBOTTOMLEFT))
70 #define ON_RIGHT_BORDER(hit) \
71 (((hit) == HTRIGHT) || ((hit) == HTTOPRIGHT) || ((hit) == HTBOTTOMRIGHT))
72 #define ON_TOP_BORDER(hit) \
73 (((hit) == HTTOP) || ((hit) == HTTOPLEFT) || ((hit) == HTTOPRIGHT))
74 #define ON_BOTTOM_BORDER(hit) \
75 (((hit) == HTBOTTOM) || ((hit) == HTBOTTOMLEFT) || ((hit) == HTBOTTOMRIGHT))
77 /***********************************************************************
78 * WIN_WindowNeedsWMBorder
80 * This method defines the rules for a window to have a WM border,
81 * caption... It is used for consitency purposes.
83 BOOL WIN_WindowNeedsWMBorder( DWORD style, DWORD exStyle )
85 if (!(style & WS_CHILD) && Options.managed &&
86 (((style & WS_CAPTION) == WS_CAPTION) ||
87 (style & WS_THICKFRAME) ||
88 (exStyle & WS_EX_DLGMODALFRAME))) return TRUE;
89 return FALSE;
92 /***********************************************************************
93 * NC_AdjustRect
95 * Compute the size of the window rectangle from the size of the
96 * client rectangle.
98 static void NC_AdjustRect( LPRECT16 rect, DWORD style, BOOL menu,
99 DWORD exStyle )
101 if (TWEAK_WineLook > WIN31_LOOK)
102 ERR_(nonclient)("Called in Win95 mode. Aiee! Please report this.\n" );
104 if(style & WS_ICONIC) return;
105 /* Decide if the window will be managed (see CreateWindowEx) */
106 if (!WIN_WindowNeedsWMBorder(style, exStyle))
108 if (HAS_THICKFRAME( style, exStyle ))
109 InflateRect16( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
110 else
111 if (HAS_DLGFRAME( style, exStyle ))
112 InflateRect16( rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
113 else
114 if (HAS_THINFRAME( style ))
115 InflateRect16( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
117 if ((style & WS_CAPTION) == WS_CAPTION)
118 rect->top -= GetSystemMetrics(SM_CYCAPTION) - GetSystemMetrics(SM_CYBORDER);
120 if (menu) rect->top -= GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CYBORDER);
122 if (style & WS_VSCROLL) {
123 rect->right += GetSystemMetrics(SM_CXVSCROLL) - 1;
124 if(!HAS_ANYFRAME( style, exStyle ))
125 rect->right++;
128 if (style & WS_HSCROLL) {
129 rect->bottom += GetSystemMetrics(SM_CYHSCROLL) - 1;
130 if(!HAS_ANYFRAME( style, exStyle ))
131 rect->bottom++;
136 /******************************************************************************
137 * NC_AdjustRectOuter95
139 * Computes the size of the "outside" parts of the window based on the
140 * parameters of the client area.
142 + PARAMS
143 * LPRECT16 rect
144 * DWORD style
145 * BOOL32 menu
146 * DWORD exStyle
148 * NOTES
149 * "Outer" parts of a window means the whole window frame, caption and
150 * menu bar. It does not include "inner" parts of the frame like client
151 * edge, static edge or scroll bars.
153 * Revision history
154 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
155 * Original (NC_AdjustRect95) cut & paste from NC_AdjustRect
157 * 20-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
158 * Split NC_AdjustRect95 into NC_AdjustRectOuter95 and
159 * NC_AdjustRectInner95 and added handling of Win95 styles.
161 * 28-Jul-1999 Ove Kåven (ovek@arcticnet.no)
162 * Streamlined window style checks.
164 *****************************************************************************/
166 static void
167 NC_AdjustRectOuter95 (LPRECT16 rect, DWORD style, BOOL menu, DWORD exStyle)
169 if(style & WS_ICONIC) return;
171 /* Decide if the window will be managed (see CreateWindowEx) */
172 if (!WIN_WindowNeedsWMBorder(style, exStyle))
174 if (HAS_THICKFRAME( style, exStyle ))
175 InflateRect16( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
176 else
177 if (HAS_DLGFRAME( style, exStyle ))
178 InflateRect16(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
179 else
180 if (HAS_THINFRAME( style ))
181 InflateRect16( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
183 if ((style & WS_CAPTION) == WS_CAPTION)
185 if (exStyle & WS_EX_TOOLWINDOW)
186 rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
187 else
188 rect->top -= GetSystemMetrics(SM_CYCAPTION);
192 if (menu)
193 rect->top -= GetSystemMetrics(SM_CYMENU);
197 /******************************************************************************
198 * NC_AdjustRectInner95
200 * Computes the size of the "inside" part of the window based on the
201 * parameters of the client area.
203 + PARAMS
204 * LPRECT16 rect
205 * DWORD style
206 * DWORD exStyle
208 * NOTES
209 * "Inner" part of a window means the window frame inside of the flat
210 * window frame. It includes the client edge, the static edge and the
211 * scroll bars.
213 * Revision history
214 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
215 * Original (NC_AdjustRect95) cut & paste from NC_AdjustRect
217 * 20-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
218 * Split NC_AdjustRect95 into NC_AdjustRectOuter95 and
219 * NC_AdjustRectInner95 and added handling of Win95 styles.
221 *****************************************************************************/
223 static void
224 NC_AdjustRectInner95 (LPRECT16 rect, DWORD style, DWORD exStyle)
226 if(style & WS_ICONIC) return;
228 if (exStyle & WS_EX_CLIENTEDGE)
229 InflateRect16 (rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
231 if (exStyle & WS_EX_STATICEDGE)
232 InflateRect16 (rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
234 if (style & WS_VSCROLL) rect->right += GetSystemMetrics(SM_CXVSCROLL);
235 if (style & WS_HSCROLL) rect->bottom += GetSystemMetrics(SM_CYHSCROLL);
239 /***********************************************************************
240 * DrawCaption16 [USER.660] Draws a caption bar
242 * PARAMS
243 * hwnd [I]
244 * hdc [I]
245 * lpRect [I]
246 * uFlags [I]
248 * RETURNS
249 * Success:
250 * Failure:
253 BOOL16 WINAPI
254 DrawCaption16 (HWND16 hwnd, HDC16 hdc, const RECT16 *rect, UINT16 uFlags)
256 RECT rect32;
258 if (rect)
259 CONV_RECT16TO32 (rect, &rect32);
261 return (BOOL16)DrawCaptionTempA (hwnd, hdc, rect ? &rect32 : NULL,
262 0, 0, NULL, uFlags & 0x1F);
266 /***********************************************************************
267 * DrawCaption32 [USER32.154] Draws a caption bar
269 * PARAMS
270 * hwnd [I]
271 * hdc [I]
272 * lpRect [I]
273 * uFlags [I]
275 * RETURNS
276 * Success:
277 * Failure:
280 BOOL WINAPI
281 DrawCaption (HWND hwnd, HDC hdc, const RECT *lpRect, UINT uFlags)
283 return DrawCaptionTempA (hwnd, hdc, lpRect, 0, 0, NULL, uFlags & 0x1F);
287 /***********************************************************************
288 * DrawCaptionTemp16 [USER.657]
290 * PARAMS
292 * RETURNS
293 * Success:
294 * Failure:
297 BOOL16 WINAPI
298 DrawCaptionTemp16 (HWND16 hwnd, HDC16 hdc, const RECT16 *rect, HFONT16 hFont,
299 HICON16 hIcon, LPCSTR str, UINT16 uFlags)
301 RECT rect32;
303 if (rect)
304 CONV_RECT16TO32(rect,&rect32);
306 return (BOOL16)DrawCaptionTempA (hwnd, hdc, rect?&rect32:NULL, hFont,
307 hIcon, str, uFlags & 0x1F);
311 /***********************************************************************
312 * DrawCaptionTemp32A [USER32.599]
314 * PARAMS
316 * RETURNS
317 * Success:
318 * Failure:
321 BOOL WINAPI
322 DrawCaptionTempA (HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont,
323 HICON hIcon, LPCSTR str, UINT uFlags)
325 RECT rc = *rect;
327 TRACE_(nonclient)("(%08x,%08x,%p,%08x,%08x,\"%s\",%08x)\n",
328 hwnd, hdc, rect, hFont, hIcon, str, uFlags);
330 /* drawing background */
331 if (uFlags & DC_INBUTTON) {
332 FillRect (hdc, &rc, GetSysColorBrush (COLOR_3DFACE));
334 if (uFlags & DC_ACTIVE) {
335 HBRUSH hbr = SelectObject (hdc, CACHE_GetPattern55AABrush ());
336 PatBlt (hdc, rc.left, rc.top,
337 rc.right-rc.left, rc.bottom-rc.top, 0xFA0089);
338 SelectObject (hdc, hbr);
341 else {
342 FillRect (hdc, &rc, GetSysColorBrush ((uFlags & DC_ACTIVE) ?
343 COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION));
347 /* drawing icon */
348 if ((uFlags & DC_ICON) && !(uFlags & DC_SMALLCAP)) {
349 POINT pt;
351 pt.x = rc.left + 2;
352 pt.y = (rc.bottom + rc.top - GetSystemMetrics(SM_CYSMICON)) / 2;
354 if (hIcon) {
355 DrawIconEx (hdc, pt.x, pt.y, hIcon, GetSystemMetrics(SM_CXSMICON),
356 GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL);
358 else {
359 HICON hAppIcon = (HICON) GetClassLongA(hwnd, GCL_HICONSM);
360 if(!hAppIcon) hAppIcon = (HICON) GetClassLongA(hwnd, GCL_HICON);
362 DrawIconEx (hdc, pt.x, pt.y, hAppIcon, GetSystemMetrics(SM_CXSMICON),
363 GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL);
366 rc.left += (rc.bottom - rc.top);
369 /* drawing text */
370 if (uFlags & DC_TEXT) {
371 HFONT hOldFont;
373 if (uFlags & DC_INBUTTON)
374 SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
375 else if (uFlags & DC_ACTIVE)
376 SetTextColor (hdc, GetSysColor (COLOR_CAPTIONTEXT));
377 else
378 SetTextColor (hdc, GetSysColor (COLOR_INACTIVECAPTIONTEXT));
380 SetBkMode (hdc, TRANSPARENT);
382 if (hFont)
383 hOldFont = SelectObject (hdc, hFont);
384 else {
385 NONCLIENTMETRICSA nclm;
386 HFONT hNewFont;
387 nclm.cbSize = sizeof(NONCLIENTMETRICSA);
388 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
389 hNewFont = CreateFontIndirectA ((uFlags & DC_SMALLCAP) ?
390 &nclm.lfSmCaptionFont : &nclm.lfCaptionFont);
391 hOldFont = SelectObject (hdc, hNewFont);
394 if (str)
395 DrawTextA (hdc, str, -1, &rc,
396 DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT);
397 else {
398 CHAR szText[128];
399 INT nLen;
400 nLen = GetWindowTextA (hwnd, szText, 128);
401 DrawTextA (hdc, szText, nLen, &rc,
402 DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT);
405 if (hFont)
406 SelectObject (hdc, hOldFont);
407 else
408 DeleteObject (SelectObject (hdc, hOldFont));
411 /* drawing focus ??? */
412 if (uFlags & 0x2000)
413 FIXME_(nonclient)("undocumented flag (0x2000)!\n");
415 return 0;
419 /***********************************************************************
420 * DrawCaptionTemp32W [USER32.602]
422 * PARAMS
424 * RETURNS
425 * Success:
426 * Failure:
429 BOOL WINAPI
430 DrawCaptionTempW (HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont,
431 HICON hIcon, LPCWSTR str, UINT uFlags)
433 LPSTR p = HEAP_strdupWtoA (GetProcessHeap (), 0, str);
434 BOOL res = DrawCaptionTempA (hwnd, hdc, rect, hFont, hIcon, p, uFlags);
435 HeapFree (GetProcessHeap (), 0, p);
436 return res;
440 /***********************************************************************
441 * AdjustWindowRect16 (USER.102)
443 BOOL16 WINAPI AdjustWindowRect16( LPRECT16 rect, DWORD style, BOOL16 menu )
445 return AdjustWindowRectEx16( rect, style, menu, 0 );
449 /***********************************************************************
450 * AdjustWindowRect32 (USER32.2)
452 BOOL WINAPI AdjustWindowRect( LPRECT rect, DWORD style, BOOL menu )
454 return AdjustWindowRectEx( rect, style, menu, 0 );
458 /***********************************************************************
459 * AdjustWindowRectEx16 (USER.454)
461 BOOL16 WINAPI AdjustWindowRectEx16( LPRECT16 rect, DWORD style,
462 BOOL16 menu, DWORD exStyle )
464 /* Correct the window style */
466 if (!(style & (WS_POPUP | WS_CHILD))) /* Overlapped window */
467 style |= WS_CAPTION;
468 style &= (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME | WS_CHILD);
469 exStyle &= (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE |
470 WS_EX_STATICEDGE | WS_EX_TOOLWINDOW);
471 if (exStyle & WS_EX_DLGMODALFRAME) style &= ~WS_THICKFRAME;
473 TRACE_(nonclient)("(%d,%d)-(%d,%d) %08lx %d %08lx\n",
474 rect->left, rect->top, rect->right, rect->bottom,
475 style, menu, exStyle );
477 if (TWEAK_WineLook == WIN31_LOOK)
478 NC_AdjustRect( rect, style, menu, exStyle );
479 else {
480 NC_AdjustRectOuter95( rect, style, menu, exStyle );
481 NC_AdjustRectInner95( rect, style, exStyle );
484 return TRUE;
488 /***********************************************************************
489 * AdjustWindowRectEx32 (USER32.3)
491 BOOL WINAPI AdjustWindowRectEx( LPRECT rect, DWORD style,
492 BOOL menu, DWORD exStyle )
494 RECT16 rect16;
495 BOOL ret;
497 CONV_RECT32TO16( rect, &rect16 );
498 ret = AdjustWindowRectEx16( &rect16, style, (BOOL16)menu, exStyle );
499 CONV_RECT16TO32( &rect16, rect );
500 return ret;
504 /***********************************************************************
505 * NC_HandleNCCalcSize
507 * Handle a WM_NCCALCSIZE message. Called from DefWindowProc().
509 LONG NC_HandleNCCalcSize( WND *pWnd, RECT *winRect )
511 RECT16 tmpRect = { 0, 0, 0, 0 };
512 LONG result = 0;
513 UINT style = (UINT) GetClassLongA(pWnd->hwndSelf, GCL_STYLE);
515 if (style & CS_VREDRAW) result |= WVR_VREDRAW;
516 if (style & CS_HREDRAW) result |= WVR_HREDRAW;
518 if( !( pWnd->dwStyle & WS_MINIMIZE ) ) {
519 if (TWEAK_WineLook == WIN31_LOOK)
520 NC_AdjustRect( &tmpRect, pWnd->dwStyle, FALSE, pWnd->dwExStyle );
521 else
522 NC_AdjustRectOuter95( &tmpRect, pWnd->dwStyle, FALSE, pWnd->dwExStyle );
524 winRect->left -= tmpRect.left;
525 winRect->top -= tmpRect.top;
526 winRect->right -= tmpRect.right;
527 winRect->bottom -= tmpRect.bottom;
529 if (HAS_MENU(pWnd)) {
530 TRACE_(nonclient)("Calling "
531 "GetMenuBarHeight with HWND 0x%x, width %d, "
532 "at (%d, %d).\n", pWnd->hwndSelf,
533 winRect->right - winRect->left,
534 -tmpRect.left, -tmpRect.top );
536 winRect->top +=
537 MENU_GetMenuBarHeight( pWnd->hwndSelf,
538 winRect->right - winRect->left,
539 -tmpRect.left, -tmpRect.top ) + 1;
542 if (TWEAK_WineLook > WIN31_LOOK) {
543 SetRect16 (&tmpRect, 0, 0, 0, 0);
544 NC_AdjustRectInner95 (&tmpRect, pWnd->dwStyle, pWnd->dwExStyle);
545 winRect->left -= tmpRect.left;
546 winRect->top -= tmpRect.top;
547 winRect->right -= tmpRect.right;
548 winRect->bottom -= tmpRect.bottom;
551 return result;
555 /***********************************************************************
556 * NC_GetInsideRect
558 * Get the 'inside' rectangle of a window, i.e. the whole window rectangle
559 * but without the borders (if any).
560 * The rectangle is in window coordinates (for drawing with GetWindowDC()).
562 static void NC_GetInsideRect( HWND hwnd, RECT *rect )
564 WND * wndPtr = WIN_FindWndPtr( hwnd );
566 rect->top = rect->left = 0;
567 rect->right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
568 rect->bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
570 if ((wndPtr->dwStyle & WS_ICONIC) || (wndPtr->flags & WIN_MANAGED)) goto END;
572 /* Remove frame from rectangle */
573 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
574 InflateRect( rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) );
575 else
576 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
578 InflateRect( rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
579 /* FIXME: this isn't in NC_AdjustRect? why not? */
580 if (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME)
581 InflateRect( rect, -1, 0 );
583 else
584 if (HAS_THINFRAME( wndPtr->dwStyle ))
585 InflateRect( rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER) );
586 END:
587 WIN_ReleaseWndPtr(wndPtr);
588 return;
592 /***********************************************************************
593 * NC_GetInsideRect95
595 * Get the 'inside' rectangle of a window, i.e. the whole window rectangle
596 * but without the borders (if any).
597 * The rectangle is in window coordinates (for drawing with GetWindowDC()).
600 static void
601 NC_GetInsideRect95 (HWND hwnd, RECT *rect)
603 WND * wndPtr = WIN_FindWndPtr( hwnd );
605 rect->top = rect->left = 0;
606 rect->right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
607 rect->bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
609 if ((wndPtr->dwStyle & WS_ICONIC) || (wndPtr->flags & WIN_MANAGED)) goto END;
611 /* Remove frame from rectangle */
612 if (HAS_THICKFRAME (wndPtr->dwStyle, wndPtr->dwExStyle))
614 InflateRect( rect, -GetSystemMetrics(SM_CXSIZEFRAME), -GetSystemMetrics(SM_CYSIZEFRAME) );
616 else if (HAS_DLGFRAME (wndPtr->dwStyle, wndPtr->dwExStyle ))
618 InflateRect( rect, -GetSystemMetrics(SM_CXFIXEDFRAME), -GetSystemMetrics(SM_CYFIXEDFRAME));
620 else if (HAS_THINFRAME (wndPtr->dwStyle))
622 InflateRect( rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER) );
625 if (wndPtr->dwStyle & WS_CHILD) {
626 if (wndPtr->dwExStyle & WS_EX_CLIENTEDGE)
627 InflateRect (rect, -GetSystemMetrics(SM_CXEDGE), -GetSystemMetrics(SM_CYEDGE));
629 if (wndPtr->dwExStyle & WS_EX_STATICEDGE)
630 InflateRect (rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
632 END:
633 WIN_ReleaseWndPtr(wndPtr);
634 return;
638 /***********************************************************************
639 * NC_DoNCHitTest
641 * Handle a WM_NCHITTEST message. Called from NC_HandleNcHitTest().
644 static LONG NC_DoNCHitTest (WND *wndPtr, POINT16 pt )
646 RECT16 rect;
648 TRACE_(nonclient)("hwnd=%04x pt=%d,%d\n",
649 wndPtr->hwndSelf, pt.x, pt.y );
651 GetWindowRect16 (wndPtr->hwndSelf, &rect );
652 if (!PtInRect16( &rect, pt )) return HTNOWHERE;
654 if (wndPtr->dwStyle & WS_MINIMIZE) return HTCAPTION;
656 if (!(wndPtr->flags & WIN_MANAGED))
658 /* Check borders */
659 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
661 InflateRect16( &rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) );
662 if (!PtInRect16( &rect, pt ))
664 /* Check top sizing border */
665 if (pt.y < rect.top)
667 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTTOPLEFT;
668 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTTOPRIGHT;
669 return HTTOP;
671 /* Check bottom sizing border */
672 if (pt.y >= rect.bottom)
674 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMLEFT;
675 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMRIGHT;
676 return HTBOTTOM;
678 /* Check left sizing border */
679 if (pt.x < rect.left)
681 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPLEFT;
682 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMLEFT;
683 return HTLEFT;
685 /* Check right sizing border */
686 if (pt.x >= rect.right)
688 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPRIGHT;
689 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMRIGHT;
690 return HTRIGHT;
694 else /* No thick frame */
696 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
697 InflateRect16(&rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
698 else if (HAS_THINFRAME( wndPtr->dwStyle ))
699 InflateRect16(&rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
700 if (!PtInRect16( &rect, pt )) return HTBORDER;
703 /* Check caption */
705 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
707 rect.top += GetSystemMetrics(SM_CYCAPTION) - GetSystemMetrics(SM_CYBORDER);
708 if (!PtInRect16( &rect, pt ))
710 /* Check system menu */
711 if (wndPtr->dwStyle & WS_SYSMENU)
712 rect.left += GetSystemMetrics(SM_CXSIZE);
713 if (pt.x <= rect.left) return HTSYSMENU;
714 /* Check maximize box */
715 if (wndPtr->dwStyle & WS_MAXIMIZEBOX)
716 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
717 if (pt.x >= rect.right) return HTMAXBUTTON;
718 /* Check minimize box */
719 if (wndPtr->dwStyle & WS_MINIMIZEBOX)
720 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
721 if (pt.x >= rect.right) return HTMINBUTTON;
722 return HTCAPTION;
727 /* Check client area */
729 ScreenToClient16( wndPtr->hwndSelf, &pt );
730 GetClientRect16( wndPtr->hwndSelf, &rect );
731 if (PtInRect16( &rect, pt )) return HTCLIENT;
733 /* Check vertical scroll bar */
735 if (wndPtr->dwStyle & WS_VSCROLL)
737 rect.right += GetSystemMetrics(SM_CXVSCROLL);
738 if (PtInRect16( &rect, pt )) return HTVSCROLL;
741 /* Check horizontal scroll bar */
743 if (wndPtr->dwStyle & WS_HSCROLL)
745 rect.bottom += GetSystemMetrics(SM_CYHSCROLL);
746 if (PtInRect16( &rect, pt ))
748 /* Check size box */
749 if ((wndPtr->dwStyle & WS_VSCROLL) &&
750 (pt.x >= rect.right - GetSystemMetrics(SM_CXVSCROLL)))
751 return HTSIZE;
752 return HTHSCROLL;
756 /* Check menu bar */
758 if (HAS_MENU(wndPtr))
760 if ((pt.y < 0) && (pt.x >= 0) && (pt.x < rect.right))
761 return HTMENU;
764 /* Should never get here */
765 return HTERROR;
769 /***********************************************************************
770 * NC_DoNCHitTest95
772 * Handle a WM_NCHITTEST message. Called from NC_HandleNCHitTest().
774 * FIXME: Just a modified copy of the Win 3.1 version.
777 static LONG
778 NC_DoNCHitTest95 (WND *wndPtr, POINT16 pt )
780 RECT16 rect;
782 TRACE_(nonclient)("hwnd=%04x pt=%d,%d\n",
783 wndPtr->hwndSelf, pt.x, pt.y );
785 GetWindowRect16 (wndPtr->hwndSelf, &rect );
786 if (!PtInRect16( &rect, pt )) return HTNOWHERE;
788 if (wndPtr->dwStyle & WS_MINIMIZE) return HTCAPTION;
790 if (!(wndPtr->flags & WIN_MANAGED))
792 /* Check borders */
793 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
795 InflateRect16( &rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) );
796 if (!PtInRect16( &rect, pt ))
798 /* Check top sizing border */
799 if (pt.y < rect.top)
801 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTTOPLEFT;
802 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTTOPRIGHT;
803 return HTTOP;
805 /* Check bottom sizing border */
806 if (pt.y >= rect.bottom)
808 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMLEFT;
809 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMRIGHT;
810 return HTBOTTOM;
812 /* Check left sizing border */
813 if (pt.x < rect.left)
815 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPLEFT;
816 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMLEFT;
817 return HTLEFT;
819 /* Check right sizing border */
820 if (pt.x >= rect.right)
822 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPRIGHT;
823 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMRIGHT;
824 return HTRIGHT;
828 else /* No thick frame */
830 if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
831 InflateRect16(&rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
832 else if (HAS_THINFRAME( wndPtr->dwStyle ))
833 InflateRect16(&rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
834 if (!PtInRect16( &rect, pt )) return HTBORDER;
837 /* Check caption */
839 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
841 if (wndPtr->dwExStyle & WS_EX_TOOLWINDOW)
842 rect.top += GetSystemMetrics(SM_CYSMCAPTION) - 1;
843 else
844 rect.top += GetSystemMetrics(SM_CYCAPTION) - 1;
845 if (!PtInRect16( &rect, pt ))
847 /* Check system menu */
848 if ((wndPtr->dwStyle & WS_SYSMENU) &&
849 (((HICON) GetClassLongA(wndPtr->hwndSelf, GCL_HICONSM)) ||
850 ((HICON) GetClassLongA(wndPtr->hwndSelf, GCL_HICON))))
851 rect.left += GetSystemMetrics(SM_CYCAPTION) - 1;
852 if (pt.x < rect.left) return HTSYSMENU;
854 /* Check close button */
855 if (wndPtr->dwStyle & WS_SYSMENU)
856 rect.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
857 if (pt.x > rect.right) return HTCLOSE;
859 /* Check maximize box */
860 if (wndPtr->dwStyle & WS_MAXIMIZEBOX)
861 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
862 if (pt.x > rect.right) return HTMAXBUTTON;
864 /* Check minimize box */
865 if (wndPtr->dwStyle & WS_MINIMIZEBOX)
866 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
867 if (pt.x > rect.right) return HTMINBUTTON;
868 return HTCAPTION;
873 /* Check client area */
875 ScreenToClient16( wndPtr->hwndSelf, &pt );
876 GetClientRect16( wndPtr->hwndSelf, &rect );
877 if (PtInRect16( &rect, pt )) return HTCLIENT;
879 /* Check vertical scroll bar */
881 if (wndPtr->dwStyle & WS_VSCROLL)
883 rect.right += GetSystemMetrics(SM_CXVSCROLL);
884 if (PtInRect16( &rect, pt )) return HTVSCROLL;
887 /* Check horizontal scroll bar */
889 if (wndPtr->dwStyle & WS_HSCROLL)
891 rect.bottom += GetSystemMetrics(SM_CYHSCROLL);
892 if (PtInRect16( &rect, pt ))
894 /* Check size box */
895 if ((wndPtr->dwStyle & WS_VSCROLL) &&
896 (pt.x >= rect.right - GetSystemMetrics(SM_CXVSCROLL)))
897 return HTSIZE;
898 return HTHSCROLL;
902 /* Check menu bar */
904 if (HAS_MENU(wndPtr))
906 if ((pt.y < 0) && (pt.x >= 0) && (pt.x < rect.right))
907 return HTMENU;
910 /* Should never get here */
911 return HTERROR;
915 /***********************************************************************
916 * NC_HandleNCHitTest
918 * Handle a WM_NCHITTEST message. Called from DefWindowProc().
920 LONG
921 NC_HandleNCHitTest (HWND hwnd , POINT16 pt)
923 LONG retvalue;
924 WND *wndPtr = WIN_FindWndPtr (hwnd);
926 if (!wndPtr)
927 return HTERROR;
929 if (TWEAK_WineLook == WIN31_LOOK)
930 retvalue = NC_DoNCHitTest (wndPtr, pt);
931 else
932 retvalue = NC_DoNCHitTest95 (wndPtr, pt);
933 WIN_ReleaseWndPtr(wndPtr);
934 return retvalue;
938 /***********************************************************************
939 * NC_DrawSysButton
941 void NC_DrawSysButton( HWND hwnd, HDC hdc, BOOL down )
943 RECT rect;
944 HDC hdcMem;
945 HBITMAP hbitmap;
946 WND *wndPtr = WIN_FindWndPtr( hwnd );
948 if( !(wndPtr->flags & WIN_MANAGED) )
950 NC_GetInsideRect( hwnd, &rect );
951 hdcMem = CreateCompatibleDC( hdc );
952 hbitmap = SelectObject( hdcMem, hbitmapClose );
953 BitBlt(hdc, rect.left, rect.top, GetSystemMetrics(SM_CXSIZE), GetSystemMetrics(SM_CYSIZE),
954 hdcMem, (wndPtr->dwStyle & WS_CHILD) ? GetSystemMetrics(SM_CXSIZE) : 0, 0,
955 down ? NOTSRCCOPY : SRCCOPY );
956 SelectObject( hdcMem, hbitmap );
957 DeleteDC( hdcMem );
959 WIN_ReleaseWndPtr(wndPtr);
963 /***********************************************************************
964 * NC_DrawMaxButton
966 static void NC_DrawMaxButton( HWND hwnd, HDC16 hdc, BOOL down )
968 RECT rect;
969 WND *wndPtr = WIN_FindWndPtr( hwnd );
970 HDC hdcMem;
972 if( !(wndPtr->flags & WIN_MANAGED) )
974 NC_GetInsideRect( hwnd, &rect );
975 hdcMem = CreateCompatibleDC( hdc );
976 SelectObject( hdcMem, (IsZoomed(hwnd)
977 ? (down ? hbitmapRestoreD : hbitmapRestore)
978 : (down ? hbitmapMaximizeD : hbitmapMaximize)) );
979 BitBlt( hdc, rect.right - GetSystemMetrics(SM_CXSIZE) - 1, rect.top,
980 GetSystemMetrics(SM_CXSIZE) + 1, GetSystemMetrics(SM_CYSIZE), hdcMem, 0, 0,
981 SRCCOPY );
982 DeleteDC( hdcMem );
984 WIN_ReleaseWndPtr(wndPtr);
989 /***********************************************************************
990 * NC_DrawMinButton
992 static void NC_DrawMinButton( HWND hwnd, HDC16 hdc, BOOL down )
994 RECT rect;
995 WND *wndPtr = WIN_FindWndPtr( hwnd );
996 HDC hdcMem;
998 if( !(wndPtr->flags & WIN_MANAGED) )
1000 NC_GetInsideRect( hwnd, &rect );
1001 hdcMem = CreateCompatibleDC( hdc );
1002 SelectObject( hdcMem, (down ? hbitmapMinimizeD : hbitmapMinimize) );
1003 if (wndPtr->dwStyle & WS_MAXIMIZEBOX) rect.right -= GetSystemMetrics(SM_CXSIZE)+1;
1004 BitBlt( hdc, rect.right - GetSystemMetrics(SM_CXSIZE) - 1, rect.top,
1005 GetSystemMetrics(SM_CXSIZE) + 1, GetSystemMetrics(SM_CYSIZE), hdcMem, 0, 0,
1006 SRCCOPY );
1007 DeleteDC( hdcMem );
1009 WIN_ReleaseWndPtr(wndPtr);
1013 /******************************************************************************
1015 * void NC_DrawSysButton95(
1016 * HWND32 hwnd,
1017 * HDC32 hdc,
1018 * BOOL32 down )
1020 * Draws the Win95 system icon.
1022 * Revision history
1023 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1024 * Original implementation from NC_DrawSysButton source.
1025 * 11-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1026 * Fixed most bugs.
1028 *****************************************************************************/
1030 BOOL
1031 NC_DrawSysButton95 (HWND hwnd, HDC hdc, BOOL down)
1033 WND *wndPtr = WIN_FindWndPtr( hwnd );
1035 if( !(wndPtr->flags & WIN_MANAGED) )
1037 HICON hIcon;
1038 RECT rect;
1040 NC_GetInsideRect95( hwnd, &rect );
1042 hIcon = (HICON) GetClassLongA(wndPtr->hwndSelf, GCL_HICONSM);
1043 if(!hIcon) hIcon = (HICON) GetClassLongA(wndPtr->hwndSelf, GCL_HICON);
1045 if (hIcon)
1046 DrawIconEx (hdc, rect.left + 2, rect.top + 2, hIcon,
1047 GetSystemMetrics(SM_CXSMICON),
1048 GetSystemMetrics(SM_CYSMICON),
1049 0, 0, DI_NORMAL);
1051 WIN_ReleaseWndPtr(wndPtr);
1052 return (hIcon != 0);
1054 WIN_ReleaseWndPtr(wndPtr);
1055 return FALSE;
1059 /******************************************************************************
1061 * void NC_DrawCloseButton95(
1062 * HWND32 hwnd,
1063 * HDC32 hdc,
1064 * BOOL32 down )
1066 * Draws the Win95 close button.
1068 * Revision history
1069 * 11-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1070 * Original implementation from NC_DrawSysButton95 source.
1072 *****************************************************************************/
1074 static void NC_DrawCloseButton95 (HWND hwnd, HDC hdc, BOOL down)
1076 RECT rect;
1077 HDC hdcMem;
1078 WND *wndPtr = WIN_FindWndPtr( hwnd );
1080 if( !(wndPtr->flags & WIN_MANAGED) )
1082 BITMAP bmp;
1083 HBITMAP hBmp, hOldBmp;
1085 NC_GetInsideRect95( hwnd, &rect );
1087 hdcMem = CreateCompatibleDC( hdc );
1088 hBmp = down ? hbitmapCloseD : hbitmapClose;
1089 hOldBmp = SelectObject (hdcMem, hBmp);
1090 GetObjectA (hBmp, sizeof(BITMAP), &bmp);
1091 BitBlt (hdc, rect.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2,
1092 rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
1093 bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY);
1095 SelectObject (hdcMem, hOldBmp);
1096 DeleteDC (hdcMem);
1098 WIN_ReleaseWndPtr(wndPtr);
1101 /******************************************************************************
1103 * NC_DrawMaxButton95(
1104 * HWND32 hwnd,
1105 * HDC16 hdc,
1106 * BOOL32 down )
1108 * Draws the maximize button for Win95 style windows.
1110 * Bugs
1111 * Many. Spacing might still be incorrect. Need to fit a close
1112 * button between the max button and the edge.
1113 * Should scale the image with the title bar. And more...
1115 * Revision history
1116 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1117 * Original implementation.
1119 *****************************************************************************/
1121 static void NC_DrawMaxButton95(HWND hwnd,HDC16 hdc,BOOL down )
1123 RECT rect;
1124 HDC hdcMem;
1125 WND *wndPtr = WIN_FindWndPtr( hwnd );
1127 if( !(wndPtr->flags & WIN_MANAGED))
1129 BITMAP bmp;
1130 HBITMAP hBmp,hOldBmp;
1132 NC_GetInsideRect95( hwnd, &rect );
1133 hdcMem = CreateCompatibleDC( hdc );
1134 hBmp = IsZoomed(hwnd) ?
1135 (down ? hbitmapRestoreD : hbitmapRestore ) :
1136 (down ? hbitmapMaximizeD: hbitmapMaximize);
1137 hOldBmp=SelectObject( hdcMem, hBmp );
1138 GetObjectA (hBmp, sizeof(BITMAP), &bmp);
1140 if (wndPtr->dwStyle & WS_SYSMENU)
1141 rect.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
1143 BitBlt( hdc, rect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
1144 rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
1145 bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY );
1146 SelectObject (hdcMem, hOldBmp);
1147 DeleteDC( hdcMem );
1149 WIN_ReleaseWndPtr(wndPtr);
1152 /******************************************************************************
1154 * NC_DrawMinButton95(
1155 * HWND32 hwnd,
1156 * HDC16 hdc,
1157 * BOOL32 down )
1159 * Draws the minimize button for Win95 style windows.
1161 * Bugs
1162 * Many. Spacing is still incorrect. Should scale the image with the
1163 * title bar. And more...
1165 * Revision history
1166 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1167 * Original implementation.
1169 *****************************************************************************/
1171 static void NC_DrawMinButton95(HWND hwnd,HDC16 hdc,BOOL down )
1173 RECT rect;
1174 HDC hdcMem;
1175 WND *wndPtr = WIN_FindWndPtr( hwnd );
1177 if( !(wndPtr->flags & WIN_MANAGED))
1180 BITMAP bmp;
1181 HBITMAP hBmp,hOldBmp;
1183 NC_GetInsideRect95( hwnd, &rect );
1185 hdcMem = CreateCompatibleDC( hdc );
1186 hBmp = down ? hbitmapMinimizeD : hbitmapMinimize;
1187 hOldBmp= SelectObject( hdcMem, hBmp );
1188 GetObjectA (hBmp, sizeof(BITMAP), &bmp);
1190 if (wndPtr->dwStyle & WS_SYSMENU)
1191 rect.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
1193 if (wndPtr->dwStyle & WS_MAXIMIZEBOX)
1194 rect.right += -1 - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2;
1196 BitBlt( hdc, rect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
1197 rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
1198 bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY );
1200 SelectObject (hdcMem, hOldBmp);
1201 DeleteDC( hdcMem );
1203 WIN_ReleaseWndPtr(wndPtr);
1206 /***********************************************************************
1207 * NC_DrawFrame
1209 * Draw a window frame inside the given rectangle, and update the rectangle.
1210 * The correct pen for the frame must be selected in the DC.
1212 static void NC_DrawFrame( HDC hdc, RECT *rect, BOOL dlgFrame,
1213 BOOL active )
1215 INT width, height;
1217 if (TWEAK_WineLook != WIN31_LOOK)
1218 ERR_(nonclient)("Called in Win95 mode. Aiee! Please report this.\n" );
1220 if (dlgFrame)
1222 width = GetSystemMetrics(SM_CXDLGFRAME) - 1;
1223 height = GetSystemMetrics(SM_CYDLGFRAME) - 1;
1224 SelectObject( hdc, GetSysColorBrush(active ? COLOR_ACTIVECAPTION :
1225 COLOR_INACTIVECAPTION) );
1227 else
1229 width = GetSystemMetrics(SM_CXFRAME) - 2;
1230 height = GetSystemMetrics(SM_CYFRAME) - 2;
1231 SelectObject( hdc, GetSysColorBrush(active ? COLOR_ACTIVEBORDER :
1232 COLOR_INACTIVEBORDER) );
1235 /* Draw frame */
1236 PatBlt( hdc, rect->left, rect->top,
1237 rect->right - rect->left, height, PATCOPY );
1238 PatBlt( hdc, rect->left, rect->top,
1239 width, rect->bottom - rect->top, PATCOPY );
1240 PatBlt( hdc, rect->left, rect->bottom - 1,
1241 rect->right - rect->left, -height, PATCOPY );
1242 PatBlt( hdc, rect->right - 1, rect->top,
1243 -width, rect->bottom - rect->top, PATCOPY );
1245 if (dlgFrame)
1247 InflateRect( rect, -width, -height );
1249 else
1251 INT decYOff = GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXSIZE) - 1;
1252 INT decXOff = GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYSIZE) - 1;
1254 /* Draw inner rectangle */
1256 SelectObject( hdc, GetStockObject(NULL_BRUSH) );
1257 Rectangle( hdc, rect->left + width, rect->top + height,
1258 rect->right - width , rect->bottom - height );
1260 /* Draw the decorations */
1262 MoveToEx( hdc, rect->left, rect->top + decYOff, NULL );
1263 LineTo( hdc, rect->left + width, rect->top + decYOff );
1264 MoveToEx( hdc, rect->right - 1, rect->top + decYOff, NULL );
1265 LineTo( hdc, rect->right - width - 1, rect->top + decYOff );
1266 MoveToEx( hdc, rect->left, rect->bottom - decYOff, NULL );
1267 LineTo( hdc, rect->left + width, rect->bottom - decYOff );
1268 MoveToEx( hdc, rect->right - 1, rect->bottom - decYOff, NULL );
1269 LineTo( hdc, rect->right - width - 1, rect->bottom - decYOff );
1271 MoveToEx( hdc, rect->left + decXOff, rect->top, NULL );
1272 LineTo( hdc, rect->left + decXOff, rect->top + height);
1273 MoveToEx( hdc, rect->left + decXOff, rect->bottom - 1, NULL );
1274 LineTo( hdc, rect->left + decXOff, rect->bottom - height - 1 );
1275 MoveToEx( hdc, rect->right - decXOff, rect->top, NULL );
1276 LineTo( hdc, rect->right - decXOff, rect->top + height );
1277 MoveToEx( hdc, rect->right - decXOff, rect->bottom - 1, NULL );
1278 LineTo( hdc, rect->right - decXOff, rect->bottom - height - 1 );
1280 InflateRect( rect, -width - 1, -height - 1 );
1285 /******************************************************************************
1287 * void NC_DrawFrame95(
1288 * HDC32 hdc,
1289 * RECT32 *rect,
1290 * BOOL32 dlgFrame,
1291 * BOOL32 active )
1293 * Draw a window frame inside the given rectangle, and update the rectangle.
1294 * The correct pen for the frame must be selected in the DC.
1296 * Bugs
1297 * Many. First, just what IS a frame in Win95? Note that the 3D look
1298 * on the outer edge is handled by NC_DoNCPaint95. As is the inner
1299 * edge. The inner rectangle just inside the frame is handled by the
1300 * Caption code.
1302 * In short, for most people, this function should be a nop (unless
1303 * you LIKE thick borders in Win95/NT4.0 -- I've been working with
1304 * them lately, but just to get this code right). Even so, it doesn't
1305 * appear to be so. It's being worked on...
1307 * Revision history
1308 * 06-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1309 * Original implementation (based on NC_DrawFrame)
1310 * 02-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1311 * Some minor fixes.
1312 * 29-Jun-1999 Ove Kåven (ovek@arcticnet.no)
1313 * Fixed a fix or something.
1315 *****************************************************************************/
1317 static void NC_DrawFrame95(
1318 HDC hdc,
1319 RECT *rect,
1320 BOOL dlgFrame,
1321 BOOL active )
1323 INT width, height;
1325 if (dlgFrame)
1327 width = GetSystemMetrics(SM_CXDLGFRAME) - GetSystemMetrics(SM_CXEDGE);
1328 height = GetSystemMetrics(SM_CYDLGFRAME) - GetSystemMetrics(SM_CYEDGE);
1330 else
1332 width = GetSystemMetrics(SM_CXFRAME) - GetSystemMetrics(SM_CXEDGE);
1333 height = GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYEDGE);
1336 SelectObject( hdc, GetSysColorBrush(active ? COLOR_ACTIVEBORDER :
1337 COLOR_INACTIVEBORDER) );
1339 /* Draw frame */
1340 PatBlt( hdc, rect->left, rect->top,
1341 rect->right - rect->left, height, PATCOPY );
1342 PatBlt( hdc, rect->left, rect->top,
1343 width, rect->bottom - rect->top, PATCOPY );
1344 PatBlt( hdc, rect->left, rect->bottom - 1,
1345 rect->right - rect->left, -height, PATCOPY );
1346 PatBlt( hdc, rect->right - 1, rect->top,
1347 -width, rect->bottom - rect->top, PATCOPY );
1349 InflateRect( rect, -width, -height );
1352 /***********************************************************************
1353 * NC_DrawMovingFrame
1355 * Draw the frame used when moving or resizing window.
1357 * FIXME: This causes problems in Win95 mode. (why?)
1359 static void NC_DrawMovingFrame( HDC hdc, RECT *rect, BOOL thickframe )
1361 if (thickframe)
1363 RECT16 r16;
1364 CONV_RECT32TO16( rect, &r16 );
1365 FastWindowFrame16( hdc, &r16, GetSystemMetrics(SM_CXFRAME),
1366 GetSystemMetrics(SM_CYFRAME), PATINVERT );
1368 else DrawFocusRect( hdc, rect );
1372 /***********************************************************************
1373 * NC_DrawCaption
1375 * Draw the window caption.
1376 * The correct pen for the window frame must be selected in the DC.
1378 static void NC_DrawCaption( HDC hdc, RECT *rect, HWND hwnd,
1379 DWORD style, BOOL active )
1381 RECT r = *rect;
1382 WND * wndPtr = WIN_FindWndPtr( hwnd );
1383 char buffer[256];
1385 if (wndPtr->flags & WIN_MANAGED)
1387 WIN_ReleaseWndPtr(wndPtr);
1388 return;
1391 if (!hbitmapClose)
1393 if (!(hbitmapClose = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_CLOSE) )))
1395 WIN_ReleaseWndPtr(wndPtr);
1396 return;
1398 hbitmapCloseD = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_CLOSED) );
1399 hbitmapMinimize = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_REDUCE) );
1400 hbitmapMinimizeD = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_REDUCED) );
1401 hbitmapMaximize = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_ZOOM) );
1402 hbitmapMaximizeD = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_ZOOMD) );
1403 hbitmapRestore = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_RESTORE) );
1404 hbitmapRestoreD = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_RESTORED) );
1407 if (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME)
1409 HBRUSH hbrushOld = SelectObject(hdc, GetSysColorBrush(COLOR_WINDOW) );
1410 PatBlt( hdc, r.left, r.top, 1, r.bottom-r.top+1,PATCOPY );
1411 PatBlt( hdc, r.right-1, r.top, 1, r.bottom-r.top+1, PATCOPY );
1412 PatBlt( hdc, r.left, r.top-1, r.right-r.left, 1, PATCOPY );
1413 r.left++;
1414 r.right--;
1415 SelectObject( hdc, hbrushOld );
1417 WIN_ReleaseWndPtr(wndPtr);
1418 MoveTo16( hdc, r.left, r.bottom );
1419 LineTo( hdc, r.right, r.bottom );
1421 if (style & WS_SYSMENU)
1423 NC_DrawSysButton( hwnd, hdc, FALSE );
1424 r.left += GetSystemMetrics(SM_CXSIZE) + 1;
1425 MoveTo16( hdc, r.left - 1, r.top );
1426 LineTo( hdc, r.left - 1, r.bottom );
1428 if (style & WS_MAXIMIZEBOX)
1430 NC_DrawMaxButton( hwnd, hdc, FALSE );
1431 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1433 if (style & WS_MINIMIZEBOX)
1435 NC_DrawMinButton( hwnd, hdc, FALSE );
1436 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1439 FillRect( hdc, &r, GetSysColorBrush(active ? COLOR_ACTIVECAPTION :
1440 COLOR_INACTIVECAPTION) );
1442 if (GetWindowTextA( hwnd, buffer, sizeof(buffer) ))
1444 if (active) SetTextColor( hdc, GetSysColor( COLOR_CAPTIONTEXT ) );
1445 else SetTextColor( hdc, GetSysColor( COLOR_INACTIVECAPTIONTEXT ) );
1446 SetBkMode( hdc, TRANSPARENT );
1447 DrawTextA( hdc, buffer, -1, &r,
1448 DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_NOPREFIX );
1453 /******************************************************************************
1455 * NC_DrawCaption95(
1456 * HDC32 hdc,
1457 * RECT32 *rect,
1458 * HWND32 hwnd,
1459 * DWORD style,
1460 * BOOL32 active )
1462 * Draw the window caption for Win95 style windows.
1463 * The correct pen for the window frame must be selected in the DC.
1465 * Bugs
1466 * Hey, a function that finally works! Well, almost.
1467 * It's being worked on.
1469 * Revision history
1470 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1471 * Original implementation.
1472 * 02-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1473 * Some minor fixes.
1475 *****************************************************************************/
1477 static void NC_DrawCaption95(
1478 HDC hdc,
1479 RECT *rect,
1480 HWND hwnd,
1481 DWORD style,
1482 DWORD exStyle,
1483 BOOL active )
1485 RECT r = *rect;
1486 WND *wndPtr = WIN_FindWndPtr( hwnd );
1487 char buffer[256];
1488 HPEN hPrevPen;
1490 if (wndPtr->flags & WIN_MANAGED)
1492 WIN_ReleaseWndPtr(wndPtr);
1493 return;
1495 WIN_ReleaseWndPtr(wndPtr);
1497 hPrevPen = SelectObject( hdc, GetSysColorPen(COLOR_3DFACE) );
1498 MoveToEx( hdc, r.left, r.bottom - 1, NULL );
1499 LineTo( hdc, r.right, r.bottom - 1 );
1500 SelectObject( hdc, hPrevPen );
1501 r.bottom--;
1503 FillRect( hdc, &r, GetSysColorBrush(active ? COLOR_ACTIVECAPTION :
1504 COLOR_INACTIVECAPTION) );
1506 if (!hbitmapClose) {
1507 if (!(hbitmapClose = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_CLOSE) )))
1508 return;
1509 hbitmapCloseD = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_CLOSED));
1510 hbitmapMinimize = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_REDUCE) );
1511 hbitmapMinimizeD = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_REDUCED) );
1512 hbitmapMaximize = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_ZOOM) );
1513 hbitmapMaximizeD = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_ZOOMD) );
1514 hbitmapRestore = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_RESTORE) );
1515 hbitmapRestoreD = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_RESTORED) );
1518 if ((style & WS_SYSMENU) && !(exStyle & WS_EX_TOOLWINDOW)) {
1519 if (NC_DrawSysButton95 (hwnd, hdc, FALSE))
1520 r.left += GetSystemMetrics(SM_CYCAPTION) - 1;
1522 if (style & WS_SYSMENU) {
1523 NC_DrawCloseButton95 (hwnd, hdc, FALSE);
1524 r.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
1526 if (style & WS_MAXIMIZEBOX) {
1527 NC_DrawMaxButton95( hwnd, hdc, FALSE );
1528 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1530 if (style & WS_MINIMIZEBOX) {
1531 NC_DrawMinButton95( hwnd, hdc, FALSE );
1532 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1535 if (GetWindowTextA( hwnd, buffer, sizeof(buffer) )) {
1536 NONCLIENTMETRICSA nclm;
1537 HFONT hFont, hOldFont;
1538 nclm.cbSize = sizeof(NONCLIENTMETRICSA);
1539 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
1540 if (exStyle & WS_EX_TOOLWINDOW)
1541 hFont = CreateFontIndirectA (&nclm.lfSmCaptionFont);
1542 else
1543 hFont = CreateFontIndirectA (&nclm.lfCaptionFont);
1544 hOldFont = SelectObject (hdc, hFont);
1545 if (active) SetTextColor( hdc, GetSysColor( COLOR_CAPTIONTEXT ) );
1546 else SetTextColor( hdc, GetSysColor( COLOR_INACTIVECAPTIONTEXT ) );
1547 SetBkMode( hdc, TRANSPARENT );
1548 r.left += 2;
1549 DrawTextA( hdc, buffer, -1, &r,
1550 DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT );
1551 DeleteObject (SelectObject (hdc, hOldFont));
1557 /***********************************************************************
1558 * NC_DoNCPaint
1560 * Paint the non-client area. clip is currently unused.
1562 static void NC_DoNCPaint( WND* wndPtr, HRGN clip, BOOL suppress_menupaint )
1564 HDC hdc;
1565 RECT rect;
1566 BOOL active;
1567 HWND hwnd = wndPtr->hwndSelf;
1569 if ( wndPtr->dwStyle & WS_MINIMIZE ||
1570 !WIN_IsWindowDrawable( wndPtr, 0 )) return; /* Nothing to do */
1572 active = wndPtr->flags & WIN_NCACTIVATED;
1574 TRACE_(nonclient)("%04x %d\n", hwnd, active );
1576 if (!(hdc = GetDCEx( hwnd, (clip > 1) ? clip : 0, DCX_USESTYLE | DCX_WINDOW |
1577 ((clip > 1) ? (DCX_INTERSECTRGN | DCX_KEEPCLIPRGN): 0) ))) return;
1579 if (ExcludeVisRect16( hdc, wndPtr->rectClient.left-wndPtr->rectWindow.left,
1580 wndPtr->rectClient.top-wndPtr->rectWindow.top,
1581 wndPtr->rectClient.right-wndPtr->rectWindow.left,
1582 wndPtr->rectClient.bottom-wndPtr->rectWindow.top )
1583 == NULLREGION)
1585 ReleaseDC( hwnd, hdc );
1586 return;
1589 rect.top = rect.left = 0;
1590 rect.right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
1591 rect.bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
1593 SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
1595 if (!(wndPtr->flags & WIN_MANAGED))
1597 if (HAS_ANYFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
1599 SelectObject( hdc, GetStockObject(NULL_BRUSH) );
1600 Rectangle( hdc, 0, 0, rect.right, rect.bottom );
1601 InflateRect( &rect, -1, -1 );
1604 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
1605 NC_DrawFrame(hdc, &rect, FALSE, active );
1606 else if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
1607 NC_DrawFrame( hdc, &rect, TRUE, active );
1609 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
1611 RECT r = rect;
1612 r.bottom = rect.top + GetSystemMetrics(SM_CYSIZE);
1613 rect.top += GetSystemMetrics(SM_CYSIZE) + GetSystemMetrics(SM_CYBORDER);
1614 NC_DrawCaption( hdc, &r, hwnd, wndPtr->dwStyle, active );
1618 if (HAS_MENU(wndPtr))
1620 RECT r = rect;
1621 r.bottom = rect.top + GetSystemMetrics(SM_CYMENU); /* default height */
1622 rect.top += MENU_DrawMenuBar( hdc, &r, hwnd, suppress_menupaint );
1625 /* Draw the scroll-bars */
1627 if (wndPtr->dwStyle & WS_VSCROLL)
1628 SCROLL_DrawScrollBar( hwnd, hdc, SB_VERT, TRUE, TRUE );
1629 if (wndPtr->dwStyle & WS_HSCROLL)
1630 SCROLL_DrawScrollBar( hwnd, hdc, SB_HORZ, TRUE, TRUE );
1632 /* Draw the "size-box" */
1634 if ((wndPtr->dwStyle & WS_VSCROLL) && (wndPtr->dwStyle & WS_HSCROLL))
1636 RECT r = rect;
1637 r.left = r.right - GetSystemMetrics(SM_CXVSCROLL) + 1;
1638 r.top = r.bottom - GetSystemMetrics(SM_CYHSCROLL) + 1;
1639 if(wndPtr->dwStyle & WS_BORDER) {
1640 r.left++;
1641 r.top++;
1643 FillRect( hdc, &r, GetSysColorBrush(COLOR_SCROLLBAR) );
1646 ReleaseDC( hwnd, hdc );
1650 /******************************************************************************
1652 * void NC_DoNCPaint95(
1653 * WND *wndPtr,
1654 * HRGN32 clip,
1655 * BOOL32 suppress_menupaint )
1657 * Paint the non-client area for Win95 windows. The clip region is
1658 * currently ignored.
1660 * Bugs
1661 * grep -E -A10 -B5 \(95\)\|\(Bugs\)\|\(FIXME\) windows/nonclient.c \
1662 * misc/tweak.c controls/menu.c # :-)
1664 * Revision history
1665 * 03-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1666 * Original implementation
1667 * 10-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
1668 * Fixed some bugs.
1669 * 29-Jun-1999 Ove Kåven (ovek@arcticnet.no)
1670 * Streamlined window style checks.
1672 *****************************************************************************/
1674 static void NC_DoNCPaint95(
1675 WND *wndPtr,
1676 HRGN clip,
1677 BOOL suppress_menupaint )
1679 HDC hdc;
1680 RECT rfuzz, rect, rectClip;
1681 BOOL active;
1682 HWND hwnd = wndPtr->hwndSelf;
1684 if ( wndPtr->dwStyle & WS_MINIMIZE ||
1685 !WIN_IsWindowDrawable( wndPtr, 0 )) return; /* Nothing to do */
1687 active = wndPtr->flags & WIN_NCACTIVATED;
1689 TRACE_(nonclient)("%04x %d\n", hwnd, active );
1691 /* MSDN docs are pretty idiotic here, they say app CAN use clipRgn in the call to
1692 * GetDCEx implying that it is allowed not to use it either. However, the suggested
1693 * GetDCEx( , DCX_WINDOW | DCX_INTERSECTRGN) will cause clipRgn to be deleted
1694 * after ReleaseDC(). Now, how is the "system" supposed to tell what happened?
1697 if (!(hdc = GetDCEx( hwnd, (clip > 1) ? clip : 0, DCX_USESTYLE | DCX_WINDOW |
1698 ((clip > 1) ?(DCX_INTERSECTRGN | DCX_KEEPCLIPRGN) : 0) ))) return;
1701 if (ExcludeVisRect16( hdc, wndPtr->rectClient.left-wndPtr->rectWindow.left,
1702 wndPtr->rectClient.top-wndPtr->rectWindow.top,
1703 wndPtr->rectClient.right-wndPtr->rectWindow.left,
1704 wndPtr->rectClient.bottom-wndPtr->rectWindow.top )
1705 == NULLREGION)
1707 ReleaseDC( hwnd, hdc );
1708 return;
1711 rect.top = rect.left = 0;
1712 rect.right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
1713 rect.bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
1715 if( clip > 1 )
1716 GetRgnBox( clip, &rectClip );
1717 else
1719 clip = 0;
1720 rectClip = rect;
1723 SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
1725 if(!(wndPtr->flags & WIN_MANAGED)) {
1726 if (HAS_BIGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle)) {
1727 DrawEdge (hdc, &rect, EDGE_RAISED, BF_RECT | BF_ADJUST);
1729 if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
1730 NC_DrawFrame95(hdc, &rect, FALSE, active );
1731 else if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
1732 NC_DrawFrame95( hdc, &rect, TRUE, active );
1733 else if (HAS_THINFRAME( wndPtr->dwStyle )) {
1734 SelectObject( hdc, GetStockObject(NULL_BRUSH) );
1735 Rectangle( hdc, 0, 0, rect.right, rect.bottom );
1738 if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
1740 RECT r = rect;
1741 if (wndPtr->dwExStyle & WS_EX_TOOLWINDOW) {
1742 r.bottom = rect.top + GetSystemMetrics(SM_CYSMCAPTION);
1743 rect.top += GetSystemMetrics(SM_CYSMCAPTION);
1745 else {
1746 r.bottom = rect.top + GetSystemMetrics(SM_CYCAPTION);
1747 rect.top += GetSystemMetrics(SM_CYCAPTION);
1749 if( !clip || IntersectRect( &rfuzz, &r, &rectClip ) )
1750 NC_DrawCaption95 (hdc, &r, hwnd, wndPtr->dwStyle,
1751 wndPtr->dwExStyle, active);
1755 if (HAS_MENU(wndPtr))
1757 RECT r = rect;
1758 r.bottom = rect.top + GetSystemMetrics(SM_CYMENU);
1760 TRACE_(nonclient)("Calling DrawMenuBar with "
1761 "rect (%d, %d)-(%d, %d)\n", r.left, r.top,
1762 r.right, r.bottom);
1764 rect.top += MENU_DrawMenuBar( hdc, &r, hwnd, suppress_menupaint ) + 1;
1767 TRACE_(nonclient)("After MenuBar, rect is (%d, %d)-(%d, %d).\n",
1768 rect.left, rect.top, rect.right, rect.bottom );
1770 if (wndPtr->dwExStyle & WS_EX_CLIENTEDGE)
1771 DrawEdge (hdc, &rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
1773 if (wndPtr->dwExStyle & WS_EX_STATICEDGE)
1774 DrawEdge (hdc, &rect, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
1776 /* Draw the scroll-bars */
1778 if (wndPtr->dwStyle & WS_VSCROLL)
1779 SCROLL_DrawScrollBar( hwnd, hdc, SB_VERT, TRUE, TRUE );
1780 if (wndPtr->dwStyle & WS_HSCROLL)
1781 SCROLL_DrawScrollBar( hwnd, hdc, SB_HORZ, TRUE, TRUE );
1783 /* Draw the "size-box" */
1784 if ((wndPtr->dwStyle & WS_VSCROLL) && (wndPtr->dwStyle & WS_HSCROLL))
1786 RECT r = rect;
1787 r.left = r.right - GetSystemMetrics(SM_CXVSCROLL) + 1;
1788 r.top = r.bottom - GetSystemMetrics(SM_CYHSCROLL) + 1;
1789 FillRect( hdc, &r, GetSysColorBrush(COLOR_SCROLLBAR) );
1792 ReleaseDC( hwnd, hdc );
1798 /***********************************************************************
1799 * NC_HandleNCPaint
1801 * Handle a WM_NCPAINT message. Called from DefWindowProc().
1803 LONG NC_HandleNCPaint( HWND hwnd , HRGN clip)
1805 WND* wndPtr = WIN_FindWndPtr( hwnd );
1807 if( wndPtr && wndPtr->dwStyle & WS_VISIBLE )
1809 if( wndPtr->dwStyle & WS_MINIMIZE )
1810 WINPOS_RedrawIconTitle( hwnd );
1811 else if (TWEAK_WineLook == WIN31_LOOK)
1812 NC_DoNCPaint( wndPtr, clip, FALSE );
1813 else
1814 NC_DoNCPaint95( wndPtr, clip, FALSE );
1816 WIN_ReleaseWndPtr(wndPtr);
1817 return 0;
1821 /***********************************************************************
1822 * NC_HandleNCActivate
1824 * Handle a WM_NCACTIVATE message. Called from DefWindowProc().
1826 LONG NC_HandleNCActivate( WND *wndPtr, WPARAM16 wParam )
1828 WORD wStateChange;
1830 if( wParam ) wStateChange = !(wndPtr->flags & WIN_NCACTIVATED);
1831 else wStateChange = wndPtr->flags & WIN_NCACTIVATED;
1833 if( wStateChange )
1835 if (wParam) wndPtr->flags |= WIN_NCACTIVATED;
1836 else wndPtr->flags &= ~WIN_NCACTIVATED;
1838 if( wndPtr->dwStyle & WS_MINIMIZE )
1839 WINPOS_RedrawIconTitle( wndPtr->hwndSelf );
1840 else if (TWEAK_WineLook == WIN31_LOOK)
1841 NC_DoNCPaint( wndPtr, (HRGN)1, FALSE );
1842 else
1843 NC_DoNCPaint95( wndPtr, (HRGN)1, FALSE );
1845 return TRUE;
1849 /***********************************************************************
1850 * NC_HandleSetCursor
1852 * Handle a WM_SETCURSOR message. Called from DefWindowProc().
1854 LONG NC_HandleSetCursor( HWND hwnd, WPARAM16 wParam, LPARAM lParam )
1856 if (hwnd != (HWND)wParam) return 0; /* Don't set the cursor for child windows */
1858 switch(LOWORD(lParam))
1860 case HTERROR:
1862 WORD msg = HIWORD( lParam );
1863 if ((msg == WM_LBUTTONDOWN) || (msg == WM_MBUTTONDOWN) ||
1864 (msg == WM_RBUTTONDOWN))
1865 MessageBeep(0);
1867 break;
1869 case HTCLIENT:
1871 HICON16 hCursor = (HICON16) GetClassWord(hwnd, GCW_HCURSOR);
1872 if(hCursor) {
1873 SetCursor16(hCursor);
1874 return TRUE;
1876 return FALSE;
1879 case HTLEFT:
1880 case HTRIGHT:
1881 return (LONG)SetCursor16( LoadCursor16( 0, IDC_SIZEWE16 ) );
1883 case HTTOP:
1884 case HTBOTTOM:
1885 return (LONG)SetCursor16( LoadCursor16( 0, IDC_SIZENS16 ) );
1887 case HTTOPLEFT:
1888 case HTBOTTOMRIGHT:
1889 return (LONG)SetCursor16( LoadCursor16( 0, IDC_SIZENWSE16 ) );
1891 case HTTOPRIGHT:
1892 case HTBOTTOMLEFT:
1893 return (LONG)SetCursor16( LoadCursor16( 0, IDC_SIZENESW16 ) );
1896 /* Default cursor: arrow */
1897 return (LONG)SetCursor16( LoadCursor16( 0, IDC_ARROW16 ) );
1900 /***********************************************************************
1901 * NC_GetSysPopupPos
1903 BOOL NC_GetSysPopupPos( WND* wndPtr, RECT* rect )
1905 if( wndPtr->hSysMenu )
1907 if( wndPtr->dwStyle & WS_MINIMIZE )
1908 GetWindowRect( wndPtr->hwndSelf, rect );
1909 else
1911 if (TWEAK_WineLook == WIN31_LOOK)
1912 NC_GetInsideRect( wndPtr->hwndSelf, rect );
1913 else
1914 NC_GetInsideRect95( wndPtr->hwndSelf, rect );
1915 OffsetRect( rect, wndPtr->rectWindow.left, wndPtr->rectWindow.top);
1916 if (wndPtr->dwStyle & WS_CHILD)
1917 ClientToScreen( wndPtr->parent->hwndSelf, (POINT *)rect );
1918 if (TWEAK_WineLook == WIN31_LOOK) {
1919 rect->right = rect->left + GetSystemMetrics(SM_CXSIZE);
1920 rect->bottom = rect->top + GetSystemMetrics(SM_CYSIZE);
1922 else {
1923 rect->right = rect->left + GetSystemMetrics(SM_CYCAPTION) - 1;
1924 rect->bottom = rect->top + GetSystemMetrics(SM_CYCAPTION) - 1;
1927 return TRUE;
1929 return FALSE;
1932 /***********************************************************************
1933 * NC_StartSizeMove
1935 * Initialisation of a move or resize, when initiatied from a menu choice.
1936 * Return hit test code for caption or sizing border.
1938 static LONG NC_StartSizeMove( WND* wndPtr, WPARAM16 wParam,
1939 POINT16 *capturePoint )
1941 LONG hittest = 0;
1942 POINT16 pt;
1943 MSG msg;
1944 RECT rectWindow;
1946 GetWindowRect(wndPtr->hwndSelf,&rectWindow);
1948 if ((wParam & 0xfff0) == SC_MOVE)
1950 /* Move pointer at the center of the caption */
1951 RECT rect;
1952 if (TWEAK_WineLook == WIN31_LOOK)
1953 NC_GetInsideRect( wndPtr->hwndSelf, &rect );
1954 else
1955 NC_GetInsideRect95( wndPtr->hwndSelf, &rect );
1956 if (wndPtr->dwStyle & WS_SYSMENU)
1957 rect.left += GetSystemMetrics(SM_CXSIZE) + 1;
1958 if (wndPtr->dwStyle & WS_MINIMIZEBOX)
1959 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1960 if (wndPtr->dwStyle & WS_MAXIMIZEBOX)
1961 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1962 pt.x = rectWindow.left + (rect.right - rect.left) / 2;
1963 pt.y = rectWindow.top + rect.top + GetSystemMetrics(SM_CYSIZE)/2;
1964 hittest = HTCAPTION;
1965 *capturePoint = pt;
1967 else /* SC_SIZE */
1969 while(!hittest)
1971 MSG_InternalGetMessage( &msg, 0, 0, MSGF_SIZE, PM_REMOVE, FALSE );
1972 switch(msg.message)
1974 case WM_MOUSEMOVE:
1975 CONV_POINT32TO16(&msg.pt, &pt);
1976 hittest = NC_HandleNCHitTest( wndPtr->hwndSelf, pt );
1977 if ((hittest < HTLEFT) || (hittest > HTBOTTOMRIGHT))
1978 hittest = 0;
1979 break;
1981 case WM_LBUTTONUP:
1982 return 0;
1984 case WM_KEYDOWN:
1985 switch(msg.wParam)
1987 case VK_UP:
1988 hittest = HTTOP;
1989 pt.x =(rectWindow.left+rectWindow.right)/2;
1990 pt.y = rectWindow.top + GetSystemMetrics(SM_CYFRAME) / 2;
1991 break;
1992 case VK_DOWN:
1993 hittest = HTBOTTOM;
1994 pt.x =(rectWindow.left+rectWindow.right)/2;
1995 pt.y = rectWindow.bottom - GetSystemMetrics(SM_CYFRAME) / 2;
1996 break;
1997 case VK_LEFT:
1998 hittest = HTLEFT;
1999 pt.x = rectWindow.left + GetSystemMetrics(SM_CXFRAME) / 2;
2000 pt.y =(rectWindow.top+rectWindow.bottom)/2;
2001 break;
2002 case VK_RIGHT:
2003 hittest = HTRIGHT;
2004 pt.x = rectWindow.right - GetSystemMetrics(SM_CXFRAME) / 2;
2005 pt.y =(rectWindow.top+rectWindow.bottom)/2;
2006 break;
2007 case VK_RETURN:
2008 case VK_ESCAPE: return 0;
2012 *capturePoint = pt;
2014 SetCursorPos( pt.x, pt.y );
2015 NC_HandleSetCursor( wndPtr->hwndSelf,
2016 wndPtr->hwndSelf, MAKELONG( hittest, WM_MOUSEMOVE ));
2017 return hittest;
2021 /***********************************************************************
2022 * NC_DoSizeMove
2024 * Perform SC_MOVE and SC_SIZE commands. `
2026 static void NC_DoSizeMove( HWND hwnd, WORD wParam )
2028 MSG msg;
2029 RECT sizingRect, mouseRect;
2030 HDC hdc;
2031 LONG hittest = (LONG)(wParam & 0x0f);
2032 HCURSOR16 hDragCursor = 0, hOldCursor = 0;
2033 POINT minTrack, maxTrack;
2034 POINT16 capturePoint, pt;
2035 WND * wndPtr = WIN_FindWndPtr( hwnd );
2036 BOOL thickframe = HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle );
2037 BOOL iconic = wndPtr->dwStyle & WS_MINIMIZE;
2038 BOOL moved = FALSE;
2039 DWORD dwPoint = GetMessagePos ();
2041 capturePoint = pt = *(POINT16*)&dwPoint;
2043 if (IsZoomed(hwnd) || !IsWindowVisible(hwnd) ||
2044 (wndPtr->flags & WIN_MANAGED)) goto END;
2046 if ((wParam & 0xfff0) == SC_MOVE)
2048 if (!(wndPtr->dwStyle & WS_CAPTION)) goto END;
2049 if (!hittest)
2050 hittest = NC_StartSizeMove( wndPtr, wParam, &capturePoint );
2051 if (!hittest) goto END;
2053 else /* SC_SIZE */
2055 if (!thickframe) goto END;
2056 if ( hittest && hittest != HTSYSMENU ) hittest += 2;
2057 else
2059 SetCapture(hwnd);
2060 hittest = NC_StartSizeMove( wndPtr, wParam, &capturePoint );
2061 if (!hittest)
2063 ReleaseCapture();
2064 goto END;
2069 /* Get min/max info */
2071 WINPOS_GetMinMaxInfo( wndPtr, NULL, NULL, &minTrack, &maxTrack );
2072 sizingRect = wndPtr->rectWindow;
2073 if (wndPtr->dwStyle & WS_CHILD)
2074 GetClientRect( wndPtr->parent->hwndSelf, &mouseRect );
2075 else
2076 SetRect(&mouseRect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
2077 if (ON_LEFT_BORDER(hittest))
2079 mouseRect.left = MAX( mouseRect.left, sizingRect.right-maxTrack.x );
2080 mouseRect.right = MIN( mouseRect.right, sizingRect.right-minTrack.x );
2082 else if (ON_RIGHT_BORDER(hittest))
2084 mouseRect.left = MAX( mouseRect.left, sizingRect.left+minTrack.x );
2085 mouseRect.right = MIN( mouseRect.right, sizingRect.left+maxTrack.x );
2087 if (ON_TOP_BORDER(hittest))
2089 mouseRect.top = MAX( mouseRect.top, sizingRect.bottom-maxTrack.y );
2090 mouseRect.bottom = MIN( mouseRect.bottom,sizingRect.bottom-minTrack.y);
2092 else if (ON_BOTTOM_BORDER(hittest))
2094 mouseRect.top = MAX( mouseRect.top, sizingRect.top+minTrack.y );
2095 mouseRect.bottom = MIN( mouseRect.bottom, sizingRect.top+maxTrack.y );
2097 if (wndPtr->dwStyle & WS_CHILD)
2099 MapWindowPoints( wndPtr->parent->hwndSelf, 0,
2100 (LPPOINT)&mouseRect, 2 );
2102 SendMessage16( hwnd, WM_ENTERSIZEMOVE, 0, 0 );
2104 if (GetCapture() != hwnd) SetCapture( hwnd );
2106 if (wndPtr->dwStyle & WS_CHILD)
2108 /* Retrieve a default cache DC (without using the window style) */
2109 hdc = GetDCEx( wndPtr->parent->hwndSelf, 0, DCX_CACHE );
2111 else
2112 { /* Grab the server only when moving top-level windows without desktop */
2113 hdc = GetDC( 0 );
2116 wndPtr->pDriver->pPreSizeMove(wndPtr);
2118 if( iconic ) /* create a cursor for dragging */
2120 HICON16 hIcon = GetClassWord(wndPtr->hwndSelf, GCW_HICON);
2121 if(!hIcon) hIcon = (HICON16) SendMessage16( hwnd, WM_QUERYDRAGICON, 0, 0L);
2122 if( hIcon ) hDragCursor = CURSORICON_IconToCursor( hIcon, TRUE );
2123 if( !hDragCursor ) iconic = FALSE;
2126 if( !iconic ) NC_DrawMovingFrame( hdc, &sizingRect, thickframe );
2128 while(1)
2130 int dx = 0, dy = 0;
2132 MSG_InternalGetMessage( &msg, 0, 0, MSGF_SIZE, PM_REMOVE, FALSE );
2134 /* Exit on button-up, Return, or Esc */
2135 if ((msg.message == WM_LBUTTONUP) ||
2136 ((msg.message == WM_KEYDOWN) &&
2137 ((msg.wParam == VK_RETURN) || (msg.wParam == VK_ESCAPE)))) break;
2139 if ((msg.message != WM_KEYDOWN) && (msg.message != WM_MOUSEMOVE))
2140 continue; /* We are not interested in other messages */
2142 dwPoint = GetMessagePos ();
2143 pt = *(POINT16*)&dwPoint;
2145 if (msg.message == WM_KEYDOWN) switch(msg.wParam)
2147 case VK_UP: pt.y -= 8; break;
2148 case VK_DOWN: pt.y += 8; break;
2149 case VK_LEFT: pt.x -= 8; break;
2150 case VK_RIGHT: pt.x += 8; break;
2153 pt.x = MAX( pt.x, mouseRect.left );
2154 pt.x = MIN( pt.x, mouseRect.right );
2155 pt.y = MAX( pt.y, mouseRect.top );
2156 pt.y = MIN( pt.y, mouseRect.bottom );
2158 dx = pt.x - capturePoint.x;
2159 dy = pt.y - capturePoint.y;
2161 if (dx || dy)
2163 if( !moved )
2165 moved = TRUE;
2166 if( iconic ) /* ok, no system popup tracking */
2168 hOldCursor = SetCursor(hDragCursor);
2169 ShowCursor( TRUE );
2170 WINPOS_ShowIconTitle( wndPtr, FALSE );
2174 if (msg.message == WM_KEYDOWN) SetCursorPos( pt.x, pt.y );
2175 else
2177 RECT newRect = sizingRect;
2179 if (hittest == HTCAPTION) OffsetRect( &newRect, dx, dy );
2180 if (ON_LEFT_BORDER(hittest)) newRect.left += dx;
2181 else if (ON_RIGHT_BORDER(hittest)) newRect.right += dx;
2182 if (ON_TOP_BORDER(hittest)) newRect.top += dy;
2183 else if (ON_BOTTOM_BORDER(hittest)) newRect.bottom += dy;
2184 if( !iconic )
2186 NC_DrawMovingFrame( hdc, &sizingRect, thickframe );
2187 NC_DrawMovingFrame( hdc, &newRect, thickframe );
2189 capturePoint = pt;
2190 sizingRect = newRect;
2195 ReleaseCapture();
2196 if( iconic )
2198 if( moved ) /* restore cursors, show icon title later on */
2200 ShowCursor( FALSE );
2201 SetCursor( hOldCursor );
2203 DestroyCursor( hDragCursor );
2205 else
2206 NC_DrawMovingFrame( hdc, &sizingRect, thickframe );
2208 if (wndPtr->dwStyle & WS_CHILD)
2209 ReleaseDC( wndPtr->parent->hwndSelf, hdc );
2210 else
2212 ReleaseDC( 0, hdc );
2215 wndPtr->pDriver->pPostSizeMove(wndPtr);
2217 if (HOOK_IsHooked( WH_CBT ))
2219 RECT16* pr = SEGPTR_NEW(RECT16);
2220 if( pr )
2222 CONV_RECT32TO16( &sizingRect, pr );
2223 if( HOOK_CallHooks16( WH_CBT, HCBT_MOVESIZE, hwnd,
2224 (LPARAM)SEGPTR_GET(pr)) )
2225 sizingRect = wndPtr->rectWindow;
2226 else
2227 CONV_RECT16TO32( pr, &sizingRect );
2228 SEGPTR_FREE(pr);
2231 SendMessage16( hwnd, WM_EXITSIZEMOVE, 0, 0 );
2232 SendMessage16( hwnd, WM_SETVISIBLE, !IsIconic16(hwnd), 0L);
2234 /* window moved or resized */
2235 if (moved)
2237 /* if the moving/resizing isn't canceled call SetWindowPos
2238 * with the new position or the new size of the window
2240 if (!((msg.message == WM_KEYDOWN) && (msg.wParam == VK_ESCAPE)) )
2242 /* NOTE: SWP_NOACTIVATE prevents document window activation in Word 6 */
2243 SetWindowPos( hwnd, 0, sizingRect.left, sizingRect.top,
2244 sizingRect.right - sizingRect.left,
2245 sizingRect.bottom - sizingRect.top,
2246 ( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 );
2248 else
2250 /* if the moving/resizing is canceled and the window is not active
2251 * call SetWindowPos to activate and to show this window
2253 if (GetActiveWindow() != hwnd)
2254 SetWindowPos( hwnd, 0, 0, 0,0,0,SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
2257 else
2259 /* show the window if it is not moved/resized and it is not active */
2260 if (GetActiveWindow() != hwnd)
2261 SetWindowPos( hwnd, 0, 0, 0,0,0,SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
2264 if( IsWindow(hwnd) )
2265 if( wndPtr->dwStyle & WS_MINIMIZE )
2267 /* Single click brings up the system menu when iconized */
2269 if( !moved )
2271 if( wndPtr->dwStyle & WS_SYSMENU )
2272 SendMessage16( hwnd, WM_SYSCOMMAND,
2273 SC_MOUSEMENU + HTSYSMENU, *((LPARAM*)&pt));
2275 else WINPOS_ShowIconTitle( wndPtr, TRUE );
2278 END:
2279 WIN_ReleaseWndPtr(wndPtr);
2283 /***********************************************************************
2284 * NC_TrackMinMaxBox
2286 * Track a mouse button press on the minimize or maximize box.
2288 static void NC_TrackMinMaxBox( HWND hwnd, WORD wParam )
2290 MSG msg;
2291 POINT16 pt16;
2292 HDC hdc = GetWindowDC( hwnd );
2293 BOOL pressed = TRUE;
2294 void (*paintButton)(HWND, HDC16, BOOL);
2296 SetCapture( hwnd );
2297 if (wParam == HTMINBUTTON)
2298 paintButton =
2299 (TWEAK_WineLook == WIN31_LOOK) ? &NC_DrawMinButton : &NC_DrawMinButton95;
2300 else
2301 paintButton =
2302 (TWEAK_WineLook == WIN31_LOOK) ? &NC_DrawMaxButton : &NC_DrawMaxButton95;
2304 (*paintButton)( hwnd, hdc, TRUE );
2308 BOOL oldstate = pressed;
2309 MSG_InternalGetMessage( &msg, 0, 0, 0, PM_REMOVE, FALSE );
2310 CONV_POINT32TO16( &msg.pt, &pt16 );
2312 pressed = (NC_HandleNCHitTest( hwnd, pt16 ) == wParam);
2313 if (pressed != oldstate)
2314 (*paintButton)( hwnd, hdc, pressed );
2315 } while (msg.message != WM_LBUTTONUP);
2317 (*paintButton)( hwnd, hdc, FALSE );
2319 ReleaseCapture();
2320 ReleaseDC( hwnd, hdc );
2321 if (!pressed) return;
2323 if (wParam == HTMINBUTTON)
2324 SendMessage16( hwnd, WM_SYSCOMMAND, SC_MINIMIZE, *(LONG*)&pt16 );
2325 else
2326 SendMessage16( hwnd, WM_SYSCOMMAND,
2327 IsZoomed(hwnd) ? SC_RESTORE:SC_MAXIMIZE, *(LONG*)&pt16 );
2331 /***********************************************************************
2332 * NC_TrackCloseButton95
2334 * Track a mouse button press on the Win95 close button.
2336 static void
2337 NC_TrackCloseButton95 (HWND hwnd, WORD wParam)
2339 MSG msg;
2340 POINT16 pt16;
2341 HDC hdc = GetWindowDC( hwnd );
2342 BOOL pressed = TRUE;
2344 SetCapture( hwnd );
2346 NC_DrawCloseButton95 (hwnd, hdc, TRUE);
2350 BOOL oldstate = pressed;
2351 MSG_InternalGetMessage( &msg, 0, 0, 0, PM_REMOVE, FALSE );
2352 CONV_POINT32TO16( &msg.pt, &pt16 );
2354 pressed = (NC_HandleNCHitTest( hwnd, pt16 ) == wParam);
2355 if (pressed != oldstate)
2356 NC_DrawCloseButton95 (hwnd, hdc, pressed);
2357 } while (msg.message != WM_LBUTTONUP);
2359 NC_DrawCloseButton95 (hwnd, hdc, FALSE);
2361 ReleaseCapture();
2362 ReleaseDC( hwnd, hdc );
2363 if (!pressed) return;
2365 SendMessage16( hwnd, WM_SYSCOMMAND, SC_CLOSE, *(LONG*)&pt16 );
2369 /***********************************************************************
2370 * NC_TrackScrollBar
2372 * Track a mouse button press on the horizontal or vertical scroll-bar.
2374 static void NC_TrackScrollBar( HWND hwnd, WPARAM wParam, POINT pt )
2376 MSG16 *msg;
2377 INT scrollbar;
2378 WND *wndPtr = WIN_FindWndPtr( hwnd );
2380 if ((wParam & 0xfff0) == SC_HSCROLL)
2382 if ((wParam & 0x0f) != HTHSCROLL) goto END;
2383 scrollbar = SB_HORZ;
2385 else /* SC_VSCROLL */
2387 if ((wParam & 0x0f) != HTVSCROLL) goto END;
2388 scrollbar = SB_VERT;
2391 if (!(msg = SEGPTR_NEW(MSG16))) goto END;
2392 pt.x -= wndPtr->rectWindow.left;
2393 pt.y -= wndPtr->rectWindow.top;
2394 SetCapture( hwnd );
2395 SCROLL_HandleScrollEvent( hwnd, scrollbar, WM_LBUTTONDOWN, pt );
2399 GetMessage16( SEGPTR_GET(msg), 0, 0, 0 );
2400 switch(msg->message)
2402 case WM_LBUTTONUP:
2403 case WM_MOUSEMOVE:
2404 case WM_SYSTIMER:
2405 pt.x = LOWORD(msg->lParam) + wndPtr->rectClient.left -
2406 wndPtr->rectWindow.left;
2407 pt.y = HIWORD(msg->lParam) + wndPtr->rectClient.top -
2408 wndPtr->rectWindow.top;
2409 SCROLL_HandleScrollEvent( hwnd, scrollbar, msg->message, pt );
2410 break;
2411 default:
2412 TranslateMessage16( msg );
2413 DispatchMessage16( msg );
2414 break;
2416 if (!IsWindow( hwnd ))
2418 ReleaseCapture();
2419 break;
2421 } while (msg->message != WM_LBUTTONUP);
2422 SEGPTR_FREE(msg);
2423 END:
2424 WIN_ReleaseWndPtr(wndPtr);
2427 /***********************************************************************
2428 * NC_HandleNCLButtonDown
2430 * Handle a WM_NCLBUTTONDOWN message. Called from DefWindowProc().
2432 LONG NC_HandleNCLButtonDown( WND* pWnd, WPARAM16 wParam, LPARAM lParam )
2434 HWND hwnd = pWnd->hwndSelf;
2436 switch(wParam) /* Hit test */
2438 case HTCAPTION:
2439 hwnd = WIN_GetTopParent(hwnd);
2441 if( WINPOS_SetActiveWindow(hwnd, TRUE, TRUE) || (GetActiveWindow() == hwnd) )
2442 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, lParam );
2443 break;
2445 case HTSYSMENU:
2446 if( pWnd->dwStyle & WS_SYSMENU )
2448 if( !(pWnd->dwStyle & WS_MINIMIZE) )
2450 HDC hDC = GetWindowDC(hwnd);
2451 if (TWEAK_WineLook == WIN31_LOOK)
2452 NC_DrawSysButton( hwnd, hDC, TRUE );
2453 else
2454 NC_DrawSysButton95( hwnd, hDC, TRUE );
2455 ReleaseDC( hwnd, hDC );
2457 SendMessage16( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU + HTSYSMENU, lParam );
2459 break;
2461 case HTMENU:
2462 SendMessage16( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU, lParam );
2463 break;
2465 case HTHSCROLL:
2466 SendMessage16( hwnd, WM_SYSCOMMAND, SC_HSCROLL + HTHSCROLL, lParam );
2467 break;
2469 case HTVSCROLL:
2470 SendMessage16( hwnd, WM_SYSCOMMAND, SC_VSCROLL + HTVSCROLL, lParam );
2471 break;
2473 case HTMINBUTTON:
2474 case HTMAXBUTTON:
2475 NC_TrackMinMaxBox( hwnd, wParam );
2476 break;
2478 case HTCLOSE:
2479 if (TWEAK_WineLook >= WIN95_LOOK)
2480 NC_TrackCloseButton95 (hwnd, wParam);
2481 break;
2483 case HTLEFT:
2484 case HTRIGHT:
2485 case HTTOP:
2486 case HTTOPLEFT:
2487 case HTTOPRIGHT:
2488 case HTBOTTOM:
2489 case HTBOTTOMLEFT:
2490 case HTBOTTOMRIGHT:
2491 /* make sure hittest fits into 0xf and doesn't overlap with HTSYSMENU */
2492 SendMessage16( hwnd, WM_SYSCOMMAND, SC_SIZE + wParam - 2, lParam);
2493 break;
2495 case HTBORDER:
2496 break;
2498 return 0;
2502 /***********************************************************************
2503 * NC_HandleNCLButtonDblClk
2505 * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc().
2507 LONG NC_HandleNCLButtonDblClk( WND *pWnd, WPARAM16 wParam, LPARAM lParam )
2510 * if this is an icon, send a restore since we are handling
2511 * a double click
2513 if (pWnd->dwStyle & WS_MINIMIZE)
2515 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND, SC_RESTORE, lParam );
2516 return 0;
2519 switch(wParam) /* Hit test */
2521 case HTCAPTION:
2522 /* stop processing if WS_MAXIMIZEBOX is missing */
2523 if (pWnd->dwStyle & WS_MAXIMIZEBOX)
2524 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND,
2525 (pWnd->dwStyle & WS_MAXIMIZE) ? SC_RESTORE : SC_MAXIMIZE,
2526 lParam );
2527 break;
2529 case HTSYSMENU:
2530 if (!(GetClassWord(pWnd->hwndSelf, GCW_STYLE) & CS_NOCLOSE))
2531 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND, SC_CLOSE, lParam );
2532 break;
2534 case HTHSCROLL:
2535 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND, SC_HSCROLL + HTHSCROLL,
2536 lParam );
2537 break;
2539 case HTVSCROLL:
2540 SendMessage16( pWnd->hwndSelf, WM_SYSCOMMAND, SC_VSCROLL + HTVSCROLL,
2541 lParam );
2542 break;
2544 return 0;
2548 /***********************************************************************
2549 * NC_HandleSysCommand
2551 * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
2553 LONG NC_HandleSysCommand( HWND hwnd, WPARAM16 wParam, POINT16 pt )
2555 WND *wndPtr = WIN_FindWndPtr( hwnd );
2556 POINT pt32;
2557 UINT16 uCommand = wParam & 0xFFF0;
2559 TRACE_(nonclient)("Handling WM_SYSCOMMAND %x %d,%d\n",
2560 wParam, pt.x, pt.y );
2562 if (wndPtr->dwStyle & WS_CHILD && uCommand != SC_KEYMENU )
2563 ScreenToClient16( wndPtr->parent->hwndSelf, &pt );
2565 switch (uCommand)
2567 case SC_SIZE:
2568 case SC_MOVE:
2569 NC_DoSizeMove( hwnd, wParam );
2570 break;
2572 case SC_MINIMIZE:
2573 ShowWindow( hwnd, SW_MINIMIZE );
2574 break;
2576 case SC_MAXIMIZE:
2577 ShowWindow( hwnd, SW_MAXIMIZE );
2578 break;
2580 case SC_RESTORE:
2581 ShowWindow( hwnd, SW_RESTORE );
2582 break;
2584 case SC_CLOSE:
2585 WIN_ReleaseWndPtr(wndPtr);
2586 return SendMessage16( hwnd, WM_CLOSE, 0, 0 );
2588 case SC_VSCROLL:
2589 case SC_HSCROLL:
2590 CONV_POINT16TO32( &pt, &pt32 );
2591 NC_TrackScrollBar( hwnd, wParam, pt32 );
2592 break;
2594 case SC_MOUSEMENU:
2595 CONV_POINT16TO32( &pt, &pt32 );
2596 MENU_TrackMouseMenuBar( wndPtr, wParam & 0x000F, pt32 );
2597 break;
2599 case SC_KEYMENU:
2600 MENU_TrackKbdMenuBar( wndPtr , wParam , pt.x );
2601 break;
2603 case SC_TASKLIST:
2604 WinExec( "taskman.exe", SW_SHOWNORMAL );
2605 break;
2607 case SC_SCREENSAVE:
2608 if (wParam == SC_ABOUTWINE)
2609 ShellAboutA(hwnd,"Wine", WINE_RELEASE_INFO, 0);
2610 else
2611 if (wParam == SC_PUTMARK)
2612 TRACE_(shell)("Mark requested by user\n");
2613 break;
2615 case SC_HOTKEY:
2616 case SC_ARRANGE:
2617 case SC_NEXTWINDOW:
2618 case SC_PREVWINDOW:
2619 FIXME_(nonclient)("unimplemented!\n");
2620 break;
2622 WIN_ReleaseWndPtr(wndPtr);
2623 return 0;