1 /* $Id: window.c,v 1.58 2003/08/14 20:25:52 royce 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 ******************************************************************/
18 #include <user32/callback.h>
19 #include <user32/regcontrol.h>
24 static BOOL ControlsInitCalled
= FALSE
;
26 /* FUNCTIONS *****************************************************************/
28 WinHasThickFrameStyle(ULONG Style
, ULONG ExStyle
)
30 return((Style
& WS_THICKFRAME
) &&
31 (!((Style
& (WS_DLGFRAME
| WS_BORDER
)) == WS_DLGFRAME
)));
36 User32SendNCCALCSIZEMessageForKernel(PVOID Arguments
, ULONG ArgumentLength
)
38 PSENDNCCALCSIZEMESSAGE_CALLBACK_ARGUMENTS CallbackArgs
;
39 SENDNCCALCSIZEMESSAGE_CALLBACK_RESULT Result
;
42 DPRINT("User32SendNCCALCSIZEMessageForKernel.\n");
43 CallbackArgs
= (PSENDNCCALCSIZEMESSAGE_CALLBACK_ARGUMENTS
)Arguments
;
44 if (ArgumentLength
!= sizeof(SENDNCCALCSIZEMESSAGE_CALLBACK_ARGUMENTS
))
46 DPRINT("Wrong length.\n");
47 return(STATUS_INFO_LENGTH_MISMATCH
);
49 Proc
= (WNDPROC
)GetWindowLongW(CallbackArgs
->Wnd
, GWL_WNDPROC
);
50 DPRINT("Proc %X\n", Proc
);
51 /* Call the window procedure; notice kernel messages are always unicode. */
52 if (CallbackArgs
->Validate
)
54 Result
.Result
= CallWindowProcW(Proc
, CallbackArgs
->Wnd
, WM_NCCALCSIZE
,
56 (LPARAM
)&CallbackArgs
->Params
);
57 Result
.Params
= CallbackArgs
->Params
;
61 Result
.Result
= CallWindowProcW(Proc
, CallbackArgs
->Wnd
, WM_NCCALCSIZE
,
62 FALSE
, (LPARAM
)&CallbackArgs
->Rect
);
63 Result
.Rect
= CallbackArgs
->Rect
;
65 DPRINT("Returning result %d.\n", Result
);
66 return(ZwCallbackReturn(&Result
, sizeof(Result
), STATUS_SUCCESS
));
71 User32SendGETMINMAXINFOMessageForKernel(PVOID Arguments
, ULONG ArgumentLength
)
73 PSENDGETMINMAXINFO_CALLBACK_ARGUMENTS CallbackArgs
;
74 SENDGETMINMAXINFO_CALLBACK_RESULT Result
;
77 DPRINT("User32SendGETMINAXINFOMessageForKernel.\n");
78 CallbackArgs
= (PSENDGETMINMAXINFO_CALLBACK_ARGUMENTS
)Arguments
;
79 if (ArgumentLength
!= sizeof(SENDGETMINMAXINFO_CALLBACK_ARGUMENTS
))
81 DPRINT("Wrong length.\n");
82 return(STATUS_INFO_LENGTH_MISMATCH
);
84 Proc
= (WNDPROC
)GetWindowLongW(CallbackArgs
->Wnd
, GWL_WNDPROC
);
85 DPRINT("Proc %X\n", Proc
);
86 /* Call the window procedure; notice kernel messages are always unicode. */
87 Result
.Result
= CallWindowProcW(Proc
, CallbackArgs
->Wnd
, WM_GETMINMAXINFO
,
88 0, (LPARAM
)&CallbackArgs
->MinMaxInfo
);
89 Result
.MinMaxInfo
= CallbackArgs
->MinMaxInfo
;
90 DPRINT("Returning result %d.\n", Result
);
91 return(ZwCallbackReturn(&Result
, sizeof(Result
), STATUS_SUCCESS
));
96 User32SendCREATEMessageForKernel(PVOID Arguments
, ULONG ArgumentLength
)
98 PSENDCREATEMESSAGE_CALLBACK_ARGUMENTS CallbackArgs
;
102 DPRINT("User32SendCREATEMessageForKernel.\n");
103 CallbackArgs
= (PSENDCREATEMESSAGE_CALLBACK_ARGUMENTS
)Arguments
;
104 if (ArgumentLength
!= sizeof(SENDCREATEMESSAGE_CALLBACK_ARGUMENTS
))
106 DPRINT("Wrong length.\n");
107 return(STATUS_INFO_LENGTH_MISMATCH
);
109 Proc
= (WNDPROC
)GetWindowLongW(CallbackArgs
->Wnd
, GWL_WNDPROC
);
110 DPRINT("Proc %X\n", Proc
);
111 /* Call the window procedure; notice kernel messages are always unicode. */
112 Result
= CallWindowProcW(Proc
, CallbackArgs
->Wnd
, WM_CREATE
, 0,
113 (LPARAM
)&CallbackArgs
->CreateStruct
);
114 DPRINT("Returning result %d.\n", Result
);
115 return(ZwCallbackReturn(&Result
, sizeof(LRESULT
), STATUS_SUCCESS
));
120 User32SendNCCREATEMessageForKernel(PVOID Arguments
, ULONG ArgumentLength
)
122 PSENDNCCREATEMESSAGE_CALLBACK_ARGUMENTS CallbackArgs
;
126 DPRINT("User32SendNCCREATEMessageForKernel.\n");
127 CallbackArgs
= (PSENDNCCREATEMESSAGE_CALLBACK_ARGUMENTS
)Arguments
;
128 if (ArgumentLength
!= sizeof(SENDNCCREATEMESSAGE_CALLBACK_ARGUMENTS
))
130 DPRINT("Wrong length.\n");
131 return(STATUS_INFO_LENGTH_MISMATCH
);
133 Proc
= (WNDPROC
)GetWindowLongW(CallbackArgs
->Wnd
, GWL_WNDPROC
);
134 DPRINT("Proc %X\n", Proc
);
135 /* Call the window procedure; notice kernel messages are always unicode. */
136 Result
= CallWindowProcW(Proc
, CallbackArgs
->Wnd
, WM_NCCREATE
, 0,
137 (LPARAM
)&CallbackArgs
->CreateStruct
);
138 DPRINT("Returning result %d.\n", Result
);
139 return(ZwCallbackReturn(&Result
, sizeof(LRESULT
), STATUS_SUCCESS
));
144 User32SendWINDOWPOSCHANGINGMessageForKernel(PVOID Arguments
, ULONG ArgumentLength
)
146 PSENDWINDOWPOSCHANGING_CALLBACK_ARGUMENTS CallbackArgs
;
150 DPRINT("User32SendWINDOWPOSCHANGINGMessageForKernel.\n");
151 CallbackArgs
= (PSENDWINDOWPOSCHANGING_CALLBACK_ARGUMENTS
)Arguments
;
152 if (ArgumentLength
!= sizeof(SENDWINDOWPOSCHANGING_CALLBACK_ARGUMENTS
))
154 DPRINT("Wrong length.\n");
155 return(STATUS_INFO_LENGTH_MISMATCH
);
157 Proc
= (WNDPROC
)GetWindowLongW(CallbackArgs
->Wnd
, GWL_WNDPROC
);
158 DPRINT("Proc %X\n", Proc
);
159 /* Call the window procedure; notice kernel messages are always unicode. */
160 Result
= CallWindowProcW(Proc
, CallbackArgs
->Wnd
, WM_WINDOWPOSCHANGING
, 0,
161 (LPARAM
)&CallbackArgs
->WindowPos
);
162 DPRINT("Returning result %d.\n", Result
);
163 return(ZwCallbackReturn(&Result
, sizeof(LRESULT
), STATUS_SUCCESS
));
168 User32SendWINDOWPOSCHANGEDMessageForKernel(PVOID Arguments
, ULONG ArgumentLength
)
170 PSENDWINDOWPOSCHANGED_CALLBACK_ARGUMENTS CallbackArgs
;
174 DPRINT("User32SendWINDOWPOSCHANGEDMessageForKernel.\n");
175 CallbackArgs
= (PSENDWINDOWPOSCHANGED_CALLBACK_ARGUMENTS
)Arguments
;
176 if (ArgumentLength
!= sizeof(SENDWINDOWPOSCHANGED_CALLBACK_ARGUMENTS
))
178 DPRINT("Wrong length.\n");
179 return(STATUS_INFO_LENGTH_MISMATCH
);
181 Proc
= (WNDPROC
)GetWindowLongW(CallbackArgs
->Wnd
, GWL_WNDPROC
);
182 DPRINT("Proc %X\n", Proc
);
183 /* Call the window procedure; notice kernel messages are always unicode. */
184 Result
= CallWindowProcW(Proc
, CallbackArgs
->Wnd
, WM_WINDOWPOSCHANGED
, 0,
185 (LPARAM
)&CallbackArgs
->WindowPos
);
186 DPRINT("Returning result %d.\n", Result
);
187 return(ZwCallbackReturn(&Result
, sizeof(LRESULT
), STATUS_SUCCESS
));
192 User32SendSTYLECHANGINGMessageForKernel(PVOID Arguments
, ULONG ArgumentLength
)
194 PSENDSTYLECHANGING_CALLBACK_ARGUMENTS CallbackArgs
;
198 DPRINT("User32SendSTYLECHANGINGMessageForKernel.\n");
199 CallbackArgs
= (PSENDSTYLECHANGING_CALLBACK_ARGUMENTS
)Arguments
;
200 if (ArgumentLength
!= sizeof(SENDSTYLECHANGING_CALLBACK_ARGUMENTS
))
202 DPRINT("Wrong length.\n");
203 return(STATUS_INFO_LENGTH_MISMATCH
);
205 Proc
= (WNDPROC
)GetWindowLongW(CallbackArgs
->Wnd
, GWL_WNDPROC
);
206 DPRINT("Proc %X\n", Proc
);
207 /* Call the window procedure; notice kernel messages are always unicode. */
208 Result
= CallWindowProcW(Proc
, CallbackArgs
->Wnd
, WM_STYLECHANGING
, CallbackArgs
->WhichStyle
,
209 (LPARAM
)&CallbackArgs
->Style
);
210 DPRINT("Returning result %d.\n", Result
);
211 return(ZwCallbackReturn(&Result
, sizeof(LRESULT
), STATUS_SUCCESS
));
216 User32SendSTYLECHANGEDMessageForKernel(PVOID Arguments
, ULONG ArgumentLength
)
218 PSENDSTYLECHANGED_CALLBACK_ARGUMENTS CallbackArgs
;
222 DPRINT("User32SendSTYLECHANGEDGMessageForKernel.\n");
223 CallbackArgs
= (PSENDSTYLECHANGED_CALLBACK_ARGUMENTS
)Arguments
;
224 if (ArgumentLength
!= sizeof(SENDSTYLECHANGED_CALLBACK_ARGUMENTS
))
226 DPRINT("Wrong length.\n");
227 return(STATUS_INFO_LENGTH_MISMATCH
);
229 Proc
= (WNDPROC
)GetWindowLongW(CallbackArgs
->Wnd
, GWL_WNDPROC
);
230 DPRINT("Proc %X\n", Proc
);
231 /* Call the window procedure; notice kernel messages are always unicode. */
232 Result
= CallWindowProcW(Proc
, CallbackArgs
->Wnd
, WM_STYLECHANGED
, CallbackArgs
->WhichStyle
,
233 (LPARAM
)&CallbackArgs
->Style
);
234 DPRINT("Returning result %d.\n", Result
);
235 return(ZwCallbackReturn(&Result
, sizeof(LRESULT
), STATUS_SUCCESS
));
240 User32CallSendAsyncProcForKernel(PVOID Arguments
, ULONG ArgumentLength
)
242 PSENDASYNCPROC_CALLBACK_ARGUMENTS CallbackArgs
;
244 DPRINT("User32CallSendAsyncProcKernel()\n");
245 CallbackArgs
= (PSENDASYNCPROC_CALLBACK_ARGUMENTS
)Arguments
;
246 if (ArgumentLength
!= sizeof(WINDOWPROC_CALLBACK_ARGUMENTS
))
248 return(STATUS_INFO_LENGTH_MISMATCH
);
250 CallbackArgs
->Callback(CallbackArgs
->Wnd
, CallbackArgs
->Msg
,
251 CallbackArgs
->Context
, CallbackArgs
->Result
);
252 return(STATUS_SUCCESS
);
257 User32CallWindowProcFromKernel(PVOID Arguments
, ULONG ArgumentLength
)
259 PWINDOWPROC_CALLBACK_ARGUMENTS CallbackArgs
;
262 CallbackArgs
= (PWINDOWPROC_CALLBACK_ARGUMENTS
)Arguments
;
263 if (ArgumentLength
!= sizeof(WINDOWPROC_CALLBACK_ARGUMENTS
))
265 return(STATUS_INFO_LENGTH_MISMATCH
);
267 if (CallbackArgs
->Proc
== NULL
)
269 CallbackArgs
->Proc
= (WNDPROC
)GetWindowLongW(CallbackArgs
->Wnd
, GWL_WNDPROC
);
271 Result
= CallWindowProcW(CallbackArgs
->Proc
, CallbackArgs
->Wnd
,
272 CallbackArgs
->Msg
, CallbackArgs
->wParam
,
273 CallbackArgs
->lParam
);
274 return(ZwCallbackReturn(&Result
, sizeof(LRESULT
), STATUS_SUCCESS
));
278 static void NC_AdjustRectOuter95 (LPRECT rect
, DWORD style
, BOOL menu
, DWORD exStyle
)
281 if(style
& WS_ICONIC
) return;
283 if ((exStyle
& (WS_EX_STATICEDGE
|WS_EX_DLGMODALFRAME
)) ==
286 adjust
= 1; /* for the outer frame always present */
291 if ((exStyle
& WS_EX_DLGMODALFRAME
) ||
292 (style
& (WS_THICKFRAME
|WS_DLGFRAME
))) adjust
= 2; /* outer */
294 if (style
& WS_THICKFRAME
)
295 adjust
+= ( GetSystemMetrics (SM_CXFRAME
)
296 - GetSystemMetrics (SM_CXDLGFRAME
)); /* The resize border */
297 if ((style
& (WS_BORDER
|WS_DLGFRAME
)) ||
298 (exStyle
& WS_EX_DLGMODALFRAME
))
299 adjust
++; /* The other border */
301 InflateRect (rect
, adjust
, adjust
);
303 if ((style
& WS_CAPTION
) == WS_CAPTION
)
305 if (exStyle
& WS_EX_TOOLWINDOW
)
306 rect
->top
-= GetSystemMetrics(SM_CYSMCAPTION
);
308 rect
->top
-= GetSystemMetrics(SM_CYCAPTION
);
310 if (menu
) rect
->top
-= GetSystemMetrics(SM_CYMENU
);
315 NC_AdjustRectInner95 (LPRECT rect
, DWORD style
, DWORD exStyle
)
317 if(style
& WS_ICONIC
) return;
319 if (exStyle
& WS_EX_CLIENTEDGE
)
320 InflateRect(rect
, GetSystemMetrics(SM_CXEDGE
), GetSystemMetrics(SM_CYEDGE
));
322 if (style
& WS_VSCROLL
)
324 if((exStyle
& WS_EX_LEFTSCROLLBAR
) != 0)
325 rect
->left
-= GetSystemMetrics(SM_CXVSCROLL
);
327 rect
->right
+= GetSystemMetrics(SM_CXVSCROLL
);
329 if (style
& WS_HSCROLL
) rect
->bottom
+= GetSystemMetrics(SM_CYHSCROLL
);
337 AdjustWindowRect(LPRECT lpRect
,
341 return(AdjustWindowRectEx(lpRect
, dwStyle
, bMenu
, 0));
349 AdjustWindowRectEx(LPRECT lpRect
,
354 dwStyle
&= (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
| WS_CHILD
);
355 dwExStyle
&= (WS_EX_DLGMODALFRAME
| WS_EX_CLIENTEDGE
|
356 WS_EX_STATICEDGE
| WS_EX_TOOLWINDOW
);
357 if (dwExStyle
& WS_EX_DLGMODALFRAME
) dwStyle
&= ~WS_THICKFRAME
;
359 NC_AdjustRectOuter95( lpRect
, dwStyle
, bMenu
, dwExStyle
);
360 NC_AdjustRectInner95( lpRect
, dwStyle
, dwExStyle
);
371 AllowSetForegroundWindow(DWORD dwProcessId
)
382 AnimateWindow(HWND hwnd
,
395 ArrangeIconicWindows(HWND hWnd
)
406 BeginDeferWindowPos(int nNumWindows
)
417 BringWindowToTop(HWND hWnd
)
428 CascadeWindows(HWND hwndParent
,
443 ChildWindowFromPoint(HWND hWndParent
,
455 ChildWindowFromPointEx(HWND hwndParent
,
468 CloseWindow(HWND hWnd
)
470 SendMessageA(hWnd
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
472 return (WINBOOL
)(hWnd
);
479 CreateWindowExA(DWORD dwExStyle
,
492 UNICODE_STRING WindowName
;
493 UNICODE_STRING ClassName
;
497 /* Register built-in controls if not already done */
498 if (! ControlsInitCalled
)
501 ControlsInitCalled
= TRUE
;
504 if (IS_ATOM(lpClassName
))
506 RtlInitUnicodeString(&ClassName
, NULL
);
507 ClassName
.Buffer
= (LPWSTR
)lpClassName
;
511 if (!RtlCreateUnicodeStringFromAsciiz(&(ClassName
), (PCSZ
)lpClassName
))
513 SetLastError(ERROR_OUTOFMEMORY
);
518 if (!RtlCreateUnicodeStringFromAsciiz(&WindowName
, (PCSZ
)lpWindowName
))
520 if (!IS_ATOM(lpClassName
))
522 RtlFreeUnicodeString(&ClassName
);
524 SetLastError(ERROR_OUTOFMEMORY
);
528 /* Fixup default coordinates. */
530 if (x
== (LONG
) CW_USEDEFAULT
|| nWidth
== (LONG
) CW_USEDEFAULT
)
532 if (dwStyle
& (WS_CHILD
| WS_POPUP
))
534 if (x
== (LONG
) CW_USEDEFAULT
)
538 if (nWidth
== (LONG
) CW_USEDEFAULT
)
540 nWidth
= nHeight
= 0;
547 GetStartupInfoA(&info
);
549 if (x
== (LONG
) CW_USEDEFAULT
)
551 if (y
!= (LONG
) CW_USEDEFAULT
)
555 x
= (info
.dwFlags
& STARTF_USEPOSITION
) ? info
.dwX
: 0;
556 y
= (info
.dwFlags
& STARTF_USEPOSITION
) ? info
.dwY
: 0;
559 if (nWidth
== (LONG
) CW_USEDEFAULT
)
561 if (info
.dwFlags
& STARTF_USESIZE
)
563 nWidth
= info
.dwXSize
;
564 nHeight
= info
.dwYSize
;
570 SystemParametersInfoA(SPI_GETWORKAREA
, 0, &r
, 0);
571 nWidth
= (((r
.right
- r
.left
) * 3) / 4) - x
;
572 nHeight
= (((r
.bottom
- r
.top
) * 3) / 4) - y
;
578 Handle
= NtUserCreateWindowEx(dwExStyle
,
592 RtlFreeUnicodeString(&WindowName
);
594 if (!IS_ATOM(lpClassName
))
596 RtlFreeUnicodeString(&ClassName
);
607 CreateWindowExW(DWORD dwExStyle
,
609 LPCWSTR lpWindowName
,
620 UNICODE_STRING WindowName
;
621 UNICODE_STRING ClassName
;
625 /* Register built-in controls if not already done */
626 if (! ControlsInitCalled
)
629 ControlsInitCalled
= TRUE
;
632 if (IS_ATOM(lpClassName
))
634 RtlInitUnicodeString(&ClassName
, NULL
);
635 ClassName
.Buffer
= (LPWSTR
)lpClassName
;
639 RtlInitUnicodeString(&ClassName
, lpClassName
);
642 RtlInitUnicodeString(&WindowName
, lpWindowName
);
644 /* Fixup default coordinates. */
646 if (x
== (LONG
) CW_USEDEFAULT
|| nWidth
== (LONG
) CW_USEDEFAULT
)
648 if (dwStyle
& (WS_CHILD
| WS_POPUP
))
650 if (x
== (LONG
) CW_USEDEFAULT
)
654 if (nWidth
== (LONG
) CW_USEDEFAULT
)
656 nWidth
= nHeight
= 0;
663 GetStartupInfoW(&info
);
665 if (x
== (LONG
) CW_USEDEFAULT
)
667 if (y
!= (LONG
) CW_USEDEFAULT
)
671 x
= (info
.dwFlags
& STARTF_USEPOSITION
) ? info
.dwX
: 0;
672 y
= (info
.dwFlags
& STARTF_USEPOSITION
) ? info
.dwY
: 0;
675 if (nWidth
== (LONG
) CW_USEDEFAULT
)
677 if (info
.dwFlags
& STARTF_USESIZE
)
679 nWidth
= info
.dwXSize
;
680 nHeight
= info
.dwYSize
;
686 SystemParametersInfoW(SPI_GETWORKAREA
, 0, &r
, 0);
687 nWidth
= (((r
.right
- r
.left
) * 3) / 4) - x
;
688 nHeight
= (((r
.bottom
- r
.top
) * 3) / 4) - y
;
694 Handle
= NtUserCreateWindowEx(dwExStyle
,
716 DeferWindowPos(HDWP hWinPosInfo
,
718 HWND hWndInsertAfter
,
725 return NtUserDeferWindowPos(hWinPosInfo
, hWnd
, hWndInsertAfter
, x
, y
, cx
, cy
, uFlags
);
733 DestroyWindow(HWND hWnd
)
735 return NtUserDestroyWindow(hWnd
);
743 EndDeferWindowPos(HDWP hWinPosInfo
)
755 ENUMWINDOWSPROC lpfn
,
760 DWORD i
, dwCount
= 0;
766 SetLastError ( ERROR_INVALID_PARAMETER
);
770 /* FIXME instead of always making two calls, should we use some
771 sort of persistent buffer and only grow it ( requiring a 2nd
772 call ) when the buffer wasn't already big enough? */
773 /* first get how many window entries there are */
775 dwCount
= NtUserBuildHwndList (
776 hDesktop
, hWndparent
, bChildren
, dwThreadId
, lParam
, NULL
, 0 );
777 if ( !dwCount
|| GetLastError() )
780 /* allocate buffer to receive HWND handles */
781 hHeap
= GetProcessHeap();
782 pHwnd
= HeapAlloc ( hHeap
, 0, sizeof(HWND
)*(dwCount
+1) );
785 SetLastError ( ERROR_NOT_ENOUGH_MEMORY
);
789 /* now call kernel again to fill the buffer this time */
790 dwCount
= NtUserBuildHwndList (
791 hDesktop
, hWndparent
, bChildren
, dwThreadId
, lParam
, pHwnd
, dwCount
);
792 if ( !dwCount
|| GetLastError() )
795 HeapFree ( hHeap
, 0, pHwnd
);
799 /* call the user's callback function until we're done or
800 they tell us to quit */
801 for ( i
= 0; i
< dwCount
; i
++ )
803 /* FIXME I'm only getting NULLs from Thread Enumeration, and it's
804 * probably because I'm not doing it right in NtUserBuildHwndList.
805 * Once that's fixed, we shouldn't have to check for a NULL HWND
808 if ( !(ULONG
)pHwnd
[i
] ) /* don't enumerate a NULL HWND */
810 if ( !(*lpfn
)( pHwnd
[i
], lParam
) )
814 HeapFree ( hHeap
, 0, pHwnd
);
826 ENUMWINDOWSPROC lpEnumFunc
,
830 hWndParent
= GetDesktopWindow();
831 return User32EnumWindows ( NULL
, hWndParent
, lpEnumFunc
, lParam
, 0, FALSE
);
840 EnumThreadWindows(DWORD dwThreadId
,
841 ENUMWINDOWSPROC lpfn
,
845 dwThreadId
= GetCurrentThreadId();
846 return User32EnumWindows ( NULL
, NULL
, lpfn
, lParam
, dwThreadId
, FALSE
);
854 EnumWindows(ENUMWINDOWSPROC lpEnumFunc
,
857 return User32EnumWindows ( NULL
, NULL
, lpEnumFunc
, lParam
, 0, FALSE
);
868 ENUMWINDOWSPROC lpfn
,
871 return User32EnumWindows ( hDesktop
, NULL
, lpfn
, lParam
, 0, FALSE
);
879 FindWindowA(LPCSTR lpClassName
, LPCSTR lpWindowName
)
881 //FIXME: FindWindow does not search children, but FindWindowEx does.
882 // what should we do about this?
883 return FindWindowExA (NULL
, NULL
, lpClassName
, lpWindowName
);
891 FindWindowExA(HWND hwndParent
,
905 FindWindowW(LPCWSTR lpClassName
, LPCWSTR lpWindowName
)
909 There was a FIXME here earlier, but I think it is just a documentation unclarity.
911 FindWindow only searches top level windows. What they mean is that child
912 windows of other windows than the desktop can be searched.
913 FindWindowExW never does a recursive search.
918 return FindWindowExW (NULL
, NULL
, lpClassName
, lpWindowName
);
926 FindWindowExW(HWND hwndParent
,
931 UNICODE_STRING ucClassName
;
932 UNICODE_STRING ucWindowName
;
934 if (IS_ATOM(lpszClass
))
936 RtlInitUnicodeString(&ucClassName
, NULL
);
937 ucClassName
.Buffer
= (LPWSTR
)lpszClass
;
941 RtlInitUnicodeString(&ucClassName
, lpszClass
);
944 // Window names can't be atoms, and if lpszWindow = NULL,
945 // RtlInitUnicodeString will clear it
947 RtlInitUnicodeString(&ucWindowName
, lpszWindow
);
950 return NtUserFindWindowEx(hwndParent
, hwndChildAfter
, &ucClassName
, &ucWindowName
);
957 GetAltTabInfoA(HWND hwnd
,
972 GetAltTabInfoW(HWND hwnd
,
987 GetAncestor(HWND hwnd
, UINT gaFlags
)
989 return(NtUserGetAncestor(hwnd
, gaFlags
));
997 GetClientRect(HWND hWnd
, LPRECT lpRect
)
999 return(NtUserGetClientRect(hWnd
, lpRect
));
1007 GetDesktopWindow(VOID
)
1009 return NtUserGetDesktopWindow();
1017 GetForegroundWindow(VOID
)
1028 GetGUIThreadInfo(DWORD idThread
,
1029 LPGUITHREADINFO lpgui
)
1040 GetLastActivePopup(HWND hWnd
)
1042 return NtUserGetLastActivePopup(hWnd
);
1050 GetParent(HWND hWnd
)
1052 return NtUserGetParent(hWnd
);
1060 GetProcessDefaultLayout(DWORD
*pdwDefaultLayout
)
1071 GetTitleBarInfo(HWND hwnd
,
1083 GetTopWindow(HWND hWnd
)
1085 if (!hWnd
) hWnd
= GetDesktopWindow();
1086 return GetWindow( hWnd
, GW_CHILD
);
1094 GetWindow(HWND hWnd
,
1097 return NtUserGetWindow(hWnd
, uCmd
);
1105 GetWindowInfo(HWND hwnd
,
1117 GetWindowModuleFileName(HWND hwnd
,
1119 UINT cchFileNameMax
)
1130 GetWindowModuleFileNameA(HWND hwnd
,
1132 UINT cchFileNameMax
)
1143 GetWindowModuleFileNameW(HWND hwnd
,
1144 LPWSTR lpszFileName
,
1145 UINT cchFileNameMax
)
1156 GetWindowPlacement(HWND hWnd
,
1157 WINDOWPLACEMENT
*lpwndpl
)
1168 GetWindowRect(HWND hWnd
,
1171 return(NtUserGetWindowRect(hWnd
, lpRect
));
1179 GetWindowTextA(HWND hWnd
, LPSTR lpString
, int nMaxCount
)
1181 return(SendMessageA(hWnd
, WM_GETTEXT
, nMaxCount
, (LPARAM
)lpString
));
1189 GetWindowTextLengthA(HWND hWnd
)
1191 return(SendMessageA(hWnd
, WM_GETTEXTLENGTH
, 0, 0));
1199 GetWindowTextLengthW(HWND hWnd
)
1201 return(SendMessageW(hWnd
, WM_GETTEXTLENGTH
, 0, 0));
1214 return(SendMessageW(hWnd
, WM_GETTEXT
, nMaxCount
, (LPARAM
)lpString
));
1218 GetWindowThreadProcessId(HWND hWnd
,
1219 LPDWORD lpdwProcessId
)
1221 return NtUserGetWindowThreadProcessId(hWnd
, lpdwProcessId
);
1229 IsChild(HWND hWndParent
,
1243 return (NtUserGetWindowLong( hWnd
, GWL_STYLE
, FALSE
) & WS_MINIMIZE
) != 0;
1253 DWORD WndProc
= NtUserGetWindowLong(hWnd
, GWL_WNDPROC
, FALSE
);
1254 return (0 != WndProc
|| ERROR_INVALID_HANDLE
!= GetLastError());
1262 IsWindowUnicode(HWND hWnd
)
1264 return (WINBOOL
)NtUserCallOneParam((DWORD
)hWnd
,ONEPARAM_ROUTINE_ISWINDOWUNICODE
);
1272 IsWindowVisible(HWND hWnd
)
1274 while (GetWindowLongW(hWnd
, GWL_STYLE
) & WS_CHILD
)
1276 if (!(GetWindowLongW(hWnd
, GWL_STYLE
) & WS_VISIBLE
))
1280 hWnd
= GetAncestor(hWnd
, GA_PARENT
);
1282 return(GetWindowLongW(hWnd
, GWL_STYLE
) & WS_VISIBLE
);
1292 ULONG uStyle
= GetWindowLongW(hWnd
, GWL_STYLE
);
1294 return (uStyle
& WS_MAXIMIZE
);
1302 LockSetForegroundWindow(UINT uLockCode
)
1313 MoveWindow(HWND hWnd
,
1320 return NtUserMoveWindow(hWnd
, X
, Y
, nWidth
, nHeight
, bRepaint
);
1339 RealChildWindowFromPoint(HWND hwndParent
,
1340 POINT ptParentClientCoords
)
1350 SetForegroundWindow(HWND hWnd
)
1361 SetLayeredWindowAttributes(HWND hwnd
,
1375 SetParent(HWND hWndChild
,
1378 return NtUserSetParent(hWndChild
, hWndNewParent
);
1386 SetProcessDefaultLayout(DWORD dwDefaultLayout
)
1397 SetWindowPlacement(HWND hWnd
,
1398 CONST WINDOWPLACEMENT
*lpwndpl
)
1409 SetWindowPos(HWND hWnd
,
1410 HWND hWndInsertAfter
,
1417 return NtUserSetWindowPos(hWnd
,hWndInsertAfter
, X
, Y
, cx
, cy
, uFlags
);
1425 SetWindowTextA(HWND hWnd
,
1428 return SendMessageA(hWnd
, WM_SETTEXT
, 0, (LPARAM
)lpString
);
1436 SetWindowTextW(HWND hWnd
,
1439 return SendMessageW(hWnd
, WM_SETTEXT
, 0, (LPARAM
)lpString
);
1447 ShowOwnedPopups(HWND hWnd
,
1459 ShowWindow(HWND hWnd
,
1462 return NtUserShowWindow(hWnd
, nCmdShow
);
1470 ShowWindowAsync(HWND hWnd
,
1482 TileWindows(HWND hwndParent
,
1497 UpdateLayeredWindow(HWND hwnd
,
1504 BLENDFUNCTION
*pblend
,
1516 WindowFromPoint(POINT Point
)
1527 MapWindowPoints(HWND hWndFrom
, HWND hWndTo
, LPPOINT lpPoints
, UINT cPoints
)
1529 POINT FromOffset
, ToOffset
;
1533 NtUserGetClientOrigin(hWndFrom
, &FromOffset
);
1534 NtUserGetClientOrigin(hWndTo
, &ToOffset
);
1535 XMove
= FromOffset
.x
- ToOffset
.x
;
1536 YMove
= FromOffset
.y
- ToOffset
.y
;
1538 for (i
= 0; i
< cPoints
; i
++)
1540 lpPoints
[i
].x
+= XMove
;
1541 lpPoints
[i
].y
+= YMove
;
1543 return(MAKELONG(LOWORD(XMove
), LOWORD(YMove
)));
1551 ScreenToClient(HWND hWnd
, LPPOINT lpPoint
)
1553 return(MapWindowPoints(NULL
, hWnd
, lpPoint
, 1));
1561 ClientToScreen(HWND hWnd
, LPPOINT lpPoint
)
1563 return (MapWindowPoints( hWnd
, NULL
, lpPoint
, 1 ));
1569 SetWindowContextHelpId(HWND hwnd
,
1570 DWORD dwContextHelpId
)
1582 GetWindowContextHelpId(HWND hwnd
)
1593 InternalGetWindowText(HWND hWnd
, LPWSTR lpString
, int nMaxCount
)
1597 if(lpString
&& (nMaxCount
> 0))
1599 lps
= RtlAllocateHeap(RtlGetProcessHeap(), 0, nMaxCount
* sizeof(WCHAR
));
1602 SetLastError(ERROR_OUTOFMEMORY
);
1607 res
= NtUserInternalGetWindowText(hWnd
, lps
, nMaxCount
);
1611 RtlCopyMemory(lpString
, lps
, res
* sizeof(WCHAR
));
1612 lpString
[res
] = (WCHAR
)"\0"; /* null-terminate the string */
1614 RtlFreeHeap(RtlGetProcessHeap(), 0, lps
);
1623 WINBOOL STDCALL
IsHungAppWindow(HWND hwnd
)
1625 /* FIXME: ReactOS doesnt identify hung app windows yet */