2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS user32.dll
4 * FILE: lib/user32/windows/window.c
5 * PURPOSE: Window management
6 * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
8 * 06-06-2001 CSH Created
11 /* INCLUDES ******************************************************************/
15 #include <wine/debug.h>
16 WINE_DEFAULT_DEBUG_CHANNEL(user32
);
18 LRESULT
DefWndNCPaint(HWND hWnd
, HRGN hRgn
, BOOL Active
);
19 void MDI_CalcDefaultChildPos( HWND hwndClient
, INT total
, LPPOINT lpPos
, INT delta
, UINT
*id
);
21 #define CW_USEDEFAULT16 0x00008000
23 /* FUNCTIONS *****************************************************************/
27 User32CallSendAsyncProcForKernel(PVOID Arguments
, ULONG ArgumentLength
)
29 PSENDASYNCPROC_CALLBACK_ARGUMENTS CallbackArgs
;
31 TRACE("User32CallSendAsyncProcKernel()\n");
32 CallbackArgs
= (PSENDASYNCPROC_CALLBACK_ARGUMENTS
)Arguments
;
34 if (ArgumentLength
!= sizeof(WINDOWPROC_CALLBACK_ARGUMENTS
))
36 return(STATUS_INFO_LENGTH_MISMATCH
);
39 CallbackArgs
->Callback(CallbackArgs
->Wnd
,
41 CallbackArgs
->Context
,
42 CallbackArgs
->Result
);
43 return(STATUS_SUCCESS
);
51 AllowSetForegroundWindow(DWORD dwProcessId
)
53 static BOOL show_message
= TRUE
;
67 BeginDeferWindowPos(int nNumWindows
)
71 SetLastError(ERROR_INVALID_PARAMETER
);
87 BringWindowToTop(HWND hWnd
)
89 return NtUserSetWindowPos(hWnd
,
95 SWP_NOSIZE
| SWP_NOMOVE
);
100 SwitchToThisWindow(HWND hwnd
, BOOL fUnknown
)
102 ShowWindow(hwnd
, SW_SHOW
);
110 ChildWindowFromPoint(HWND hWndParent
,
113 return (HWND
) NtUserChildWindowFromPointEx(hWndParent
, Point
.x
, Point
.y
, 0);
121 ChildWindowFromPointEx(HWND hwndParent
,
125 return (HWND
) NtUserChildWindowFromPointEx(hwndParent
, pt
.x
, pt
.y
, uFlags
);
133 CloseWindow(HWND hWnd
)
135 SendMessageA(hWnd
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
142 User32CreateWindowEx(DWORD dwExStyle
,
156 UNICODE_STRING WindowName
;
157 UNICODE_STRING ClassName
;
163 DbgPrint("[window] User32CreateWindowEx style %d, exstyle %d, parent %d\n", dwStyle
, dwExStyle
, hWndParent
);
166 if (!RegisterDefaultClasses
)
168 ERR("User32CreateWindowEx RegisterSystemControls\n");
169 RegisterSystemControls();
172 if (IS_ATOM(lpClassName
))
174 RtlInitUnicodeString(&ClassName
, NULL
);
175 ClassName
.Buffer
= (LPWSTR
)lpClassName
;
180 RtlInitUnicodeString(&ClassName
, (PCWSTR
)lpClassName
);
183 if (!RtlCreateUnicodeStringFromAsciiz(&(ClassName
), (PCSZ
)lpClassName
))
185 SetLastError(ERROR_OUTOFMEMORY
);
192 RtlInitUnicodeString(&WindowName
, (PCWSTR
)lpWindowName
);
195 if (!RtlCreateUnicodeStringFromAsciiz(&WindowName
, (PCSZ
)lpWindowName
))
197 if (!IS_ATOM(lpClassName
))
199 RtlFreeUnicodeString(&ClassName
);
201 SetLastError(ERROR_OUTOFMEMORY
);
206 if(!hMenu
&& (dwStyle
& (WS_OVERLAPPEDWINDOW
| WS_POPUP
)))
210 wceW
.cbSize
= sizeof(WNDCLASSEXW
);
211 if(GetClassInfoExW(hInstance
, (LPCWSTR
)lpClassName
, &wceW
) && wceW
.lpszMenuName
)
213 hMenu
= LoadMenuW(hInstance
, wceW
.lpszMenuName
);
218 wceA
.cbSize
= sizeof(WNDCLASSEXA
);
219 if(GetClassInfoExA(hInstance
, lpClassName
, &wceA
) && wceA
.lpszMenuName
)
221 hMenu
= LoadMenuA(hInstance
, wceA
.lpszMenuName
);
226 Handle
= NtUserCreateWindowEx(dwExStyle
,
243 DbgPrint("[window] NtUserCreateWindowEx() == %d\n", Handle
);
248 RtlFreeUnicodeString(&WindowName
);
250 if (!IS_ATOM(lpClassName
))
252 RtlFreeUnicodeString(&ClassName
);
263 CreateWindowExA(DWORD dwExStyle
,
276 MDICREATESTRUCTA mdi
;
279 if (!RegisterDefaultClasses
)
281 ERR("CreateWindowExA RegisterSystemControls\n");
282 RegisterSystemControls();
285 if (dwExStyle
& WS_EX_MDICHILD
)
291 /* lpParams of WM_[NC]CREATE is different for MDI children.
292 * MDICREATESTRUCT members have the originally passed values.
294 mdi
.szClass
= lpClassName
;
295 mdi
.szTitle
= lpWindowName
;
296 mdi
.hOwner
= hInstance
;
302 mdi
.lParam
= (LPARAM
)lpParam
;
304 lpParam
= (LPVOID
)&mdi
;
306 if (GetWindowLongPtrW(hWndParent
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
308 if (dwStyle
& WS_POPUP
)
310 WARN("WS_POPUP with MDIS_ALLCHILDSTYLES is not allowed\n");
313 dwStyle
|= (WS_CHILD
| WS_CLIPSIBLINGS
);
317 dwStyle
&= ~WS_POPUP
;
318 dwStyle
|= (WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CAPTION
|
319 WS_SYSMENU
| WS_THICKFRAME
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
);
322 top_child
= GetWindow(hWndParent
, GW_CHILD
);
326 /* Restore current maximized child */
327 if((dwStyle
& WS_VISIBLE
) && IsZoomed(top_child
))
329 TRACE("Restoring current maximized child %p\n", top_child
);
330 SendMessageW( top_child
, WM_SETREDRAW
, FALSE
, 0 );
331 ShowWindow(top_child
, SW_RESTORE
);
332 SendMessageW( top_child
, WM_SETREDRAW
, TRUE
, 0 );
336 MDI_CalcDefaultChildPos(hWndParent
, -1, mPos
, 0, &id
);
338 if (!(dwStyle
& WS_POPUP
)) hMenu
= (HMENU
)id
;
340 if (dwStyle
& (WS_CHILD
| WS_POPUP
))
342 if (x
== CW_USEDEFAULT
|| x
== CW_USEDEFAULT16
)
347 if (nWidth
== CW_USEDEFAULT
|| nWidth
== CW_USEDEFAULT16
|| !nWidth
)
349 if (nHeight
== CW_USEDEFAULT
|| nHeight
== CW_USEDEFAULT16
|| !nHeight
)
354 hwnd
= User32CreateWindowEx(dwExStyle
,
375 CreateWindowExW(DWORD dwExStyle
,
377 LPCWSTR lpWindowName
,
388 MDICREATESTRUCTW mdi
;
391 if (!RegisterDefaultClasses
)
393 ERR("CreateWindowExW RegisterSystemControls\n");
394 RegisterSystemControls();
397 if (dwExStyle
& WS_EX_MDICHILD
)
403 /* lpParams of WM_[NC]CREATE is different for MDI children.
404 * MDICREATESTRUCT members have the originally passed values.
406 mdi
.szClass
= lpClassName
;
407 mdi
.szTitle
= lpWindowName
;
408 mdi
.hOwner
= hInstance
;
414 mdi
.lParam
= (LPARAM
)lpParam
;
416 lpParam
= (LPVOID
)&mdi
;
418 if (GetWindowLongPtrW(hWndParent
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
420 if (dwStyle
& WS_POPUP
)
422 WARN("WS_POPUP with MDIS_ALLCHILDSTYLES is not allowed\n");
425 dwStyle
|= (WS_CHILD
| WS_CLIPSIBLINGS
);
429 dwStyle
&= ~WS_POPUP
;
430 dwStyle
|= (WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CAPTION
|
431 WS_SYSMENU
| WS_THICKFRAME
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
);
434 top_child
= GetWindow(hWndParent
, GW_CHILD
);
438 /* Restore current maximized child */
439 if((dwStyle
& WS_VISIBLE
) && IsZoomed(top_child
))
441 TRACE("Restoring current maximized child %p\n", top_child
);
442 SendMessageW( top_child
, WM_SETREDRAW
, FALSE
, 0 );
443 ShowWindow(top_child
, SW_RESTORE
);
444 SendMessageW( top_child
, WM_SETREDRAW
, TRUE
, 0 );
448 MDI_CalcDefaultChildPos(hWndParent
, -1, mPos
, 0, &id
);
450 if (!(dwStyle
& WS_POPUP
)) hMenu
= (HMENU
)id
;
452 if (dwStyle
& (WS_CHILD
| WS_POPUP
))
454 if (x
== CW_USEDEFAULT
|| x
== CW_USEDEFAULT16
)
459 if (nWidth
== CW_USEDEFAULT
|| nWidth
== CW_USEDEFAULT16
|| !nWidth
)
461 if (nHeight
== CW_USEDEFAULT
|| nHeight
== CW_USEDEFAULT16
|| !nHeight
)
466 hwnd
= User32CreateWindowEx(dwExStyle
,
467 (LPCSTR
) lpClassName
,
468 (LPCSTR
) lpWindowName
,
486 DeferWindowPos(HDWP hWinPosInfo
,
488 HWND hWndInsertAfter
,
496 return NtUserDeferWindowPos(hWinPosInfo
, hWnd
, hWndInsertAfter
, x
, y
, cx
, cy
, uFlags
);
498 SetWindowPos(hWnd
, hWndInsertAfter
, x
, y
, cx
, cy
, uFlags
);
508 EndDeferWindowPos(HDWP hWinPosInfo
)
523 GetDesktopWindow(VOID
)
530 Wnd
= GetThreadDesktopWnd();
532 Ret
= UserHMGetHandle(Wnd
);
534 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
545 User32EnumWindows(HDESK hDesktop
,
552 DWORD i
, dwCount
= 0;
559 SetLastError ( ERROR_INVALID_PARAMETER
);
563 /* FIXME instead of always making two calls, should we use some
564 sort of persistent buffer and only grow it ( requiring a 2nd
565 call ) when the buffer wasn't already big enough? */
566 /* first get how many window entries there are */
567 Status
= NtUserBuildHwndList(hDesktop
,
574 if (!NT_SUCCESS(Status
))
577 /* allocate buffer to receive HWND handles */
578 hHeap
= GetProcessHeap();
579 pHwnd
= HeapAlloc(hHeap
, 0, sizeof(HWND
)*(dwCount
+1));
582 SetLastError ( ERROR_NOT_ENOUGH_MEMORY
);
586 /* now call kernel again to fill the buffer this time */
587 Status
= NtUserBuildHwndList(hDesktop
,
594 if (!NT_SUCCESS(Status
))
597 HeapFree(hHeap
, 0, pHwnd
);
601 /* call the user's callback function until we're done or
602 they tell us to quit */
603 for ( i
= 0; i
< dwCount
; i
++ )
605 /* FIXME I'm only getting NULLs from Thread Enumeration, and it's
606 * probably because I'm not doing it right in NtUserBuildHwndList.
607 * Once that's fixed, we shouldn't have to check for a NULL HWND
610 if (!(ULONG
)pHwnd
[i
]) /* don't enumerate a NULL HWND */
612 if (!(*lpfn
)(pHwnd
[i
], lParam
))
614 HeapFree ( hHeap
, 0, pHwnd
);
619 HeapFree(hHeap
, 0, pHwnd
);
628 EnumChildWindows(HWND hWndParent
,
629 WNDENUMPROC lpEnumFunc
,
634 return EnumWindows(lpEnumFunc
, lParam
);
636 return User32EnumWindows(NULL
, hWndParent
, lpEnumFunc
, lParam
, 0, TRUE
);
644 EnumThreadWindows(DWORD dwThreadId
,
649 dwThreadId
= GetCurrentThreadId();
650 return User32EnumWindows(NULL
, NULL
, lpfn
, lParam
, dwThreadId
, FALSE
);
658 EnumWindows(WNDENUMPROC lpEnumFunc
,
661 return User32EnumWindows(NULL
, NULL
, lpEnumFunc
, lParam
, 0, FALSE
);
669 EnumDesktopWindows(HDESK hDesktop
,
673 return User32EnumWindows(hDesktop
, NULL
, lpfn
, lParam
, 0, FALSE
);
681 FindWindowExA(HWND hwndParent
,
686 UNICODE_STRING ucClassName
, *pucClassName
= NULL
;
687 UNICODE_STRING ucWindowName
, *pucWindowName
= NULL
;
690 if (IS_ATOM(lpszClass
))
692 ucClassName
.Buffer
= (LPWSTR
)lpszClass
;
693 ucClassName
.Length
= 0;
694 pucClassName
= &ucClassName
;
696 else if (lpszClass
!= NULL
)
698 if (!RtlCreateUnicodeStringFromAsciiz(&ucClassName
,
701 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
704 pucClassName
= &ucClassName
;
707 if (lpszWindow
!= NULL
)
709 if (!RtlCreateUnicodeStringFromAsciiz(&ucWindowName
,
712 if (!IS_ATOM(lpszClass
) && lpszClass
!= NULL
)
713 RtlFreeUnicodeString(&ucWindowName
);
715 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
719 pucWindowName
= &ucWindowName
;
722 Result
= NtUserFindWindowEx(hwndParent
,
728 if (!IS_ATOM(lpszClass
) && lpszClass
!= NULL
)
729 RtlFreeUnicodeString(&ucClassName
);
730 if (lpszWindow
!= NULL
)
731 RtlFreeUnicodeString(&ucWindowName
);
741 FindWindowExW(HWND hwndParent
,
746 UNICODE_STRING ucClassName
, *pucClassName
= NULL
;
747 UNICODE_STRING ucWindowName
, *pucWindowName
= NULL
;
749 if (IS_ATOM(lpszClass
))
751 ucClassName
.Length
= 0;
752 ucClassName
.Buffer
= (LPWSTR
)lpszClass
;
753 pucClassName
= &ucClassName
;
755 else if (lpszClass
!= NULL
)
757 RtlInitUnicodeString(&ucClassName
,
759 pucClassName
= &ucClassName
;
762 if (lpszWindow
!= NULL
)
764 RtlInitUnicodeString(&ucWindowName
,
766 pucWindowName
= &ucWindowName
;
769 return NtUserFindWindowEx(hwndParent
,
781 FindWindowA(LPCSTR lpClassName
, LPCSTR lpWindowName
)
783 //FIXME: FindWindow does not search children, but FindWindowEx does.
784 // what should we do about this?
785 return FindWindowExA (NULL
, NULL
, lpClassName
, lpWindowName
);
793 FindWindowW(LPCWSTR lpClassName
, LPCWSTR lpWindowName
)
797 There was a FIXME here earlier, but I think it is just a documentation unclarity.
799 FindWindow only searches top level windows. What they mean is that child
800 windows of other windows than the desktop can be searched.
801 FindWindowExW never does a recursive search.
806 return FindWindowExW(NULL
, NULL
, lpClassName
, lpWindowName
);
815 GetAltTabInfoA(HWND hwnd
,
830 GetAltTabInfoW(HWND hwnd
,
845 GetAncestor(HWND hwnd
, UINT gaFlags
)
850 Wnd
= ValidateHwnd(hwnd
);
860 if (Wnd
->spwndParent
!= NULL
)
861 Ancestor
= DesktopPtrToUser(Wnd
->spwndParent
);
865 /* FIXME: Call win32k for now */
870 if (Ancestor
!= NULL
)
871 Ret
= UserHMGetHandle(Ancestor
);
873 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
879 if (!Wnd
) /* Fall back */
880 Ret
= NtUserGetAncestor(hwnd
, gaFlags
);
890 GetClientRect(HWND hWnd
, LPRECT lpRect
)
892 PWND Wnd
= ValidateHwnd(hWnd
);
896 lpRect
->left
= lpRect
->top
= 0;
897 lpRect
->right
= Wnd
->rcClient
.right
- Wnd
->rcClient
.left
;
898 lpRect
->bottom
= Wnd
->rcClient
.bottom
- Wnd
->rcClient
.top
;
910 GetLastActivePopup(HWND hWnd
)
915 Wnd
= ValidateHwnd(hWnd
);
920 if (Wnd
->hWndLastActive
)
921 Ret
= Wnd
->hWndLastActive
;
923 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
942 Wnd
= ValidateHwnd(hWnd
);
948 if (Wnd
->style
& WS_CHILD
)
950 if (Wnd
->spwndParent
!= NULL
)
951 WndParent
= DesktopPtrToUser(Wnd
->spwndParent
);
953 else if (Wnd
->style
& WS_POPUP
)
955 if (Wnd
->spwndOwner
!= NULL
)
956 WndParent
= DesktopPtrToUser(Wnd
->spwndOwner
);
959 if (WndParent
!= NULL
)
960 Ret
= UserHMGetHandle(WndParent
);
962 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
977 GetProcessDefaultLayout(DWORD
*pdwDefaultLayout
)
979 if (!pdwDefaultLayout
)
981 SetLastError(ERROR_INVALID_PARAMETER
);
987 *pdwDefaultLayout
= 0;
1002 Wnd
= ValidateHwnd(hWnd
);
1012 if (Wnd
->spwndOwner
!= NULL
)
1013 FoundWnd
= DesktopPtrToUser(Wnd
->spwndOwner
);
1017 if(Wnd
->spwndParent
!= NULL
)
1019 FoundWnd
= DesktopPtrToUser(Wnd
->spwndParent
);
1020 if (FoundWnd
->spwndChild
!= NULL
)
1021 FoundWnd
= DesktopPtrToUser(FoundWnd
->spwndChild
);
1025 if (Wnd
->spwndNext
!= NULL
)
1026 FoundWnd
= DesktopPtrToUser(Wnd
->spwndNext
);
1030 if (Wnd
->spwndPrev
!= NULL
)
1031 FoundWnd
= DesktopPtrToUser(Wnd
->spwndPrev
);
1035 if (Wnd
->spwndChild
!= NULL
)
1036 FoundWnd
= DesktopPtrToUser(Wnd
->spwndChild
);
1041 while ( FoundWnd
->spwndNext
!= NULL
)
1042 FoundWnd
= DesktopPtrToUser(FoundWnd
->spwndNext
);
1050 if (FoundWnd
!= NULL
)
1051 Ret
= UserHMGetHandle(FoundWnd
);
1053 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1067 GetTopWindow(HWND hWnd
)
1069 if (!hWnd
) hWnd
= GetDesktopWindow();
1070 return GetWindow(hWnd
, GW_CHILD
);
1078 GetWindowInfo(HWND hWnd
,
1086 if ( !pwi
|| pwi
->cbSize
!= sizeof(WINDOWINFO
))
1087 SetLastError(ERROR_INVALID_PARAMETER
); // Just set the error and go!
1089 pWnd
= ValidateHwnd(hWnd
);
1093 UserGetWindowBorders(pWnd
->style
, pWnd
->ExStyle
, &Size
, FALSE
);
1097 pCls
= DesktopPtrToUser(pWnd
->pcls
);
1098 pwi
->rcWindow
= pWnd
->rcWindow
;
1099 pwi
->rcClient
= pWnd
->rcClient
;
1100 pwi
->dwStyle
= pWnd
->style
;
1101 pwi
->dwExStyle
= pWnd
->ExStyle
;
1102 pwi
->cxWindowBorders
= Size
.cx
;
1103 pwi
->cyWindowBorders
= Size
.cy
;
1104 pwi
->dwWindowStatus
= 0;
1105 if (pWnd
->state
& WNDS_ACTIVEFRAME
)
1106 pwi
->dwWindowStatus
= WS_ACTIVECAPTION
;
1107 pwi
->atomWindowType
= (pCls
? pCls
->atomClassName
: 0 );
1109 if ( pWnd
->state2
& WNDS2_WIN50COMPAT
)
1111 pwi
->wCreatorVersion
= 0x500;
1113 else if ( pWnd
->state2
& WNDS2_WIN40COMPAT
)
1115 pwi
->wCreatorVersion
= 0x400;
1117 else if ( pWnd
->state2
& WNDS2_WIN31COMPAT
)
1119 pwi
->wCreatorVersion
= 0x30A;
1123 pwi
->wCreatorVersion
= 0x300;
1128 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1142 GetWindowModuleFileNameA(HWND hwnd
,
1144 UINT cchFileNameMax
)
1146 PWND Wnd
= ValidateHwnd(hwnd
);
1151 return GetModuleFileNameA(Wnd
->hModule
, lpszFileName
, cchFileNameMax
);
1159 GetWindowModuleFileNameW(HWND hwnd
,
1160 LPWSTR lpszFileName
,
1161 UINT cchFileNameMax
)
1163 PWND Wnd
= ValidateHwnd(hwnd
);
1168 return GetModuleFileNameW( Wnd
->hModule
, lpszFileName
, cchFileNameMax
);
1176 GetWindowRect(HWND hWnd
,
1179 PWND Wnd
= ValidateHwnd(hWnd
);
1183 *lpRect
= Wnd
->rcWindow
;
1195 GetWindowTextA(HWND hWnd
, LPSTR lpString
, int nMaxCount
)
1201 if (lpString
== NULL
)
1204 Wnd
= ValidateHwnd(hWnd
);
1210 if (!TestWindowProcess( Wnd
))
1214 /* do not send WM_GETTEXT messages to other processes */
1215 Length
= Wnd
->strName
.Length
/ sizeof(WCHAR
);
1218 Buffer
= DesktopPtrToUser(Wnd
->strName
.Buffer
);
1221 if (!WideCharToMultiByte(CP_ACP
,
1230 lpString
[nMaxCount
- 1] = '\0';
1243 Wnd
= NULL
; /* Don't send a message */
1246 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1250 Wnd
= NULL
; /* Don't send a message */
1255 Length
= SendMessageA(hWnd
, WM_GETTEXT
, nMaxCount
, (LPARAM
)lpString
);
1265 GetWindowTextLengthA(HWND hWnd
)
1267 return(SendMessageA(hWnd
, WM_GETTEXTLENGTH
, 0, 0));
1275 GetWindowTextLengthW(HWND hWnd
)
1277 return(SendMessageW(hWnd
, WM_GETTEXTLENGTH
, 0, 0));
1285 GetWindowTextW(HWND hWnd
, LPWSTR lpString
, int nMaxCount
)
1291 if (lpString
== NULL
)
1294 Wnd
= ValidateHwnd(hWnd
);
1300 if (!TestWindowProcess( Wnd
))
1304 /* do not send WM_GETTEXT messages to other processes */
1305 Length
= Wnd
->strName
.Length
/ sizeof(WCHAR
);
1308 Buffer
= DesktopPtrToUser(Wnd
->strName
.Buffer
);
1311 RtlCopyMemory(lpString
,
1313 (Length
+ 1) * sizeof(WCHAR
));
1325 Wnd
= NULL
; /* Don't send a message */
1328 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1332 Wnd
= NULL
; /* Don't send a message */
1337 Length
= SendMessageW(hWnd
, WM_GETTEXT
, nMaxCount
, (LPARAM
)lpString
);
1343 GetWindowThreadProcessId(HWND hWnd
,
1344 LPDWORD lpdwProcessId
)
1348 PWND pWnd
= ValidateHwnd(hWnd
);
1350 if (!pWnd
) return Ret
;
1352 ti
= pWnd
->head
.pti
;
1356 if (ti
== GetW32ThreadInfo())
1357 { // We are current.
1358 //FIXME("Current!\n");
1360 *lpdwProcessId
= (DWORD
)NtCurrentTeb()->ClientId
.UniqueProcess
;
1361 Ret
= (DWORD
)NtCurrentTeb()->ClientId
.UniqueThread
;
1364 { // Ask kernel for info.
1365 //FIXME("Kernel call!\n");
1367 *lpdwProcessId
= NtUserQueryWindow(hWnd
, QUERY_WINDOW_UNIQUE_PROCESS_ID
);
1368 Ret
= NtUserQueryWindow(hWnd
, QUERY_WINDOW_UNIQUE_THREAD_ID
);
1379 IsChild(HWND hWndParent
,
1382 PWND WndParent
, Wnd
;
1385 WndParent
= ValidateHwnd(hWndParent
);
1388 Wnd
= ValidateHwnd(hWnd
);
1396 if (Wnd
->spwndParent
!= NULL
)
1398 Wnd
= DesktopPtrToUser(Wnd
->spwndParent
);
1399 if (Wnd
== WndParent
)
1409 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1425 PWND Wnd
= ValidateHwnd(hWnd
);
1428 return (Wnd
->style
& WS_MINIMIZE
) != 0;
1440 PWND Wnd
= ValidateHwndNoErr(hWnd
);
1443 /* FIXME: If window is being destroyed return FALSE! */
1455 IsWindowUnicode(HWND hWnd
)
1457 PWND Wnd
= ValidateHwnd(hWnd
);
1460 return Wnd
->Unicode
;
1470 IsWindowVisible(HWND hWnd
)
1473 PWND Wnd
= ValidateHwnd(hWnd
);
1483 if (!(Wnd
->style
& WS_VISIBLE
))
1489 if (Wnd
->spwndParent
!= NULL
)
1490 Wnd
= DesktopPtrToUser(Wnd
->spwndParent
);
1494 } while (Wnd
!= NULL
);
1496 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1511 IsWindowEnabled(HWND hWnd
)
1513 // AG: I don't know if child windows are affected if the parent is
1514 // disabled. I think they stop processing messages but stay appearing
1517 return !(GetWindowLongPtrW(hWnd
, GWL_STYLE
) & WS_DISABLED
);
1527 return (GetWindowLongPtrW(hWnd
, GWL_STYLE
) & WS_MAXIMIZE
) != 0;
1535 LockSetForegroundWindow(UINT uLockCode
)
1546 AnimateWindow(HWND hwnd
,
1550 /* FIXME Add animation code */
1552 /* If trying to show/hide and it's already *
1553 * shown/hidden or invalid window, fail with *
1554 * invalid parameter */
1557 visible
= IsWindowVisible(hwnd
);
1558 if(!IsWindow(hwnd
) ||
1559 (visible
&& !(dwFlags
& AW_HIDE
)) ||
1560 (!visible
&& (dwFlags
& AW_HIDE
)))
1562 SetLastError(ERROR_INVALID_PARAMETER
);
1566 ShowWindow(hwnd
, (dwFlags
& AW_HIDE
) ? SW_HIDE
: ((dwFlags
& AW_ACTIVATE
) ? SW_SHOW
: SW_SHOWNA
));
1578 if (!(GetWindowLongPtrW(hWnd
, GWL_STYLE
) & WS_MINIMIZE
))
1581 ShowWindow(hWnd
,SW_RESTORE
);
1590 RealChildWindowFromPoint(HWND hwndParent
,
1591 POINT ptParentClientCoords
)
1593 return ChildWindowFromPointEx(hwndParent
, ptParentClientCoords
, CWP_SKIPTRANSPARENT
);
1600 SetForegroundWindow(HWND hWnd
)
1602 return NtUserCallHwndLock(hWnd
, HWNDLOCK_ROUTINE_SETFOREGROUNDWINDOW
);
1610 SetProcessDefaultLayout(DWORD dwDefaultLayout
)
1612 if (dwDefaultLayout
== 0)
1624 SetWindowTextA(HWND hWnd
,
1628 if(!GetWindowThreadProcessId(hWnd
, &ProcessId
))
1633 if(ProcessId
!= GetCurrentProcessId())
1635 /* do not send WM_GETTEXT messages to other processes */
1637 DefSetText(hWnd
, (PCWSTR
)lpString
, TRUE
);
1639 if ((GetWindowLongPtrW(hWnd
, GWL_STYLE
) & WS_CAPTION
) == WS_CAPTION
)
1641 DefWndNCPaint(hWnd
, (HRGN
)1, -1);
1646 return SendMessageA(hWnd
, WM_SETTEXT
, 0, (LPARAM
)lpString
);
1654 SetWindowTextW(HWND hWnd
,
1658 if(!GetWindowThreadProcessId(hWnd
, &ProcessId
))
1663 if(ProcessId
!= GetCurrentProcessId())
1665 /* do not send WM_GETTEXT messages to other processes */
1667 DefSetText(hWnd
, lpString
, FALSE
);
1669 if ((GetWindowLongPtrW(hWnd
, GWL_STYLE
) & WS_CAPTION
) == WS_CAPTION
)
1671 DefWndNCPaint(hWnd
, (HRGN
)1, -1);
1676 return SendMessageW(hWnd
, WM_SETTEXT
, 0, (LPARAM
)lpString
);
1684 ShowOwnedPopups(HWND hWnd
,
1687 return (BOOL
)NtUserCallTwoParam((DWORD_PTR
)hWnd
, fShow
, TWOPARAM_ROUTINE_SHOWOWNEDPOPUPS
);
1695 UpdateLayeredWindow( HWND hwnd
,
1705 if ( dwFlags
& ULW_EX_NORESIZE
)
1706 dwFlags
= ~(ULW_EX_NORESIZE
|ULW_OPAQUE
|ULW_ALPHA
|ULW_COLORKEY
);
1707 return NtUserUpdateLayeredWindow( hwnd
,
1723 UpdateLayeredWindowIndirect(HWND hwnd
,
1724 const UPDATELAYEREDWINDOWINFO
*info
)
1726 if (info
&& info
->cbSize
== sizeof(info
))
1728 return NtUserUpdateLayeredWindow( hwnd
,
1730 (POINT
*)info
->pptDst
,
1731 (SIZE
*)info
->psize
,
1733 (POINT
*)info
->pptSrc
,
1735 (BLENDFUNCTION
*)info
->pblend
,
1737 (RECT
*)info
->prcDirty
);
1739 SetLastError(ERROR_INVALID_PARAMETER
);
1748 WindowFromPoint(POINT Point
)
1750 //TODO: Determine what the actual parameters to
1751 // NtUserWindowFromPoint are.
1752 return NtUserWindowFromPoint(Point
.x
, Point
.y
);
1760 MapWindowPoints(HWND hWndFrom
, HWND hWndTo
, LPPOINT lpPoints
, UINT cPoints
)
1762 PWND FromWnd
, ToWnd
;
1766 FromWnd
= ValidateHwndOrDesk(hWndFrom
);
1770 ToWnd
= ValidateHwndOrDesk(hWndTo
);
1774 Delta
.x
= FromWnd
->rcClient
.left
- ToWnd
->rcClient
.left
;
1775 Delta
.y
= FromWnd
->rcClient
.top
- ToWnd
->rcClient
.top
;
1777 for (i
= 0; i
!= cPoints
; i
++)
1779 lpPoints
[i
].x
+= Delta
.x
;
1780 lpPoints
[i
].y
+= Delta
.y
;
1783 return MAKELONG(LOWORD(Delta
.x
), LOWORD(Delta
.y
));
1791 ScreenToClient(HWND hWnd
, LPPOINT lpPoint
)
1793 PWND Wnd
, DesktopWnd
;
1795 Wnd
= ValidateHwnd(hWnd
);
1799 DesktopWnd
= GetThreadDesktopWnd();
1801 lpPoint
->x
+= DesktopWnd
->rcClient
.left
- Wnd
->rcClient
.left
;
1802 lpPoint
->y
+= DesktopWnd
->rcClient
.top
- Wnd
->rcClient
.top
;
1812 ClientToScreen(HWND hWnd
, LPPOINT lpPoint
)
1814 PWND Wnd
, DesktopWnd
;
1816 Wnd
= ValidateHwnd(hWnd
);
1820 DesktopWnd
= GetThreadDesktopWnd();
1822 lpPoint
->x
+= Wnd
->rcClient
.left
- DesktopWnd
->rcClient
.left
;
1823 lpPoint
->y
+= Wnd
->rcClient
.top
- DesktopWnd
->rcClient
.top
;
1833 SetWindowContextHelpId(HWND hwnd
,
1834 DWORD dwContextHelpId
)
1836 return NtUserSetWindowContextHelpId(hwnd
, dwContextHelpId
);
1844 GetWindowContextHelpId(HWND hwnd
)
1846 return NtUserCallHwnd(hwnd
, HWND_ROUTINE_GETWNDCONTEXTHLPID
);
1853 InternalGetWindowText(HWND hWnd
, LPWSTR lpString
, int nMaxCount
)
1855 INT Ret
= NtUserInternalGetWindowText(hWnd
, lpString
, nMaxCount
);
1865 IsHungAppWindow(HWND hwnd
)
1867 return (NtUserQueryWindow(hwnd
, QUERY_WINDOW_ISHUNG
) != 0);
1874 SetLastErrorEx(DWORD dwErrCode
, DWORD dwType
)
1876 SetLastError(dwErrCode
);
1885 return (HWND
)NtUserGetThreadState(THREADSTATE_FOCUSWINDOW
);
1889 GetRealWindowOwner(HWND hwnd
)
1891 return NtUserQueryWindow(hwnd
, QUERY_WINDOW_REAL_ID
);
1898 SetTaskmanWindow(HWND hWnd
)
1900 return NtUserCallHwndOpt(hWnd
, HWNDOPT_ROUTINE_SETTASKMANWINDOW
);
1907 SetProgmanWindow(HWND hWnd
)
1909 return NtUserCallHwndOpt(hWnd
, HWNDOPT_ROUTINE_SETPROGMANWINDOW
);
1916 GetProgmanWindow(VOID
)
1918 return (HWND
)NtUserGetThreadState(THREADSTATE_PROGMANWINDOW
);
1925 GetTaskmanWindow(VOID
)
1927 return (HWND
)NtUserGetThreadState(THREADSTATE_TASKMANWINDOW
);
1934 ScrollWindow(HWND hWnd
,
1938 CONST RECT
*prcClip
)
1940 return NtUserScrollWindowEx(hWnd
,
1947 (lpRect
? 0 : SW_SCROLLCHILDREN
) | SW_INVALIDATE
) != ERROR
;
1955 ScrollWindowEx(HWND hWnd
,
1958 CONST RECT
*prcScroll
,
1959 CONST RECT
*prcClip
,
1964 return NtUserScrollWindowEx(hWnd
,
1980 return NtUserAnyPopup();
1987 IsWindowInDestroy(HWND hWnd
)
1989 return NtUserIsWindowInDestroy(hWnd
);
1996 DisableProcessWindowsGhosting(VOID
)
1998 NtUserEnableProcessWindowGhosting(FALSE
);