2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
5 * FILE: subsystems/win32/win32k/ntuser/window.c
6 * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
8 * 06-06-2001 CSH Created
11 /* INCLUDES ******************************************************************/
18 #define POINT_IN_RECT(p, r) (((r.bottom >= p.y) && (r.top <= p.y))&&((r.left <= p.x )&&( r.right >= p.x )))
20 /* PRIVATE FUNCTIONS **********************************************************/
25 * Initialize windowing implementation.
33 return STATUS_SUCCESS
;
39 * Cleanup windowing implementation.
43 CleanupWindowImpl(VOID
)
45 return STATUS_SUCCESS
;
48 /* HELPER FUNCTIONS ***********************************************************/
50 BOOL FASTCALL
UserUpdateUiState(PWND Wnd
, WPARAM wParam
)
52 WORD Action
= LOWORD(wParam
);
53 WORD Flags
= HIWORD(wParam
);
55 if (Flags
& ~(UISF_HIDEFOCUS
| UISF_HIDEACCEL
| UISF_ACTIVE
))
57 EngSetLastError(ERROR_INVALID_PARAMETER
);
64 EngSetLastError(ERROR_INVALID_PARAMETER
);
68 if (Flags
& UISF_HIDEFOCUS
)
69 Wnd
->HideFocus
= TRUE
;
70 if (Flags
& UISF_HIDEACCEL
)
71 Wnd
->HideAccel
= TRUE
;
75 if (Flags
& UISF_HIDEFOCUS
)
76 Wnd
->HideFocus
= FALSE
;
77 if (Flags
& UISF_HIDEACCEL
)
78 Wnd
->HideAccel
= FALSE
;
85 PWND FASTCALL
IntGetWindowObject(HWND hWnd
)
89 if (!hWnd
) return NULL
;
91 Window
= UserGetWindowObject(hWnd
);
94 ASSERT(Window
->head
.cLockObj
>= 0);
96 Window
->head
.cLockObj
++;
102 PWND FASTCALL
UserGetWindowObject(HWND hWnd
)
107 if (PsGetCurrentProcess() != PsInitialSystemProcess
)
109 ti
= GetW32ThreadInfo();
112 EngSetLastError(ERROR_ACCESS_DENIED
);
119 EngSetLastError(ERROR_INVALID_WINDOW_HANDLE
);
123 Window
= (PWND
)UserGetObject(gHandleTable
, hWnd
, otWindow
);
124 if (!Window
|| 0 != (Window
->state
& WNDS_DESTROYED
))
126 EngSetLastError(ERROR_INVALID_WINDOW_HANDLE
);
130 ASSERT(Window
->head
.cLockObj
>= 0);
139 * The function determines whether the specified window handle identifies
140 * an existing window.
144 * Handle to the window to test.
147 * If the window handle identifies an existing window, the return value
148 * is TRUE. If the window handle does not identify an existing window,
149 * the return value is FALSE.
153 IntIsWindow(HWND hWnd
)
157 if (!(Window
= UserGetWindowObject(hWnd
)))
165 IntGetParent(PWND Wnd
)
167 if (Wnd
->style
& WS_POPUP
)
169 return Wnd
->spwndOwner
;
171 else if (Wnd
->style
& WS_CHILD
)
173 return Wnd
->spwndParent
;
182 * Compile a list of all child window handles from given window.
185 * This function is similar to Wine WIN_ListChildren. The caller
186 * must free the returned list with ExFreePool.
190 IntWinListChildren(PWND Window
)
194 UINT Index
, NumChildren
= 0;
196 if (!Window
) return NULL
;
198 for (Child
= Window
->spwndChild
; Child
; Child
= Child
->spwndNext
)
201 List
= ExAllocatePoolWithTag(PagedPool
, (NumChildren
+ 1) * sizeof(HWND
), USERTAG_WINDOWLIST
);
204 DPRINT1("Failed to allocate memory for children array\n");
205 EngSetLastError(ERROR_NOT_ENOUGH_MEMORY
);
208 for (Child
= Window
->spwndChild
, Index
= 0;
210 Child
= Child
->spwndNext
, ++Index
)
211 List
[Index
] = Child
->head
.h
;
217 /***********************************************************************
220 static void IntSendDestroyMsg(HWND hWnd
)
228 if (GetGUIThreadInfo(GetCurrentThreadId(), &info
))
230 if (hWnd
== info
.hwndCaret
)
237 Window
= UserGetWindowObject(hWnd
);
240 // USER_REFERENCE_ENTRY Ref;
241 // UserRefObjectCo(Window, &Ref);
243 if (!Window
->spwndOwner
&& !IntGetParent(Window
))
245 co_IntShellHookNotify(HSHELL_WINDOWDESTROYED
, (LPARAM
) hWnd
);
248 // UserDerefObjectCo(Window);
251 /* The window could already be destroyed here */
254 * Send the WM_DESTROY to the window.
257 co_IntSendMessage(hWnd
, WM_DESTROY
, 0, 0);
260 * This WM_DESTROY message can trigger re-entrant calls to DestroyWindow
261 * make sure that the window still exists when we come back.
270 if (!(pWndArray
= WIN_ListChildren( hwnd
)))
273 /* start from the end (FIXME: is this needed?) */
274 for (i
= 0; pWndArray
[i
]; i
++)
279 if (IsWindow( pWndArray
[i
] ))
280 WIN_SendDestroyMsg( pWndArray
[i
] );
282 HeapFree(GetProcessHeap(), 0, pWndArray
);
286 DPRINT("destroyed itself while in WM_DESTROY!\n");
292 UserFreeWindowInfo(PTHREADINFO ti
, PWND Wnd
)
294 PCLIENTINFO ClientInfo
= GetWin32ClientInfo();
298 if (ClientInfo
->CallbackWnd
.pWnd
== DesktopHeapAddressToUser(Wnd
))
300 ClientInfo
->CallbackWnd
.hWnd
= NULL
;
301 ClientInfo
->CallbackWnd
.pWnd
= NULL
;
304 if (Wnd
->strName
.Buffer
!= NULL
)
306 Wnd
->strName
.Length
= 0;
307 Wnd
->strName
.MaximumLength
= 0;
308 DesktopHeapFree(Wnd
->head
.rpdesk
,
309 Wnd
->strName
.Buffer
);
310 Wnd
->strName
.Buffer
= NULL
;
313 // DesktopHeapFree(Wnd->head.rpdesk, Wnd);
314 // WindowObject->Wnd = NULL;
317 /***********************************************************************
320 * Destroy storage associated to a window. "Internals" p.358
322 * This is the "functional" DestroyWindows function ei. all stuff
323 * done in CreateWindow is undone here and not in DestroyWindow:-P
326 static LRESULT
co_UserFreeWindow(PWND Window
,
327 PPROCESSINFO ProcessData
,
328 PTHREADINFO ThreadData
,
329 BOOLEAN SendMessages
)
335 BOOLEAN BelongsToThreadData
;
339 if(Window
->state2
& WNDS2_INDESTROY
)
341 DPRINT("Tried to call IntDestroyWindow() twice\n");
344 Window
->state2
|= WNDS2_INDESTROY
;
345 Window
->style
&= ~WS_VISIBLE
;
347 IntNotifyWinEvent(EVENT_OBJECT_DESTROY
, Window
, OBJID_WINDOW
, CHILDID_SELF
, 0);
349 /* remove the window already at this point from the thread window list so we
350 don't get into trouble when destroying the thread windows while we're still
351 in IntDestroyWindow() */
352 RemoveEntryList(&Window
->ThreadListEntry
);
354 BelongsToThreadData
= IntWndBelongsToThread(Window
, ThreadData
);
356 IntDeRegisterShellHookWindow(Window
->head
.h
);
360 /* Send destroy messages */
361 IntSendDestroyMsg(Window
->head
.h
);
364 /* free child windows */
365 Children
= IntWinListChildren(Window
);
368 for (ChildHandle
= Children
; *ChildHandle
; ++ChildHandle
)
370 if ((Child
= IntGetWindowObject(*ChildHandle
)))
372 if(!IntWndBelongsToThread(Child
, ThreadData
))
374 /* send WM_DESTROY messages to windows not belonging to the same thread */
375 IntSendDestroyMsg(Child
->head
.h
);
378 co_UserFreeWindow(Child
, ProcessData
, ThreadData
, SendMessages
);
380 UserDereferenceObject(Child
);
383 ExFreePool(Children
);
389 * Clear the update region to make sure no WM_PAINT messages will be
390 * generated for this window while processing the WM_NCDESTROY.
392 co_UserRedrawWindow(Window
, NULL
, 0,
393 RDW_VALIDATE
| RDW_NOFRAME
| RDW_NOERASE
|
394 RDW_NOINTERNALPAINT
| RDW_NOCHILDREN
);
395 if(BelongsToThreadData
)
396 co_IntSendMessage(Window
->head
.h
, WM_NCDESTROY
, 0, 0);
399 DestroyTimersForWindow(ThreadData
, Window
);
401 /* Unregister hot keys */
402 UnregisterWindowHotKeys (Window
);
404 /* flush the message queue */
405 MsqRemoveWindowMessagesFromQueue(Window
);
407 /* from now on no messages can be sent to this window anymore */
408 Window
->state
|= WNDS_DESTROYED
;
409 Window
->fnid
|= FNID_FREED
;
411 /* don't remove the WINDOWSTATUS_DESTROYING bit */
413 /* reset shell window handles */
414 if(ThreadData
->rpdesk
)
416 if (Window
->head
.h
== ThreadData
->rpdesk
->rpwinstaParent
->ShellWindow
)
417 ThreadData
->rpdesk
->rpwinstaParent
->ShellWindow
= NULL
;
419 if (Window
->head
.h
== ThreadData
->rpdesk
->rpwinstaParent
->ShellListView
)
420 ThreadData
->rpdesk
->rpwinstaParent
->ShellListView
= NULL
;
423 /* FIXME: do we need to fake QS_MOUSEMOVE wakebit? */
427 WinPosCheckInternalPos(Window
->head
.h
);
428 if (Window
->head
.h
== GetCapture())
433 /* free resources associated with the window */
434 TIMER_RemoveWindowTimers(Window
->head
.h
);
437 if ( ((Window
->style
& (WS_CHILD
|WS_POPUP
)) != WS_CHILD
) &&
439 (Menu
= UserGetMenuObject((HMENU
)Window
->IDMenu
)))
441 IntDestroyMenuObject(Menu
, TRUE
, TRUE
);
445 if(Window
->SystemMenu
446 && (Menu
= UserGetMenuObject(Window
->SystemMenu
)))
448 IntDestroyMenuObject(Menu
, TRUE
, TRUE
);
449 Window
->SystemMenu
= (HMENU
)0;
452 DceFreeWindowDCE(Window
); /* Always do this to catch orphaned DCs */
455 WINPROC_FreeProc(Window
->winproc
, WIN_PROC_WINDOW
);
456 CLASS_RemoveWindow(Window
->Class
);
459 IntUnlinkWindow(Window
);
461 UserReferenceObject(Window
);
462 UserDeleteObject(Window
->head
.h
, otWindow
);
464 IntDestroyScrollBars(Window
);
466 /* dereference the class */
467 IntDereferenceClass(Window
->pcls
,
468 Window
->head
.pti
->pDeskInfo
,
469 Window
->head
.pti
->ppi
);
474 GreDeleteObject(Window
->hrgnClip
);
477 // ASSERT(Window != NULL);
478 UserFreeWindowInfo(Window
->head
.pti
, Window
);
480 UserDereferenceObject(Window
);
482 IntClipboardFreeWindow(Window
);
488 IntGetWindowBorderMeasures(PWND Wnd
, UINT
*cx
, UINT
*cy
)
490 if(HAS_DLGFRAME(Wnd
->style
, Wnd
->ExStyle
) && !(Wnd
->style
& WS_MINIMIZE
))
492 *cx
= UserGetSystemMetrics(SM_CXDLGFRAME
);
493 *cy
= UserGetSystemMetrics(SM_CYDLGFRAME
);
497 if(HAS_THICKFRAME(Wnd
->style
, Wnd
->ExStyle
)&& !(Wnd
->style
& WS_MINIMIZE
))
499 *cx
= UserGetSystemMetrics(SM_CXFRAME
);
500 *cy
= UserGetSystemMetrics(SM_CYFRAME
);
502 else if(HAS_THINFRAME(Wnd
->style
, Wnd
->ExStyle
))
504 *cx
= UserGetSystemMetrics(SM_CXBORDER
);
505 *cy
= UserGetSystemMetrics(SM_CYBORDER
);
515 // Same as User32:IntGetWndProc.
518 IntGetWindowProc(PWND pWnd
,
523 WNDPROC gcpd
, Ret
= 0;
525 ASSERT(UserIsEnteredExclusive() == TRUE
);
529 if (pWnd
->state
& WNDS_SERVERSIDEWINDOWPROC
)
531 for ( i
= FNID_FIRST
; i
<= FNID_SWITCH
; i
++)
533 if (GETPFNSERVER(i
) == pWnd
->lpfnWndProc
)
536 Ret
= GETPFNCLIENTA(i
);
538 Ret
= GETPFNCLIENTW(i
);
544 if (Class
->fnid
== FNID_EDIT
)
545 Ret
= pWnd
->lpfnWndProc
;
548 Ret
= pWnd
->lpfnWndProc
;
550 if (Class
->fnid
<= FNID_GHOST
&& Class
->fnid
>= FNID_BUTTON
)
554 if (GETPFNCLIENTW(Class
->fnid
) == pWnd
->lpfnWndProc
)
555 Ret
= GETPFNCLIENTA(Class
->fnid
);
559 if (GETPFNCLIENTA(Class
->fnid
) == pWnd
->lpfnWndProc
)
560 Ret
= GETPFNCLIENTW(Class
->fnid
);
563 if ( Ret
!= pWnd
->lpfnWndProc
)
566 if ( Ansi
== !!(pWnd
->state
& WNDS_ANSIWINDOWPROC
) )
569 gcpd
= (WNDPROC
)UserGetCPD(
571 (Ansi
? UserGetCPDA2U
: UserGetCPDU2A
)|UserGetCPDWindow
,
574 return (gcpd
? gcpd
: Ret
);
578 IntSetWindowProc(PWND pWnd
,
583 PCALLPROCDATA CallProc
;
585 WNDPROC Ret
, chWndProc
= NULL
;
587 // Retrieve previous window proc.
588 Ret
= IntGetWindowProc(pWnd
, Ansi
);
592 if (IsCallProcHandle(NewWndProc
))
594 CallProc
= UserGetObject(gHandleTable
, NewWndProc
, otCallProc
);
596 { // Reset new WndProc.
597 NewWndProc
= CallProc
->pfnClientPrevious
;
598 // Reset Ansi from CallProc handle. This is expected with wine "deftest".
599 Ansi
= !!(CallProc
->wType
& UserGetCPDU2A
);
602 // Switch from Client Side call to Server Side call if match. Ref: "deftest".
603 for ( i
= FNID_FIRST
; i
<= FNID_SWITCH
; i
++)
605 if (GETPFNCLIENTW(i
) == NewWndProc
)
607 chWndProc
= GETPFNSERVER(i
);
610 if (GETPFNCLIENTA(i
) == NewWndProc
)
612 chWndProc
= GETPFNSERVER(i
);
616 // If match, set/reset to Server Side and clear ansi.
619 pWnd
->lpfnWndProc
= chWndProc
;
620 pWnd
->Unicode
= TRUE
;
621 pWnd
->state
&= ~WNDS_ANSIWINDOWPROC
;
622 pWnd
->state
|= WNDS_SERVERSIDEWINDOWPROC
;
626 pWnd
->Unicode
= !Ansi
;
627 // Handle the state change in here.
629 pWnd
->state
|= WNDS_ANSIWINDOWPROC
;
631 pWnd
->state
&= ~WNDS_ANSIWINDOWPROC
;
633 if (pWnd
->state
& WNDS_SERVERSIDEWINDOWPROC
)
634 pWnd
->state
&= ~WNDS_SERVERSIDEWINDOWPROC
;
636 if (!NewWndProc
) NewWndProc
= pWnd
->lpfnWndProc
;
638 if (Class
->fnid
<= FNID_GHOST
&& Class
->fnid
>= FNID_BUTTON
)
642 if (GETPFNCLIENTW(Class
->fnid
) == NewWndProc
)
643 chWndProc
= GETPFNCLIENTA(Class
->fnid
);
647 if (GETPFNCLIENTA(Class
->fnid
) == NewWndProc
)
648 chWndProc
= GETPFNCLIENTW(Class
->fnid
);
651 // Now set the new window proc.
652 pWnd
->lpfnWndProc
= (chWndProc
? chWndProc
: NewWndProc
);
663 PMENU_OBJECT OldMenu
, NewMenu
= NULL
;
665 if ((Wnd
->style
& (WS_CHILD
| WS_POPUP
)) == WS_CHILD
)
667 EngSetLastError(ERROR_INVALID_WINDOW_HANDLE
);
671 *Changed
= (Wnd
->IDMenu
!= (UINT
) Menu
);
679 OldMenu
= IntGetMenuObject((HMENU
) Wnd
->IDMenu
);
680 ASSERT(NULL
== OldMenu
|| OldMenu
->MenuInfo
.Wnd
== Wnd
->head
.h
);
689 NewMenu
= IntGetMenuObject(Menu
);
694 IntReleaseMenuObject(OldMenu
);
696 EngSetLastError(ERROR_INVALID_MENU_HANDLE
);
699 if (NULL
!= NewMenu
->MenuInfo
.Wnd
)
701 /* Can't use the same menu for two windows */
704 IntReleaseMenuObject(OldMenu
);
706 EngSetLastError(ERROR_INVALID_MENU_HANDLE
);
712 Wnd
->IDMenu
= (UINT
) Menu
;
715 NewMenu
->MenuInfo
.Wnd
= Wnd
->head
.h
;
716 IntReleaseMenuObject(NewMenu
);
720 OldMenu
->MenuInfo
.Wnd
= NULL
;
721 IntReleaseMenuObject(OldMenu
);
728 /* INTERNAL ******************************************************************/
732 co_DestroyThreadWindows(struct _ETHREAD
*Thread
)
737 USER_REFERENCE_ENTRY Ref
;
738 WThread
= (PTHREADINFO
)Thread
->Tcb
.Win32Thread
;
740 while (!IsListEmpty(&WThread
->WindowListHead
))
742 Current
= WThread
->WindowListHead
.Flink
;
743 Wnd
= CONTAINING_RECORD(Current
, WND
, ThreadListEntry
);
745 DPRINT("thread cleanup: while destroy wnds, wnd=0x%x\n",Wnd
);
747 /* window removes itself from the list */
750 fixme: it is critical that the window removes itself! if now, we will loop
754 //ASSERT(co_UserDestroyWindow(Wnd));
756 UserRefObjectCo(Wnd
, &Ref
);//faxme: temp hack??
757 if (!co_UserDestroyWindow(Wnd
))
759 DPRINT1("Unable to destroy window 0x%x at thread cleanup... This is _VERY_ bad!\n", Wnd
);
761 UserDerefObjectCo(Wnd
);//faxme: temp hack??
769 * Returns client window rectangle relative to the upper-left corner of client area.
771 * \note Does not check the validity of the parameters
774 IntGetClientRect(PWND Window
, RECTL
*Rect
)
779 Rect
->left
= Rect
->top
= 0;
780 Rect
->right
= Window
->rcClient
.right
- Window
->rcClient
.left
;
781 Rect
->bottom
= Window
->rcClient
.bottom
- Window
->rcClient
.top
;
785 PMENU_OBJECT FASTCALL
786 IntGetSystemMenu(PWND Window
, BOOL bRevert
, BOOL RetMenu
)
788 PMENU_OBJECT Menu
, NewMenu
= NULL
, SysMenu
= NULL
, ret
= NULL
;
789 PTHREADINFO W32Thread
;
790 HMENU hNewMenu
, hSysMenu
;
791 ROSMENUITEMINFO ItemInfo
;
795 W32Thread
= PsGetCurrentThreadWin32Thread();
797 if(!W32Thread
->rpdesk
)
800 if(Window
->SystemMenu
)
802 Menu
= UserGetMenuObject(Window
->SystemMenu
);
805 IntDestroyMenuObject(Menu
, TRUE
, TRUE
);
806 Window
->SystemMenu
= (HMENU
)0;
810 if(W32Thread
->rpdesk
->rpwinstaParent
->SystemMenuTemplate
)
812 /* clone system menu */
813 Menu
= UserGetMenuObject(W32Thread
->rpdesk
->rpwinstaParent
->SystemMenuTemplate
);
817 NewMenu
= IntCloneMenu(Menu
);
820 Window
->SystemMenu
= NewMenu
->MenuInfo
.Self
;
821 NewMenu
->MenuInfo
.Flags
|= MF_SYSMENU
;
822 NewMenu
->MenuInfo
.Wnd
= Window
->head
.h
;
824 //IntReleaseMenuObject(NewMenu);
829 hSysMenu
= UserCreateMenu(FALSE
);
830 if (NULL
== hSysMenu
)
834 SysMenu
= IntGetMenuObject(hSysMenu
);
837 UserDestroyMenu(hSysMenu
);
840 SysMenu
->MenuInfo
.Flags
|= MF_SYSMENU
;
841 SysMenu
->MenuInfo
.Wnd
= Window
->head
.h
;
842 hNewMenu
= co_IntLoadSysMenuTemplate();
845 IntReleaseMenuObject(SysMenu
);
846 UserDestroyMenu(hSysMenu
);
849 Menu
= IntGetMenuObject(hNewMenu
);
852 IntReleaseMenuObject(SysMenu
);
853 UserDestroyMenu(hSysMenu
);
857 NewMenu
= IntCloneMenu(Menu
);
860 NewMenu
->MenuInfo
.Flags
|= MF_SYSMENU
| MF_POPUP
;
861 IntReleaseMenuObject(NewMenu
);
862 UserSetMenuDefaultItem(NewMenu
, SC_CLOSE
, FALSE
);
864 ItemInfo
.cbSize
= sizeof(MENUITEMINFOW
);
865 ItemInfo
.fMask
= MIIM_FTYPE
| MIIM_STRING
| MIIM_STATE
| MIIM_SUBMENU
;
866 ItemInfo
.fType
= MF_POPUP
;
867 ItemInfo
.fState
= MFS_ENABLED
;
868 ItemInfo
.dwTypeData
= NULL
;
870 ItemInfo
.hSubMenu
= NewMenu
->MenuInfo
.Self
;
871 IntInsertMenuItem(SysMenu
, (UINT
) -1, TRUE
, &ItemInfo
);
873 Window
->SystemMenu
= SysMenu
->MenuInfo
.Self
;
877 IntDestroyMenuObject(Menu
, FALSE
, TRUE
);
886 if(Window
->SystemMenu
)
887 return IntGetMenuObject((HMENU
)Window
->SystemMenu
);
895 IntIsChildWindow(PWND Parent
, PWND BaseWindow
)
900 while (Window
&& ((Window
->style
& (WS_POPUP
|WS_CHILD
)) == WS_CHILD
))
902 if (Window
== Parent
)
907 Window
= Window
->spwndParent
;
914 IntIsWindowVisible(PWND BaseWindow
)
921 if(!(Window
->style
& WS_CHILD
))
925 if(!(Window
->style
& WS_VISIBLE
))
930 Window
= Window
->spwndParent
;
933 if(Window
&& Window
->style
& WS_VISIBLE
)
943 link the window into siblings list
944 children and parent are kept in place.
949 PWND WndInsertAfter
/* set to NULL if top sibling */
952 if ((Wnd
->spwndPrev
= WndInsertAfter
))
954 /* link after WndInsertAfter */
955 if ((Wnd
->spwndNext
= WndInsertAfter
->spwndNext
))
956 Wnd
->spwndNext
->spwndPrev
= Wnd
;
958 Wnd
->spwndPrev
->spwndNext
= Wnd
;
963 if ((Wnd
->spwndNext
= Wnd
->spwndParent
->spwndChild
))
964 Wnd
->spwndNext
->spwndPrev
= Wnd
;
966 Wnd
->spwndParent
->spwndChild
= Wnd
;
971 VOID FASTCALL
IntLinkHwnd(PWND Wnd
, HWND hWndPrev
)
973 if (hWndPrev
== HWND_NOTOPMOST
)
975 if (!(Wnd
->ExStyle
& WS_EX_TOPMOST
) &&
976 (Wnd
->ExStyle2
& WS_EX2_LINKED
)) return; /* nothing to do */
977 Wnd
->ExStyle
&= ~WS_EX_TOPMOST
;
978 hWndPrev
= HWND_TOP
; /* fallback to the HWND_TOP case */
981 IntUnlinkWindow(Wnd
); /* unlink it from the previous location */
983 if (hWndPrev
== HWND_BOTTOM
)
985 /* Link in the bottom of the list */
988 WndInsertAfter
= Wnd
->spwndParent
->spwndChild
;
989 while( WndInsertAfter
&& WndInsertAfter
->spwndNext
)
990 WndInsertAfter
= WndInsertAfter
->spwndNext
;
992 IntLinkWindow(Wnd
, WndInsertAfter
);
993 Wnd
->ExStyle
&= ~WS_EX_TOPMOST
;
995 else if (hWndPrev
== HWND_TOPMOST
)
997 /* Link in the top of the list */
998 IntLinkWindow(Wnd
, NULL
);
1000 Wnd
->ExStyle
|= WS_EX_TOPMOST
;
1002 else if (hWndPrev
== HWND_TOP
)
1004 /* Link it after the last topmost window */
1005 PWND WndInsertBefore
;
1007 WndInsertBefore
= Wnd
->spwndParent
->spwndChild
;
1009 if (!(Wnd
->ExStyle
& WS_EX_TOPMOST
)) /* put it above the first non-topmost window */
1011 while (WndInsertBefore
!= NULL
&& WndInsertBefore
->spwndNext
!= NULL
)
1013 if (!(WndInsertBefore
->ExStyle
& WS_EX_TOPMOST
)) break;
1014 if (WndInsertBefore
== Wnd
->spwndOwner
) /* keep it above owner */
1016 Wnd
->ExStyle
|= WS_EX_TOPMOST
;
1019 WndInsertBefore
= WndInsertBefore
->spwndNext
;
1023 IntLinkWindow(Wnd
, WndInsertBefore
? WndInsertBefore
->spwndPrev
: NULL
);
1027 /* Link it after hWndPrev */
1028 PWND WndInsertAfter
;
1030 WndInsertAfter
= UserGetWindowObject(hWndPrev
);
1031 /* Are we called with an erroneous handle */
1032 if(WndInsertAfter
== NULL
)
1034 /* Link in a default position */
1035 IntLinkHwnd(Wnd
, HWND_TOP
);
1039 IntLinkWindow(Wnd
, WndInsertAfter
);
1041 /* Fix the WS_EX_TOPMOST flag */
1042 if (!(WndInsertAfter
->ExStyle
& WS_EX_TOPMOST
))
1044 Wnd
->ExStyle
&= ~WS_EX_TOPMOST
;
1048 if(WndInsertAfter
->spwndNext
&&
1049 WndInsertAfter
->spwndNext
->ExStyle
& WS_EX_TOPMOST
)
1051 Wnd
->ExStyle
|= WS_EX_TOPMOST
;
1058 IntSetOwner(HWND hWnd
, HWND hWndNewOwner
)
1060 PWND Wnd
, WndOldOwner
, WndNewOwner
;
1063 Wnd
= IntGetWindowObject(hWnd
);
1067 WndOldOwner
= Wnd
->spwndOwner
;
1069 ret
= WndOldOwner
? WndOldOwner
->head
.h
: 0;
1071 if((WndNewOwner
= UserGetWindowObject(hWndNewOwner
)))
1073 Wnd
->spwndOwner
= WndNewOwner
;
1077 Wnd
->spwndOwner
= NULL
;
1080 UserDereferenceObject(Wnd
);
1085 co_IntSetParent(PWND Wnd
, PWND WndNewParent
)
1087 PWND WndOldParent
, pWndExam
;
1091 ASSERT(WndNewParent
);
1092 ASSERT_REFS_CO(Wnd
);
1093 ASSERT_REFS_CO(WndNewParent
);
1095 if (Wnd
== Wnd
->head
.rpdesk
->spwndMessage
)
1097 EngSetLastError(ERROR_ACCESS_DENIED
);
1101 /* Some applications try to set a child as a parent */
1102 if (IntIsChildWindow(Wnd
, WndNewParent
))
1104 EngSetLastError( ERROR_INVALID_PARAMETER
);
1108 pWndExam
= WndNewParent
; // Load parent Window to examine.
1109 // Now test for set parent to parent hit.
1112 if (Wnd
== pWndExam
)
1114 EngSetLastError(ERROR_INVALID_PARAMETER
);
1117 pWndExam
= pWndExam
->spwndParent
;
1121 * Windows hides the window first, then shows it again
1122 * including the WM_SHOWWINDOW messages and all
1124 WasVisible
= co_WinPosShowWindow(Wnd
, SW_HIDE
);
1126 /* Window must belong to current process */
1127 if (Wnd
->head
.pti
->pEThread
->ThreadsProcess
!= PsGetCurrentProcess())
1130 WndOldParent
= Wnd
->spwndParent
;
1132 if (WndOldParent
) UserReferenceObject(WndOldParent
); /* caller must deref */
1134 if (WndNewParent
!= WndOldParent
)
1136 /* Unlink the window from the siblings list */
1137 IntUnlinkWindow(Wnd
);
1139 /* Set the new parent */
1140 Wnd
->spwndParent
= WndNewParent
;
1142 /* Link the window with its new siblings*/
1143 IntLinkHwnd(Wnd
, HWND_TOP
);
1147 IntNotifyWinEvent(EVENT_OBJECT_PARENTCHANGE
, Wnd
,OBJID_WINDOW
, CHILDID_SELF
, WEF_SETBYWNDPTI
);
1149 * SetParent additionally needs to make hwnd the top window
1150 * in the z-order and send the expected WM_WINDOWPOSCHANGING and
1151 * WM_WINDOWPOSCHANGED notification messages.
1153 co_WinPosSetWindowPos(Wnd
, (0 == (Wnd
->ExStyle
& WS_EX_TOPMOST
) ? HWND_TOP
: HWND_TOPMOST
),
1154 0, 0, 0, 0, SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOSIZE
1155 | (WasVisible
? SWP_SHOWWINDOW
: 0));
1158 * FIXME: a WM_MOVE is also generated (in the DefWindowProc handler
1159 * for WM_WINDOWPOSCHANGED) in Windows, should probably remove SWP_NOMOVE
1162 return WndOldParent
;
1166 co_UserSetParent(HWND hWndChild
, HWND hWndNewParent
)
1168 PWND Wnd
= NULL
, WndParent
= NULL
, WndOldParent
;
1169 HWND hWndOldParent
= NULL
;
1170 USER_REFERENCE_ENTRY Ref
, ParentRef
;
1172 if (IntIsBroadcastHwnd(hWndChild
) || IntIsBroadcastHwnd(hWndNewParent
))
1174 EngSetLastError(ERROR_INVALID_PARAMETER
);
1178 if (hWndChild
== IntGetDesktopWindow())
1180 EngSetLastError(ERROR_ACCESS_DENIED
);
1186 if (!(WndParent
= UserGetWindowObject(hWndNewParent
)))
1193 if (!(WndParent
= UserGetWindowObject(IntGetDesktopWindow())))
1199 if (!(Wnd
= UserGetWindowObject(hWndChild
)))
1204 UserRefObjectCo(Wnd
, &Ref
);
1205 UserRefObjectCo(WndParent
, &ParentRef
);
1207 WndOldParent
= co_IntSetParent(Wnd
, WndParent
);
1209 UserDerefObjectCo(WndParent
);
1210 UserDerefObjectCo(Wnd
);
1214 hWndOldParent
= WndOldParent
->head
.h
;
1215 UserDereferenceObject(WndOldParent
);
1218 return( hWndOldParent
);
1222 IntSetSystemMenu(PWND Window
, PMENU_OBJECT Menu
)
1224 PMENU_OBJECT OldMenu
;
1225 if(Window
->SystemMenu
)
1227 OldMenu
= IntGetMenuObject(Window
->SystemMenu
);
1230 OldMenu
->MenuInfo
.Flags
&= ~ MF_SYSMENU
;
1231 IntReleaseMenuObject(OldMenu
);
1237 /* FIXME check window style, propably return FALSE ? */
1238 Window
->SystemMenu
= Menu
->MenuInfo
.Self
;
1239 Menu
->MenuInfo
.Flags
|= MF_SYSMENU
;
1242 Window
->SystemMenu
= (HMENU
)0;
1247 /* unlink the window from siblings. children and parent are kept in place. */
1249 IntUnlinkWindow(PWND Wnd
)
1252 Wnd
->spwndNext
->spwndPrev
= Wnd
->spwndPrev
;
1255 Wnd
->spwndPrev
->spwndNext
= Wnd
->spwndNext
;
1257 if (Wnd
->spwndParent
&& Wnd
->spwndParent
->spwndChild
== Wnd
)
1258 Wnd
->spwndParent
->spwndChild
= Wnd
->spwndNext
;
1260 Wnd
->spwndPrev
= Wnd
->spwndNext
= NULL
;
1265 IntGetWindowPlacement(PWND Wnd
, WINDOWPLACEMENT
*lpwndpl
)
1269 if (!Wnd
) return FALSE
;
1271 if(lpwndpl
->length
!= sizeof(WINDOWPLACEMENT
))
1277 if (0 == (Wnd
->style
& WS_VISIBLE
))
1279 lpwndpl
->showCmd
= SW_HIDE
;
1281 else if (0 != (Wnd
->state2
& WNDS2_MAXIMIZEBUTTONDOWN
) ||
1282 0 != (Wnd
->style
& WS_MAXIMIZE
))
1284 lpwndpl
->showCmd
= SW_MAXIMIZE
;
1286 else if (0 != (Wnd
->style
& WS_MINIMIZE
))
1288 lpwndpl
->showCmd
= SW_MINIMIZE
;
1290 else if (0 != (Wnd
->style
& WS_VISIBLE
))
1292 lpwndpl
->showCmd
= SW_SHOWNORMAL
;
1295 Size
.x
= Wnd
->rcWindow
.left
;
1296 Size
.y
= Wnd
->rcWindow
.top
;
1297 WinPosInitInternalPos(Wnd
, &Size
,
1300 lpwndpl
->rcNormalPosition
= Wnd
->InternalPos
.NormalRect
;
1301 lpwndpl
->ptMinPosition
= Wnd
->InternalPos
.IconPos
;
1302 lpwndpl
->ptMaxPosition
= Wnd
->InternalPos
.MaxPos
;
1308 /* FUNCTIONS *****************************************************************/
1311 * As best as I can figure, this function is used by EnumWindows,
1312 * EnumChildWindows, EnumDesktopWindows, & EnumThreadWindows.
1314 * It's supposed to build a list of HWNDs to return to the caller.
1315 * We can figure out what kind of list by what parameters are
1323 NtUserBuildHwndList(
1336 return ERROR_INVALID_PARAMETER
;
1338 if (hwndParent
|| !dwThreadId
)
1341 PWND Parent
, Window
;
1345 if(hDesktop
== NULL
&& !(Desktop
= IntGetActiveDesktop()))
1347 return ERROR_INVALID_HANDLE
;
1352 Status
= IntValidateDesktopHandle(hDesktop
,
1356 if(!NT_SUCCESS(Status
))
1358 return ERROR_INVALID_HANDLE
;
1361 hwndParent
= Desktop
->DesktopWindow
;
1368 if((Parent
= UserGetWindowObject(hwndParent
)) &&
1369 (Window
= Parent
->spwndChild
))
1371 BOOL bGoDown
= TRUE
;
1373 Status
= STATUS_SUCCESS
;
1378 if(dwCount
++ < *pBufSize
&& pWnd
)
1382 ProbeForWrite(pWnd
, sizeof(HWND
), 1);
1383 *pWnd
= Window
->head
.h
;
1386 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1388 Status
= _SEH2_GetExceptionCode();
1391 if(!NT_SUCCESS(Status
))
1393 SetLastNtError(Status
);
1397 if (Window
->spwndChild
&& bChildren
)
1399 Window
= Window
->spwndChild
;
1404 if (Window
->spwndNext
)
1406 Window
= Window
->spwndNext
;
1410 Window
= Window
->spwndParent
;
1411 if (Window
== Parent
)
1420 ObDereferenceObject(Desktop
);
1423 else // Build EnumThreadWindows list!
1426 PTHREADINFO W32Thread
;
1427 PLIST_ENTRY Current
;
1430 Status
= PsLookupThreadByThreadId((HANDLE
)dwThreadId
, &Thread
);
1431 if (!NT_SUCCESS(Status
))
1433 DPRINT1("Thread Id is not valid!\n");
1434 return ERROR_INVALID_PARAMETER
;
1436 if (!(W32Thread
= (PTHREADINFO
)Thread
->Tcb
.Win32Thread
))
1438 ObDereferenceObject(Thread
);
1439 DPRINT1("Thread is not initialized!\n");
1440 return ERROR_INVALID_PARAMETER
;
1443 Current
= W32Thread
->WindowListHead
.Flink
;
1444 while (Current
!= &(W32Thread
->WindowListHead
))
1446 Window
= CONTAINING_RECORD(Current
, WND
, ThreadListEntry
);
1449 if (dwCount
< *pBufSize
&& pWnd
)
1453 ProbeForWrite(pWnd
, sizeof(HWND
), 1);
1454 *pWnd
= Window
->head
.h
;
1457 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1459 Status
= _SEH2_GetExceptionCode();
1462 if (!NT_SUCCESS(Status
))
1464 DPRINT1("Failure to build window list!\n");
1465 SetLastNtError(Status
);
1470 Current
= Window
->ThreadListEntry
.Flink
;
1473 ObDereferenceObject(Thread
);
1476 *pBufSize
= dwCount
;
1477 return STATUS_SUCCESS
;
1485 NtUserChildWindowFromPointEx(HWND hwndParent
,
1495 if(!(Parent
= UserGetWindowObject(hwndParent
)))
1503 if(Parent
->head
.h
!= IntGetDesktopWindow())
1505 Pt
.x
+= Parent
->rcClient
.left
;
1506 Pt
.y
+= Parent
->rcClient
.top
;
1509 if(!IntPtInWindow(Parent
, Pt
.x
, Pt
.y
))
1514 Ret
= Parent
->head
.h
;
1515 if((List
= IntWinListChildren(Parent
)))
1517 for(phWnd
= List
; *phWnd
; phWnd
++)
1520 if((Child
= UserGetWindowObject(*phWnd
)))
1522 if(!(Child
->style
& WS_VISIBLE
) && (uiFlags
& CWP_SKIPINVISIBLE
))
1526 if((Child
->style
& WS_DISABLED
) && (uiFlags
& CWP_SKIPDISABLED
))
1530 if((Child
->ExStyle
& WS_EX_TRANSPARENT
) && (uiFlags
& CWP_SKIPTRANSPARENT
))
1534 if(IntPtInWindow(Child
, Pt
.x
, Pt
.y
))
1536 Ret
= Child
->head
.h
;
1547 static void IntSendParentNotify( PWND pWindow
, UINT msg
)
1549 if ( (pWindow
->style
& (WS_CHILD
| WS_POPUP
)) == WS_CHILD
&&
1550 !(pWindow
->style
& WS_EX_NOPARENTNOTIFY
))
1552 if (pWindow
->spwndParent
&& pWindow
->spwndParent
!= UserGetDesktopWindow())
1554 co_IntSendMessage( pWindow
->spwndParent
->head
.h
,
1556 MAKEWPARAM( msg
, pWindow
->IDMenu
),
1557 (LPARAM
)pWindow
->head
.h
);
1563 IntFixWindowCoordinates(CREATESTRUCTW
* Cs
, PWND ParentWindow
, DWORD
* dwShowMode
)
1565 #define IS_DEFAULT(x) ((x) == CW_USEDEFAULT || (x) == (SHORT)0x8000)
1567 /* default positioning for overlapped windows */
1568 if(!(Cs
->style
& (WS_POPUP
| WS_CHILD
)))
1571 PRTL_USER_PROCESS_PARAMETERS ProcessParams
;
1573 pMonitor
= IntGetPrimaryMonitor();
1576 ProcessParams
= PsGetCurrentProcess()->Peb
->ProcessParameters
;
1578 if (IS_DEFAULT(Cs
->x
))
1580 if (!IS_DEFAULT(Cs
->y
)) *dwShowMode
= Cs
->y
;
1582 if(ProcessParams
->WindowFlags
& STARTF_USEPOSITION
)
1584 Cs
->x
= ProcessParams
->StartingX
;
1585 Cs
->y
= ProcessParams
->StartingY
;
1589 Cs
->x
= pMonitor
->cWndStack
* (UserGetSystemMetrics(SM_CXSIZE
) + UserGetSystemMetrics(SM_CXFRAME
));
1590 Cs
->y
= pMonitor
->cWndStack
* (UserGetSystemMetrics(SM_CYSIZE
) + UserGetSystemMetrics(SM_CYFRAME
));
1591 if (Cs
->x
> ((pMonitor
->rcWork
.right
- pMonitor
->rcWork
.left
) / 4) ||
1592 Cs
->y
> ((pMonitor
->rcWork
.bottom
- pMonitor
->rcWork
.top
) / 4))
1594 /* reset counter and position */
1597 pMonitor
->cWndStack
= 0;
1599 pMonitor
->cWndStack
++;
1603 if (IS_DEFAULT(Cs
->cx
))
1605 if (ProcessParams
->WindowFlags
& STARTF_USEPOSITION
)
1607 Cs
->cx
= ProcessParams
->CountX
;
1608 Cs
->cy
= ProcessParams
->CountY
;
1612 Cs
->cx
= (pMonitor
->rcWork
.right
- pMonitor
->rcWork
.left
) * 3 / 4;
1613 Cs
->cy
= (pMonitor
->rcWork
.bottom
- pMonitor
->rcWork
.top
) * 3 / 4;
1616 /* neither x nor cx are default. Check the y values .
1617 * In the trace we see Outlook and Outlook Express using
1618 * cy set to CW_USEDEFAULT when opening the address book.
1620 else if (IS_DEFAULT(Cs
->cy
))
1622 DPRINT("Strange use of CW_USEDEFAULT in nHeight\n");
1623 Cs
->cy
= (pMonitor
->rcWork
.bottom
- pMonitor
->rcWork
.top
) * 3 / 4;
1628 /* if CW_USEDEFAULT is set for non-overlapped windows, both values are set to zero */
1629 if(IS_DEFAULT(Cs
->x
))
1634 if(IS_DEFAULT(Cs
->cx
))
1644 /* Allocates and initializes a window*/
1645 PWND FASTCALL
IntCreateWindow(CREATESTRUCTW
* Cs
,
1646 PLARGE_STRING WindowName
,
1653 PTHREADINFO pti
= NULL
;
1654 PMENU_OBJECT SystemMenu
;
1656 BOOL bUnicodeWindow
;
1658 pti
= PsGetCurrentThreadWin32Thread();
1660 if (!(Cs
->dwExStyle
& WS_EX_LAYOUTRTL
))
1664 if ( (Cs
->style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
&&
1665 ParentWindow
->ExStyle
& WS_EX_LAYOUTRTL
&&
1666 !(ParentWindow
->ExStyle
& WS_EX_NOINHERITLAYOUT
) )
1667 Cs
->dwExStyle
|= WS_EX_LAYOUTRTL
;
1671 Note from MSDN http://msdn.microsoft.com/en-us/library/aa913269.aspx :
1673 Dialog boxes and message boxes do not inherit layout, so you must
1674 set the layout explicitly.
1676 if ( Class
&& Class
->fnid
!= FNID_DIALOG
)
1678 PPROCESSINFO ppi
= PsGetCurrentProcessWin32Process();
1679 if (ppi
->dwLayout
& LAYOUT_RTL
)
1681 Cs
->dwExStyle
|= WS_EX_LAYOUTRTL
;
1687 /* Automatically add WS_EX_WINDOWEDGE */
1688 if ((Cs
->dwExStyle
& WS_EX_DLGMODALFRAME
) ||
1689 ((!(Cs
->dwExStyle
& WS_EX_STATICEDGE
)) &&
1690 (Cs
->style
& (WS_DLGFRAME
| WS_THICKFRAME
))))
1691 Cs
->dwExStyle
|= WS_EX_WINDOWEDGE
;
1693 Cs
->dwExStyle
&= ~WS_EX_WINDOWEDGE
;
1695 /* Is it a unicode window? */
1696 bUnicodeWindow
=!(Cs
->dwExStyle
& WS_EX_SETANSICREATOR
);
1697 Cs
->dwExStyle
&= ~WS_EX_SETANSICREATOR
;
1699 /* Allocate the new window */
1700 pWnd
= (PWND
) UserCreateObject( gHandleTable
,
1704 sizeof(WND
) + Class
->cbwndExtra
);
1711 DPRINT("Created object with handle %X\n", hWnd
);
1713 if (NULL
== pti
->rpdesk
->DesktopWindow
)
1715 /* If there is no desktop window yet, we must be creating it */
1716 pti
->rpdesk
->DesktopWindow
= hWnd
;
1717 pti
->rpdesk
->pDeskInfo
->spwnd
= pWnd
;
1721 * Fill out the structure describing it.
1723 /* Remember, pWnd->head is setup in object.c ...*/
1724 pWnd
->spwndParent
= ParentWindow
;
1725 pWnd
->spwndOwner
= OwnerWindow
;
1727 pWnd
->hWndLastActive
= hWnd
;
1728 pWnd
->state2
|= WNDS2_WIN40COMPAT
;
1730 pWnd
->hModule
= Cs
->hInstance
;
1731 pWnd
->style
= Cs
->style
& ~WS_VISIBLE
;
1732 pWnd
->ExStyle
= Cs
->dwExStyle
;
1733 pWnd
->cbwndExtra
= pWnd
->pcls
->cbwndExtra
;
1735 IntReferenceMessageQueue(pWnd
->head
.pti
->MessageQueue
);
1736 if (pWnd
->spwndParent
!= NULL
&& Cs
->hwndParent
!= 0)
1738 pWnd
->HideFocus
= pWnd
->spwndParent
->HideFocus
;
1739 pWnd
->HideAccel
= pWnd
->spwndParent
->HideAccel
;
1742 if (pWnd
->pcls
->CSF_flags
& CSF_SERVERSIDEPROC
)
1743 pWnd
->state
|= WNDS_SERVERSIDEWINDOWPROC
;
1745 /* BugBoy Comments: Comment below say that System classes are always created
1746 as UNICODE. In windows, creating a window with the ANSI version of CreateWindow
1747 sets the window to ansi as verified by testing with IsUnicodeWindow API.
1749 No where can I see in code or through testing does the window change back
1750 to ANSI after being created as UNICODE in ROS. I didnt do more testing to
1751 see what problems this would cause.*/
1753 // Set WndProc from Class.
1754 pWnd
->lpfnWndProc
= pWnd
->pcls
->lpfnWndProc
;
1756 // GetWindowProc, test for non server side default classes and set WndProc.
1757 if ( pWnd
->pcls
->fnid
<= FNID_GHOST
&& pWnd
->pcls
->fnid
>= FNID_BUTTON
)
1761 if (GETPFNCLIENTA(pWnd
->pcls
->fnid
) == pWnd
->lpfnWndProc
)
1762 pWnd
->lpfnWndProc
= GETPFNCLIENTW(pWnd
->pcls
->fnid
);
1766 if (GETPFNCLIENTW(pWnd
->pcls
->fnid
) == pWnd
->lpfnWndProc
)
1767 pWnd
->lpfnWndProc
= GETPFNCLIENTA(pWnd
->pcls
->fnid
);
1771 // If not an Unicode caller, set Ansi creator bit.
1772 if (!bUnicodeWindow
) pWnd
->state
|= WNDS_ANSICREATOR
;
1774 // Clone Class Ansi/Unicode proc type.
1775 if (pWnd
->pcls
->CSF_flags
& CSF_ANSIPROC
)
1777 pWnd
->state
|= WNDS_ANSIWINDOWPROC
;
1778 pWnd
->Unicode
= FALSE
;
1782 It seems there can be both an Ansi creator and Unicode Class Window
1783 WndProc, unless the following overriding conditions occur:
1785 if ( !bUnicodeWindow
&&
1786 ( Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_BUTTON
] ||
1787 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_COMBOBOX
] ||
1788 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_COMBOLBOX
] ||
1789 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_DIALOG
] ||
1790 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_EDIT
] ||
1791 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_IME
] ||
1792 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_LISTBOX
] ||
1793 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_MDICLIENT
] ||
1794 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_STATIC
] ) )
1795 { // Override Class and set the window Ansi WndProc.
1796 pWnd
->state
|= WNDS_ANSIWINDOWPROC
;
1797 pWnd
->Unicode
= FALSE
;
1800 { // Set the window Unicode WndProc.
1801 pWnd
->state
&= ~WNDS_ANSIWINDOWPROC
;
1802 pWnd
->Unicode
= TRUE
;
1806 /* BugBoy Comments: if the window being created is a edit control, ATOM 0xCxxx,
1807 then my testing shows that windows (2k and XP) creates a CallProc for it immediately
1808 Dont understand why it does this. */
1809 if (Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_EDIT
])
1811 PCALLPROCDATA CallProc
;
1812 CallProc
= CreateCallProc(NULL
, pWnd
->lpfnWndProc
, pWnd
->Unicode
, pWnd
->head
.pti
->ppi
);
1816 EngSetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1817 DPRINT1("Warning: Unable to create CallProc for edit control. Control may not operate correctly! hwnd %x\n",hWnd
);
1821 UserAddCallProcToClass(pWnd
->pcls
, CallProc
);
1825 InitializeListHead(&pWnd
->PropListHead
);
1827 if ( WindowName
->Buffer
!= NULL
&& WindowName
->Length
> 0 )
1829 pWnd
->strName
.Buffer
= DesktopHeapAlloc(pWnd
->head
.rpdesk
,
1830 WindowName
->Length
+ sizeof(UNICODE_NULL
));
1831 if (pWnd
->strName
.Buffer
== NULL
)
1836 RtlCopyMemory(pWnd
->strName
.Buffer
, WindowName
->Buffer
, WindowName
->Length
);
1837 pWnd
->strName
.Buffer
[WindowName
->Length
/ sizeof(WCHAR
)] = L
'\0';
1838 pWnd
->strName
.Length
= WindowName
->Length
;
1839 pWnd
->strName
.MaximumLength
= WindowName
->Length
+ sizeof(UNICODE_NULL
);
1842 /* Correct the window style. */
1843 if ((pWnd
->style
& (WS_CHILD
| WS_POPUP
)) != WS_CHILD
)
1845 pWnd
->style
|= WS_CLIPSIBLINGS
;
1846 if (!(pWnd
->style
& WS_POPUP
))
1848 pWnd
->style
|= WS_CAPTION
;
1849 pWnd
->state
|= WNDS_SENDSIZEMOVEMSGS
;
1853 if ((pWnd
->ExStyle
& WS_EX_DLGMODALFRAME
) ||
1854 (pWnd
->style
& (WS_DLGFRAME
| WS_THICKFRAME
)))
1855 pWnd
->ExStyle
|= WS_EX_WINDOWEDGE
;
1857 pWnd
->ExStyle
&= ~WS_EX_WINDOWEDGE
;
1859 /* create system menu */
1860 if((Cs
->style
& WS_SYSMENU
) )//&& (dwStyle & WS_CAPTION) == WS_CAPTION)
1862 SystemMenu
= IntGetSystemMenu(pWnd
, TRUE
, TRUE
);
1865 pWnd
->SystemMenu
= SystemMenu
->MenuInfo
.Self
;
1866 IntReleaseMenuObject(SystemMenu
);
1870 /* Set the window menu */
1871 if ((Cs
->style
& (WS_CHILD
| WS_POPUP
)) != WS_CHILD
)
1874 IntSetMenu(pWnd
, Cs
->hMenu
, &MenuChanged
);
1875 else if (pWnd
->pcls
->lpszMenuName
) // Take it from the parent.
1877 UNICODE_STRING MenuName
;
1880 if (IS_INTRESOURCE(pWnd
->pcls
->lpszMenuName
))
1882 MenuName
.Length
= 0;
1883 MenuName
.MaximumLength
= 0;
1884 MenuName
.Buffer
= pWnd
->pcls
->lpszMenuName
;
1888 RtlInitUnicodeString( &MenuName
, pWnd
->pcls
->lpszMenuName
);
1890 hMenu
= co_IntCallLoadMenu( pWnd
->pcls
->hModule
, &MenuName
);
1891 if (hMenu
) IntSetMenu(pWnd
, hMenu
, &MenuChanged
);
1895 pWnd
->IDMenu
= (UINT
) Cs
->hMenu
;
1897 /* Insert the window into the thread's window list. */
1898 InsertTailList (&pti
->WindowListHead
, &pWnd
->ThreadListEntry
);
1900 /* Handle "CS_CLASSDC", it is tested first. */
1901 if ( (pWnd
->pcls
->style
& CS_CLASSDC
) && !(pWnd
->pcls
->pdce
) )
1902 { /* One DCE per class to have CLASS. */
1903 pWnd
->pcls
->pdce
= DceAllocDCE( pWnd
, DCE_CLASS_DC
);
1905 else if ( pWnd
->pcls
->style
& CS_OWNDC
)
1906 { /* Allocate a DCE for this window. */
1907 DceAllocDCE(pWnd
, DCE_WINDOW_DC
);
1915 UserDereferenceObject(pWnd
);
1917 SetLastNtError(STATUS_INSUFFICIENT_RESOURCES
);
1925 co_UserCreateWindowEx(CREATESTRUCTW
* Cs
,
1926 PUNICODE_STRING ClassName
,
1927 PLARGE_STRING WindowName
)
1929 PWND Window
= NULL
, ParentWindow
= NULL
, OwnerWindow
;
1930 HWND hWnd
, hWndParent
, hWndOwner
, hwndInsertAfter
;
1931 PWINSTATION_OBJECT WinSta
;
1935 CBT_CREATEWNDW
* pCbtCreate
;
1937 USER_REFERENCE_ENTRY ParentRef
, Ref
;
1939 DWORD dwShowMode
= SW_SHOW
;
1940 CREATESTRUCTW
*pCsw
= NULL
;
1941 PVOID pszClass
= NULL
, pszName
= NULL
;
1942 DECLARE_RETURN(PWND
);
1944 /* Get the current window station and reference it */
1945 pti
= GetW32ThreadInfo();
1946 if (pti
== NULL
|| pti
->rpdesk
== NULL
)
1948 DPRINT1("Thread is not attached to a desktop! Cannot create window!\n");
1949 return NULL
; //There is nothing to cleanup
1951 WinSta
= pti
->rpdesk
->rpwinstaParent
;
1952 ObReferenceObjectByPointer(WinSta
, KernelMode
, ExWindowStationObjectType
, 0);
1957 /* Get the class and reference it*/
1958 Class
= IntGetAndReferenceClass(ClassName
, Cs
->hInstance
);
1961 DPRINT1("Failed to find class %wZ\n", ClassName
);
1965 /* Now find the parent and the owner window */
1966 hWndParent
= IntGetDesktopWindow();
1969 if (Cs
->hwndParent
== HWND_MESSAGE
)
1971 Cs
->hwndParent
= hWndParent
= IntGetMessageWindow();
1973 else if (Cs
->hwndParent
)
1975 if ((Cs
->style
& (WS_CHILD
|WS_POPUP
)) != WS_CHILD
)
1976 hWndOwner
= Cs
->hwndParent
;
1978 hWndParent
= Cs
->hwndParent
;
1980 else if ((Cs
->style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
)
1982 DPRINT1("Cannot create a child window without a parrent!\n");
1983 EngSetLastError(ERROR_TLW_WITH_WSCHILD
);
1984 RETURN(NULL
); /* WS_CHILD needs a parent, but WS_POPUP doesn't */
1987 ParentWindow
= hWndParent
? UserGetWindowObject(hWndParent
): NULL
;
1988 OwnerWindow
= hWndOwner
? UserGetWindowObject(hWndOwner
): NULL
;
1990 /* FIXME: is this correct?*/
1992 OwnerWindow
= UserGetAncestor(OwnerWindow
, GA_ROOT
);
1994 /* Fix the position and the size of the window */
1997 UserRefObjectCo(ParentWindow
, &ParentRef
);
1998 IntFixWindowCoordinates(Cs
, ParentWindow
, &dwShowMode
);
2001 /* Allocate and initialize the new window */
2002 Window
= IntCreateWindow(Cs
,
2009 DPRINT1("IntCreateWindow failed!\n");
2013 hWnd
= UserHMGetHandle(Window
);
2014 hwndInsertAfter
= HWND_TOP
;
2016 UserRefObjectCo(Window
, &Ref
);
2017 ObDereferenceObject(WinSta
);
2019 //// Check for a hook to eliminate overhead. ////
2020 if ( ISITHOOKED(WH_CBT
) || (pti
->rpdesk
->pDeskInfo
->fsHooks
& HOOKID_TO_FLAG(WH_CBT
)) )
2022 // Allocate the calling structures Justin Case this goes Global.
2023 pCsw
= ExAllocatePoolWithTag(NonPagedPool
, sizeof(CREATESTRUCTW
), TAG_HOOK
);
2024 pCbtCreate
= ExAllocatePoolWithTag(NonPagedPool
, sizeof(CBT_CREATEWNDW
), TAG_HOOK
);
2026 /* Fill the new CREATESTRUCTW */
2027 RtlCopyMemory(pCsw
, Cs
, sizeof(CREATESTRUCTW
));
2028 pCsw
->style
= Window
->style
; /* HCBT_CREATEWND needs the real window style */
2030 // Based on the assumption this is from "unicode source" user32, ReactOS, answer is yes.
2031 if (!IS_ATOM(ClassName
->Buffer
))
2033 if (Window
->state
& WNDS_ANSICREATOR
)
2035 ANSI_STRING AnsiString
;
2036 AnsiString
.MaximumLength
= RtlUnicodeStringToAnsiSize(ClassName
)+sizeof(CHAR
);
2037 pszClass
= UserHeapAlloc(AnsiString
.MaximumLength
);
2038 RtlZeroMemory(pszClass
, AnsiString
.MaximumLength
);
2039 AnsiString
.Buffer
= (PCHAR
)pszClass
;
2040 RtlUnicodeStringToAnsiString(&AnsiString
, ClassName
, FALSE
);
2044 UNICODE_STRING UnicodeString
;
2045 UnicodeString
.MaximumLength
= ClassName
->Length
+ sizeof(UNICODE_NULL
);
2046 pszClass
= UserHeapAlloc(UnicodeString
.MaximumLength
);
2047 RtlZeroMemory(pszClass
, UnicodeString
.MaximumLength
);
2048 UnicodeString
.Buffer
= (PWSTR
)pszClass
;
2049 RtlCopyUnicodeString(&UnicodeString
, ClassName
);
2051 if (pszClass
) pCsw
->lpszClass
= UserHeapAddressToUser(pszClass
);
2053 if (WindowName
->Length
)
2055 UNICODE_STRING Name
;
2056 Name
.Buffer
= WindowName
->Buffer
;
2057 Name
.Length
= WindowName
->Length
;
2058 Name
.MaximumLength
= WindowName
->MaximumLength
;
2060 if (Window
->state
& WNDS_ANSICREATOR
)
2062 ANSI_STRING AnsiString
;
2063 AnsiString
.MaximumLength
= RtlUnicodeStringToAnsiSize(&Name
)+sizeof(CHAR
);
2064 pszName
= UserHeapAlloc(AnsiString
.MaximumLength
);
2065 RtlZeroMemory(pszName
, AnsiString
.MaximumLength
);
2066 AnsiString
.Buffer
= (PCHAR
)pszName
;
2067 RtlUnicodeStringToAnsiString(&AnsiString
, &Name
, FALSE
);
2071 UNICODE_STRING UnicodeString
;
2072 UnicodeString
.MaximumLength
= Name
.Length
+ sizeof(UNICODE_NULL
);
2073 pszName
= UserHeapAlloc(UnicodeString
.MaximumLength
);
2074 RtlZeroMemory(pszName
, UnicodeString
.MaximumLength
);
2075 UnicodeString
.Buffer
= (PWSTR
)pszName
;
2076 RtlCopyUnicodeString(&UnicodeString
, &Name
);
2078 if (pszName
) pCsw
->lpszName
= UserHeapAddressToUser(pszName
);
2081 pCbtCreate
->lpcs
= pCsw
;
2082 pCbtCreate
->hwndInsertAfter
= hwndInsertAfter
;
2084 //// Call the WH_CBT hook ////
2085 Result
= co_HOOK_CallHooks(WH_CBT
, HCBT_CREATEWND
, (WPARAM
) hWnd
, (LPARAM
) pCbtCreate
);
2088 DPRINT1("WH_CBT HCBT_CREATEWND hook failed! 0x%x\n", Result
);
2089 RETURN( (PWND
) NULL
);
2091 // Write back changes.
2096 hwndInsertAfter
= pCbtCreate
->hwndInsertAfter
;
2099 /* NCCREATE and WM_NCCALCSIZE need the original values */
2100 Cs
->lpszName
= (LPCWSTR
) WindowName
;
2101 Cs
->lpszClass
= (LPCWSTR
) ClassName
;
2103 /* Send the WM_GETMINMAXINFO message*/
2107 if ((Cs
->style
& WS_THICKFRAME
) || !(Cs
->style
& (WS_POPUP
| WS_CHILD
)))
2109 POINT MaxSize
, MaxPos
, MinTrack
, MaxTrack
;
2111 co_WinPosGetMinMaxInfo(Window
, &MaxSize
, &MaxPos
, &MinTrack
, &MaxTrack
);
2112 if (Size
.cx
> MaxTrack
.x
) Size
.cx
= MaxTrack
.x
;
2113 if (Size
.cy
> MaxTrack
.y
) Size
.cy
= MaxTrack
.y
;
2114 if (Size
.cx
< MinTrack
.x
) Size
.cx
= MinTrack
.x
;
2115 if (Size
.cy
< MinTrack
.y
) Size
.cy
= MinTrack
.y
;
2118 Window
->rcWindow
.left
= Cs
->x
;
2119 Window
->rcWindow
.top
= Cs
->y
;
2120 Window
->rcWindow
.right
= Cs
->x
+ Size
.cx
;
2121 Window
->rcWindow
.bottom
= Cs
->y
+ Size
.cy
;
2122 if (0 != (Window
->style
& WS_CHILD
) && ParentWindow
)
2124 RECTL_vOffsetRect(&Window
->rcWindow
,
2125 ParentWindow
->rcClient
.left
,
2126 ParentWindow
->rcClient
.top
);
2128 Window
->rcClient
= Window
->rcWindow
;
2130 /* Link the window*/
2131 if (NULL
!= ParentWindow
)
2133 /* link the window into the siblings list */
2134 if ((Cs
->style
& (WS_CHILD
|WS_MAXIMIZE
)) == WS_CHILD
)
2135 IntLinkHwnd(Window
, HWND_BOTTOM
);
2137 IntLinkHwnd(Window
, hwndInsertAfter
);
2140 /* Send the NCCREATE message */
2141 Result
= co_IntSendMessage(UserHMGetHandle(Window
), WM_NCCREATE
, 0, (LPARAM
) Cs
);
2144 DPRINT1("co_UserCreateWindowEx(): NCCREATE message failed\n");
2148 /* Send the WM_NCCALCSIZE message */
2149 MaxPos
.x
= Window
->rcWindow
.left
;
2150 MaxPos
.y
= Window
->rcWindow
.top
;
2152 Result
= co_WinPosGetNonClientSize(Window
, &Window
->rcWindow
, &Window
->rcClient
);
2154 RECTL_vOffsetRect(&Window
->rcWindow
, MaxPos
.x
- Window
->rcWindow
.left
,
2155 MaxPos
.y
- Window
->rcWindow
.top
);
2158 /* Send the WM_CREATE message. */
2159 Result
= co_IntSendMessage(UserHMGetHandle(Window
), WM_CREATE
, 0, (LPARAM
) Cs
);
2160 if (Result
== (LRESULT
)-1)
2162 DPRINT1("co_UserCreateWindowEx(): WM_CREATE message failed\n");
2166 /* Send the EVENT_OBJECT_CREATE event*/
2167 IntNotifyWinEvent(EVENT_OBJECT_CREATE
, Window
, OBJID_WINDOW
, CHILDID_SELF
, 0);
2169 /* By setting the flag below it can be examined to determine if the window
2170 was created successfully and a valid pwnd was passed back to caller since
2171 from here the function has to succeed. */
2172 Window
->state2
|= WNDS2_WMCREATEMSGPROCESSED
;
2174 /* Send the WM_SIZE and WM_MOVE messages. */
2175 if (!(Window
->state
& WNDS_SENDSIZEMOVEMSGS
))
2177 co_WinPosSendSizeMove(Window
);
2180 /* Show or maybe minimize or maximize the window. */
2181 if (Window
->style
& (WS_MINIMIZE
| WS_MAXIMIZE
))
2186 SwFlag
= (Window
->style
& WS_MINIMIZE
) ? SW_MINIMIZE
: SW_MAXIMIZE
;
2188 co_WinPosMinMaximize(Window
, SwFlag
, &NewPos
);
2190 SwFlag
= ((Window
->style
& WS_CHILD
) || UserGetActiveWindow()) ?
2191 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
:
2192 SWP_NOZORDER
| SWP_FRAMECHANGED
;
2194 co_WinPosSetWindowPos(Window
, 0, NewPos
.left
, NewPos
.top
,
2195 NewPos
.right
, NewPos
.bottom
, SwFlag
);
2198 /* Send the WM_PARENTNOTIFY message */
2199 IntSendParentNotify(Window
, WM_CREATE
);
2201 /* Notify the shell that a new window was created */
2202 if ((!hWndParent
) && (!hWndOwner
))
2204 co_IntShellHookNotify(HSHELL_WINDOWCREATED
, (LPARAM
)hWnd
);
2207 /* Initialize and show the window's scrollbars */
2208 if (Window
->style
& WS_VSCROLL
)
2210 co_UserShowScrollBar(Window
, SB_VERT
, TRUE
);
2212 if (Window
->style
& WS_HSCROLL
)
2214 co_UserShowScrollBar(Window
, SB_HORZ
, TRUE
);
2217 /* Show the new window */
2218 if (Cs
->style
& WS_VISIBLE
)
2220 if (Window
->style
& WS_MAXIMIZE
)
2221 dwShowMode
= SW_SHOW
;
2222 else if (Window
->style
& WS_MINIMIZE
)
2223 dwShowMode
= SW_SHOWMINIMIZED
;
2225 co_WinPosShowWindow(Window
, dwShowMode
);
2227 if (Window
->ExStyle
& WS_EX_MDICHILD
)
2229 co_IntSendMessage(UserHMGetHandle(ParentWindow
), WM_MDIREFRESHMENU
, 0, 0);
2230 /* ShowWindow won't activate child windows */
2231 co_WinPosSetWindowPos(Window
, HWND_TOP
, 0, 0, 0, 0, SWP_SHOWWINDOW
| SWP_NOMOVE
| SWP_NOSIZE
);
2235 DPRINT("co_UserCreateWindowEx(): Created window %X\n", hWnd
);
2241 DPRINT("co_UserCreateWindowEx(): Error Created window!\n");
2242 /* If the window was created, the class will be dereferenced by co_UserDestroyWindow */
2244 co_UserDestroyWindow(Window
);
2246 IntDereferenceClass(Class
, pti
->pDeskInfo
, pti
->ppi
);
2249 if (pCsw
) ExFreePoolWithTag(pCsw
, TAG_HOOK
);
2250 if (pCbtCreate
) ExFreePoolWithTag(pCbtCreate
, TAG_HOOK
);
2251 if (pszName
) UserHeapFree(pszName
);
2252 if (pszClass
) UserHeapFree(pszClass
);
2256 UserDerefObjectCo(Window
);
2257 UserDereferenceObject(Window
);
2259 if (ParentWindow
) UserDerefObjectCo(ParentWindow
);
2266 ProbeAndCaptureLargeString(
2267 OUT PLARGE_STRING plstrSafe
,
2268 IN PLARGE_STRING plstrUnsafe
)
2270 LARGE_STRING lstrTemp
;
2271 PVOID pvBuffer
= NULL
;
2275 /* Probe and copy the string */
2276 ProbeForRead(plstrUnsafe
, sizeof(LARGE_STRING
), sizeof(ULONG
));
2277 lstrTemp
= *plstrUnsafe
;
2279 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2282 _SEH2_YIELD(return _SEH2_GetExceptionCode();)
2286 if (lstrTemp
.Length
!= 0)
2288 /* Allocate a buffer from paged pool */
2289 pvBuffer
= ExAllocatePoolWithTag(PagedPool
, lstrTemp
.Length
, TAG_STRING
);
2292 return STATUS_NO_MEMORY
;
2297 /* Probe and copy the buffer */
2298 ProbeForRead(lstrTemp
.Buffer
, lstrTemp
.Length
, sizeof(WCHAR
));
2299 RtlCopyMemory(pvBuffer
, lstrTemp
.Buffer
, lstrTemp
.Length
);
2301 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2303 /* Cleanup and fail */
2304 ExFreePool(pvBuffer
);
2305 _SEH2_YIELD(return _SEH2_GetExceptionCode();)
2310 /* Set the output string */
2311 plstrSafe
->Buffer
= pvBuffer
;
2312 plstrSafe
->Length
= lstrTemp
.Length
;
2313 plstrSafe
->MaximumLength
= lstrTemp
.Length
;
2315 return STATUS_SUCCESS
;
2319 * \todo Allow passing plstrClassName as ANSI.
2323 NtUserCreateWindowEx(
2325 PLARGE_STRING plstrClassName
,
2326 PLARGE_STRING plstrClsVersion
,
2327 PLARGE_STRING plstrWindowName
,
2335 HINSTANCE hInstance
,
2341 LARGE_STRING lstrWindowName
;
2342 LARGE_STRING lstrClassName
;
2343 UNICODE_STRING ustrClassName
;
2348 lstrWindowName
.Buffer
= NULL
;
2349 lstrClassName
.Buffer
= NULL
;
2351 /* Check if we got a Window name */
2352 if (plstrWindowName
)
2354 /* Copy the string to kernel mode */
2355 Status
= ProbeAndCaptureLargeString(&lstrWindowName
, plstrWindowName
);
2356 if (!NT_SUCCESS(Status
))
2358 DPRINT1("NtUserCreateWindowEx: failed to capture plstrWindowName\n");
2359 SetLastNtError(Status
);
2362 plstrWindowName
= &lstrWindowName
;
2365 /* Check if the class is an atom */
2366 if (IS_ATOM(plstrClassName
))
2368 /* It is, pass the atom in the UNICODE_STRING */
2369 ustrClassName
.Buffer
= (PVOID
)plstrClassName
;
2370 ustrClassName
.Length
= 0;
2371 ustrClassName
.MaximumLength
= 0;
2375 /* It's not, capture the class name */
2376 Status
= ProbeAndCaptureLargeString(&lstrClassName
, plstrClassName
);
2377 if (!NT_SUCCESS(Status
))
2379 DPRINT1("NtUserCreateWindowEx: failed to capture plstrClassName\n");
2380 /* Set last error, cleanup and return */
2381 SetLastNtError(Status
);
2385 /* We pass it on as a UNICODE_STRING */
2386 ustrClassName
.Buffer
= lstrClassName
.Buffer
;
2387 ustrClassName
.Length
= lstrClassName
.Length
;
2388 ustrClassName
.MaximumLength
= lstrClassName
.MaximumLength
;
2391 /* Fill the CREATESTRUCTW */
2392 /* we will keep here the original parameters */
2394 Cs
.lpCreateParams
= lpParam
;
2395 Cs
.hInstance
= hInstance
;
2397 Cs
.hwndParent
= hWndParent
;
2402 Cs
.lpszName
= (LPCWSTR
) plstrWindowName
->Buffer
;
2403 if (IS_ATOM(plstrClassName
))
2404 Cs
.lpszClass
= (LPCWSTR
) plstrClassName
;
2406 Cs
.lpszClass
= (LPCWSTR
) plstrClassName
->Buffer
;
2407 Cs
.dwExStyle
= dwExStyle
;
2409 UserEnterExclusive();
2411 /* Call the internal function */
2412 pwnd
= co_UserCreateWindowEx(&Cs
, &ustrClassName
, plstrWindowName
);
2416 DPRINT1("co_UserCreateWindowEx failed!\n");
2418 hwnd
= pwnd
? UserHMGetHandle(pwnd
) : NULL
;
2423 if (lstrWindowName
.Buffer
)
2425 ExFreePoolWithTag(lstrWindowName
.Buffer
, TAG_STRING
);
2427 if (lstrClassName
.Buffer
)
2429 ExFreePoolWithTag(lstrClassName
.Buffer
, TAG_STRING
);
2436 BOOLEAN FASTCALL
co_UserDestroyWindow(PWND Window
)
2442 ASSERT_REFS_CO(Window
); // FIXME: temp hack?
2444 hWnd
= Window
->head
.h
;
2446 DPRINT("co_UserDestroyWindow \n");
2448 /* Check for owner thread */
2449 if ( (Window
->head
.pti
->pEThread
!= PsGetCurrentThread()) ||
2450 Window
->head
.pti
!= PsGetCurrentThreadWin32Thread() )
2452 EngSetLastError(ERROR_ACCESS_DENIED
);
2456 /* If window was created successfully and it is hooked */
2457 if ((Window
->state2
& WNDS2_WMCREATEMSGPROCESSED
))
2459 if (co_HOOK_CallHooks(WH_CBT
, HCBT_DESTROYWND
, (WPARAM
) hWnd
, 0))
2461 DPRINT1("Destroy Window WH_CBT Call Hook return!\n");
2466 /* Inform the parent */
2467 if (Window
->style
& WS_CHILD
)
2469 IntSendParentNotify(Window
, WM_DESTROY
);
2472 /* Look whether the focus is within the tree of windows we will
2475 if (!co_WinPosShowWindow(Window
, SW_HIDE
))
2477 if (UserGetActiveWindow() == Window
->head
.h
)
2479 co_WinPosActivateOtherWindow(Window
);
2483 if (Window
->head
.pti
->MessageQueue
->ActiveWindow
== Window
->head
.h
)
2484 Window
->head
.pti
->MessageQueue
->ActiveWindow
= NULL
;
2485 if (Window
->head
.pti
->MessageQueue
->FocusWindow
== Window
->head
.h
)
2486 Window
->head
.pti
->MessageQueue
->FocusWindow
= NULL
;
2487 if (Window
->head
.pti
->MessageQueue
->CaptureWindow
== Window
->head
.h
)
2488 Window
->head
.pti
->MessageQueue
->CaptureWindow
= NULL
;
2491 * Check if this window is the Shell's Desktop Window. If so set hShellWindow to NULL
2494 ti
= PsGetCurrentThreadWin32Thread();
2496 if ((ti
!= NULL
) & (ti
->pDeskInfo
!= NULL
))
2498 if (ti
->pDeskInfo
->hShellWindow
== hWnd
)
2500 DPRINT1("Destroying the ShellWindow!\n");
2501 ti
->pDeskInfo
->hShellWindow
= NULL
;
2505 IntDereferenceMessageQueue(Window
->head
.pti
->MessageQueue
);
2507 IntEngWindowChanged(Window
, WOC_DELETE
);
2509 if (!IntIsWindow(Window
->head
.h
))
2514 /* Recursively destroy owned windows */
2516 if (! (Window
->style
& WS_CHILD
))
2520 BOOL GotOne
= FALSE
;
2523 PWND Child
, Desktop
;
2525 Desktop
= IntIsDesktopWindow(Window
) ? Window
:
2526 UserGetWindowObject(IntGetDesktopWindow());
2527 Children
= IntWinListChildren(Desktop
);
2531 for (ChildHandle
= Children
; *ChildHandle
; ++ChildHandle
)
2533 Child
= UserGetWindowObject(*ChildHandle
);
2536 if (Child
->spwndOwner
!= Window
)
2541 if (IntWndBelongsToThread(Child
, PsGetCurrentThreadWin32Thread()))
2543 USER_REFERENCE_ENTRY ChildRef
;
2544 UserRefObjectCo(Child
, &ChildRef
);//temp hack?
2545 co_UserDestroyWindow(Child
);
2546 UserDerefObjectCo(Child
);//temp hack?
2552 if (Child
->spwndOwner
!= NULL
)
2554 Child
->spwndOwner
= NULL
;
2558 ExFreePool(Children
);
2567 /* Generate mouse move message for the next window */
2568 msg
.message
= WM_MOUSEMOVE
;
2569 msg
.wParam
= IntGetSysCursorInfo()->ButtonsDown
;
2570 msg
.lParam
= MAKELPARAM(gpsi
->ptCursor
.x
, gpsi
->ptCursor
.y
);
2571 msg
.pt
= gpsi
->ptCursor
;
2572 co_MsqInsertMouseMessage(&msg
);
2574 if (!IntIsWindow(Window
->head
.h
))
2579 /* Destroy the window storage */
2580 co_UserFreeWindow(Window
, PsGetCurrentProcessWin32Process(), PsGetCurrentThreadWin32Thread(), TRUE
);
2590 NtUserDestroyWindow(HWND Wnd
)
2593 DECLARE_RETURN(BOOLEAN
);
2595 USER_REFERENCE_ENTRY Ref
;
2597 DPRINT("Enter NtUserDestroyWindow\n");
2598 UserEnterExclusive();
2600 if (!(Window
= UserGetWindowObject(Wnd
)))
2605 UserRefObjectCo(Window
, &Ref
);//faxme: dunno if win should be reffed during destroy..
2606 ret
= co_UserDestroyWindow(Window
);
2607 UserDerefObjectCo(Window
);//faxme: dunno if win should be reffed during destroy..
2612 DPRINT("Leave NtUserDestroyWindow, ret=%i\n",_ret_
);
2618 static HWND FASTCALL
2619 IntFindWindow(PWND Parent
,
2622 PUNICODE_STRING WindowName
)
2624 BOOL CheckWindowName
;
2627 UNICODE_STRING CurrentWindowName
;
2631 CheckWindowName
= WindowName
->Length
!= 0;
2633 if((List
= IntWinListChildren(Parent
)))
2638 /* skip handles before and including ChildAfter */
2639 while(*phWnd
&& (*(phWnd
++) != ChildAfter
->head
.h
))
2643 /* search children */
2647 if(!(Child
= UserGetWindowObject(*(phWnd
++))))
2652 /* Do not send WM_GETTEXT messages in the kernel mode version!
2653 The user mode version however calls GetWindowText() which will
2654 send WM_GETTEXT messages to windows belonging to its processes */
2655 if (!ClassAtom
|| Child
->pcls
->atomClassName
== ClassAtom
)
2657 // HACK: use UNICODE_STRING instead of LARGE_STRING
2658 CurrentWindowName
.Buffer
= Child
->strName
.Buffer
;
2659 CurrentWindowName
.Length
= Child
->strName
.Length
;
2660 CurrentWindowName
.MaximumLength
= Child
->strName
.MaximumLength
;
2661 if(!CheckWindowName
||
2662 (Child
->strName
.Length
< 0xFFFF &&
2663 !RtlCompareUnicodeString(WindowName
, &CurrentWindowName
, TRUE
)))
2665 Ret
= Child
->head
.h
;
2678 * Searches a window's children for a window with the specified
2681 * hwndParent = The window whose childs are to be searched.
2683 * HWND_MESSAGE = message-only windows
2685 * hwndChildAfter = Search starts after this child window.
2686 * NULL = start from beginning
2688 * ucClassName = Class name to search for
2689 * Reguired parameter.
2691 * ucWindowName = Window name
2692 * ->Buffer == NULL = don't care
2695 * The HWND of the window if it was found, otherwise NULL
2701 NtUserFindWindowEx(HWND hwndParent
,
2702 HWND hwndChildAfter
,
2703 PUNICODE_STRING ucClassName
,
2704 PUNICODE_STRING ucWindowName
,
2707 PWND Parent
, ChildAfter
;
2708 UNICODE_STRING ClassName
= {0}, WindowName
= {0};
2709 HWND Desktop
, Ret
= NULL
;
2710 RTL_ATOM ClassAtom
= (RTL_ATOM
)0;
2711 DECLARE_RETURN(HWND
);
2713 DPRINT("Enter NtUserFindWindowEx\n");
2716 if (ucClassName
!= NULL
|| ucWindowName
!= NULL
)
2720 if (ucClassName
!= NULL
)
2722 ClassName
= ProbeForReadUnicodeString(ucClassName
);
2723 if (ClassName
.Length
!= 0)
2725 ProbeForRead(ClassName
.Buffer
,
2729 else if (!IS_ATOM(ClassName
.Buffer
))
2731 EngSetLastError(ERROR_INVALID_PARAMETER
);
2735 if (!IntGetAtomFromStringOrAtom(&ClassName
,
2742 if (ucWindowName
!= NULL
)
2744 WindowName
= ProbeForReadUnicodeString(ucWindowName
);
2745 if (WindowName
.Length
!= 0)
2747 ProbeForRead(WindowName
.Buffer
,
2753 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2755 SetLastNtError(_SEH2_GetExceptionCode());
2756 _SEH2_YIELD(RETURN(NULL
));
2760 if (ucClassName
!= NULL
)
2762 if (ClassName
.Length
== 0 && ClassName
.Buffer
!= NULL
&&
2763 !IS_ATOM(ClassName
.Buffer
))
2765 EngSetLastError(ERROR_INVALID_PARAMETER
);
2768 else if (ClassAtom
== (RTL_ATOM
)0)
2770 /* LastError code was set by IntGetAtomFromStringOrAtom */
2776 Desktop
= IntGetCurrentThreadDesktopWindow();
2778 if(hwndParent
== NULL
)
2779 hwndParent
= Desktop
;
2780 else if(hwndParent
== HWND_MESSAGE
)
2782 hwndParent
= IntGetMessageWindow();
2785 if(!(Parent
= UserGetWindowObject(hwndParent
)))
2791 if(hwndChildAfter
&& !(ChildAfter
= UserGetWindowObject(hwndChildAfter
)))
2798 if(Parent
->head
.h
== Desktop
)
2801 PWND TopLevelWindow
;
2802 BOOLEAN CheckWindowName
;
2803 BOOLEAN WindowMatches
;
2804 BOOLEAN ClassMatches
;
2806 /* windows searches through all top-level windows if the parent is the desktop
2809 if((List
= IntWinListChildren(Parent
)))
2815 /* skip handles before and including ChildAfter */
2816 while(*phWnd
&& (*(phWnd
++) != ChildAfter
->head
.h
))
2820 CheckWindowName
= WindowName
.Length
!= 0;
2822 /* search children */
2825 UNICODE_STRING ustr
;
2827 if(!(TopLevelWindow
= UserGetWindowObject(*(phWnd
++))))
2832 /* Do not send WM_GETTEXT messages in the kernel mode version!
2833 The user mode version however calls GetWindowText() which will
2834 send WM_GETTEXT messages to windows belonging to its processes */
2835 ustr
.Buffer
= TopLevelWindow
->strName
.Buffer
;
2836 ustr
.Length
= TopLevelWindow
->strName
.Length
;
2837 ustr
.MaximumLength
= TopLevelWindow
->strName
.MaximumLength
;
2838 WindowMatches
= !CheckWindowName
||
2839 (TopLevelWindow
->strName
.Length
< 0xFFFF &&
2840 !RtlCompareUnicodeString(&WindowName
, &ustr
, TRUE
));
2841 ClassMatches
= (ClassAtom
== (RTL_ATOM
)0) ||
2842 ClassAtom
== TopLevelWindow
->pcls
->atomClassName
;
2844 if (WindowMatches
&& ClassMatches
)
2846 Ret
= TopLevelWindow
->head
.h
;
2850 if (IntFindWindow(TopLevelWindow
, NULL
, ClassAtom
, &WindowName
))
2852 /* window returns the handle of the top-level window, in case it found
2854 Ret
= TopLevelWindow
->head
.h
;
2863 Ret
= IntFindWindow(Parent
, ChildAfter
, ClassAtom
, &WindowName
);
2867 if(Ret
== NULL
&& hwndParent
== NULL
&& hwndChildAfter
== NULL
)
2869 /* FIXME - if both hwndParent and hwndChildAfter are NULL, we also should
2870 search the message-only windows. Should this also be done if
2871 Parent is the desktop window??? */
2874 if((MsgWindows
= UserGetWindowObject(IntGetMessageWindow())))
2876 Ret
= IntFindWindow(MsgWindows
, ChildAfter
, ClassAtom
, &WindowName
);
2881 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2883 SetLastNtError(_SEH2_GetExceptionCode());
2891 DPRINT("Leave NtUserFindWindowEx, ret %i\n",_ret_
);
2900 PWND FASTCALL
UserGetAncestor(PWND Wnd
, UINT Type
)
2902 PWND WndAncestor
, Parent
;
2904 if (Wnd
->head
.h
== IntGetDesktopWindow())
2913 WndAncestor
= Wnd
->spwndParent
;
2924 if(!(Parent
= WndAncestor
->spwndParent
))
2928 if(IntIsDesktopWindow(Parent
))
2933 WndAncestor
= Parent
;
2946 Parent
= IntGetParent(WndAncestor
);
2953 WndAncestor
= Parent
;
2971 NtUserGetAncestor(HWND hWnd
, UINT Type
)
2973 PWND Window
, Ancestor
;
2974 DECLARE_RETURN(HWND
);
2976 DPRINT("Enter NtUserGetAncestor\n");
2977 UserEnterExclusive();
2979 if (!(Window
= UserGetWindowObject(hWnd
)))
2984 Ancestor
= UserGetAncestor(Window
, Type
);
2985 /* faxme: can UserGetAncestor ever return NULL for a valid window? */
2987 RETURN(Ancestor
? Ancestor
->head
.h
: NULL
);
2990 DPRINT("Leave NtUserGetAncestor, ret=%i\n",_ret_
);
2998 NtUserGetComboBoxInfo(
3003 DECLARE_RETURN(BOOL
);
3005 DPRINT("Enter NtUserGetComboBoxInfo\n");
3008 if (!(Wnd
= UserGetWindowObject(hWnd
)))
3017 sizeof(COMBOBOXINFO
),
3021 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
3023 SetLastNtError(_SEH2_GetExceptionCode());
3024 _SEH2_YIELD(RETURN(FALSE
));
3028 // Pass the user pointer, it was already probed.
3029 RETURN( (BOOL
) co_IntSendMessage( Wnd
->head
.h
, CB_GETCOMBOBOXINFO
, 0, (LPARAM
)pcbi
));
3032 DPRINT("Leave NtUserGetComboBoxInfo, ret=%i\n",_ret_
);
3042 NtUserGetInternalWindowPos( HWND hWnd
,
3049 WINDOWPLACEMENT wndpl
;
3053 if (!(Window
= UserGetWindowObject(hWnd
)))
3063 ProbeForWrite(rectWnd
,
3069 ProbeForWrite(ptIcon
,
3075 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
3077 SetLastNtError(_SEH2_GetExceptionCode());
3082 wndpl
.length
= sizeof(WINDOWPLACEMENT
);
3084 if (IntGetWindowPlacement(Window
, &wndpl
) && !Hit
)
3090 RtlCopyMemory(rectWnd
, &wndpl
.rcNormalPosition
, sizeof(RECT
));
3094 RtlCopyMemory(ptIcon
, &wndpl
.ptMinPosition
, sizeof(POINT
));
3098 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
3100 SetLastNtError(_SEH2_GetExceptionCode());
3105 if (!Hit
) Ret
= wndpl
.showCmd
;
3114 NtUserGetListBoxInfo(
3118 DECLARE_RETURN(DWORD
);
3120 DPRINT("Enter NtUserGetListBoxInfo\n");
3123 if (!(Wnd
= UserGetWindowObject(hWnd
)))
3128 RETURN( (DWORD
) co_IntSendMessage( Wnd
->head
.h
, LB_GETLISTBOXINFO
, 0, 0 ));
3131 DPRINT("Leave NtUserGetListBoxInfo, ret=%i\n",_ret_
);
3139 * The NtUserSetParent function changes the parent window of the specified
3143 * The new parent window and the child window must belong to the same
3144 * application. If the window identified by the hWndChild parameter is
3145 * visible, the system performs the appropriate redrawing and repainting.
3146 * For compatibility reasons, NtUserSetParent does not modify the WS_CHILD
3147 * or WS_POPUP window styles of the window whose parent is being changed.
3154 NtUserSetParent(HWND hWndChild
, HWND hWndNewParent
)
3156 DECLARE_RETURN(HWND
);
3158 DPRINT("Enter NtUserSetParent\n");
3159 UserEnterExclusive();
3162 Check Parent first from user space, set it here.
3166 hWndNewParent
= IntGetDesktopWindow();
3168 else if (hWndNewParent
== HWND_MESSAGE
)
3170 hWndNewParent
= IntGetMessageWindow();
3173 RETURN( co_UserSetParent(hWndChild
, hWndNewParent
));
3176 DPRINT("Leave NtUserSetParent, ret=%i\n",_ret_
);
3182 * UserGetShellWindow
3184 * Returns a handle to shell window that was set by NtUserSetShellWindowEx.
3189 HWND FASTCALL
UserGetShellWindow(VOID
)
3191 PWINSTATION_OBJECT WinStaObject
;
3194 NTSTATUS Status
= IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation
,
3199 if (!NT_SUCCESS(Status
))
3201 SetLastNtError(Status
);
3205 Ret
= (HWND
)WinStaObject
->ShellWindow
;
3207 ObDereferenceObject(WinStaObject
);
3212 * NtUserSetShellWindowEx
3214 * This is undocumented function to set global shell window. The global
3215 * shell window has special handling of window position.
3221 NtUserSetShellWindowEx(HWND hwndShell
, HWND hwndListView
)
3223 PWINSTATION_OBJECT WinStaObject
;
3224 PWND WndShell
, WndListView
;
3225 DECLARE_RETURN(BOOL
);
3226 USER_REFERENCE_ENTRY Ref
;
3230 DPRINT("Enter NtUserSetShellWindowEx\n");
3231 UserEnterExclusive();
3233 if (!(WndShell
= UserGetWindowObject(hwndShell
)))
3238 if(!(WndListView
= UserGetWindowObject(hwndListView
)))
3243 Status
= IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation
,
3248 if (!NT_SUCCESS(Status
))
3250 SetLastNtError(Status
);
3255 * Test if we are permitted to change the shell window.
3257 if (WinStaObject
->ShellWindow
)
3259 ObDereferenceObject(WinStaObject
);
3264 * Move shell window into background.
3266 if (hwndListView
&& hwndListView
!= hwndShell
)
3269 * Disabled for now to get Explorer working.
3270 * -- Filip, 01/nov/2003
3273 co_WinPosSetWindowPos(hwndListView
, HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
);
3276 if (WndListView
->ExStyle
& WS_EX_TOPMOST
)
3278 ObDereferenceObject(WinStaObject
);
3283 if (WndShell
->ExStyle
& WS_EX_TOPMOST
)
3285 ObDereferenceObject(WinStaObject
);
3289 UserRefObjectCo(WndShell
, &Ref
);
3290 co_WinPosSetWindowPos(WndShell
, HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
);
3292 WinStaObject
->ShellWindow
= hwndShell
;
3293 WinStaObject
->ShellListView
= hwndListView
;
3295 ti
= GetW32ThreadInfo();
3296 if (ti
->pDeskInfo
) ti
->pDeskInfo
->hShellWindow
= hwndShell
;
3298 UserDerefObjectCo(WndShell
);
3300 ObDereferenceObject(WinStaObject
);
3304 DPRINT("Leave NtUserSetShellWindowEx, ret=%i\n",_ret_
);
3310 * NtUserGetSystemMenu
3312 * The NtUserGetSystemMenu function allows the application to access the
3313 * window menu (also known as the system menu or the control menu) for
3314 * copying and modifying.
3318 * Handle to the window that will own a copy of the window menu.
3320 * Specifies the action to be taken. If this parameter is FALSE,
3321 * NtUserGetSystemMenu returns a handle to the copy of the window menu
3322 * currently in use. The copy is initially identical to the window menu
3323 * but it can be modified.
3324 * If this parameter is TRUE, GetSystemMenu resets the window menu back
3325 * to the default state. The previous window menu, if any, is destroyed.
3328 * If the bRevert parameter is FALSE, the return value is a handle to a
3329 * copy of the window menu. If the bRevert parameter is TRUE, the return
3337 NtUserGetSystemMenu(HWND hWnd
, BOOL bRevert
)
3341 DECLARE_RETURN(HMENU
);
3343 DPRINT("Enter NtUserGetSystemMenu\n");
3346 if (!(Window
= UserGetWindowObject(hWnd
)))
3351 if (!(Menu
= IntGetSystemMenu(Window
, bRevert
, FALSE
)))
3356 RETURN(Menu
->MenuInfo
.Self
);
3359 DPRINT("Leave NtUserGetSystemMenu, ret=%i\n",_ret_
);
3365 * NtUserSetSystemMenu
3372 NtUserSetSystemMenu(HWND hWnd
, HMENU hMenu
)
3374 BOOL Result
= FALSE
;
3377 DECLARE_RETURN(BOOL
);
3379 DPRINT("Enter NtUserSetSystemMenu\n");
3380 UserEnterExclusive();
3382 if (!(Window
= UserGetWindowObject(hWnd
)))
3390 * Assign new menu handle.
3392 if (!(Menu
= UserGetMenuObject(hMenu
)))
3397 Result
= IntSetSystemMenu(Window
, Menu
);
3403 DPRINT("Leave NtUserSetSystemMenu, ret=%i\n",_ret_
);
3409 co_UserSetWindowLong(HWND hWnd
, DWORD Index
, LONG NewValue
, BOOL Ansi
)
3411 PWND Window
, Parent
;
3412 PWINSTATION_OBJECT WindowStation
;
3416 if (hWnd
== IntGetDesktopWindow())
3418 EngSetLastError(STATUS_ACCESS_DENIED
);
3422 if (!(Window
= UserGetWindowObject(hWnd
)))
3427 if ((INT
)Index
>= 0)
3429 if ((Index
+ sizeof(LONG
)) > Window
->cbwndExtra
)
3431 EngSetLastError(ERROR_INVALID_INDEX
);
3435 OldValue
= *((LONG
*)((PCHAR
)(Window
+ 1) + Index
));
3437 if ( Index == DWLP_DLGPROC && Wnd->state & WNDS_DIALOGWINDOW)
3439 OldValue = (LONG)IntSetWindowProc( Wnd,
3442 if (!OldValue) return 0;
3445 *((LONG
*)((PCHAR
)(Window
+ 1) + Index
)) = NewValue
;
3452 OldValue
= (LONG
) Window
->ExStyle
;
3453 Style
.styleOld
= OldValue
;
3454 Style
.styleNew
= NewValue
;
3457 * Remove extended window style bit WS_EX_TOPMOST for shell windows.
3459 WindowStation
= Window
->head
.pti
->rpdesk
->rpwinstaParent
;
3462 if (hWnd
== WindowStation
->ShellWindow
|| hWnd
== WindowStation
->ShellListView
)
3463 Style
.styleNew
&= ~WS_EX_TOPMOST
;
3466 co_IntSendMessage(hWnd
, WM_STYLECHANGING
, GWL_EXSTYLE
, (LPARAM
) &Style
);
3467 Window
->ExStyle
= (DWORD
)Style
.styleNew
;
3468 co_IntSendMessage(hWnd
, WM_STYLECHANGED
, GWL_EXSTYLE
, (LPARAM
) &Style
);
3472 OldValue
= (LONG
) Window
->style
;
3473 Style
.styleOld
= OldValue
;
3474 Style
.styleNew
= NewValue
;
3475 co_IntSendMessage(hWnd
, WM_STYLECHANGING
, GWL_STYLE
, (LPARAM
) &Style
);
3476 Window
->style
= (DWORD
)Style
.styleNew
;
3477 co_IntSendMessage(hWnd
, WM_STYLECHANGED
, GWL_STYLE
, (LPARAM
) &Style
);
3482 if ( Window
->head
.pti
->ppi
!= PsGetCurrentProcessWin32Process() ||
3483 Window
->fnid
& FNID_FREED
)
3485 EngSetLastError(ERROR_ACCESS_DENIED
);
3488 OldValue
= (LONG
)IntSetWindowProc(Window
,
3495 OldValue
= (LONG
) Window
->hModule
;
3496 Window
->hModule
= (HINSTANCE
) NewValue
;
3499 case GWL_HWNDPARENT
:
3500 Parent
= Window
->spwndParent
;
3501 if (Parent
&& (Parent
->head
.h
== IntGetDesktopWindow()))
3502 OldValue
= (LONG
) IntSetOwner(Window
->head
.h
, (HWND
) NewValue
);
3504 OldValue
= (LONG
) co_UserSetParent(Window
->head
.h
, (HWND
) NewValue
);
3508 OldValue
= (LONG
) Window
->IDMenu
;
3509 Window
->IDMenu
= (UINT
) NewValue
;
3513 OldValue
= Window
->dwUserData
;
3514 Window
->dwUserData
= NewValue
;
3518 DPRINT1("NtUserSetWindowLong(): Unsupported index %d\n", Index
);
3519 EngSetLastError(ERROR_INVALID_INDEX
);
3529 * NtUserSetWindowLong
3531 * The NtUserSetWindowLong function changes an attribute of the specified
3532 * window. The function also sets the 32-bit (long) value at the specified
3533 * offset into the extra window memory.
3540 NtUserSetWindowLong(HWND hWnd
, DWORD Index
, LONG NewValue
, BOOL Ansi
)
3542 DECLARE_RETURN(LONG
);
3544 DPRINT("Enter NtUserSetWindowLong\n");
3545 UserEnterExclusive();
3547 RETURN( co_UserSetWindowLong(hWnd
, Index
, NewValue
, Ansi
));
3550 DPRINT("Leave NtUserSetWindowLong, ret=%i\n",_ret_
);
3556 * NtUserSetWindowWord
3558 * Legacy function similar to NtUserSetWindowLong.
3565 NtUserSetWindowWord(HWND hWnd
, INT Index
, WORD NewValue
)
3569 DECLARE_RETURN(WORD
);
3571 DPRINT("Enter NtUserSetWindowWord\n");
3572 UserEnterExclusive();
3574 if (!(Window
= UserGetWindowObject(hWnd
)))
3583 case GWL_HWNDPARENT
:
3584 RETURN( co_UserSetWindowLong(Window
->head
.h
, Index
, (UINT
)NewValue
, TRUE
));
3588 EngSetLastError(ERROR_INVALID_INDEX
);
3593 if (Index
> Window
->cbwndExtra
- sizeof(WORD
))
3595 EngSetLastError(ERROR_INVALID_PARAMETER
);
3599 OldValue
= *((WORD
*)((PCHAR
)(Window
+ 1) + Index
));
3600 *((WORD
*)((PCHAR
)(Window
+ 1) + Index
)) = NewValue
;
3605 DPRINT("Leave NtUserSetWindowWord, ret=%i\n",_ret_
);
3614 NtUserGetWindowPlacement(HWND hWnd
,
3615 WINDOWPLACEMENT
*lpwndpl
)
3619 WINDOWPLACEMENT Safepl
;
3621 DECLARE_RETURN(BOOL
);
3623 DPRINT("Enter NtUserGetWindowPlacement\n");
3626 if (!(Wnd
= UserGetWindowObject(hWnd
)))
3631 Status
= MmCopyFromCaller(&Safepl
, lpwndpl
, sizeof(WINDOWPLACEMENT
));
3632 if(!NT_SUCCESS(Status
))
3634 SetLastNtError(Status
);
3637 if(Safepl
.length
!= sizeof(WINDOWPLACEMENT
))
3643 if (0 == (Wnd
->style
& WS_VISIBLE
))
3645 Safepl
.showCmd
= SW_HIDE
;
3647 else if ((0 != (Wnd
->state2
& WNDS2_MAXIMIZEBUTTONDOWN
) ||
3648 0 != (Wnd
->style
& WS_MAXIMIZE
)) &&
3649 0 == (Wnd
->style
& WS_MINIMIZE
))
3651 Safepl
.showCmd
= SW_SHOWMAXIMIZED
;
3653 else if (0 != (Wnd
->style
& WS_MINIMIZE
))
3655 Safepl
.showCmd
= SW_SHOWMINIMIZED
;
3657 else if (0 != (Wnd
->style
& WS_VISIBLE
))
3659 Safepl
.showCmd
= SW_SHOWNORMAL
;
3662 Size
.x
= Wnd
->rcWindow
.left
;
3663 Size
.y
= Wnd
->rcWindow
.top
;
3664 WinPosInitInternalPos(Wnd
, &Size
,
3667 Safepl
.rcNormalPosition
= Wnd
->InternalPos
.NormalRect
;
3668 Safepl
.ptMinPosition
= Wnd
->InternalPos
.IconPos
;
3669 Safepl
.ptMaxPosition
= Wnd
->InternalPos
.MaxPos
;
3671 Status
= MmCopyToCaller(lpwndpl
, &Safepl
, sizeof(WINDOWPLACEMENT
));
3672 if(!NT_SUCCESS(Status
))
3674 SetLastNtError(Status
);
3681 DPRINT("Leave NtUserGetWindowPlacement, ret=%i\n",_ret_
);
3698 return NtUserSetWindowPos(hWnd
, 0, X
, Y
, nWidth
, nHeight
,
3699 (bRepaint
? SWP_NOZORDER
| SWP_NOACTIVATE
:
3700 SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOREDRAW
));
3704 QueryWindow based on KJK::Hyperion and James Tabor.
3706 0 = QWUniqueProcessId
3707 1 = QWUniqueThreadId
3710 4 = QWIsHung Implements IsHungAppWindow found
3713 9 = QWKillWindow When I called this with hWnd ==
3714 DesktopWindow, it shutdown the system
3721 NtUserQueryWindow(HWND hWnd
, DWORD Index
)
3725 DECLARE_RETURN(UINT
);
3727 DPRINT("Enter NtUserQueryWindow\n");
3730 if (!(pWnd
= UserGetWindowObject(hWnd
)))
3737 case QUERY_WINDOW_UNIQUE_PROCESS_ID
:
3738 Result
= (DWORD
)IntGetWndProcessId(pWnd
);
3741 case QUERY_WINDOW_UNIQUE_THREAD_ID
:
3742 Result
= (DWORD
)IntGetWndThreadId(pWnd
);
3745 case QUERY_WINDOW_ACTIVE
:
3746 Result
= (DWORD
)UserGetActiveWindow();
3749 case QUERY_WINDOW_FOCUS
:
3750 Result
= (DWORD
)IntGetFocusWindow();
3753 case QUERY_WINDOW_ISHUNG
:
3754 Result
= (DWORD
)MsqIsHung(pWnd
->head
.pti
->MessageQueue
);
3757 case QUERY_WINDOW_REAL_ID
:
3758 Result
= (DWORD
)pWnd
->head
.pti
->pEThread
->Cid
.UniqueProcess
;
3761 Result
= (DWORD
)NULL
;
3768 DPRINT("Leave NtUserQueryWindow, ret=%i\n",_ret_
);
3778 NtUserRegisterWindowMessage(PUNICODE_STRING MessageNameUnsafe
)
3780 UNICODE_STRING SafeMessageName
;
3783 DECLARE_RETURN(UINT
);
3785 DPRINT("Enter NtUserRegisterWindowMessage\n");
3786 UserEnterExclusive();
3788 if(MessageNameUnsafe
== NULL
)
3790 EngSetLastError(ERROR_INVALID_PARAMETER
);
3794 Status
= IntSafeCopyUnicodeStringTerminateNULL(&SafeMessageName
, MessageNameUnsafe
);
3795 if(!NT_SUCCESS(Status
))
3797 SetLastNtError(Status
);
3801 Ret
= (UINT
)IntAddAtom(SafeMessageName
.Buffer
);
3802 if (SafeMessageName
.Buffer
)
3803 ExFreePoolWithTag(SafeMessageName
.Buffer
, TAG_STRING
);
3807 DPRINT("Leave NtUserRegisterWindowMessage, ret=%i\n",_ret_
);
3824 DECLARE_RETURN(BOOL
);
3826 DPRINT("Enter NtUserSetMenu\n");
3827 UserEnterExclusive();
3829 if (!(Window
= UserGetWindowObject(hWnd
)))
3834 if (! IntSetMenu(Window
, Menu
, &Changed
))
3839 if (Changed
&& Repaint
)
3841 USER_REFERENCE_ENTRY Ref
;
3843 UserRefObjectCo(Window
, &Ref
);
3844 co_WinPosSetWindowPos(Window
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
3845 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
3847 UserDerefObjectCo(Window
);
3853 DPRINT("Leave NtUserSetMenu, ret=%i\n",_ret_
);
3863 NtUserSetWindowFNID(HWND hWnd
,
3867 DECLARE_RETURN(BOOL
);
3869 DPRINT("Enter NtUserSetWindowFNID\n");
3870 UserEnterExclusive();
3872 if (!(Wnd
= UserGetWindowObject(hWnd
)))
3877 if (Wnd
->head
.pti
->ppi
!= PsGetCurrentProcessWin32Process())
3879 EngSetLastError(ERROR_ACCESS_DENIED
);
3883 // From user land we only set these.
3884 if (fnID
!= FNID_DESTROY
)
3885 { // Hacked so we can mark desktop~!
3886 if ( (/*(fnID < FNID_BUTTON)*/ (fnID
< FNID_FIRST
) && (fnID
> FNID_GHOST
)) ||
3889 EngSetLastError(ERROR_INVALID_PARAMETER
);
3898 DPRINT("Leave NtUserSetWindowFNID\n");
3908 NtUserSetWindowPlacement(HWND hWnd
,
3909 WINDOWPLACEMENT
*lpwndpl
)
3912 WINDOWPLACEMENT Safepl
;
3914 DECLARE_RETURN(BOOL
);
3915 USER_REFERENCE_ENTRY Ref
;
3917 DPRINT("Enter NtUserSetWindowPlacement\n");
3918 UserEnterExclusive();
3920 if (!(Wnd
= UserGetWindowObject(hWnd
)))
3925 Status
= MmCopyFromCaller(&Safepl
, lpwndpl
, sizeof(WINDOWPLACEMENT
));
3926 if(!NT_SUCCESS(Status
))
3928 SetLastNtError(Status
);
3931 if(Safepl
.length
!= sizeof(WINDOWPLACEMENT
))
3936 UserRefObjectCo(Wnd
, &Ref
);
3938 if ((Wnd
->style
& (WS_MAXIMIZE
| WS_MINIMIZE
)) == 0)
3940 co_WinPosSetWindowPos(Wnd
, NULL
,
3941 Safepl
.rcNormalPosition
.left
, Safepl
.rcNormalPosition
.top
,
3942 Safepl
.rcNormalPosition
.right
- Safepl
.rcNormalPosition
.left
,
3943 Safepl
.rcNormalPosition
.bottom
- Safepl
.rcNormalPosition
.top
,
3944 SWP_NOZORDER
| SWP_NOACTIVATE
);
3947 /* FIXME - change window status */
3948 co_WinPosShowWindow(Wnd
, Safepl
.showCmd
);
3950 Wnd
->InternalPosInitialized
= TRUE
;
3951 Wnd
->InternalPos
.NormalRect
= Safepl
.rcNormalPosition
;
3952 Wnd
->InternalPos
.IconPos
= Safepl
.ptMinPosition
;
3953 Wnd
->InternalPos
.MaxPos
= Safepl
.ptMaxPosition
;
3955 UserDerefObjectCo(Wnd
);
3959 DPRINT("Leave NtUserSetWindowPlacement, ret=%i\n",_ret_
);
3971 HWND hWndInsertAfter
,
3978 DECLARE_RETURN(BOOL
);
3981 USER_REFERENCE_ENTRY Ref
;
3983 DPRINT("Enter NtUserSetWindowPos\n");
3984 UserEnterExclusive();
3986 if (!(Window
= UserGetWindowObject(hWnd
)))
3991 /* First make sure that coordinates are valid for WM_WINDOWPOSCHANGING */
3992 if (!(uFlags
& SWP_NOMOVE
))
3994 if (X
< -32768) X
= -32768;
3995 else if (X
> 32767) X
= 32767;
3996 if (Y
< -32768) Y
= -32768;
3997 else if (Y
> 32767) Y
= 32767;
3999 if (!(uFlags
& SWP_NOSIZE
))
4002 else if (cx
> 32767) cx
= 32767;
4004 else if (cy
> 32767) cy
= 32767;
4007 UserRefObjectCo(Window
, &Ref
);
4008 ret
= co_WinPosSetWindowPos(Window
, hWndInsertAfter
, X
, Y
, cx
, cy
, uFlags
);
4009 UserDerefObjectCo(Window
);
4014 DPRINT("Leave NtUserSetWindowPos, ret=%i\n",_ret_
);
4021 IntGetWindowRgn(PWND Window
, HRGN hRgn
)
4036 /* Create a new window region using the window rectangle */
4037 VisRgn
= IntSysCreateRectRgnIndirect(&Window
->rcWindow
);
4038 NtGdiOffsetRgn(VisRgn
, -Window
->rcWindow
.left
, -Window
->rcWindow
.top
);
4039 /* if there's a region assigned to the window, combine them both */
4040 if(Window
->hrgnClip
&& !(Window
->style
& WS_MINIMIZE
))
4041 NtGdiCombineRgn(VisRgn
, VisRgn
, Window
->hrgnClip
, RGN_AND
);
4042 /* Copy the region into hRgn */
4043 NtGdiCombineRgn(hRgn
, VisRgn
, NULL
, RGN_COPY
);
4045 if((pRgn
= RGNOBJAPI_Lock(hRgn
, NULL
)))
4047 Ret
= REGION_Complexity(pRgn
);
4048 RGNOBJAPI_Unlock(pRgn
);
4053 REGION_FreeRgnByHandle(VisRgn
);
4059 IntGetWindowRgnBox(PWND Window
, RECTL
*Rect
)
4074 /* Create a new window region using the window rectangle */
4075 VisRgn
= IntSysCreateRectRgnIndirect(&Window
->rcWindow
);
4076 NtGdiOffsetRgn(VisRgn
, -Window
->rcWindow
.left
, -Window
->rcWindow
.top
);
4077 /* if there's a region assigned to the window, combine them both */
4078 if(Window
->hrgnClip
&& !(Window
->style
& WS_MINIMIZE
))
4079 NtGdiCombineRgn(VisRgn
, VisRgn
, Window
->hrgnClip
, RGN_AND
);
4081 if((pRgn
= RGNOBJAPI_Lock(VisRgn
, NULL
)))
4083 Ret
= REGION_Complexity(pRgn
);
4084 *Rect
= pRgn
->rdh
.rcBound
;
4085 RGNOBJAPI_Unlock(pRgn
);
4090 REGION_FreeRgnByHandle(VisRgn
);
4107 DECLARE_RETURN(INT
);
4109 DPRINT("Enter NtUserSetWindowRgn\n");
4110 UserEnterExclusive();
4112 if (!(Window
= UserGetWindowObject(hWnd
)))
4117 if (hRgn
) // The region will be deleted in user32.
4119 if (GDIOBJ_ValidateHandle(hRgn
, GDI_OBJECT_TYPE_REGION
))
4121 hrgnCopy
= IntSysCreateRectRgn(0, 0, 0, 0);
4122 NtGdiCombineRgn(hrgnCopy
, hRgn
, 0, RGN_COPY
);
4128 hrgnCopy
= (HRGN
) 1;
4130 if (Window
->hrgnClip
)
4132 /* Delete no longer needed region handle */
4133 GreDeleteObject(Window
->hrgnClip
);
4135 Window
->hrgnClip
= hrgnCopy
;
4137 /* FIXME - send WM_WINDOWPOSCHANGING and WM_WINDOWPOSCHANGED messages to the window */
4141 USER_REFERENCE_ENTRY Ref
;
4142 UserRefObjectCo(Window
, &Ref
);
4143 co_UserRedrawWindow(Window
, NULL
, NULL
, RDW_INVALIDATE
);
4144 UserDerefObjectCo(Window
);
4150 DPRINT("Leave NtUserSetWindowRgn, ret=%i\n",_ret_
);
4160 NtUserShowWindow(HWND hWnd
, LONG nCmdShow
)
4164 DECLARE_RETURN(BOOL
);
4165 USER_REFERENCE_ENTRY Ref
;
4167 DPRINT("Enter NtUserShowWindow\n");
4168 UserEnterExclusive();
4170 if (!(Window
= UserGetWindowObject(hWnd
)))
4175 UserRefObjectCo(Window
, &Ref
);
4176 ret
= co_WinPosShowWindow(Window
, nCmdShow
);
4177 UserDerefObjectCo(Window
);
4182 DPRINT("Leave NtUserShowWindow, ret=%i\n",_ret_
);
4192 NtUserShowWindowAsync(HWND hWnd
, LONG nCmdShow
)
4198 return NtUserShowWindow(hWnd
, nCmdShow
);
4206 NtUserWindowFromPoint(LONG X
, LONG Y
)
4210 PWND DesktopWindow
= NULL
, Window
= NULL
;
4212 DECLARE_RETURN(HWND
);
4213 USER_REFERENCE_ENTRY Ref
;
4215 DPRINT("Enter NtUserWindowFromPoint\n");
4216 UserEnterExclusive();
4218 if ((DesktopWindow
= UserGetWindowObject(IntGetDesktopWindow())))
4225 //hmm... threads live on desktops thus we have a reference on the desktop and indirectly the desktop window
4226 //its possible this referencing is useless, thou it shouldnt hurt...
4227 UserRefObjectCo(DesktopWindow
, &Ref
);
4229 pti
= PsGetCurrentThreadWin32Thread();
4230 Window
= co_WinPosWindowFromPoint(DesktopWindow
, &pt
, &hittest
);
4234 Ret
= Window
->head
.h
;
4243 if (Window
) UserDereferenceObject(Window
);
4244 if (DesktopWindow
) UserDerefObjectCo(DesktopWindow
);
4246 DPRINT("Leave NtUserWindowFromPoint, ret=%i\n",_ret_
);
4256 * Undocumented function that is called from DefWindowProc to set
4263 NtUserDefSetText(HWND hWnd
, PLARGE_STRING WindowText
)
4266 LARGE_STRING SafeText
;
4267 UNICODE_STRING UnicodeString
;
4270 DPRINT("Enter NtUserDefSetText\n");
4272 if (WindowText
!= NULL
)
4276 SafeText
= ProbeForReadLargeString(WindowText
);
4278 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
4281 SetLastNtError(_SEH2_GetExceptionCode());
4291 UserEnterExclusive();
4293 if(!(Wnd
= UserGetWindowObject(hWnd
)))
4299 // ReactOS uses Unicode and not mixed. Up/Down converting will take time.
4300 // Brought to you by: The Wine Project! Dysfunctional Thought Processes!
4301 // Now we know what the bAnsi is for.
4302 RtlInitUnicodeString(&UnicodeString
, NULL
);
4303 if (SafeText
.Buffer
)
4308 ProbeForRead(SafeText
.Buffer
, SafeText
.Length
, sizeof(CHAR
));
4310 ProbeForRead(SafeText
.Buffer
, SafeText
.Length
, sizeof(WCHAR
));
4311 Ret
= RtlLargeStringToUnicodeString(&UnicodeString
, &SafeText
);
4313 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
4316 SetLastNtError(_SEH2_GetExceptionCode());
4319 if (!Ret
) goto Exit
;
4322 if (UnicodeString
.Length
!= 0)
4324 if (Wnd
->strName
.MaximumLength
> 0 &&
4325 UnicodeString
.Length
<= Wnd
->strName
.MaximumLength
- sizeof(UNICODE_NULL
))
4327 ASSERT(Wnd
->strName
.Buffer
!= NULL
);
4329 Wnd
->strName
.Length
= UnicodeString
.Length
;
4330 Wnd
->strName
.Buffer
[UnicodeString
.Length
/ sizeof(WCHAR
)] = L
'\0';
4331 RtlCopyMemory(Wnd
->strName
.Buffer
,
4332 UnicodeString
.Buffer
,
4333 UnicodeString
.Length
);
4338 Wnd
->strName
.MaximumLength
= Wnd
->strName
.Length
= 0;
4339 buf
= Wnd
->strName
.Buffer
;
4340 Wnd
->strName
.Buffer
= NULL
;
4343 DesktopHeapFree(Wnd
->head
.rpdesk
, buf
);
4346 Wnd
->strName
.Buffer
= DesktopHeapAlloc(Wnd
->head
.rpdesk
,
4347 UnicodeString
.Length
+ sizeof(UNICODE_NULL
));
4348 if (Wnd
->strName
.Buffer
!= NULL
)
4350 Wnd
->strName
.Buffer
[UnicodeString
.Length
/ sizeof(WCHAR
)] = L
'\0';
4351 RtlCopyMemory(Wnd
->strName
.Buffer
,
4352 UnicodeString
.Buffer
,
4353 UnicodeString
.Length
);
4354 Wnd
->strName
.MaximumLength
= UnicodeString
.Length
+ sizeof(UNICODE_NULL
);
4355 Wnd
->strName
.Length
= UnicodeString
.Length
;
4359 EngSetLastError(ERROR_NOT_ENOUGH_MEMORY
);
4367 Wnd
->strName
.Length
= 0;
4368 if (Wnd
->strName
.Buffer
!= NULL
)
4369 Wnd
->strName
.Buffer
[0] = L
'\0';
4372 // HAX! FIXME! Windows does not do this in here!
4373 // In User32, these are called after: NotifyWinEvent EVENT_OBJECT_NAMECHANGE than
4374 // RepaintButton, StaticRepaint, NtUserCallHwndLock HWNDLOCK_ROUTINE_REDRAWFRAMEANDHOOK, etc.
4375 /* Send shell notifications */
4376 if (!Wnd
->spwndOwner
&& !IntGetParent(Wnd
))
4378 co_IntShellHookNotify(HSHELL_REDRAW
, (LPARAM
) hWnd
);
4383 if (UnicodeString
.Buffer
) RtlFreeUnicodeString(&UnicodeString
);
4384 DPRINT("Leave NtUserDefSetText, ret=%i\n", Ret
);
4390 * NtUserInternalGetWindowText
4397 NtUserInternalGetWindowText(HWND hWnd
, LPWSTR lpString
, INT nMaxCount
)
4402 DECLARE_RETURN(INT
);
4404 DPRINT("Enter NtUserInternalGetWindowText\n");
4407 if(lpString
&& (nMaxCount
<= 1))
4409 EngSetLastError(ERROR_INVALID_PARAMETER
);
4413 if(!(Wnd
= UserGetWindowObject(hWnd
)))
4418 Result
= Wnd
->strName
.Length
/ sizeof(WCHAR
);
4421 const WCHAR Terminator
= L
'\0';
4423 WCHAR
*Buffer
= (WCHAR
*)lpString
;
4425 Copy
= min(nMaxCount
- 1, Result
);
4428 Status
= MmCopyToCaller(Buffer
, Wnd
->strName
.Buffer
, Copy
* sizeof(WCHAR
));
4429 if(!NT_SUCCESS(Status
))
4431 SetLastNtError(Status
);
4437 Status
= MmCopyToCaller(Buffer
, &Terminator
, sizeof(WCHAR
));
4438 if(!NT_SUCCESS(Status
))
4440 SetLastNtError(Status
);
4450 DPRINT("Leave NtUserInternalGetWindowText, ret=%i\n",_ret_
);
4458 IntShowOwnedPopups(PWND OwnerWnd
, BOOL fShow
)
4464 // ASSERT(OwnerWnd);
4466 win_array
= IntWinListChildren(UserGetWindowObject(IntGetDesktopWindow()));
4471 while (win_array
[count
])
4473 while (--count
>= 0)
4475 if (!(pWnd
= UserGetWindowObject( win_array
[count
] )))
4477 if (pWnd
->spwndOwner
!= OwnerWnd
)
4482 if (pWnd
->state
& WNDS_HIDDENPOPUP
)
4484 /* In Windows, ShowOwnedPopups(TRUE) generates
4485 * WM_SHOWWINDOW messages with SW_PARENTOPENING,
4486 * regardless of the state of the owner
4488 co_IntSendMessage(win_array
[count
], WM_SHOWWINDOW
, SW_SHOWNORMAL
, SW_PARENTOPENING
);
4494 if (pWnd
->style
& WS_VISIBLE
)
4496 /* In Windows, ShowOwnedPopups(FALSE) generates
4497 * WM_SHOWWINDOW messages with SW_PARENTCLOSING,
4498 * regardless of the state of the owner
4500 co_IntSendMessage(win_array
[count
], WM_SHOWWINDOW
, SW_HIDE
, SW_PARENTCLOSING
);
4506 ExFreePool( win_array
);
4511 * NtUserValidateHandleSecure
4519 NtUserValidateHandleSecure(
4527 PUSER_HANDLE_ENTRY entry
;
4528 if (!(entry
= handle_to_entry(gHandleTable
, handle
)))
4530 EngSetLastError(ERROR_INVALID_HANDLE
);
4533 uType
= entry
->type
;
4540 if ((Window
= UserGetWindowObject((HWND
) handle
))) return TRUE
;
4546 if ((Menu
= UserGetMenuObject((HMENU
) handle
))) return TRUE
;
4551 PACCELERATOR_TABLE Accel
;
4552 if ((Accel
= UserGetAccelObject((HACCEL
) handle
))) return TRUE
;
4557 PCURICON_OBJECT Cursor
;
4558 if ((Cursor
= UserGetCurIconObject((HCURSOR
) handle
))) return TRUE
;
4564 if ((Hook
= IntGetHookObject((HHOOK
) handle
))) return TRUE
;
4570 if ((Monitor
= UserGetMonitorObject((HMONITOR
) handle
))) return TRUE
;
4576 return UserGetCallProcInfo( handle
, &Proc
);
4579 EngSetLastError(ERROR_INVALID_HANDLE
);
4583 { /* Is handle entry restricted? */