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 NtUserShowWindow(hwnd
, SW_SHOW
);
111 CascadeChildWindows ( HWND hWndParent
, WORD wFlags
)
113 return CascadeWindows(hWndParent
, wFlags
, NULL
, 0, NULL
);
121 ChildWindowFromPoint(HWND hWndParent
,
124 return (HWND
) NtUserChildWindowFromPointEx(hWndParent
, Point
.x
, Point
.y
, 0);
132 ChildWindowFromPointEx(HWND hwndParent
,
136 return (HWND
) NtUserChildWindowFromPointEx(hwndParent
, pt
.x
, pt
.y
, uFlags
);
144 CloseWindow(HWND hWnd
)
146 SendMessageA(hWnd
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
153 User32CreateWindowEx(DWORD dwExStyle
,
167 UNICODE_STRING WindowName
;
168 UNICODE_STRING ClassName
;
174 DbgPrint("[window] User32CreateWindowEx style %d, exstyle %d, parent %d\n", dwStyle
, dwExStyle
, hWndParent
);
177 if (IS_ATOM(lpClassName
))
179 RtlInitUnicodeString(&ClassName
, NULL
);
180 ClassName
.Buffer
= (LPWSTR
)lpClassName
;
185 RtlInitUnicodeString(&ClassName
, (PCWSTR
)lpClassName
);
188 if (!RtlCreateUnicodeStringFromAsciiz(&(ClassName
), (PCSZ
)lpClassName
))
190 SetLastError(ERROR_OUTOFMEMORY
);
197 RtlInitUnicodeString(&WindowName
, (PCWSTR
)lpWindowName
);
200 if (!RtlCreateUnicodeStringFromAsciiz(&WindowName
, (PCSZ
)lpWindowName
))
202 if (!IS_ATOM(lpClassName
))
204 RtlFreeUnicodeString(&ClassName
);
206 SetLastError(ERROR_OUTOFMEMORY
);
211 if(!hMenu
&& (dwStyle
& (WS_OVERLAPPEDWINDOW
| WS_POPUP
)))
215 wceW
.cbSize
= sizeof(WNDCLASSEXW
);
216 if(GetClassInfoExW(hInstance
, (LPCWSTR
)lpClassName
, &wceW
) && wceW
.lpszMenuName
)
218 hMenu
= LoadMenuW(hInstance
, wceW
.lpszMenuName
);
223 wceA
.cbSize
= sizeof(WNDCLASSEXA
);
224 if(GetClassInfoExA(hInstance
, lpClassName
, &wceA
) && wceA
.lpszMenuName
)
226 hMenu
= LoadMenuA(hInstance
, wceA
.lpszMenuName
);
231 Handle
= NtUserCreateWindowEx(dwExStyle
,
248 DbgPrint("[window] NtUserCreateWindowEx() == %d\n", Handle
);
253 RtlFreeUnicodeString(&WindowName
);
255 if (!IS_ATOM(lpClassName
))
257 RtlFreeUnicodeString(&ClassName
);
268 CreateWindowExA(DWORD dwExStyle
,
281 MDICREATESTRUCTA mdi
;
284 if (dwExStyle
& WS_EX_MDICHILD
)
290 /* lpParams of WM_[NC]CREATE is different for MDI children.
291 * MDICREATESTRUCT members have the originally passed values.
293 mdi
.szClass
= lpClassName
;
294 mdi
.szTitle
= lpWindowName
;
295 mdi
.hOwner
= hInstance
;
301 mdi
.lParam
= (LPARAM
)lpParam
;
303 lpParam
= (LPVOID
)&mdi
;
305 if (GetWindowLongW(hWndParent
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
307 if (dwStyle
& WS_POPUP
)
309 WARN("WS_POPUP with MDIS_ALLCHILDSTYLES is not allowed\n");
312 dwStyle
|= (WS_CHILD
| WS_CLIPSIBLINGS
);
316 dwStyle
&= ~WS_POPUP
;
317 dwStyle
|= (WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CAPTION
|
318 WS_SYSMENU
| WS_THICKFRAME
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
);
321 top_child
= GetWindow(hWndParent
, GW_CHILD
);
325 /* Restore current maximized child */
326 if((dwStyle
& WS_VISIBLE
) && IsZoomed(top_child
))
328 TRACE("Restoring current maximized child %p\n", top_child
);
329 SendMessageW( top_child
, WM_SETREDRAW
, FALSE
, 0 );
330 NtUserShowWindow(top_child
, SW_RESTORE
);
331 SendMessageW( top_child
, WM_SETREDRAW
, TRUE
, 0 );
335 MDI_CalcDefaultChildPos(hWndParent
, -1, mPos
, 0, &id
);
337 if (!(dwStyle
& WS_POPUP
)) hMenu
= (HMENU
)id
;
339 if (dwStyle
& (WS_CHILD
| WS_POPUP
))
341 if (x
== CW_USEDEFAULT
|| x
== CW_USEDEFAULT16
)
346 if (nWidth
== CW_USEDEFAULT
|| nWidth
== CW_USEDEFAULT16
|| !nWidth
)
348 if (nHeight
== CW_USEDEFAULT
|| nHeight
== CW_USEDEFAULT16
|| !nHeight
)
353 hwnd
= User32CreateWindowEx(dwExStyle
,
374 CreateWindowExW(DWORD dwExStyle
,
376 LPCWSTR lpWindowName
,
387 MDICREATESTRUCTW mdi
;
390 if (dwExStyle
& WS_EX_MDICHILD
)
396 /* lpParams of WM_[NC]CREATE is different for MDI children.
397 * MDICREATESTRUCT members have the originally passed values.
399 mdi
.szClass
= lpClassName
;
400 mdi
.szTitle
= lpWindowName
;
401 mdi
.hOwner
= hInstance
;
407 mdi
.lParam
= (LPARAM
)lpParam
;
409 lpParam
= (LPVOID
)&mdi
;
411 if (GetWindowLongW(hWndParent
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
413 if (dwStyle
& WS_POPUP
)
415 WARN("WS_POPUP with MDIS_ALLCHILDSTYLES is not allowed\n");
418 dwStyle
|= (WS_CHILD
| WS_CLIPSIBLINGS
);
422 dwStyle
&= ~WS_POPUP
;
423 dwStyle
|= (WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CAPTION
|
424 WS_SYSMENU
| WS_THICKFRAME
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
);
427 top_child
= GetWindow(hWndParent
, GW_CHILD
);
431 /* Restore current maximized child */
432 if((dwStyle
& WS_VISIBLE
) && IsZoomed(top_child
))
434 TRACE("Restoring current maximized child %p\n", top_child
);
435 SendMessageW( top_child
, WM_SETREDRAW
, FALSE
, 0 );
436 NtUserShowWindow(top_child
, SW_RESTORE
);
437 SendMessageW( top_child
, WM_SETREDRAW
, TRUE
, 0 );
441 MDI_CalcDefaultChildPos(hWndParent
, -1, mPos
, 0, &id
);
443 if (!(dwStyle
& WS_POPUP
)) hMenu
= (HMENU
)id
;
445 if (dwStyle
& (WS_CHILD
| WS_POPUP
))
447 if (x
== CW_USEDEFAULT
|| x
== CW_USEDEFAULT16
)
452 if (nWidth
== CW_USEDEFAULT
|| nWidth
== CW_USEDEFAULT16
|| !nWidth
)
454 if (nHeight
== CW_USEDEFAULT
|| nHeight
== CW_USEDEFAULT16
|| !nHeight
)
459 hwnd
= User32CreateWindowEx(dwExStyle
,
460 (LPCSTR
) lpClassName
,
461 (LPCSTR
) lpWindowName
,
479 DeferWindowPos(HDWP hWinPosInfo
,
481 HWND hWndInsertAfter
,
489 return NtUserDeferWindowPos(hWinPosInfo
, hWnd
, hWndInsertAfter
, x
, y
, cx
, cy
, uFlags
);
491 NtUserSetWindowPos(hWnd
, hWndInsertAfter
, x
, y
, cx
, cy
, uFlags
);
501 EndDeferWindowPos(HDWP hWinPosInfo
)
516 GetDesktopWindow(VOID
)
523 Wnd
= GetThreadDesktopWnd();
525 Ret
= UserHMGetHandle(Wnd
);
527 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
538 User32EnumWindows(HDESK hDesktop
,
545 DWORD i
, dwCount
= 0;
552 SetLastError ( ERROR_INVALID_PARAMETER
);
556 /* FIXME instead of always making two calls, should we use some
557 sort of persistent buffer and only grow it ( requiring a 2nd
558 call ) when the buffer wasn't already big enough? */
559 /* first get how many window entries there are */
560 Status
= NtUserBuildHwndList(hDesktop
,
567 if (!NT_SUCCESS(Status
))
570 /* allocate buffer to receive HWND handles */
571 hHeap
= GetProcessHeap();
572 pHwnd
= HeapAlloc(hHeap
, 0, sizeof(HWND
)*(dwCount
+1));
575 SetLastError ( ERROR_NOT_ENOUGH_MEMORY
);
579 /* now call kernel again to fill the buffer this time */
580 Status
= NtUserBuildHwndList(hDesktop
,
587 if (!NT_SUCCESS(Status
))
590 HeapFree(hHeap
, 0, pHwnd
);
594 /* call the user's callback function until we're done or
595 they tell us to quit */
596 for ( i
= 0; i
< dwCount
; i
++ )
598 /* FIXME I'm only getting NULLs from Thread Enumeration, and it's
599 * probably because I'm not doing it right in NtUserBuildHwndList.
600 * Once that's fixed, we shouldn't have to check for a NULL HWND
603 if (!(ULONG
)pHwnd
[i
]) /* don't enumerate a NULL HWND */
605 if (!(*lpfn
)(pHwnd
[i
], lParam
))
607 HeapFree ( hHeap
, 0, pHwnd
);
612 HeapFree(hHeap
, 0, pHwnd
);
621 EnumChildWindows(HWND hWndParent
,
622 WNDENUMPROC lpEnumFunc
,
627 return EnumWindows(lpEnumFunc
, lParam
);
629 return User32EnumWindows(NULL
, hWndParent
, lpEnumFunc
, lParam
, 0, TRUE
);
637 EnumThreadWindows(DWORD dwThreadId
,
642 dwThreadId
= GetCurrentThreadId();
643 return User32EnumWindows(NULL
, NULL
, lpfn
, lParam
, dwThreadId
, FALSE
);
651 EnumWindows(WNDENUMPROC lpEnumFunc
,
654 return User32EnumWindows(NULL
, NULL
, lpEnumFunc
, lParam
, 0, FALSE
);
662 EnumDesktopWindows(HDESK hDesktop
,
666 return User32EnumWindows(hDesktop
, NULL
, lpfn
, lParam
, 0, FALSE
);
674 FindWindowExA(HWND hwndParent
,
679 UNICODE_STRING ucClassName
, *pucClassName
= NULL
;
680 UNICODE_STRING ucWindowName
, *pucWindowName
= NULL
;
683 if (IS_ATOM(lpszClass
))
685 ucClassName
.Buffer
= (LPWSTR
)lpszClass
;
686 ucClassName
.Length
= 0;
687 pucClassName
= &ucClassName
;
689 else if (lpszClass
!= NULL
)
691 if (!RtlCreateUnicodeStringFromAsciiz(&ucClassName
,
694 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
697 pucClassName
= &ucClassName
;
700 if (lpszWindow
!= NULL
)
702 if (!RtlCreateUnicodeStringFromAsciiz(&ucWindowName
,
705 if (!IS_ATOM(lpszClass
) && lpszClass
!= NULL
)
706 RtlFreeUnicodeString(&ucWindowName
);
708 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
712 pucWindowName
= &ucWindowName
;
715 Result
= NtUserFindWindowEx(hwndParent
,
721 if (!IS_ATOM(lpszClass
) && lpszClass
!= NULL
)
722 RtlFreeUnicodeString(&ucClassName
);
723 if (lpszWindow
!= NULL
)
724 RtlFreeUnicodeString(&ucWindowName
);
734 FindWindowExW(HWND hwndParent
,
739 UNICODE_STRING ucClassName
, *pucClassName
= NULL
;
740 UNICODE_STRING ucWindowName
, *pucWindowName
= NULL
;
742 if (IS_ATOM(lpszClass
))
744 ucClassName
.Length
= 0;
745 ucClassName
.Buffer
= (LPWSTR
)lpszClass
;
746 pucClassName
= &ucClassName
;
748 else if (lpszClass
!= NULL
)
750 RtlInitUnicodeString(&ucClassName
,
752 pucClassName
= &ucClassName
;
755 if (lpszWindow
!= NULL
)
757 RtlInitUnicodeString(&ucWindowName
,
759 pucWindowName
= &ucWindowName
;
762 return NtUserFindWindowEx(hwndParent
,
774 FindWindowA(LPCSTR lpClassName
, LPCSTR lpWindowName
)
776 //FIXME: FindWindow does not search children, but FindWindowEx does.
777 // what should we do about this?
778 return FindWindowExA (NULL
, NULL
, lpClassName
, lpWindowName
);
786 FindWindowW(LPCWSTR lpClassName
, LPCWSTR lpWindowName
)
790 There was a FIXME here earlier, but I think it is just a documentation unclarity.
792 FindWindow only searches top level windows. What they mean is that child
793 windows of other windows than the desktop can be searched.
794 FindWindowExW never does a recursive search.
799 return FindWindowExW(NULL
, NULL
, lpClassName
, lpWindowName
);
808 GetAltTabInfoA(HWND hwnd
,
823 GetAltTabInfoW(HWND hwnd
,
838 GetAncestor(HWND hwnd
, UINT gaFlags
)
841 PWINDOW Ancestor
, Wnd
;
843 Wnd
= ValidateHwnd(hwnd
);
853 if (Wnd
->Parent
!= NULL
)
854 Ancestor
= DesktopPtrToUser(Wnd
->Parent
);
858 /* FIXME: Call win32k for now */
863 if (Ancestor
!= NULL
)
864 Ret
= UserHMGetHandle(Ancestor
);
866 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
872 if (!Wnd
) /* Fall back */
873 Ret
= NtUserGetAncestor(hwnd
, gaFlags
);
883 GetClientRect(HWND hWnd
, LPRECT lpRect
)
885 PWINDOW Wnd
= ValidateHwnd(hWnd
);
889 lpRect
->left
= lpRect
->top
= 0;
890 lpRect
->right
= Wnd
->ClientRect
.right
- Wnd
->ClientRect
.left
;
891 lpRect
->bottom
= Wnd
->ClientRect
.bottom
- Wnd
->ClientRect
.top
;
903 GetLastActivePopup(HWND hWnd
)
908 Wnd
= ValidateHwnd(hWnd
);
913 if (Wnd
->hWndLastActive
)
914 Ret
= Wnd
->hWndLastActive
;
916 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
932 PWINDOW Wnd
, WndParent
;
935 Wnd
= ValidateHwnd(hWnd
);
941 if (Wnd
->Style
& WS_CHILD
)
943 if (Wnd
->Parent
!= NULL
)
944 WndParent
= DesktopPtrToUser(Wnd
->Parent
);
946 else if (Wnd
->Style
& WS_POPUP
)
948 if (Wnd
->Owner
!= NULL
)
949 WndParent
= DesktopPtrToUser(Wnd
->Owner
);
952 if (WndParent
!= NULL
)
953 Ret
= UserHMGetHandle(WndParent
);
955 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
970 GetProcessDefaultLayout(DWORD
*pdwDefaultLayout
)
972 if (!pdwDefaultLayout
)
974 SetLastError(ERROR_INVALID_PARAMETER
);
980 *pdwDefaultLayout
= 0;
992 PWINDOW Wnd
, FoundWnd
;
995 Wnd
= ValidateHwnd(hWnd
);
1005 if (Wnd
->Owner
!= NULL
)
1006 FoundWnd
= DesktopPtrToUser(Wnd
->Owner
);
1010 /* FIXME: Optimize! Fall back to NtUserGetWindow for now... */
1015 if (FoundWnd
!= NULL
)
1016 Ret
= UserHMGetHandle(FoundWnd
);
1018 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1024 if (!Wnd
) /* Fall back to win32k... */
1025 Ret
= NtUserGetWindow(hWnd
, uCmd
);
1035 GetTopWindow(HWND hWnd
)
1037 if (!hWnd
) hWnd
= GetDesktopWindow();
1038 return GetWindow(hWnd
, GW_CHILD
);
1046 GetWindowInfo(HWND hwnd
,
1049 return NtUserGetWindowInfo(hwnd
, pwi
);
1057 GetWindowModuleFileNameA(HWND hwnd
,
1059 UINT cchFileNameMax
)
1063 if(!(hWndInst
= NtUserGetWindowInstance(hwnd
)))
1068 return GetModuleFileNameA(hWndInst
, lpszFileName
, cchFileNameMax
);
1076 GetWindowModuleFileNameW(HWND hwnd
,
1077 LPWSTR lpszFileName
,
1078 UINT cchFileNameMax
)
1082 if(!(hWndInst
= NtUserGetWindowInstance(hwnd
)))
1087 return GetModuleFileNameW(hWndInst
, lpszFileName
, cchFileNameMax
);
1095 GetWindowRect(HWND hWnd
,
1098 PWINDOW Wnd
= ValidateHwnd(hWnd
);
1102 *lpRect
= Wnd
->WindowRect
;
1114 GetWindowTextA(HWND hWnd
, LPSTR lpString
, int nMaxCount
)
1120 if (lpString
== NULL
)
1123 Wnd
= ValidateHwnd(hWnd
);
1129 if (Wnd
->pi
!= g_kpi
)
1133 /* do not send WM_GETTEXT messages to other processes */
1134 Length
= Wnd
->WindowName
.Length
/ sizeof(WCHAR
);
1137 Buffer
= DesktopPtrToUser(Wnd
->WindowName
.Buffer
);
1140 if (!WideCharToMultiByte(CP_ACP
,
1149 lpString
[nMaxCount
- 1] = '\0';
1162 Wnd
= NULL
; /* Don't send a message */
1165 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1169 Wnd
= NULL
; /* Don't send a message */
1174 Length
= SendMessageA(hWnd
, WM_GETTEXT
, nMaxCount
, (LPARAM
)lpString
);
1184 GetWindowTextLengthA(HWND hWnd
)
1186 return(SendMessageA(hWnd
, WM_GETTEXTLENGTH
, 0, 0));
1194 GetWindowTextLengthW(HWND hWnd
)
1196 return(SendMessageW(hWnd
, WM_GETTEXTLENGTH
, 0, 0));
1204 GetWindowTextW(HWND hWnd
, LPWSTR lpString
, int nMaxCount
)
1210 if (lpString
== NULL
)
1213 Wnd
= ValidateHwnd(hWnd
);
1219 if (Wnd
->pi
!= g_kpi
)
1223 /* do not send WM_GETTEXT messages to other processes */
1224 Length
= Wnd
->WindowName
.Length
/ sizeof(WCHAR
);
1227 Buffer
= DesktopPtrToUser(Wnd
->WindowName
.Buffer
);
1230 RtlCopyMemory(lpString
,
1232 (Length
+ 1) * sizeof(WCHAR
));
1244 Wnd
= NULL
; /* Don't send a message */
1247 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1251 Wnd
= NULL
; /* Don't send a message */
1256 Length
= SendMessageW(hWnd
, WM_GETTEXT
, nMaxCount
, (LPARAM
)lpString
);
1262 GetWindowThreadProcessId(HWND hWnd
,
1263 LPDWORD lpdwProcessId
)
1267 PWINDOW pWnd
= ValidateHwnd(hWnd
);
1269 if (!pWnd
) return Ret
;
1271 ti
= SharedPtrToUser(pWnd
->ti
);
1275 if (ti
== GetW32ThreadInfo())
1276 { // We are current.
1277 //FIXME("Current!\n");
1279 *lpdwProcessId
= (DWORD
)NtCurrentTeb()->ClientId
.UniqueProcess
;
1280 Ret
= (DWORD
)NtCurrentTeb()->ClientId
.UniqueThread
;
1283 { // Ask kernel for info.
1284 //FIXME("Kernel call!\n");
1286 *lpdwProcessId
= NtUserQueryWindow(hWnd
, QUERY_WINDOW_UNIQUE_PROCESS_ID
);
1287 Ret
= NtUserQueryWindow(hWnd
, QUERY_WINDOW_UNIQUE_THREAD_ID
);
1298 IsChild(HWND hWndParent
,
1301 PWINDOW WndParent
, Wnd
;
1304 WndParent
= ValidateHwnd(hWndParent
);
1307 Wnd
= ValidateHwnd(hWnd
);
1315 if (Wnd
->Parent
!= NULL
)
1317 Wnd
= DesktopPtrToUser(Wnd
->Parent
);
1318 if (Wnd
== WndParent
)
1328 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1344 PWINDOW Wnd
= ValidateHwnd(hWnd
);
1347 return (Wnd
->Style
& WS_MINIMIZE
) != 0;
1359 PWINDOW Wnd
= ValidateHwndNoErr(hWnd
);
1362 /* FIXME: If window is being destroyed return FALSE! */
1374 IsWindowUnicode(HWND hWnd
)
1376 PWINDOW Wnd
= ValidateHwnd(hWnd
);
1379 return Wnd
->Unicode
;
1389 IsWindowVisible(HWND hWnd
)
1392 PWINDOW Wnd
= ValidateHwnd(hWnd
);
1402 if (!(Wnd
->Style
& WS_VISIBLE
))
1408 if (Wnd
->Parent
!= NULL
)
1409 Wnd
= DesktopPtrToUser(Wnd
->Parent
);
1413 } while (Wnd
!= NULL
);
1415 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1430 IsWindowEnabled(HWND hWnd
)
1432 // AG: I don't know if child windows are affected if the parent is
1433 // disabled. I think they stop processing messages but stay appearing
1436 return !(GetWindowLongW(hWnd
, GWL_STYLE
) & WS_DISABLED
);
1446 return (GetWindowLongW(hWnd
, GWL_STYLE
) & WS_MAXIMIZE
) != 0;
1454 LockSetForegroundWindow(UINT uLockCode
)
1465 AnimateWindow(HWND hwnd
,
1469 /* FIXME Add animation code */
1471 /* If trying to show/hide and it's already *
1472 * shown/hidden or invalid window, fail with *
1473 * invalid parameter */
1476 visible
= IsWindowVisible(hwnd
);
1477 if(!IsWindow(hwnd
) ||
1478 (visible
&& !(dwFlags
& AW_HIDE
)) ||
1479 (!visible
&& (dwFlags
& AW_HIDE
)))
1481 SetLastError(ERROR_INVALID_PARAMETER
);
1485 NtUserShowWindow(hwnd
, (dwFlags
& AW_HIDE
) ? SW_HIDE
: ((dwFlags
& AW_ACTIVATE
) ? SW_SHOW
: SW_SHOWNA
));
1497 if (!(GetWindowLongW(hWnd
, GWL_STYLE
) & WS_MINIMIZE
))
1500 NtUserShowWindow(hWnd
,SW_RESTORE
);
1509 RealChildWindowFromPoint(HWND hwndParent
,
1510 POINT ptParentClientCoords
)
1512 return ChildWindowFromPointEx(hwndParent
, ptParentClientCoords
, CWP_SKIPTRANSPARENT
);
1519 SetForegroundWindow(HWND hWnd
)
1521 return NtUserCallHwndLock(hWnd
, HWNDLOCK_ROUTINE_SETFOREGROUNDWINDOW
);
1529 SetProcessDefaultLayout(DWORD dwDefaultLayout
)
1531 if (dwDefaultLayout
== 0)
1543 SetWindowTextA(HWND hWnd
,
1547 if(!GetWindowThreadProcessId(hWnd
, &ProcessId
))
1552 if(ProcessId
!= GetCurrentProcessId())
1554 /* do not send WM_GETTEXT messages to other processes */
1556 DefSetText(hWnd
, (PCWSTR
)lpString
, TRUE
);
1558 if ((GetWindowLongW(hWnd
, GWL_STYLE
) & WS_CAPTION
) == WS_CAPTION
)
1560 DefWndNCPaint(hWnd
, (HRGN
)1, -1);
1565 return SendMessageA(hWnd
, WM_SETTEXT
, 0, (LPARAM
)lpString
);
1573 SetWindowTextW(HWND hWnd
,
1577 if(!GetWindowThreadProcessId(hWnd
, &ProcessId
))
1582 if(ProcessId
!= GetCurrentProcessId())
1584 /* do not send WM_GETTEXT messages to other processes */
1586 DefSetText(hWnd
, lpString
, FALSE
);
1588 if ((GetWindowLongW(hWnd
, GWL_STYLE
) & WS_CAPTION
) == WS_CAPTION
)
1590 DefWndNCPaint(hWnd
, (HRGN
)1, -1);
1595 return SendMessageW(hWnd
, WM_SETTEXT
, 0, (LPARAM
)lpString
);
1603 ShowOwnedPopups(HWND hWnd
,
1606 return (BOOL
)NtUserCallTwoParam((DWORD
)hWnd
, fShow
, TWOPARAM_ROUTINE_SHOWOWNEDPOPUPS
);
1614 UpdateLayeredWindowIndirect(HWND hwnd
,
1615 const UPDATELAYEREDWINDOWINFO
*info
)
1626 WindowFromPoint(POINT Point
)
1628 //TODO: Determine what the actual parameters to
1629 // NtUserWindowFromPoint are.
1630 return NtUserWindowFromPoint(Point
.x
, Point
.y
);
1638 MapWindowPoints(HWND hWndFrom
, HWND hWndTo
, LPPOINT lpPoints
, UINT cPoints
)
1640 PWINDOW FromWnd
, ToWnd
;
1644 FromWnd
= ValidateHwndOrDesk(hWndFrom
);
1648 ToWnd
= ValidateHwndOrDesk(hWndTo
);
1652 Delta
.x
= FromWnd
->ClientRect
.left
- ToWnd
->ClientRect
.left
;
1653 Delta
.y
= FromWnd
->ClientRect
.top
- ToWnd
->ClientRect
.top
;
1655 for (i
= 0; i
!= cPoints
; i
++)
1657 lpPoints
[i
].x
+= Delta
.x
;
1658 lpPoints
[i
].y
+= Delta
.y
;
1661 return MAKELONG(LOWORD(Delta
.x
), LOWORD(Delta
.y
));
1669 ScreenToClient(HWND hWnd
, LPPOINT lpPoint
)
1671 PWINDOW Wnd
, DesktopWnd
;
1673 Wnd
= ValidateHwnd(hWnd
);
1677 DesktopWnd
= GetThreadDesktopWnd();
1679 lpPoint
->x
+= DesktopWnd
->ClientRect
.left
- Wnd
->ClientRect
.left
;
1680 lpPoint
->y
+= DesktopWnd
->ClientRect
.top
- Wnd
->ClientRect
.top
;
1690 ClientToScreen(HWND hWnd
, LPPOINT lpPoint
)
1692 PWINDOW Wnd
, DesktopWnd
;
1694 Wnd
= ValidateHwnd(hWnd
);
1698 DesktopWnd
= GetThreadDesktopWnd();
1700 lpPoint
->x
+= Wnd
->ClientRect
.left
- DesktopWnd
->ClientRect
.left
;
1701 lpPoint
->y
+= Wnd
->ClientRect
.top
- DesktopWnd
->ClientRect
.top
;
1711 SetWindowContextHelpId(HWND hwnd
,
1712 DWORD dwContextHelpId
)
1714 return NtUserSetWindowContextHelpId(hwnd
, dwContextHelpId
);
1722 GetWindowContextHelpId(HWND hwnd
)
1724 PWINDOW Wnd
= ValidateHwnd(hwnd
);
1727 return Wnd
->ContextHelpId
;
1737 InternalGetWindowText(HWND hWnd
, LPWSTR lpString
, int nMaxCount
)
1739 INT Ret
= NtUserInternalGetWindowText(hWnd
, lpString
, nMaxCount
);
1749 IsHungAppWindow(HWND hwnd
)
1751 return (NtUserQueryWindow(hwnd
, QUERY_WINDOW_ISHUNG
) != 0);
1758 SetLastErrorEx(DWORD dwErrCode
, DWORD dwType
)
1760 SetLastError(dwErrCode
);
1769 return (HWND
)NtUserGetThreadState(THREADSTATE_FOCUSWINDOW
);
1776 SetTaskmanWindow(HWND hWnd
)
1778 return NtUserCallHwndOpt(hWnd
, HWNDOPT_ROUTINE_SETTASKMANWINDOW
);
1785 SetProgmanWindow(HWND hWnd
)
1787 return NtUserCallHwndOpt(hWnd
, HWNDOPT_ROUTINE_SETPROGMANWINDOW
);
1794 GetProgmanWindow(VOID
)
1796 return (HWND
)NtUserGetThreadState(THREADSTATE_PROGMANWINDOW
);
1803 GetTaskmanWindow(VOID
)
1805 return (HWND
)NtUserGetThreadState(THREADSTATE_TASKMANWINDOW
);
1812 ScrollWindow(HWND hWnd
,
1816 CONST RECT
*prcClip
)
1818 return NtUserScrollWindowEx(hWnd
,
1825 (lpRect
? 0 : SW_SCROLLCHILDREN
) | SW_INVALIDATE
) != ERROR
;
1833 ScrollWindowEx(HWND hWnd
,
1836 CONST RECT
*prcScroll
,
1837 CONST RECT
*prcClip
,
1842 return NtUserScrollWindowEx(hWnd
,
1857 TileChildWindows(HWND hWndParent
, WORD wFlags
)
1859 return TileWindows(hWndParent
, wFlags
, NULL
, 0, NULL
);
1868 return NtUserAnyPopup();
1875 IsWindowInDestroy(HWND hWnd
)
1877 return NtUserIsWindowInDestroy(hWnd
);
1884 DisableProcessWindowsGhosting(VOID
)
1886 NtUserEnableProcessWindowGhosting(FALSE
);