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 ******************************************************************/
16 #include <wine/debug.h>
17 WINE_DEFAULT_DEBUG_CHANNEL(user32
);
20 #define WM_SETVISIBLE 9
22 #ifndef WM_QUERYDROPOBJECT
23 #define WM_QUERYDROPOBJECT 0x022B
26 LRESULT
DefWndNCPaint(HWND hWnd
, HRGN hRgn
, BOOL Active
);
27 LRESULT
DefWndNCCalcSize(HWND hWnd
, BOOL CalcSizeStruct
, RECT
*Rect
);
28 LRESULT
DefWndNCActivate(HWND hWnd
, WPARAM wParam
);
29 LRESULT
DefWndNCHitTest(HWND hWnd
, POINT Point
);
30 LRESULT
DefWndNCLButtonDown(HWND hWnd
, WPARAM wParam
, LPARAM lParam
);
31 LRESULT
DefWndNCLButtonDblClk(HWND hWnd
, WPARAM wParam
, LPARAM lParam
);
32 void FASTCALL
MenuInitSysMenuPopup(HMENU Menu
, DWORD Style
, DWORD ClsStyle
, LONG HitTest
);
34 /* GLOBALS *******************************************************************/
36 /* Bits in the dwKeyData */
37 #define KEYDATA_ALT 0x2000
38 #define KEYDATA_PREVSTATE 0x4000
40 static short iF10Key
= 0;
41 static short iMenuSysKey
= 0;
43 /* FUNCTIONS *****************************************************************/
46 InitStockObjects(void)
48 /* FIXME - Instead of copying the stuff to usermode we should map the tables to
49 userland. The current implementation has one big flaw: the system color
50 table doesn't get updated when another process changes them. That's why
51 we should rather map the table into usermode. But it only affects the
52 SysColors table - the pens, brushes and stock objects are not affected
53 as their handles never change. But it'd be faster to map them, too. */
62 GetSysColor(int nIndex
)
64 if(nIndex
>= 0 && nIndex
<= NUM_SYSCOLORS
)
66 return g_psi
->SysColors
[nIndex
];
69 SetLastError(ERROR_INVALID_PARAMETER
);
77 GetSysColorPen(int nIndex
)
79 if(nIndex
>= 0 && nIndex
<= NUM_SYSCOLORS
)
81 return g_psi
->SysColorPens
[nIndex
];
84 SetLastError(ERROR_INVALID_PARAMETER
);
92 GetSysColorBrush(int nIndex
)
94 if(nIndex
>= 0 && nIndex
<= NUM_SYSCOLORS
)
96 return g_psi
->SysColorBrushes
[nIndex
];
99 SetLastError(ERROR_INVALID_PARAMETER
);
110 CONST INT
*lpaElements
,
111 CONST COLORREF
*lpaRgbValues
)
120 ChangeSysColors
.Elements
= (INT
*)lpaElements
;
121 ChangeSysColors
.Colors
= (COLORREF
*)lpaRgbValues
;
125 Ret
= NtUserSetSysColors(&ChangeSysColors
, cElements
);
129 SetLastError(ERROR_INVALID_PARAMETER
);
137 UserGetInsideRectNC(PWINDOW Wnd
, RECT
*rect
)
143 ExStyle
= Wnd
->ExStyle
;
145 rect
->top
= rect
->left
= 0;
146 rect
->right
= Wnd
->WindowRect
.right
- Wnd
->WindowRect
.left
;
147 rect
->bottom
= Wnd
->WindowRect
.bottom
- Wnd
->WindowRect
.top
;
149 if (Style
& WS_ICONIC
)
154 /* Remove frame from rectangle */
155 if (UserHasThickFrameStyle(Style
, ExStyle
))
157 InflateRect(rect
, -GetSystemMetrics(SM_CXFRAME
),
158 -GetSystemMetrics(SM_CYFRAME
));
162 if (UserHasDlgFrameStyle(Style
, ExStyle
))
164 InflateRect(rect
, -GetSystemMetrics(SM_CXDLGFRAME
),
165 -GetSystemMetrics(SM_CYDLGFRAME
));
166 /* FIXME: this isn't in NC_AdjustRect? why not? */
167 if (ExStyle
& WS_EX_DLGMODALFRAME
)
168 InflateRect( rect
, -1, 0 );
172 if (UserHasThinFrameStyle(Style
, ExStyle
))
174 InflateRect(rect
, -GetSystemMetrics(SM_CXBORDER
),
175 -GetSystemMetrics(SM_CYBORDER
));
183 DefWndSetRedraw(HWND hWnd
, WPARAM wParam
)
185 LONG Style
= GetWindowLong(hWnd
, GWL_STYLE
);
186 /* Content can be redrawn after a change. */
189 if (!(Style
& WS_VISIBLE
)) /* Not Visible */
191 SetWindowLong(hWnd
, GWL_STYLE
, WS_VISIBLE
);
194 else /* Content cannot be redrawn after a change. */
196 if (Style
& WS_VISIBLE
) /* Visible */
198 RedrawWindow( hWnd
, NULL
, 0, RDW_ALLCHILDREN
| RDW_VALIDATE
);
199 Style
&= ~WS_VISIBLE
;
200 SetWindowLong(hWnd
, GWL_STYLE
, Style
); /* clear bits */
208 DefWndHandleSetCursor(HWND hWnd
, WPARAM wParam
, LPARAM lParam
, ULONG Style
)
210 /* Not for child windows. */
211 if (hWnd
!= (HWND
)wParam
)
216 switch((INT_PTR
) LOWORD(lParam
))
220 WORD Msg
= HIWORD(lParam
);
221 if (Msg
== WM_LBUTTONDOWN
|| Msg
== WM_MBUTTONDOWN
||
222 Msg
== WM_RBUTTONDOWN
|| Msg
== WM_XBUTTONDOWN
)
231 HICON hCursor
= (HICON
)GetClassLongW(hWnd
, GCL_HCURSOR
);
243 if (Style
& WS_MAXIMIZE
)
247 return((LRESULT
)SetCursor(LoadCursorW(0, IDC_SIZEWE
)));
253 if (Style
& WS_MAXIMIZE
)
257 return((LRESULT
)SetCursor(LoadCursorW(0, IDC_SIZENS
)));
263 if (Style
& WS_MAXIMIZE
)
267 return((LRESULT
)SetCursor(LoadCursorW(0, IDC_SIZENWSE
)));
273 if (GetWindowLongW(hWnd
, GWL_STYLE
) & WS_MAXIMIZE
)
277 return((LRESULT
)SetCursor(LoadCursorW(0, IDC_SIZENESW
)));
280 return((LRESULT
)SetCursor(LoadCursorW(0, IDC_ARROW
)));
284 DefWndStartSizeMove(HWND hWnd
, PWINDOW Wnd
, WPARAM wParam
, POINT
*capturePoint
)
290 ULONG Style
= Wnd
->Style
;
292 rectWindow
= Wnd
->WindowRect
;
294 if ((wParam
& 0xfff0) == SC_MOVE
)
296 /* Move pointer at the center of the caption */
298 UserGetInsideRectNC(Wnd
, &rect
);
299 if (Style
& WS_SYSMENU
)
300 rect
.left
+= GetSystemMetrics(SM_CXSIZE
) + 1;
301 if (Style
& WS_MINIMIZEBOX
)
302 rect
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
303 if (Style
& WS_MAXIMIZEBOX
)
304 rect
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
305 pt
.x
= rectWindow
.left
+ (rect
.right
- rect
.left
) / 2;
306 pt
.y
= rectWindow
.top
+ rect
.top
+ GetSystemMetrics(SM_CYSIZE
)/2;
315 if (GetMessageW(&msg
, NULL
, 0, 0) <= 0)
320 hittest
= DefWndNCHitTest(hWnd
, msg
.pt
);
321 if ((hittest
< HTLEFT
) || (hittest
> HTBOTTOMRIGHT
))
333 pt
.x
=(rectWindow
.left
+rectWindow
.right
)/2;
334 pt
.y
= rectWindow
.top
+ GetSystemMetrics(SM_CYFRAME
) / 2;
338 pt
.x
=(rectWindow
.left
+rectWindow
.right
)/2;
339 pt
.y
= rectWindow
.bottom
- GetSystemMetrics(SM_CYFRAME
) / 2;
343 pt
.x
= rectWindow
.left
+ GetSystemMetrics(SM_CXFRAME
) / 2;
344 pt
.y
=(rectWindow
.top
+rectWindow
.bottom
)/2;
348 pt
.x
= rectWindow
.right
- GetSystemMetrics(SM_CXFRAME
) / 2;
349 pt
.y
=(rectWindow
.top
+rectWindow
.bottom
)/2;
352 case VK_ESCAPE
: return 0;
358 SetCursorPos( pt
.x
, pt
.y
);
359 DefWndHandleSetCursor(hWnd
, (WPARAM
)hWnd
, MAKELONG(hittest
, WM_MOUSEMOVE
), Style
);
363 #define ON_LEFT_BORDER(hit) \
364 (((hit) == HTLEFT) || ((hit) == HTTOPLEFT) || ((hit) == HTBOTTOMLEFT))
365 #define ON_RIGHT_BORDER(hit) \
366 (((hit) == HTRIGHT) || ((hit) == HTTOPRIGHT) || ((hit) == HTBOTTOMRIGHT))
367 #define ON_TOP_BORDER(hit) \
368 (((hit) == HTTOP) || ((hit) == HTTOPLEFT) || ((hit) == HTTOPRIGHT))
369 #define ON_BOTTOM_BORDER(hit) \
370 (((hit) == HTBOTTOM) || ((hit) == HTBOTTOMLEFT) || ((hit) == HTBOTTOMRIGHT))
373 UserDrawWindowFrame(HDC hdc
, const RECT
*rect
,
374 ULONG width
, ULONG height
)
376 static HBRUSH hDraggingRectBrush
= NULL
;
379 if(!hDraggingRectBrush
)
381 static HBITMAP hDraggingPattern
= NULL
;
382 const DWORD Pattern
[4] = {0x5555AAAA, 0x5555AAAA, 0x5555AAAA, 0x5555AAAA};
384 hDraggingPattern
= CreateBitmap(8, 8, 1, 1, Pattern
);
385 hDraggingRectBrush
= CreatePatternBrush(hDraggingPattern
);
388 hbrush
= SelectObject( hdc
, hDraggingRectBrush
);
389 PatBlt( hdc
, rect
->left
, rect
->top
,
390 rect
->right
- rect
->left
- width
, height
, PATINVERT
);
391 PatBlt( hdc
, rect
->left
, rect
->top
+ height
, width
,
392 rect
->bottom
- rect
->top
- height
, PATINVERT
);
393 PatBlt( hdc
, rect
->left
+ width
, rect
->bottom
- 1,
394 rect
->right
- rect
->left
- width
, -height
, PATINVERT
);
395 PatBlt( hdc
, rect
->right
- 1, rect
->top
, -width
,
396 rect
->bottom
- rect
->top
- height
, PATINVERT
);
397 SelectObject( hdc
, hbrush
);
401 UserDrawMovingFrame(HDC hdc
, RECT
*rect
, BOOL thickframe
)
405 UserDrawWindowFrame(hdc
, rect
, GetSystemMetrics(SM_CXFRAME
), GetSystemMetrics(SM_CYFRAME
));
409 UserDrawWindowFrame(hdc
, rect
, 1, 1);
414 DefWndDoSizeMove(HWND hwnd
, WORD wParam
)
418 RECT sizingRect
, mouseRect
, origRect
, clipRect
, unmodRect
;
420 LONG hittest
= (LONG
)(wParam
& 0x0f);
421 HCURSOR hDragCursor
= 0, hOldCursor
= 0;
422 POINT minTrack
, maxTrack
;
423 POINT capturePoint
, pt
;
424 ULONG Style
, ExStyle
;
428 DWORD dwPoint
= GetMessagePos();
429 BOOL DragFullWindows
= FALSE
;
430 HWND hWndParent
= NULL
;
433 Wnd
= ValidateHwnd(hwnd
);
438 ExStyle
= Wnd
->ExStyle
;
439 iconic
= (Style
& WS_MINIMIZE
) != 0;
441 SystemParametersInfoA(SPI_GETDRAGFULLWINDOWS
, 0, &DragFullWindows
, 0);
443 pt
.x
= GET_X_LPARAM(dwPoint
);
444 pt
.y
= GET_Y_LPARAM(dwPoint
);
447 if ((Style
& WS_MAXIMIZE
) || !IsWindowVisible(hwnd
))
452 thickframe
= UserHasThickFrameStyle(Style
, ExStyle
) && !(Style
& WS_MINIMIZE
);
453 if ((wParam
& 0xfff0) == SC_MOVE
)
457 hittest
= DefWndStartSizeMove(hwnd
, Wnd
, wParam
, &capturePoint
);
470 if (hittest
&& ((wParam
& 0xfff0) != SC_MOUSEMENU
))
472 hittest
+= (HTLEFT
- WMSZ_LEFT
);
477 hittest
= DefWndStartSizeMove(hwnd
, Wnd
, wParam
, &capturePoint
);
486 /* Get min/max info */
488 WinPosGetMinMaxInfo(hwnd
, NULL
, NULL
, &minTrack
, &maxTrack
);
489 sizingRect
= Wnd
->WindowRect
;
490 if (Style
& WS_CHILD
)
492 hWndParent
= GetParent(hwnd
);
493 MapWindowPoints( 0, hWndParent
, (LPPOINT
)&sizingRect
, 2 );
494 unmodRect
= sizingRect
;
495 GetClientRect(hWndParent
, &mouseRect
);
496 clipRect
= mouseRect
;
497 MapWindowPoints(hWndParent
, HWND_DESKTOP
, (LPPOINT
)&clipRect
, 2);
501 if(!(ExStyle
& WS_EX_TOPMOST
))
503 SystemParametersInfoW(SPI_GETWORKAREA
, 0, &clipRect
, 0);
504 mouseRect
= clipRect
;
508 SetRect(&mouseRect
, 0, 0, GetSystemMetrics(SM_CXSCREEN
), GetSystemMetrics(SM_CYSCREEN
));
509 clipRect
= mouseRect
;
511 unmodRect
= sizingRect
;
513 ClipCursor(&clipRect
);
515 origRect
= sizingRect
;
516 if (ON_LEFT_BORDER(hittest
))
518 mouseRect
.left
= max( mouseRect
.left
, sizingRect
.right
-maxTrack
.x
);
519 mouseRect
.right
= min( mouseRect
.right
, sizingRect
.right
-minTrack
.x
);
521 else if (ON_RIGHT_BORDER(hittest
))
523 mouseRect
.left
= max( mouseRect
.left
, sizingRect
.left
+minTrack
.x
);
524 mouseRect
.right
= min( mouseRect
.right
, sizingRect
.left
+maxTrack
.x
);
526 if (ON_TOP_BORDER(hittest
))
528 mouseRect
.top
= max( mouseRect
.top
, sizingRect
.bottom
-maxTrack
.y
);
529 mouseRect
.bottom
= min( mouseRect
.bottom
,sizingRect
.bottom
-minTrack
.y
);
531 else if (ON_BOTTOM_BORDER(hittest
))
533 mouseRect
.top
= max( mouseRect
.top
, sizingRect
.top
+minTrack
.y
);
534 mouseRect
.bottom
= min( mouseRect
.bottom
, sizingRect
.top
+maxTrack
.y
);
536 if (Style
& WS_CHILD
)
538 MapWindowPoints( hWndParent
, 0, (LPPOINT
)&mouseRect
, 2 );
541 SendMessageA( hwnd
, WM_ENTERSIZEMOVE
, 0, 0 );
542 (void)NtUserSetGUIThreadHandle(MSQ_STATE_MOVESIZE
, hwnd
);
543 if (GetCapture() != hwnd
) SetCapture( hwnd
);
545 if (Style
& WS_CHILD
)
547 /* Retrieve a default cache DC (without using the window style) */
548 hdc
= GetDCEx(hWndParent
, 0, DCX_CACHE
);
554 DesktopRgn
= CreateRectRgnIndirect(&clipRect
);
557 SelectObject(hdc
, DesktopRgn
);
559 if( iconic
) /* create a cursor for dragging */
561 HICON hIcon
= (HICON
)GetClassLongW(hwnd
, GCL_HICON
);
562 if(!hIcon
) hIcon
= (HICON
)SendMessageW( hwnd
, WM_QUERYDRAGICON
, 0, 0L);
563 if( hIcon
) hDragCursor
= CursorIconToCursor( hIcon
, TRUE
);
564 if( !hDragCursor
) iconic
= FALSE
;
567 /* invert frame if WIN31_LOOK to indicate mouse click on caption */
568 if( !iconic
&& !DragFullWindows
)
570 UserDrawMovingFrame( hdc
, &sizingRect
, thickframe
);
577 if (GetMessageW(&msg
, 0, 0, 0) <= 0)
580 /* Exit on button-up, Return, or Esc */
581 if ((msg
.message
== WM_LBUTTONUP
) ||
582 ((msg
.message
== WM_KEYDOWN
) &&
583 ((msg
.wParam
== VK_RETURN
) || (msg
.wParam
== VK_ESCAPE
)))) break;
585 if (msg
.message
== WM_PAINT
)
587 if(!iconic
&& !DragFullWindows
) UserDrawMovingFrame( hdc
, &sizingRect
, thickframe
);
588 UpdateWindow( msg
.hwnd
);
589 if(!iconic
&& !DragFullWindows
) UserDrawMovingFrame( hdc
, &sizingRect
, thickframe
);
593 if ((msg
.message
!= WM_KEYDOWN
) && (msg
.message
!= WM_MOUSEMOVE
))
594 continue; /* We are not interested in other messages */
598 if (msg
.message
== WM_KEYDOWN
) switch(msg
.wParam
)
600 case VK_UP
: pt
.y
-= 8; break;
601 case VK_DOWN
: pt
.y
+= 8; break;
602 case VK_LEFT
: pt
.x
-= 8; break;
603 case VK_RIGHT
: pt
.x
+= 8; break;
606 pt
.x
= max( pt
.x
, mouseRect
.left
);
607 pt
.x
= min( pt
.x
, mouseRect
.right
);
608 pt
.y
= max( pt
.y
, mouseRect
.top
);
609 pt
.y
= min( pt
.y
, mouseRect
.bottom
);
611 dx
= pt
.x
- capturePoint
.x
;
612 dy
= pt
.y
- capturePoint
.y
;
620 if( iconic
) /* ok, no system popup tracking */
622 hOldCursor
= SetCursor(hDragCursor
);
627 if (msg
.message
== WM_KEYDOWN
) SetCursorPos( pt
.x
, pt
.y
);
630 RECT newRect
= unmodRect
;
631 WPARAM wpSizingHit
= 0;
633 if (hittest
== HTCAPTION
) OffsetRect( &newRect
, dx
, dy
);
634 if (ON_LEFT_BORDER(hittest
)) newRect
.left
+= dx
;
635 else if (ON_RIGHT_BORDER(hittest
)) newRect
.right
+= dx
;
636 if (ON_TOP_BORDER(hittest
)) newRect
.top
+= dy
;
637 else if (ON_BOTTOM_BORDER(hittest
)) newRect
.bottom
+= dy
;
638 if(!iconic
&& !DragFullWindows
) UserDrawMovingFrame( hdc
, &sizingRect
, thickframe
);
641 /* determine the hit location */
642 if (hittest
>= HTLEFT
&& hittest
<= HTBOTTOMRIGHT
)
643 wpSizingHit
= WMSZ_LEFT
+ (hittest
- HTLEFT
);
645 SendMessageA( hwnd
, WM_SIZING
, wpSizingHit
, (LPARAM
)&newRect
);
650 UserDrawMovingFrame( hdc
, &newRect
, thickframe
);
652 /* To avoid any deadlocks, all the locks on the windows
653 structures must be suspended before the SetWindowPos */
654 SetWindowPos( hwnd
, 0, newRect
.left
, newRect
.top
,
655 newRect
.right
- newRect
.left
,
656 newRect
.bottom
- newRect
.top
,
657 ( hittest
== HTCAPTION
) ? SWP_NOSIZE
: 0 );
660 sizingRect
= newRect
;
669 if( moved
) /* restore cursors, show icon title later on */
672 SetCursor( hOldCursor
);
674 DestroyCursor( hDragCursor
);
676 else if(!DragFullWindows
)
677 UserDrawMovingFrame( hdc
, &sizingRect
, thickframe
);
679 if (Style
& WS_CHILD
)
680 ReleaseDC( hWndParent
, hdc
);
686 DeleteObject(DesktopRgn
);
689 (void)NtUserSetGUIThreadHandle(MSQ_STATE_MOVESIZE
, NULL
);
690 SendMessageA( hwnd
, WM_EXITSIZEMOVE
, 0, 0 );
691 SendMessageA( hwnd
, WM_SETVISIBLE
, !IsIconic(hwnd
), 0L);
693 /* window moved or resized */
696 /* if the moving/resizing isn't canceled call SetWindowPos
697 * with the new position or the new size of the window
699 if (!((msg
.message
== WM_KEYDOWN
) && (msg
.wParam
== VK_ESCAPE
)) )
701 /* NOTE: SWP_NOACTIVATE prevents document window activation in Word 6 */
703 SetWindowPos( hwnd
, 0, sizingRect
.left
, sizingRect
.top
,
704 sizingRect
.right
- sizingRect
.left
,
705 sizingRect
.bottom
- sizingRect
.top
,
706 ( hittest
== HTCAPTION
) ? SWP_NOSIZE
: 0 );
708 else { /* restore previous size/position */
710 SetWindowPos( hwnd
, 0, origRect
.left
, origRect
.top
,
711 origRect
.right
- origRect
.left
,
712 origRect
.bottom
- origRect
.top
,
713 ( hittest
== HTCAPTION
) ? SWP_NOSIZE
: 0 );
718 if( Style
& WS_MINIMIZE
)
720 /* Single click brings up the system menu when iconized */
724 if( Style
& WS_SYSMENU
)
725 SendMessageA( hwnd
, WM_SYSCOMMAND
,
726 SC_MOUSEMENU
+ HTSYSMENU
, MAKELONG(pt
.x
,pt
.y
));
732 /***********************************************************************
733 * DefWndTrackScrollBar
735 * Track a mouse button press on the horizontal or vertical scroll-bar.
738 DefWndTrackScrollBar(HWND Wnd
, WPARAM wParam
, POINT Pt
)
742 if (SC_HSCROLL
== (wParam
& 0xfff0))
744 if (HTHSCROLL
!= (wParam
& 0x0f))
750 else /* SC_VSCROLL */
752 if (HTVSCROLL
!= (wParam
& 0x0f))
758 ScrollTrackScrollBar(Wnd
, ScrollBar
, Pt
);
763 DefWndHandleSysCommand(HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
768 switch (wParam
& 0xfff0)
772 DefWndDoSizeMove(hWnd
, wParam
);
775 wp
.length
= sizeof(WINDOWPLACEMENT
);
776 if(GetWindowPlacement(hWnd
, &wp
))
778 wp
.showCmd
= SW_MINIMIZE
;
779 SetWindowPlacement(hWnd
, &wp
);
783 wp
.length
= sizeof(WINDOWPLACEMENT
);
784 if(GetWindowPlacement(hWnd
, &wp
))
786 wp
.showCmd
= SW_MAXIMIZE
;
787 SetWindowPlacement(hWnd
, &wp
);
791 wp
.length
= sizeof(WINDOWPLACEMENT
);
792 if(GetWindowPlacement(hWnd
, &wp
))
794 wp
.showCmd
= SW_RESTORE
;
795 SetWindowPlacement(hWnd
, &wp
);
799 SendMessageA(hWnd
, WM_CLOSE
, 0, 0);
803 Pt
.x
= (short)LOWORD(lParam
);
804 Pt
.y
= (short)HIWORD(lParam
);
805 MenuTrackMouseMenuBar(hWnd
, wParam
& 0x000f, Pt
);
809 MenuTrackKbdMenuBar(hWnd
, wParam
, (WCHAR
)lParam
);
814 Pt
.x
= (short)LOWORD(lParam
);
815 Pt
.y
= (short)HIWORD(lParam
);
816 DefWndTrackScrollBar(hWnd
, wParam
, Pt
);
821 /* FIXME: Implement */
830 DefWndHandleWindowPosChanging(HWND hWnd
, WINDOWPOS
* Pos
)
832 POINT maxTrack
, minTrack
;
833 LONG style
= GetWindowLongA(hWnd
, GWL_STYLE
);
835 if (Pos
->flags
& SWP_NOSIZE
) return 0;
836 if ((style
& WS_THICKFRAME
) || ((style
& (WS_POPUP
| WS_CHILD
)) == 0))
838 WinPosGetMinMaxInfo(hWnd
, NULL
, NULL
, &minTrack
, &maxTrack
);
839 Pos
->cx
= min(Pos
->cx
, maxTrack
.x
);
840 Pos
->cy
= min(Pos
->cy
, maxTrack
.y
);
841 if (!(style
& WS_MINIMIZE
))
843 if (Pos
->cx
< minTrack
.x
) Pos
->cx
= minTrack
.x
;
844 if (Pos
->cy
< minTrack
.y
) Pos
->cy
= minTrack
.y
;
849 Pos
->cx
= max(Pos
->cx
, 0);
850 Pos
->cy
= max(Pos
->cy
, 0);
855 /* Undocumented flags. */
856 #define SWP_NOCLIENTMOVE 0x0800
857 #define SWP_NOCLIENTSIZE 0x1000
860 DefWndHandleWindowPosChanged(HWND hWnd
, WINDOWPOS
* Pos
)
864 GetClientRect(hWnd
, &Rect
);
865 MapWindowPoints(hWnd
, (GetWindowLongW(hWnd
, GWL_STYLE
) & WS_CHILD
?
866 GetParent(hWnd
) : NULL
), (LPPOINT
) &Rect
, 2);
868 if (! (Pos
->flags
& SWP_NOCLIENTMOVE
))
870 SendMessageW(hWnd
, WM_MOVE
, 0, MAKELONG(Rect
.left
, Rect
.top
));
873 if (! (Pos
->flags
& SWP_NOCLIENTSIZE
))
875 WPARAM wp
= SIZE_RESTORED
;
880 else if (IsIconic(hWnd
))
884 SendMessageW(hWnd
, WM_SIZE
, wp
,
885 MAKELONG(Rect
.right
- Rect
.left
, Rect
.bottom
- Rect
.top
));
891 /***********************************************************************
894 * Default colors for control painting.
897 DefWndControlColor(HDC hDC
, UINT ctlType
)
899 if (CTLCOLOR_SCROLLBAR
== ctlType
)
901 HBRUSH hb
= GetSysColorBrush(COLOR_SCROLLBAR
);
902 COLORREF bk
= GetSysColor(COLOR_3DHILIGHT
);
903 SetTextColor(hDC
, GetSysColor(COLOR_3DFACE
));
906 /* if COLOR_WINDOW happens to be the same as COLOR_3DHILIGHT
907 * we better use 0x55aa bitmap brush to make scrollbar's background
908 * look different from the window background.
910 if (bk
== GetSysColor(COLOR_WINDOW
))
912 static const WORD wPattern55AA
[] =
914 0x5555, 0xaaaa, 0x5555, 0xaaaa,
915 0x5555, 0xaaaa, 0x5555, 0xaaaa
917 static HBITMAP hPattern55AABitmap
= NULL
;
918 static HBRUSH hPattern55AABrush
= NULL
;
919 if (hPattern55AABrush
== NULL
)
921 hPattern55AABitmap
= CreateBitmap(8, 8, 1, 1, wPattern55AA
);
922 hPattern55AABrush
= CreatePatternBrush(hPattern55AABitmap
);
924 return hPattern55AABrush
;
930 SetTextColor(hDC
, GetSysColor(COLOR_WINDOWTEXT
));
932 if ((CTLCOLOR_EDIT
== ctlType
) || (CTLCOLOR_LISTBOX
== ctlType
))
934 SetBkColor(hDC
, GetSysColor(COLOR_WINDOW
));
938 SetBkColor(hDC
, GetSysColor(COLOR_3DFACE
));
939 return GetSysColorBrush(COLOR_3DFACE
);
942 return GetSysColorBrush(COLOR_WINDOW
);
945 static void DefWndPrint( HWND hwnd
, HDC hdc
, ULONG uFlags
)
950 if ( (uFlags
& PRF_CHECKVISIBLE
) &&
951 !IsWindowVisible(hwnd
) )
955 * Unimplemented flags.
957 if ( (uFlags
& PRF_CHILDREN
) ||
958 (uFlags
& PRF_OWNED
) ||
959 (uFlags
& PRF_NONCLIENT
) )
961 FIXME("WM_PRINT message with unsupported flags\n");
967 if ( uFlags
& PRF_ERASEBKGND
)
968 SendMessageW(hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
973 if ( uFlags
& PRF_CLIENT
)
974 SendMessageW(hwnd
, WM_PRINTCLIENT
, (WPARAM
)hdc
, PRF_CLIENT
);
978 UserSendUiUpdateMsg(HWND hwnd
, LPARAM lParam
)
980 SendMessageW(hwnd
, WM_UPDATEUISTATE
, (WPARAM
)lParam
, 0);
986 DefWndScreenshot(HWND hWnd
)
998 hdc
= GetWindowDC(hWnd
);
999 GetWindowRect(hWnd
, &rect
);
1000 w
= rect
.right
- rect
.left
;
1001 h
= rect
.bottom
- rect
.top
;
1003 hbitmap
= CreateCompatibleBitmap(hdc
, w
, h
);
1004 hdc2
= CreateCompatibleDC(hdc
);
1005 SelectObject(hdc2
, hbitmap
);
1007 BitBlt(hdc2
, 0, 0, w
, h
,
1011 SetClipboardData(CF_BITMAP
, hbitmap
);
1013 ReleaseDC(hWnd
, hdc
);
1014 ReleaseDC(hWnd
, hdc2
);
1023 User32DefWindowProc(HWND hWnd
,
1033 return DefWndNCPaint(hWnd
, (HRGN
)wParam
, -1);
1038 return DefWndNCCalcSize(hWnd
, (BOOL
)wParam
, (RECT
*)lParam
);
1043 return DefWndNCActivate(hWnd
, wParam
);
1049 Point
.x
= GET_X_LPARAM(lParam
);
1050 Point
.y
= GET_Y_LPARAM(lParam
);
1051 return (DefWndNCHitTest(hWnd
, Point
));
1054 case WM_LBUTTONDOWN
:
1055 case WM_RBUTTONDOWN
:
1056 case WM_MBUTTONDOWN
:
1057 iF10Key
= iMenuSysKey
= 0;
1060 case WM_NCLBUTTONDOWN
:
1062 return (DefWndNCLButtonDown(hWnd
, wParam
, lParam
));
1065 case WM_LBUTTONDBLCLK
:
1066 return (DefWndNCLButtonDblClk(hWnd
, HTCLIENT
, lParam
));
1068 case WM_NCLBUTTONDBLCLK
:
1070 return (DefWndNCLButtonDblClk(hWnd
, wParam
, lParam
));
1073 case WM_WINDOWPOSCHANGING
:
1075 return (DefWndHandleWindowPosChanging(hWnd
, (WINDOWPOS
*)lParam
));
1078 case WM_WINDOWPOSCHANGED
:
1080 return (DefWndHandleWindowPosChanged(hWnd
, (WINDOWPOS
*)lParam
));
1083 case WM_NCRBUTTONDOWN
:
1085 /* in Windows, capture is taken when right-clicking on the caption bar */
1086 if (wParam
== HTCAPTION
)
1096 if (hWnd
== GetCapture())
1100 Pt
.x
= GET_X_LPARAM(lParam
);
1101 Pt
.y
= GET_Y_LPARAM(lParam
);
1102 ClientToScreen(hWnd
, &Pt
);
1103 lParam
= MAKELPARAM(Pt
.x
, Pt
.y
);
1106 SendMessageW(hWnd
, WM_CONTEXTMENU
, (WPARAM
)hWnd
, lParam
);
1110 SendMessageA(hWnd
, WM_CONTEXTMENU
, (WPARAM
)hWnd
, lParam
);
1115 case WM_NCRBUTTONUP
:
1117 * FIXME : we must NOT send WM_CONTEXTMENU on a WM_NCRBUTTONUP (checked
1118 * in Windows), but what _should_ we do? According to MSDN :
1119 * "If it is appropriate to do so, the system sends the WM_SYSCOMMAND
1120 * message to the window". When is it appropriate?
1124 case WM_CONTEXTMENU
:
1126 if (GetWindowLongW(hWnd
, GWL_STYLE
) & WS_CHILD
)
1130 SendMessageW(GetParent(hWnd
), Msg
, wParam
, lParam
);
1134 SendMessageA(GetParent(hWnd
), WM_CONTEXTMENU
, wParam
, lParam
);
1143 Style
= GetWindowLongW(hWnd
, GWL_STYLE
);
1145 Pt
.x
= GET_X_LPARAM(lParam
);
1146 Pt
.y
= GET_Y_LPARAM(lParam
);
1147 if (Style
& WS_CHILD
)
1149 ScreenToClient(GetParent(hWnd
), &Pt
);
1152 HitCode
= DefWndNCHitTest(hWnd
, Pt
);
1154 if (HitCode
== HTCAPTION
|| HitCode
== HTSYSMENU
)
1159 if((SystemMenu
= GetSystemMenu(hWnd
, FALSE
)))
1161 MenuInitSysMenuPopup(SystemMenu
, GetWindowLongW(hWnd
, GWL_STYLE
),
1162 GetClassLongW(hWnd
, GCL_STYLE
), HitCode
);
1164 if(HitCode
== HTCAPTION
)
1165 Flags
= TPM_LEFTBUTTON
| TPM_RIGHTBUTTON
;
1167 Flags
= TPM_LEFTBUTTON
;
1169 TrackPopupMenu(SystemMenu
, Flags
,
1170 Pt
.x
, Pt
.y
, 0, hWnd
, NULL
);
1179 DefWndPrint(hWnd
, (HDC
)wParam
, lParam
);
1187 HDC hDC
= BeginPaint(hWnd
, &Ps
);
1191 if (GetWindowLongW(hWnd
, GWL_STYLE
) & WS_MINIMIZE
&&
1192 (hIcon
= (HICON
)GetClassLongW(hWnd
, GCL_HICON
)) != NULL
)
1196 GetClientRect(hWnd
, &ClientRect
);
1197 x
= (ClientRect
.right
- ClientRect
.left
-
1198 GetSystemMetrics(SM_CXICON
)) / 2;
1199 y
= (ClientRect
.bottom
- ClientRect
.top
-
1200 GetSystemMetrics(SM_CYICON
)) / 2;
1201 DrawIcon(hDC
, x
, y
, hIcon
);
1203 EndPaint(hWnd
, &Ps
);
1211 hRgn
= CreateRectRgn(0, 0, 0, 0);
1212 if (GetUpdateRgn(hWnd
, hRgn
, FALSE
) != NULLREGION
)
1214 RedrawWindow(hWnd
, NULL
, hRgn
,
1215 RDW_ERASENOW
| RDW_ERASE
| RDW_FRAME
|
1224 DefWndSetRedraw(hWnd
, wParam
);
1230 DestroyWindow(hWnd
);
1234 case WM_MOUSEACTIVATE
:
1236 if (GetWindowLongW(hWnd
, GWL_STYLE
) & WS_CHILD
)
1241 Ret
= SendMessageW(GetParent(hWnd
), WM_MOUSEACTIVATE
,
1246 Ret
= SendMessageA(GetParent(hWnd
), WM_MOUSEACTIVATE
,
1254 return ((LOWORD(lParam
) >= HTCLIENT
) ? MA_ACTIVATE
: MA_NOACTIVATE
);
1259 /* Check if the window is minimized. */
1260 if (LOWORD(wParam
) != WA_INACTIVE
&&
1261 !(GetWindowLongW(hWnd
, GWL_STYLE
) & WS_MINIMIZE
))
1270 if (GetWindowLongW(hWnd
, GWL_STYLE
) & WS_CHILD
)
1274 return (SendMessageW(GetParent(hWnd
), WM_MOUSEWHEEL
,
1279 return (SendMessageA(GetParent(hWnd
), WM_MOUSEWHEEL
,
1287 case WM_ICONERASEBKGND
:
1290 HBRUSH hBrush
= (HBRUSH
)GetClassLongW(hWnd
, GCL_HBRBACKGROUND
);
1296 if (GetClassLongW(hWnd
, GCL_STYLE
) & CS_PARENTDC
)
1298 /* can't use GetClipBox with a parent DC or we fill the whole parent */
1299 GetClientRect(hWnd
, &Rect
);
1300 DPtoLP((HDC
)wParam
, (LPPOINT
)&Rect
, 2);
1304 GetClipBox((HDC
)wParam
, &Rect
);
1306 FillRect((HDC
)wParam
, &Rect
, hBrush
);
1310 case WM_CTLCOLORMSGBOX
:
1311 case WM_CTLCOLOREDIT
:
1312 case WM_CTLCOLORLISTBOX
:
1313 case WM_CTLCOLORBTN
:
1314 case WM_CTLCOLORDLG
:
1315 case WM_CTLCOLORSTATIC
:
1316 case WM_CTLCOLORSCROLLBAR
:
1317 return (LRESULT
) DefWndControlColor((HDC
)wParam
, Msg
- WM_CTLCOLORMSGBOX
);
1320 return (LRESULT
) DefWndControlColor((HDC
)wParam
, HIWORD(lParam
));
1324 ULONG Style
= GetWindowLongW(hWnd
, GWL_STYLE
);
1326 if (Style
& WS_CHILD
)
1328 if (LOWORD(lParam
) < HTLEFT
|| LOWORD(lParam
) > HTBOTTOMRIGHT
)
1333 bResult
= SendMessageW(GetParent(hWnd
), WM_SETCURSOR
,
1338 bResult
= SendMessageA(GetParent(hWnd
), WM_SETCURSOR
,
1347 return (DefWndHandleSetCursor(hWnd
, wParam
, lParam
, Style
));
1351 return (DefWndHandleSysCommand(hWnd
, wParam
, lParam
));
1354 if(wParam
== VK_F10
) iF10Key
= VK_F10
;
1357 /* FIXME: This is also incomplete. */
1360 if (HIWORD(lParam
) & KEYDATA_ALT
)
1362 /* if( HIWORD(lParam) & ~KEYDATA_PREVSTATE ) */
1363 if ( (wParam
== VK_MENU
|| wParam
== VK_LMENU
1364 || wParam
== VK_RMENU
) && !iMenuSysKey
)
1371 if (wParam
== VK_F4
) /* Try to close the window */
1373 HWND top
= GetAncestor(hWnd
, GA_ROOT
);
1374 if (!(GetClassLongW(top
, GCL_STYLE
) & CS_NOCLOSE
))
1377 PostMessageW(top
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
1379 PostMessageA(top
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
1382 else if (wParam
== VK_SNAPSHOT
)
1385 while (GetParent(hwnd
) != NULL
)
1387 hwnd
= GetParent(hwnd
);
1389 DefWndScreenshot(hwnd
);
1392 else if( wParam
== VK_F10
)
1394 else if( wParam
== VK_ESCAPE
&& (GetKeyState(VK_SHIFT
) & 0x8000))
1395 SendMessageW( hWnd
, WM_SYSCOMMAND
, SC_KEYMENU
, ' ' );
1402 /* Press and release F10 or ALT */
1403 if (((wParam
== VK_MENU
|| wParam
== VK_LMENU
|| wParam
== VK_RMENU
)
1404 && iMenuSysKey
) || ((wParam
== VK_F10
) && iF10Key
))
1405 SendMessageW( GetAncestor( hWnd
, GA_ROOT
), WM_SYSCOMMAND
, SC_KEYMENU
, 0L );
1406 iMenuSysKey
= iF10Key
= 0;
1413 if (wParam
== '\r' && IsIconic(hWnd
))
1415 PostMessageW( hWnd
, WM_SYSCOMMAND
, SC_RESTORE
, 0L );
1418 if ((HIWORD(lParam
) & KEYDATA_ALT
) && wParam
)
1420 if (wParam
== '\t' || wParam
== '\x1b') break;
1421 if (wParam
== ' ' && (GetWindowLongW( hWnd
, GWL_STYLE
) & WS_CHILD
))
1422 SendMessageW( GetParent(hWnd
), Msg
, wParam
, lParam
);
1424 SendMessageW( hWnd
, WM_SYSCOMMAND
, SC_KEYMENU
, wParam
);
1426 else /* check for Ctrl-Esc */
1427 if (wParam
!= '\x1b') MessageBeep(0);
1436 if (!lParam
) return 0;
1437 Style
= GetWindowLongW(hWnd
, GWL_STYLE
);
1438 if ((Style
& WS_VISIBLE
) && wParam
) return 0;
1439 if (!(Style
& WS_VISIBLE
) && !wParam
) return 0;
1440 if (!GetWindow(hWnd
, GW_OWNER
)) return 0;
1441 Ret
= NtUserCallTwoParam((DWORD
) hWnd
, (DWORD
) wParam
, TWOPARAM_ROUTINE_ROS_SHOWWINDOW
);
1444 if( Ret
== -1) return 0;
1447 ShowWindow(hWnd
, wParam
? SW_SHOWNOACTIVATE
: SW_HIDE
);
1454 /* FIXME: Check for a desktop. */
1455 if (!(GetWindowLongW( hWnd
, GWL_STYLE
) & WS_CHILD
)) EndMenu();
1456 if (GetCapture() == hWnd
)
1470 case WM_QUERYDROPOBJECT
:
1472 if (GetWindowLongW(hWnd
, GWL_EXSTYLE
) & WS_EX_ACCEPTFILES
)
1479 case WM_QUERYDRAGICON
:
1484 hIcon
= (HICON
)GetClassLongW(hWnd
, GCL_HICON
);
1487 return ((LRESULT
)hIcon
);
1489 for (Len
= 1; Len
< 64; Len
++)
1491 if ((hIcon
= LoadIconW(NULL
, MAKEINTRESOURCEW(Len
))) != NULL
)
1493 return((LRESULT
)hIcon
);
1496 return ((LRESULT
)LoadIconW(0, IDI_APPLICATION
));
1499 /* FIXME: WM_ISACTIVEICON */
1501 case WM_NOTIFYFORMAT
:
1503 if (lParam
== NF_QUERY
)
1504 return IsWindowUnicode(hWnd
) ? NFR_UNICODE
: NFR_ANSI
;
1510 INT Index
= (wParam
!= 0) ? GCL_HICON
: GCL_HICONSM
;
1511 HICON hOldIcon
= (HICON
)GetClassLongW(hWnd
, Index
);
1512 SetClassLongW(hWnd
, Index
, lParam
);
1513 SetWindowPos(hWnd
, 0, 0, 0, 0, 0,
1514 SWP_FRAMECHANGED
| SWP_NOSIZE
| SWP_NOMOVE
|
1515 SWP_NOACTIVATE
| SWP_NOZORDER
);
1516 return ((LRESULT
)hOldIcon
);
1521 INT Index
= (wParam
== ICON_BIG
) ? GCL_HICON
: GCL_HICONSM
;
1522 return (GetClassLongW(hWnd
, Index
));
1529 SendMessageW(GetParent(hWnd
), Msg
, wParam
, lParam
);
1533 SendMessageA(GetParent(hWnd
), Msg
, wParam
, lParam
);
1540 THRDCARETINFO CaretInfo
;
1543 case 0xffff: /* Caret timer */
1544 /* switch showing byte in win32k and get information about the caret */
1545 if(NtUserSwitchCaretShowing(&CaretInfo
) && (CaretInfo
.hWnd
== hWnd
))
1547 DrawCaret(hWnd
, &CaretInfo
);
1555 case WM_QUERYENDSESSION
:
1560 case WM_INPUTLANGCHANGEREQUEST
:
1564 if(wParam
& INPUTLANGCHANGE_BACKWARD
1565 && wParam
& INPUTLANGCHANGE_FORWARD
)
1570 //FIXME: What to do with INPUTLANGCHANGE_SYSCHARSET ?
1572 if(wParam
& INPUTLANGCHANGE_BACKWARD
) NewHkl
= (HKL
) HKL_PREV
;
1573 else if(wParam
& INPUTLANGCHANGE_FORWARD
) NewHkl
= (HKL
) HKL_NEXT
;
1574 else NewHkl
= (HKL
) lParam
;
1576 NtUserActivateKeyboardLayout(NewHkl
, 0);
1581 case WM_INPUTLANGCHANGE
:
1583 //FIXME: What to do?
1588 if (wParam
) PostQuitMessage(0);
1591 case WM_QUERYUISTATE
:
1594 PWINDOW Wnd
= ValidateHwnd(hWnd
);
1598 Ret
|= UISF_HIDEFOCUS
;
1600 Ret
|= UISF_HIDEACCEL
;
1605 case WM_CHANGEUISTATE
:
1607 BOOL AlwaysShowCues
= TRUE
;
1608 WORD Action
= LOWORD(wParam
);
1609 WORD Flags
= HIWORD(wParam
);
1612 SystemParametersInfoW(SPI_GETKEYBOARDCUES
, 0, &AlwaysShowCues
, 0);
1616 Wnd
= ValidateHwnd(hWnd
);
1617 if (!Wnd
|| lParam
!= 0)
1620 if (Flags
& ~(UISF_HIDEFOCUS
| UISF_HIDEACCEL
| UISF_ACTIVE
))
1623 if (Flags
& UISF_ACTIVE
)
1625 WARN("WM_CHANGEUISTATE does not yet support UISF_ACTIVE!\n");
1628 if (Action
== UIS_INITIALIZE
)
1630 PDESKTOP Desk
= GetThreadDesktopInfo();
1634 Action
= Desk
->LastInputWasKbd
? UIS_CLEAR
: UIS_SET
;
1635 Flags
= UISF_HIDEFOCUS
| UISF_HIDEACCEL
;
1637 /* We need to update wParam in case we need to send out messages */
1638 wParam
= MAKEWPARAM(Action
, Flags
);
1644 /* See if we actually need to change something */
1645 if ((Flags
& UISF_HIDEFOCUS
) && !Wnd
->HideFocus
)
1647 if ((Flags
& UISF_HIDEACCEL
) && !Wnd
->HideAccel
)
1650 /* Don't need to do anything... */
1654 /* See if we actually need to change something */
1655 if ((Flags
& UISF_HIDEFOCUS
) && Wnd
->HideFocus
)
1657 if ((Flags
& UISF_HIDEACCEL
) && Wnd
->HideAccel
)
1660 /* Don't need to do anything... */
1664 WARN("WM_CHANGEUISTATE: Unsupported Action 0x%x\n", Action
);
1668 if ((Wnd
->Style
& WS_CHILD
) && Wnd
->Parent
!= NULL
)
1670 /* We're a child window and we need to pass this message down until
1671 we reach the root */
1672 hWnd
= UserHMGetHandle((PWINDOW
)DesktopPtrToUser(Wnd
->Parent
));
1676 /* We're a top level window, we need to change the UI state */
1677 Msg
= WM_UPDATEUISTATE
;
1681 return SendMessageW(hWnd
, Msg
, wParam
, lParam
);
1683 return SendMessageA(hWnd
, Msg
, wParam
, lParam
);
1686 case WM_UPDATEUISTATE
:
1689 BOOL AlwaysShowCues
= TRUE
;
1690 WORD Action
= LOWORD(wParam
);
1691 WORD Flags
= HIWORD(wParam
);
1694 SystemParametersInfoW(SPI_GETKEYBOARDCUES
, 0, &AlwaysShowCues
, 0);
1698 Wnd
= ValidateHwnd(hWnd
);
1699 if (!Wnd
|| lParam
!= 0)
1702 if (Flags
& ~(UISF_HIDEFOCUS
| UISF_HIDEACCEL
| UISF_ACTIVE
))
1705 if (Flags
& UISF_ACTIVE
)
1707 WARN("WM_UPDATEUISTATE does not yet support UISF_ACTIVE!\n");
1710 if (Action
== UIS_INITIALIZE
)
1712 PDESKTOP Desk
= GetThreadDesktopInfo();
1716 Action
= Desk
->LastInputWasKbd
? UIS_CLEAR
: UIS_SET
;
1717 Flags
= UISF_HIDEFOCUS
| UISF_HIDEACCEL
;
1719 /* We need to update wParam for broadcasting the update */
1720 wParam
= MAKEWPARAM(Action
, Flags
);
1726 /* See if we actually need to change something */
1727 if ((Flags
& UISF_HIDEFOCUS
) && !Wnd
->HideFocus
)
1729 if ((Flags
& UISF_HIDEACCEL
) && !Wnd
->HideAccel
)
1732 /* Don't need to do anything... */
1737 /* See if we actually need to change something */
1738 if ((Flags
& UISF_HIDEFOCUS
) && Wnd
->HideFocus
)
1740 if ((Flags
& UISF_HIDEACCEL
) && Wnd
->HideAccel
)
1743 /* Don't need to do anything... */
1748 WARN("WM_UPDATEUISTATE: Unsupported Action 0x%x\n", Action
);
1752 /* Pack the information and call win32k */
1755 if (!NtUserCallTwoParam((DWORD
)hWnd
, (DWORD
)Flags
| ((DWORD
)Action
<< 3), TWOPARAM_ROUTINE_ROS_UPDATEUISTATE
))
1759 /* Always broadcast the update to all children */
1760 EnumChildWindows(hWnd
,
1761 UserSendUiUpdateMsg
,
1773 DefWindowProcA(HWND hWnd
,
1781 SPY_EnterMessage(SPY_DEFWNDPROC
, hWnd
, Msg
, wParam
, lParam
);
1786 ANSI_STRING AnsiString
;
1787 UNICODE_STRING UnicodeString
;
1788 LPCREATESTRUCTA cs
= (LPCREATESTRUCTA
)lParam
;
1789 /* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
1790 * may have child window IDs instead of window name */
1794 RtlInitAnsiString(&AnsiString
, (LPSTR
)cs
->lpszName
);
1795 RtlAnsiStringToUnicodeString(&UnicodeString
, &AnsiString
, TRUE
);
1796 NtUserDefSetText(hWnd
, &UnicodeString
);
1797 RtlFreeUnicodeString(&UnicodeString
);
1800 NtUserDefSetText(hWnd
, NULL
);
1806 case WM_GETTEXTLENGTH
:
1811 Wnd
= ValidateHwnd(hWnd
);
1812 if (Wnd
!= NULL
&& Wnd
->WindowName
.Length
!= 0)
1814 buf
= DesktopPtrToUser(Wnd
->WindowName
.Buffer
);
1816 NT_SUCCESS(RtlUnicodeToMultiByteSize(&len
,
1818 Wnd
->WindowName
.Length
)))
1820 Result
= (LRESULT
)len
;
1829 PSTR outbuf
= (PSTR
)lParam
;
1832 Wnd
= ValidateHwnd(hWnd
);
1833 if (Wnd
!= NULL
&& wParam
!= 0)
1835 if (Wnd
->WindowName
.Buffer
!= NULL
)
1836 buf
= DesktopPtrToUser(Wnd
->WindowName
.Buffer
);
1842 if (Wnd
->WindowName
.Length
!= 0)
1844 copy
= min(Wnd
->WindowName
.Length
/ sizeof(WCHAR
), wParam
- 1);
1845 Result
= WideCharToMultiByte(CP_ACP
,
1853 outbuf
[Result
] = '\0';
1864 ANSI_STRING AnsiString
;
1865 UNICODE_STRING UnicodeString
;
1869 RtlInitAnsiString(&AnsiString
, (LPSTR
)lParam
);
1870 RtlAnsiStringToUnicodeString(&UnicodeString
, &AnsiString
, TRUE
);
1871 NtUserDefSetText(hWnd
, &UnicodeString
);
1872 RtlFreeUnicodeString(&UnicodeString
);
1875 NtUserDefSetText(hWnd
, NULL
);
1877 if ((GetWindowLongW(hWnd
, GWL_STYLE
) & WS_CAPTION
) == WS_CAPTION
)
1879 DefWndNCPaint(hWnd
, (HRGN
)1, -1);
1886 /* FIXME: Implement these. */
1888 case WM_IME_KEYDOWN
:
1890 case WM_IME_STARTCOMPOSITION
:
1891 case WM_IME_COMPOSITION
:
1892 case WM_IME_ENDCOMPOSITION
:
1894 case WM_IME_SETCONTEXT
:
1895 FIXME("FIXME: WM_IME_* conversion isn't implemented yet!");
1898 Result
= User32DefWindowProc(hWnd
, Msg
, wParam
, lParam
, FALSE
);
1901 SPY_ExitMessage(SPY_RESULT_DEFWND
, hWnd
, Msg
, Result
, wParam
, lParam
);
1907 DefWindowProcW(HWND hWnd
,
1915 SPY_EnterMessage(SPY_DEFWNDPROC
, hWnd
, Msg
, wParam
, lParam
);
1920 UNICODE_STRING UnicodeString
;
1921 LPCREATESTRUCTW cs
= (LPCREATESTRUCTW
)lParam
;
1922 /* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
1923 * may have child window IDs instead of window name */
1926 RtlInitUnicodeString(&UnicodeString
, (LPWSTR
)cs
->lpszName
);
1928 NtUserDefSetText( hWnd
, (cs
->lpszName
? &UnicodeString
: NULL
));
1933 case WM_GETTEXTLENGTH
:
1938 Wnd
= ValidateHwnd(hWnd
);
1939 if (Wnd
!= NULL
&& Wnd
->WindowName
.Length
!= 0)
1941 buf
= DesktopPtrToUser(Wnd
->WindowName
.Buffer
);
1943 NT_SUCCESS(RtlUnicodeToMultiByteSize(&len
,
1945 Wnd
->WindowName
.Length
)))
1947 Result
= (LRESULT
)len
;
1956 PWSTR outbuf
= (PWSTR
)lParam
;
1958 Wnd
= ValidateHwnd(hWnd
);
1959 if (Wnd
!= NULL
&& wParam
!= 0)
1961 if (Wnd
->WindowName
.Buffer
!= NULL
)
1962 buf
= DesktopPtrToUser(Wnd
->WindowName
.Buffer
);
1968 if (Wnd
->WindowName
.Length
!= 0)
1970 Result
= min(Wnd
->WindowName
.Length
/ sizeof(WCHAR
), wParam
- 1);
1971 RtlCopyMemory(outbuf
,
1973 Result
* sizeof(WCHAR
));
1974 outbuf
[Result
] = L
'\0';
1985 UNICODE_STRING UnicodeString
;
1988 RtlInitUnicodeString(&UnicodeString
, (LPWSTR
)lParam
);
1990 NtUserDefSetText(hWnd
, (lParam
? &UnicodeString
: NULL
));
1992 if ((GetWindowLongW(hWnd
, GWL_STYLE
) & WS_CAPTION
) == WS_CAPTION
)
1994 DefWndNCPaint(hWnd
, (HRGN
)1, -1);
2002 SendMessageW(hWnd
, WM_CHAR
, wParam
, lParam
);
2007 case WM_IME_SETCONTEXT
:
2010 FIXME("FIXME: WM_IME_SETCONTEXT is not implemented!");
2016 Result
= User32DefWindowProc(hWnd
, Msg
, wParam
, lParam
, TRUE
);
2018 SPY_ExitMessage(SPY_RESULT_DEFWND
, hWnd
, Msg
, Result
, wParam
, lParam
);