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"
30 int NC_CaptionLeftNudge
;
31 int NC_CaptionTopNudge
;
32 int NC_SysControlNudge
;
33 int NC_MaxControlNudge
;
34 int NC_MinControlNudge
;
35 UINT32 NC_CaptionTextFlags
;
36 HBRUSH32 NC_WinHighlight95
;
37 HBRUSH32 NC_WinShadow95
;
39 static HBITMAP16 hbitmapClose
= 0;
40 static HBITMAP16 hbitmapMinimize
= 0;
41 static HBITMAP16 hbitmapMinimizeD
= 0;
42 static HBITMAP16 hbitmapMaximize
= 0;
43 static HBITMAP16 hbitmapMaximizeD
= 0;
44 static HBITMAP16 hbitmapRestore
= 0;
45 static HBITMAP16 hbitmapRestoreD
= 0;
47 #define SC_ABOUTWINE (SC_SCREENSAVE+1)
49 /* Some useful macros */
50 #define HAS_DLGFRAME(style,exStyle) \
51 (((exStyle) & WS_EX_DLGMODALFRAME) || \
52 (((style) & WS_DLGFRAME) && !((style) & WS_BORDER)))
54 #define HAS_THICKFRAME(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
,
79 fprintf( stddeb
, "NC_AdjustRect was called in Win95 mode. Aiee! "
80 "Please report this.\n" );
82 if(style
& WS_ICONIC
) return;
83 /* Decide if the window will be managed (see CreateWindowEx) */
84 if (!(Options
.managed
&& !(style
& WS_CHILD
) &&
85 ((style
& (WS_DLGFRAME
| WS_THICKFRAME
)) ||
86 (exStyle
& WS_EX_DLGMODALFRAME
))))
88 if (HAS_DLGFRAME( style
, exStyle
))
89 InflateRect16(rect
, SYSMETRICS_CXDLGFRAME
, SYSMETRICS_CYDLGFRAME
);
92 if (HAS_THICKFRAME(style
))
93 InflateRect16( rect
, SYSMETRICS_CXFRAME
, SYSMETRICS_CYFRAME
);
94 if (style
& WS_BORDER
)
95 InflateRect16( rect
, SYSMETRICS_CXBORDER
, SYSMETRICS_CYBORDER
);
98 if ((style
& WS_CAPTION
) == WS_CAPTION
)
99 rect
->top
-= SYSMETRICS_CYCAPTION
- SYSMETRICS_CYBORDER
;
101 if (menu
) rect
->top
-= SYSMETRICS_CYMENU
+ SYSMETRICS_CYBORDER
;
103 if (style
& WS_VSCROLL
) rect
->right
+= SYSMETRICS_CXVSCROLL
- 1;
104 if (style
& WS_HSCROLL
) rect
->bottom
+= SYSMETRICS_CYHSCROLL
- 1;
108 /******************************************************************************
116 * Computes the size of the window based on the parameters of the client
120 * Most of this code is copied from NC_AdjustRect. It shouldn't be.
121 * There are some unique things about Win 95 that are being horribly
122 * neglected here. I don't know what they are, either. :-\
125 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
126 * Original cut & paste from NC_AdjustRect
128 *****************************************************************************/
130 static void NC_AdjustRect95( LPRECT16 rect
, DWORD style
, BOOL32 menu
,
133 if(style
& WS_ICONIC
) return;
135 /* Decide if the window will be managed (see CreateWindowEx) */
136 if (!(Options
.managed
&& !(style
& WS_CHILD
) &&
137 ((style
& (WS_DLGFRAME
| WS_THICKFRAME
)) ||
138 (exStyle
& WS_EX_DLGMODALFRAME
))))
140 if (HAS_DLGFRAME( style
, exStyle
))
141 InflateRect16(rect
, SYSMETRICS_CXDLGFRAME
, SYSMETRICS_CYDLGFRAME
);
144 if (HAS_THICKFRAME(style
))
145 InflateRect16( rect
, SYSMETRICS_CXFRAME
, SYSMETRICS_CYFRAME
);
146 if (style
& WS_BORDER
)
147 InflateRect16( rect
, SYSMETRICS_CXBORDER
, SYSMETRICS_CYBORDER
);
150 if ((style
& WS_CAPTION
) == WS_CAPTION
)
151 rect
->top
-= SYSMETRICS_CYCAPTION
- SYSMETRICS_CYBORDER
;
153 if (menu
) rect
->top
-= SYSMETRICS_CYMENU
+ SYSMETRICS_CYBORDER
+ 2;
154 else rect
->top
+= SYSMETRICS_CYBORDER
;
156 if (style
& WS_VSCROLL
) rect
->right
+= SYSMETRICS_CXVSCROLL
;
157 if (style
& WS_HSCROLL
) rect
->bottom
+= SYSMETRICS_CYHSCROLL
;
161 /***********************************************************************
162 * DrawCaptionTempA (USER32.)
165 DrawCaptionTemp32A(HWND32 hwnd
,HDC32 hdc
,LPRECT32 rect
,HFONT32 hfont
,DWORD x1
,LPCSTR str
,DWORD x2
) {
166 fprintf(stderr
,"DrawCaptionTempA(%08x,%08x,%p,%08x,%08lx,\"%s\",%08lx),tub!\n",
167 hwnd
,hdc
,rect
,hfont
,x1
,str
,x2
173 /***********************************************************************
174 * AdjustWindowRect16 (USER.102)
176 BOOL16 WINAPI
AdjustWindowRect16( LPRECT16 rect
, DWORD style
, BOOL16 menu
)
178 return AdjustWindowRectEx16( rect
, style
, menu
, 0 );
182 /***********************************************************************
183 * AdjustWindowRect32 (USER32.)
185 BOOL32 WINAPI
AdjustWindowRect32( LPRECT32 rect
, DWORD style
, BOOL32 menu
)
187 return AdjustWindowRectEx32( rect
, style
, menu
, 0 );
191 /***********************************************************************
192 * AdjustWindowRectEx16 (USER.454)
194 BOOL16 WINAPI
AdjustWindowRectEx16( LPRECT16 rect
, DWORD style
,
195 BOOL16 menu
, DWORD exStyle
)
197 /* Correct the window style */
199 if (!(style
& (WS_POPUP
| WS_CHILD
))) /* Overlapped window */
201 style
&= (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
| WS_CHILD
);
202 exStyle
&= WS_EX_DLGMODALFRAME
;
203 if (exStyle
& WS_EX_DLGMODALFRAME
) style
&= ~WS_THICKFRAME
;
205 dprintf_nonclient(stddeb
, "AdjustWindowRectEx: (%d,%d)-(%d,%d) %08lx %d %08lx\n",
206 rect
->left
, rect
->top
, rect
->right
, rect
->bottom
,
207 style
, menu
, exStyle
);
210 NC_AdjustRect95( rect
, style
, menu
, exStyle
);
212 NC_AdjustRect( rect
, style
, menu
, exStyle
);
218 /***********************************************************************
219 * AdjustWindowRectEx32 (USER32.)
221 BOOL32 WINAPI
AdjustWindowRectEx32( LPRECT32 rect
, DWORD style
,
222 BOOL32 menu
, DWORD exStyle
)
227 CONV_RECT32TO16( rect
, &rect16
);
228 ret
= AdjustWindowRectEx16( &rect16
, style
, (BOOL16
)menu
, exStyle
);
229 CONV_RECT16TO32( &rect16
, rect
);
234 /***********************************************************************
235 * NC_HandleNCCalcSize
237 * Handle a WM_NCCALCSIZE message. Called from DefWindowProc().
239 LONG
NC_HandleNCCalcSize( WND
*pWnd
, RECT32
*winRect
)
241 RECT16 tmpRect
= { 0, 0, 0, 0 };
244 if (pWnd
->class->style
& CS_VREDRAW
) result
|= WVR_VREDRAW
;
245 if (pWnd
->class->style
& CS_HREDRAW
) result
|= WVR_HREDRAW
;
247 if( !( pWnd
->dwStyle
& WS_MINIMIZE
) ) {
249 NC_AdjustRect95( &tmpRect
, pWnd
->dwStyle
, FALSE
, pWnd
->dwExStyle
);
251 NC_AdjustRect( &tmpRect
, pWnd
->dwStyle
, FALSE
, pWnd
->dwExStyle
);
253 winRect
->left
-= tmpRect
.left
;
254 winRect
->top
-= tmpRect
.top
;
255 winRect
->right
-= tmpRect
.right
;
256 winRect
->bottom
-= tmpRect
.bottom
;
258 if (HAS_MENU(pWnd
)) {
259 dprintf_nonclient( stddeb
, "NC_HandleNCCalcSize: Calling "
260 "GetMenuBarHeight with HWND 0x%x, width %d, "
261 "at (%d, %d).\n", pWnd
->hwndSelf
,
262 winRect
->right
- winRect
->left
,
263 -tmpRect
.left
, -tmpRect
.top
);
266 MENU_GetMenuBarHeight( pWnd
->hwndSelf
,
267 winRect
->right
- winRect
->left
,
268 -tmpRect
.left
, -tmpRect
.top
) + 1;
275 /***********************************************************************
278 * Get the 'inside' rectangle of a window, i.e. the whole window rectangle
279 * but without the borders (if any).
280 * The rectangle is in window coordinates (for drawing with GetWindowDC()).
282 * FIXME: A Win95 version of this function is needed.
284 static void NC_GetInsideRect( HWND32 hwnd
, RECT32
*rect
)
286 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
288 rect
->top
= rect
->left
= 0;
289 rect
->right
= wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
;
290 rect
->bottom
= wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
;
292 if ((wndPtr
->dwStyle
& WS_ICONIC
) || (wndPtr
->flags
& WIN_MANAGED
)) return;
294 /* Remove frame from rectangle */
295 if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
297 InflateRect32( rect
, -SYSMETRICS_CXDLGFRAME
, -SYSMETRICS_CYDLGFRAME
);
298 if (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
)
299 InflateRect32( rect
, -1, 0 );
303 if (HAS_THICKFRAME( wndPtr
->dwStyle
))
304 InflateRect32( rect
, -SYSMETRICS_CXFRAME
, -SYSMETRICS_CYFRAME
);
305 if (wndPtr
->dwStyle
& WS_BORDER
)
306 InflateRect32( rect
, -SYSMETRICS_CXBORDER
, -SYSMETRICS_CYBORDER
);
313 /***********************************************************************
316 * Handle a WM_NCHITTEST message. Called from DefWindowProc().
318 * FIXME: A Win95 version of this function is needed.
320 LONG
NC_HandleNCHitTest( HWND32 hwnd
, POINT16 pt
)
323 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
324 if (!wndPtr
) return HTERROR
;
326 dprintf_nonclient(stddeb
, "NC_HandleNCHitTest: hwnd=%04x pt=%d,%d\n",
329 GetWindowRect16( hwnd
, &rect
);
330 if (!PtInRect16( &rect
, pt
)) return HTNOWHERE
;
332 if (wndPtr
->dwStyle
& WS_MINIMIZE
) return HTCAPTION
;
334 if (!(wndPtr
->flags
& WIN_MANAGED
))
337 if (HAS_THICKFRAME( wndPtr
->dwStyle
))
339 InflateRect16( &rect
, -SYSMETRICS_CXFRAME
, -SYSMETRICS_CYFRAME
);
340 if (wndPtr
->dwStyle
& WS_BORDER
)
341 InflateRect16(&rect
,-SYSMETRICS_CXBORDER
,-SYSMETRICS_CYBORDER
);
342 if (!PtInRect16( &rect
, pt
))
344 /* Check top sizing border */
347 if (pt
.x
< rect
.left
+SYSMETRICS_CXSIZE
) return HTTOPLEFT
;
348 if (pt
.x
>= rect
.right
-SYSMETRICS_CXSIZE
) return HTTOPRIGHT
;
351 /* Check bottom sizing border */
352 if (pt
.y
>= rect
.bottom
)
354 if (pt
.x
< rect
.left
+SYSMETRICS_CXSIZE
) return HTBOTTOMLEFT
;
355 if (pt
.x
>= rect
.right
-SYSMETRICS_CXSIZE
) return HTBOTTOMRIGHT
;
358 /* Check left sizing border */
359 if (pt
.x
< rect
.left
)
361 if (pt
.y
< rect
.top
+SYSMETRICS_CYSIZE
) return HTTOPLEFT
;
362 if (pt
.y
>= rect
.bottom
-SYSMETRICS_CYSIZE
) return HTBOTTOMLEFT
;
365 /* Check right sizing border */
366 if (pt
.x
>= rect
.right
)
368 if (pt
.y
< rect
.top
+SYSMETRICS_CYSIZE
) return HTTOPRIGHT
;
369 if (pt
.y
>= rect
.bottom
-SYSMETRICS_CYSIZE
) return HTBOTTOMRIGHT
;
374 else /* No thick frame */
376 if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
377 InflateRect16(&rect
, -SYSMETRICS_CXDLGFRAME
, -SYSMETRICS_CYDLGFRAME
);
378 else if (wndPtr
->dwStyle
& WS_BORDER
)
379 InflateRect16(&rect
, -SYSMETRICS_CXBORDER
, -SYSMETRICS_CYBORDER
);
380 if (!PtInRect16( &rect
, pt
)) return HTBORDER
;
385 if ((wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
387 rect
.top
+= SYSMETRICS_CYCAPTION
- 1;
388 if (!PtInRect16( &rect
, pt
))
390 /* Check system menu */
391 if (wndPtr
->dwStyle
& WS_SYSMENU
)
392 rect
.left
+= SYSMETRICS_CXSIZE
;
393 if (pt
.x
<= rect
.left
) return HTSYSMENU
;
394 /* Check maximize box */
395 if (wndPtr
->dwStyle
& WS_MAXIMIZEBOX
)
396 rect
.right
-= SYSMETRICS_CXSIZE
+ 1;
397 if (pt
.x
>= rect
.right
) return HTMAXBUTTON
;
398 /* Check minimize box */
399 if (wndPtr
->dwStyle
& WS_MINIMIZEBOX
)
400 rect
.right
-= SYSMETRICS_CXSIZE
+ 1;
401 if (pt
.x
>= rect
.right
) return HTMINBUTTON
;
407 /* Check client area */
409 ScreenToClient16( hwnd
, &pt
);
410 GetClientRect16( hwnd
, &rect
);
411 if (PtInRect16( &rect
, pt
)) return HTCLIENT
;
413 /* Check vertical scroll bar */
415 if (wndPtr
->dwStyle
& WS_VSCROLL
)
417 rect
.right
+= SYSMETRICS_CXVSCROLL
;
418 if (PtInRect16( &rect
, pt
)) return HTVSCROLL
;
421 /* Check horizontal scroll bar */
423 if (wndPtr
->dwStyle
& WS_HSCROLL
)
425 rect
.bottom
+= SYSMETRICS_CYHSCROLL
;
426 if (PtInRect16( &rect
, pt
))
429 if ((wndPtr
->dwStyle
& WS_VSCROLL
) &&
430 (pt
.x
>= rect
.right
- SYSMETRICS_CXVSCROLL
))
438 if (HAS_MENU(wndPtr
))
440 if ((pt
.y
< 0) && (pt
.x
>= 0) && (pt
.x
< rect
.right
))
444 /* Should never get here */
449 /***********************************************************************
452 void NC_DrawSysButton( HWND32 hwnd
, HDC32 hdc
, BOOL32 down
)
457 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
459 if( !(wndPtr
->flags
& WIN_MANAGED
) )
461 NC_GetInsideRect( hwnd
, &rect
);
462 hdcMem
= CreateCompatibleDC32( hdc
);
463 hbitmap
= SelectObject32( hdcMem
, hbitmapClose
);
464 BitBlt32(hdc
, rect
.left
, rect
.top
, SYSMETRICS_CXSIZE
, SYSMETRICS_CYSIZE
,
465 hdcMem
, (wndPtr
->dwStyle
& WS_CHILD
) ? SYSMETRICS_CXSIZE
: 0, 0,
466 down
? NOTSRCCOPY
: SRCCOPY
);
467 SelectObject32( hdcMem
, hbitmap
);
468 DeleteDC32( hdcMem
);
473 /***********************************************************************
476 static void NC_DrawMaxButton( HWND32 hwnd
, HDC16 hdc
, BOOL32 down
)
479 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
481 if( !(wndPtr
->flags
& WIN_MANAGED
) )
483 NC_GetInsideRect( hwnd
, &rect
);
484 GRAPH_DrawBitmap( hdc
, (IsZoomed32(hwnd
)
485 ? (down
? hbitmapRestoreD
: hbitmapRestore
)
486 : (down
? hbitmapMaximizeD
: hbitmapMaximize
)),
487 rect
.right
- SYSMETRICS_CXSIZE
- 1, rect
.top
,
488 0, 0, SYSMETRICS_CXSIZE
+1, SYSMETRICS_CYSIZE
, FALSE
);
493 /***********************************************************************
496 static void NC_DrawMinButton( HWND32 hwnd
, HDC16 hdc
, BOOL32 down
)
499 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
501 if( !(wndPtr
->flags
& WIN_MANAGED
) )
503 NC_GetInsideRect( hwnd
, &rect
);
504 if (wndPtr
->dwStyle
& WS_MAXIMIZEBOX
) rect
.right
-= SYSMETRICS_CXSIZE
+1;
505 GRAPH_DrawBitmap( hdc
, (down
? hbitmapMinimizeD
: hbitmapMinimize
),
506 rect
.right
- SYSMETRICS_CXSIZE
- 1, rect
.top
,
507 0, 0, SYSMETRICS_CXSIZE
+1, SYSMETRICS_CYSIZE
, FALSE
);
512 /******************************************************************************
514 * void NC_DrawSysButton95(
519 * Draws a fake Win95 system button. Horribly broken. We should be drawing
520 * an icon, not the X. (This will require some thought)
523 * Plain and simply doesn't work. Fails miserably for child windows.
526 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
527 * Original implementation from NC_DrawSysButton source.
529 *****************************************************************************/
531 void NC_DrawSysButton95(
539 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
542 if( !(wndPtr
->flags
& WIN_MANAGED
) )
544 NC_GetInsideRect( hwnd
, &rect
);
545 hdcMem
= CreateCompatibleDC32( hdc
);
546 hbitmap
= SelectObject32( hdcMem
, hbitmapClose
);
547 if(GetBitmapDimensionEx32( hbitmapClose
, &bmsz
)) {
548 BitBlt32(hdc
, rect
.left
+ (sysMetrics
[SM_CXSIZE
] - bmsz
.cx
) / 2 +
550 rect
.top
+ (sysMetrics
[SM_CYSIZE
] - bmsz
.cy
- 1) / 2,
552 hdcMem
, 0, 0, down
? NOTSRCCOPY
: SRCCOPY
);
554 SelectObject32( hdcMem
, hbitmap
);
555 DeleteDC32( hdcMem
);
562 /******************************************************************************
564 * NC_DrawMaxButton95(
569 * Draws the maximize button for Win95 style windows.
572 * Many. Spacing might still be incorrect. Need to fit a close
573 * button between the max button and the edge. Draws the wrong thing
574 * (a Win31 up-down) when maximized. Should scale the image with the
575 * title bar. And more...
578 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
579 * Original implementation.
581 *****************************************************************************/
583 static void NC_DrawMaxButton95(
589 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
593 if( !(wndPtr
->flags
& WIN_MANAGED
) &&
594 GetBitmapDimensionEx32((bm
= IsZoomed32(hwnd
) ?
595 (down
? hbitmapRestoreD
: hbitmapRestore
) :
596 (down
? hbitmapMaximizeD
: hbitmapMaximize
)),
599 NC_GetInsideRect( hwnd
, &rect
);
601 GRAPH_DrawBitmap( hdc
, bm
,
602 rect
.right
+ NC_MaxControlNudge
-
603 (sysMetrics
[SM_CXSIZE
] + bmsz
.cx
) / 2,
604 rect
.top
+ (sysMetrics
[SM_CYSIZE
] - bmsz
.cy
- 1) / 2,
605 0, 0, bmsz
.cx
, bmsz
.cy
, FALSE
);
612 /******************************************************************************
614 * NC_DrawMinButton95(
619 * Draws the minimize button for Win95 style windows.
622 * Many. Spacing is still incorrect. Should scale the image with the
623 * title bar. And more...
626 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
627 * Original implementation.
629 *****************************************************************************/
631 static void NC_DrawMinButton95(
637 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
641 if( !(wndPtr
->flags
& WIN_MANAGED
) &&
642 GetBitmapDimensionEx32((bm
= down
? hbitmapMinimizeD
:
643 hbitmapMinimize
), &bmsz
)) {
645 NC_GetInsideRect( hwnd
, &rect
);
647 if (wndPtr
->dwStyle
& WS_MAXIMIZEBOX
)
648 rect
.right
+= -1 + NC_MaxControlNudge
-
649 (sysMetrics
[SM_CXSIZE
] + bmsz
.cx
) / 2;
651 GRAPH_DrawBitmap( hdc
, bm
, rect
.right
+ NC_MinControlNudge
-
652 (sysMetrics
[SM_CXSIZE
] + bmsz
.cx
) / 2,
653 rect
.top
+ (sysMetrics
[SM_CYSIZE
] - bmsz
.cy
- 1) / 2,
654 0, 0, bmsz
.cx
, bmsz
.cy
, FALSE
);
661 /***********************************************************************
664 * Draw a window frame inside the given rectangle, and update the rectangle.
665 * The correct pen for the frame must be selected in the DC.
667 static void NC_DrawFrame( HDC32 hdc
, RECT32
*rect
, BOOL32 dlgFrame
,
673 fprintf( stddeb
, "NC_DrawFrame was called in Win95 mode. Aiee! "
674 "Please report this.\n" );
678 width
= SYSMETRICS_CXDLGFRAME
- 1;
679 height
= SYSMETRICS_CYDLGFRAME
- 1;
680 SelectObject32( hdc
, GetSysColorBrush32(active
? COLOR_ACTIVECAPTION
:
681 COLOR_INACTIVECAPTION
) );
685 width
= SYSMETRICS_CXFRAME
- 1;
686 height
= SYSMETRICS_CYFRAME
- 1;
687 SelectObject32( hdc
, GetSysColorBrush32(active
? COLOR_ACTIVEBORDER
:
688 COLOR_INACTIVEBORDER
) );
692 PatBlt32( hdc
, rect
->left
, rect
->top
,
693 rect
->right
- rect
->left
, height
, PATCOPY
);
694 PatBlt32( hdc
, rect
->left
, rect
->top
,
695 width
, rect
->bottom
- rect
->top
, PATCOPY
);
696 PatBlt32( hdc
, rect
->left
, rect
->bottom
,
697 rect
->right
- rect
->left
, -height
, PATCOPY
);
698 PatBlt32( hdc
, rect
->right
, rect
->top
,
699 -width
, rect
->bottom
- rect
->top
, PATCOPY
);
703 InflateRect32( rect
, -width
, -height
);
709 /* Draw inner rectangle */
711 GRAPH_DrawRectangle( hdc
, rect
->left
+ width
,
713 rect
->right
- rect
->left
- 2*width
,
714 rect
->bottom
- rect
->top
- 2*height
,
717 /* Draw the decorations */
719 lpt
[4].x
= lpt
[0].x
= rect
->left
;
720 lpt
[5].x
= lpt
[1].x
= rect
->left
+ width
;
721 lpt
[6].x
= lpt
[2].x
= rect
->right
- 1;
722 lpt
[7].x
= lpt
[3].x
= rect
->right
- width
- 1;
724 lpt
[0].y
= lpt
[1].y
= lpt
[2].y
= lpt
[3].y
=
725 rect
->top
+ SYSMETRICS_CYFRAME
+ SYSMETRICS_CYSIZE
;
726 lpt
[4].y
= lpt
[5].y
= lpt
[6].y
= lpt
[7].y
=
727 rect
->bottom
- SYSMETRICS_CYFRAME
- SYSMETRICS_CYSIZE
;
729 lpt
[8].x
= lpt
[9].x
= lpt
[10].x
= lpt
[11].x
=
730 rect
->left
+ SYSMETRICS_CXFRAME
+ SYSMETRICS_CXSIZE
;
731 lpt
[12].x
= lpt
[13].x
= lpt
[14].x
= lpt
[15].x
=
732 rect
->right
- SYSMETRICS_CXFRAME
- SYSMETRICS_CYSIZE
;
734 lpt
[12].y
= lpt
[8].y
= rect
->top
;
735 lpt
[13].y
= lpt
[9].y
= rect
->top
+ height
;
736 lpt
[14].y
= lpt
[10].y
= rect
->bottom
- 1;
737 lpt
[15].y
= lpt
[11].y
= rect
->bottom
- height
- 1;
739 GRAPH_DrawLines( hdc
, lpt
, 8, (HPEN32
)0 ); /* 8 is the maximum */
740 InflateRect32( rect
, -width
- 1, -height
- 1 );
745 /******************************************************************************
747 * void NC_DrawFrame95(
753 * Draw a window frame inside the given rectangle, and update the rectangle.
754 * The correct pen for the frame must be selected in the DC.
757 * Many. First, just what IS a frame in Win95? Note that the 3D look
758 * on the outer edge is handled by NC_DoNCPaint95. As is the inner
759 * edge. The inner rectangle just inside the frame is handled by the
762 * In short, for most people, this function should be a nop (unless
763 * you LIKE thick borders in Win95/NT4.0 -- I've been working with
764 * them lately, but just to get this code right). Even so, it doesn't
765 * appear to be so. It's being worked on...
768 * 06-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
769 * Original implementation (based on NC_DrawFrame)
771 *****************************************************************************/
773 static void NC_DrawFrame95(
783 width
= SYSMETRICS_CXDLGFRAME
- 1;
784 height
= SYSMETRICS_CYDLGFRAME
- 1;
785 SelectObject32( hdc
, GetSysColorBrush32(active
? COLOR_ACTIVECAPTION
:
786 COLOR_INACTIVECAPTION
) );
790 width
= sysMetrics
[SM_CXFRAME
] - sysMetrics
[SM_CXEDGE
] - 1;
791 height
= sysMetrics
[SM_CYFRAME
] - sysMetrics
[SM_CYEDGE
] - 1;
792 SelectObject32( hdc
, GetSysColorBrush32(active
? COLOR_ACTIVEBORDER
:
793 COLOR_INACTIVEBORDER
) );
797 PatBlt32( hdc
, rect
->left
, rect
->top
,
798 rect
->right
- rect
->left
, height
, PATCOPY
);
799 PatBlt32( hdc
, rect
->left
, rect
->top
,
800 width
, rect
->bottom
- rect
->top
, PATCOPY
);
801 PatBlt32( hdc
, rect
->left
, rect
->bottom
,
802 rect
->right
- rect
->left
, -height
, PATCOPY
);
803 PatBlt32( hdc
, rect
->right
, rect
->top
,
804 -width
, rect
->bottom
- rect
->top
, PATCOPY
);
806 InflateRect32( rect
, -width
, -height
);
809 /* Draw inner rectangle */
810 GRAPH_DrawRectangle( hdc
, rect
->left
, rect
->top
,
811 rect
->right
- rect
->left
,
812 rect
->bottom
- rect
->top
,
815 InflateRect32( rect
, -1, -1 );
821 /***********************************************************************
824 * Draw the frame used when moving or resizing window.
826 * FIXME: This causes problems in Win95 mode. (why?)
828 static void NC_DrawMovingFrame( HDC32 hdc
, RECT32
*rect
, BOOL32 thickframe
)
833 CONV_RECT32TO16( rect
, &r16
);
834 FastWindowFrame( hdc
, &r16
, SYSMETRICS_CXFRAME
,
835 SYSMETRICS_CYFRAME
, PATINVERT
);
837 else DrawFocusRect32( hdc
, rect
);
841 /***********************************************************************
844 * Draw the window caption.
845 * The correct pen for the window frame must be selected in the DC.
847 static void NC_DrawCaption( HDC32 hdc
, RECT32
*rect
, HWND32 hwnd
,
848 DWORD style
, BOOL32 active
)
851 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
854 if (wndPtr
->flags
& WIN_MANAGED
) return;
858 if (!(hbitmapClose
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_CLOSE
) )))
860 hbitmapMinimize
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_REDUCE
) );
861 hbitmapMinimizeD
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_REDUCED
) );
862 hbitmapMaximize
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_ZOOM
) );
863 hbitmapMaximizeD
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_ZOOMD
) );
864 hbitmapRestore
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_RESTORE
) );
865 hbitmapRestoreD
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_RESTORED
) );
868 if (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
)
870 HBRUSH32 hbrushOld
= SelectObject32(hdc
, GetSysColorBrush32(COLOR_WINDOW
) );
871 PatBlt32( hdc
, r
.left
, r
.top
, 1, r
.bottom
-r
.top
+1,PATCOPY
);
872 PatBlt32( hdc
, r
.right
-1, r
.top
, 1, r
.bottom
-r
.top
+1, PATCOPY
);
873 PatBlt32( hdc
, r
.left
, r
.top
-1, r
.right
-r
.left
, 1, PATCOPY
);
876 SelectObject32( hdc
, hbrushOld
);
879 MoveTo( hdc
, r
.left
, r
.bottom
);
880 LineTo32( hdc
, r
.right
, r
.bottom
);
882 if (style
& WS_SYSMENU
)
884 NC_DrawSysButton( hwnd
, hdc
, FALSE
);
885 r
.left
+= SYSMETRICS_CXSIZE
+ 1;
886 MoveTo( hdc
, r
.left
- 1, r
.top
);
887 LineTo32( hdc
, r
.left
- 1, r
.bottom
);
889 if (style
& WS_MAXIMIZEBOX
)
891 NC_DrawMaxButton( hwnd
, hdc
, FALSE
);
892 r
.right
-= SYSMETRICS_CXSIZE
+ 1;
894 if (style
& WS_MINIMIZEBOX
)
896 NC_DrawMinButton( hwnd
, hdc
, FALSE
);
897 r
.right
-= SYSMETRICS_CXSIZE
+ 1;
900 FillRect32( hdc
, &r
, GetSysColorBrush32(active
? COLOR_ACTIVECAPTION
:
901 COLOR_INACTIVECAPTION
) );
903 if (GetWindowText32A( hwnd
, buffer
, sizeof(buffer
) ))
905 if (active
) SetTextColor32( hdc
, GetSysColor32( COLOR_CAPTIONTEXT
) );
906 else SetTextColor32( hdc
, GetSysColor32( COLOR_INACTIVECAPTIONTEXT
) );
907 SetBkMode32( hdc
, TRANSPARENT
);
908 DrawText32A( hdc
, buffer
, -1, &r
,
909 DT_SINGLELINE
| DT_CENTER
| DT_VCENTER
| DT_NOPREFIX
);
914 /******************************************************************************
923 * Draw the window caption for Win95 style windows.
924 * The correct pen for the window frame must be selected in the DC.
927 * Hey, a function that finally works! Well, almost. In Win95, the
928 * title has its own font -- not the system font. It's being worked
932 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
933 * Original implementation.
935 *****************************************************************************/
937 static void NC_DrawCaption95(
945 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
948 if (wndPtr
->flags
& WIN_MANAGED
) return;
950 FillRect32( hdc
, &r
, GetSysColorBrush32(active
? COLOR_ACTIVECAPTION
:
951 COLOR_INACTIVECAPTION
) );
954 if (!(hbitmapClose
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_CLOSE
) )))
956 hbitmapMinimize
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_REDUCE
) );
957 hbitmapMinimizeD
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_REDUCED
) );
958 hbitmapMaximize
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_ZOOM
) );
959 hbitmapMaximizeD
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_ZOOMD
) );
960 hbitmapRestore
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_RESTORE
) );
961 hbitmapRestoreD
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_RESTORED
) );
964 if (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
) {
965 HBRUSH32 hbrushOld
= SelectObject32(hdc
, GetSysColorBrush32(COLOR_WINDOW
) );
966 PatBlt32( hdc
, r
.left
, r
.top
, 1, r
.bottom
-r
.top
+1,PATCOPY
);
967 PatBlt32( hdc
, r
.right
-1, r
.top
, 1, r
.bottom
-r
.top
+1, PATCOPY
);
968 PatBlt32( hdc
, r
.left
, r
.top
-1, r
.right
-r
.left
, 1, PATCOPY
);
971 SelectObject32( hdc
, hbrushOld
);
974 if (style
& WS_SYSMENU
) {
975 NC_DrawSysButton95( hwnd
, hdc
, FALSE
);
976 r
.left
+= SYSMETRICS_CXSIZE
+ 1;
978 if (style
& WS_MAXIMIZEBOX
) {
979 NC_DrawMaxButton95( hwnd
, hdc
, FALSE
);
980 r
.right
-= SYSMETRICS_CXSIZE
+ 1;
982 if (style
& WS_MINIMIZEBOX
) {
983 NC_DrawMinButton95( hwnd
, hdc
, FALSE
);
984 r
.right
-= SYSMETRICS_CXSIZE
+ 1;
987 if (GetWindowText32A( hwnd
, buffer
, sizeof(buffer
) )) {
988 if (active
) SetTextColor32( hdc
, GetSysColor32( COLOR_CAPTIONTEXT
) );
989 else SetTextColor32( hdc
, GetSysColor32( COLOR_INACTIVECAPTIONTEXT
) );
990 SetBkMode32( hdc
, TRANSPARENT
);
991 r
.top
+= NC_CaptionTopNudge
- 2;
992 r
.left
+= NC_CaptionLeftNudge
;
993 DrawText32A( hdc
, buffer
, -1, &r
, NC_CaptionTextFlags
);
999 /***********************************************************************
1002 * Paint the non-client area. clip is currently unused.
1004 void NC_DoNCPaint( WND
* wndPtr
, HRGN32 clip
, BOOL32 suppress_menupaint
)
1009 HWND32 hwnd
= wndPtr
->hwndSelf
;
1011 if ( wndPtr
->dwStyle
& WS_MINIMIZE
||
1012 !WIN_IsWindowDrawable( wndPtr
, 0 )) return; /* Nothing to do */
1014 active
= wndPtr
->flags
& WIN_NCACTIVATED
;
1016 dprintf_nonclient(stddeb
, "NC_DoNCPaint: %04x %d\n", hwnd
, active
);
1018 if (!(hdc
= GetDCEx32( hwnd
, 0, DCX_USESTYLE
| DCX_WINDOW
))) return;
1020 if (ExcludeVisRect( hdc
, wndPtr
->rectClient
.left
-wndPtr
->rectWindow
.left
,
1021 wndPtr
->rectClient
.top
-wndPtr
->rectWindow
.top
,
1022 wndPtr
->rectClient
.right
-wndPtr
->rectWindow
.left
,
1023 wndPtr
->rectClient
.bottom
-wndPtr
->rectWindow
.top
)
1026 ReleaseDC32( hwnd
, hdc
);
1030 rect
.top
= rect
.left
= 0;
1031 rect
.right
= wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
;
1032 rect
.bottom
= wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
;
1034 SelectObject32( hdc
, GetSysColorPen32(COLOR_WINDOWFRAME
) );
1036 if (!(wndPtr
->flags
& WIN_MANAGED
))
1038 if ((wndPtr
->dwStyle
& WS_BORDER
) || (wndPtr
->dwStyle
& WS_DLGFRAME
) ||
1039 (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
))
1041 GRAPH_DrawRectangle( hdc
, 0, 0,
1042 rect
.right
, rect
.bottom
, (HPEN32
)0 );
1043 InflateRect32( &rect
, -1, -1 );
1046 if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
1047 NC_DrawFrame( hdc
, &rect
, TRUE
, active
);
1048 else if (wndPtr
->dwStyle
& WS_THICKFRAME
)
1049 NC_DrawFrame(hdc
, &rect
, FALSE
, active
);
1051 if ((wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
1054 r
.bottom
= rect
.top
+ SYSMETRICS_CYSIZE
;
1055 rect
.top
+= SYSMETRICS_CYSIZE
+ SYSMETRICS_CYBORDER
;
1056 NC_DrawCaption( hdc
, &r
, hwnd
, wndPtr
->dwStyle
, active
);
1060 if (HAS_MENU(wndPtr
))
1063 r
.bottom
= rect
.top
+ SYSMETRICS_CYMENU
; /* default height */
1064 rect
.top
+= MENU_DrawMenuBar( hdc
, &r
, hwnd
, suppress_menupaint
);
1067 /* Draw the scroll-bars */
1069 if (wndPtr
->dwStyle
& WS_VSCROLL
)
1070 SCROLL_DrawScrollBar( hwnd
, hdc
, SB_VERT
, TRUE
);
1071 if (wndPtr
->dwStyle
& WS_HSCROLL
)
1072 SCROLL_DrawScrollBar( hwnd
, hdc
, SB_HORZ
, TRUE
);
1074 /* Draw the "size-box" */
1076 if ((wndPtr
->dwStyle
& WS_VSCROLL
) && (wndPtr
->dwStyle
& WS_HSCROLL
))
1079 r
.left
= r
.right
- SYSMETRICS_CXVSCROLL
+ 1;
1080 r
.top
= r
.bottom
- SYSMETRICS_CYHSCROLL
+ 1;
1081 FillRect32( hdc
, &r
, GetSysColorBrush32(COLOR_SCROLLBAR
) );
1084 ReleaseDC32( hwnd
, hdc
);
1088 /******************************************************************************
1090 * void NC_DoNCPaint95(
1093 * BOOL32 suppress_menupaint )
1095 * Paint the non-client area for Win95 windows. The clip region is
1096 * currently ignored.
1099 * grep -E -A10 -B5 \(95\)\|\(Bugs\)\|\(FIXME\) windows/nonclient.c \
1100 * misc/tweak.c controls/menu.c # :-)
1103 * 03-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
1104 * Original implementation
1106 *****************************************************************************/
1108 void NC_DoNCPaint95(
1111 BOOL32 suppress_menupaint
)
1116 HWND32 hwnd
= wndPtr
->hwndSelf
;
1118 if ( wndPtr
->dwStyle
& WS_MINIMIZE
||
1119 !WIN_IsWindowDrawable( wndPtr
, 0 )) return; /* Nothing to do */
1121 active
= wndPtr
->flags
& WIN_NCACTIVATED
;
1123 dprintf_nonclient(stddeb
, "NC_DoNCPaint95: %04x %d\n", hwnd
, active
);
1125 if (!(hdc
= GetDCEx32( hwnd
, 0, DCX_USESTYLE
| DCX_WINDOW
))) return;
1127 if (ExcludeVisRect( hdc
, wndPtr
->rectClient
.left
-wndPtr
->rectWindow
.left
,
1128 wndPtr
->rectClient
.top
-wndPtr
->rectWindow
.top
,
1129 wndPtr
->rectClient
.right
-wndPtr
->rectWindow
.left
,
1130 wndPtr
->rectClient
.bottom
-wndPtr
->rectWindow
.top
)
1133 ReleaseDC32( hwnd
, hdc
);
1137 rect
.top
= rect
.left
= 0;
1138 rect
.right
= wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
;
1139 rect
.bottom
= wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
;
1141 SelectObject32( hdc
, GetSysColorPen32(COLOR_WINDOWFRAME
) );
1143 if(!(wndPtr
->flags
& WIN_MANAGED
)) {
1144 if((wndPtr
->dwStyle
& WS_BORDER
) || (wndPtr
->dwStyle
& WS_DLGFRAME
) ||
1145 (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
)) {
1146 TWEAK_DrawReliefRect95(hdc
, &rect
);
1147 InflateRect32(&rect
, -2, -2);
1150 if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
1151 NC_DrawFrame95( hdc
, &rect
, TRUE
, active
);
1152 else if (wndPtr
->dwStyle
& WS_THICKFRAME
)
1153 NC_DrawFrame95(hdc
, &rect
, FALSE
, active
);
1155 if ((wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
1158 POINT32 sep
[2] = { { rect
.left
,
1159 rect
.top
+ sysMetrics
[SM_CYCAPTION
] - 2 },
1161 rect
.top
+ sysMetrics
[SM_CYCAPTION
] - 2 } };
1163 r
.bottom
= rect
.top
+ sysMetrics
[SM_CYCAPTION
] - 2;
1164 rect
.top
+= sysMetrics
[SM_CYCAPTION
] - 2 + sysMetrics
[SM_CYBORDER
];
1165 NC_DrawCaption95( hdc
, &r
, hwnd
, wndPtr
->dwStyle
, active
);
1166 GRAPH_DrawLines( hdc
, sep
, 1, TWEAK_PenC095
);
1170 if (HAS_MENU(wndPtr
))
1173 r
.bottom
= rect
.top
+ sysMetrics
[SM_CYMENU
] - sysMetrics
[SM_CYBORDER
];
1174 r
.top
-= sysMetrics
[SM_CYBORDER
];
1176 dprintf_nonclient(stddeb
, "DoNCPaint95: Calling DrawMenuBar with "
1177 "rect (%d, %d)-(%d, %d)\n", r
.left
, r
.top
,
1180 rect
.top
+= MENU_DrawMenuBar( hdc
, &r
, hwnd
, suppress_menupaint
);
1183 dprintf_nonclient( stddeb
, "After MenuBar, rect is (%d, %d)-(%d, %d).\n",
1184 rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1186 /* Draw the inner frames */
1187 GRAPH_DrawRectangle( hdc
, rect
.left
, rect
.top
, rect
.right
- rect
.left
,
1188 rect
.bottom
- rect
.top
, TWEAK_PenC095
);
1189 InflateRect32(&rect
, -1, -1);
1190 GRAPH_DrawGenericReliefRect( hdc
, &rect
, 1, 1, NC_WinShadow95
,
1191 NC_WinHighlight95
);
1193 InflateRect32(&rect
, -1, -1);
1195 /* Draw the scroll-bars */
1197 if (wndPtr
->dwStyle
& WS_VSCROLL
)
1198 SCROLL_DrawScrollBar( hwnd
, hdc
, SB_VERT
, TRUE
);
1199 if (wndPtr
->dwStyle
& WS_HSCROLL
)
1200 SCROLL_DrawScrollBar( hwnd
, hdc
, SB_HORZ
, TRUE
);
1202 /* Draw the "size-box" */
1203 if ((wndPtr
->dwStyle
& WS_VSCROLL
) && (wndPtr
->dwStyle
& WS_HSCROLL
))
1206 r
.left
= r
.right
- SYSMETRICS_CXVSCROLL
+ 1;
1207 r
.top
= r
.bottom
- SYSMETRICS_CYHSCROLL
+ 1;
1208 FillRect32( hdc
, &r
, GetSysColorBrush32(COLOR_SCROLLBAR
) );
1211 ReleaseDC32( hwnd
, hdc
);
1217 /***********************************************************************
1220 * Handle a WM_NCPAINT message. Called from DefWindowProc().
1222 LONG
NC_HandleNCPaint( HWND32 hwnd
, HRGN32 clip
)
1224 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
1226 if( wndPtr
&& wndPtr
->dwStyle
& WS_VISIBLE
)
1228 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
1229 WINPOS_RedrawIconTitle( hwnd
);
1230 else if(TWEAK_Win95Look
)
1231 NC_DoNCPaint95( wndPtr
, clip
, FALSE
);
1233 NC_DoNCPaint( wndPtr
, clip
, FALSE
);
1239 /***********************************************************************
1240 * NC_HandleNCActivate
1242 * Handle a WM_NCACTIVATE message. Called from DefWindowProc().
1244 LONG
NC_HandleNCActivate( WND
*wndPtr
, WPARAM16 wParam
)
1248 if( wParam
) wStateChange
= !(wndPtr
->flags
& WIN_NCACTIVATED
);
1249 else wStateChange
= wndPtr
->flags
& WIN_NCACTIVATED
;
1253 if (wParam
) wndPtr
->flags
|= WIN_NCACTIVATED
;
1254 else wndPtr
->flags
&= ~WIN_NCACTIVATED
;
1256 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
1257 WINPOS_RedrawIconTitle( wndPtr
->hwndSelf
);
1258 else if( TWEAK_Win95Look
)
1259 NC_DoNCPaint95( wndPtr
, (HRGN32
)1, FALSE
);
1261 NC_DoNCPaint( wndPtr
, (HRGN32
)1, FALSE
);
1267 /***********************************************************************
1268 * NC_HandleSetCursor
1270 * Handle a WM_SETCURSOR message. Called from DefWindowProc().
1272 LONG
NC_HandleSetCursor( HWND32 hwnd
, WPARAM16 wParam
, LPARAM lParam
)
1274 if (hwnd
!= (HWND32
)wParam
) return 0; /* Don't set the cursor for child windows */
1276 switch(LOWORD(lParam
))
1280 WORD msg
= HIWORD( lParam
);
1281 if ((msg
== WM_LBUTTONDOWN
) || (msg
== WM_MBUTTONDOWN
) ||
1282 (msg
== WM_RBUTTONDOWN
))
1290 if (!(wndPtr
= WIN_FindWndPtr( hwnd
))) break;
1291 if (wndPtr
->class->hCursor
)
1293 SetCursor16( wndPtr
->class->hCursor
);
1301 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZEWE
) );
1305 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZENS
) );
1309 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZENWSE
) );
1313 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_SIZENESW
) );
1316 /* Default cursor: arrow */
1317 return (LONG
)SetCursor16( LoadCursor16( 0, IDC_ARROW
) );
1320 /***********************************************************************
1323 BOOL32
NC_GetSysPopupPos( WND
* wndPtr
, RECT32
* rect
)
1325 if( wndPtr
->hSysMenu
)
1327 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
1328 GetWindowRect32( wndPtr
->hwndSelf
, rect
);
1331 NC_GetInsideRect( wndPtr
->hwndSelf
, rect
);
1332 OffsetRect32( rect
, wndPtr
->rectWindow
.left
, wndPtr
->rectWindow
.top
);
1333 if (wndPtr
->dwStyle
& WS_CHILD
)
1334 ClientToScreen32( wndPtr
->parent
->hwndSelf
, (POINT32
*)rect
);
1335 rect
->right
= rect
->left
+ SYSMETRICS_CXSIZE
;
1336 rect
->bottom
= rect
->top
+ SYSMETRICS_CYSIZE
;
1343 /***********************************************************************
1346 * Initialisation of a move or resize, when initiatied from a menu choice.
1347 * Return hit test code for caption or sizing border.
1349 static LONG
NC_StartSizeMove( WND
* wndPtr
, WPARAM16 wParam
,
1350 POINT16
*capturePoint
)
1356 if ((wParam
& 0xfff0) == SC_MOVE
)
1358 /* Move pointer at the center of the caption */
1360 NC_GetInsideRect( wndPtr
->hwndSelf
, &rect
);
1361 if (wndPtr
->dwStyle
& WS_SYSMENU
)
1362 rect
.left
+= SYSMETRICS_CXSIZE
+ 1;
1363 if (wndPtr
->dwStyle
& WS_MINIMIZEBOX
)
1364 rect
.right
-= SYSMETRICS_CXSIZE
+ 1;
1365 if (wndPtr
->dwStyle
& WS_MAXIMIZEBOX
)
1366 rect
.right
-= SYSMETRICS_CXSIZE
+ 1;
1367 pt
.x
= wndPtr
->rectWindow
.left
+ (rect
.right
- rect
.left
) / 2;
1368 pt
.y
= wndPtr
->rectWindow
.top
+ rect
.top
+ SYSMETRICS_CYSIZE
/2;
1369 hittest
= HTCAPTION
;
1372 if (wndPtr
->dwStyle
& WS_CHILD
)
1373 ClientToScreen16( wndPtr
->parent
->hwndSelf
, &pt
);
1379 MSG_InternalGetMessage( &msg
, 0, 0, MSGF_SIZE
, PM_REMOVE
, FALSE
);
1383 hittest
= NC_HandleNCHitTest( wndPtr
->hwndSelf
, msg
.pt
);
1385 if ((hittest
< HTLEFT
) || (hittest
> HTBOTTOMRIGHT
))
1397 pt
.x
=(wndPtr
->rectWindow
.left
+wndPtr
->rectWindow
.right
)/2;
1398 pt
.y
= wndPtr
->rectWindow
.top
+ SYSMETRICS_CYFRAME
/ 2;
1402 pt
.x
=(wndPtr
->rectWindow
.left
+wndPtr
->rectWindow
.right
)/2;
1403 pt
.y
= wndPtr
->rectWindow
.bottom
- SYSMETRICS_CYFRAME
/ 2;
1407 pt
.x
= wndPtr
->rectWindow
.left
+ SYSMETRICS_CXFRAME
/ 2;
1408 pt
.y
=(wndPtr
->rectWindow
.top
+wndPtr
->rectWindow
.bottom
)/2;
1412 pt
.x
= wndPtr
->rectWindow
.right
- SYSMETRICS_CXFRAME
/ 2;
1413 pt
.y
=(wndPtr
->rectWindow
.top
+wndPtr
->rectWindow
.bottom
)/2;
1416 case VK_ESCAPE
: return 0;
1422 SetCursorPos32( pt
.x
, pt
.y
);
1423 NC_HandleSetCursor( wndPtr
->hwndSelf
,
1424 wndPtr
->hwndSelf
, MAKELONG( hittest
, WM_MOUSEMOVE
));
1429 /***********************************************************************
1432 * Perform SC_MOVE and SC_SIZE commands.
1434 static void NC_DoSizeMove( HWND32 hwnd
, WORD wParam
, POINT16 pt
)
1437 RECT32 sizingRect
, mouseRect
;
1439 LONG hittest
= (LONG
)(wParam
& 0x0f);
1440 HCURSOR16 hDragCursor
= 0, hOldCursor
= 0;
1441 POINT32 minTrack
, maxTrack
;
1442 POINT16 capturePoint
= pt
;
1443 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
1444 BOOL32 thickframe
= HAS_THICKFRAME( wndPtr
->dwStyle
);
1445 BOOL32 iconic
= wndPtr
->dwStyle
& WS_MINIMIZE
;
1446 BOOL32 moved
= FALSE
;
1448 if (IsZoomed32(hwnd
) || !IsWindowVisible32(hwnd
) ||
1449 (wndPtr
->flags
& WIN_MANAGED
)) return;
1451 if ((wParam
& 0xfff0) == SC_MOVE
)
1453 if (!(wndPtr
->dwStyle
& WS_CAPTION
)) return;
1455 hittest
= NC_StartSizeMove( wndPtr
, wParam
, &capturePoint
);
1456 if (!hittest
) return;
1460 if (!thickframe
) return;
1461 if ( hittest
&& hittest
!= HTSYSMENU
) hittest
+= 2;
1465 hittest
= NC_StartSizeMove( wndPtr
, wParam
, &capturePoint
);
1474 /* Get min/max info */
1476 WINPOS_GetMinMaxInfo( wndPtr
, NULL
, NULL
, &minTrack
, &maxTrack
);
1477 sizingRect
= wndPtr
->rectWindow
;
1478 if (wndPtr
->dwStyle
& WS_CHILD
)
1479 GetClientRect32( wndPtr
->parent
->hwndSelf
, &mouseRect
);
1481 SetRect32(&mouseRect
, 0, 0, SYSMETRICS_CXSCREEN
, SYSMETRICS_CYSCREEN
);
1482 if (ON_LEFT_BORDER(hittest
))
1484 mouseRect
.left
= MAX( mouseRect
.left
, sizingRect
.right
-maxTrack
.x
);
1485 mouseRect
.right
= MIN( mouseRect
.right
, sizingRect
.right
-minTrack
.x
);
1487 else if (ON_RIGHT_BORDER(hittest
))
1489 mouseRect
.left
= MAX( mouseRect
.left
, sizingRect
.left
+minTrack
.x
);
1490 mouseRect
.right
= MIN( mouseRect
.right
, sizingRect
.left
+maxTrack
.x
);
1492 if (ON_TOP_BORDER(hittest
))
1494 mouseRect
.top
= MAX( mouseRect
.top
, sizingRect
.bottom
-maxTrack
.y
);
1495 mouseRect
.bottom
= MIN( mouseRect
.bottom
,sizingRect
.bottom
-minTrack
.y
);
1497 else if (ON_BOTTOM_BORDER(hittest
))
1499 mouseRect
.top
= MAX( mouseRect
.top
, sizingRect
.top
+minTrack
.y
);
1500 mouseRect
.bottom
= MIN( mouseRect
.bottom
, sizingRect
.top
+maxTrack
.y
);
1502 SendMessage16( hwnd
, WM_ENTERSIZEMOVE
, 0, 0 );
1504 if (GetCapture32() != hwnd
) SetCapture32( hwnd
);
1506 if (wndPtr
->dwStyle
& WS_CHILD
)
1508 /* Retrieve a default cache DC (without using the window style) */
1509 hdc
= GetDCEx32( wndPtr
->parent
->hwndSelf
, 0, DCX_CACHE
);
1512 { /* Grab the server only when moving top-level windows without desktop */
1514 if (rootWindow
== DefaultRootWindow(display
)) TSXGrabServer( display
);
1517 if( iconic
) /* create a cursor for dragging */
1519 HICON16 hIcon
= (wndPtr
->class->hIcon
) ? wndPtr
->class->hIcon
1520 : (HICON16
)SendMessage16( hwnd
, WM_QUERYDRAGICON
, 0, 0L);
1521 if( hIcon
) hDragCursor
= CURSORICON_IconToCursor( hIcon
, TRUE
);
1522 if( !hDragCursor
) iconic
= FALSE
;
1525 if( !iconic
) NC_DrawMovingFrame( hdc
, &sizingRect
, thickframe
);
1531 MSG_InternalGetMessage( &msg
, 0, 0, MSGF_SIZE
, PM_REMOVE
, FALSE
);
1533 /* Exit on button-up, Return, or Esc */
1534 if ((msg
.message
== WM_LBUTTONUP
) ||
1535 ((msg
.message
== WM_KEYDOWN
) &&
1536 ((msg
.wParam
== VK_RETURN
) || (msg
.wParam
== VK_ESCAPE
)))) break;
1538 if ((msg
.message
!= WM_KEYDOWN
) && (msg
.message
!= WM_MOUSEMOVE
))
1539 continue; /* We are not interested in other messages */
1542 if (wndPtr
->dwStyle
& WS_CHILD
)
1543 ScreenToClient16( wndPtr
->parent
->hwndSelf
, &pt
);
1545 if (msg
.message
== WM_KEYDOWN
) switch(msg
.wParam
)
1547 case VK_UP
: pt
.y
-= 8; break;
1548 case VK_DOWN
: pt
.y
+= 8; break;
1549 case VK_LEFT
: pt
.x
-= 8; break;
1550 case VK_RIGHT
: pt
.x
+= 8; break;
1553 pt
.x
= MAX( pt
.x
, mouseRect
.left
);
1554 pt
.x
= MIN( pt
.x
, mouseRect
.right
);
1555 pt
.y
= MAX( pt
.y
, mouseRect
.top
);
1556 pt
.y
= MIN( pt
.y
, mouseRect
.bottom
);
1558 dx
= pt
.x
- capturePoint
.x
;
1559 dy
= pt
.y
- capturePoint
.y
;
1566 if( iconic
) /* ok, no system popup tracking */
1568 hOldCursor
= SetCursor32(hDragCursor
);
1569 ShowCursor32( TRUE
);
1570 WINPOS_ShowIconTitle( wndPtr
, FALSE
);
1574 if (msg
.message
== WM_KEYDOWN
) SetCursorPos32( pt
.x
, pt
.y
);
1577 RECT32 newRect
= sizingRect
;
1579 if (hittest
== HTCAPTION
) OffsetRect32( &newRect
, dx
, dy
);
1580 if (ON_LEFT_BORDER(hittest
)) newRect
.left
+= dx
;
1581 else if (ON_RIGHT_BORDER(hittest
)) newRect
.right
+= dx
;
1582 if (ON_TOP_BORDER(hittest
)) newRect
.top
+= dy
;
1583 else if (ON_BOTTOM_BORDER(hittest
)) newRect
.bottom
+= dy
;
1586 NC_DrawMovingFrame( hdc
, &sizingRect
, thickframe
);
1587 NC_DrawMovingFrame( hdc
, &newRect
, thickframe
);
1590 sizingRect
= newRect
;
1598 if( moved
) /* restore cursors, show icon title later on */
1600 ShowCursor32( FALSE
);
1601 SetCursor32( hOldCursor
);
1603 DestroyCursor32( hDragCursor
);
1606 NC_DrawMovingFrame( hdc
, &sizingRect
, thickframe
);
1608 if (wndPtr
->dwStyle
& WS_CHILD
)
1609 ReleaseDC32( wndPtr
->parent
->hwndSelf
, hdc
);
1612 ReleaseDC32( 0, hdc
);
1613 if (rootWindow
== DefaultRootWindow(display
)) TSXUngrabServer( display
);
1616 if (HOOK_IsHooked( WH_CBT
))
1618 RECT16
* pr
= SEGPTR_NEW(RECT16
);
1621 CONV_RECT32TO16( &sizingRect
, pr
);
1622 if( HOOK_CallHooks16( WH_CBT
, HCBT_MOVESIZE
, hwnd
,
1623 (LPARAM
)SEGPTR_GET(pr
)) )
1624 sizingRect
= wndPtr
->rectWindow
;
1626 CONV_RECT16TO32( pr
, &sizingRect
);
1630 SendMessage16( hwnd
, WM_EXITSIZEMOVE
, 0, 0 );
1631 SendMessage16( hwnd
, WM_SETVISIBLE
, !IsIconic16(hwnd
), 0L);
1633 if( moved
&& !((msg
.message
== WM_KEYDOWN
) && (msg
.wParam
== VK_ESCAPE
)) )
1635 /* NOTE: SWP_NOACTIVATE prevents document window activation in Word 6 */
1636 SetWindowPos32( hwnd
, 0, sizingRect
.left
, sizingRect
.top
,
1637 sizingRect
.right
- sizingRect
.left
,
1638 sizingRect
.bottom
- sizingRect
.top
,
1639 ( hittest
== HTCAPTION
) ? SWP_NOSIZE
: 0 );
1642 if( IsWindow32(hwnd
) )
1643 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
1645 /* Single click brings up the system menu when iconized */
1649 if( wndPtr
->dwStyle
& WS_SYSMENU
)
1650 SendMessage16( hwnd
, WM_SYSCOMMAND
,
1651 SC_MOUSEMENU
+ HTSYSMENU
, *((LPARAM
*)&pt
));
1653 else WINPOS_ShowIconTitle( wndPtr
, TRUE
);
1658 /***********************************************************************
1661 * Track a mouse button press on the minimize or maximize box.
1663 static void NC_TrackMinMaxBox( HWND32 hwnd
, WORD wParam
)
1666 HDC32 hdc
= GetWindowDC32( hwnd
);
1667 BOOL32 pressed
= TRUE
;
1668 void (*paintButton
)(HWND32
, HDC16
, BOOL32
);
1670 SetCapture32( hwnd
);
1671 if (wParam
== HTMINBUTTON
)
1672 paintButton
= (TWEAK_Win95Look
) ? &NC_DrawMinButton95
: &NC_DrawMinButton
;
1674 paintButton
= (TWEAK_Win95Look
) ? &NC_DrawMaxButton95
: &NC_DrawMaxButton
;
1676 (*paintButton
)( hwnd
, hdc
, TRUE
);
1680 BOOL32 oldstate
= pressed
;
1681 MSG_InternalGetMessage( &msg
, 0, 0, 0, PM_REMOVE
, FALSE
);
1683 pressed
= (NC_HandleNCHitTest( hwnd
, msg
.pt
) == wParam
);
1684 if (pressed
!= oldstate
)
1685 (*paintButton
)( hwnd
, hdc
, pressed
);
1686 } while (msg
.message
!= WM_LBUTTONUP
);
1688 (*paintButton
)( hwnd
, hdc
, FALSE
);
1691 ReleaseDC32( hwnd
, hdc
);
1692 if (!pressed
) return;
1694 if (wParam
== HTMINBUTTON
)
1695 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MINIMIZE
, *(LONG
*)&msg
.pt
);
1697 SendMessage16( hwnd
, WM_SYSCOMMAND
,
1698 IsZoomed32(hwnd
) ? SC_RESTORE
:SC_MAXIMIZE
, *(LONG
*)&msg
.pt
);
1702 /***********************************************************************
1705 * Track a mouse button press on the horizontal or vertical scroll-bar.
1707 static void NC_TrackScrollBar( HWND32 hwnd
, WPARAM32 wParam
, POINT32 pt
)
1711 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1713 if ((wParam
& 0xfff0) == SC_HSCROLL
)
1715 if ((wParam
& 0x0f) != HTHSCROLL
) return;
1716 scrollbar
= SB_HORZ
;
1718 else /* SC_VSCROLL */
1720 if ((wParam
& 0x0f) != HTVSCROLL
) return;
1721 scrollbar
= SB_VERT
;
1724 if (!(msg
= SEGPTR_NEW(MSG16
))) return;
1725 pt
.x
-= wndPtr
->rectWindow
.left
;
1726 pt
.y
-= wndPtr
->rectWindow
.top
;
1727 SetCapture32( hwnd
);
1728 SCROLL_HandleScrollEvent( hwnd
, scrollbar
, WM_LBUTTONDOWN
, pt
);
1732 GetMessage16( SEGPTR_GET(msg
), 0, 0, 0 );
1733 switch(msg
->message
)
1738 pt
.x
= LOWORD(msg
->lParam
) + wndPtr
->rectClient
.left
-
1739 wndPtr
->rectWindow
.left
;
1740 pt
.y
= HIWORD(msg
->lParam
) + wndPtr
->rectClient
.top
-
1741 wndPtr
->rectWindow
.top
;
1742 SCROLL_HandleScrollEvent( hwnd
, scrollbar
, msg
->message
, pt
);
1745 TranslateMessage16( msg
);
1746 DispatchMessage16( msg
);
1749 if (!IsWindow32( hwnd
))
1754 } while (msg
->message
!= WM_LBUTTONUP
);
1758 /***********************************************************************
1759 * NC_HandleNCLButtonDown
1761 * Handle a WM_NCLBUTTONDOWN message. Called from DefWindowProc().
1763 LONG
NC_HandleNCLButtonDown( WND
* pWnd
, WPARAM16 wParam
, LPARAM lParam
)
1765 HWND32 hwnd
= pWnd
->hwndSelf
;
1767 switch(wParam
) /* Hit test */
1770 hwnd
= WIN_GetTopParent(hwnd
);
1772 if( WINPOS_SetActiveWindow(hwnd
, TRUE
, TRUE
) || (GetActiveWindow32() == hwnd
) )
1773 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_MOVE
+ HTCAPTION
, lParam
);
1777 if( pWnd
->dwStyle
& WS_SYSMENU
)
1779 if( !(pWnd
->dwStyle
& WS_MINIMIZE
) )
1781 HDC32 hDC
= GetWindowDC32(hwnd
);
1782 if( TWEAK_Win95Look
)
1783 NC_DrawSysButton95( hwnd
, hDC
, TRUE
);
1785 NC_DrawSysButton( hwnd
, hDC
, TRUE
);
1786 ReleaseDC32( hwnd
, hDC
);
1788 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MOUSEMENU
+ HTSYSMENU
, lParam
);
1793 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_MOUSEMENU
, lParam
);
1797 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_HSCROLL
+ HTHSCROLL
, lParam
);
1801 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_VSCROLL
+ HTVSCROLL
, lParam
);
1806 NC_TrackMinMaxBox( hwnd
, wParam
);
1817 /* make sure hittest fits into 0xf and doesn't overlap with HTSYSMENU */
1818 SendMessage16( hwnd
, WM_SYSCOMMAND
, SC_SIZE
+ wParam
- 2, lParam
);
1828 /***********************************************************************
1829 * NC_HandleNCLButtonDblClk
1831 * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc().
1833 LONG
NC_HandleNCLButtonDblClk( WND
*pWnd
, WPARAM16 wParam
, LPARAM lParam
)
1836 * if this is an icon, send a restore since we are handling
1839 if (pWnd
->dwStyle
& WS_MINIMIZE
)
1841 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_RESTORE
, lParam
);
1845 switch(wParam
) /* Hit test */
1848 /* stop processing if WS_MAXIMIZEBOX is missing */
1849 if (pWnd
->dwStyle
& WS_MAXIMIZEBOX
)
1850 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
,
1851 (pWnd
->dwStyle
& WS_MAXIMIZE
) ? SC_RESTORE
: SC_MAXIMIZE
,
1856 if (!(pWnd
->class->style
& CS_NOCLOSE
))
1857 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_CLOSE
, lParam
);
1861 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_HSCROLL
+ HTHSCROLL
,
1866 SendMessage16( pWnd
->hwndSelf
, WM_SYSCOMMAND
, SC_VSCROLL
+ HTVSCROLL
,
1874 /***********************************************************************
1875 * NC_HandleSysCommand
1877 * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
1879 LONG
NC_HandleSysCommand( HWND32 hwnd
, WPARAM16 wParam
, POINT16 pt
)
1881 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
1883 UINT16 uCommand
= wParam
& 0xFFF0;
1885 dprintf_nonclient(stddeb
, "Handling WM_SYSCOMMAND %x %d,%d\n",
1886 wParam
, pt
.x
, pt
.y
);
1888 if (wndPtr
->dwStyle
& WS_CHILD
&& uCommand
!= SC_KEYMENU
)
1889 ScreenToClient16( wndPtr
->parent
->hwndSelf
, &pt
);
1895 NC_DoSizeMove( hwnd
, wParam
, pt
);
1899 ShowWindow32( hwnd
, SW_MINIMIZE
);
1903 ShowWindow32( hwnd
, SW_MAXIMIZE
);
1907 ShowWindow32( hwnd
, SW_RESTORE
);
1911 return SendMessage16( hwnd
, WM_CLOSE
, 0, 0 );
1915 CONV_POINT16TO32( &pt
, &pt32
);
1916 NC_TrackScrollBar( hwnd
, wParam
, pt32
);
1920 CONV_POINT16TO32( &pt
, &pt32
);
1921 MENU_TrackMouseMenuBar( wndPtr
, wParam
& 0x000F, pt32
);
1925 MENU_TrackKbdMenuBar( wndPtr
, wParam
, pt
.x
);
1929 WinExec32( "taskman.exe", SW_SHOWNORMAL
);
1933 if (wParam
== SC_ABOUTWINE
)
1934 ShellAbout32A(hwnd
,"Wine", WINE_RELEASE_INFO
, 0);
1941 /* FIXME: unimplemented */