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 ******************************************************************/
19 /* dialog resources appear to pass this in 16 bits, handle them properly */
20 #define CW_USEDEFAULT16 (0x8000)
22 #define POINT_IN_RECT(p, r) (((r.bottom >= p.y) && (r.top <= p.y))&&((r.left <= p.x )&&( r.right >= p.x )))
24 /* PRIVATE FUNCTIONS **********************************************************/
29 * Initialize windowing implementation.
35 return STATUS_SUCCESS
;
41 * Cleanup windowing implementation.
45 CleanupWindowImpl(VOID
)
47 return STATUS_SUCCESS
;
50 /* HELPER FUNCTIONS ***********************************************************/
52 BOOL FASTCALL
UserUpdateUiState(PWND Wnd
, WPARAM wParam
)
54 WORD Action
= LOWORD(wParam
);
55 WORD Flags
= HIWORD(wParam
);
57 if (Flags
& ~(UISF_HIDEFOCUS
| UISF_HIDEACCEL
| UISF_ACTIVE
))
59 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
66 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
70 if (Flags
& UISF_HIDEFOCUS
)
71 Wnd
->HideFocus
= TRUE
;
72 if (Flags
& UISF_HIDEACCEL
)
73 Wnd
->HideAccel
= TRUE
;
77 if (Flags
& UISF_HIDEFOCUS
)
78 Wnd
->HideFocus
= FALSE
;
79 if (Flags
& UISF_HIDEACCEL
)
80 Wnd
->HideAccel
= FALSE
;
87 PWINDOW_OBJECT FASTCALL
IntGetWindowObject(HWND hWnd
)
89 PWINDOW_OBJECT Window
;
91 if (!hWnd
) return NULL
;
93 Window
= UserGetWindowObject(hWnd
);
96 ASSERT(Window
->head
.cLockObj
>= 0);
98 Window
->head
.cLockObj
++;
106 PWINDOW_OBJECT FASTCALL
UserGetWindowObject(HWND hWnd
)
109 PWINDOW_OBJECT Window
;
111 if (PsGetCurrentProcess() != PsInitialSystemProcess
)
113 ti
= GetW32ThreadInfo();
116 SetLastWin32Error(ERROR_ACCESS_DENIED
);
123 SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE
);
127 Window
= (PWINDOW_OBJECT
)UserGetObject(gHandleTable
, hWnd
, otWindow
);
128 if (!Window
|| 0 != (Window
->state
& WINDOWSTATUS_DESTROYED
))
130 SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE
);
134 ASSERT(Window
->head
.cLockObj
>= 0);
145 * The function determines whether the specified window handle identifies
146 * an existing window.
150 * Handle to the window to test.
153 * If the window handle identifies an existing window, the return value
154 * is TRUE. If the window handle does not identify an existing window,
155 * the return value is FALSE.
159 IntIsWindow(HWND hWnd
)
161 PWINDOW_OBJECT Window
;
163 if (!(Window
= UserGetWindowObject(hWnd
)))
171 PWINDOW_OBJECT FASTCALL
172 IntGetParent(PWINDOW_OBJECT Wnd
)
174 if (Wnd
->Wnd
->style
& WS_POPUP
)
176 return Wnd
->spwndOwner
;
178 else if (Wnd
->Wnd
->style
& WS_CHILD
)
180 return Wnd
->spwndParent
;
190 * Compile a list of all child window handles from given window.
193 * This function is similar to Wine WIN_ListChildren. The caller
194 * must free the returned list with ExFreePool.
198 IntWinListChildren(PWINDOW_OBJECT Window
)
200 PWINDOW_OBJECT Child
;
202 UINT Index
, NumChildren
= 0;
204 if (!Window
) return NULL
;
206 for (Child
= Window
->spwndChild
; Child
; Child
= Child
->spwndNext
)
209 List
= ExAllocatePoolWithTag(PagedPool
, (NumChildren
+ 1) * sizeof(HWND
), TAG_WINLIST
);
212 DPRINT1("Failed to allocate memory for children array\n");
213 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
216 for (Child
= Window
->spwndChild
, Index
= 0;
218 Child
= Child
->spwndNext
, ++Index
)
219 List
[Index
] = Child
->hSelf
;
225 /***********************************************************************
228 static void IntSendDestroyMsg(HWND hWnd
)
231 PWINDOW_OBJECT Window
;
236 if (GetGUIThreadInfo(GetCurrentThreadId(), &info
))
238 if (hWnd
== info
.hwndCaret
)
245 Window
= UserGetWindowObject(hWnd
);
248 // USER_REFERENCE_ENTRY Ref;
249 // UserRefObjectCo(Window, &Ref);
251 if (!Window
->spwndOwner
&& !IntGetParent(Window
))
253 co_IntShellHookNotify(HSHELL_WINDOWDESTROYED
, (LPARAM
) hWnd
);
256 // UserDerefObjectCo(Window);
259 /* The window could already be destroyed here */
262 * Send the WM_DESTROY to the window.
265 co_IntSendMessage(hWnd
, WM_DESTROY
, 0, 0);
268 * This WM_DESTROY message can trigger re-entrant calls to DestroyWindow
269 * make sure that the window still exists when we come back.
278 if (!(pWndArray
= WIN_ListChildren( hwnd
)))
281 /* start from the end (FIXME: is this needed?) */
282 for (i
= 0; pWndArray
[i
]; i
++)
287 if (IsWindow( pWndArray
[i
] ))
288 WIN_SendDestroyMsg( pWndArray
[i
] );
290 HeapFree(GetProcessHeap(), 0, pWndArray
);
294 DPRINT("destroyed itself while in WM_DESTROY!\n");
300 UserFreeWindowInfo(PTHREADINFO ti
, PWINDOW_OBJECT WindowObject
)
302 PCLIENTINFO ClientInfo
= GetWin32ClientInfo();
303 PWND Wnd
= WindowObject
->Wnd
;
307 if (ClientInfo
->CallbackWnd
.pvWnd
== DesktopHeapAddressToUser(WindowObject
->Wnd
))
309 ClientInfo
->CallbackWnd
.hWnd
= NULL
;
310 ClientInfo
->CallbackWnd
.pvWnd
= NULL
;
313 if (Wnd
->strName
.Buffer
!= NULL
)
315 Wnd
->strName
.Length
= 0;
316 Wnd
->strName
.MaximumLength
= 0;
317 DesktopHeapFree(Wnd
->head
.rpdesk
,
318 Wnd
->strName
.Buffer
);
319 Wnd
->strName
.Buffer
= NULL
;
322 DesktopHeapFree(Wnd
->head
.rpdesk
, Wnd
);
323 WindowObject
->Wnd
= NULL
;
326 /***********************************************************************
329 * Destroy storage associated to a window. "Internals" p.358
331 * This is the "functional" DestroyWindows function ei. all stuff
332 * done in CreateWindow is undone here and not in DestroyWindow:-P
335 static LRESULT
co_UserFreeWindow(PWINDOW_OBJECT Window
,
336 PPROCESSINFO ProcessData
,
337 PTHREADINFO ThreadData
,
338 BOOLEAN SendMessages
)
342 PWINDOW_OBJECT Child
;
344 BOOLEAN BelongsToThreadData
;
351 if(Window
->state
& WINDOWSTATUS_DESTROYING
)
353 DPRINT("Tried to call IntDestroyWindow() twice\n");
356 Window
->state
|= WINDOWSTATUS_DESTROYING
;
357 Wnd
->style
&= ~WS_VISIBLE
;
359 IntNotifyWinEvent(EVENT_OBJECT_DESTROY
, Wnd
, OBJID_WINDOW
, 0);
361 /* remove the window already at this point from the thread window list so we
362 don't get into trouble when destroying the thread windows while we're still
363 in IntDestroyWindow() */
364 RemoveEntryList(&Window
->ThreadListEntry
);
366 BelongsToThreadData
= IntWndBelongsToThread(Window
, ThreadData
);
368 IntDeRegisterShellHookWindow(Window
->hSelf
);
372 /* Send destroy messages */
373 IntSendDestroyMsg(Window
->hSelf
);
376 /* free child windows */
377 Children
= IntWinListChildren(Window
);
380 for (ChildHandle
= Children
; *ChildHandle
; ++ChildHandle
)
382 if ((Child
= IntGetWindowObject(*ChildHandle
)))
384 if(!IntWndBelongsToThread(Child
, ThreadData
))
386 /* send WM_DESTROY messages to windows not belonging to the same thread */
387 IntSendDestroyMsg(Child
->hSelf
);
390 co_UserFreeWindow(Child
, ProcessData
, ThreadData
, SendMessages
);
392 UserDereferenceObject(Child
);
395 ExFreePool(Children
);
401 * Clear the update region to make sure no WM_PAINT messages will be
402 * generated for this window while processing the WM_NCDESTROY.
404 co_UserRedrawWindow(Window
, NULL
, 0,
405 RDW_VALIDATE
| RDW_NOFRAME
| RDW_NOERASE
|
406 RDW_NOINTERNALPAINT
| RDW_NOCHILDREN
);
407 if(BelongsToThreadData
)
408 co_IntSendMessage(Window
->hSelf
, WM_NCDESTROY
, 0, 0);
410 DestroyTimersForWindow(ThreadData
, Window
);
411 HOOK_DestroyThreadHooks(ThreadData
->pEThread
); // This is needed here too!
413 /* flush the message queue */
414 MsqRemoveWindowMessagesFromQueue(Window
);
416 /* from now on no messages can be sent to this window anymore */
417 Window
->state
|= WINDOWSTATUS_DESTROYED
;
418 Wnd
->state
|= WNDS_DESTROYED
;
419 Wnd
->fnid
|= FNID_FREED
;
421 /* don't remove the WINDOWSTATUS_DESTROYING bit */
423 /* reset shell window handles */
424 if(ThreadData
->rpdesk
)
426 if (Window
->hSelf
== ThreadData
->rpdesk
->rpwinstaParent
->ShellWindow
)
427 ThreadData
->rpdesk
->rpwinstaParent
->ShellWindow
= NULL
;
429 if (Window
->hSelf
== ThreadData
->rpdesk
->rpwinstaParent
->ShellListView
)
430 ThreadData
->rpdesk
->rpwinstaParent
->ShellListView
= NULL
;
433 /* Unregister hot keys */
434 UnregisterWindowHotKeys (Window
);
436 /* FIXME: do we need to fake QS_MOUSEMOVE wakebit? */
440 WinPosCheckInternalPos(Window
->hSelf
);
441 if (Window
->hSelf
== GetCapture())
446 /* free resources associated with the window */
447 TIMER_RemoveWindowTimers(Window
->hSelf
);
450 if (!(Wnd
->style
& WS_CHILD
) && Wnd
->IDMenu
451 && (Menu
= UserGetMenuObject((HMENU
)Wnd
->IDMenu
)))
453 IntDestroyMenuObject(Menu
, TRUE
, TRUE
);
457 if(Window
->SystemMenu
458 && (Menu
= UserGetMenuObject(Window
->SystemMenu
)))
460 IntDestroyMenuObject(Menu
, TRUE
, TRUE
);
461 Window
->SystemMenu
= (HMENU
)0;
464 DceFreeWindowDCE(Window
); /* Always do this to catch orphaned DCs */
467 WINPROC_FreeProc(Window
->winproc
, WIN_PROC_WINDOW
);
468 CLASS_RemoveWindow(Window
->Class
);
471 IntUnlinkWindow(Window
);
473 UserReferenceObject(Window
);
474 UserDeleteObject(Window
->hSelf
, otWindow
);
476 IntDestroyScrollBars(Window
);
478 /* dereference the class */
479 IntDereferenceClass(Wnd
->pcls
,
480 Window
->pti
->pDeskInfo
,
486 GreDeleteObject(Window
->hrgnClip
);
489 ASSERT(Window
->Wnd
!= NULL
);
490 UserFreeWindowInfo(Window
->pti
, Window
);
492 UserDereferenceObject(Window
);
494 IntClipboardFreeWindow(Window
);
500 IntGetWindowBorderMeasures(PWINDOW_OBJECT Window
, UINT
*cx
, UINT
*cy
)
502 PWND Wnd
= Window
->Wnd
;
503 if(HAS_DLGFRAME(Wnd
->style
, Wnd
->ExStyle
) && !(Wnd
->style
& WS_MINIMIZE
))
505 *cx
= UserGetSystemMetrics(SM_CXDLGFRAME
);
506 *cy
= UserGetSystemMetrics(SM_CYDLGFRAME
);
510 if(HAS_THICKFRAME(Wnd
->style
, Wnd
->ExStyle
)&& !(Wnd
->style
& WS_MINIMIZE
))
512 *cx
= UserGetSystemMetrics(SM_CXFRAME
);
513 *cy
= UserGetSystemMetrics(SM_CYFRAME
);
515 else if(HAS_THINFRAME(Wnd
->style
, Wnd
->ExStyle
))
517 *cx
= UserGetSystemMetrics(SM_CXBORDER
);
518 *cy
= UserGetSystemMetrics(SM_CYBORDER
);
528 // Same as User32:IntGetWndProc.
531 IntGetWindowProc(PWND pWnd
,
536 WNDPROC gcpd
, Ret
= 0;
538 ASSERT(UserIsEnteredExclusive() == TRUE
);
542 if (pWnd
->state
& WNDS_SERVERSIDEWINDOWPROC
)
544 for ( i
= FNID_FIRST
; i
<= FNID_SWITCH
; i
++)
546 if (GETPFNSERVER(i
) == pWnd
->lpfnWndProc
)
549 Ret
= GETPFNCLIENTA(i
);
551 Ret
= GETPFNCLIENTW(i
);
557 if (Class
->fnid
== FNID_EDIT
)
558 Ret
= pWnd
->lpfnWndProc
;
561 Ret
= pWnd
->lpfnWndProc
;
563 if (Class
->fnid
<= FNID_GHOST
&& Class
->fnid
>= FNID_BUTTON
)
567 if (GETPFNCLIENTW(Class
->fnid
) == pWnd
->lpfnWndProc
)
568 Ret
= GETPFNCLIENTA(Class
->fnid
);
572 if (GETPFNCLIENTA(Class
->fnid
) == pWnd
->lpfnWndProc
)
573 Ret
= GETPFNCLIENTW(Class
->fnid
);
576 if ( Ret
!= pWnd
->lpfnWndProc
)
579 if ( Ansi
== !!(pWnd
->state
& WNDS_ANSIWINDOWPROC
) )
582 gcpd
= (WNDPROC
)UserGetCPD(
584 (Ansi
? UserGetCPDA2U
: UserGetCPDU2A
)|UserGetCPDWindow
,
587 return (gcpd
? gcpd
: Ret
);
591 IntSetWindowProc(PWND pWnd
,
596 PCALLPROCDATA CallProc
;
598 WNDPROC Ret
, chWndProc
= NULL
;
600 // Retrieve previous window proc.
601 Ret
= IntGetWindowProc(pWnd
, Ansi
);
605 if (IsCallProcHandle(NewWndProc
))
607 CallProc
= UserGetObject(gHandleTable
, NewWndProc
, otCallProc
);
609 { // Reset new WndProc.
610 NewWndProc
= CallProc
->pfnClientPrevious
;
611 // Reset Ansi from CallProc handle. This is expected with wine "deftest".
612 Ansi
= !!(CallProc
->wType
& UserGetCPDU2A
);
615 // Switch from Client Side call to Server Side call if match. Ref: "deftest".
616 for ( i
= FNID_FIRST
; i
<= FNID_SWITCH
; i
++)
618 if (GETPFNCLIENTW(i
) == NewWndProc
)
620 chWndProc
= GETPFNSERVER(i
);
623 if (GETPFNCLIENTA(i
) == NewWndProc
)
625 chWndProc
= GETPFNSERVER(i
);
629 // If match, set/reset to Server Side and clear ansi.
632 pWnd
->lpfnWndProc
= chWndProc
;
633 pWnd
->Unicode
= TRUE
;
634 pWnd
->state
&= ~WNDS_ANSIWINDOWPROC
;
635 pWnd
->state
|= WNDS_SERVERSIDEWINDOWPROC
;
639 pWnd
->Unicode
= !Ansi
;
640 // Handle the state change in here.
642 pWnd
->state
|= WNDS_ANSIWINDOWPROC
;
644 pWnd
->state
&= ~WNDS_ANSIWINDOWPROC
;
646 if (pWnd
->state
& WNDS_SERVERSIDEWINDOWPROC
)
647 pWnd
->state
&= ~WNDS_SERVERSIDEWINDOWPROC
;
649 if (!NewWndProc
) NewWndProc
= pWnd
->lpfnWndProc
;
651 if (Class
->fnid
<= FNID_GHOST
&& Class
->fnid
>= FNID_BUTTON
)
655 if (GETPFNCLIENTW(Class
->fnid
) == NewWndProc
)
656 chWndProc
= GETPFNCLIENTA(Class
->fnid
);
660 if (GETPFNCLIENTA(Class
->fnid
) == NewWndProc
)
661 chWndProc
= GETPFNCLIENTW(Class
->fnid
);
664 // Now set the new window proc.
665 pWnd
->lpfnWndProc
= (chWndProc
? chWndProc
: NewWndProc
);
670 // Move this to user space!
672 IntGetWindowInfo(PWINDOW_OBJECT Window
, PWINDOWINFO pwi
)
674 PWND Wnd
= Window
->Wnd
;
676 pwi
->cbSize
= sizeof(WINDOWINFO
);
677 pwi
->rcWindow
= Window
->Wnd
->rcWindow
;
678 pwi
->rcClient
= Window
->Wnd
->rcClient
;
679 pwi
->dwStyle
= Wnd
->style
;
680 pwi
->dwExStyle
= Wnd
->ExStyle
;
681 pwi
->dwWindowStatus
= (UserGetForegroundWindow() == Window
->hSelf
); /* WS_ACTIVECAPTION */
682 IntGetWindowBorderMeasures(Window
, &pwi
->cxWindowBorders
, &pwi
->cyWindowBorders
);
683 pwi
->atomWindowType
= (Wnd
->pcls
? Wnd
->pcls
->atomClassName
: 0);
684 pwi
->wCreatorVersion
= 0x400; /* FIXME - return a real version number */
690 PWINDOW_OBJECT Window
,
694 PMENU_OBJECT OldMenu
, NewMenu
= NULL
;
695 PWND Wnd
= Window
->Wnd
;
697 if ((Wnd
->style
& (WS_CHILD
| WS_POPUP
)) == WS_CHILD
)
699 SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE
);
703 *Changed
= (Wnd
->IDMenu
!= (UINT
) Menu
);
711 OldMenu
= IntGetMenuObject((HMENU
) Wnd
->IDMenu
);
712 ASSERT(NULL
== OldMenu
|| OldMenu
->MenuInfo
.Wnd
== Window
->hSelf
);
721 NewMenu
= IntGetMenuObject(Menu
);
726 IntReleaseMenuObject(OldMenu
);
728 SetLastWin32Error(ERROR_INVALID_MENU_HANDLE
);
731 if (NULL
!= NewMenu
->MenuInfo
.Wnd
)
733 /* Can't use the same menu for two windows */
736 IntReleaseMenuObject(OldMenu
);
738 SetLastWin32Error(ERROR_INVALID_MENU_HANDLE
);
744 Wnd
->IDMenu
= (UINT
) Menu
;
747 NewMenu
->MenuInfo
.Wnd
= Window
->hSelf
;
748 IntReleaseMenuObject(NewMenu
);
752 OldMenu
->MenuInfo
.Wnd
= NULL
;
753 IntReleaseMenuObject(OldMenu
);
760 /* INTERNAL ******************************************************************/
764 co_DestroyThreadWindows(struct _ETHREAD
*Thread
)
769 USER_REFERENCE_ENTRY Ref
;
770 WThread
= (PTHREADINFO
)Thread
->Tcb
.Win32Thread
;
772 while (!IsListEmpty(&WThread
->WindowListHead
))
774 Current
= WThread
->WindowListHead
.Flink
;
775 Wnd
= CONTAINING_RECORD(Current
, WINDOW_OBJECT
, ThreadListEntry
);
777 DPRINT("thread cleanup: while destroy wnds, wnd=0x%x\n",Wnd
);
779 /* window removes itself from the list */
782 fixme: it is critical that the window removes itself! if now, we will loop
786 //ASSERT(co_UserDestroyWindow(Wnd));
788 UserRefObjectCo(Wnd
, &Ref
);//faxme: temp hack??
789 if (!co_UserDestroyWindow(Wnd
))
791 DPRINT1("Unable to destroy window 0x%x at thread cleanup... This is _VERY_ bad!\n", Wnd
);
793 UserDerefObjectCo(Wnd
);//faxme: temp hack??
801 * Returns client window rectangle relative to the upper-left corner of client area.
803 * \note Does not check the validity of the parameters
806 IntGetClientRect(PWINDOW_OBJECT Window
, RECTL
*Rect
)
811 Rect
->left
= Rect
->top
= 0;
812 Rect
->right
= Window
->Wnd
->rcClient
.right
- Window
->Wnd
->rcClient
.left
;
813 Rect
->bottom
= Window
->Wnd
->rcClient
.bottom
- Window
->Wnd
->rcClient
.top
;
819 IntGetFocusWindow(VOID
)
821 PUSER_MESSAGE_QUEUE Queue
;
822 PDESKTOP pdo
= IntGetActiveDesktop();
827 Queue
= (PUSER_MESSAGE_QUEUE
)pdo
->ActiveMessageQueue
;
832 return(Queue
->FocusWindow
);
836 PMENU_OBJECT FASTCALL
837 IntGetSystemMenu(PWINDOW_OBJECT Window
, BOOL bRevert
, BOOL RetMenu
)
839 PMENU_OBJECT Menu
, NewMenu
= NULL
, SysMenu
= NULL
, ret
= NULL
;
840 PTHREADINFO W32Thread
;
841 HMENU hNewMenu
, hSysMenu
;
842 ROSMENUITEMINFO ItemInfo
;
846 W32Thread
= PsGetCurrentThreadWin32Thread();
848 if(!W32Thread
->rpdesk
)
851 if(Window
->SystemMenu
)
853 Menu
= UserGetMenuObject(Window
->SystemMenu
);
856 IntDestroyMenuObject(Menu
, TRUE
, TRUE
);
857 Window
->SystemMenu
= (HMENU
)0;
861 if(W32Thread
->rpdesk
->rpwinstaParent
->SystemMenuTemplate
)
863 /* clone system menu */
864 Menu
= UserGetMenuObject(W32Thread
->rpdesk
->rpwinstaParent
->SystemMenuTemplate
);
868 NewMenu
= IntCloneMenu(Menu
);
871 Window
->SystemMenu
= NewMenu
->MenuInfo
.Self
;
872 NewMenu
->MenuInfo
.Flags
|= MF_SYSMENU
;
873 NewMenu
->MenuInfo
.Wnd
= Window
->hSelf
;
875 //IntReleaseMenuObject(NewMenu);
880 hSysMenu
= UserCreateMenu(FALSE
);
881 if (NULL
== hSysMenu
)
885 SysMenu
= IntGetMenuObject(hSysMenu
);
888 UserDestroyMenu(hSysMenu
);
891 SysMenu
->MenuInfo
.Flags
|= MF_SYSMENU
;
892 SysMenu
->MenuInfo
.Wnd
= Window
->hSelf
;
893 hNewMenu
= co_IntLoadSysMenuTemplate();
896 IntReleaseMenuObject(SysMenu
);
897 UserDestroyMenu(hSysMenu
);
900 Menu
= IntGetMenuObject(hNewMenu
);
903 IntReleaseMenuObject(SysMenu
);
904 UserDestroyMenu(hSysMenu
);
908 NewMenu
= IntCloneMenu(Menu
);
911 NewMenu
->MenuInfo
.Flags
|= MF_SYSMENU
| MF_POPUP
;
912 IntReleaseMenuObject(NewMenu
);
913 UserSetMenuDefaultItem(NewMenu
, SC_CLOSE
, FALSE
);
915 ItemInfo
.cbSize
= sizeof(MENUITEMINFOW
);
916 ItemInfo
.fMask
= MIIM_FTYPE
| MIIM_STRING
| MIIM_STATE
| MIIM_SUBMENU
;
917 ItemInfo
.fType
= MF_POPUP
;
918 ItemInfo
.fState
= MFS_ENABLED
;
919 ItemInfo
.dwTypeData
= NULL
;
921 ItemInfo
.hSubMenu
= NewMenu
->MenuInfo
.Self
;
922 IntInsertMenuItem(SysMenu
, (UINT
) -1, TRUE
, &ItemInfo
);
924 Window
->SystemMenu
= SysMenu
->MenuInfo
.Self
;
928 IntDestroyMenuObject(Menu
, FALSE
, TRUE
);
937 if(Window
->SystemMenu
)
938 return IntGetMenuObject((HMENU
)Window
->SystemMenu
);
946 IntIsChildWindow(PWINDOW_OBJECT Parent
, PWINDOW_OBJECT BaseWindow
)
948 PWINDOW_OBJECT Window
;
955 if (Window
== Parent
)
959 if(!(Wnd
->style
& WS_CHILD
))
964 Window
= Window
->spwndParent
;
971 IntIsWindowVisible(PWINDOW_OBJECT BaseWindow
)
973 PWINDOW_OBJECT Window
;
980 if(!(Wnd
->style
& WS_CHILD
))
984 if(!(Wnd
->style
& WS_VISIBLE
))
989 Window
= Window
->spwndParent
;
992 if(Window
&& Wnd
->style
& WS_VISIBLE
)
1004 PWND WndPrevSibling
) /* set to NULL if top sibling */
1006 Wnd
->spwndParent
= WndParent
;
1007 if ((Wnd
->spwndPrev
= WndPrevSibling
))
1009 /* link after WndPrevSibling */
1010 if ((Wnd
->spwndNext
= WndPrevSibling
->spwndNext
))
1011 Wnd
->spwndNext
->spwndPrev
= Wnd
;
1013 Wnd
->spwndPrev
->spwndNext
= Wnd
;
1018 if ((Wnd
->spwndNext
= WndParent
->spwndChild
))
1019 Wnd
->spwndNext
->spwndPrev
= Wnd
;
1021 WndParent
->spwndChild
= Wnd
;
1026 /* link the window into siblings and parent. children are kept in place. */
1030 PWINDOW_OBJECT WndParent
,
1031 PWINDOW_OBJECT WndPrevSibling
/* set to NULL if top sibling */
1034 PWINDOW_OBJECT Parent
;
1036 IntLinkWnd(Wnd
->Wnd
,
1038 WndPrevSibling
? WndPrevSibling
->Wnd
: NULL
);
1040 Wnd
->spwndParent
= WndParent
;
1041 if ((Wnd
->spwndPrev
= WndPrevSibling
))
1043 /* link after WndPrevSibling */
1044 if ((Wnd
->spwndNext
= WndPrevSibling
->spwndNext
))
1045 Wnd
->spwndNext
->spwndPrev
= Wnd
;
1046 Wnd
->spwndPrev
->spwndNext
= Wnd
;
1051 Parent
= Wnd
->spwndParent
;
1052 if ((Wnd
->spwndNext
= WndParent
->spwndChild
))
1053 Wnd
->spwndNext
->spwndPrev
= Wnd
;
1056 Parent
->spwndChild
= Wnd
;
1061 Parent
->spwndChild
= Wnd
;
1068 IntSetOwner(HWND hWnd
, HWND hWndNewOwner
)
1070 PWINDOW_OBJECT Wnd
, WndOldOwner
, WndNewOwner
;
1073 Wnd
= IntGetWindowObject(hWnd
);
1077 WndOldOwner
= Wnd
->spwndOwner
;
1079 ret
= WndOldOwner
? WndOldOwner
->hSelf
: 0;
1081 if((WndNewOwner
= UserGetWindowObject(hWndNewOwner
)))
1083 Wnd
->spwndOwner
= WndNewOwner
;
1084 Wnd
->Wnd
->spwndOwner
= WndNewOwner
->Wnd
;
1088 Wnd
->spwndOwner
= NULL
;
1089 Wnd
->Wnd
->spwndOwner
= NULL
;
1092 UserDereferenceObject(Wnd
);
1096 PWINDOW_OBJECT FASTCALL
1097 co_IntSetParent(PWINDOW_OBJECT Wnd
, PWINDOW_OBJECT WndNewParent
)
1099 PWINDOW_OBJECT WndOldParent
, Sibling
, InsertAfter
;
1100 // HWND hWnd, hWndNewParent;
1104 ASSERT(WndNewParent
);
1105 ASSERT_REFS_CO(Wnd
);
1106 ASSERT_REFS_CO(WndNewParent
);
1108 // hWnd = Wnd->hSelf;
1109 // hWndNewParent = WndNewParent->hSelf;
1111 /* Some applications try to set a child as a parent */
1112 if (IntIsChildWindow(Wnd
, WndNewParent
))
1114 SetLastWin32Error( ERROR_INVALID_PARAMETER
);
1119 * Windows hides the window first, then shows it again
1120 * including the WM_SHOWWINDOW messages and all
1122 WasVisible
= co_WinPosShowWindow(Wnd
, SW_HIDE
);
1124 // /* Validate that window and parent still exist */
1125 // if (!IntIsWindow(hWnd) || !IntIsWindow(hWndNewParent))
1128 /* Window must belong to current process */
1129 if (Wnd
->pti
->pEThread
->ThreadsProcess
!= PsGetCurrentProcess())
1132 WndOldParent
= Wnd
->spwndParent
;
1134 if (WndOldParent
) UserReferenceObject(WndOldParent
); /* caller must deref */
1136 if (WndNewParent
!= WndOldParent
)
1138 IntUnlinkWindow(Wnd
);
1140 if (0 == (Wnd
->Wnd
->ExStyle
& WS_EX_TOPMOST
))
1142 /* Not a TOPMOST window, put after TOPMOSTs of new parent */
1143 Sibling
= WndNewParent
->spwndChild
;
1144 while (NULL
!= Sibling
&& 0 != (Sibling
->Wnd
->ExStyle
& WS_EX_TOPMOST
))
1146 InsertAfter
= Sibling
;
1147 Sibling
= Sibling
->spwndNext
;
1150 if (NULL
== InsertAfter
)
1152 IntLinkWindow(Wnd
, WndNewParent
, InsertAfter
/*prev sibling*/);
1156 // UserReferenceObject(InsertAfter);
1157 IntLinkWindow(Wnd
, WndNewParent
, InsertAfter
/*prev sibling*/);
1158 // UserDereferenceObject(InsertAfter);
1163 * SetParent additionally needs to make hwnd the top window
1164 * in the z-order and send the expected WM_WINDOWPOSCHANGING and
1165 * WM_WINDOWPOSCHANGED notification messages.
1167 co_WinPosSetWindowPos(Wnd
, (0 == (Wnd
->Wnd
->ExStyle
& WS_EX_TOPMOST
) ? HWND_TOP
: HWND_TOPMOST
),
1168 0, 0, 0, 0, SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOSIZE
1169 | (WasVisible
? SWP_SHOWWINDOW
: 0));
1172 * FIXME: a WM_MOVE is also generated (in the DefWindowProc handler
1173 * for WM_WINDOWPOSCHANGED) in Windows, should probably remove SWP_NOMOVE
1177 * Validate that the old parent still exist, since it migth have been
1178 * destroyed during the last callbacks to user-mode
1182 // if(!IntIsWindow(WndOldParent->hSelf))
1184 // UserDereferenceObject(WndOldParent);
1188 /* don't dereference the window object here, it must be done by the caller
1189 of IntSetParent() */
1190 // return WndOldParent;
1193 return WndOldParent
;//NULL;
1197 IntSetSystemMenu(PWINDOW_OBJECT Window
, PMENU_OBJECT Menu
)
1199 PMENU_OBJECT OldMenu
;
1200 if(Window
->SystemMenu
)
1202 OldMenu
= IntGetMenuObject(Window
->SystemMenu
);
1205 OldMenu
->MenuInfo
.Flags
&= ~ MF_SYSMENU
;
1206 IntReleaseMenuObject(OldMenu
);
1212 /* FIXME check window style, propably return FALSE ? */
1213 Window
->SystemMenu
= Menu
->MenuInfo
.Self
;
1214 Menu
->MenuInfo
.Flags
|= MF_SYSMENU
;
1217 Window
->SystemMenu
= (HMENU
)0;
1222 /* unlink the window from siblings and parent. children are kept in place. */
1224 IntUnlinkWnd(PWND Wnd
)
1227 Wnd
->spwndNext
->spwndPrev
= Wnd
->spwndPrev
;
1230 Wnd
->spwndPrev
->spwndNext
= Wnd
->spwndNext
;
1232 if (Wnd
->spwndParent
&& Wnd
->spwndParent
->spwndChild
== Wnd
)
1233 Wnd
->spwndParent
->spwndChild
= Wnd
->spwndNext
;
1235 Wnd
->spwndPrev
= Wnd
->spwndNext
= Wnd
->spwndParent
= NULL
;
1239 /* unlink the window from siblings and parent. children are kept in place. */
1241 IntUnlinkWindow(PWINDOW_OBJECT Wnd
)
1243 PWINDOW_OBJECT WndParent
= Wnd
->spwndParent
;
1245 IntUnlinkWnd(Wnd
->Wnd
);
1248 Wnd
->spwndNext
->spwndPrev
= Wnd
->spwndPrev
;
1251 Wnd
->spwndPrev
->spwndNext
= Wnd
->spwndNext
;
1252 else if (WndParent
&& WndParent
->spwndChild
== Wnd
)
1253 WndParent
->spwndChild
= Wnd
->spwndNext
;
1255 Wnd
->spwndPrev
= Wnd
->spwndNext
= Wnd
->spwndParent
= NULL
;
1259 IntIsWindowInDestroy(PWINDOW_OBJECT Window
)
1261 return ((Window
->state
& WINDOWSTATUS_DESTROYING
) == WINDOWSTATUS_DESTROYING
);
1267 IntGetWindowPlacement(PWINDOW_OBJECT Window
, WINDOWPLACEMENT
*lpwndpl
)
1273 if (!Wnd
) return FALSE
;
1275 if(lpwndpl
->length
!= sizeof(WINDOWPLACEMENT
))
1281 if (0 == (Wnd
->style
& WS_VISIBLE
))
1283 lpwndpl
->showCmd
= SW_HIDE
;
1285 else if (0 != (Window
->state
& WINDOWOBJECT_RESTOREMAX
) ||
1286 0 != (Wnd
->style
& WS_MAXIMIZE
))
1288 lpwndpl
->showCmd
= SW_MAXIMIZE
;
1290 else if (0 != (Wnd
->style
& WS_MINIMIZE
))
1292 lpwndpl
->showCmd
= SW_MINIMIZE
;
1294 else if (0 != (Wnd
->style
& WS_VISIBLE
))
1296 lpwndpl
->showCmd
= SW_SHOWNORMAL
;
1299 Size
.x
= Wnd
->rcWindow
.left
;
1300 Size
.y
= Wnd
->rcWindow
.top
;
1301 WinPosInitInternalPos(Window
, &Size
,
1304 lpwndpl
->rcNormalPosition
= Wnd
->InternalPos
.NormalRect
;
1305 lpwndpl
->ptMinPosition
= Wnd
->InternalPos
.IconPos
;
1306 lpwndpl
->ptMaxPosition
= Wnd
->InternalPos
.MaxPos
;
1312 /* FUNCTIONS *****************************************************************/
1318 NtUserAlterWindowStyle(DWORD Unknown0
,
1328 * As best as I can figure, this function is used by EnumWindows,
1329 * EnumChildWindows, EnumDesktopWindows, & EnumThreadWindows.
1331 * It's supposed to build a list of HWNDs to return to the caller.
1332 * We can figure out what kind of list by what parameters are
1340 NtUserBuildHwndList(
1353 return ERROR_INVALID_PARAMETER
;
1355 if (hwndParent
|| !dwThreadId
)
1358 PWINDOW_OBJECT Parent
, Window
;
1362 if(hDesktop
== NULL
&& !(Desktop
= IntGetActiveDesktop()))
1364 return ERROR_INVALID_HANDLE
;
1369 Status
= IntValidateDesktopHandle(hDesktop
,
1373 if(!NT_SUCCESS(Status
))
1375 return ERROR_INVALID_HANDLE
;
1378 hwndParent
= Desktop
->DesktopWindow
;
1385 if((Parent
= UserGetWindowObject(hwndParent
)) &&
1386 (Window
= Parent
->spwndChild
))
1388 BOOL bGoDown
= TRUE
;
1390 Status
= STATUS_SUCCESS
;
1395 if(dwCount
++ < *pBufSize
&& pWnd
)
1399 ProbeForWrite(pWnd
, sizeof(HWND
), 1);
1400 *pWnd
= Window
->hSelf
;
1403 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1405 Status
= _SEH2_GetExceptionCode();
1408 if(!NT_SUCCESS(Status
))
1410 SetLastNtError(Status
);
1414 if (Window
->spwndChild
&& bChildren
)
1416 Window
= Window
->spwndChild
;
1421 if (Window
->spwndNext
)
1423 Window
= Window
->spwndNext
;
1427 Window
= Window
->spwndParent
;
1428 if (Window
== Parent
)
1437 ObDereferenceObject(Desktop
);
1443 PTHREADINFO W32Thread
;
1444 PLIST_ENTRY Current
;
1445 PWINDOW_OBJECT Window
;
1447 Status
= PsLookupThreadByThreadId((HANDLE
)dwThreadId
, &Thread
);
1448 if(!NT_SUCCESS(Status
))
1450 return ERROR_INVALID_PARAMETER
;
1452 if(!(W32Thread
= (PTHREADINFO
)Thread
->Tcb
.Win32Thread
))
1454 ObDereferenceObject(Thread
);
1455 DPRINT("Thread is not a GUI Thread!\n");
1456 return ERROR_INVALID_PARAMETER
;
1459 Current
= W32Thread
->WindowListHead
.Flink
;
1460 while(Current
!= &(W32Thread
->WindowListHead
))
1462 Window
= CONTAINING_RECORD(Current
, WINDOW_OBJECT
, ThreadListEntry
);
1465 if(bChildren
|| Window
->spwndOwner
!= NULL
)
1467 if(dwCount
< *pBufSize
&& pWnd
)
1469 Status
= MmCopyToCaller(pWnd
++, &Window
->hSelf
, sizeof(HWND
));
1470 if(!NT_SUCCESS(Status
))
1472 SetLastNtError(Status
);
1478 Current
= Current
->Flink
;
1481 ObDereferenceObject(Thread
);
1484 *pBufSize
= dwCount
;
1485 return STATUS_SUCCESS
;
1493 NtUserChildWindowFromPointEx(HWND hwndParent
,
1498 PWINDOW_OBJECT Parent
;
1503 if(!(Parent
= UserGetWindowObject(hwndParent
)))
1511 if(Parent
->hSelf
!= IntGetDesktopWindow())
1513 Pt
.x
+= Parent
->Wnd
->rcClient
.left
;
1514 Pt
.y
+= Parent
->Wnd
->rcClient
.top
;
1517 if(!IntPtInWindow(Parent
, Pt
.x
, Pt
.y
))
1522 Ret
= Parent
->hSelf
;
1523 if((List
= IntWinListChildren(Parent
)))
1525 for(phWnd
= List
; *phWnd
; phWnd
++)
1527 PWINDOW_OBJECT Child
;
1529 if((Child
= UserGetWindowObject(*phWnd
)))
1531 ChildWnd
= Child
->Wnd
;
1532 if(!(ChildWnd
->style
& WS_VISIBLE
) && (uiFlags
& CWP_SKIPINVISIBLE
))
1536 if((ChildWnd
->style
& WS_DISABLED
) && (uiFlags
& CWP_SKIPDISABLED
))
1540 if((ChildWnd
->ExStyle
& WS_EX_TRANSPARENT
) && (uiFlags
& CWP_SKIPTRANSPARENT
))
1544 if(IntPtInWindow(Child
, Pt
.x
, Pt
.y
))
1558 IntFixWindowCoordinates(CREATESTRUCTW
* Cs
, PWINDOW_OBJECT ParentWindow
, DWORD
* dwShowMode
)
1560 #define IS_DEFAULT(x) ((x) == CW_USEDEFAULT || (x) == (SHORT)0x8000)
1562 /* default positioning for overlapped windows */
1563 if(!(Cs
->style
& (WS_POPUP
| WS_CHILD
)))
1566 PRTL_USER_PROCESS_PARAMETERS ProcessParams
;
1568 UserSystemParametersInfo(SPI_GETWORKAREA
, 0, &WorkArea
, 0);
1570 ProcessParams
= PsGetCurrentProcess()->Peb
->ProcessParameters
;
1572 if (IS_DEFAULT(Cs
->x
))
1574 if (!IS_DEFAULT(Cs
->y
)) *dwShowMode
= Cs
->y
;
1576 if(ProcessParams
->WindowFlags
& STARTF_USEPOSITION
)
1578 Cs
->x
= ProcessParams
->StartingX
;
1579 Cs
->y
= ProcessParams
->StartingY
;
1583 Cs
->x
= WorkArea
.left
;
1584 Cs
->y
= WorkArea
.top
;
1588 if (IS_DEFAULT(Cs
->cx
))
1590 if (ProcessParams
->WindowFlags
& STARTF_USEPOSITION
)
1592 Cs
->cx
= ProcessParams
->CountX
;
1593 Cs
->cy
= ProcessParams
->CountY
;
1597 Cs
->cx
= (WorkArea
.right
- WorkArea
.left
) * 3 / 4 - Cs
->x
;
1598 Cs
->cy
= (WorkArea
.bottom
- WorkArea
.top
) * 3 / 4 - Cs
->y
;
1601 /* neither x nor cx are default. Check the y values .
1602 * In the trace we see Outlook and Outlook Express using
1603 * cy set to CW_USEDEFAULT when opening the address book.
1605 else if (IS_DEFAULT(Cs
->cy
))
1607 DPRINT("Strange use of CW_USEDEFAULT in nHeight\n");
1608 Cs
->cy
= (WorkArea
.bottom
- WorkArea
.top
) * 3 / 4 - Cs
->y
;
1613 /* if CW_USEDEFAULT is set for non-overlapped windows, both values are set to zero */
1614 if(IS_DEFAULT(Cs
->x
))
1619 if(IS_DEFAULT(Cs
->cx
))
1629 /* Allocates and initializes a window*/
1630 PWINDOW_OBJECT FASTCALL
IntCreateWindow(CREATESTRUCTW
* Cs
,
1631 PLARGE_STRING WindowName
,
1633 PWINDOW_OBJECT ParentWindow
,
1634 PWINDOW_OBJECT OwnerWindow
)
1637 PWINDOW_OBJECT Window
;
1639 PTHREADINFO pti
= NULL
;
1640 PMENU_OBJECT SystemMenu
;
1642 BOOL bUnicodeWindow
;
1644 pti
= PsGetCurrentThreadWin32Thread();
1646 /* Automatically add WS_EX_WINDOWEDGE */
1647 if ((Cs
->dwExStyle
& WS_EX_DLGMODALFRAME
) ||
1648 ((!(Cs
->dwExStyle
& WS_EX_STATICEDGE
)) &&
1649 (Cs
->style
& (WS_DLGFRAME
| WS_THICKFRAME
))))
1650 Cs
->dwExStyle
|= WS_EX_WINDOWEDGE
;
1652 Cs
->dwExStyle
&= ~WS_EX_WINDOWEDGE
;
1654 /* Is it a unicode window? */
1655 bUnicodeWindow
=!(Cs
->dwExStyle
& WS_EX_SETANSICREATOR
);
1656 Cs
->dwExStyle
&= ~WS_EX_SETANSICREATOR
;
1658 /* Allocate the new window */
1659 Window
= (PWINDOW_OBJECT
) UserCreateObject( gHandleTable
,
1663 sizeof(WINDOW_OBJECT
));
1669 Wnd
= DesktopHeapAlloc(pti
->rpdesk
, sizeof(WND
) + Class
->cbwndExtra
);
1676 RtlZeroMemory(Wnd
, sizeof(WND
) + Class
->cbwndExtra
);
1678 DPRINT("Created object with handle %X\n", hWnd
);
1680 if (NULL
== pti
->rpdesk
->DesktopWindow
)
1682 /* If there is no desktop window yet, we must be creating it */
1683 pti
->rpdesk
->DesktopWindow
= hWnd
;
1684 pti
->rpdesk
->pDeskInfo
->spwnd
= Wnd
;
1688 * Fill out the structure describing it.
1692 Window
->hSelf
= hWnd
;
1693 Window
->spwndParent
= ParentWindow
;
1694 Window
->spwndOwner
= OwnerWindow
;
1697 Wnd
->head
.pti
= pti
;
1698 Wnd
->head
.rpdesk
= pti
->rpdesk
;
1700 Wnd
->hWndLastActive
= hWnd
;
1701 Wnd
->state2
|= WNDS2_WIN40COMPAT
;
1703 Wnd
->hModule
= Cs
->hInstance
;
1704 Wnd
->style
= Cs
->style
& ~WS_VISIBLE
;
1705 Wnd
->ExStyle
= Cs
->dwExStyle
;
1706 Wnd
->cbwndExtra
= Wnd
->pcls
->cbwndExtra
;
1707 Wnd
->spwndOwner
= OwnerWindow
? OwnerWindow
->Wnd
: NULL
;
1708 Wnd
->spwndParent
= ParentWindow
? ParentWindow
->Wnd
: NULL
;
1710 IntReferenceMessageQueue(Window
->pti
->MessageQueue
);
1711 if (Wnd
->spwndParent
!= NULL
&& Cs
->hwndParent
!= 0)
1713 Wnd
->HideFocus
= Wnd
->spwndParent
->HideFocus
;
1714 Wnd
->HideAccel
= Wnd
->spwndParent
->HideAccel
;
1717 if (Wnd
->pcls
->CSF_flags
& CSF_SERVERSIDEPROC
)
1718 Wnd
->state
|= WNDS_SERVERSIDEWINDOWPROC
;
1720 /* BugBoy Comments: Comment below say that System classes are always created
1721 as UNICODE. In windows, creating a window with the ANSI version of CreateWindow
1722 sets the window to ansi as verified by testing with IsUnicodeWindow API.
1724 No where can I see in code or through testing does the window change back
1725 to ANSI after being created as UNICODE in ROS. I didnt do more testing to
1726 see what problems this would cause.*/
1728 // Set WndProc from Class.
1729 Wnd
->lpfnWndProc
= Wnd
->pcls
->lpfnWndProc
;
1731 // GetWindowProc, test for non server side default classes and set WndProc.
1732 if ( Wnd
->pcls
->fnid
<= FNID_GHOST
&& Wnd
->pcls
->fnid
>= FNID_BUTTON
)
1736 if (GETPFNCLIENTA(Wnd
->pcls
->fnid
) == Wnd
->lpfnWndProc
)
1737 Wnd
->lpfnWndProc
= GETPFNCLIENTW(Wnd
->pcls
->fnid
);
1741 if (GETPFNCLIENTW(Wnd
->pcls
->fnid
) == Wnd
->lpfnWndProc
)
1742 Wnd
->lpfnWndProc
= GETPFNCLIENTA(Wnd
->pcls
->fnid
);
1746 // If not an Unicode caller, set Ansi creator bit.
1747 if (!bUnicodeWindow
) Wnd
->state
|= WNDS_ANSICREATOR
;
1749 // Clone Class Ansi/Unicode proc type.
1750 if (Wnd
->pcls
->CSF_flags
& CSF_ANSIPROC
)
1752 Wnd
->state
|= WNDS_ANSIWINDOWPROC
;
1753 Wnd
->Unicode
= FALSE
;
1757 It seems there can be both an Ansi creator and Unicode Class Window
1758 WndProc, unless the following overriding conditions occur:
1760 if ( !bUnicodeWindow
&&
1761 ( Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_BUTTON
] ||
1762 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_COMBOBOX
] ||
1763 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_COMBOLBOX
] ||
1764 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_DIALOG
] ||
1765 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_EDIT
] ||
1766 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_IME
] ||
1767 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_LISTBOX
] ||
1768 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_MDICLIENT
] ||
1769 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_STATIC
] ) )
1770 { // Override Class and set the window Ansi WndProc.
1771 Wnd
->state
|= WNDS_ANSIWINDOWPROC
;
1772 Wnd
->Unicode
= FALSE
;
1775 { // Set the window Unicode WndProc.
1776 Wnd
->state
&= ~WNDS_ANSIWINDOWPROC
;
1777 Wnd
->Unicode
= TRUE
;
1781 /* BugBoy Comments: if the window being created is a edit control, ATOM 0xCxxx,
1782 then my testing shows that windows (2k and XP) creates a CallProc for it immediately
1783 Dont understand why it does this. */
1784 if (Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_EDIT
])
1786 PCALLPROCDATA CallProc
;
1787 //CallProc = CreateCallProc(NULL, Wnd->lpfnWndProc, bUnicodeWindow, Wnd->ti->ppi);
1788 CallProc
= CreateCallProc(NULL
, Wnd
->lpfnWndProc
, Wnd
->Unicode
, Wnd
->head
.pti
->ppi
);
1792 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
1793 DPRINT1("Warning: Unable to create CallProc for edit control. Control may not operate correctly! hwnd %x\n",hWnd
);
1797 UserAddCallProcToClass(Wnd
->pcls
, CallProc
);
1801 InitializeListHead(&Wnd
->PropListHead
);
1803 if ( WindowName
->Buffer
!= NULL
&& WindowName
->Length
> 0 )
1805 Wnd
->strName
.Buffer
= DesktopHeapAlloc(Wnd
->head
.rpdesk
,
1806 WindowName
->Length
+ sizeof(UNICODE_NULL
));
1807 if (Wnd
->strName
.Buffer
== NULL
)
1812 RtlCopyMemory(Wnd
->strName
.Buffer
, WindowName
->Buffer
, WindowName
->Length
);
1813 Wnd
->strName
.Buffer
[WindowName
->Length
/ sizeof(WCHAR
)] = L
'\0';
1814 Wnd
->strName
.Length
= WindowName
->Length
;
1817 /* Correct the window style. */
1818 if ((Wnd
->style
& (WS_CHILD
| WS_POPUP
)) != WS_CHILD
)
1820 Wnd
->style
|= WS_CLIPSIBLINGS
;
1821 if (!(Wnd
->style
& WS_POPUP
))
1823 Wnd
->style
|= WS_CAPTION
;
1824 Window
->state
|= WINDOWOBJECT_NEED_SIZE
;
1828 if ((Wnd
->ExStyle
& WS_EX_DLGMODALFRAME
) ||
1829 (Wnd
->style
& (WS_DLGFRAME
| WS_THICKFRAME
)))
1830 Wnd
->ExStyle
|= WS_EX_WINDOWEDGE
;
1832 Wnd
->ExStyle
&= ~WS_EX_WINDOWEDGE
;
1834 /* create system menu */
1835 if((Cs
->style
& WS_SYSMENU
) )//&& (dwStyle & WS_CAPTION) == WS_CAPTION)
1837 SystemMenu
= IntGetSystemMenu(Window
, TRUE
, TRUE
);
1840 Window
->SystemMenu
= SystemMenu
->MenuInfo
.Self
;
1841 IntReleaseMenuObject(SystemMenu
);
1845 /* Set the window menu */
1846 if ((Cs
->style
& (WS_CHILD
| WS_POPUP
)) != WS_CHILD
)
1849 IntSetMenu(Window
, Cs
->hMenu
, &MenuChanged
);
1850 else if (Wnd
->pcls
->lpszMenuName
) // Take it from the parent.
1852 UNICODE_STRING MenuName
;
1855 if (IS_INTRESOURCE(Wnd
->pcls
->lpszMenuName
))
1857 MenuName
.Length
= 0;
1858 MenuName
.MaximumLength
= 0;
1859 MenuName
.Buffer
= Wnd
->pcls
->lpszMenuName
;
1863 RtlInitUnicodeString( &MenuName
, Wnd
->pcls
->lpszMenuName
);
1865 hMenu
= co_IntCallLoadMenu( Wnd
->pcls
->hModule
, &MenuName
);
1866 if (hMenu
) IntSetMenu(Window
, hMenu
, &MenuChanged
);
1870 Wnd
->IDMenu
= (UINT
) Cs
->hMenu
;
1872 /* Insert the window into the thread's window list. */
1873 InsertTailList (&pti
->WindowListHead
, &Window
->ThreadListEntry
);
1875 /* Handle "CS_CLASSDC", it is tested first. */
1876 if ( (Wnd
->pcls
->style
& CS_CLASSDC
) && !(Wnd
->pcls
->pdce
) )
1877 { /* One DCE per class to have CLASS. */
1878 Wnd
->pcls
->pdce
= DceAllocDCE( Window
, DCE_CLASS_DC
);
1880 else if ( Wnd
->pcls
->style
& CS_OWNDC
)
1881 { /* Allocate a DCE for this window. */
1882 DceAllocDCE(Window
, DCE_WINDOW_DC
);
1890 UserDereferenceObject(Window
);
1893 DesktopHeapFree(Wnd
->head
.rpdesk
, Wnd
);
1895 SetLastNtError(STATUS_INSUFFICIENT_RESOURCES
);
1903 co_UserCreateWindowEx(CREATESTRUCTW
* Cs
,
1904 PUNICODE_STRING ClassName
,
1905 PLARGE_STRING WindowName
)
1907 PWINDOW_OBJECT Window
= NULL
, ParentWindow
= NULL
, OwnerWindow
;
1908 HWND hWnd
, hWndParent
, hWndOwner
;
1910 PWINSTATION_OBJECT WinSta
;
1915 CBT_CREATEWNDW CbtCreate
;
1917 USER_REFERENCE_ENTRY ParentRef
, Ref
;
1919 DWORD dwShowMode
= SW_SHOW
;
1920 DECLARE_RETURN(PWND
);
1922 /* Get the current window station and reference it */
1923 pti
= GetW32ThreadInfo();
1924 if (pti
== NULL
|| pti
->rpdesk
== NULL
)
1926 DPRINT1("Thread is not attached to a desktop! Cannot create window!\n");
1927 return NULL
; //There is nothing to cleanup
1929 WinSta
= pti
->rpdesk
->rpwinstaParent
;
1930 ObReferenceObjectByPointer(WinSta
, KernelMode
, ExWindowStationObjectType
, 0);
1932 /* Get the class and reference it*/
1933 Class
= IntGetAndReferenceClass(ClassName
, Cs
->hInstance
);
1936 DPRINT1("Failed to find class %wZ\n", ClassName
);
1940 /* Now find the parent and the owner window */
1941 hWndParent
= IntGetDesktopWindow();
1944 if (Cs
->hwndParent
== HWND_MESSAGE
)
1946 Cs
->hwndParent
= hWndParent
= IntGetMessageWindow();
1948 else if (Cs
->hwndParent
)
1950 if ((Cs
->style
& (WS_CHILD
|WS_POPUP
)) != WS_CHILD
)
1951 hWndOwner
= Cs
->hwndParent
;
1953 hWndParent
= Cs
->hwndParent
;
1955 else if ((Cs
->style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
)
1957 DPRINT1("Cannot create a child window without a parrent!\n");
1958 SetLastWin32Error(ERROR_TLW_WITH_WSCHILD
);
1959 RETURN(NULL
); /* WS_CHILD needs a parent, but WS_POPUP doesn't */
1962 ParentWindow
= hWndParent
? UserGetWindowObject(hWndParent
): NULL
;
1963 OwnerWindow
= hWndOwner
? UserGetWindowObject(hWndOwner
): NULL
;
1965 /* FIXME: is this correct?*/
1967 OwnerWindow
= UserGetAncestor(OwnerWindow
, GA_ROOT
);
1969 /* Fix the position and the size of the window */
1972 UserRefObjectCo(ParentWindow
, &ParentRef
);
1973 IntFixWindowCoordinates(Cs
, ParentWindow
, &dwShowMode
);
1976 /* Allocate and initialize the new window */
1977 Window
= IntCreateWindow(Cs
,
1984 DPRINT1("IntCreateWindow failed!\n");
1989 hWnd
= Window
->hSelf
;
1991 UserRefObjectCo(Window
, &Ref
);
1992 ObDereferenceObject(WinSta
);
1994 /* Call the WH_CBT hook */
1995 dwStyle
= Cs
->style
;
1996 Cs
->style
= Wnd
->style
; /* HCBT_CREATEWND needs the real window style */
1997 CbtCreate
.lpcs
= Cs
;
1998 CbtCreate
.hwndInsertAfter
= HWND_TOP
;
1999 if (ISITHOOKED(WH_CBT
))
2001 if (co_HOOK_CallHooks(WH_CBT
, HCBT_CREATEWND
, (WPARAM
) hWnd
, (LPARAM
) &CbtCreate
))
2003 DPRINT1("HCBT_CREATEWND hook failed!\n");
2004 RETURN( (PWND
) NULL
);
2007 Cs
->style
= dwStyle
; /* NCCREATE and WM_NCCALCSIZE need the original values*/
2009 /* Send the WM_GETMINMAXINFO message*/
2013 if ((dwStyle
& WS_THICKFRAME
) || !(dwStyle
& (WS_POPUP
| WS_CHILD
)))
2015 POINT MaxSize
, MaxPos
, MinTrack
, MaxTrack
;
2017 co_WinPosGetMinMaxInfo(Window
, &MaxSize
, &MaxPos
, &MinTrack
, &MaxTrack
);
2018 if (Size
.cx
> MaxTrack
.x
) Size
.cx
= MaxTrack
.x
;
2019 if (Size
.cy
> MaxTrack
.y
) Size
.cy
= MaxTrack
.y
;
2020 if (Size
.cx
< MinTrack
.x
) Size
.cx
= MinTrack
.x
;
2021 if (Size
.cy
< MinTrack
.y
) Size
.cy
= MinTrack
.y
;
2024 Wnd
->rcWindow
.left
= Cs
->x
;
2025 Wnd
->rcWindow
.top
= Cs
->y
;
2026 Wnd
->rcWindow
.right
= Cs
->x
+ Size
.cx
;
2027 Wnd
->rcWindow
.bottom
= Cs
->y
+ Size
.cy
;
2028 if (0 != (Wnd
->style
& WS_CHILD
) && ParentWindow
)
2030 RECTL_vOffsetRect(&Wnd
->rcWindow
,
2031 ParentWindow
->Wnd
->rcClient
.left
,
2032 ParentWindow
->Wnd
->rcClient
.top
);
2034 Wnd
->rcClient
= Wnd
->rcWindow
;
2037 /* Link the window*/
2038 if (NULL
!= ParentWindow
)
2040 /* link the window into the parent's child list */
2041 if ((dwStyle
& (WS_CHILD
|WS_MAXIMIZE
)) == WS_CHILD
)
2043 PWINDOW_OBJECT PrevSibling
;
2045 PrevSibling
= ParentWindow
->spwndChild
;
2049 while (PrevSibling
->spwndNext
)
2050 PrevSibling
= PrevSibling
->spwndNext
;
2053 /* link window as bottom sibling */
2054 IntLinkWindow(Window
, ParentWindow
, PrevSibling
/*prev sibling*/);
2058 /* link window as top sibling (but after topmost siblings) */
2059 PWINDOW_OBJECT InsertAfter
, Sibling
;
2060 if (!(Cs
->dwExStyle
& WS_EX_TOPMOST
))
2063 Sibling
= ParentWindow
->spwndChild
;
2064 while (Sibling
&& (Sibling
->Wnd
->ExStyle
& WS_EX_TOPMOST
))
2066 InsertAfter
= Sibling
;
2067 Sibling
= Sibling
->spwndNext
;
2075 IntLinkWindow(Window
, ParentWindow
, InsertAfter
/* prev sibling */);
2079 /* Send the NCCREATE message */
2080 Result
= co_IntSendMessage(Window
->hSelf
, WM_NCCREATE
, 0, (LPARAM
) Cs
);
2083 DPRINT1("co_UserCreateWindowEx(): NCCREATE message failed\n");
2087 /* Send the WM_NCCALCSIZE message */
2088 MaxPos
.x
= Window
->Wnd
->rcWindow
.left
;
2089 MaxPos
.y
= Window
->Wnd
->rcWindow
.top
;
2091 Result
= co_WinPosGetNonClientSize(Window
, &Wnd
->rcWindow
, &Wnd
->rcClient
);
2093 RECTL_vOffsetRect(&Wnd
->rcWindow
, MaxPos
.x
- Wnd
->rcWindow
.left
,
2094 MaxPos
.y
- Wnd
->rcWindow
.top
);
2097 /* Send the WM_CREATE message. */
2098 Result
= co_IntSendMessage(Window
->hSelf
, WM_CREATE
, 0, (LPARAM
) Cs
);
2099 if (Result
== (LRESULT
)-1)
2101 DPRINT1("co_UserCreateWindowEx(): WM_CREATE message failed\n");
2102 IntUnlinkWindow(Window
);
2106 /* Send the EVENT_OBJECT_CREATE event*/
2107 IntNotifyWinEvent(EVENT_OBJECT_CREATE
, Window
->Wnd
, OBJID_WINDOW
, 0);
2109 /* By setting the flag below it can be examined to determine if the window
2110 was created successfully and a valid pwnd was passed back to caller since
2111 from here the function has to succeed. */
2112 Window
->Wnd
->state2
|= WNDS2_WMCREATEMSGPROCESSED
;
2114 /* Send the WM_SIZE and WM_MOVE messages. */
2115 if (!(Window
->state
& WINDOWOBJECT_NEED_SIZE
))
2117 co_WinPosSendSizeMove(Window
);
2120 /* Show or maybe minimize or maximize the window. */
2121 if (Wnd
->style
& (WS_MINIMIZE
| WS_MAXIMIZE
))
2126 SwFlag
= (Wnd
->style
& WS_MINIMIZE
) ? SW_MINIMIZE
: SW_MAXIMIZE
;
2128 co_WinPosMinMaximize(Window
, SwFlag
, &NewPos
);
2130 SwFlag
= ((Wnd
->style
& WS_CHILD
) || UserGetActiveWindow()) ?
2131 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
:
2132 SWP_NOZORDER
| SWP_FRAMECHANGED
;
2134 co_WinPosSetWindowPos(Window
, 0, NewPos
.left
, NewPos
.top
,
2135 NewPos
.right
, NewPos
.bottom
, SwFlag
);
2138 /* Send the WM_PARENTNOTIFY message */
2139 if ((Wnd
->style
& WS_CHILD
) &&
2140 (!(Wnd
->ExStyle
& WS_EX_NOPARENTNOTIFY
)) && ParentWindow
)
2142 co_IntSendMessage(ParentWindow
->hSelf
,
2144 MAKEWPARAM(WM_CREATE
, Wnd
->IDMenu
),
2145 (LPARAM
)Window
->hSelf
);
2148 /* Notify the shell that a new window was created */
2149 if ((!hWndParent
) && (!hWndOwner
))
2151 co_IntShellHookNotify(HSHELL_WINDOWCREATED
, (LPARAM
)hWnd
);
2154 /* Initialize and show the window's scrollbars */
2155 if (Wnd
->style
& WS_VSCROLL
)
2157 co_UserShowScrollBar(Window
, SB_VERT
, TRUE
);
2159 if (Wnd
->style
& WS_HSCROLL
)
2161 co_UserShowScrollBar(Window
, SB_HORZ
, TRUE
);
2164 /* Show the new window */
2165 if (Cs
->style
& WS_VISIBLE
)
2167 if (Wnd
->style
& WS_MAXIMIZE
)
2168 dwShowMode
= SW_SHOW
;
2169 else if (Wnd
->style
& WS_MINIMIZE
)
2170 dwShowMode
= SW_SHOWMINIMIZED
;
2172 co_WinPosShowWindow(Window
, dwShowMode
);
2174 if (Wnd
->ExStyle
& WS_EX_MDICHILD
)
2176 co_IntSendMessage(ParentWindow
->hSelf
, WM_MDIREFRESHMENU
, 0, 0);
2177 /* ShowWindow won't activate child windows */
2178 co_WinPosSetWindowPos(Window
, HWND_TOP
, 0, 0, 0, 0, SWP_SHOWWINDOW
| SWP_NOMOVE
| SWP_NOSIZE
);
2182 DPRINT("co_UserCreateWindowEx(): Created window %X\n", hWnd
);
2188 /* If the window was created, the class will be dereferenced by co_UserDestroyWindow */
2190 co_UserDestroyWindow(Window
);
2192 IntDereferenceClass(Class
, pti
->pDeskInfo
, pti
->ppi
);
2197 UserDerefObjectCo(Window
);
2198 UserDereferenceObject(Window
);
2200 if (ParentWindow
) UserDerefObjectCo(ParentWindow
);
2207 ProbeAndCaptureLargeString(
2208 OUT PLARGE_STRING plstrSafe
,
2209 IN PLARGE_STRING plstrUnsafe
)
2211 LARGE_STRING lstrTemp
;
2212 PVOID pvBuffer
= NULL
;
2216 /* Probe and copy the string */
2217 ProbeForRead(plstrUnsafe
, sizeof(LARGE_STRING
), sizeof(ULONG
));
2218 lstrTemp
= *plstrUnsafe
;
2220 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2223 _SEH2_YIELD(return _SEH2_GetExceptionCode();)
2227 if (lstrTemp
.Length
!= 0)
2229 /* Allocate a buffer from paged pool */
2230 pvBuffer
= ExAllocatePoolWithTag(PagedPool
, lstrTemp
.Length
, TAG_STRING
);
2233 return STATUS_NO_MEMORY
;
2238 /* Probe and copy the buffer */
2239 ProbeForRead(lstrTemp
.Buffer
, lstrTemp
.Length
, sizeof(WCHAR
));
2240 RtlCopyMemory(pvBuffer
, lstrTemp
.Buffer
, lstrTemp
.Length
);
2242 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2244 /* Cleanup and fail */
2245 ExFreePool(pvBuffer
);
2246 _SEH2_YIELD(return _SEH2_GetExceptionCode();)
2251 /* Set the output string */
2252 plstrSafe
->Buffer
= pvBuffer
;
2253 plstrSafe
->Length
= lstrTemp
.Length
;
2254 plstrSafe
->MaximumLength
= lstrTemp
.Length
;
2256 return STATUS_SUCCESS
;
2260 * \todo Allow passing plstrClassName as ANSI.
2264 NtUserCreateWindowEx(
2266 PLARGE_STRING plstrClassName
,
2267 PLARGE_STRING plstrClsVersion
,
2268 PLARGE_STRING plstrWindowName
,
2276 HINSTANCE hInstance
,
2282 LARGE_STRING lstrWindowName
;
2283 LARGE_STRING lstrClassName
;
2284 UNICODE_STRING ustrClassName
;
2289 lstrWindowName
.Buffer
= NULL
;
2290 lstrClassName
.Buffer
= NULL
;
2292 /* Check if we got a Window name */
2293 if (plstrWindowName
)
2295 /* Copy the string to kernel mode */
2296 Status
= ProbeAndCaptureLargeString(&lstrWindowName
, plstrWindowName
);
2297 if (!NT_SUCCESS(Status
))
2299 DPRINT1("NtUserCreateWindowEx: failed to capture plstrWindowName\n");
2300 SetLastNtError(Status
);
2303 plstrWindowName
= &lstrWindowName
;
2306 /* Check if the class is an atom */
2307 if (IS_ATOM(plstrClassName
))
2309 /* It is, pass the atom in the UNICODE_STRING */
2310 ustrClassName
.Buffer
= (PVOID
)plstrClassName
;
2311 ustrClassName
.Length
= 0;
2312 ustrClassName
.MaximumLength
= 0;
2316 /* It's not, capture the class name */
2317 Status
= ProbeAndCaptureLargeString(&lstrClassName
, plstrClassName
);
2318 if (!NT_SUCCESS(Status
))
2320 DPRINT1("NtUserCreateWindowEx: failed to capture plstrClassName\n");
2321 /* Set last error, cleanup and return */
2322 SetLastNtError(Status
);
2326 /* We pass it on as a UNICODE_STRING */
2327 ustrClassName
.Buffer
= lstrClassName
.Buffer
;
2328 ustrClassName
.Length
= lstrClassName
.Length
;
2329 ustrClassName
.MaximumLength
= lstrClassName
.MaximumLength
;
2332 /* Fill the CREATESTRUCTW */
2333 /* we will keep here the original parameters */
2335 Cs
.lpCreateParams
= lpParam
;
2336 Cs
.hInstance
= hInstance
;
2338 Cs
.hwndParent
= hWndParent
;
2343 // Cs.lpszName = (LPCWSTR) WindowName->Buffer;
2344 // Cs.lpszClass = (LPCWSTR) ClassName->Buffer;
2345 Cs
.lpszName
= (LPCWSTR
) plstrWindowName
;
2346 Cs
.lpszClass
= (LPCWSTR
) &ustrClassName
;
2347 Cs
.dwExStyle
= dwExStyle
;
2349 UserEnterExclusive();
2351 /* Call the internal function */
2352 pwnd
= co_UserCreateWindowEx(&Cs
, &ustrClassName
, plstrWindowName
);
2356 DPRINT1("co_UserCreateWindowEx failed!\n");
2358 hwnd
= pwnd
? UserHMGetHandle(pwnd
) : NULL
;
2363 if (lstrWindowName
.Buffer
)
2365 ExFreePoolWithTag(lstrWindowName
.Buffer
, TAG_STRING
);
2367 if (lstrClassName
.Buffer
)
2369 ExFreePoolWithTag(lstrClassName
.Buffer
, TAG_STRING
);
2379 NtUserDeferWindowPos(HDWP WinPosInfo
,
2381 HWND WndInsertAfter
,
2394 BOOLEAN FASTCALL
co_UserDestroyWindow(PWINDOW_OBJECT Window
)
2402 ASSERT_REFS_CO(Window
); // FIXME: temp hack?
2404 hWnd
= Window
->hSelf
;
2408 if (!Wnd
) return TRUE
; // FIXME: Need to finish object rewrite or lock the thread when killing the window!
2410 DPRINT("co_UserDestroyWindow \n");
2412 /* Check for owner thread */
2413 if ( (Window
->pti
->pEThread
!= PsGetCurrentThread()) ||
2414 Wnd
->head
.pti
!= PsGetCurrentThreadWin32Thread() )
2416 SetLastWin32Error(ERROR_ACCESS_DENIED
);
2420 /* If window was created successfully and it is hooked */
2421 if ((Wnd
->state2
& WNDS2_WMCREATEMSGPROCESSED
) && (ISITHOOKED(WH_CBT
)))
2423 if (co_HOOK_CallHooks(WH_CBT
, HCBT_DESTROYWND
, (WPARAM
) hWnd
, 0)) return FALSE
;
2426 /* Look whether the focus is within the tree of windows we will
2429 if (!co_WinPosShowWindow(Window
, SW_HIDE
))
2431 if (UserGetActiveWindow() == Window
->hSelf
)
2433 co_WinPosActivateOtherWindow(Window
);
2437 if (Window
->pti
->MessageQueue
->ActiveWindow
== Window
->hSelf
)
2438 Window
->pti
->MessageQueue
->ActiveWindow
= NULL
;
2439 if (Window
->pti
->MessageQueue
->FocusWindow
== Window
->hSelf
)
2440 Window
->pti
->MessageQueue
->FocusWindow
= NULL
;
2441 if (Window
->pti
->MessageQueue
->CaptureWindow
== Window
->hSelf
)
2442 Window
->pti
->MessageQueue
->CaptureWindow
= NULL
;
2445 * Check if this window is the Shell's Desktop Window. If so set hShellWindow to NULL
2448 ti
= PsGetCurrentThreadWin32Thread();
2450 if ((ti
!= NULL
) & (ti
->pDeskInfo
!= NULL
))
2452 if (ti
->pDeskInfo
->hShellWindow
== hWnd
)
2454 DPRINT1("Destroying the ShellWindow!\n");
2455 ti
->pDeskInfo
->hShellWindow
= NULL
;
2459 IntDereferenceMessageQueue(Window
->pti
->MessageQueue
);
2461 IntEngWindowChanged(Window
, WOC_DELETE
);
2462 isChild
= (0 != (Wnd
->style
& WS_CHILD
));
2468 if (! USER_IsExitingThread(GetCurrentThreadId()))
2470 send_parent_notify(hwnd
, WM_DESTROY
);
2473 else if (NULL
!= GetWindow(Wnd
, GW_OWNER
))
2475 co_HOOK_CallHooks( WH_SHELL
, HSHELL_WINDOWDESTROYED
, (WPARAM
)hwnd
, 0L, TRUE
);
2476 /* FIXME: clean up palette - see "Internals" p.352 */
2480 if (!IntIsWindow(Window
->hSelf
))
2485 /* Recursively destroy owned windows */
2490 BOOL GotOne
= FALSE
;
2493 PWINDOW_OBJECT Child
, Desktop
;
2495 Desktop
= IntIsDesktopWindow(Window
) ? Window
:
2496 UserGetWindowObject(IntGetDesktopWindow());
2497 Children
= IntWinListChildren(Desktop
);
2501 for (ChildHandle
= Children
; *ChildHandle
; ++ChildHandle
)
2503 Child
= UserGetWindowObject(*ChildHandle
);
2506 if (Child
->spwndOwner
!= Window
)
2511 if (IntWndBelongsToThread(Child
, PsGetCurrentThreadWin32Thread()))
2513 USER_REFERENCE_ENTRY ChildRef
;
2514 UserRefObjectCo(Child
, &ChildRef
);//temp hack?
2515 co_UserDestroyWindow(Child
);
2516 UserDerefObjectCo(Child
);//temp hack?
2522 if (Child
->spwndOwner
!= NULL
)
2524 Child
->spwndOwner
= NULL
;
2525 Child
->Wnd
->spwndOwner
= NULL
;
2529 ExFreePool(Children
);
2538 /* Generate mouse move message for the next window */
2539 msg
.message
= WM_MOUSEMOVE
;
2540 msg
.wParam
= IntGetSysCursorInfo()->ButtonsDown
;
2541 msg
.lParam
= MAKELPARAM(gpsi
->ptCursor
.x
, gpsi
->ptCursor
.y
);
2542 msg
.pt
= gpsi
->ptCursor
;
2543 MsqInsertSystemMessage(&msg
);
2545 if (!IntIsWindow(Window
->hSelf
))
2550 /* Destroy the window storage */
2551 co_UserFreeWindow(Window
, PsGetCurrentProcessWin32Process(), PsGetCurrentThreadWin32Thread(), TRUE
);
2561 NtUserDestroyWindow(HWND Wnd
)
2563 PWINDOW_OBJECT Window
;
2564 DECLARE_RETURN(BOOLEAN
);
2566 USER_REFERENCE_ENTRY Ref
;
2568 DPRINT("Enter NtUserDestroyWindow\n");
2569 UserEnterExclusive();
2571 if (!(Window
= UserGetWindowObject(Wnd
)))
2576 UserRefObjectCo(Window
, &Ref
);//faxme: dunno if win should be reffed during destroy..
2577 ret
= co_UserDestroyWindow(Window
);
2578 UserDerefObjectCo(Window
);//faxme: dunno if win should be reffed during destroy..
2583 DPRINT("Leave NtUserDestroyWindow, ret=%i\n",_ret_
);
2595 NtUserDrawMenuBarTemp(
2602 /* we'll use this function just for caching the menu bar */
2612 NtUserEndDeferWindowPosEx(DWORD Unknown0
,
2622 * FillWindow: Called from User; Dialog, Edit and ListBox procs during a WM_ERASEBKGND.
2628 NtUserFillWindow(HWND hWndPaint
,
2639 static HWND FASTCALL
2640 IntFindWindow(PWINDOW_OBJECT Parent
,
2641 PWINDOW_OBJECT ChildAfter
,
2643 PUNICODE_STRING WindowName
)
2645 BOOL CheckWindowName
;
2648 UNICODE_STRING CurrentWindowName
;
2652 CheckWindowName
= WindowName
->Length
!= 0;
2654 if((List
= IntWinListChildren(Parent
)))
2659 /* skip handles before and including ChildAfter */
2660 while(*phWnd
&& (*(phWnd
++) != ChildAfter
->hSelf
))
2664 /* search children */
2667 PWINDOW_OBJECT Child
;
2668 if(!(Child
= UserGetWindowObject(*(phWnd
++))))
2673 /* Do not send WM_GETTEXT messages in the kernel mode version!
2674 The user mode version however calls GetWindowText() which will
2675 send WM_GETTEXT messages to windows belonging to its processes */
2676 if (!ClassAtom
|| Child
->Wnd
->pcls
->atomClassName
== ClassAtom
)
2678 // HACK: use UNICODE_STRING instead of LARGE_STRING
2679 CurrentWindowName
.Buffer
= Child
->Wnd
->strName
.Buffer
;
2680 CurrentWindowName
.Length
= Child
->Wnd
->strName
.Length
;
2681 CurrentWindowName
.MaximumLength
= Child
->Wnd
->strName
.MaximumLength
;
2682 if(!CheckWindowName
||
2683 (Child
->Wnd
->strName
.Length
< 0xFFFF &&
2684 !RtlCompareUnicodeString(WindowName
, &CurrentWindowName
, TRUE
)))
2699 * Searches a window's children for a window with the specified
2702 * hwndParent = The window whose childs are to be searched.
2704 * HWND_MESSAGE = message-only windows
2706 * hwndChildAfter = Search starts after this child window.
2707 * NULL = start from beginning
2709 * ucClassName = Class name to search for
2710 * Reguired parameter.
2712 * ucWindowName = Window name
2713 * ->Buffer == NULL = don't care
2716 * The HWND of the window if it was found, otherwise NULL
2722 NtUserFindWindowEx(HWND hwndParent
,
2723 HWND hwndChildAfter
,
2724 PUNICODE_STRING ucClassName
,
2725 PUNICODE_STRING ucWindowName
,
2728 PWINDOW_OBJECT Parent
, ChildAfter
;
2729 UNICODE_STRING ClassName
= {0}, WindowName
= {0};
2730 HWND Desktop
, Ret
= NULL
;
2731 RTL_ATOM ClassAtom
= (RTL_ATOM
)0;
2732 DECLARE_RETURN(HWND
);
2734 DPRINT("Enter NtUserFindWindowEx\n");
2737 if (ucClassName
!= NULL
|| ucWindowName
!= NULL
)
2741 if (ucClassName
!= NULL
)
2743 ClassName
= ProbeForReadUnicodeString(ucClassName
);
2744 if (ClassName
.Length
!= 0)
2746 ProbeForRead(ClassName
.Buffer
,
2750 else if (!IS_ATOM(ClassName
.Buffer
))
2752 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
2756 if (!IntGetAtomFromStringOrAtom(&ClassName
,
2763 if (ucWindowName
!= NULL
)
2765 WindowName
= ProbeForReadUnicodeString(ucWindowName
);
2766 if (WindowName
.Length
!= 0)
2768 ProbeForRead(WindowName
.Buffer
,
2774 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2776 SetLastNtError(_SEH2_GetExceptionCode());
2777 _SEH2_YIELD(RETURN(NULL
));
2781 if (ucClassName
!= NULL
)
2783 if (ClassName
.Length
== 0 && ClassName
.Buffer
!= NULL
&&
2784 !IS_ATOM(ClassName
.Buffer
))
2786 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
2789 else if (ClassAtom
== (RTL_ATOM
)0)
2791 /* LastError code was set by IntGetAtomFromStringOrAtom */
2797 Desktop
= IntGetCurrentThreadDesktopWindow();
2799 if(hwndParent
== NULL
)
2800 hwndParent
= Desktop
;
2801 else if(hwndParent
== HWND_MESSAGE
)
2803 hwndParent
= IntGetMessageWindow();
2806 if(!(Parent
= UserGetWindowObject(hwndParent
)))
2812 if(hwndChildAfter
&& !(ChildAfter
= UserGetWindowObject(hwndChildAfter
)))
2819 if(Parent
->hSelf
== Desktop
)
2822 PWINDOW_OBJECT TopLevelWindow
;
2823 BOOLEAN CheckWindowName
;
2824 BOOLEAN WindowMatches
;
2825 BOOLEAN ClassMatches
;
2827 /* windows searches through all top-level windows if the parent is the desktop
2830 if((List
= IntWinListChildren(Parent
)))
2836 /* skip handles before and including ChildAfter */
2837 while(*phWnd
&& (*(phWnd
++) != ChildAfter
->hSelf
))
2841 CheckWindowName
= WindowName
.Length
!= 0;
2843 /* search children */
2846 UNICODE_STRING ustr
;
2848 if(!(TopLevelWindow
= UserGetWindowObject(*(phWnd
++))))
2853 /* Do not send WM_GETTEXT messages in the kernel mode version!
2854 The user mode version however calls GetWindowText() which will
2855 send WM_GETTEXT messages to windows belonging to its processes */
2856 ustr
.Buffer
= TopLevelWindow
->Wnd
->strName
.Buffer
;
2857 ustr
.Length
= TopLevelWindow
->Wnd
->strName
.Length
;
2858 ustr
.MaximumLength
= TopLevelWindow
->Wnd
->strName
.MaximumLength
;
2859 WindowMatches
= !CheckWindowName
||
2860 (TopLevelWindow
->Wnd
->strName
.Length
< 0xFFFF &&
2861 !RtlCompareUnicodeString(&WindowName
, &ustr
, TRUE
));
2862 ClassMatches
= (ClassAtom
== (RTL_ATOM
)0) ||
2863 ClassAtom
== TopLevelWindow
->Wnd
->pcls
->atomClassName
;
2865 if (WindowMatches
&& ClassMatches
)
2867 Ret
= TopLevelWindow
->hSelf
;
2871 if (IntFindWindow(TopLevelWindow
, NULL
, ClassAtom
, &WindowName
))
2873 /* window returns the handle of the top-level window, in case it found
2875 Ret
= TopLevelWindow
->hSelf
;
2884 Ret
= IntFindWindow(Parent
, ChildAfter
, ClassAtom
, &WindowName
);
2888 if(Ret
== NULL
&& hwndParent
== NULL
&& hwndChildAfter
== NULL
)
2890 /* FIXME - if both hwndParent and hwndChildAfter are NULL, we also should
2891 search the message-only windows. Should this also be done if
2892 Parent is the desktop window??? */
2893 PWINDOW_OBJECT MsgWindows
;
2895 if((MsgWindows
= UserGetWindowObject(IntGetMessageWindow())))
2897 Ret
= IntFindWindow(MsgWindows
, ChildAfter
, ClassAtom
, &WindowName
);
2902 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2904 SetLastNtError(_SEH2_GetExceptionCode());
2912 DPRINT("Leave NtUserFindWindowEx, ret %i\n",_ret_
);
2922 NtUserFlashWindowEx(IN PFLASHWINFO pfwi
)
2933 PWINDOW_OBJECT FASTCALL
UserGetAncestor(PWINDOW_OBJECT Wnd
, UINT Type
)
2935 PWINDOW_OBJECT WndAncestor
, Parent
;
2937 if (Wnd
->hSelf
== IntGetDesktopWindow())
2946 WndAncestor
= Wnd
->spwndParent
;
2957 if(!(Parent
= WndAncestor
->spwndParent
))
2961 if(IntIsDesktopWindow(Parent
))
2966 WndAncestor
= Parent
;
2977 PWINDOW_OBJECT Parent
;
2979 Parent
= IntGetParent(WndAncestor
);
2986 WndAncestor
= Parent
;
3004 NtUserGetAncestor(HWND hWnd
, UINT Type
)
3006 PWINDOW_OBJECT Window
, Ancestor
;
3007 DECLARE_RETURN(HWND
);
3009 DPRINT("Enter NtUserGetAncestor\n");
3010 UserEnterExclusive();
3012 if (!(Window
= UserGetWindowObject(hWnd
)))
3017 Ancestor
= UserGetAncestor(Window
, Type
);
3018 /* faxme: can UserGetAncestor ever return NULL for a valid window? */
3020 RETURN(Ancestor
? Ancestor
->hSelf
: NULL
);
3023 DPRINT("Leave NtUserGetAncestor, ret=%i\n",_ret_
);
3031 NtUserGetComboBoxInfo(
3036 DECLARE_RETURN(BOOL
);
3038 DPRINT("Enter NtUserGetComboBoxInfo\n");
3041 if (!(Wnd
= UserGetWindowObject(hWnd
)))
3050 sizeof(COMBOBOXINFO
),
3054 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
3056 SetLastNtError(_SEH2_GetExceptionCode());
3057 _SEH2_YIELD(RETURN(FALSE
));
3061 // Pass the user pointer, it was already probed.
3062 RETURN( (BOOL
) co_IntSendMessage( Wnd
->hSelf
, CB_GETCOMBOBOXINFO
, 0, (LPARAM
)pcbi
));
3065 DPRINT("Leave NtUserGetComboBoxInfo, ret=%i\n",_ret_
);
3075 NtUserGetInternalWindowPos( HWND hWnd
,
3079 PWINDOW_OBJECT Window
;
3082 WINDOWPLACEMENT wndpl
;
3086 if (!(Window
= UserGetWindowObject(hWnd
)) || !Window
->Wnd
)
3096 ProbeForWrite(rectWnd
,
3102 ProbeForWrite(ptIcon
,
3108 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
3110 SetLastNtError(_SEH2_GetExceptionCode());
3115 wndpl
.length
= sizeof(WINDOWPLACEMENT
);
3117 if (IntGetWindowPlacement(Window
, &wndpl
) && !Hit
)
3123 RtlCopyMemory(rectWnd
, &wndpl
.rcNormalPosition
, sizeof(RECT
));
3127 RtlCopyMemory(ptIcon
, &wndpl
.ptMinPosition
, sizeof(POINT
));
3131 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
3133 SetLastNtError(_SEH2_GetExceptionCode());
3138 if (!Hit
) Ret
= wndpl
.showCmd
;
3147 NtUserGetListBoxInfo(
3151 DECLARE_RETURN(DWORD
);
3153 DPRINT("Enter NtUserGetListBoxInfo\n");
3156 if (!(Wnd
= UserGetWindowObject(hWnd
)))
3161 RETURN( (DWORD
) co_IntSendMessage( Wnd
->hSelf
, LB_GETLISTBOXINFO
, 0, 0 ));
3164 DPRINT("Leave NtUserGetListBoxInfo, ret=%i\n",_ret_
);
3171 co_UserSetParent(HWND hWndChild
, HWND hWndNewParent
)
3173 PWINDOW_OBJECT Wnd
= NULL
, WndParent
= NULL
, WndOldParent
;
3174 HWND hWndOldParent
= NULL
;
3175 USER_REFERENCE_ENTRY Ref
, ParentRef
;
3177 if (IntIsBroadcastHwnd(hWndChild
) || IntIsBroadcastHwnd(hWndNewParent
))
3179 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
3183 if (hWndChild
== IntGetDesktopWindow())
3185 SetLastWin32Error(ERROR_ACCESS_DENIED
);
3191 if (!(WndParent
= UserGetWindowObject(hWndNewParent
)))
3198 if (!(WndParent
= UserGetWindowObject(IntGetDesktopWindow())))
3204 if (!(Wnd
= UserGetWindowObject(hWndChild
)))
3209 UserRefObjectCo(Wnd
, &Ref
);
3210 UserRefObjectCo(WndParent
, &ParentRef
);
3212 WndOldParent
= co_IntSetParent(Wnd
, WndParent
);
3214 UserDerefObjectCo(WndParent
);
3215 UserDerefObjectCo(Wnd
);
3219 hWndOldParent
= WndOldParent
->hSelf
;
3220 UserDereferenceObject(WndOldParent
);
3223 return( hWndOldParent
);
3229 * The NtUserSetParent function changes the parent window of the specified
3233 * The new parent window and the child window must belong to the same
3234 * application. If the window identified by the hWndChild parameter is
3235 * visible, the system performs the appropriate redrawing and repainting.
3236 * For compatibility reasons, NtUserSetParent does not modify the WS_CHILD
3237 * or WS_POPUP window styles of the window whose parent is being changed.
3244 NtUserSetParent(HWND hWndChild
, HWND hWndNewParent
)
3246 DECLARE_RETURN(HWND
);
3248 DPRINT("Enter NtUserSetParent\n");
3249 UserEnterExclusive();
3252 Check Parent first from user space, set it here.
3256 hWndNewParent
= IntGetDesktopWindow();
3258 else if (hWndNewParent
== HWND_MESSAGE
)
3260 hWndNewParent
= IntGetMessageWindow();
3263 RETURN( co_UserSetParent(hWndChild
, hWndNewParent
));
3266 DPRINT("Leave NtUserSetParent, ret=%i\n",_ret_
);
3272 * UserGetShellWindow
3274 * Returns a handle to shell window that was set by NtUserSetShellWindowEx.
3279 HWND FASTCALL
UserGetShellWindow(VOID
)
3281 PWINSTATION_OBJECT WinStaObject
;
3284 NTSTATUS Status
= IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation
,
3289 if (!NT_SUCCESS(Status
))
3291 SetLastNtError(Status
);
3295 Ret
= (HWND
)WinStaObject
->ShellWindow
;
3297 ObDereferenceObject(WinStaObject
);
3302 * NtUserSetShellWindowEx
3304 * This is undocumented function to set global shell window. The global
3305 * shell window has special handling of window position.
3311 NtUserSetShellWindowEx(HWND hwndShell
, HWND hwndListView
)
3313 PWINSTATION_OBJECT WinStaObject
;
3314 PWINDOW_OBJECT WndShell
, WndListView
;
3315 DECLARE_RETURN(BOOL
);
3316 USER_REFERENCE_ENTRY Ref
;
3320 DPRINT("Enter NtUserSetShellWindowEx\n");
3321 UserEnterExclusive();
3323 if (!(WndShell
= UserGetWindowObject(hwndShell
)))
3328 if(!(WndListView
= UserGetWindowObject(hwndListView
)))
3333 Status
= IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation
,
3338 if (!NT_SUCCESS(Status
))
3340 SetLastNtError(Status
);
3345 * Test if we are permitted to change the shell window.
3347 if (WinStaObject
->ShellWindow
)
3349 ObDereferenceObject(WinStaObject
);
3354 * Move shell window into background.
3356 if (hwndListView
&& hwndListView
!= hwndShell
)
3359 * Disabled for now to get Explorer working.
3360 * -- Filip, 01/nov/2003
3363 co_WinPosSetWindowPos(hwndListView
, HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
);
3366 if (WndListView
->Wnd
->ExStyle
& WS_EX_TOPMOST
)
3368 ObDereferenceObject(WinStaObject
);
3373 if (WndShell
->Wnd
->ExStyle
& WS_EX_TOPMOST
)
3375 ObDereferenceObject(WinStaObject
);
3379 UserRefObjectCo(WndShell
, &Ref
);
3380 co_WinPosSetWindowPos(WndShell
, HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
);
3382 WinStaObject
->ShellWindow
= hwndShell
;
3383 WinStaObject
->ShellListView
= hwndListView
;
3385 ti
= GetW32ThreadInfo();
3386 if (ti
->pDeskInfo
) ti
->pDeskInfo
->hShellWindow
= hwndShell
;
3388 UserDerefObjectCo(WndShell
);
3390 ObDereferenceObject(WinStaObject
);
3394 DPRINT("Leave NtUserSetShellWindowEx, ret=%i\n",_ret_
);
3400 * NtUserGetSystemMenu
3402 * The NtUserGetSystemMenu function allows the application to access the
3403 * window menu (also known as the system menu or the control menu) for
3404 * copying and modifying.
3408 * Handle to the window that will own a copy of the window menu.
3410 * Specifies the action to be taken. If this parameter is FALSE,
3411 * NtUserGetSystemMenu returns a handle to the copy of the window menu
3412 * currently in use. The copy is initially identical to the window menu
3413 * but it can be modified.
3414 * If this parameter is TRUE, GetSystemMenu resets the window menu back
3415 * to the default state. The previous window menu, if any, is destroyed.
3418 * If the bRevert parameter is FALSE, the return value is a handle to a
3419 * copy of the window menu. If the bRevert parameter is TRUE, the return
3427 NtUserGetSystemMenu(HWND hWnd
, BOOL bRevert
)
3429 PWINDOW_OBJECT Window
;
3431 DECLARE_RETURN(HMENU
);
3433 DPRINT("Enter NtUserGetSystemMenu\n");
3436 if (!(Window
= UserGetWindowObject(hWnd
)))
3441 if (!(Menu
= IntGetSystemMenu(Window
, bRevert
, FALSE
)))
3446 RETURN(Menu
->MenuInfo
.Self
);
3449 DPRINT("Leave NtUserGetSystemMenu, ret=%i\n",_ret_
);
3455 * NtUserSetSystemMenu
3462 NtUserSetSystemMenu(HWND hWnd
, HMENU hMenu
)
3464 BOOL Result
= FALSE
;
3465 PWINDOW_OBJECT Window
;
3467 DECLARE_RETURN(BOOL
);
3469 DPRINT("Enter NtUserSetSystemMenu\n");
3470 UserEnterExclusive();
3472 if (!(Window
= UserGetWindowObject(hWnd
)))
3480 * Assign new menu handle.
3482 if (!(Menu
= UserGetMenuObject(hMenu
)))
3487 Result
= IntSetSystemMenu(Window
, Menu
);
3493 DPRINT("Leave NtUserSetSystemMenu, ret=%i\n",_ret_
);
3499 co_UserSetWindowLong(HWND hWnd
, DWORD Index
, LONG NewValue
, BOOL Ansi
)
3501 PWINDOW_OBJECT Window
, Parent
;
3503 PWINSTATION_OBJECT WindowStation
;
3507 if (hWnd
== IntGetDesktopWindow())
3509 SetLastWin32Error(STATUS_ACCESS_DENIED
);
3513 if (!(Window
= UserGetWindowObject(hWnd
)))
3520 if (!Wnd
) return 0; // No go on zero.
3522 if ((INT
)Index
>= 0)
3524 if ((Index
+ sizeof(LONG
)) > Wnd
->cbwndExtra
)
3526 SetLastWin32Error(ERROR_INVALID_INDEX
);
3530 OldValue
= *((LONG
*)((PCHAR
)(Wnd
+ 1) + Index
));
3532 if ( Index == DWLP_DLGPROC && Wnd->state & WNDS_DIALOGWINDOW)
3534 OldValue = (LONG)IntSetWindowProc( Wnd,
3537 if (!OldValue) return 0;
3540 *((LONG
*)((PCHAR
)(Wnd
+ 1) + Index
)) = NewValue
;
3547 OldValue
= (LONG
) Wnd
->ExStyle
;
3548 Style
.styleOld
= OldValue
;
3549 Style
.styleNew
= NewValue
;
3552 * Remove extended window style bit WS_EX_TOPMOST for shell windows.
3554 WindowStation
= Window
->pti
->rpdesk
->rpwinstaParent
;
3557 if (hWnd
== WindowStation
->ShellWindow
|| hWnd
== WindowStation
->ShellListView
)
3558 Style
.styleNew
&= ~WS_EX_TOPMOST
;
3561 co_IntSendMessage(hWnd
, WM_STYLECHANGING
, GWL_EXSTYLE
, (LPARAM
) &Style
);
3562 Wnd
->ExStyle
= (DWORD
)Style
.styleNew
;
3563 co_IntSendMessage(hWnd
, WM_STYLECHANGED
, GWL_EXSTYLE
, (LPARAM
) &Style
);
3567 OldValue
= (LONG
) Wnd
->style
;
3568 Style
.styleOld
= OldValue
;
3569 Style
.styleNew
= NewValue
;
3570 co_IntSendMessage(hWnd
, WM_STYLECHANGING
, GWL_STYLE
, (LPARAM
) &Style
);
3571 Wnd
->style
= (DWORD
)Style
.styleNew
;
3572 co_IntSendMessage(hWnd
, WM_STYLECHANGED
, GWL_STYLE
, (LPARAM
) &Style
);
3577 if ( Wnd
->head
.pti
->ppi
!= PsGetCurrentProcessWin32Process() ||
3578 Wnd
->fnid
& FNID_FREED
)
3580 SetLastWin32Error(ERROR_ACCESS_DENIED
);
3583 OldValue
= (LONG
)IntSetWindowProc(Wnd
,
3590 OldValue
= (LONG
) Wnd
->hModule
;
3591 Wnd
->hModule
= (HINSTANCE
) NewValue
;
3594 case GWL_HWNDPARENT
:
3595 Parent
= Window
->spwndParent
;
3596 if (Parent
&& (Parent
->hSelf
== IntGetDesktopWindow()))
3597 OldValue
= (LONG
) IntSetOwner(Window
->hSelf
, (HWND
) NewValue
);
3599 OldValue
= (LONG
) co_UserSetParent(Window
->hSelf
, (HWND
) NewValue
);
3603 OldValue
= (LONG
) Wnd
->IDMenu
;
3604 Wnd
->IDMenu
= (UINT
) NewValue
;
3608 OldValue
= Wnd
->dwUserData
;
3609 Wnd
->dwUserData
= NewValue
;
3613 DPRINT1("NtUserSetWindowLong(): Unsupported index %d\n", Index
);
3614 SetLastWin32Error(ERROR_INVALID_INDEX
);
3624 * NtUserSetWindowLong
3626 * The NtUserSetWindowLong function changes an attribute of the specified
3627 * window. The function also sets the 32-bit (long) value at the specified
3628 * offset into the extra window memory.
3635 NtUserSetWindowLong(HWND hWnd
, DWORD Index
, LONG NewValue
, BOOL Ansi
)
3637 DECLARE_RETURN(LONG
);
3639 DPRINT("Enter NtUserSetWindowLong\n");
3640 UserEnterExclusive();
3642 RETURN( co_UserSetWindowLong(hWnd
, Index
, NewValue
, Ansi
));
3645 DPRINT("Leave NtUserSetWindowLong, ret=%i\n",_ret_
);
3651 * NtUserSetWindowWord
3653 * Legacy function similar to NtUserSetWindowLong.
3660 NtUserSetWindowWord(HWND hWnd
, INT Index
, WORD NewValue
)
3662 PWINDOW_OBJECT Window
;
3664 DECLARE_RETURN(WORD
);
3666 DPRINT("Enter NtUserSetWindowWord\n");
3667 UserEnterExclusive();
3669 if (!(Window
= UserGetWindowObject(hWnd
)))
3678 case GWL_HWNDPARENT
:
3679 RETURN( co_UserSetWindowLong(Window
->hSelf
, Index
, (UINT
)NewValue
, TRUE
));
3683 SetLastWin32Error(ERROR_INVALID_INDEX
);
3688 if (Index
> Window
->Wnd
->cbwndExtra
- sizeof(WORD
))
3690 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
3694 OldValue
= *((WORD
*)((PCHAR
)(Window
->Wnd
+ 1) + Index
));
3695 *((WORD
*)((PCHAR
)(Window
->Wnd
+ 1) + Index
)) = NewValue
;
3700 DPRINT("Leave NtUserSetWindowWord, ret=%i\n",_ret_
);
3709 NtUserGetWindowPlacement(HWND hWnd
,
3710 WINDOWPLACEMENT
*lpwndpl
)
3712 PWINDOW_OBJECT Window
;
3715 WINDOWPLACEMENT Safepl
;
3717 DECLARE_RETURN(BOOL
);
3719 DPRINT("Enter NtUserGetWindowPlacement\n");
3722 if (!(Window
= UserGetWindowObject(hWnd
)))
3728 Status
= MmCopyFromCaller(&Safepl
, lpwndpl
, sizeof(WINDOWPLACEMENT
));
3729 if(!NT_SUCCESS(Status
))
3731 SetLastNtError(Status
);
3734 if(Safepl
.length
!= sizeof(WINDOWPLACEMENT
))
3740 if (0 == (Wnd
->style
& WS_VISIBLE
))
3742 Safepl
.showCmd
= SW_HIDE
;
3744 else if ((0 != (Window
->state
& WINDOWOBJECT_RESTOREMAX
) ||
3745 0 != (Wnd
->style
& WS_MAXIMIZE
)) &&
3746 0 == (Wnd
->style
& WS_MINIMIZE
))
3748 Safepl
.showCmd
= SW_SHOWMAXIMIZED
;
3750 else if (0 != (Wnd
->style
& WS_MINIMIZE
))
3752 Safepl
.showCmd
= SW_SHOWMINIMIZED
;
3754 else if (0 != (Wnd
->style
& WS_VISIBLE
))
3756 Safepl
.showCmd
= SW_SHOWNORMAL
;
3759 Size
.x
= Wnd
->rcWindow
.left
;
3760 Size
.y
= Wnd
->rcWindow
.top
;
3761 WinPosInitInternalPos(Window
, &Size
,
3764 Safepl
.rcNormalPosition
= Wnd
->InternalPos
.NormalRect
;
3765 Safepl
.ptMinPosition
= Wnd
->InternalPos
.IconPos
;
3766 Safepl
.ptMaxPosition
= Wnd
->InternalPos
.MaxPos
;
3768 Status
= MmCopyToCaller(lpwndpl
, &Safepl
, sizeof(WINDOWPLACEMENT
));
3769 if(!NT_SUCCESS(Status
))
3771 SetLastNtError(Status
);
3778 DPRINT("Leave NtUserGetWindowPlacement, ret=%i\n",_ret_
);
3788 NtUserLockWindowUpdate(HWND hWnd
)
3808 return NtUserSetWindowPos(hWnd
, 0, X
, Y
, nWidth
, nHeight
,
3809 (bRepaint
? SWP_NOZORDER
| SWP_NOACTIVATE
:
3810 SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOREDRAW
));
3814 QueryWindow based on KJK::Hyperion and James Tabor.
3816 0 = QWUniqueProcessId
3817 1 = QWUniqueThreadId
3820 4 = QWIsHung Implements IsHungAppWindow found
3823 9 = QWKillWindow When I called this with hWnd ==
3824 DesktopWindow, it shutdown the system
3831 NtUserQueryWindow(HWND hWnd
, DWORD Index
)
3833 PWINDOW_OBJECT Window
;
3836 DECLARE_RETURN(UINT
);
3838 DPRINT("Enter NtUserQueryWindow\n");
3841 if (!(Window
= UserGetWindowObject(hWnd
)) || !Window
->Wnd
)
3850 case QUERY_WINDOW_UNIQUE_PROCESS_ID
:
3851 Result
= (DWORD
)IntGetWndProcessId(Window
);
3854 case QUERY_WINDOW_UNIQUE_THREAD_ID
:
3855 Result
= (DWORD
)IntGetWndThreadId(Window
);
3858 case QUERY_WINDOW_ACTIVE
:
3859 Result
= (DWORD
)UserGetActiveWindow();
3862 case QUERY_WINDOW_FOCUS
:
3863 Result
= (DWORD
)IntGetFocusWindow();
3866 case QUERY_WINDOW_ISHUNG
:
3867 Result
= (DWORD
)MsqIsHung(Window
->pti
->MessageQueue
);
3870 case QUERY_WINDOW_REAL_ID
:
3871 Result
= (DWORD
)pWnd
->head
.pti
->pEThread
->Cid
.UniqueProcess
;
3874 Result
= (DWORD
)NULL
;
3881 DPRINT("Leave NtUserQueryWindow, ret=%i\n",_ret_
);
3891 NtUserRealChildWindowFromPoint(DWORD Unknown0
,
3905 NtUserRegisterWindowMessage(PUNICODE_STRING MessageNameUnsafe
)
3907 UNICODE_STRING SafeMessageName
;
3910 DECLARE_RETURN(UINT
);
3912 DPRINT("Enter NtUserRegisterWindowMessage\n");
3913 UserEnterExclusive();
3915 if(MessageNameUnsafe
== NULL
)
3917 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
3921 Status
= IntSafeCopyUnicodeStringTerminateNULL(&SafeMessageName
, MessageNameUnsafe
);
3922 if(!NT_SUCCESS(Status
))
3924 SetLastNtError(Status
);
3928 Ret
= (UINT
)IntAddAtom(SafeMessageName
.Buffer
);
3929 if (SafeMessageName
.Buffer
)
3930 ExFreePoolWithTag(SafeMessageName
.Buffer
, TAG_STRING
);
3934 DPRINT("Leave NtUserRegisterWindowMessage, ret=%i\n",_ret_
);
3944 NtUserSetImeOwnerWindow(DWORD Unknown0
,
3957 NtUserSetInternalWindowPos(
3974 NtUserSetLayeredWindowAttributes(HWND hwnd
,
3988 NtUserSetLogonNotifyWindow(HWND hWnd
)
4005 PWINDOW_OBJECT Window
;
4007 DECLARE_RETURN(BOOL
);
4009 DPRINT("Enter NtUserSetMenu\n");
4010 UserEnterExclusive();
4012 if (!(Window
= UserGetWindowObject(hWnd
)))
4017 if (! IntSetMenu(Window
, Menu
, &Changed
))
4022 if (Changed
&& Repaint
)
4024 USER_REFERENCE_ENTRY Ref
;
4026 UserRefObjectCo(Window
, &Ref
);
4027 co_WinPosSetWindowPos(Window
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
4028 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
4030 UserDerefObjectCo(Window
);
4036 DPRINT("Leave NtUserSetMenu, ret=%i\n",_ret_
);
4046 NtUserSetWindowFNID(HWND hWnd
,
4049 PWINDOW_OBJECT Window
;
4051 DECLARE_RETURN(BOOL
);
4053 DPRINT("Enter NtUserSetWindowFNID\n");
4054 UserEnterExclusive();
4056 if (!(Window
= UserGetWindowObject(hWnd
)))
4063 { // From user land we only set these.
4064 if ((fnID
!= FNID_DESTROY
) || ((fnID
< FNID_BUTTON
) && (fnID
> FNID_IME
)) )
4069 Wnd
->pcls
->fnid
|= fnID
;
4074 DPRINT("Leave NtUserSetWindowFNID\n");
4084 NtUserSetWindowPlacement(HWND hWnd
,
4085 WINDOWPLACEMENT
*lpwndpl
)
4087 PWINDOW_OBJECT Window
;
4089 WINDOWPLACEMENT Safepl
;
4091 DECLARE_RETURN(BOOL
);
4092 USER_REFERENCE_ENTRY Ref
;
4094 DPRINT("Enter NtUserSetWindowPlacement\n");
4095 UserEnterExclusive();
4097 if (!(Window
= UserGetWindowObject(hWnd
)))
4103 Status
= MmCopyFromCaller(&Safepl
, lpwndpl
, sizeof(WINDOWPLACEMENT
));
4104 if(!NT_SUCCESS(Status
))
4106 SetLastNtError(Status
);
4109 if(Safepl
.length
!= sizeof(WINDOWPLACEMENT
))
4114 UserRefObjectCo(Window
, &Ref
);
4116 if ((Wnd
->style
& (WS_MAXIMIZE
| WS_MINIMIZE
)) == 0)
4118 co_WinPosSetWindowPos(Window
, NULL
,
4119 Safepl
.rcNormalPosition
.left
, Safepl
.rcNormalPosition
.top
,
4120 Safepl
.rcNormalPosition
.right
- Safepl
.rcNormalPosition
.left
,
4121 Safepl
.rcNormalPosition
.bottom
- Safepl
.rcNormalPosition
.top
,
4122 SWP_NOZORDER
| SWP_NOACTIVATE
);
4125 /* FIXME - change window status */
4126 co_WinPosShowWindow(Window
, Safepl
.showCmd
);
4128 Wnd
->InternalPosInitialized
= TRUE
;
4129 Wnd
->InternalPos
.NormalRect
= Safepl
.rcNormalPosition
;
4130 Wnd
->InternalPos
.IconPos
= Safepl
.ptMinPosition
;
4131 Wnd
->InternalPos
.MaxPos
= Safepl
.ptMaxPosition
;
4133 UserDerefObjectCo(Window
);
4137 DPRINT("Leave NtUserSetWindowPlacement, ret=%i\n",_ret_
);
4149 HWND hWndInsertAfter
,
4156 DECLARE_RETURN(BOOL
);
4157 PWINDOW_OBJECT Window
;
4159 USER_REFERENCE_ENTRY Ref
;
4161 DPRINT("Enter NtUserSetWindowPos\n");
4162 UserEnterExclusive();
4164 if (!(Window
= UserGetWindowObject(hWnd
)))
4169 /* First make sure that coordinates are valid for WM_WINDOWPOSCHANGING */
4170 if (!(uFlags
& SWP_NOMOVE
))
4172 if (X
< -32768) X
= -32768;
4173 else if (X
> 32767) X
= 32767;
4174 if (Y
< -32768) Y
= -32768;
4175 else if (Y
> 32767) Y
= 32767;
4177 if (!(uFlags
& SWP_NOSIZE
))
4180 else if (cx
> 32767) cx
= 32767;
4182 else if (cy
> 32767) cy
= 32767;
4185 UserRefObjectCo(Window
, &Ref
);
4186 ret
= co_WinPosSetWindowPos(Window
, hWndInsertAfter
, X
, Y
, cx
, cy
, uFlags
);
4187 UserDerefObjectCo(Window
);
4192 DPRINT("Leave NtUserSetWindowPos, ret=%i\n",_ret_
);
4199 IntGetWindowRgn(PWINDOW_OBJECT Window
, HRGN hRgn
)
4217 /* Create a new window region using the window rectangle */
4218 VisRgn
= IntSysCreateRectRgnIndirect(&Window
->Wnd
->rcWindow
);
4219 NtGdiOffsetRgn(VisRgn
, -Window
->Wnd
->rcWindow
.left
, -Window
->Wnd
->rcWindow
.top
);
4220 /* if there's a region assigned to the window, combine them both */
4221 if(Window
->hrgnClip
&& !(Wnd
->style
& WS_MINIMIZE
))
4222 NtGdiCombineRgn(VisRgn
, VisRgn
, Window
->hrgnClip
, RGN_AND
);
4223 /* Copy the region into hRgn */
4224 NtGdiCombineRgn(hRgn
, VisRgn
, NULL
, RGN_COPY
);
4226 if((pRgn
= RGNOBJAPI_Lock(hRgn
, NULL
)))
4228 Ret
= pRgn
->rdh
.iType
;
4229 RGNOBJAPI_Unlock(pRgn
);
4234 REGION_FreeRgnByHandle(VisRgn
);
4240 IntGetWindowRgnBox(PWINDOW_OBJECT Window
, RECTL
*Rect
)
4258 /* Create a new window region using the window rectangle */
4259 VisRgn
= IntSysCreateRectRgnIndirect(&Window
->Wnd
->rcWindow
);
4260 NtGdiOffsetRgn(VisRgn
, -Window
->Wnd
->rcWindow
.left
, -Window
->Wnd
->rcWindow
.top
);
4261 /* if there's a region assigned to the window, combine them both */
4262 if(Window
->hrgnClip
&& !(Wnd
->style
& WS_MINIMIZE
))
4263 NtGdiCombineRgn(VisRgn
, VisRgn
, Window
->hrgnClip
, RGN_AND
);
4265 if((pRgn
= RGNOBJAPI_Lock(VisRgn
, NULL
)))
4267 Ret
= pRgn
->rdh
.iType
;
4268 *Rect
= pRgn
->rdh
.rcBound
;
4269 RGNOBJAPI_Unlock(pRgn
);
4274 REGION_FreeRgnByHandle(VisRgn
);
4290 PWINDOW_OBJECT Window
;
4291 DECLARE_RETURN(INT
);
4293 DPRINT("Enter NtUserSetWindowRgn\n");
4294 UserEnterExclusive();
4296 if (!(Window
= UserGetWindowObject(hWnd
)))
4301 if (hRgn
) // The region will be deleted in user32.
4303 if (GDIOBJ_ValidateHandle(hRgn
, GDI_OBJECT_TYPE_REGION
))
4305 hrgnCopy
= IntSysCreateRectRgn(0, 0, 0, 0);
4306 NtGdiCombineRgn(hrgnCopy
, hRgn
, 0, RGN_COPY
);
4312 hrgnCopy
= (HRGN
) 1;
4314 if (Window
->hrgnClip
)
4316 /* Delete no longer needed region handle */
4317 GreDeleteObject(Window
->hrgnClip
);
4319 Window
->hrgnClip
= hrgnCopy
;
4321 /* FIXME - send WM_WINDOWPOSCHANGING and WM_WINDOWPOSCHANGED messages to the window */
4325 USER_REFERENCE_ENTRY Ref
;
4326 UserRefObjectCo(Window
, &Ref
);
4327 co_UserRedrawWindow(Window
, NULL
, NULL
, RDW_INVALIDATE
);
4328 UserDerefObjectCo(Window
);
4334 DPRINT("Leave NtUserSetWindowRgn, ret=%i\n",_ret_
);
4344 NtUserShowWindow(HWND hWnd
, LONG nCmdShow
)
4346 PWINDOW_OBJECT Window
;
4348 DECLARE_RETURN(BOOL
);
4349 USER_REFERENCE_ENTRY Ref
;
4351 DPRINT("Enter NtUserShowWindow\n");
4352 UserEnterExclusive();
4354 if (!(Window
= UserGetWindowObject(hWnd
)))
4359 UserRefObjectCo(Window
, &Ref
);
4360 ret
= co_WinPosShowWindow(Window
, nCmdShow
);
4361 UserDerefObjectCo(Window
);
4366 DPRINT("Leave NtUserShowWindow, ret=%i\n",_ret_
);
4376 NtUserShowWindowAsync(HWND hWnd
, LONG nCmdShow
)
4382 return NtUserShowWindow(hWnd
, nCmdShow
);
4392 NtUserUpdateLayeredWindow(
4400 BLENDFUNCTION
*pblend
,
4413 NtUserWindowFromPhysicalPoint(POINT Point
)
4424 NtUserWindowFromPoint(LONG X
, LONG Y
)
4428 PWINDOW_OBJECT DesktopWindow
= NULL
, Window
= NULL
;
4429 DECLARE_RETURN(HWND
);
4430 USER_REFERENCE_ENTRY Ref
;
4432 DPRINT("Enter NtUserWindowFromPoint\n");
4433 UserEnterExclusive();
4435 if ((DesktopWindow
= UserGetWindowObject(IntGetDesktopWindow())))
4442 //hmm... threads live on desktops thus we have a reference on the desktop and indirectly the desktop window
4443 //its possible this referencing is useless, thou it shouldnt hurt...
4444 UserRefObjectCo(DesktopWindow
, &Ref
);
4446 pti
= PsGetCurrentThreadWin32Thread();
4447 co_WinPosWindowFromPoint(DesktopWindow
, pti
->MessageQueue
, &pt
, &Window
);
4451 Ret
= Window
->hSelf
;
4460 if (Window
) UserDereferenceObject(Window
);
4461 if (DesktopWindow
) UserDerefObjectCo(DesktopWindow
);
4463 DPRINT("Leave NtUserWindowFromPoint, ret=%i\n",_ret_
);
4473 * Undocumented function that is called from DefWindowProc to set
4480 NtUserDefSetText(HWND hWnd
, PLARGE_STRING WindowText
)
4482 PWINDOW_OBJECT Window
;
4484 LARGE_STRING SafeText
;
4485 UNICODE_STRING UnicodeString
;
4488 DPRINT("Enter NtUserDefSetText\n");
4490 if (WindowText
!= NULL
)
4494 SafeText
= ProbeForReadLargeString(WindowText
);
4496 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
4499 SetLastNtError(_SEH2_GetExceptionCode());
4509 UserEnterExclusive();
4511 if(!(Window
= UserGetWindowObject(hWnd
)) || !Window
->Wnd
)
4518 // ReactOS uses Unicode and not mixed. Up/Down converting will take time.
4519 // Brought to you by: The Wine Project! Dysfunctional Thought Processes!
4520 // Now we know what the bAnsi is for.
4521 RtlInitUnicodeString(&UnicodeString
, NULL
);
4522 if (SafeText
.Buffer
)
4527 ProbeForRead(SafeText
.Buffer
, SafeText
.Length
, sizeof(CHAR
));
4529 ProbeForRead(SafeText
.Buffer
, SafeText
.Length
, sizeof(WCHAR
));
4530 Ret
= RtlLargeStringToUnicodeString(&UnicodeString
, &SafeText
);
4532 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
4535 SetLastNtError(_SEH2_GetExceptionCode());
4538 if (!Ret
) goto Exit
;
4541 if (UnicodeString
.Length
!= 0)
4543 if (Wnd
->strName
.MaximumLength
> 0 &&
4544 UnicodeString
.Length
<= Wnd
->strName
.MaximumLength
- sizeof(UNICODE_NULL
))
4546 ASSERT(Wnd
->strName
.Buffer
!= NULL
);
4548 Wnd
->strName
.Length
= UnicodeString
.Length
;
4549 Wnd
->strName
.Buffer
[UnicodeString
.Length
/ sizeof(WCHAR
)] = L
'\0';
4550 RtlCopyMemory(Wnd
->strName
.Buffer
,
4551 UnicodeString
.Buffer
,
4552 UnicodeString
.Length
);
4557 Wnd
->strName
.MaximumLength
= Wnd
->strName
.Length
= 0;
4558 buf
= Wnd
->strName
.Buffer
;
4559 Wnd
->strName
.Buffer
= NULL
;
4562 DesktopHeapFree(Wnd
->head
.rpdesk
, buf
);
4565 Wnd
->strName
.Buffer
= DesktopHeapAlloc(Wnd
->head
.rpdesk
,
4566 UnicodeString
.Length
+ sizeof(UNICODE_NULL
));
4567 if (Wnd
->strName
.Buffer
!= NULL
)
4569 Wnd
->strName
.Buffer
[UnicodeString
.Length
/ sizeof(WCHAR
)] = L
'\0';
4570 RtlCopyMemory(Wnd
->strName
.Buffer
,
4571 UnicodeString
.Buffer
,
4572 UnicodeString
.Length
);
4573 Wnd
->strName
.MaximumLength
= UnicodeString
.Length
+ sizeof(UNICODE_NULL
);
4574 Wnd
->strName
.Length
= UnicodeString
.Length
;
4578 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
4586 Wnd
->strName
.Length
= 0;
4587 if (Wnd
->strName
.Buffer
!= NULL
)
4588 Wnd
->strName
.Buffer
[0] = L
'\0';
4591 // HAX! FIXME! Windows does not do this in here!
4592 // In User32, these are called after: NotifyWinEvent EVENT_OBJECT_NAMECHANGE than
4593 // RepaintButton, StaticRepaint, NtUserCallHwndLock HWNDLOCK_ROUTINE_REDRAWFRAMEANDHOOK, etc.
4594 /* Send shell notifications */
4595 if (!Window
->spwndOwner
&& !IntGetParent(Window
))
4597 co_IntShellHookNotify(HSHELL_REDRAW
, (LPARAM
) hWnd
);
4602 if (UnicodeString
.Buffer
) RtlFreeUnicodeString(&UnicodeString
);
4603 DPRINT("Leave NtUserDefSetText, ret=%i\n", Ret
);
4609 * NtUserInternalGetWindowText
4616 NtUserInternalGetWindowText(HWND hWnd
, LPWSTR lpString
, INT nMaxCount
)
4618 PWINDOW_OBJECT Window
;
4622 DECLARE_RETURN(INT
);
4624 DPRINT("Enter NtUserInternalGetWindowText\n");
4627 if(lpString
&& (nMaxCount
<= 1))
4629 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
4633 if(!(Window
= UserGetWindowObject(hWnd
)))
4639 Result
= Wnd
->strName
.Length
/ sizeof(WCHAR
);
4642 const WCHAR Terminator
= L
'\0';
4644 WCHAR
*Buffer
= (WCHAR
*)lpString
;
4646 Copy
= min(nMaxCount
- 1, Result
);
4649 Status
= MmCopyToCaller(Buffer
, Wnd
->strName
.Buffer
, Copy
* sizeof(WCHAR
));
4650 if(!NT_SUCCESS(Status
))
4652 SetLastNtError(Status
);
4658 Status
= MmCopyToCaller(Buffer
, &Terminator
, sizeof(WCHAR
));
4659 if(!NT_SUCCESS(Status
))
4661 SetLastNtError(Status
);
4671 DPRINT("Leave NtUserInternalGetWindowText, ret=%i\n",_ret_
);
4679 IntShowOwnedPopups(PWINDOW_OBJECT OwnerWnd
, BOOL fShow
)
4682 PWINDOW_OBJECT pWnd
;
4685 // ASSERT(OwnerWnd);
4687 win_array
= IntWinListChildren(UserGetWindowObject(IntGetDesktopWindow()));
4692 while (win_array
[count
])
4694 while (--count
>= 0)
4696 if (!(pWnd
= UserGetWindowObject( win_array
[count
] )))
4698 if (pWnd
->spwndOwner
!= OwnerWnd
)
4703 if (pWnd
->Wnd
->state
& WNDS_HIDDENPOPUP
)
4705 /* In Windows, ShowOwnedPopups(TRUE) generates
4706 * WM_SHOWWINDOW messages with SW_PARENTOPENING,
4707 * regardless of the state of the owner
4709 co_IntSendMessage(win_array
[count
], WM_SHOWWINDOW
, SW_SHOWNORMAL
, SW_PARENTOPENING
);
4715 if (pWnd
->Wnd
->style
& WS_VISIBLE
)
4717 /* In Windows, ShowOwnedPopups(FALSE) generates
4718 * WM_SHOWWINDOW messages with SW_PARENTCLOSING,
4719 * regardless of the state of the owner
4721 co_IntSendMessage(win_array
[count
], WM_SHOWWINDOW
, SW_HIDE
, SW_PARENTCLOSING
);
4727 ExFreePool( win_array
);
4732 * NtUserValidateHandleSecure
4740 NtUserValidateHandleSecure(
4748 PUSER_HANDLE_ENTRY entry
;
4749 if (!(entry
= handle_to_entry(gHandleTable
, handle
)))
4751 SetLastWin32Error(ERROR_INVALID_HANDLE
);
4754 uType
= entry
->type
;
4760 PWINDOW_OBJECT Window
;
4761 if ((Window
= UserGetWindowObject((HWND
) handle
))) return TRUE
;
4767 if ((Menu
= UserGetMenuObject((HMENU
) handle
))) return TRUE
;
4772 PACCELERATOR_TABLE Accel
;
4773 if ((Accel
= UserGetAccelObject((HACCEL
) handle
))) return TRUE
;
4778 PCURICON_OBJECT Cursor
;
4779 if ((Cursor
= UserGetCurIconObject((HCURSOR
) handle
))) return TRUE
;
4785 if ((Hook
= IntGetHookObject((HHOOK
) handle
))) return TRUE
;
4791 if ((Monitor
= UserGetMonitorObject((HMONITOR
) handle
))) return TRUE
;
4797 return UserGetCallProcInfo( handle
, &Proc
);
4800 SetLastWin32Error(ERROR_INVALID_HANDLE
);
4804 { /* Is handle entry restricted? */