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);
1571 ProcessParams
= PsGetCurrentProcess()->Peb
->ProcessParameters
;
1573 if (IS_DEFAULT(Cs
->x
))
1575 if (!IS_DEFAULT(Cs
->y
)) *dwShowMode
= Cs
->y
;
1577 if(ProcessParams
->WindowFlags
& STARTF_USEPOSITION
)
1579 Cs
->x
= ProcessParams
->StartingX
;
1580 Cs
->y
= ProcessParams
->StartingY
;
1584 Cs
->x
= WorkArea
.left
;
1585 Cs
->y
= WorkArea
.top
;
1589 if (IS_DEFAULT(Cs
->cx
))
1591 if (ProcessParams
->WindowFlags
& STARTF_USEPOSITION
)
1593 Cs
->cx
= ProcessParams
->CountX
;
1594 Cs
->cy
= ProcessParams
->CountY
;
1598 Cs
->cx
= (WorkArea
.right
- WorkArea
.left
) * 3 / 4 - Cs
->x
;
1599 Cs
->cy
= (WorkArea
.bottom
- WorkArea
.top
) * 3 / 4 - Cs
->y
;
1602 /* neither x nor cx are default. Check the y values .
1603 * In the trace we see Outlook and Outlook Express using
1604 * cy set to CW_USEDEFAULT when opening the address book.
1606 else if (IS_DEFAULT(Cs
->cy
))
1608 DPRINT("Strange use of CW_USEDEFAULT in nHeight\n");
1609 Cs
->cy
= (WorkArea
.bottom
- WorkArea
.top
) * 3 / 4 - Cs
->y
;
1614 /* if CW_USEDEFAULT is set for non-overlapped windows, both values are set to zero */
1615 if(IS_DEFAULT(Cs
->x
))
1620 if(IS_DEFAULT(Cs
->cx
))
1630 /* Allocates and initializes a window*/
1631 PWINDOW_OBJECT FASTCALL
IntCreateWindow(CREATESTRUCTW
* Cs
,
1632 PLARGE_STRING WindowName
,
1634 PWINDOW_OBJECT ParentWindow
,
1635 PWINDOW_OBJECT OwnerWindow
)
1638 PWINDOW_OBJECT Window
;
1640 PTHREADINFO pti
= NULL
;
1641 PMENU_OBJECT SystemMenu
;
1643 BOOL bUnicodeWindow
;
1645 pti
= PsGetCurrentThreadWin32Thread();
1647 /* Automatically add WS_EX_WINDOWEDGE */
1648 if ((Cs
->dwExStyle
& WS_EX_DLGMODALFRAME
) ||
1649 ((!(Cs
->dwExStyle
& WS_EX_STATICEDGE
)) &&
1650 (Cs
->style
& (WS_DLGFRAME
| WS_THICKFRAME
))))
1651 Cs
->dwExStyle
|= WS_EX_WINDOWEDGE
;
1653 Cs
->dwExStyle
&= ~WS_EX_WINDOWEDGE
;
1655 /* Is it a unicode window? */
1656 bUnicodeWindow
=!(Cs
->dwExStyle
& WS_EX_SETANSICREATOR
);
1657 Cs
->dwExStyle
&= ~WS_EX_SETANSICREATOR
;
1659 /* Allocate the new window */
1660 Window
= (PWINDOW_OBJECT
) UserCreateObject( gHandleTable
,
1664 sizeof(WINDOW_OBJECT
));
1666 Wnd
= DesktopHeapAlloc(pti
->rpdesk
, sizeof(WND
) + Class
->cbwndExtra
);
1673 RtlZeroMemory(Wnd
, sizeof(WND
) + Class
->cbwndExtra
);
1675 DPRINT("Created object with handle %X\n", hWnd
);
1677 if (NULL
== pti
->rpdesk
->DesktopWindow
)
1679 /* If there is no desktop window yet, we must be creating it */
1680 pti
->rpdesk
->DesktopWindow
= hWnd
;
1681 pti
->rpdesk
->pDeskInfo
->spwnd
= Wnd
;
1685 * Fill out the structure describing it.
1689 Window
->hSelf
= hWnd
;
1690 Window
->spwndParent
= ParentWindow
;
1691 Window
->spwndOwner
= OwnerWindow
;
1694 Wnd
->head
.pti
= pti
;
1695 Wnd
->head
.rpdesk
= pti
->rpdesk
;
1697 Wnd
->hWndLastActive
= hWnd
;
1698 Wnd
->state2
|= WNDS2_WIN40COMPAT
;
1700 Wnd
->hModule
= Cs
->hInstance
;
1701 Wnd
->style
= Cs
->style
& ~WS_VISIBLE
;
1702 Wnd
->ExStyle
= Cs
->dwExStyle
;
1703 Wnd
->cbwndExtra
= Wnd
->pcls
->cbwndExtra
;
1704 Wnd
->spwndOwner
= OwnerWindow
? OwnerWindow
->Wnd
: NULL
;
1705 Wnd
->spwndParent
= ParentWindow
? ParentWindow
->Wnd
: NULL
;
1707 IntReferenceMessageQueue(Window
->pti
->MessageQueue
);
1708 if (Wnd
->spwndParent
!= NULL
&& Cs
->hwndParent
!= 0)
1710 Wnd
->HideFocus
= Wnd
->spwndParent
->HideFocus
;
1711 Wnd
->HideAccel
= Wnd
->spwndParent
->HideAccel
;
1714 if (Wnd
->pcls
->CSF_flags
& CSF_SERVERSIDEPROC
)
1715 Wnd
->state
|= WNDS_SERVERSIDEWINDOWPROC
;
1717 /* BugBoy Comments: Comment below say that System classes are always created
1718 as UNICODE. In windows, creating a window with the ANSI version of CreateWindow
1719 sets the window to ansi as verified by testing with IsUnicodeWindow API.
1721 No where can I see in code or through testing does the window change back
1722 to ANSI after being created as UNICODE in ROS. I didnt do more testing to
1723 see what problems this would cause.*/
1725 // Set WndProc from Class.
1726 Wnd
->lpfnWndProc
= Wnd
->pcls
->lpfnWndProc
;
1728 // GetWindowProc, test for non server side default classes and set WndProc.
1729 if ( Wnd
->pcls
->fnid
<= FNID_GHOST
&& Wnd
->pcls
->fnid
>= FNID_BUTTON
)
1733 if (GETPFNCLIENTA(Wnd
->pcls
->fnid
) == Wnd
->lpfnWndProc
)
1734 Wnd
->lpfnWndProc
= GETPFNCLIENTW(Wnd
->pcls
->fnid
);
1738 if (GETPFNCLIENTW(Wnd
->pcls
->fnid
) == Wnd
->lpfnWndProc
)
1739 Wnd
->lpfnWndProc
= GETPFNCLIENTA(Wnd
->pcls
->fnid
);
1743 // If not an Unicode caller, set Ansi creator bit.
1744 if (!bUnicodeWindow
) Wnd
->state
|= WNDS_ANSICREATOR
;
1746 // Clone Class Ansi/Unicode proc type.
1747 if (Wnd
->pcls
->CSF_flags
& CSF_ANSIPROC
)
1749 Wnd
->state
|= WNDS_ANSIWINDOWPROC
;
1750 Wnd
->Unicode
= FALSE
;
1754 It seems there can be both an Ansi creator and Unicode Class Window
1755 WndProc, unless the following overriding conditions occur:
1757 if ( !bUnicodeWindow
&&
1758 ( Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_BUTTON
] ||
1759 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_COMBOBOX
] ||
1760 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_COMBOLBOX
] ||
1761 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_DIALOG
] ||
1762 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_EDIT
] ||
1763 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_IME
] ||
1764 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_LISTBOX
] ||
1765 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_MDICLIENT
] ||
1766 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_STATIC
] ) )
1767 { // Override Class and set the window Ansi WndProc.
1768 Wnd
->state
|= WNDS_ANSIWINDOWPROC
;
1769 Wnd
->Unicode
= FALSE
;
1772 { // Set the window Unicode WndProc.
1773 Wnd
->state
&= ~WNDS_ANSIWINDOWPROC
;
1774 Wnd
->Unicode
= TRUE
;
1778 /* BugBoy Comments: if the window being created is a edit control, ATOM 0xCxxx,
1779 then my testing shows that windows (2k and XP) creates a CallProc for it immediately
1780 Dont understand why it does this. */
1781 if (Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_EDIT
])
1783 PCALLPROCDATA CallProc
;
1784 //CallProc = CreateCallProc(NULL, Wnd->lpfnWndProc, bUnicodeWindow, Wnd->ti->ppi);
1785 CallProc
= CreateCallProc(NULL
, Wnd
->lpfnWndProc
, Wnd
->Unicode
, Wnd
->head
.pti
->ppi
);
1789 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
1790 DPRINT1("Warning: Unable to create CallProc for edit control. Control may not operate correctly! hwnd %x\n",hWnd
);
1794 UserAddCallProcToClass(Wnd
->pcls
, CallProc
);
1798 InitializeListHead(&Wnd
->PropListHead
);
1800 if ( WindowName
->Buffer
!= NULL
&& WindowName
->Length
> 0 )
1802 Wnd
->strName
.Buffer
= DesktopHeapAlloc(Wnd
->head
.rpdesk
,
1803 WindowName
->Length
+ sizeof(UNICODE_NULL
));
1804 if (Wnd
->strName
.Buffer
== NULL
)
1809 RtlCopyMemory(Wnd
->strName
.Buffer
, WindowName
->Buffer
, WindowName
->Length
);
1810 Wnd
->strName
.Buffer
[WindowName
->Length
/ sizeof(WCHAR
)] = L
'\0';
1811 Wnd
->strName
.Length
= WindowName
->Length
;
1814 /* Correct the window style. */
1815 if ((Wnd
->style
& (WS_CHILD
| WS_POPUP
)) != WS_CHILD
)
1817 Wnd
->style
|= WS_CLIPSIBLINGS
;
1818 if (!(Wnd
->style
& WS_POPUP
))
1820 Wnd
->style
|= WS_CAPTION
;
1821 Window
->state
|= WINDOWOBJECT_NEED_SIZE
;
1825 if ((Wnd
->ExStyle
& WS_EX_DLGMODALFRAME
) ||
1826 (Wnd
->style
& (WS_DLGFRAME
| WS_THICKFRAME
)))
1827 Wnd
->ExStyle
|= WS_EX_WINDOWEDGE
;
1829 Wnd
->ExStyle
&= ~WS_EX_WINDOWEDGE
;
1831 /* create system menu */
1832 if((Cs
->style
& WS_SYSMENU
) )//&& (dwStyle & WS_CAPTION) == WS_CAPTION)
1834 SystemMenu
= IntGetSystemMenu(Window
, TRUE
, TRUE
);
1837 Window
->SystemMenu
= SystemMenu
->MenuInfo
.Self
;
1838 IntReleaseMenuObject(SystemMenu
);
1842 /* Set the window menu */
1843 if ((Cs
->style
& (WS_CHILD
| WS_POPUP
)) != WS_CHILD
)
1846 IntSetMenu(Window
, Cs
->hMenu
, &MenuChanged
);
1847 else if (Wnd
->pcls
->lpszMenuName
) // Take it from the parent.
1849 UNICODE_STRING MenuName
;
1852 if (IS_INTRESOURCE(Wnd
->pcls
->lpszMenuName
))
1854 MenuName
.Length
= 0;
1855 MenuName
.MaximumLength
= 0;
1856 MenuName
.Buffer
= Wnd
->pcls
->lpszMenuName
;
1860 RtlInitUnicodeString( &MenuName
, Wnd
->pcls
->lpszMenuName
);
1862 hMenu
= co_IntCallLoadMenu( Wnd
->pcls
->hModule
, &MenuName
);
1863 if (hMenu
) IntSetMenu(Window
, hMenu
, &MenuChanged
);
1867 Wnd
->IDMenu
= (UINT
) Cs
->hMenu
;
1869 /* Insert the window into the thread's window list. */
1870 InsertTailList (&pti
->WindowListHead
, &Window
->ThreadListEntry
);
1872 /* Handle "CS_CLASSDC", it is tested first. */
1873 if ( (Wnd
->pcls
->style
& CS_CLASSDC
) && !(Wnd
->pcls
->pdce
) )
1874 { /* One DCE per class to have CLASS. */
1875 Wnd
->pcls
->pdce
= DceAllocDCE( Window
, DCE_CLASS_DC
);
1877 else if ( Wnd
->pcls
->style
& CS_OWNDC
)
1878 { /* Allocate a DCE for this window. */
1879 DceAllocDCE(Window
, DCE_WINDOW_DC
);
1887 UserDereferenceObject(Window
);
1890 DesktopHeapFree(Wnd
->head
.rpdesk
, Wnd
);
1892 SetLastNtError(STATUS_INSUFFICIENT_RESOURCES
);
1900 co_UserCreateWindowEx(CREATESTRUCTW
* Cs
,
1901 PUNICODE_STRING ClassName
,
1902 PLARGE_STRING WindowName
)
1904 PWINDOW_OBJECT Window
= NULL
, ParentWindow
= NULL
, OwnerWindow
;
1905 HWND hWnd
, hWndParent
, hWndOwner
;
1907 PWINSTATION_OBJECT WinSta
;
1912 CBT_CREATEWNDW CbtCreate
;
1914 USER_REFERENCE_ENTRY ParentRef
, Ref
;
1916 DWORD dwShowMode
= SW_SHOW
;
1917 DECLARE_RETURN(PWND
);
1919 /* Get the current window station and reference it */
1920 pti
= GetW32ThreadInfo();
1921 if (pti
== NULL
|| pti
->rpdesk
== NULL
)
1923 DPRINT1("Thread is not attached to a desktop! Cannot create window!\n");
1924 return NULL
; //There is nothing to cleanup
1926 WinSta
= pti
->rpdesk
->rpwinstaParent
;
1927 ObReferenceObjectByPointer(WinSta
, KernelMode
, ExWindowStationObjectType
, 0);
1929 /* Get the class and reference it*/
1930 Class
= IntGetAndReferenceClass(ClassName
, Cs
->hInstance
);
1933 DPRINT1("Failed to find class %wZ\n", ClassName
);
1937 /* Now find the parent and the owner window */
1938 hWndParent
= IntGetDesktopWindow();
1941 if (Cs
->hwndParent
== HWND_MESSAGE
)
1943 Cs
->hwndParent
= hWndParent
= IntGetMessageWindow();
1945 else if (Cs
->hwndParent
)
1947 if ((Cs
->style
& (WS_CHILD
|WS_POPUP
)) != WS_CHILD
)
1948 hWndOwner
= Cs
->hwndParent
;
1950 hWndParent
= Cs
->hwndParent
;
1952 else if ((Cs
->style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
)
1954 DPRINT1("Cannot create a child window without a parrent!\n");
1955 SetLastWin32Error(ERROR_TLW_WITH_WSCHILD
);
1956 RETURN(NULL
); /* WS_CHILD needs a parent, but WS_POPUP doesn't */
1959 ParentWindow
= hWndParent
? UserGetWindowObject(hWndParent
): NULL
;
1960 OwnerWindow
= hWndOwner
? UserGetWindowObject(hWndOwner
): NULL
;
1962 /* FIXME: is this correct?*/
1964 OwnerWindow
= UserGetAncestor(OwnerWindow
, GA_ROOT
);
1966 /* Fix the position and the size of the window */
1969 UserRefObjectCo(ParentWindow
, &ParentRef
);
1970 IntFixWindowCoordinates(Cs
, ParentWindow
, &dwShowMode
);
1973 /* Allocate and initialize the new window */
1974 Window
= IntCreateWindow(Cs
,
1981 DPRINT1("IntCreateWindow failed!\n");
1986 hWnd
= Window
->hSelf
;
1988 UserRefObjectCo(Window
, &Ref
);
1989 ObDereferenceObject(WinSta
);
1991 /* Call the WH_CBT hook */
1992 dwStyle
= Cs
->style
;
1993 Cs
->style
= Wnd
->style
; /* HCBT_CREATEWND needs the real window style */
1994 CbtCreate
.lpcs
= Cs
;
1995 CbtCreate
.hwndInsertAfter
= HWND_TOP
;
1996 if (ISITHOOKED(WH_CBT
))
1998 if (co_HOOK_CallHooks(WH_CBT
, HCBT_CREATEWND
, (WPARAM
) hWnd
, (LPARAM
) &CbtCreate
))
2000 DPRINT1("HCBT_CREATEWND hook failed!\n");
2001 RETURN( (PWND
) NULL
);
2004 Cs
->style
= dwStyle
; /* NCCREATE and WM_NCCALCSIZE need the original values*/
2006 /* Send the WM_GETMINMAXINFO message*/
2010 if ((dwStyle
& WS_THICKFRAME
) || !(dwStyle
& (WS_POPUP
| WS_CHILD
)))
2012 POINT MaxSize
, MaxPos
, MinTrack
, MaxTrack
;
2014 co_WinPosGetMinMaxInfo(Window
, &MaxSize
, &MaxPos
, &MinTrack
, &MaxTrack
);
2015 if (Size
.cx
> MaxTrack
.x
) Size
.cx
= MaxTrack
.x
;
2016 if (Size
.cy
> MaxTrack
.y
) Size
.cy
= MaxTrack
.y
;
2017 if (Size
.cx
< MinTrack
.x
) Size
.cx
= MinTrack
.x
;
2018 if (Size
.cy
< MinTrack
.y
) Size
.cy
= MinTrack
.y
;
2021 Wnd
->rcWindow
.left
= Cs
->x
;
2022 Wnd
->rcWindow
.top
= Cs
->y
;
2023 Wnd
->rcWindow
.right
= Cs
->x
+ Size
.cx
;
2024 Wnd
->rcWindow
.bottom
= Cs
->y
+ Size
.cy
;
2025 if (0 != (Wnd
->style
& WS_CHILD
) && ParentWindow
)
2027 RECTL_vOffsetRect(&Wnd
->rcWindow
,
2028 ParentWindow
->Wnd
->rcClient
.left
,
2029 ParentWindow
->Wnd
->rcClient
.top
);
2031 Wnd
->rcClient
= Wnd
->rcWindow
;
2034 /* Link the window*/
2035 if (NULL
!= ParentWindow
)
2037 /* link the window into the parent's child list */
2038 if ((dwStyle
& (WS_CHILD
|WS_MAXIMIZE
)) == WS_CHILD
)
2040 PWINDOW_OBJECT PrevSibling
;
2042 PrevSibling
= ParentWindow
->spwndChild
;
2046 while (PrevSibling
->spwndNext
)
2047 PrevSibling
= PrevSibling
->spwndNext
;
2050 /* link window as bottom sibling */
2051 IntLinkWindow(Window
, ParentWindow
, PrevSibling
/*prev sibling*/);
2055 /* link window as top sibling (but after topmost siblings) */
2056 PWINDOW_OBJECT InsertAfter
, Sibling
;
2057 if (!(Cs
->dwExStyle
& WS_EX_TOPMOST
))
2060 Sibling
= ParentWindow
->spwndChild
;
2061 while (Sibling
&& (Sibling
->Wnd
->ExStyle
& WS_EX_TOPMOST
))
2063 InsertAfter
= Sibling
;
2064 Sibling
= Sibling
->spwndNext
;
2072 IntLinkWindow(Window
, ParentWindow
, InsertAfter
/* prev sibling */);
2076 /* Send the NCCREATE message */
2077 Result
= co_IntSendMessage(Window
->hSelf
, WM_NCCREATE
, 0, (LPARAM
) Cs
);
2080 DPRINT1("co_UserCreateWindowEx(): NCCREATE message failed\n");
2084 /* Send the WM_NCCALCSIZE message */
2085 MaxPos
.x
= Window
->Wnd
->rcWindow
.left
;
2086 MaxPos
.y
= Window
->Wnd
->rcWindow
.top
;
2088 Result
= co_WinPosGetNonClientSize(Window
, &Wnd
->rcWindow
, &Wnd
->rcClient
);
2090 RECTL_vOffsetRect(&Wnd
->rcWindow
, MaxPos
.x
- Wnd
->rcWindow
.left
,
2091 MaxPos
.y
- Wnd
->rcWindow
.top
);
2094 /* Send the WM_CREATE message. */
2095 Result
= co_IntSendMessage(Window
->hSelf
, WM_CREATE
, 0, (LPARAM
) Cs
);
2096 if (Result
== (LRESULT
)-1)
2098 DPRINT1("co_UserCreateWindowEx(): WM_CREATE message failed\n");
2099 IntUnlinkWindow(Window
);
2103 /* Send the EVENT_OBJECT_CREATE event*/
2104 IntNotifyWinEvent(EVENT_OBJECT_CREATE
, Window
->Wnd
, OBJID_WINDOW
, 0);
2106 /* By setting the flag below it can be examined to determine if the window
2107 was created successfully and a valid pwnd was passed back to caller since
2108 from here the function has to succeed. */
2109 Window
->Wnd
->state2
|= WNDS2_WMCREATEMSGPROCESSED
;
2111 /* Send the WM_SIZE and WM_MOVE messages. */
2112 if (!(Window
->state
& WINDOWOBJECT_NEED_SIZE
))
2114 co_WinPosSendSizeMove(Window
);
2117 /* Show or maybe minimize or maximize the window. */
2118 if (Wnd
->style
& (WS_MINIMIZE
| WS_MAXIMIZE
))
2123 SwFlag
= (Wnd
->style
& WS_MINIMIZE
) ? SW_MINIMIZE
: SW_MAXIMIZE
;
2125 co_WinPosMinMaximize(Window
, SwFlag
, &NewPos
);
2127 SwFlag
= ((Wnd
->style
& WS_CHILD
) || UserGetActiveWindow()) ?
2128 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
:
2129 SWP_NOZORDER
| SWP_FRAMECHANGED
;
2131 co_WinPosSetWindowPos(Window
, 0, NewPos
.left
, NewPos
.top
,
2132 NewPos
.right
, NewPos
.bottom
, SwFlag
);
2135 /* Send the WM_PARENTNOTIFY message */
2136 if ((Wnd
->style
& WS_CHILD
) &&
2137 (!(Wnd
->ExStyle
& WS_EX_NOPARENTNOTIFY
)) && ParentWindow
)
2139 co_IntSendMessage(ParentWindow
->hSelf
,
2141 MAKEWPARAM(WM_CREATE
, Wnd
->IDMenu
),
2142 (LPARAM
)Window
->hSelf
);
2145 /* Notify the shell that a new window was created */
2146 if ((!hWndParent
) && (!hWndOwner
))
2148 co_IntShellHookNotify(HSHELL_WINDOWCREATED
, (LPARAM
)hWnd
);
2151 /* Initialize and show the window's scrollbars */
2152 if (Wnd
->style
& WS_VSCROLL
)
2154 co_UserShowScrollBar(Window
, SB_VERT
, TRUE
);
2156 if (Wnd
->style
& WS_HSCROLL
)
2158 co_UserShowScrollBar(Window
, SB_HORZ
, TRUE
);
2161 /* Show the new window */
2162 if (Cs
->style
& WS_VISIBLE
)
2164 if (Wnd
->style
& WS_MAXIMIZE
)
2165 dwShowMode
= SW_SHOW
;
2166 else if (Wnd
->style
& WS_MINIMIZE
)
2167 dwShowMode
= SW_SHOWMINIMIZED
;
2169 co_WinPosShowWindow(Window
, dwShowMode
);
2171 if (Wnd
->ExStyle
& WS_EX_MDICHILD
)
2173 co_IntSendMessage(ParentWindow
->hSelf
, WM_MDIREFRESHMENU
, 0, 0);
2174 /* ShowWindow won't activate child windows */
2175 co_WinPosSetWindowPos(Window
, HWND_TOP
, 0, 0, 0, 0, SWP_SHOWWINDOW
| SWP_NOMOVE
| SWP_NOSIZE
);
2179 DPRINT("co_UserCreateWindowEx(): Created window %X\n", hWnd
);
2185 /* If the window was created, the class will be dereferenced by co_UserDestroyWindow */
2187 co_UserDestroyWindow(Window
);
2189 IntDereferenceClass(Class
, pti
->pDeskInfo
, pti
->ppi
);
2194 UserDerefObjectCo(Window
);
2195 UserDereferenceObject(Window
);
2197 if (ParentWindow
) UserDerefObjectCo(ParentWindow
);
2204 ProbeAndCaptureLargeString(
2205 OUT PLARGE_STRING plstrSafe
,
2206 IN PLARGE_STRING plstrUnsafe
)
2208 LARGE_STRING lstrTemp
;
2209 PVOID pvBuffer
= NULL
;
2213 /* Probe and copy the string */
2214 ProbeForRead(plstrUnsafe
, sizeof(LARGE_STRING
), sizeof(ULONG
));
2215 lstrTemp
= *plstrUnsafe
;
2217 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2220 _SEH2_YIELD(return _SEH2_GetExceptionCode();)
2224 if (lstrTemp
.Length
!= 0)
2226 /* Allocate a buffer from paged pool */
2227 pvBuffer
= ExAllocatePoolWithTag(PagedPool
, lstrTemp
.Length
, TAG_STRING
);
2230 return STATUS_NO_MEMORY
;
2235 /* Probe and copy the buffer */
2236 ProbeForRead(lstrTemp
.Buffer
, lstrTemp
.Length
, sizeof(WCHAR
));
2237 RtlCopyMemory(pvBuffer
, lstrTemp
.Buffer
, lstrTemp
.Length
);
2239 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2241 /* Cleanup and fail */
2242 ExFreePool(pvBuffer
);
2243 _SEH2_YIELD(return _SEH2_GetExceptionCode();)
2248 /* Set the output string */
2249 plstrSafe
->Buffer
= pvBuffer
;
2250 plstrSafe
->Length
= lstrTemp
.Length
;
2251 plstrSafe
->MaximumLength
= lstrTemp
.Length
;
2253 return STATUS_SUCCESS
;
2257 * \todo Allow passing plstrClassName as ANSI.
2261 NtUserCreateWindowEx(
2263 PLARGE_STRING plstrClassName
,
2264 PLARGE_STRING plstrClsVersion
,
2265 PLARGE_STRING plstrWindowName
,
2273 HINSTANCE hInstance
,
2279 LARGE_STRING lstrWindowName
;
2280 LARGE_STRING lstrClassName
;
2281 UNICODE_STRING ustrClassName
;
2286 lstrWindowName
.Buffer
= NULL
;
2287 lstrClassName
.Buffer
= NULL
;
2289 /* Check if we got a Window name */
2290 if (plstrWindowName
)
2292 /* Copy the string to kernel mode */
2293 Status
= ProbeAndCaptureLargeString(&lstrWindowName
, plstrWindowName
);
2294 if (!NT_SUCCESS(Status
))
2296 DPRINT1("NtUserCreateWindowEx: failed to capture plstrWindowName\n");
2297 SetLastNtError(Status
);
2300 plstrWindowName
= &lstrWindowName
;
2303 /* Check if the class is an atom */
2304 if (IS_ATOM(plstrClassName
))
2306 /* It is, pass the atom in the UNICODE_STRING */
2307 ustrClassName
.Buffer
= (PVOID
)plstrClassName
;
2308 ustrClassName
.Length
= 0;
2309 ustrClassName
.MaximumLength
= 0;
2313 /* It's not, capture the class name */
2314 Status
= ProbeAndCaptureLargeString(&lstrClassName
, plstrClassName
);
2315 if (!NT_SUCCESS(Status
))
2317 DPRINT1("NtUserCreateWindowEx: failed to capture plstrClassName\n");
2318 /* Set last error, cleanup and return */
2319 SetLastNtError(Status
);
2323 /* We pass it on as a UNICODE_STRING */
2324 ustrClassName
.Buffer
= lstrClassName
.Buffer
;
2325 ustrClassName
.Length
= lstrClassName
.Length
;
2326 ustrClassName
.MaximumLength
= lstrClassName
.MaximumLength
;
2329 /* Fill the CREATESTRUCTW */
2330 /* we will keep here the original parameters */
2332 Cs
.lpCreateParams
= lpParam
;
2333 Cs
.hInstance
= hInstance
;
2335 Cs
.hwndParent
= hWndParent
;
2340 // Cs.lpszName = (LPCWSTR) WindowName->Buffer;
2341 // Cs.lpszClass = (LPCWSTR) ClassName->Buffer;
2342 Cs
.lpszName
= (LPCWSTR
) plstrWindowName
;
2343 Cs
.lpszClass
= (LPCWSTR
) &ustrClassName
;
2344 Cs
.dwExStyle
= dwExStyle
;
2346 UserEnterExclusive();
2348 /* Call the internal function */
2349 pwnd
= co_UserCreateWindowEx(&Cs
, &ustrClassName
, plstrWindowName
);
2353 DPRINT1("co_UserCreateWindowEx failed!\n");
2355 hwnd
= pwnd
? UserHMGetHandle(pwnd
) : NULL
;
2360 if (lstrWindowName
.Buffer
)
2362 ExFreePoolWithTag(lstrWindowName
.Buffer
, TAG_STRING
);
2364 if (lstrClassName
.Buffer
)
2366 ExFreePoolWithTag(lstrClassName
.Buffer
, TAG_STRING
);
2376 NtUserDeferWindowPos(HDWP WinPosInfo
,
2378 HWND WndInsertAfter
,
2391 BOOLEAN FASTCALL
co_UserDestroyWindow(PWINDOW_OBJECT Window
)
2399 ASSERT_REFS_CO(Window
); // FIXME: temp hack?
2401 hWnd
= Window
->hSelf
;
2405 if (!Wnd
) return TRUE
; // FIXME: Need to finish object rewrite or lock the thread when killing the window!
2407 DPRINT("co_UserDestroyWindow \n");
2409 /* Check for owner thread */
2410 if ( (Window
->pti
->pEThread
!= PsGetCurrentThread()) ||
2411 Wnd
->head
.pti
!= PsGetCurrentThreadWin32Thread() )
2413 SetLastWin32Error(ERROR_ACCESS_DENIED
);
2417 /* If window was created successfully and it is hooked */
2418 if ((Wnd
->state2
& WNDS2_WMCREATEMSGPROCESSED
) && (ISITHOOKED(WH_CBT
)))
2420 if (co_HOOK_CallHooks(WH_CBT
, HCBT_DESTROYWND
, (WPARAM
) hWnd
, 0)) return FALSE
;
2423 /* Look whether the focus is within the tree of windows we will
2426 if (!co_WinPosShowWindow(Window
, SW_HIDE
))
2428 if (UserGetActiveWindow() == Window
->hSelf
)
2430 co_WinPosActivateOtherWindow(Window
);
2434 if (Window
->pti
->MessageQueue
->ActiveWindow
== Window
->hSelf
)
2435 Window
->pti
->MessageQueue
->ActiveWindow
= NULL
;
2436 if (Window
->pti
->MessageQueue
->FocusWindow
== Window
->hSelf
)
2437 Window
->pti
->MessageQueue
->FocusWindow
= NULL
;
2438 if (Window
->pti
->MessageQueue
->CaptureWindow
== Window
->hSelf
)
2439 Window
->pti
->MessageQueue
->CaptureWindow
= NULL
;
2442 * Check if this window is the Shell's Desktop Window. If so set hShellWindow to NULL
2445 ti
= PsGetCurrentThreadWin32Thread();
2447 if ((ti
!= NULL
) & (ti
->pDeskInfo
!= NULL
))
2449 if (ti
->pDeskInfo
->hShellWindow
== hWnd
)
2451 DPRINT1("Destroying the ShellWindow!\n");
2452 ti
->pDeskInfo
->hShellWindow
= NULL
;
2456 IntDereferenceMessageQueue(Window
->pti
->MessageQueue
);
2458 IntEngWindowChanged(Window
, WOC_DELETE
);
2459 isChild
= (0 != (Wnd
->style
& WS_CHILD
));
2465 if (! USER_IsExitingThread(GetCurrentThreadId()))
2467 send_parent_notify(hwnd
, WM_DESTROY
);
2470 else if (NULL
!= GetWindow(Wnd
, GW_OWNER
))
2472 co_HOOK_CallHooks( WH_SHELL
, HSHELL_WINDOWDESTROYED
, (WPARAM
)hwnd
, 0L, TRUE
);
2473 /* FIXME: clean up palette - see "Internals" p.352 */
2477 if (!IntIsWindow(Window
->hSelf
))
2482 /* Recursively destroy owned windows */
2487 BOOL GotOne
= FALSE
;
2490 PWINDOW_OBJECT Child
, Desktop
;
2492 Desktop
= IntIsDesktopWindow(Window
) ? Window
:
2493 UserGetWindowObject(IntGetDesktopWindow());
2494 Children
= IntWinListChildren(Desktop
);
2498 for (ChildHandle
= Children
; *ChildHandle
; ++ChildHandle
)
2500 Child
= UserGetWindowObject(*ChildHandle
);
2503 if (Child
->spwndOwner
!= Window
)
2508 if (IntWndBelongsToThread(Child
, PsGetCurrentThreadWin32Thread()))
2510 USER_REFERENCE_ENTRY ChildRef
;
2511 UserRefObjectCo(Child
, &ChildRef
);//temp hack?
2512 co_UserDestroyWindow(Child
);
2513 UserDerefObjectCo(Child
);//temp hack?
2519 if (Child
->spwndOwner
!= NULL
)
2521 Child
->spwndOwner
= NULL
;
2522 Child
->Wnd
->spwndOwner
= NULL
;
2526 ExFreePool(Children
);
2535 /* Generate mouse move message for the next window */
2536 msg
.message
= WM_MOUSEMOVE
;
2537 msg
.wParam
= IntGetSysCursorInfo()->ButtonsDown
;
2538 msg
.lParam
= MAKELPARAM(gpsi
->ptCursor
.x
, gpsi
->ptCursor
.y
);
2539 msg
.pt
= gpsi
->ptCursor
;
2540 MsqInsertSystemMessage(&msg
);
2542 if (!IntIsWindow(Window
->hSelf
))
2547 /* Destroy the window storage */
2548 co_UserFreeWindow(Window
, PsGetCurrentProcessWin32Process(), PsGetCurrentThreadWin32Thread(), TRUE
);
2558 NtUserDestroyWindow(HWND Wnd
)
2560 PWINDOW_OBJECT Window
;
2561 DECLARE_RETURN(BOOLEAN
);
2563 USER_REFERENCE_ENTRY Ref
;
2565 DPRINT("Enter NtUserDestroyWindow\n");
2566 UserEnterExclusive();
2568 if (!(Window
= UserGetWindowObject(Wnd
)))
2573 UserRefObjectCo(Window
, &Ref
);//faxme: dunno if win should be reffed during destroy..
2574 ret
= co_UserDestroyWindow(Window
);
2575 UserDerefObjectCo(Window
);//faxme: dunno if win should be reffed during destroy..
2580 DPRINT("Leave NtUserDestroyWindow, ret=%i\n",_ret_
);
2592 NtUserDrawMenuBarTemp(
2599 /* we'll use this function just for caching the menu bar */
2609 NtUserEndDeferWindowPosEx(DWORD Unknown0
,
2619 * FillWindow: Called from User; Dialog, Edit and ListBox procs during a WM_ERASEBKGND.
2625 NtUserFillWindow(HWND hWndPaint
,
2636 static HWND FASTCALL
2637 IntFindWindow(PWINDOW_OBJECT Parent
,
2638 PWINDOW_OBJECT ChildAfter
,
2640 PUNICODE_STRING WindowName
)
2642 BOOL CheckWindowName
;
2645 UNICODE_STRING CurrentWindowName
;
2649 CheckWindowName
= WindowName
->Length
!= 0;
2651 if((List
= IntWinListChildren(Parent
)))
2656 /* skip handles before and including ChildAfter */
2657 while(*phWnd
&& (*(phWnd
++) != ChildAfter
->hSelf
))
2661 /* search children */
2664 PWINDOW_OBJECT Child
;
2665 if(!(Child
= UserGetWindowObject(*(phWnd
++))))
2670 /* Do not send WM_GETTEXT messages in the kernel mode version!
2671 The user mode version however calls GetWindowText() which will
2672 send WM_GETTEXT messages to windows belonging to its processes */
2673 if (!ClassAtom
|| Child
->Wnd
->pcls
->atomClassName
== ClassAtom
)
2675 // HACK: use UNICODE_STRING instead of LARGE_STRING
2676 CurrentWindowName
.Buffer
= Child
->Wnd
->strName
.Buffer
;
2677 CurrentWindowName
.Length
= Child
->Wnd
->strName
.Length
;
2678 CurrentWindowName
.MaximumLength
= Child
->Wnd
->strName
.MaximumLength
;
2679 if(!CheckWindowName
||
2680 (Child
->Wnd
->strName
.Length
< 0xFFFF &&
2681 !RtlCompareUnicodeString(WindowName
, &CurrentWindowName
, TRUE
)))
2696 * Searches a window's children for a window with the specified
2699 * hwndParent = The window whose childs are to be searched.
2701 * HWND_MESSAGE = message-only windows
2703 * hwndChildAfter = Search starts after this child window.
2704 * NULL = start from beginning
2706 * ucClassName = Class name to search for
2707 * Reguired parameter.
2709 * ucWindowName = Window name
2710 * ->Buffer == NULL = don't care
2713 * The HWND of the window if it was found, otherwise NULL
2719 NtUserFindWindowEx(HWND hwndParent
,
2720 HWND hwndChildAfter
,
2721 PUNICODE_STRING ucClassName
,
2722 PUNICODE_STRING ucWindowName
,
2725 PWINDOW_OBJECT Parent
, ChildAfter
;
2726 UNICODE_STRING ClassName
= {0}, WindowName
= {0};
2727 HWND Desktop
, Ret
= NULL
;
2728 RTL_ATOM ClassAtom
= (RTL_ATOM
)0;
2729 DECLARE_RETURN(HWND
);
2731 DPRINT("Enter NtUserFindWindowEx\n");
2734 if (ucClassName
!= NULL
|| ucWindowName
!= NULL
)
2738 if (ucClassName
!= NULL
)
2740 ClassName
= ProbeForReadUnicodeString(ucClassName
);
2741 if (ClassName
.Length
!= 0)
2743 ProbeForRead(ClassName
.Buffer
,
2747 else if (!IS_ATOM(ClassName
.Buffer
))
2749 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
2753 if (!IntGetAtomFromStringOrAtom(&ClassName
,
2760 if (ucWindowName
!= NULL
)
2762 WindowName
= ProbeForReadUnicodeString(ucWindowName
);
2763 if (WindowName
.Length
!= 0)
2765 ProbeForRead(WindowName
.Buffer
,
2771 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2773 SetLastNtError(_SEH2_GetExceptionCode());
2774 _SEH2_YIELD(RETURN(NULL
));
2778 if (ucClassName
!= NULL
)
2780 if (ClassName
.Length
== 0 && ClassName
.Buffer
!= NULL
&&
2781 !IS_ATOM(ClassName
.Buffer
))
2783 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
2786 else if (ClassAtom
== (RTL_ATOM
)0)
2788 /* LastError code was set by IntGetAtomFromStringOrAtom */
2794 Desktop
= IntGetCurrentThreadDesktopWindow();
2796 if(hwndParent
== NULL
)
2797 hwndParent
= Desktop
;
2798 else if(hwndParent
== HWND_MESSAGE
)
2800 hwndParent
= IntGetMessageWindow();
2803 if(!(Parent
= UserGetWindowObject(hwndParent
)))
2809 if(hwndChildAfter
&& !(ChildAfter
= UserGetWindowObject(hwndChildAfter
)))
2816 if(Parent
->hSelf
== Desktop
)
2819 PWINDOW_OBJECT TopLevelWindow
;
2820 BOOLEAN CheckWindowName
;
2821 BOOLEAN WindowMatches
;
2822 BOOLEAN ClassMatches
;
2824 /* windows searches through all top-level windows if the parent is the desktop
2827 if((List
= IntWinListChildren(Parent
)))
2833 /* skip handles before and including ChildAfter */
2834 while(*phWnd
&& (*(phWnd
++) != ChildAfter
->hSelf
))
2838 CheckWindowName
= WindowName
.Length
!= 0;
2840 /* search children */
2843 UNICODE_STRING ustr
;
2845 if(!(TopLevelWindow
= UserGetWindowObject(*(phWnd
++))))
2850 /* Do not send WM_GETTEXT messages in the kernel mode version!
2851 The user mode version however calls GetWindowText() which will
2852 send WM_GETTEXT messages to windows belonging to its processes */
2853 ustr
.Buffer
= TopLevelWindow
->Wnd
->strName
.Buffer
;
2854 ustr
.Length
= TopLevelWindow
->Wnd
->strName
.Length
;
2855 ustr
.MaximumLength
= TopLevelWindow
->Wnd
->strName
.MaximumLength
;
2856 WindowMatches
= !CheckWindowName
||
2857 (TopLevelWindow
->Wnd
->strName
.Length
< 0xFFFF &&
2858 !RtlCompareUnicodeString(&WindowName
, &ustr
, TRUE
));
2859 ClassMatches
= (ClassAtom
== (RTL_ATOM
)0) ||
2860 ClassAtom
== TopLevelWindow
->Wnd
->pcls
->atomClassName
;
2862 if (WindowMatches
&& ClassMatches
)
2864 Ret
= TopLevelWindow
->hSelf
;
2868 if (IntFindWindow(TopLevelWindow
, NULL
, ClassAtom
, &WindowName
))
2870 /* window returns the handle of the top-level window, in case it found
2872 Ret
= TopLevelWindow
->hSelf
;
2881 Ret
= IntFindWindow(Parent
, ChildAfter
, ClassAtom
, &WindowName
);
2885 if(Ret
== NULL
&& hwndParent
== NULL
&& hwndChildAfter
== NULL
)
2887 /* FIXME - if both hwndParent and hwndChildAfter are NULL, we also should
2888 search the message-only windows. Should this also be done if
2889 Parent is the desktop window??? */
2890 PWINDOW_OBJECT MsgWindows
;
2892 if((MsgWindows
= UserGetWindowObject(IntGetMessageWindow())))
2894 Ret
= IntFindWindow(MsgWindows
, ChildAfter
, ClassAtom
, &WindowName
);
2899 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2901 SetLastNtError(_SEH2_GetExceptionCode());
2909 DPRINT("Leave NtUserFindWindowEx, ret %i\n",_ret_
);
2919 NtUserFlashWindowEx(IN PFLASHWINFO pfwi
)
2930 PWINDOW_OBJECT FASTCALL
UserGetAncestor(PWINDOW_OBJECT Wnd
, UINT Type
)
2932 PWINDOW_OBJECT WndAncestor
, Parent
;
2934 if (Wnd
->hSelf
== IntGetDesktopWindow())
2943 WndAncestor
= Wnd
->spwndParent
;
2954 if(!(Parent
= WndAncestor
->spwndParent
))
2958 if(IntIsDesktopWindow(Parent
))
2963 WndAncestor
= Parent
;
2974 PWINDOW_OBJECT Parent
, Old
;
2977 Parent
= IntGetParent(WndAncestor
);
2984 WndAncestor
= Parent
;
3002 NtUserGetAncestor(HWND hWnd
, UINT Type
)
3004 PWINDOW_OBJECT Window
, Ancestor
;
3005 DECLARE_RETURN(HWND
);
3007 DPRINT("Enter NtUserGetAncestor\n");
3008 UserEnterExclusive();
3010 if (!(Window
= UserGetWindowObject(hWnd
)))
3015 Ancestor
= UserGetAncestor(Window
, Type
);
3016 /* faxme: can UserGetAncestor ever return NULL for a valid window? */
3018 RETURN(Ancestor
? Ancestor
->hSelf
: NULL
);
3021 DPRINT("Leave NtUserGetAncestor, ret=%i\n",_ret_
);
3029 NtUserGetComboBoxInfo(
3034 DECLARE_RETURN(BOOL
);
3036 DPRINT("Enter NtUserGetComboBoxInfo\n");
3039 if (!(Wnd
= UserGetWindowObject(hWnd
)))
3048 sizeof(COMBOBOXINFO
),
3052 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
3054 SetLastNtError(_SEH2_GetExceptionCode());
3055 _SEH2_YIELD(RETURN(FALSE
));
3059 // Pass the user pointer, it was already probed.
3060 RETURN( (BOOL
) co_IntSendMessage( Wnd
->hSelf
, CB_GETCOMBOBOXINFO
, 0, (LPARAM
)pcbi
));
3063 DPRINT("Leave NtUserGetComboBoxInfo, ret=%i\n",_ret_
);
3073 NtUserGetInternalWindowPos( HWND hWnd
,
3077 PWINDOW_OBJECT Window
;
3081 WINDOWPLACEMENT wndpl
;
3085 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())))
4443 //hmm... threads live on desktops thus we have a reference on the desktop and indirectly the desktop window
4444 //its possible this referencing is useless, thou it shouldnt hurt...
4445 UserRefObjectCo(DesktopWindow
, &Ref
);
4447 pti
= PsGetCurrentThreadWin32Thread();
4448 Hit
= co_WinPosWindowFromPoint(DesktopWindow
, pti
->MessageQueue
, &pt
, &Window
);
4452 Ret
= Window
->hSelf
;
4461 if (Window
) UserDereferenceObject(Window
);
4462 if (DesktopWindow
) UserDerefObjectCo(DesktopWindow
);
4464 DPRINT("Leave NtUserWindowFromPoint, ret=%i\n",_ret_
);
4474 * Undocumented function that is called from DefWindowProc to set
4481 NtUserDefSetText(HWND hWnd
, PLARGE_STRING WindowText
)
4483 PWINDOW_OBJECT Window
;
4485 LARGE_STRING SafeText
;
4486 UNICODE_STRING UnicodeString
;
4489 DPRINT("Enter NtUserDefSetText\n");
4491 if (WindowText
!= NULL
)
4495 SafeText
= ProbeForReadLargeString(WindowText
);
4497 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
4500 SetLastNtError(_SEH2_GetExceptionCode());
4510 UserEnterExclusive();
4512 if(!(Window
= UserGetWindowObject(hWnd
)) || !Window
->Wnd
)
4519 // ReactOS uses Unicode and not mixed. Up/Down converting will take time.
4520 // Brought to you by: The Wine Project! Dysfunctional Thought Processes!
4521 // Now we know what the bAnsi is for.
4522 RtlInitUnicodeString(&UnicodeString
, NULL
);
4523 if (SafeText
.Buffer
)
4528 ProbeForRead(SafeText
.Buffer
, SafeText
.Length
, sizeof(CHAR
));
4530 ProbeForRead(SafeText
.Buffer
, SafeText
.Length
, sizeof(WCHAR
));
4531 Ret
= RtlLargeStringToUnicodeString(&UnicodeString
, &SafeText
);
4533 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
4536 SetLastNtError(_SEH2_GetExceptionCode());
4539 if (!Ret
) goto Exit
;
4542 if (UnicodeString
.Length
!= 0)
4544 if (Wnd
->strName
.MaximumLength
> 0 &&
4545 UnicodeString
.Length
<= Wnd
->strName
.MaximumLength
- sizeof(UNICODE_NULL
))
4547 ASSERT(Wnd
->strName
.Buffer
!= NULL
);
4549 Wnd
->strName
.Length
= UnicodeString
.Length
;
4550 Wnd
->strName
.Buffer
[UnicodeString
.Length
/ sizeof(WCHAR
)] = L
'\0';
4551 RtlCopyMemory(Wnd
->strName
.Buffer
,
4552 UnicodeString
.Buffer
,
4553 UnicodeString
.Length
);
4558 Wnd
->strName
.MaximumLength
= Wnd
->strName
.Length
= 0;
4559 buf
= Wnd
->strName
.Buffer
;
4560 Wnd
->strName
.Buffer
= NULL
;
4563 DesktopHeapFree(Wnd
->head
.rpdesk
, buf
);
4566 Wnd
->strName
.Buffer
= DesktopHeapAlloc(Wnd
->head
.rpdesk
,
4567 UnicodeString
.Length
+ sizeof(UNICODE_NULL
));
4568 if (Wnd
->strName
.Buffer
!= NULL
)
4570 Wnd
->strName
.Buffer
[UnicodeString
.Length
/ sizeof(WCHAR
)] = L
'\0';
4571 RtlCopyMemory(Wnd
->strName
.Buffer
,
4572 UnicodeString
.Buffer
,
4573 UnicodeString
.Length
);
4574 Wnd
->strName
.MaximumLength
= UnicodeString
.Length
+ sizeof(UNICODE_NULL
);
4575 Wnd
->strName
.Length
= UnicodeString
.Length
;
4579 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
4587 Wnd
->strName
.Length
= 0;
4588 if (Wnd
->strName
.Buffer
!= NULL
)
4589 Wnd
->strName
.Buffer
[0] = L
'\0';
4592 // HAX! FIXME! Windows does not do this in here!
4593 // In User32, these are called after: NotifyWinEvent EVENT_OBJECT_NAMECHANGE than
4594 // RepaintButton, StaticRepaint, NtUserCallHwndLock HWNDLOCK_ROUTINE_REDRAWFRAMEANDHOOK, etc.
4595 /* Send shell notifications */
4596 if (!Window
->spwndOwner
&& !IntGetParent(Window
))
4598 co_IntShellHookNotify(HSHELL_REDRAW
, (LPARAM
) hWnd
);
4603 if (UnicodeString
.Buffer
) RtlFreeUnicodeString(&UnicodeString
);
4604 DPRINT("Leave NtUserDefSetText, ret=%i\n", Ret
);
4610 * NtUserInternalGetWindowText
4617 NtUserInternalGetWindowText(HWND hWnd
, LPWSTR lpString
, INT nMaxCount
)
4619 PWINDOW_OBJECT Window
;
4623 DECLARE_RETURN(INT
);
4625 DPRINT("Enter NtUserInternalGetWindowText\n");
4628 if(lpString
&& (nMaxCount
<= 1))
4630 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
4634 if(!(Window
= UserGetWindowObject(hWnd
)))
4640 Result
= Wnd
->strName
.Length
/ sizeof(WCHAR
);
4643 const WCHAR Terminator
= L
'\0';
4645 WCHAR
*Buffer
= (WCHAR
*)lpString
;
4647 Copy
= min(nMaxCount
- 1, Result
);
4650 Status
= MmCopyToCaller(Buffer
, Wnd
->strName
.Buffer
, Copy
* sizeof(WCHAR
));
4651 if(!NT_SUCCESS(Status
))
4653 SetLastNtError(Status
);
4659 Status
= MmCopyToCaller(Buffer
, &Terminator
, sizeof(WCHAR
));
4660 if(!NT_SUCCESS(Status
))
4662 SetLastNtError(Status
);
4672 DPRINT("Leave NtUserInternalGetWindowText, ret=%i\n",_ret_
);
4680 IntShowOwnedPopups(PWINDOW_OBJECT OwnerWnd
, BOOL fShow
)
4683 PWINDOW_OBJECT pWnd
;
4686 // ASSERT(OwnerWnd);
4688 win_array
= IntWinListChildren(UserGetWindowObject(IntGetDesktopWindow()));
4693 while (win_array
[count
])
4695 while (--count
>= 0)
4697 if (!(pWnd
= UserGetWindowObject( win_array
[count
] )))
4699 if (pWnd
->spwndOwner
!= OwnerWnd
)
4704 if (pWnd
->Wnd
->state
& WNDS_HIDDENPOPUP
)
4706 /* In Windows, ShowOwnedPopups(TRUE) generates
4707 * WM_SHOWWINDOW messages with SW_PARENTOPENING,
4708 * regardless of the state of the owner
4710 co_IntSendMessage(win_array
[count
], WM_SHOWWINDOW
, SW_SHOWNORMAL
, SW_PARENTOPENING
);
4716 if (pWnd
->Wnd
->style
& WS_VISIBLE
)
4718 /* In Windows, ShowOwnedPopups(FALSE) generates
4719 * WM_SHOWWINDOW messages with SW_PARENTCLOSING,
4720 * regardless of the state of the owner
4722 co_IntSendMessage(win_array
[count
], WM_SHOWWINDOW
, SW_HIDE
, SW_PARENTCLOSING
);
4728 ExFreePool( win_array
);
4733 * NtUserValidateHandleSecure
4741 NtUserValidateHandleSecure(
4749 PUSER_HANDLE_ENTRY entry
;
4750 if (!(entry
= handle_to_entry(gHandleTable
, handle
)))
4752 SetLastWin32Error(ERROR_INVALID_HANDLE
);
4755 uType
= entry
->type
;
4761 PWINDOW_OBJECT Window
;
4762 if ((Window
= UserGetWindowObject((HWND
) handle
))) return TRUE
;
4768 if ((Menu
= UserGetMenuObject((HMENU
) handle
))) return TRUE
;
4773 PACCELERATOR_TABLE Accel
;
4774 if ((Accel
= UserGetAccelObject((HACCEL
) handle
))) return TRUE
;
4779 PCURICON_OBJECT Cursor
;
4780 if ((Cursor
= UserGetCurIconObject((HCURSOR
) handle
))) return TRUE
;
4786 if ((Hook
= IntGetHookObject((HHOOK
) handle
))) return TRUE
;
4792 if ((Monitor
= UserGetMonitorObject((HMONITOR
) handle
))) return TRUE
;
4798 return UserGetCallProcInfo( handle
, &Proc
);
4801 SetLastWin32Error(ERROR_INVALID_HANDLE
);
4805 { /* Is handle entry restricted? */