1 /* $Id: defwnd.c,v 1.90 2003/09/29 19:00:44 weiden Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS user32.dll
5 * FILE: lib/user32/windows/window.c
6 * PURPOSE: Window management
7 * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
9 * 06-06-2001 CSH Created
12 /* INCLUDES ******************************************************************/
17 #include <user32/wininternal.h>
26 /* GLOBALS *******************************************************************/
28 static HBITMAP hbSysMenu
;
29 /* TODO: widgets will be cached here.
30 static HBITMAP hbClose;
31 static HBITMAP hbCloseD;
32 static HBITMAP hbMinimize;
33 static HBITMAP hbMinimizeD;
34 static HBITMAP hbRestore;
35 static HBITMAP hbRestoreD;
36 static HBITMAP hbMaximize;
37 static HBITMAP hbScrUp;
38 static HBITMAP hbScrDwn;
39 static HBITMAP hbScrLeft;
40 static HBITMAP hbScrRight;
44 static COLORREF SysColours
[] =
46 RGB(224, 224, 224) /* COLOR_SCROLLBAR */,
47 RGB(58, 110, 165) /* COLOR_BACKGROUND */,
48 RGB(0, 0, 128) /* COLOR_ACTIVECAPTION */,
49 RGB(128, 128, 128) /* COLOR_INACTIVECAPTION */,
50 RGB(192, 192, 192) /* COLOR_MENU */,
51 RGB(255, 255, 255) /* COLOR_WINDOW */,
52 RGB(0, 0, 0) /* COLOR_WINDOWFRAME */,
53 RGB(0, 0, 0) /* COLOR_MENUTEXT */,
54 RGB(0, 0, 0) /* COLOR_WINDOWTEXT */,
55 RGB(255, 255, 255) /* COLOR_CAPTIONTEXT */,
56 RGB(128, 128, 128) /* COLOR_ACTIVEBORDER */,
57 RGB(255, 255, 255) /* COLOR_INACTIVEBORDER */,
58 RGB(255, 255, 232) /* COLOR_APPWORKSPACE */,
59 RGB(224, 224, 224) /* COLOR_HILIGHT */,
60 RGB(0, 0, 128) /* COLOR_HILIGHTTEXT */,
61 RGB(192, 192, 192) /* COLOR_BTNFACE */,
62 RGB(128, 128, 128) /* COLOR_BTNSHADOW */,
63 RGB(192, 192, 192) /* COLOR_GRAYTEXT */,
64 RGB(0, 0, 0) /* COLOR_BTNTEXT */,
65 RGB(192, 192, 192) /* COLOR_INACTIVECAPTIONTEXT */,
66 RGB(255, 255, 255) /* COLOR_BTNHILIGHT */,
67 RGB(32, 32, 32) /* COLOR_3DDKSHADOW */,
68 RGB(192, 192, 192) /* COLOR_3DLIGHT */,
69 RGB(0, 0, 0) /* COLOR_INFOTEXT */,
70 RGB(255, 255, 192) /* COLOR_INFOBK */,
71 RGB(184, 180, 184) /* COLOR_ALTERNATEBTNFACE */,
72 RGB(0, 0, 255) /* COLOR_HOTLIGHT */,
73 RGB(16, 132, 208) /* COLOR_GRADIENTACTIVECAPTION */,
74 RGB(181, 181, 181) /* COLOR_GRADIENTINACTIVECAPTION */,
77 static ATOM AtomInternalPos
;
79 /* Bits in the dwKeyData */
80 #define KEYDATA_ALT 0x2000
82 /* FUNCTIONS *****************************************************************/
85 IsMaxBoxActive(HWND hWnd
)
87 ULONG uStyle
= GetWindowLongW(hWnd
, GWL_STYLE
);
88 return (uStyle
& WS_MAXIMIZEBOX
);
92 IsCloseBoxActive(HWND hWnd
)
94 ULONG uStyle
= GetWindowLongW(hWnd
, GWL_STYLE
);
95 return (uStyle
& WS_SYSMENU
);
99 IsMinBoxActive(HWND hWnd
)
101 ULONG uStyle
= GetWindowLongW(hWnd
, GWL_STYLE
);
102 return (uStyle
& WS_MINIMIZEBOX
);
106 UIGetFrameSizeX(HWND hWnd
)
108 ULONG uStyle
= GetWindowLongW(hWnd
, GWL_STYLE
);
110 if ( uStyle
& WS_THICKFRAME
)
111 return GetSystemMetrics(SM_CXSIZEFRAME
);
113 return GetSystemMetrics(SM_CXFRAME
);
117 UIGetFrameSizeY(HWND hWnd
)
119 ULONG uStyle
= GetWindowLongW(hWnd
, GWL_STYLE
);
121 if (uStyle
& WS_THICKFRAME
)
122 return GetSystemMetrics(SM_CYSIZEFRAME
);
124 return GetSystemMetrics(SM_CYFRAME
);
128 UserSetupInternalPos(VOID
)
131 AtomInternalPos
= GlobalAddAtomA(Str
);
138 GetSysColor(int nIndex
)
140 return SysColours
[nIndex
];
147 GetSysColorPen(int nIndex
)
149 static HPEN SysPens
[sizeof(SysColours
) / sizeof(SysColours
[0])];
151 if (nIndex
< 0 || sizeof(SysColours
) / sizeof(SysColours
[0]) < nIndex
)
153 SetLastError(ERROR_INVALID_PARAMETER
);
157 /* FIXME should register this object with DeleteObject() so it
159 if (NULL
== SysPens
[nIndex
])
161 SysPens
[nIndex
] = CreatePen(PS_SOLID
, 1, SysColours
[nIndex
]);
164 return SysPens
[nIndex
];
171 GetSysColorBrush(int nIndex
)
173 static HBRUSH SysBrushes
[sizeof(SysColours
) / sizeof(SysColours
[0])];
175 if (nIndex
< 0 || sizeof(SysColours
) / sizeof(SysColours
[0]) < nIndex
)
177 SetLastError(ERROR_INVALID_PARAMETER
);
181 /* FIXME should register this object with DeleteObject() so it
183 if (NULL
== SysBrushes
[nIndex
])
185 SysBrushes
[nIndex
] = (HBRUSH
) ((DWORD
) CreateSolidBrush(SysColours
[nIndex
]) | 0x00800000);
188 return SysBrushes
[nIndex
];
195 DefFrameProcA( HWND hWnd
,
209 DefFrameProcW(HWND hWnd
,
220 UserGetInternalPos(HWND hWnd
)
223 lpPos
= (PINTERNALPOS
)GetPropA(hWnd
, (LPSTR
)(DWORD
)AtomInternalPos
);
228 DefWndRedrawIconTitle(HWND hWnd
)
230 PINTERNALPOS lpPos
= (PINTERNALPOS
)GetPropA(hWnd
, (LPSTR
)(DWORD
)AtomInternalPos
);
234 if (lpPos
->IconTitle
!= NULL
)
236 SendMessageA(lpPos
->IconTitle
, WM_SHOWWINDOW
, TRUE
, 0);
237 InvalidateRect(lpPos
->IconTitle
, NULL
, TRUE
);
245 UserHasMenu(HWND hWnd
, ULONG Style
)
247 return (!(Style
& WS_CHILD
) && GetMenu(hWnd
) != 0);
251 UserHasAnyFrameStyle(ULONG Style
, ULONG ExStyle
)
253 return ((Style
& (WS_THICKFRAME
| WS_DLGFRAME
| WS_BORDER
)) ||
254 (ExStyle
& WS_EX_DLGMODALFRAME
) ||
255 (!(Style
& (WS_CHILD
| WS_POPUP
))));
259 UserHasDlgFrameStyle(ULONG Style
, ULONG ExStyle
)
261 return ((ExStyle
& WS_EX_DLGMODALFRAME
) ||
262 ((Style
& WS_DLGFRAME
) && (!(Style
& WS_THICKFRAME
))));
266 UserHasThickFrameStyle(ULONG Style
, ULONG ExStyle
)
268 return ((Style
& WS_THICKFRAME
) &&
269 (!((Style
& (WS_DLGFRAME
| WS_BORDER
)) == WS_DLGFRAME
)));
273 UserHasThinFrameStyle(ULONG Style
, ULONG ExStyle
)
275 return ((Style
& WS_BORDER
) || (!(Style
& (WS_CHILD
| WS_POPUP
))));
279 UserHasBigFrameStyle(ULONG Style
, ULONG ExStyle
)
281 return ((Style
& (WS_THICKFRAME
| WS_DLGFRAME
)) ||
282 (ExStyle
& WS_EX_DLGMODALFRAME
));
286 UserGetInsideRectNC(HWND hWnd
, RECT
*rect
)
292 Style
= GetWindowLongW(hWnd
, GWL_STYLE
);
293 ExStyle
= GetWindowLongW(hWnd
, GWL_EXSTYLE
);
294 GetWindowRect(hWnd
, &WindowRect
);
295 rect
->top
= rect
->left
= 0;
296 rect
->right
= WindowRect
.right
- WindowRect
.left
;
297 rect
->bottom
= WindowRect
.bottom
- WindowRect
.top
;
299 if (Style
& WS_ICONIC
)
304 /* Remove frame from rectangle */
305 if (UserHasThickFrameStyle(Style
, ExStyle
))
307 InflateRect(rect
, -GetSystemMetrics(SM_CXFRAME
),
308 -GetSystemMetrics(SM_CYFRAME
));
312 if (UserHasDlgFrameStyle(Style
, ExStyle
))
314 InflateRect(rect
, -GetSystemMetrics(SM_CXDLGFRAME
),
315 -GetSystemMetrics(SM_CYDLGFRAME
));
316 /* FIXME: this isn't in NC_AdjustRect? why not? */
317 if (ExStyle
& WS_EX_DLGMODALFRAME
)
318 InflateRect( rect
, -1, 0 );
322 if (UserHasThinFrameStyle(Style
, ExStyle
))
324 InflateRect(rect
, -GetSystemMetrics(SM_CXBORDER
),
325 -GetSystemMetrics(SM_CYBORDER
));
332 UserDrawSysMenuButton(HWND hWnd
, HDC hDC
, LPRECT Rect
, BOOL down
)
335 HBITMAP hSavedBitmap
;
339 hbSysMenu
= (HBITMAP
)LoadBitmapW(0, MAKEINTRESOURCEW(OBM_CLOSE
));
341 hDcMem
= CreateCompatibleDC(hDC
);
346 hSavedBitmap
= SelectObject(hDcMem
, hbSysMenu
);
353 BitBlt(hDC
, Rect
->left
+ 2, Rect
->top
+ 3, 16, 14, hDcMem
,
354 (GetWindowLongW(hWnd
, GWL_STYLE
) & WS_CHILD
) ?
355 GetSystemMetrics(SM_CXSIZE
): 0, 0, SRCCOPY
);
357 SelectObject(hDcMem
, hSavedBitmap
);
364 * Cache bitmaps, then just bitblt instead of calling DFC() (and
365 * wasting precious CPU cycles) every time
368 UserDrawCaptionButton(HWND hWnd
, HDC hDC
, BOOL bDown
, ULONG Type
)
371 INT iBmpWidth
= GetSystemMetrics(SM_CXSIZE
) - 2;
372 INT iBmpHeight
= GetSystemMetrics(SM_CYSIZE
) - 4;
373 INT OffsetX
= UIGetFrameSizeX(hWnd
);
374 INT OffsetY
= UIGetFrameSizeY(hWnd
);
376 if (!(GetWindowLongW(hWnd
, GWL_STYLE
) & WS_SYSMENU
))
381 GetWindowRect(hWnd
, &rect
);
383 rect
.right
= rect
.right
- rect
.left
;
384 rect
.bottom
= rect
.bottom
- rect
.top
;
385 rect
.left
= rect
.top
= 0;
389 case DFCS_CAPTIONMIN
:
391 if ((GetWindowLongW(hWnd
, GWL_EXSTYLE
) & WS_EX_TOOLWINDOW
) == TRUE
)
392 return; /* ToolWindows don't have min/max buttons */
394 SetRect(&rect
, rect
.right
- OffsetX
- (iBmpWidth
* 3) - 5,
395 OffsetY
+ 2, rect
.right
- (iBmpWidth
* 2) - OffsetX
- 5,
396 rect
.top
+ iBmpHeight
+ OffsetY
+ 2);
397 DrawFrameControl(hDC
, &rect
, DFC_CAPTION
,
398 DFCS_CAPTIONMIN
| (bDown
? DFCS_PUSHED
: 0) |
399 (IsMinBoxActive(hWnd
) ? 0 : DFCS_INACTIVE
));
402 case DFCS_CAPTIONMAX
:
404 if ((GetWindowLongW(hWnd
, GWL_EXSTYLE
) & WS_EX_TOOLWINDOW
) == TRUE
)
405 return; /* ToolWindows don't have min/max buttons */
407 SetRect(&rect
, rect
.right
- OffsetX
- (iBmpWidth
* 2) - 5,
408 OffsetY
+ 2, rect
.right
- iBmpWidth
- OffsetX
- 5,
409 rect
.top
+ iBmpHeight
+ OffsetY
+ 2);
410 DrawFrameControl(hDC
, &rect
, DFC_CAPTION
,
411 (IsZoomed(hWnd
) ? DFCS_CAPTIONRESTORE
: DFCS_CAPTIONMAX
) |
412 (bDown
? DFCS_PUSHED
: 0) |
413 (IsMaxBoxActive(hWnd
) ? 0 : DFCS_INACTIVE
));
416 case DFCS_CAPTIONCLOSE
:
418 SetRect(&rect
, rect
.right
- OffsetX
- iBmpWidth
- 3,
419 OffsetY
+ 2, rect
.right
- OffsetX
- 3,
420 rect
.top
+ iBmpHeight
+ OffsetY
+ 2 );
421 DrawFrameControl(hDC
, &rect
, DFC_CAPTION
,
422 (DFCS_CAPTIONCLOSE
| (bDown
? DFCS_PUSHED
: 0) |
423 (IsCloseBoxActive(hWnd
) ? 0 : DFCS_INACTIVE
)));
429 // Enabling this will cause captions to draw smoother, but slower:
430 // #define DOUBLE_BUFFER_CAPTION
431 // NOTE: Double buffering appears to be broken for this at the moment
443 NONCLIENTMETRICSW nclm
;
446 UINT VCenter
= 0, Padding
= 0, Height
;
449 HFONT hOldFont
= NULL
;
450 HBRUSH OldBrush
= NULL
;
454 #ifdef DOUBLE_BUFFER_CAPTION
455 HBITMAP MemBMP
= NULL
, OldBMP
= NULL
;
457 MemDC
= CreateCompatibleDC(hDC
);
458 if (! MemDC
) goto cleanup
;
459 MemBMP
= CreateCompatibleBitmap(hDC
, lprc
->right
- lprc
->left
, lprc
->bottom
- lprc
->top
);
460 if (! MemBMP
) goto cleanup
;
461 OldBMP
= SelectObject(MemDC
, MemBMP
);
462 if (! OldBMP
) goto cleanup
;
466 OffsetViewportOrgEx(MemDC
, lprc
->left
, lprc
->top
, NULL
);
469 // If DC_GRADIENT is specified, a Win 98/2000 style caption gradient should
470 // be painted. For now, that flag is ignored:
471 // Windows 98/Me, Windows 2000/XP: When this flag is set, the function uses
472 // COLOR_GRADIENTACTIVECAPTION (if the DC_ACTIVE flag was set) or
473 // COLOR_GRADIENTINACTIVECAPTION for the title-bar color.
475 // Draw the caption background
476 if (uFlags
& DC_INBUTTON
)
478 OldBrush
= SelectObject(MemDC
, GetSysColorBrush(uFlags
& DC_ACTIVE
? COLOR_BTNFACE
: COLOR_BTNSHADOW
) );
479 if (! OldBrush
) goto cleanup
;
480 if (! PatBlt(MemDC
, 0, 0, lprc
->right
- lprc
->left
, lprc
->bottom
- lprc
->top
, PATCOPY
)) goto cleanup
;
484 // DC_GRADIENT check should go here somewhere
485 OldBrush
= SelectObject(MemDC
, GetSysColorBrush(uFlags
& DC_ACTIVE
? COLOR_ACTIVECAPTION
: COLOR_INACTIVECAPTION
) );
486 if (! OldBrush
) goto cleanup
;
487 if (! PatBlt(MemDC
, 0, 0, lprc
->right
- lprc
->left
, lprc
->bottom
- lprc
->top
, PATCOPY
)) goto cleanup
;
490 /* Windows behaves like this */
491 Height
= GetSystemMetrics(SM_CYCAPTION
) - 1;
493 VCenter
= (lprc
->bottom
- lprc
->top
) / 2;
494 Padding
= VCenter
- (Height
/ 2);
497 r
.right
= r
.left
+ (lprc
->right
- lprc
->left
);
499 r
.bottom
= r
.top
+ (Height
/ 2);
501 if (uFlags
& DC_ICON
)
503 // For some reason the icon isn't centered correctly...
505 UserDrawSysMenuButton(hWnd
, MemDC
, &r
, FALSE
);
512 if ((uFlags
& DC_TEXT
) && (GetWindowTextW( hWnd
, buffer
, sizeof(buffer
)/sizeof(buffer
[0]) )))
514 // Duplicate odd behaviour from Windows:
515 if ((! uFlags
& DC_SMALLCAP
) || (uFlags
& DC_ICON
) || (uFlags
& DC_INBUTTON
) ||
516 (! uFlags
& DC_ACTIVE
))
517 r
.left
+= GetSystemMetrics(SM_CXSIZE
) + Padding
;
519 r
.right
= (lprc
->right
- lprc
->left
);
520 ButtonWidth
= GetSystemMetrics(SM_CXSIZE
) - 2;
521 if (GetWindowLongW(hWnd
, GWL_STYLE
) & WS_SYSMENU
)
523 r
.right
-= 3 + ButtonWidth
;
524 if (! (GetWindowLongW(hWnd
, GWL_EXSTYLE
) & WS_EX_TOOLWINDOW
))
526 r
.right
-= 2 + 2 * ButtonWidth
;
531 nclm
.cbSize
= sizeof(nclm
);
532 if (! SystemParametersInfoW(SPI_GETNONCLIENTMETRICS
, sizeof(NONCLIENTMETRICSW
), &nclm
, 0)) goto cleanup
;
534 if (uFlags
& DC_INBUTTON
)
535 SetTextColor(MemDC
, SysColours
[ uFlags
& DC_ACTIVE
? COLOR_BTNTEXT
: COLOR_GRAYTEXT
]);
537 SetTextColor(MemDC
, SysColours
[ uFlags
& DC_ACTIVE
? COLOR_CAPTIONTEXT
: COLOR_INACTIVECAPTIONTEXT
]);
539 SetBkMode( MemDC
, TRANSPARENT
);
540 if (GetWindowLongW(hWnd
, GWL_STYLE
) & WS_EX_TOOLWINDOW
)
541 // if (uFlags & DC_SMALLCAP) // incorrect
542 hFont
= CreateFontIndirectW(&nclm
.lfSmCaptionFont
);
544 hFont
= CreateFontIndirectW(&nclm
.lfCaptionFont
);
546 if (! hFont
) goto cleanup
;
548 hOldFont
= SelectObject(MemDC
, hFont
);
549 if (! hOldFont
) goto cleanup
;
551 DrawTextW(MemDC
, buffer
, wcslen(buffer
), &r
, DT_VCENTER
| DT_END_ELLIPSIS
);
553 // TextOutW(hDC, r.left + (GetSystemMetrics(SM_CXDLGFRAME) * 2), lprc->top + (nclm.lfCaptionFont.lfHeight / 2), buffer, wcslen(buffer));
556 if (uFlags
& DC_BUTTONS
)
558 // Windows XP draws the caption buttons with DC_BUTTONS
559 // r.left += GetSystemMetrics(SM_CXSIZE) + 1;
560 // UserDrawCaptionButton( hWnd, hDC, FALSE, DFCS_CAPTIONCLOSE);
561 // r.right -= GetSystemMetrics(SM_CXSMSIZE) + 1;
562 // UserDrawCaptionButton( hWnd, hDC, FALSE, DFCS_CAPTIONMIN);
563 // UserDrawCaptionButton( hWnd, hDC, FALSE, DFCS_CAPTIONMAX);
566 #ifdef DOUBLE_BUFFER_CAPTION
567 if (! BitBlt(hDC
, lprc
->left
, lprc
->top
, lprc
->right
- lprc
->left
, lprc
->bottom
- lprc
->top
,
568 MemDC
, 0, 0, SRCCOPY
)) goto cleanup
;
576 if (OldBrush
) SelectObject(MemDC
, OldBrush
);
577 if (hOldFont
) SelectObject(MemDC
, hOldFont
);
578 if (hFont
) DeleteObject(hFont
);
579 #ifdef DOUBLE_BUFFER_CAPTION
580 if (OldBMP
) SelectObject(MemDC
, OldBMP
);
581 if (MemBMP
) DeleteObject(MemBMP
);
584 OffsetViewportOrgEx(MemDC
, -lprc
->left
, -lprc
->top
, NULL
);
606 capflags
= DC_ICON
| DC_TEXT
;
607 capflags
|= (active
& DC_ACTIVE
);
609 if (GetWindowLongW(hWnd
, GWL_STYLE
) & WS_EX_TOOLWINDOW
)
610 capflags
|= DC_SMALLCAP
;
613 // PatBlt(hDC,rect->left + GetSystemMetrics(SM_CXFRAME), rect->top +
614 // GetSystemMetrics(SM_CYFRAME), rect->right - (GetSystemMetrics(SM_CXFRAME) * 2), (rect->top +
615 // GetSystemMetrics(SM_CYCAPTION)) - 1, PATCOPY );
617 r
.left
+= GetSystemMetrics(SM_CXFRAME
);
618 r
.top
+= GetSystemMetrics(SM_CYFRAME
);
619 r
.right
-= GetSystemMetrics(SM_CXFRAME
);
620 r
.bottom
= r
.top
+ GetSystemMetrics(SM_CYCAPTION
) - 1;
621 // GetSystemMetrics(SM_CYCAPTION)) - 1, PATCOPY );
623 DrawCaption(hWnd
, hDC
, &r
, capflags
);
625 /* draw line below caption */
626 lPen
= GetSysColorPen(COLOR_MENU
);
627 oPen
= SelectObject(hDC
, lPen
);
628 MoveToEx(hDC
, r
.left
, r
.bottom
, &OldPos
);
629 LineTo(hDC
, r
.right
, r
.bottom
);
630 MoveToEx(hDC
, OldPos
.x
, OldPos
.y
, NULL
);
631 SelectObject(hDC
, oPen
);
634 if (style
& WS_SYSMENU
)
636 // UserDrawSysMenuButton( hWnd, hDC, FALSE);
637 r
.left
+= GetSystemMetrics(SM_CXSIZE
) + 1;
638 UserDrawCaptionButton( hWnd
, hDC
, FALSE
, DFCS_CAPTIONCLOSE
);
639 r
.right
-= GetSystemMetrics(SM_CXSMSIZE
) + 1;
640 UserDrawCaptionButton( hWnd
, hDC
, FALSE
, DFCS_CAPTIONMIN
);
641 UserDrawCaptionButton( hWnd
, hDC
, FALSE
, DFCS_CAPTIONMAX
);
647 UserDrawFrameNC(HDC hDC
, RECT
* rect
, BOOL dlgFrame
, BOOL active
)
649 DrawEdge(hDC
, rect
,EDGE_RAISED
, BF_RECT
| BF_MIDDLE
);
654 SCROLL_DrawScrollBar (HWND hWnd
, HDC hDC
, INT nBar
, BOOL arrows
, BOOL interior
);
657 DefWndDoPaintNC(HWND hWnd
, HRGN clip
)
661 RECT rect
, clientrect
;
666 if (GetActiveWindow() == hWnd
) Active
= TRUE
;
667 Style
= GetWindowLongW(hWnd
, GWL_STYLE
);
668 ExStyle
= GetWindowLongW(hWnd
, GWL_EXSTYLE
);
670 hDC
= GetDCEx(hWnd
, (clip
> (HRGN
)1) ? clip
: 0, DCX_USESTYLE
| DCX_WINDOW
|
671 ((clip
> (HRGN
)1) ? (DCX_INTERSECTRGN
| DCX_KEEPCLIPRGN
) : 0));
677 /* FIXME: Test whether we need to draw anything at all. */
679 GetWindowRect(hWnd
, &rect
);
680 rect
.right
= rect
.right
- rect
.left
;
681 rect
.bottom
= rect
.bottom
- rect
.top
;
682 rect
.top
= rect
.left
= 0;
684 SelectObject(hDC
, GetSysColorPen(COLOR_WINDOWFRAME
));
685 if (UserHasThickFrameStyle(Style
, ExStyle
))
687 UserDrawFrameNC(hDC
, &rect
, FALSE
, Active
);
688 wFrame
= GetSystemMetrics(SM_CXSIZEFRAME
);
690 else if (UserHasDlgFrameStyle(Style
, ExStyle
))
692 UserDrawFrameNC(hDC
, &rect
, TRUE
, Active
);
693 wFrame
= GetSystemMetrics(SM_CXDLGFRAME
);
695 if (Style
& WS_CAPTION
)
698 r
.bottom
= rect
.top
+ GetSystemMetrics(SM_CYSIZE
);
699 rect
.top
+= GetSystemMetrics(SM_CYSIZE
) +
700 GetSystemMetrics(SM_CYBORDER
);
701 UserDrawCaptionNC(hDC
, &r
, hWnd
, Style
, Active
);
705 if (UserHasMenu(hWnd
, Style
))
708 r
.bottom
= rect
.top
+ GetSystemMetrics(SM_CYMENU
);
711 rect
.top
+= MenuDrawMenuBar(hDC
, &r
, hWnd
, FALSE
);
714 /* Draw scrollbars */
715 if (Style
& WS_VSCROLL
&& (clientrect
.right
- clientrect
.left
> GetSystemMetrics(SM_CXVSCROLL
)))
716 SCROLL_DrawScrollBar(hWnd
, hDC
, SB_VERT
, TRUE
, TRUE
);
717 if (Style
& WS_HSCROLL
&& (clientrect
.bottom
- clientrect
.top
> GetSystemMetrics(SM_CYHSCROLL
)))
718 SCROLL_DrawScrollBar(hWnd
, hDC
, SB_HORZ
, TRUE
, TRUE
);
720 /* FIXME: Draw size box.*/
722 ReleaseDC(hWnd
, hDC
);
727 DefWndPaintNC(HWND hWnd
, HRGN clip
)
729 if (IsWindowVisible(hWnd
))
733 DefWndRedrawIconTitle(hWnd
);
737 DefWndDoPaintNC(hWnd
, clip
);
745 DefWndHitTestNC(HWND hWnd
, POINT Point
)
749 ULONG Style
= GetWindowLongW(hWnd
, GWL_STYLE
);
750 ULONG ExStyle
= GetWindowLongW(hWnd
, GWL_EXSTYLE
);
752 GetWindowRect(hWnd
, &WindowRect
);
753 if (!PtInRect(&WindowRect
, Point
))
757 if (Style
& WS_MINIMIZE
)
761 if (UserHasThickFrameStyle(Style
, ExStyle
))
763 InflateRect(&WindowRect
, -GetSystemMetrics(SM_CXFRAME
),
764 -GetSystemMetrics(SM_CYFRAME
));
765 if (!PtInRect(&WindowRect
, Point
))
767 if (Point
.y
< WindowRect
.top
)
769 if (Point
.x
< (WindowRect
.left
+ GetSystemMetrics(SM_CXSIZE
)))
773 if (Point
.x
>= (WindowRect
.right
- GetSystemMetrics(SM_CXSIZE
)))
779 if (Point
.y
>= WindowRect
.bottom
)
781 if (Point
.x
< (WindowRect
.left
+ GetSystemMetrics(SM_CXSIZE
)))
783 return(HTBOTTOMLEFT
);
785 if (Point
.x
>= (WindowRect
.right
- GetSystemMetrics(SM_CXSIZE
)))
787 return(HTBOTTOMRIGHT
);
791 if (Point
.x
< WindowRect
.left
)
793 if (Point
.y
< (WindowRect
.top
+ GetSystemMetrics(SM_CYSIZE
)))
797 if (Point
.y
>= (WindowRect
.bottom
- GetSystemMetrics(SM_CYSIZE
)))
799 return(HTBOTTOMLEFT
);
803 if (Point
.x
>= WindowRect
.right
)
805 if (Point
.y
< (WindowRect
.top
+ GetSystemMetrics(SM_CYSIZE
)))
809 if (Point
.y
>= (WindowRect
.bottom
- GetSystemMetrics(SM_CYSIZE
)))
811 return(HTBOTTOMRIGHT
);
819 if (UserHasDlgFrameStyle(Style
, ExStyle
))
821 InflateRect(&WindowRect
, -GetSystemMetrics(SM_CXDLGFRAME
),
822 -GetSystemMetrics(SM_CYDLGFRAME
));
824 else if (UserHasThinFrameStyle(Style
, ExStyle
))
826 InflateRect(&WindowRect
, -GetSystemMetrics(SM_CXBORDER
),
827 -GetSystemMetrics(SM_CYBORDER
));
829 if (!PtInRect(&WindowRect
, Point
))
835 if ((Style
& WS_CAPTION
) == WS_CAPTION
)
837 WindowRect
.top
+= (GetSystemMetrics(SM_CYCAPTION
) -
838 GetSystemMetrics(SM_CYBORDER
));
839 if (!PtInRect(&WindowRect
, Point
))
841 if ((Style
& WS_SYSMENU
) && !(ExStyle
& WS_EX_TOOLWINDOW
))
843 WindowRect
.left
+= GetSystemMetrics(SM_CXSIZE
);
844 WindowRect
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
846 if (Point
.x
<= WindowRect
.left
)
850 if (WindowRect
.right
<= Point
.x
)
855 if (Style
& WS_MAXIMIZEBOX
|| Style
& WS_MINIMIZEBOX
)
857 WindowRect
.right
-= GetSystemMetrics(SM_CXSIZE
);
859 if (Point
.x
>= WindowRect
.right
)
864 if (Style
& WS_MINIMIZEBOX
)
866 WindowRect
.right
-= GetSystemMetrics(SM_CXSIZE
);
868 if (Point
.x
>= WindowRect
.right
)
876 ScreenToClient(hWnd
, &Point
);
877 GetClientRect(hWnd
, &WindowRect
);
879 if (PtInRect(&WindowRect
, Point
))
884 if (Style
& WS_VSCROLL
)
886 ScrollXY
= GetSystemMetrics(SM_CXVSCROLL
);
887 if(WindowRect
.right
- WindowRect
.left
> ScrollXY
)
889 WindowRect
.right
+= ScrollXY
;
890 if (PtInRect(&WindowRect
, Point
))
897 if (Style
& WS_HSCROLL
)
899 ScrollXY
= GetSystemMetrics(SM_CYHSCROLL
);
900 if(WindowRect
.bottom
- WindowRect
.top
> ScrollXY
)
902 WindowRect
.bottom
+= ScrollXY
;
903 if (PtInRect(&WindowRect
, Point
))
905 ScrollXY
= GetSystemMetrics(SM_CXVSCROLL
);
906 if ((Style
& WS_VSCROLL
) && (WindowRect
.right
- WindowRect
.left
> ScrollXY
) &&
907 (Point
.x
>= (WindowRect
.right
- ScrollXY
)))
909 return(HTBOTTOMRIGHT
);
916 if (UserHasMenu(hWnd
, Style
))
918 if (Point
.y
< 0 && Point
.x
>= 0 && Point
.x
<= WindowRect
.right
)
928 DefWndDoButton(HWND hWnd
, WPARAM wParam
)
931 BOOL InBtn
= TRUE
, HasBtn
= FALSE
;
933 WPARAM SCMsg
, CurBtn
= wParam
, OrigBtn
= wParam
;
938 Btn
= DFCS_CAPTIONCLOSE
;
940 HasBtn
= IsCloseBoxActive(hWnd
);
943 Btn
= DFCS_CAPTIONMIN
;
945 HasBtn
= IsMinBoxActive(hWnd
);
948 Btn
= DFCS_CAPTIONMAX
;
950 HasBtn
= IsMaxBoxActive(hWnd
);
960 UserDrawCaptionButton( hWnd
, GetWindowDC(hWnd
), HasBtn
, Btn
);
964 GetMessageW(&Msg
, 0, 0, 0);
978 CurBtn
= DefWndHitTestNC(hWnd
, Msg
.pt
);
979 if(InBtn
!= (CurBtn
== OrigBtn
))
981 UserDrawCaptionButton( hWnd
, GetWindowDC(hWnd
), (CurBtn
== OrigBtn
) , Btn
);
983 InBtn
= CurBtn
== OrigBtn
;
989 UserDrawCaptionButton( hWnd
, GetWindowDC(hWnd
), FALSE
, Btn
);
991 SendMessageA(hWnd
, WM_SYSCOMMAND
, SCMsg
, 0);
996 DefWndDoScrollBarDown(HWND hWnd
, UINT Msg
, WPARAM wParam
, LPARAM lParam
)
1000 Point
.x
= SLOWORD(lParam
);
1001 Point
.y
= SHIWORD(lParam
);
1003 hit
= SCROLL_HitTest(hWnd
, (wParam
== HTHSCROLL
) ? SB_HORZ
: SB_VERT
, Point
, FALSE
);
1006 DbgPrint("SCROLL_HitTest() == 0x%x\n", hit
);
1008 SendMessageA(hWnd
, WM_SYSCOMMAND
, Msg
+ (UINT
)wParam
, lParam
);
1012 DefWndHandleLButtonDownNC(HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
1018 HWND hTopWnd
= GetAncestor(hWnd
, GA_ROOT
);
1019 if (SetActiveWindow(hTopWnd
) || GetActiveWindow() == hTopWnd
)
1021 SendMessageA(hWnd
, WM_SYSCOMMAND
, SC_MOVE
+ HTCAPTION
, lParam
);
1027 if (GetWindowLongW(hWnd
, GWL_STYLE
) & WS_SYSMENU
)
1029 if (!(GetWindowLongW(hWnd
, GWL_STYLE
) & WS_MINIMIZE
))
1031 HDC hDC
= GetWindowDC(hWnd
);
1032 // UserDrawSysMenuButton(hWnd, hDC, TRUE);
1033 ReleaseDC(hWnd
, hDC
);
1035 SendMessageA(hWnd
, WM_SYSCOMMAND
, SC_MOUSEMENU
+ HTSYSMENU
,
1042 SendMessageA(hWnd
, WM_SYSCOMMAND
, SC_MOUSEMENU
+ HTMENU
, lParam
);
1047 DefWndDoScrollBarDown(hWnd
, SC_HSCROLL
, HTHSCROLL
, lParam
);
1048 //SendMessageA(hWnd, WM_SYSCOMMAND, SC_HSCROLL + HTHSCROLL, lParam);
1053 DefWndDoScrollBarDown(hWnd
, SC_VSCROLL
, HTVSCROLL
, lParam
);
1054 //SendMessageA(hWnd, WM_SYSCOMMAND, SC_VSCROLL + HTVSCROLL, lParam);
1061 DefWndDoButton(hWnd
, wParam
);
1073 SendMessageA(hWnd
, WM_SYSCOMMAND
, SC_SIZE
+ wParam
- 2, lParam
);
1082 DefWndHandleLButtonDblClkNC(HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
1090 DefWndHandleLButtonUpNC(HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
1098 DefWndHandleActiveNC(HWND hWnd
, WPARAM wParam
)
1106 DefWndSetRedraw(HWND hWnd
, WPARAM wParam
)
1113 DefWndHandleSetCursor(HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
1115 /* Not for child windows. */
1116 if (hWnd
!= (HWND
)wParam
)
1121 switch(LOWORD(lParam
))
1125 WORD Msg
= HIWORD(lParam
);
1126 if (Msg
== WM_LBUTTONDOWN
|| Msg
== WM_MBUTTONDOWN
||
1127 Msg
== WM_RBUTTONDOWN
|| Msg
== WM_XBUTTONDOWN
)
1136 HICON hCursor
= (HICON
)GetClassLongW(hWnd
, GCL_HCURSOR
);
1148 return((LRESULT
)SetCursor(LoadCursorW(0, IDC_SIZEWE
)));
1154 return((LRESULT
)SetCursor(LoadCursorW(0, IDC_SIZENS
)));
1160 return((LRESULT
)SetCursor(LoadCursorW(0, IDC_SIZENWSE
)));
1166 return((LRESULT
)SetCursor(LoadCursorW(0, IDC_SIZENESW
)));
1169 return((LRESULT
)SetCursor(LoadCursorW(0, IDC_ARROW
)));
1173 DefWndStartSizeMove(HWND hWnd
, WPARAM wParam
, POINT
*capturePoint
)
1179 ULONG Style
= GetWindowLongW(hWnd
, GWL_STYLE
);
1181 GetWindowRect(hWnd
, &rectWindow
);
1183 if ((wParam
& 0xfff0) == SC_MOVE
)
1185 /* Move pointer at the center of the caption */
1187 UserGetInsideRectNC(hWnd
, &rect
);
1188 if (Style
& WS_SYSMENU
)
1189 rect
.left
+= GetSystemMetrics(SM_CXSIZE
) + 1;
1190 if (Style
& WS_MINIMIZEBOX
)
1191 rect
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
1192 if (Style
& WS_MAXIMIZEBOX
)
1193 rect
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
1194 pt
.x
= rectWindow
.left
+ (rect
.right
- rect
.left
) / 2;
1195 pt
.y
= rectWindow
.top
+ rect
.top
+ GetSystemMetrics(SM_CYSIZE
)/2;
1196 hittest
= HTCAPTION
;
1203 GetMessageW(&msg
, NULL
, 0, 0);
1207 hittest
= DefWndHitTestNC(hWnd
, msg
.pt
);
1208 if ((hittest
< HTLEFT
) || (hittest
> HTBOTTOMRIGHT
))
1220 pt
.x
=(rectWindow
.left
+rectWindow
.right
)/2;
1221 pt
.y
= rectWindow
.top
+ GetSystemMetrics(SM_CYFRAME
) / 2;
1225 pt
.x
=(rectWindow
.left
+rectWindow
.right
)/2;
1226 pt
.y
= rectWindow
.bottom
- GetSystemMetrics(SM_CYFRAME
) / 2;
1230 pt
.x
= rectWindow
.left
+ GetSystemMetrics(SM_CXFRAME
) / 2;
1231 pt
.y
=(rectWindow
.top
+rectWindow
.bottom
)/2;
1235 pt
.x
= rectWindow
.right
- GetSystemMetrics(SM_CXFRAME
) / 2;
1236 pt
.y
=(rectWindow
.top
+rectWindow
.bottom
)/2;
1239 case VK_ESCAPE
: return 0;
1245 SetCursorPos( pt
.x
, pt
.y
);
1246 DefWndHandleSetCursor(hWnd
, (WPARAM
)hWnd
, MAKELONG(hittest
, WM_MOUSEMOVE
));
1250 #define ON_LEFT_BORDER(hit) \
1251 (((hit) == HTLEFT) || ((hit) == HTTOPLEFT) || ((hit) == HTBOTTOMLEFT))
1252 #define ON_RIGHT_BORDER(hit) \
1253 (((hit) == HTRIGHT) || ((hit) == HTTOPRIGHT) || ((hit) == HTBOTTOMRIGHT))
1254 #define ON_TOP_BORDER(hit) \
1255 (((hit) == HTTOP) || ((hit) == HTTOPLEFT) || ((hit) == HTTOPRIGHT))
1256 #define ON_BOTTOM_BORDER(hit) \
1257 (((hit) == HTBOTTOM) || ((hit) == HTBOTTOMLEFT) || ((hit) == HTBOTTOMRIGHT))
1260 UserDrawWindowFrame(HDC hdc
, const RECT
*rect
,
1261 ULONG width
, ULONG height
, DWORD rop
)
1263 HBRUSH hbrush
= SelectObject( hdc
, GetStockObject( GRAY_BRUSH
) );
1264 PatBlt( hdc
, rect
->left
, rect
->top
,
1265 rect
->right
- rect
->left
- width
, height
, rop
);
1266 PatBlt( hdc
, rect
->left
, rect
->top
+ height
, width
,
1267 rect
->bottom
- rect
->top
- height
, rop
);
1268 PatBlt( hdc
, rect
->left
+ width
, rect
->bottom
- 1,
1269 rect
->right
- rect
->left
- width
, -height
, rop
);
1270 PatBlt( hdc
, rect
->right
- 1, rect
->top
, -width
,
1271 rect
->bottom
- rect
->top
- height
, rop
);
1272 SelectObject( hdc
, hbrush
);
1276 UserDrawMovingFrame(HDC hdc
, RECT
*rect
, BOOL thickframe
)
1280 UserDrawWindowFrame(hdc
, rect
, GetSystemMetrics(SM_CXFRAME
),
1281 GetSystemMetrics(SM_CYFRAME
), PATINVERT
);
1283 else DrawFocusRect( hdc
, rect
);
1287 DefWndDoSizeMove(HWND hwnd
, WORD wParam
)
1290 RECT sizingRect
, mouseRect
, origRect
;
1292 LONG hittest
= (LONG
)(wParam
& 0x0f);
1293 HCURSOR hDragCursor
= 0, hOldCursor
= 0;
1294 POINT minTrack
, maxTrack
;
1295 POINT capturePoint
, pt
;
1296 ULONG Style
= GetWindowLongW(hwnd
, GWL_STYLE
);
1297 ULONG ExStyle
= GetWindowLongW(hwnd
, GWL_EXSTYLE
);
1298 BOOL thickframe
= UserHasThickFrameStyle(Style
, ExStyle
);
1299 BOOL iconic
= Style
& WS_MINIMIZE
;
1301 DWORD dwPoint
= GetMessagePos();
1302 BOOL DragFullWindows
= FALSE
;
1305 SystemParametersInfoA(SPI_GETDRAGFULLWINDOWS
, 0, &DragFullWindows
, 0);
1307 pt
.x
= SLOWORD(dwPoint
);
1308 pt
.y
= SHIWORD(dwPoint
);
1311 if (IsZoomed(hwnd
) || !IsWindowVisible(hwnd
))
1316 if ((wParam
& 0xfff0) == SC_MOVE
)
1320 hittest
= DefWndStartSizeMove(hwnd
, wParam
, &capturePoint
);
1333 if (hittest
&& hittest
!= HTSYSMENU
)
1340 hittest
= DefWndStartSizeMove(hwnd
, wParam
, &capturePoint
);
1349 if (Style
& WS_CHILD
)
1351 hWndParent
= GetParent(hwnd
);
1354 /* Get min/max info */
1356 WinPosGetMinMaxInfo(hwnd
, NULL
, NULL
, &minTrack
, &maxTrack
);
1357 GetWindowRect(hwnd
, &sizingRect
);
1358 if (Style
& WS_CHILD
)
1360 MapWindowPoints( 0, hWndParent
, (LPPOINT
)&sizingRect
, 2 );
1361 GetClientRect(hWndParent
, &mouseRect
);
1365 SetRect(&mouseRect
, 0, 0, GetSystemMetrics(SM_CXSCREEN
),
1366 GetSystemMetrics(SM_CYSCREEN
));
1368 origRect
= sizingRect
;
1369 if (ON_LEFT_BORDER(hittest
))
1371 mouseRect
.left
= max( mouseRect
.left
, sizingRect
.right
-maxTrack
.x
);
1372 mouseRect
.right
= min( mouseRect
.right
, sizingRect
.right
-minTrack
.x
);
1374 else if (ON_RIGHT_BORDER(hittest
))
1376 mouseRect
.left
= max( mouseRect
.left
, sizingRect
.left
+minTrack
.x
);
1377 mouseRect
.right
= min( mouseRect
.right
, sizingRect
.left
+maxTrack
.x
);
1379 if (ON_TOP_BORDER(hittest
))
1381 mouseRect
.top
= max( mouseRect
.top
, sizingRect
.bottom
-maxTrack
.y
);
1382 mouseRect
.bottom
= min( mouseRect
.bottom
,sizingRect
.bottom
-minTrack
.y
);
1384 else if (ON_BOTTOM_BORDER(hittest
))
1386 mouseRect
.top
= max( mouseRect
.top
, sizingRect
.top
+minTrack
.y
);
1387 mouseRect
.bottom
= min( mouseRect
.bottom
, sizingRect
.top
+maxTrack
.y
);
1389 if (Style
& WS_CHILD
)
1391 MapWindowPoints( hWndParent
, 0, (LPPOINT
)&mouseRect
, 2 );
1393 SendMessageA( hwnd
, WM_ENTERSIZEMOVE
, 0, 0 );
1395 if (GetCapture() != hwnd
) SetCapture( hwnd
);
1397 if (Style
& WS_CHILD
)
1399 /* Retrieve a default cache DC (without using the window style) */
1400 hdc
= GetDCEx(hWndParent
, 0, DCX_CACHE
);
1407 if( iconic
) /* create a cursor for dragging */
1409 HICON hIcon
= (HICON
)GetClassLongW(hwnd
, GCL_HICON
);
1410 if(!hIcon
) hIcon
= (HICON
)SendMessageW( hwnd
, WM_QUERYDRAGICON
, 0, 0L);
1411 if( hIcon
) hDragCursor
= CursorIconToCursor( hIcon
, TRUE
);
1412 if( !hDragCursor
) iconic
= FALSE
;
1415 /* invert frame if WIN31_LOOK to indicate mouse click on caption */
1416 if( !iconic
&& !DragFullWindows
)
1418 UserDrawMovingFrame( hdc
, &sizingRect
, thickframe
);
1425 GetMessageW(&msg
, 0, 0, 0);
1427 /* Exit on button-up, Return, or Esc */
1428 if ((msg
.message
== WM_LBUTTONUP
) ||
1429 ((msg
.message
== WM_KEYDOWN
) &&
1430 ((msg
.wParam
== VK_RETURN
) || (msg
.wParam
== VK_ESCAPE
)))) break;
1432 if (msg
.message
== WM_PAINT
)
1434 if(!iconic
&& !DragFullWindows
) UserDrawMovingFrame( hdc
, &sizingRect
, thickframe
);
1435 UpdateWindow( msg
.hwnd
);
1436 if(!iconic
&& !DragFullWindows
) UserDrawMovingFrame( hdc
, &sizingRect
, thickframe
);
1440 if ((msg
.message
!= WM_KEYDOWN
) && (msg
.message
!= WM_MOUSEMOVE
))
1441 continue; /* We are not interested in other messages */
1445 if (msg
.message
== WM_KEYDOWN
) switch(msg
.wParam
)
1447 case VK_UP
: pt
.y
-= 8; break;
1448 case VK_DOWN
: pt
.y
+= 8; break;
1449 case VK_LEFT
: pt
.x
-= 8; break;
1450 case VK_RIGHT
: pt
.x
+= 8; break;
1453 pt
.x
= max( pt
.x
, mouseRect
.left
);
1454 pt
.x
= min( pt
.x
, mouseRect
.right
);
1455 pt
.y
= max( pt
.y
, mouseRect
.top
);
1456 pt
.y
= min( pt
.y
, mouseRect
.bottom
);
1458 dx
= pt
.x
- capturePoint
.x
;
1459 dy
= pt
.y
- capturePoint
.y
;
1467 if( iconic
) /* ok, no system popup tracking */
1469 hOldCursor
= SetCursor(hDragCursor
);
1471 WinPosShowIconTitle( hwnd
, FALSE
);
1475 if (msg
.message
== WM_KEYDOWN
) SetCursorPos( pt
.x
, pt
.y
);
1478 RECT newRect
= sizingRect
;
1479 WPARAM wpSizingHit
= 0;
1481 if (hittest
== HTCAPTION
) OffsetRect( &newRect
, dx
, dy
);
1482 if (ON_LEFT_BORDER(hittest
)) newRect
.left
+= dx
;
1483 else if (ON_RIGHT_BORDER(hittest
)) newRect
.right
+= dx
;
1484 if (ON_TOP_BORDER(hittest
)) newRect
.top
+= dy
;
1485 else if (ON_BOTTOM_BORDER(hittest
)) newRect
.bottom
+= dy
;
1486 if(!iconic
&& !DragFullWindows
) UserDrawMovingFrame( hdc
, &sizingRect
, thickframe
);
1489 /* determine the hit location */
1490 if (hittest
>= HTLEFT
&& hittest
<= HTBOTTOMRIGHT
)
1491 wpSizingHit
= WMSZ_LEFT
+ (hittest
- HTLEFT
);
1492 SendMessageA( hwnd
, WM_SIZING
, wpSizingHit
, (LPARAM
)&newRect
);
1496 if(!DragFullWindows
)
1497 UserDrawMovingFrame( hdc
, &newRect
, thickframe
);
1499 /* To avoid any deadlocks, all the locks on the windows
1500 structures must be suspended before the SetWindowPos */
1501 SetWindowPos( hwnd
, 0, newRect
.left
, newRect
.top
,
1502 newRect
.right
- newRect
.left
,
1503 newRect
.bottom
- newRect
.top
,
1504 ( hittest
== HTCAPTION
) ? SWP_NOSIZE
: 0 );
1507 sizingRect
= newRect
;
1515 if( moved
) /* restore cursors, show icon title later on */
1517 ShowCursor( FALSE
);
1518 SetCursor( hOldCursor
);
1520 DestroyCursor( hDragCursor
);
1522 else if(!DragFullWindows
)
1523 UserDrawMovingFrame( hdc
, &sizingRect
, thickframe
);
1525 if (Style
& WS_CHILD
)
1526 ReleaseDC( hWndParent
, hdc
);
1528 ReleaseDC( 0, hdc
);
1530 SendMessageA( hwnd
, WM_EXITSIZEMOVE
, 0, 0 );
1531 SendMessageA( hwnd
, WM_SETVISIBLE
, !IsIconic(hwnd
), 0L);
1533 /* window moved or resized */
1536 /* if the moving/resizing isn't canceled call SetWindowPos
1537 * with the new position or the new size of the window
1539 if (!((msg
.message
== WM_KEYDOWN
) && (msg
.wParam
== VK_ESCAPE
)) )
1541 /* NOTE: SWP_NOACTIVATE prevents document window activation in Word 6 */
1542 if(!DragFullWindows
)
1543 SetWindowPos( hwnd
, 0, sizingRect
.left
, sizingRect
.top
,
1544 sizingRect
.right
- sizingRect
.left
,
1545 sizingRect
.bottom
- sizingRect
.top
,
1546 ( hittest
== HTCAPTION
) ? SWP_NOSIZE
: 0 );
1548 else { /* restore previous size/position */
1550 SetWindowPos( hwnd
, 0, origRect
.left
, origRect
.top
,
1551 origRect
.right
- origRect
.left
,
1552 origRect
.bottom
- origRect
.top
,
1553 ( hittest
== HTCAPTION
) ? SWP_NOSIZE
: 0 );
1557 if( IsWindow(hwnd
) )
1558 if( Style
& WS_MINIMIZE
)
1560 /* Single click brings up the system menu when iconized */
1564 if( Style
& WS_SYSMENU
)
1565 SendMessageA( hwnd
, WM_SYSCOMMAND
,
1566 SC_MOUSEMENU
+ HTSYSMENU
, MAKELONG(pt
.x
,pt
.y
));
1568 else WinPosShowIconTitle( hwnd
, TRUE
);
1574 DefWndHandleSysCommand(HWND hWnd
, WPARAM wParam
, POINT Pt
)
1576 switch (wParam
& 0xfff0)
1580 DefWndDoSizeMove(hWnd
, wParam
);
1583 SendMessageA(hWnd
, WM_CLOSE
, 0, 0);
1586 MenuTrackMouseMenuBar(hWnd
, wParam
, Pt
);
1589 MenuTrackKbdMenuBar(hWnd
, wParam
, Pt
.x
);
1592 /* FIXME: Implement */
1602 DefWndAdjustRect(RECT
* Rect
, ULONG Style
, BOOL Menu
, ULONG ExStyle
)
1604 if (Style
& WS_ICONIC
)
1609 if (UserHasThickFrameStyle(Style
, ExStyle
))
1611 InflateRect(Rect
, GetSystemMetrics(SM_CXFRAME
),
1612 GetSystemMetrics(SM_CYFRAME
));
1614 else if (UserHasDlgFrameStyle(Style
, ExStyle
))
1616 InflateRect(Rect
, GetSystemMetrics(SM_CXDLGFRAME
),
1617 GetSystemMetrics(SM_CYDLGFRAME
));
1619 else if (UserHasThinFrameStyle(Style
, ExStyle
))
1621 InflateRect(Rect
, GetSystemMetrics(SM_CXBORDER
),
1622 GetSystemMetrics(SM_CYBORDER
));
1624 if (Style
& WS_CAPTION
)
1626 Rect
->top
-= (GetSystemMetrics(SM_CYCAPTION
) -
1627 GetSystemMetrics(SM_CYBORDER
)) + 1;
1631 Rect
->top
-= GetSystemMetrics(SM_CYMENU
) + GetSystemMetrics(SM_CYBORDER
);
1636 DefWndNCCalcSize(HWND hWnd
, RECT
* Rect
)
1640 RECT TmpRect
= {0, 0, 0, 0};
1641 ULONG ExStyle
= GetWindowLongW(hWnd
, GWL_EXSTYLE
);
1642 LONG Style
= GetClassLongW(hWnd
, GCL_STYLE
);
1644 if (Style
& CS_VREDRAW
)
1646 Result
|= WVR_VREDRAW
;
1648 if (Style
& CS_HREDRAW
)
1650 Result
|= WVR_HREDRAW
;
1653 Style
= GetWindowLongW(hWnd
, GWL_STYLE
);
1655 if (!(Style
& WS_MINIMIZE
))
1657 DefWndAdjustRect(&TmpRect
, Style
, FALSE
, ExStyle
);
1658 if (Style
& WS_VSCROLL
)
1660 ScrollXY
= GetSystemMetrics(SM_CXVSCROLL
);
1661 DbgPrint("@! %d > %d (%d, %d, %d ,%d)\n", Rect
->right
- Rect
->left
, ScrollXY
, Rect
->left
, Rect
->top
, Rect
->right
, Rect
->bottom
);
1662 if(Rect
->right
- Rect
->left
> ScrollXY
)
1664 TmpRect
.right
+= ScrollXY
- 1;
1665 if (UserHasAnyFrameStyle(Style
, ExStyle
))
1671 if (Style
& WS_HSCROLL
)
1673 ScrollXY
= GetSystemMetrics(SM_CYHSCROLL
);
1674 if(Rect
->bottom
- Rect
->top
> ScrollXY
)
1676 TmpRect
.bottom
+= ScrollXY
- 1;
1677 if (UserHasAnyFrameStyle(Style
, ExStyle
))
1683 Rect
->left
-= TmpRect
.left
;
1684 Rect
->top
-= TmpRect
.top
;
1685 Rect
->right
-= TmpRect
.right
;
1686 Rect
->bottom
-= TmpRect
.bottom
;
1687 if (UserHasMenu(hWnd
, Style
))
1689 Rect
->top
+= MenuGetMenuBarHeight(hWnd
, Rect
->right
- Rect
->left
,
1690 -TmpRect
.left
, -TmpRect
.top
) + 1;
1692 if (Rect
->top
> Rect
->bottom
)
1693 Rect
->bottom
= Rect
->top
;
1694 if (Rect
->left
> Rect
->right
)
1695 Rect
->right
= Rect
->left
;
1702 DefWndHandleWindowPosChanging(HWND hWnd
, WINDOWPOS
* Pos
)
1704 POINT maxSize
, minTrack
;
1705 LONG style
= GetWindowLongA(hWnd
, GWL_STYLE
);
1707 if (Pos
->flags
& SWP_NOSIZE
) return 0;
1708 if ((style
& WS_THICKFRAME
) || ((style
& (WS_POPUP
| WS_CHILD
)) == 0))
1710 WinPosGetMinMaxInfo(hWnd
, &maxSize
, NULL
, &minTrack
, NULL
);
1711 Pos
->cx
= min(Pos
->cx
, maxSize
.x
);
1712 Pos
->cy
= min(Pos
->cy
, maxSize
.y
);
1713 if (!(style
& WS_MINIMIZE
))
1715 if (Pos
->cx
< minTrack
.x
) Pos
->cx
= minTrack
.x
;
1716 if (Pos
->cy
< minTrack
.y
) Pos
->cy
= minTrack
.y
;
1722 /* Undocumented flags. */
1723 #define SWP_NOCLIENTMOVE 0x0800
1724 #define SWP_NOCLIENTSIZE 0x1000
1727 DefWndHandleWindowPosChanged(HWND hWnd
, WINDOWPOS
* Pos
)
1731 GetClientRect(hWnd
, &rect
);
1733 if (!(Pos
->flags
& SWP_NOCLIENTMOVE
))
1734 SendMessageW(hWnd
, WM_MOVE
, 0, MAKELONG(rect
.left
, rect
.top
));
1736 if (!(Pos
->flags
& SWP_NOCLIENTSIZE
))
1738 WPARAM wp
= SIZE_RESTORED
;
1739 if (IsZoomed(hWnd
)) wp
= SIZE_MAXIMIZED
;
1740 else if (IsIconic(hWnd
)) wp
= SIZE_MINIMIZED
;
1741 SendMessageW(hWnd
, WM_SIZE
, wp
,
1742 MAKELONG(rect
.right
- rect
.left
, rect
.bottom
- rect
.top
));
1748 /***********************************************************************
1749 * DefWndControlColor
1751 * Default colors for control painting.
1754 DefWndControlColor(HDC hDC
, UINT ctlType
)
1756 if (CTLCOLOR_SCROLLBAR
== ctlType
)
1758 HBRUSH hb
= GetSysColorBrush(COLOR_SCROLLBAR
);
1759 COLORREF bk
= GetSysColor(COLOR_3DHILIGHT
);
1760 SetTextColor(hDC
, GetSysColor(COLOR_3DFACE
));
1761 SetBkColor(hDC
, bk
);
1763 /* if COLOR_WINDOW happens to be the same as COLOR_3DHILIGHT
1764 * we better use 0x55aa bitmap brush to make scrollbar's background
1765 * look different from the window background.
1767 if (bk
== GetSysColor(COLOR_WINDOW
))
1770 return CACHE_GetPattern55AABrush();
1775 UnrealizeObject(hb
);
1779 SetTextColor(hDC
, GetSysColor(COLOR_WINDOWTEXT
));
1781 if ((CTLCOLOR_EDIT
== ctlType
) || (CTLCOLOR_LISTBOX
== ctlType
))
1783 SetBkColor(hDC
, GetSysColor(COLOR_WINDOW
));
1787 SetBkColor(hDC
, GetSysColor(COLOR_3DFACE
));
1788 return GetSysColorBrush(COLOR_3DFACE
);
1791 return GetSysColorBrush(COLOR_WINDOW
);
1796 User32DefWindowProc(HWND hWnd
,
1806 return (DefWndPaintNC(hWnd
, (HRGN
)wParam
));
1811 return (DefWndNCCalcSize(hWnd
, (RECT
*)lParam
));
1814 case WM_WINDOWPOSCHANGING
:
1816 return (DefWndHandleWindowPosChanging(hWnd
, (WINDOWPOS
*)lParam
));
1819 case WM_WINDOWPOSCHANGED
:
1821 return (DefWndHandleWindowPosChanged(hWnd
, (WINDOWPOS
*)lParam
));
1827 Point
.x
= SLOWORD(lParam
);
1828 Point
.y
= SHIWORD(lParam
);
1829 return (DefWndHitTestNC(hWnd
, Point
));
1832 case WM_NCLBUTTONDOWN
:
1834 return (DefWndHandleLButtonDownNC(hWnd
, wParam
, lParam
));
1837 case WM_NCLBUTTONUP
:
1839 return (DefWndHandleLButtonUpNC(hWnd
, wParam
, lParam
));
1842 case WM_LBUTTONDBLCLK
:
1843 case WM_NCLBUTTONDBLCLK
:
1845 return (DefWndHandleLButtonDblClkNC(hWnd
, wParam
, lParam
));
1848 case WM_NCRBUTTONDOWN
:
1850 if (wParam
== HTCAPTION
)
1860 if (hWnd
== GetCapture())
1864 Pt
.x
= SLOWORD(lParam
);
1865 Pt
.y
= SHIWORD(lParam
);
1866 ClientToScreen(hWnd
, &Pt
);
1867 lParam
= MAKELPARAM(Pt
.x
, Pt
.y
);
1870 SendMessageW(hWnd
, WM_CONTEXTMENU
, (WPARAM
)hWnd
, lParam
);
1874 SendMessageA(hWnd
, WM_CONTEXTMENU
, (WPARAM
)hWnd
, lParam
);
1879 case WM_CONTEXTMENU
:
1881 if (GetWindowLongW(hWnd
, GWL_STYLE
) & WS_CHILD
)
1885 SendMessageW(GetParent(hWnd
), Msg
, wParam
, lParam
);
1889 SendMessageA(GetParent(hWnd
), WM_CONTEXTMENU
, wParam
, lParam
);
1897 Pt
.x
= SLOWORD(lParam
);
1898 Pt
.y
= SHIWORD(lParam
);
1899 if (GetWindowLongW(hWnd
, GWL_STYLE
) & WS_CHILD
)
1901 ScreenToClient(GetParent(hWnd
), &Pt
);
1904 HitCode
= DefWndHitTestNC(hWnd
, Pt
);
1906 if (HitCode
== HTCAPTION
|| HitCode
== HTSYSMENU
)
1908 TrackPopupMenu(GetSystemMenu(hWnd
, FALSE
),
1909 TPM_LEFTBUTTON
| TPM_RIGHTBUTTON
,
1910 Pt
.x
, Pt
.y
, 0, hWnd
, NULL
);
1918 return (DefWndHandleActiveNC(hWnd
, wParam
));
1923 /* FIXME: Implement. */
1931 HDC hDC
= BeginPaint(hWnd
, &Ps
);
1935 if (GetWindowLongW(hWnd
, GWL_STYLE
) & WS_MINIMIZE
&&
1936 (hIcon
= (HICON
)GetClassLongW(hWnd
, GCL_HICON
)) != NULL
)
1940 GetWindowRect(hWnd
, &WindowRect
);
1941 x
= (WindowRect
.right
- WindowRect
.left
-
1942 GetSystemMetrics(SM_CXICON
)) / 2;
1943 y
= (WindowRect
.bottom
- WindowRect
.top
-
1944 GetSystemMetrics(SM_CYICON
)) / 2;
1945 DrawIcon(hDC
, x
, y
, hIcon
);
1947 if (GetWindowLongW(hWnd
, GWL_EXSTYLE
) & WS_EX_CLIENTEDGE
)
1950 GetClientRect(hWnd
, &WindowRect
);
1951 DrawEdge(hDC
, &WindowRect
, EDGE_SUNKEN
, BF_RECT
);
1953 EndPaint(hWnd
, &Ps
);
1961 hRgn
= CreateRectRgn(0, 0, 0, 0);
1962 if (GetUpdateRgn(hWnd
, hRgn
, FALSE
) != NULLREGION
)
1964 RedrawWindow(hWnd
, NULL
, hRgn
,
1965 RDW_ERASENOW
| RDW_ERASE
| RDW_FRAME
|
1974 DefWndSetRedraw(hWnd
, wParam
);
1980 DestroyWindow(hWnd
);
1984 case WM_MOUSEACTIVATE
:
1986 if (GetWindowLongW(hWnd
, GWL_STYLE
) & WS_CHILD
)
1991 Ret
= SendMessageW(GetParent(hWnd
), WM_MOUSEACTIVATE
,
1996 Ret
= SendMessageA(GetParent(hWnd
), WM_MOUSEACTIVATE
,
2004 return ((LOWORD(lParam
) >= HTCLIENT
) ? MA_ACTIVATE
: MA_NOACTIVATE
);
2009 /* Check if the window is minimized. */
2010 if (LOWORD(lParam
) != WA_INACTIVE
&&
2011 !(GetWindowLongW(hWnd
, GWL_STYLE
) & WS_MINIMIZE
))
2020 if (GetWindowLongW(hWnd
, GWL_STYLE
) & WS_CHILD
)
2024 return (SendMessageW(GetParent(hWnd
), WM_MOUSEWHEEL
,
2029 return (SendMessageA(GetParent(hWnd
), WM_MOUSEWHEEL
,
2037 case WM_ICONERASEBKGND
:
2040 HBRUSH hBrush
= (HBRUSH
)GetClassLongW(hWnd
, GCL_HBRBACKGROUND
);
2046 if (0 == (((DWORD
) hBrush
) & 0xffff0000))
2048 hBrush
= GetSysColorBrush((DWORD
) hBrush
- 1);
2050 GetClipBox((HDC
)wParam
, &Rect
);
2051 FillRect((HDC
)wParam
, &Rect
, hBrush
);
2055 case WM_CTLCOLORMSGBOX
:
2056 case WM_CTLCOLOREDIT
:
2057 case WM_CTLCOLORLISTBOX
:
2058 case WM_CTLCOLORBTN
:
2059 case WM_CTLCOLORDLG
:
2060 case WM_CTLCOLORSTATIC
:
2061 case WM_CTLCOLORSCROLLBAR
:
2062 return (LRESULT
) DefWndControlColor((HDC
)wParam
, Msg
- WM_CTLCOLORMSGBOX
);
2066 if (GetWindowLongW(hWnd
, GWL_STYLE
) & WS_CHILD
)
2068 if (LOWORD(lParam
) < HTLEFT
|| LOWORD(lParam
) > HTBOTTOMRIGHT
)
2073 bResult
= SendMessageW(GetParent(hWnd
), WM_SETCURSOR
,
2078 bResult
= SendMessageA(GetParent(hWnd
), WM_SETCURSOR
,
2087 return (DefWndHandleSetCursor(hWnd
, wParam
, lParam
));
2093 Pt
.x
= SLOWORD(lParam
);
2094 Pt
.y
= SHIWORD(lParam
);
2095 return (DefWndHandleSysCommand(hWnd
, wParam
, Pt
));
2098 /* FIXME: Handle key messages. */
2106 /* FIXME: This is also incomplete. */
2109 if (HIWORD(lParam
) & KEYDATA_ALT
)
2111 if (wParam
== VK_F4
) /* Try to close the window */
2113 HWND top
= GetAncestor(hWnd
, GA_ROOT
);
2114 if (!(GetClassLongW(top
, GCL_STYLE
) & CS_NOCLOSE
))
2117 PostMessageW(top
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
2119 PostMessageA(top
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
2132 Style
= GetWindowLongW(hWnd
, GWL_STYLE
);
2133 if (!(Style
& WS_POPUP
))
2135 if ((Style
& WS_VISIBLE
) && wParam
)
2137 if (!(Style
& WS_VISIBLE
) && !wParam
)
2139 if (!GetWindow(hWnd
, GW_OWNER
))
2141 ShowWindow(hWnd
, wParam
? SW_SHOWNA
: SW_HIDE
);
2147 /* FIXME: Check for a desktop. */
2148 if (GetCapture() == hWnd
)
2160 /* FIXME: Implement this. */
2163 case WM_QUERYDROPOBJECT
:
2165 if (GetWindowLongW(hWnd
, GWL_EXSTYLE
) & WS_EX_ACCEPTFILES
)
2172 case WM_QUERYDRAGICON
:
2177 hIcon
= (HICON
)GetClassLongW(hWnd
, GCL_HICON
);
2180 return ((LRESULT
)hIcon
);
2182 for (Len
= 1; Len
< 64; Len
++)
2184 if ((hIcon
= LoadIconW(NULL
, MAKEINTRESOURCEW(Len
))) != NULL
)
2186 return((LRESULT
)hIcon
);
2189 return ((LRESULT
)LoadIconW(0, IDI_APPLICATION
));
2192 /* FIXME: WM_ISACTIVEICON */
2194 case WM_NOTIFYFORMAT
:
2196 if (IsWindowUnicode(hWnd
))
2198 return(NFR_UNICODE
);
2208 INT Index
= (wParam
!= 0) ? GCL_HICON
: GCL_HICONSM
;
2209 HICON hOldIcon
= (HICON
)GetClassLongW(hWnd
, Index
);
2210 SetClassLongW(hWnd
, Index
, lParam
);
2211 SetWindowPos(hWnd
, 0, 0, 0, 0, 0,
2212 SWP_FRAMECHANGED
| SWP_NOSIZE
| SWP_NOMOVE
|
2213 SWP_NOACTIVATE
| SWP_NOZORDER
);
2214 return ((LRESULT
)hOldIcon
);
2219 INT Index
= (wParam
!= 0) ? GCL_HICON
: GCL_HICONSM
;
2220 return (GetClassLongW(hWnd
, Index
));
2227 SendMessageW(GetParent(hWnd
), Msg
, wParam
, lParam
);
2231 SendMessageA(GetParent(hWnd
), Msg
, wParam
, lParam
);
2237 case WM_QUERYENDSESSION
:
2247 DefWindowProcA(HWND hWnd
,
2252 static LPSTR WindowTextAtom
= 0;
2259 CREATESTRUCTA
*Cs
= (CREATESTRUCTA
*)lParam
;
2260 if (HIWORD(Cs
->lpszName
))
2262 if (0 == WindowTextAtom
)
2265 (LPSTR
)(ULONG
)GlobalAddAtomA("USER32!WindowTextAtomA");
2267 WindowText
= RtlAllocateHeap(RtlGetProcessHeap(), 0,
2268 strlen(Cs
->lpszName
) * sizeof(CHAR
));
2269 strcpy(WindowText
, Cs
->lpszName
);
2270 SetPropA(hWnd
, WindowTextAtom
, WindowText
);
2275 case WM_GETTEXTLENGTH
:
2277 if (WindowTextAtom
== 0 ||
2278 (WindowText
= GetPropA(hWnd
, WindowTextAtom
)) == NULL
)
2282 return (strlen(WindowText
));
2287 if (WindowTextAtom
== 0 ||
2288 (WindowText
= GetPropA(hWnd
, WindowTextAtom
)) == NULL
)
2292 *((PSTR
)lParam
) = '\0';
2296 strncpy((LPSTR
)lParam
, WindowText
, wParam
);
2297 return (min(wParam
, strlen(WindowText
)));
2302 if (0 == WindowTextAtom
)
2305 (LPSTR
)(DWORD
)GlobalAddAtomA("USER32!WindowTextAtomA");
2307 if (WindowTextAtom
!= 0 &&
2308 (WindowText
= GetPropA(hWnd
, WindowTextAtom
)) == NULL
)
2310 RtlFreeHeap(RtlGetProcessHeap(), 0, WindowText
);
2312 WindowText
= RtlAllocateHeap(RtlGetProcessHeap(), 0,
2313 (strlen((PSTR
)lParam
) + 1) * sizeof(CHAR
));
2314 strcpy(WindowText
, (PSTR
)lParam
);
2315 SetPropA(hWnd
, WindowTextAtom
, WindowText
);
2316 if (0 != (GetWindowLongW(hWnd
, GWL_STYLE
) & WS_CAPTION
))
2318 DefWndPaintNC(hWnd
, (HRGN
) 1);
2324 FIXME: Implement these.
2326 case WM_IME_KEYDOWN:
2328 case WM_IME_STARTCOMPOSITION:
2329 case WM_IME_COMPOSITION:
2330 case WM_IME_ENDCOMPOSITION:
2332 case WM_IME_SETCONTEXT:
2337 if (WindowTextAtom
!= 0 &&
2338 (WindowText
= RemovePropA(hWnd
, WindowTextAtom
)) == NULL
)
2340 RtlFreeHeap(GetProcessHeap(), 0, WindowText
);
2346 return User32DefWindowProc(hWnd
, Msg
, wParam
, lParam
, FALSE
);
2351 DefWindowProcW(HWND hWnd
,
2356 static LPWSTR WindowTextAtom
= 0;
2363 CREATESTRUCTW
* CreateStruct
= (CREATESTRUCTW
*)lParam
;
2364 if (HIWORD(CreateStruct
->lpszName
))
2366 if (0 == WindowTextAtom
)
2369 (LPWSTR
)(DWORD
)GlobalAddAtomW(L
"USER32!WindowTextAtomW");
2371 WindowText
= RtlAllocateHeap(RtlGetProcessHeap(), 0,
2372 wcslen(CreateStruct
->lpszName
) * sizeof(WCHAR
));
2373 wcscpy(WindowText
, CreateStruct
->lpszName
);
2374 SetPropW(hWnd
, WindowTextAtom
, WindowText
);
2379 case WM_GETTEXTLENGTH
:
2381 if (WindowTextAtom
== 0 ||
2382 (WindowText
= GetPropW(hWnd
, WindowTextAtom
)) == NULL
)
2386 return (wcslen(WindowText
));
2391 if (WindowTextAtom
== 0 ||
2392 (WindowText
= GetPropW(hWnd
, WindowTextAtom
)) == NULL
)
2396 ((PWSTR
)lParam
) = '\0';
2400 wcsncpy((PWSTR
)lParam
, WindowText
, wParam
);
2401 return (min(wParam
, wcslen(WindowText
)));
2406 if (WindowTextAtom
== 0)
2409 (LPWSTR
)(DWORD
)GlobalAddAtomW(L
"USER32!WindowTextAtomW");
2411 if (WindowTextAtom
!= 0 &&
2412 (WindowText
= GetPropW(hWnd
, WindowTextAtom
)) == NULL
)
2414 RtlFreeHeap(RtlGetProcessHeap(), 0, WindowText
);
2416 WindowText
= RtlAllocateHeap(RtlGetProcessHeap(), 0,
2417 (wcslen((PWSTR
)lParam
) + 1) * sizeof(WCHAR
));
2418 wcscpy(WindowText
, (PWSTR
)lParam
);
2419 SetPropW(hWnd
, WindowTextAtom
, WindowText
);
2420 if ((GetWindowLongW(hWnd
, GWL_STYLE
) & WS_CAPTION
) == WS_CAPTION
)
2422 DefWndPaintNC(hWnd
, (HRGN
)1);
2429 SendMessageW(hWnd
, WM_CHAR
, wParam
, lParam
);
2433 case WM_IME_SETCONTEXT
:
2441 if (WindowTextAtom
!= 0 &&
2442 (WindowText
= RemovePropW(hWnd
, WindowTextAtom
)) == NULL
)
2444 RtlFreeHeap(RtlGetProcessHeap(), 0, WindowText
);
2450 return User32DefWindowProc(hWnd
, Msg
, wParam
, lParam
, TRUE
);