2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
5 * FILE: subsystems/win32/win32k/ntuser/window.c
6 * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
8 * 06-06-2001 CSH Created
11 /* INCLUDES ******************************************************************/
18 /* dialog resources appear to pass this in 16 bits, handle them properly */
19 #define CW_USEDEFAULT16 (0x8000)
21 #define POINT_IN_RECT(p, r) (((r.bottom >= p.y) && (r.top <= p.y))&&((r.left <= p.x )&&( r.right >= p.x )))
23 /* PRIVATE FUNCTIONS **********************************************************/
28 * Initialize windowing implementation.
36 return STATUS_SUCCESS
;
42 * Cleanup windowing implementation.
46 CleanupWindowImpl(VOID
)
48 return STATUS_SUCCESS
;
51 /* HELPER FUNCTIONS ***********************************************************/
53 BOOL FASTCALL
UserUpdateUiState(PWND Wnd
, WPARAM wParam
)
55 WORD Action
= LOWORD(wParam
);
56 WORD Flags
= HIWORD(wParam
);
58 if (Flags
& ~(UISF_HIDEFOCUS
| UISF_HIDEACCEL
| UISF_ACTIVE
))
60 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
67 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
71 if (Flags
& UISF_HIDEFOCUS
)
72 Wnd
->HideFocus
= TRUE
;
73 if (Flags
& UISF_HIDEACCEL
)
74 Wnd
->HideAccel
= TRUE
;
78 if (Flags
& UISF_HIDEFOCUS
)
79 Wnd
->HideFocus
= FALSE
;
80 if (Flags
& UISF_HIDEACCEL
)
81 Wnd
->HideAccel
= FALSE
;
88 PWND FASTCALL
IntGetWindowObject(HWND hWnd
)
92 if (!hWnd
) return NULL
;
94 Window
= UserGetWindowObject(hWnd
);
97 ASSERT(Window
->head
.cLockObj
>= 0);
99 Window
->head
.cLockObj
++;
105 PWND FASTCALL
UserGetWindowObject(HWND hWnd
)
110 if (PsGetCurrentProcess() != PsInitialSystemProcess
)
112 ti
= GetW32ThreadInfo();
115 SetLastWin32Error(ERROR_ACCESS_DENIED
);
122 SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE
);
126 Window
= (PWND
)UserGetObject(gHandleTable
, hWnd
, otWindow
);
127 if (!Window
|| 0 != (Window
->state
& WNDS_DESTROYED
))
129 SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE
);
133 ASSERT(Window
->head
.cLockObj
>= 0);
142 * The function determines whether the specified window handle identifies
143 * an existing window.
147 * Handle to the window to test.
150 * If the window handle identifies an existing window, the return value
151 * is TRUE. If the window handle does not identify an existing window,
152 * the return value is FALSE.
156 IntIsWindow(HWND hWnd
)
160 if (!(Window
= UserGetWindowObject(hWnd
)))
168 IntGetParent(PWND Wnd
)
170 if (Wnd
->style
& WS_POPUP
)
172 return Wnd
->spwndOwner
;
174 else if (Wnd
->style
& WS_CHILD
)
176 return Wnd
->spwndParent
;
185 * Compile a list of all child window handles from given window.
188 * This function is similar to Wine WIN_ListChildren. The caller
189 * must free the returned list with ExFreePool.
193 IntWinListChildren(PWND Window
)
197 UINT Index
, NumChildren
= 0;
199 if (!Window
) return NULL
;
201 for (Child
= Window
->spwndChild
; Child
; Child
= Child
->spwndNext
)
204 List
= ExAllocatePoolWithTag(PagedPool
, (NumChildren
+ 1) * sizeof(HWND
), TAG_WINLIST
);
207 DPRINT1("Failed to allocate memory for children array\n");
208 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
211 for (Child
= Window
->spwndChild
, Index
= 0;
213 Child
= Child
->spwndNext
, ++Index
)
214 List
[Index
] = Child
->head
.h
;
220 /***********************************************************************
223 static void IntSendDestroyMsg(HWND hWnd
)
231 if (GetGUIThreadInfo(GetCurrentThreadId(), &info
))
233 if (hWnd
== info
.hwndCaret
)
240 Window
= UserGetWindowObject(hWnd
);
243 // USER_REFERENCE_ENTRY Ref;
244 // UserRefObjectCo(Window, &Ref);
246 if (!Window
->spwndOwner
&& !IntGetParent(Window
))
248 co_IntShellHookNotify(HSHELL_WINDOWDESTROYED
, (LPARAM
) hWnd
);
251 // UserDerefObjectCo(Window);
254 /* The window could already be destroyed here */
257 * Send the WM_DESTROY to the window.
260 co_IntSendMessage(hWnd
, WM_DESTROY
, 0, 0);
263 * This WM_DESTROY message can trigger re-entrant calls to DestroyWindow
264 * make sure that the window still exists when we come back.
273 if (!(pWndArray
= WIN_ListChildren( hwnd
)))
276 /* start from the end (FIXME: is this needed?) */
277 for (i
= 0; pWndArray
[i
]; i
++)
282 if (IsWindow( pWndArray
[i
] ))
283 WIN_SendDestroyMsg( pWndArray
[i
] );
285 HeapFree(GetProcessHeap(), 0, pWndArray
);
289 DPRINT("destroyed itself while in WM_DESTROY!\n");
295 UserFreeWindowInfo(PTHREADINFO ti
, PWND Wnd
)
297 PCLIENTINFO ClientInfo
= GetWin32ClientInfo();
301 if (ClientInfo
->CallbackWnd
.pWnd
== DesktopHeapAddressToUser(Wnd
))
303 ClientInfo
->CallbackWnd
.hWnd
= NULL
;
304 ClientInfo
->CallbackWnd
.pWnd
= NULL
;
307 if (Wnd
->strName
.Buffer
!= NULL
)
309 Wnd
->strName
.Length
= 0;
310 Wnd
->strName
.MaximumLength
= 0;
311 DesktopHeapFree(Wnd
->head
.rpdesk
,
312 Wnd
->strName
.Buffer
);
313 Wnd
->strName
.Buffer
= NULL
;
316 // DesktopHeapFree(Wnd->head.rpdesk, Wnd);
317 // WindowObject->Wnd = NULL;
320 /***********************************************************************
323 * Destroy storage associated to a window. "Internals" p.358
325 * This is the "functional" DestroyWindows function ei. all stuff
326 * done in CreateWindow is undone here and not in DestroyWindow:-P
329 static LRESULT
co_UserFreeWindow(PWND Window
,
330 PPROCESSINFO ProcessData
,
331 PTHREADINFO ThreadData
,
332 BOOLEAN SendMessages
)
338 BOOLEAN BelongsToThreadData
;
342 if(Window
->state2
& WNDS2_INDESTROY
)
344 DPRINT("Tried to call IntDestroyWindow() twice\n");
347 Window
->state2
|= WNDS2_INDESTROY
;
348 Window
->style
&= ~WS_VISIBLE
;
350 IntNotifyWinEvent(EVENT_OBJECT_DESTROY
, Window
, OBJID_WINDOW
, CHILDID_SELF
, 0);
352 /* remove the window already at this point from the thread window list so we
353 don't get into trouble when destroying the thread windows while we're still
354 in IntDestroyWindow() */
355 RemoveEntryList(&Window
->ThreadListEntry
);
357 BelongsToThreadData
= IntWndBelongsToThread(Window
, ThreadData
);
359 IntDeRegisterShellHookWindow(Window
->head
.h
);
363 /* Send destroy messages */
364 IntSendDestroyMsg(Window
->head
.h
);
367 /* free child windows */
368 Children
= IntWinListChildren(Window
);
371 for (ChildHandle
= Children
; *ChildHandle
; ++ChildHandle
)
373 if ((Child
= IntGetWindowObject(*ChildHandle
)))
375 if(!IntWndBelongsToThread(Child
, ThreadData
))
377 /* send WM_DESTROY messages to windows not belonging to the same thread */
378 IntSendDestroyMsg(Child
->head
.h
);
381 co_UserFreeWindow(Child
, ProcessData
, ThreadData
, SendMessages
);
383 UserDereferenceObject(Child
);
386 ExFreePool(Children
);
392 * Clear the update region to make sure no WM_PAINT messages will be
393 * generated for this window while processing the WM_NCDESTROY.
395 co_UserRedrawWindow(Window
, NULL
, 0,
396 RDW_VALIDATE
| RDW_NOFRAME
| RDW_NOERASE
|
397 RDW_NOINTERNALPAINT
| RDW_NOCHILDREN
);
398 if(BelongsToThreadData
)
399 co_IntSendMessage(Window
->head
.h
, WM_NCDESTROY
, 0, 0);
402 DestroyTimersForWindow(ThreadData
, Window
);
404 /* Unregister hot keys */
405 UnregisterWindowHotKeys (Window
);
407 /* flush the message queue */
408 MsqRemoveWindowMessagesFromQueue(Window
);
410 /* from now on no messages can be sent to this window anymore */
411 Window
->state
|= WNDS_DESTROYED
;
412 Window
->fnid
|= FNID_FREED
;
414 /* don't remove the WINDOWSTATUS_DESTROYING bit */
416 /* reset shell window handles */
417 if(ThreadData
->rpdesk
)
419 if (Window
->head
.h
== ThreadData
->rpdesk
->rpwinstaParent
->ShellWindow
)
420 ThreadData
->rpdesk
->rpwinstaParent
->ShellWindow
= NULL
;
422 if (Window
->head
.h
== ThreadData
->rpdesk
->rpwinstaParent
->ShellListView
)
423 ThreadData
->rpdesk
->rpwinstaParent
->ShellListView
= NULL
;
426 /* FIXME: do we need to fake QS_MOUSEMOVE wakebit? */
430 WinPosCheckInternalPos(Window
->head
.h
);
431 if (Window
->head
.h
== GetCapture())
436 /* free resources associated with the window */
437 TIMER_RemoveWindowTimers(Window
->head
.h
);
440 if (!(Window
->style
& WS_CHILD
) && Window
->IDMenu
441 && (Menu
= UserGetMenuObject((HMENU
)Window
->IDMenu
)))
443 IntDestroyMenuObject(Menu
, TRUE
, TRUE
);
447 if(Window
->SystemMenu
448 && (Menu
= UserGetMenuObject(Window
->SystemMenu
)))
450 IntDestroyMenuObject(Menu
, TRUE
, TRUE
);
451 Window
->SystemMenu
= (HMENU
)0;
454 DceFreeWindowDCE(Window
); /* Always do this to catch orphaned DCs */
457 WINPROC_FreeProc(Window
->winproc
, WIN_PROC_WINDOW
);
458 CLASS_RemoveWindow(Window
->Class
);
461 IntUnlinkWindow(Window
);
463 UserReferenceObject(Window
);
464 UserDeleteObject(Window
->head
.h
, otWindow
);
466 IntDestroyScrollBars(Window
);
468 /* dereference the class */
469 IntDereferenceClass(Window
->pcls
,
470 Window
->head
.pti
->pDeskInfo
,
471 Window
->head
.pti
->ppi
);
476 GreDeleteObject(Window
->hrgnClip
);
479 // ASSERT(Window != NULL);
480 UserFreeWindowInfo(Window
->head
.pti
, Window
);
482 UserDereferenceObject(Window
);
484 IntClipboardFreeWindow(Window
);
490 IntGetWindowBorderMeasures(PWND Wnd
, UINT
*cx
, UINT
*cy
)
492 if(HAS_DLGFRAME(Wnd
->style
, Wnd
->ExStyle
) && !(Wnd
->style
& WS_MINIMIZE
))
494 *cx
= UserGetSystemMetrics(SM_CXDLGFRAME
);
495 *cy
= UserGetSystemMetrics(SM_CYDLGFRAME
);
499 if(HAS_THICKFRAME(Wnd
->style
, Wnd
->ExStyle
)&& !(Wnd
->style
& WS_MINIMIZE
))
501 *cx
= UserGetSystemMetrics(SM_CXFRAME
);
502 *cy
= UserGetSystemMetrics(SM_CYFRAME
);
504 else if(HAS_THINFRAME(Wnd
->style
, Wnd
->ExStyle
))
506 *cx
= UserGetSystemMetrics(SM_CXBORDER
);
507 *cy
= UserGetSystemMetrics(SM_CYBORDER
);
517 // Same as User32:IntGetWndProc.
520 IntGetWindowProc(PWND pWnd
,
525 WNDPROC gcpd
, Ret
= 0;
527 ASSERT(UserIsEnteredExclusive() == TRUE
);
531 if (pWnd
->state
& WNDS_SERVERSIDEWINDOWPROC
)
533 for ( i
= FNID_FIRST
; i
<= FNID_SWITCH
; i
++)
535 if (GETPFNSERVER(i
) == pWnd
->lpfnWndProc
)
538 Ret
= GETPFNCLIENTA(i
);
540 Ret
= GETPFNCLIENTW(i
);
546 if (Class
->fnid
== FNID_EDIT
)
547 Ret
= pWnd
->lpfnWndProc
;
550 Ret
= pWnd
->lpfnWndProc
;
552 if (Class
->fnid
<= FNID_GHOST
&& Class
->fnid
>= FNID_BUTTON
)
556 if (GETPFNCLIENTW(Class
->fnid
) == pWnd
->lpfnWndProc
)
557 Ret
= GETPFNCLIENTA(Class
->fnid
);
561 if (GETPFNCLIENTA(Class
->fnid
) == pWnd
->lpfnWndProc
)
562 Ret
= GETPFNCLIENTW(Class
->fnid
);
565 if ( Ret
!= pWnd
->lpfnWndProc
)
568 if ( Ansi
== !!(pWnd
->state
& WNDS_ANSIWINDOWPROC
) )
571 gcpd
= (WNDPROC
)UserGetCPD(
573 (Ansi
? UserGetCPDA2U
: UserGetCPDU2A
)|UserGetCPDWindow
,
576 return (gcpd
? gcpd
: Ret
);
580 IntSetWindowProc(PWND pWnd
,
585 PCALLPROCDATA CallProc
;
587 WNDPROC Ret
, chWndProc
= NULL
;
589 // Retrieve previous window proc.
590 Ret
= IntGetWindowProc(pWnd
, Ansi
);
594 if (IsCallProcHandle(NewWndProc
))
596 CallProc
= UserGetObject(gHandleTable
, NewWndProc
, otCallProc
);
598 { // Reset new WndProc.
599 NewWndProc
= CallProc
->pfnClientPrevious
;
600 // Reset Ansi from CallProc handle. This is expected with wine "deftest".
601 Ansi
= !!(CallProc
->wType
& UserGetCPDU2A
);
604 // Switch from Client Side call to Server Side call if match. Ref: "deftest".
605 for ( i
= FNID_FIRST
; i
<= FNID_SWITCH
; i
++)
607 if (GETPFNCLIENTW(i
) == NewWndProc
)
609 chWndProc
= GETPFNSERVER(i
);
612 if (GETPFNCLIENTA(i
) == NewWndProc
)
614 chWndProc
= GETPFNSERVER(i
);
618 // If match, set/reset to Server Side and clear ansi.
621 pWnd
->lpfnWndProc
= chWndProc
;
622 pWnd
->Unicode
= TRUE
;
623 pWnd
->state
&= ~WNDS_ANSIWINDOWPROC
;
624 pWnd
->state
|= WNDS_SERVERSIDEWINDOWPROC
;
628 pWnd
->Unicode
= !Ansi
;
629 // Handle the state change in here.
631 pWnd
->state
|= WNDS_ANSIWINDOWPROC
;
633 pWnd
->state
&= ~WNDS_ANSIWINDOWPROC
;
635 if (pWnd
->state
& WNDS_SERVERSIDEWINDOWPROC
)
636 pWnd
->state
&= ~WNDS_SERVERSIDEWINDOWPROC
;
638 if (!NewWndProc
) NewWndProc
= pWnd
->lpfnWndProc
;
640 if (Class
->fnid
<= FNID_GHOST
&& Class
->fnid
>= FNID_BUTTON
)
644 if (GETPFNCLIENTW(Class
->fnid
) == NewWndProc
)
645 chWndProc
= GETPFNCLIENTA(Class
->fnid
);
649 if (GETPFNCLIENTA(Class
->fnid
) == NewWndProc
)
650 chWndProc
= GETPFNCLIENTW(Class
->fnid
);
653 // Now set the new window proc.
654 pWnd
->lpfnWndProc
= (chWndProc
? chWndProc
: NewWndProc
);
665 PMENU_OBJECT OldMenu
, NewMenu
= NULL
;
667 if ((Wnd
->style
& (WS_CHILD
| WS_POPUP
)) == WS_CHILD
)
669 SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE
);
673 *Changed
= (Wnd
->IDMenu
!= (UINT
) Menu
);
681 OldMenu
= IntGetMenuObject((HMENU
) Wnd
->IDMenu
);
682 ASSERT(NULL
== OldMenu
|| OldMenu
->MenuInfo
.Wnd
== Wnd
->head
.h
);
691 NewMenu
= IntGetMenuObject(Menu
);
696 IntReleaseMenuObject(OldMenu
);
698 SetLastWin32Error(ERROR_INVALID_MENU_HANDLE
);
701 if (NULL
!= NewMenu
->MenuInfo
.Wnd
)
703 /* Can't use the same menu for two windows */
706 IntReleaseMenuObject(OldMenu
);
708 SetLastWin32Error(ERROR_INVALID_MENU_HANDLE
);
714 Wnd
->IDMenu
= (UINT
) Menu
;
717 NewMenu
->MenuInfo
.Wnd
= Wnd
->head
.h
;
718 IntReleaseMenuObject(NewMenu
);
722 OldMenu
->MenuInfo
.Wnd
= NULL
;
723 IntReleaseMenuObject(OldMenu
);
730 /* INTERNAL ******************************************************************/
734 co_DestroyThreadWindows(struct _ETHREAD
*Thread
)
739 USER_REFERENCE_ENTRY Ref
;
740 WThread
= (PTHREADINFO
)Thread
->Tcb
.Win32Thread
;
742 while (!IsListEmpty(&WThread
->WindowListHead
))
744 Current
= WThread
->WindowListHead
.Flink
;
745 Wnd
= CONTAINING_RECORD(Current
, WND
, ThreadListEntry
);
747 DPRINT("thread cleanup: while destroy wnds, wnd=0x%x\n",Wnd
);
749 /* window removes itself from the list */
752 fixme: it is critical that the window removes itself! if now, we will loop
756 //ASSERT(co_UserDestroyWindow(Wnd));
758 UserRefObjectCo(Wnd
, &Ref
);//faxme: temp hack??
759 if (!co_UserDestroyWindow(Wnd
))
761 DPRINT1("Unable to destroy window 0x%x at thread cleanup... This is _VERY_ bad!\n", Wnd
);
763 UserDerefObjectCo(Wnd
);//faxme: temp hack??
771 * Returns client window rectangle relative to the upper-left corner of client area.
773 * \note Does not check the validity of the parameters
776 IntGetClientRect(PWND Window
, RECTL
*Rect
)
781 Rect
->left
= Rect
->top
= 0;
782 Rect
->right
= Window
->rcClient
.right
- Window
->rcClient
.left
;
783 Rect
->bottom
= Window
->rcClient
.bottom
- Window
->rcClient
.top
;
787 PMENU_OBJECT FASTCALL
788 IntGetSystemMenu(PWND Window
, BOOL bRevert
, BOOL RetMenu
)
790 PMENU_OBJECT Menu
, NewMenu
= NULL
, SysMenu
= NULL
, ret
= NULL
;
791 PTHREADINFO W32Thread
;
792 HMENU hNewMenu
, hSysMenu
;
793 ROSMENUITEMINFO ItemInfo
;
797 W32Thread
= PsGetCurrentThreadWin32Thread();
799 if(!W32Thread
->rpdesk
)
802 if(Window
->SystemMenu
)
804 Menu
= UserGetMenuObject(Window
->SystemMenu
);
807 IntDestroyMenuObject(Menu
, TRUE
, TRUE
);
808 Window
->SystemMenu
= (HMENU
)0;
812 if(W32Thread
->rpdesk
->rpwinstaParent
->SystemMenuTemplate
)
814 /* clone system menu */
815 Menu
= UserGetMenuObject(W32Thread
->rpdesk
->rpwinstaParent
->SystemMenuTemplate
);
819 NewMenu
= IntCloneMenu(Menu
);
822 Window
->SystemMenu
= NewMenu
->MenuInfo
.Self
;
823 NewMenu
->MenuInfo
.Flags
|= MF_SYSMENU
;
824 NewMenu
->MenuInfo
.Wnd
= Window
->head
.h
;
826 //IntReleaseMenuObject(NewMenu);
831 hSysMenu
= UserCreateMenu(FALSE
);
832 if (NULL
== hSysMenu
)
836 SysMenu
= IntGetMenuObject(hSysMenu
);
839 UserDestroyMenu(hSysMenu
);
842 SysMenu
->MenuInfo
.Flags
|= MF_SYSMENU
;
843 SysMenu
->MenuInfo
.Wnd
= Window
->head
.h
;
844 hNewMenu
= co_IntLoadSysMenuTemplate();
847 IntReleaseMenuObject(SysMenu
);
848 UserDestroyMenu(hSysMenu
);
851 Menu
= IntGetMenuObject(hNewMenu
);
854 IntReleaseMenuObject(SysMenu
);
855 UserDestroyMenu(hSysMenu
);
859 NewMenu
= IntCloneMenu(Menu
);
862 NewMenu
->MenuInfo
.Flags
|= MF_SYSMENU
| MF_POPUP
;
863 IntReleaseMenuObject(NewMenu
);
864 UserSetMenuDefaultItem(NewMenu
, SC_CLOSE
, FALSE
);
866 ItemInfo
.cbSize
= sizeof(MENUITEMINFOW
);
867 ItemInfo
.fMask
= MIIM_FTYPE
| MIIM_STRING
| MIIM_STATE
| MIIM_SUBMENU
;
868 ItemInfo
.fType
= MF_POPUP
;
869 ItemInfo
.fState
= MFS_ENABLED
;
870 ItemInfo
.dwTypeData
= NULL
;
872 ItemInfo
.hSubMenu
= NewMenu
->MenuInfo
.Self
;
873 IntInsertMenuItem(SysMenu
, (UINT
) -1, TRUE
, &ItemInfo
);
875 Window
->SystemMenu
= SysMenu
->MenuInfo
.Self
;
879 IntDestroyMenuObject(Menu
, FALSE
, TRUE
);
888 if(Window
->SystemMenu
)
889 return IntGetMenuObject((HMENU
)Window
->SystemMenu
);
897 IntIsChildWindow(PWND Parent
, PWND BaseWindow
)
904 if (Window
== Parent
)
908 if(!(Window
->style
& WS_CHILD
))
913 Window
= Window
->spwndParent
;
920 IntIsWindowVisible(PWND BaseWindow
)
927 if(!(Window
->style
& WS_CHILD
))
931 if(!(Window
->style
& WS_VISIBLE
))
936 Window
= Window
->spwndParent
;
939 if(Window
&& Window
->style
& WS_VISIBLE
)
949 link the window into siblings list
950 children and parent are kept in place.
955 PWND WndInsertAfter
/* set to NULL if top sibling */
958 if ((Wnd
->spwndPrev
= WndInsertAfter
))
960 /* link after WndInsertAfter */
961 if ((Wnd
->spwndNext
= WndInsertAfter
->spwndNext
))
962 Wnd
->spwndNext
->spwndPrev
= Wnd
;
964 Wnd
->spwndPrev
->spwndNext
= Wnd
;
969 if ((Wnd
->spwndNext
= Wnd
->spwndParent
->spwndChild
))
970 Wnd
->spwndNext
->spwndPrev
= Wnd
;
972 Wnd
->spwndParent
->spwndChild
= Wnd
;
977 VOID FASTCALL
IntLinkHwnd(PWND Wnd
, HWND hWndPrev
)
979 if (hWndPrev
== HWND_NOTOPMOST
)
981 if (!(Wnd
->ExStyle
& WS_EX_TOPMOST
) &&
982 (Wnd
->ExStyle2
& WS_EX2_LINKED
)) return; /* nothing to do */
983 Wnd
->ExStyle
&= ~WS_EX_TOPMOST
;
984 hWndPrev
= HWND_TOP
; /* fallback to the HWND_TOP case */
987 IntUnlinkWindow(Wnd
); /* unlink it from the previous location */
989 if (hWndPrev
== HWND_BOTTOM
)
991 /* Link in the bottom of the list */
994 WndInsertAfter
= Wnd
->spwndParent
->spwndChild
;
995 while( WndInsertAfter
&& WndInsertAfter
->spwndNext
)
996 WndInsertAfter
= WndInsertAfter
->spwndNext
;
998 IntLinkWindow(Wnd
, WndInsertAfter
);
999 Wnd
->ExStyle
&= ~WS_EX_TOPMOST
;
1001 else if (hWndPrev
== HWND_TOPMOST
)
1003 /* Link in the top of the list */
1004 IntLinkWindow(Wnd
, NULL
);
1006 Wnd
->ExStyle
|= WS_EX_TOPMOST
;
1008 else if (hWndPrev
== HWND_TOP
)
1010 /* Link it after the last topmost window */
1011 PWND WndInsertBefore
;
1013 WndInsertBefore
= Wnd
->spwndParent
->spwndChild
;
1015 if (!(Wnd
->ExStyle
& WS_EX_TOPMOST
)) /* put it above the first non-topmost window */
1017 while (WndInsertBefore
!= NULL
&& WndInsertBefore
->spwndNext
!= NULL
)
1019 if (!(WndInsertBefore
->ExStyle
& WS_EX_TOPMOST
)) break;
1020 if (WndInsertBefore
== Wnd
->spwndOwner
) /* keep it above owner */
1022 Wnd
->ExStyle
|= WS_EX_TOPMOST
;
1025 WndInsertBefore
= WndInsertBefore
->spwndNext
;
1029 IntLinkWindow(Wnd
, WndInsertBefore
? WndInsertBefore
->spwndPrev
: NULL
);
1033 /* Link it after hWndPrev */
1034 PWND WndInsertAfter
;
1036 WndInsertAfter
= UserGetWindowObject(hWndPrev
);
1037 /* Are we called with an erroneous handle */
1038 if(WndInsertAfter
== NULL
)
1040 /* Link in a default position */
1041 IntLinkHwnd(Wnd
, HWND_TOP
);
1045 IntLinkWindow(Wnd
, WndInsertAfter
);
1047 /* Fix the WS_EX_TOPMOST flag */
1048 if (!(WndInsertAfter
->ExStyle
& WS_EX_TOPMOST
))
1050 Wnd
->ExStyle
&= ~WS_EX_TOPMOST
;
1054 if(WndInsertAfter
->spwndNext
&&
1055 WndInsertAfter
->spwndNext
->ExStyle
& WS_EX_TOPMOST
)
1057 Wnd
->ExStyle
|= WS_EX_TOPMOST
;
1064 IntSetOwner(HWND hWnd
, HWND hWndNewOwner
)
1066 PWND Wnd
, WndOldOwner
, WndNewOwner
;
1069 Wnd
= IntGetWindowObject(hWnd
);
1073 WndOldOwner
= Wnd
->spwndOwner
;
1075 ret
= WndOldOwner
? WndOldOwner
->head
.h
: 0;
1077 if((WndNewOwner
= UserGetWindowObject(hWndNewOwner
)))
1079 Wnd
->spwndOwner
= WndNewOwner
;
1083 Wnd
->spwndOwner
= NULL
;
1086 UserDereferenceObject(Wnd
);
1091 co_IntSetParent(PWND Wnd
, PWND WndNewParent
)
1097 ASSERT(WndNewParent
);
1098 ASSERT_REFS_CO(Wnd
);
1099 ASSERT_REFS_CO(WndNewParent
);
1101 /* Some applications try to set a child as a parent */
1102 if (IntIsChildWindow(Wnd
, WndNewParent
))
1104 SetLastWin32Error( ERROR_INVALID_PARAMETER
);
1109 * Windows hides the window first, then shows it again
1110 * including the WM_SHOWWINDOW messages and all
1112 WasVisible
= co_WinPosShowWindow(Wnd
, SW_HIDE
);
1114 /* Window must belong to current process */
1115 if (Wnd
->head
.pti
->pEThread
->ThreadsProcess
!= PsGetCurrentProcess())
1118 WndOldParent
= Wnd
->spwndParent
;
1120 if (WndOldParent
) UserReferenceObject(WndOldParent
); /* caller must deref */
1122 if (WndNewParent
!= WndOldParent
)
1124 /* Unlink the window from the siblings list */
1125 IntUnlinkWindow(Wnd
);
1127 /* Set the new parent */
1128 Wnd
->spwndParent
= WndNewParent
;
1130 /* Link the window with its new siblings*/
1131 IntLinkHwnd(Wnd
, HWND_TOP
);
1135 IntNotifyWinEvent(EVENT_OBJECT_PARENTCHANGE
, Wnd
,OBJID_WINDOW
, CHILDID_SELF
, WEF_SETBYWNDPTI
);
1137 * SetParent additionally needs to make hwnd the top window
1138 * in the z-order and send the expected WM_WINDOWPOSCHANGING and
1139 * WM_WINDOWPOSCHANGED notification messages.
1141 co_WinPosSetWindowPos(Wnd
, (0 == (Wnd
->ExStyle
& WS_EX_TOPMOST
) ? HWND_TOP
: HWND_TOPMOST
),
1142 0, 0, 0, 0, SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOSIZE
1143 | (WasVisible
? SWP_SHOWWINDOW
: 0));
1146 * FIXME: a WM_MOVE is also generated (in the DefWindowProc handler
1147 * for WM_WINDOWPOSCHANGED) in Windows, should probably remove SWP_NOMOVE
1150 return WndOldParent
;
1154 IntSetSystemMenu(PWND Window
, PMENU_OBJECT Menu
)
1156 PMENU_OBJECT OldMenu
;
1157 if(Window
->SystemMenu
)
1159 OldMenu
= IntGetMenuObject(Window
->SystemMenu
);
1162 OldMenu
->MenuInfo
.Flags
&= ~ MF_SYSMENU
;
1163 IntReleaseMenuObject(OldMenu
);
1169 /* FIXME check window style, propably return FALSE ? */
1170 Window
->SystemMenu
= Menu
->MenuInfo
.Self
;
1171 Menu
->MenuInfo
.Flags
|= MF_SYSMENU
;
1174 Window
->SystemMenu
= (HMENU
)0;
1179 /* unlink the window from siblings. children and parent are kept in place. */
1181 IntUnlinkWindow(PWND Wnd
)
1184 Wnd
->spwndNext
->spwndPrev
= Wnd
->spwndPrev
;
1187 Wnd
->spwndPrev
->spwndNext
= Wnd
->spwndNext
;
1189 if (Wnd
->spwndParent
&& Wnd
->spwndParent
->spwndChild
== Wnd
)
1190 Wnd
->spwndParent
->spwndChild
= Wnd
->spwndNext
;
1192 Wnd
->spwndPrev
= Wnd
->spwndNext
= NULL
;
1197 IntGetWindowPlacement(PWND Wnd
, WINDOWPLACEMENT
*lpwndpl
)
1201 if (!Wnd
) return FALSE
;
1203 if(lpwndpl
->length
!= sizeof(WINDOWPLACEMENT
))
1209 if (0 == (Wnd
->style
& WS_VISIBLE
))
1211 lpwndpl
->showCmd
= SW_HIDE
;
1213 else if (0 != (Wnd
->state2
& WNDS2_MAXIMIZEBUTTONDOWN
) ||
1214 0 != (Wnd
->style
& WS_MAXIMIZE
))
1216 lpwndpl
->showCmd
= SW_MAXIMIZE
;
1218 else if (0 != (Wnd
->style
& WS_MINIMIZE
))
1220 lpwndpl
->showCmd
= SW_MINIMIZE
;
1222 else if (0 != (Wnd
->style
& WS_VISIBLE
))
1224 lpwndpl
->showCmd
= SW_SHOWNORMAL
;
1227 Size
.x
= Wnd
->rcWindow
.left
;
1228 Size
.y
= Wnd
->rcWindow
.top
;
1229 WinPosInitInternalPos(Wnd
, &Size
,
1232 lpwndpl
->rcNormalPosition
= Wnd
->InternalPos
.NormalRect
;
1233 lpwndpl
->ptMinPosition
= Wnd
->InternalPos
.IconPos
;
1234 lpwndpl
->ptMaxPosition
= Wnd
->InternalPos
.MaxPos
;
1240 /* FUNCTIONS *****************************************************************/
1243 * As best as I can figure, this function is used by EnumWindows,
1244 * EnumChildWindows, EnumDesktopWindows, & EnumThreadWindows.
1246 * It's supposed to build a list of HWNDs to return to the caller.
1247 * We can figure out what kind of list by what parameters are
1255 NtUserBuildHwndList(
1268 return ERROR_INVALID_PARAMETER
;
1270 if (hwndParent
|| !dwThreadId
)
1273 PWND Parent
, Window
;
1277 if(hDesktop
== NULL
&& !(Desktop
= IntGetActiveDesktop()))
1279 return ERROR_INVALID_HANDLE
;
1284 Status
= IntValidateDesktopHandle(hDesktop
,
1288 if(!NT_SUCCESS(Status
))
1290 return ERROR_INVALID_HANDLE
;
1293 hwndParent
= Desktop
->DesktopWindow
;
1300 if((Parent
= UserGetWindowObject(hwndParent
)) &&
1301 (Window
= Parent
->spwndChild
))
1303 BOOL bGoDown
= TRUE
;
1305 Status
= STATUS_SUCCESS
;
1310 if(dwCount
++ < *pBufSize
&& pWnd
)
1314 ProbeForWrite(pWnd
, sizeof(HWND
), 1);
1315 *pWnd
= Window
->head
.h
;
1318 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1320 Status
= _SEH2_GetExceptionCode();
1323 if(!NT_SUCCESS(Status
))
1325 SetLastNtError(Status
);
1329 if (Window
->spwndChild
&& bChildren
)
1331 Window
= Window
->spwndChild
;
1336 if (Window
->spwndNext
)
1338 Window
= Window
->spwndNext
;
1342 Window
= Window
->spwndParent
;
1343 if (Window
== Parent
)
1352 ObDereferenceObject(Desktop
);
1358 PTHREADINFO W32Thread
;
1359 PLIST_ENTRY Current
;
1362 Status
= PsLookupThreadByThreadId((HANDLE
)dwThreadId
, &Thread
);
1363 if(!NT_SUCCESS(Status
))
1365 return ERROR_INVALID_PARAMETER
;
1367 if(!(W32Thread
= (PTHREADINFO
)Thread
->Tcb
.Win32Thread
))
1369 ObDereferenceObject(Thread
);
1370 DPRINT("Thread is not a GUI Thread!\n");
1371 return ERROR_INVALID_PARAMETER
;
1374 Current
= W32Thread
->WindowListHead
.Flink
;
1375 while(Current
!= &(W32Thread
->WindowListHead
))
1377 Window
= CONTAINING_RECORD(Current
, WND
, ThreadListEntry
);
1380 if(bChildren
|| Window
->spwndOwner
!= NULL
)
1382 if(dwCount
< *pBufSize
&& pWnd
)
1384 Status
= MmCopyToCaller(pWnd
++, &Window
->head
.h
, sizeof(HWND
));
1385 if(!NT_SUCCESS(Status
))
1387 SetLastNtError(Status
);
1393 Current
= Current
->Flink
;
1396 ObDereferenceObject(Thread
);
1399 *pBufSize
= dwCount
;
1400 return STATUS_SUCCESS
;
1408 NtUserChildWindowFromPointEx(HWND hwndParent
,
1418 if(!(Parent
= UserGetWindowObject(hwndParent
)))
1426 if(Parent
->head
.h
!= IntGetDesktopWindow())
1428 Pt
.x
+= Parent
->rcClient
.left
;
1429 Pt
.y
+= Parent
->rcClient
.top
;
1432 if(!IntPtInWindow(Parent
, Pt
.x
, Pt
.y
))
1437 Ret
= Parent
->head
.h
;
1438 if((List
= IntWinListChildren(Parent
)))
1440 for(phWnd
= List
; *phWnd
; phWnd
++)
1443 if((Child
= UserGetWindowObject(*phWnd
)))
1445 if(!(Child
->style
& WS_VISIBLE
) && (uiFlags
& CWP_SKIPINVISIBLE
))
1449 if((Child
->style
& WS_DISABLED
) && (uiFlags
& CWP_SKIPDISABLED
))
1453 if((Child
->ExStyle
& WS_EX_TRANSPARENT
) && (uiFlags
& CWP_SKIPTRANSPARENT
))
1457 if(IntPtInWindow(Child
, Pt
.x
, Pt
.y
))
1459 Ret
= Child
->head
.h
;
1470 static void IntSendParentNotify( PWND pWindow
, UINT msg
)
1472 if ( (pWindow
->style
& (WS_CHILD
| WS_POPUP
)) == WS_CHILD
&&
1473 !(pWindow
->style
& WS_EX_NOPARENTNOTIFY
))
1475 if (pWindow
->spwndParent
&& pWindow
->spwndParent
!= UserGetDesktopWindow())
1477 co_IntSendMessage( pWindow
->spwndParent
->head
.h
,
1479 MAKEWPARAM( msg
, pWindow
->IDMenu
),
1480 (LPARAM
)pWindow
->head
.h
);
1486 IntFixWindowCoordinates(CREATESTRUCTW
* Cs
, PWND ParentWindow
, DWORD
* dwShowMode
)
1488 #define IS_DEFAULT(x) ((x) == CW_USEDEFAULT || (x) == (SHORT)0x8000)
1490 /* default positioning for overlapped windows */
1491 if(!(Cs
->style
& (WS_POPUP
| WS_CHILD
)))
1494 PRTL_USER_PROCESS_PARAMETERS ProcessParams
;
1496 pMonitor
= IntGetPrimaryMonitor();
1499 ProcessParams
= PsGetCurrentProcess()->Peb
->ProcessParameters
;
1501 if (IS_DEFAULT(Cs
->x
))
1503 if (!IS_DEFAULT(Cs
->y
)) *dwShowMode
= Cs
->y
;
1505 if(ProcessParams
->WindowFlags
& STARTF_USEPOSITION
)
1507 Cs
->x
= ProcessParams
->StartingX
;
1508 Cs
->y
= ProcessParams
->StartingY
;
1512 Cs
->x
= pMonitor
->cWndStack
* (UserGetSystemMetrics(SM_CXSIZE
) + UserGetSystemMetrics(SM_CXFRAME
));
1513 Cs
->y
= pMonitor
->cWndStack
* (UserGetSystemMetrics(SM_CYSIZE
) + UserGetSystemMetrics(SM_CYFRAME
));
1514 if (Cs
->x
> ((pMonitor
->rcWork
.right
- pMonitor
->rcWork
.left
) / 4) ||
1515 Cs
->y
> ((pMonitor
->rcWork
.bottom
- pMonitor
->rcWork
.top
) / 4))
1517 /* reset counter and position */
1520 pMonitor
->cWndStack
= 0;
1522 pMonitor
->cWndStack
++;
1526 if (IS_DEFAULT(Cs
->cx
))
1528 if (ProcessParams
->WindowFlags
& STARTF_USEPOSITION
)
1530 Cs
->cx
= ProcessParams
->CountX
;
1531 Cs
->cy
= ProcessParams
->CountY
;
1535 Cs
->cx
= (pMonitor
->rcWork
.right
- pMonitor
->rcWork
.left
) * 3 / 4;
1536 Cs
->cy
= (pMonitor
->rcWork
.bottom
- pMonitor
->rcWork
.top
) * 3 / 4;
1539 /* neither x nor cx are default. Check the y values .
1540 * In the trace we see Outlook and Outlook Express using
1541 * cy set to CW_USEDEFAULT when opening the address book.
1543 else if (IS_DEFAULT(Cs
->cy
))
1545 DPRINT("Strange use of CW_USEDEFAULT in nHeight\n");
1546 Cs
->cy
= (pMonitor
->rcWork
.bottom
- pMonitor
->rcWork
.top
) * 3 / 4;
1551 /* if CW_USEDEFAULT is set for non-overlapped windows, both values are set to zero */
1552 if(IS_DEFAULT(Cs
->x
))
1557 if(IS_DEFAULT(Cs
->cx
))
1567 /* Allocates and initializes a window*/
1568 PWND FASTCALL
IntCreateWindow(CREATESTRUCTW
* Cs
,
1569 PLARGE_STRING WindowName
,
1576 PTHREADINFO pti
= NULL
;
1577 PMENU_OBJECT SystemMenu
;
1579 BOOL bUnicodeWindow
;
1581 pti
= PsGetCurrentThreadWin32Thread();
1583 if (!(Cs
->dwExStyle
& WS_EX_LAYOUTRTL
))
1587 if ( (Cs
->style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
&&
1588 ParentWindow
->ExStyle
& WS_EX_LAYOUTRTL
&&
1589 !(ParentWindow
->ExStyle
& WS_EX_NOINHERITLAYOUT
) )
1590 Cs
->dwExStyle
|= WS_EX_LAYOUTRTL
;
1594 Note from MSDN http://msdn.microsoft.com/en-us/library/aa913269.aspx :
1596 Dialog boxes and message boxes do not inherit layout, so you must
1597 set the layout explicitly.
1599 if ( Class
&& Class
->fnid
!= FNID_DIALOG
)
1601 PPROCESSINFO ppi
= PsGetCurrentProcessWin32Process();
1602 if (ppi
->dwLayout
& LAYOUT_RTL
)
1604 Cs
->dwExStyle
|= WS_EX_LAYOUTRTL
;
1610 /* Automatically add WS_EX_WINDOWEDGE */
1611 if ((Cs
->dwExStyle
& WS_EX_DLGMODALFRAME
) ||
1612 ((!(Cs
->dwExStyle
& WS_EX_STATICEDGE
)) &&
1613 (Cs
->style
& (WS_DLGFRAME
| WS_THICKFRAME
))))
1614 Cs
->dwExStyle
|= WS_EX_WINDOWEDGE
;
1616 Cs
->dwExStyle
&= ~WS_EX_WINDOWEDGE
;
1618 /* Is it a unicode window? */
1619 bUnicodeWindow
=!(Cs
->dwExStyle
& WS_EX_SETANSICREATOR
);
1620 Cs
->dwExStyle
&= ~WS_EX_SETANSICREATOR
;
1622 /* Allocate the new window */
1623 pWnd
= (PWND
) UserCreateObject( gHandleTable
,
1627 sizeof(WND
) + Class
->cbwndExtra
);
1634 DPRINT("Created object with handle %X\n", hWnd
);
1636 if (NULL
== pti
->rpdesk
->DesktopWindow
)
1638 /* If there is no desktop window yet, we must be creating it */
1639 pti
->rpdesk
->DesktopWindow
= hWnd
;
1640 pti
->rpdesk
->pDeskInfo
->spwnd
= pWnd
;
1644 * Fill out the structure describing it.
1646 /* Remember, pWnd->head is setup in object.c ...*/
1647 pWnd
->spwndParent
= ParentWindow
;
1648 pWnd
->spwndOwner
= OwnerWindow
;
1650 pWnd
->hWndLastActive
= hWnd
;
1651 pWnd
->state2
|= WNDS2_WIN40COMPAT
;
1653 pWnd
->hModule
= Cs
->hInstance
;
1654 pWnd
->style
= Cs
->style
& ~WS_VISIBLE
;
1655 pWnd
->ExStyle
= Cs
->dwExStyle
;
1656 pWnd
->cbwndExtra
= pWnd
->pcls
->cbwndExtra
;
1658 IntReferenceMessageQueue(pWnd
->head
.pti
->MessageQueue
);
1659 if (pWnd
->spwndParent
!= NULL
&& Cs
->hwndParent
!= 0)
1661 pWnd
->HideFocus
= pWnd
->spwndParent
->HideFocus
;
1662 pWnd
->HideAccel
= pWnd
->spwndParent
->HideAccel
;
1665 if (pWnd
->pcls
->CSF_flags
& CSF_SERVERSIDEPROC
)
1666 pWnd
->state
|= WNDS_SERVERSIDEWINDOWPROC
;
1668 /* BugBoy Comments: Comment below say that System classes are always created
1669 as UNICODE. In windows, creating a window with the ANSI version of CreateWindow
1670 sets the window to ansi as verified by testing with IsUnicodeWindow API.
1672 No where can I see in code or through testing does the window change back
1673 to ANSI after being created as UNICODE in ROS. I didnt do more testing to
1674 see what problems this would cause.*/
1676 // Set WndProc from Class.
1677 pWnd
->lpfnWndProc
= pWnd
->pcls
->lpfnWndProc
;
1679 // GetWindowProc, test for non server side default classes and set WndProc.
1680 if ( pWnd
->pcls
->fnid
<= FNID_GHOST
&& pWnd
->pcls
->fnid
>= FNID_BUTTON
)
1684 if (GETPFNCLIENTA(pWnd
->pcls
->fnid
) == pWnd
->lpfnWndProc
)
1685 pWnd
->lpfnWndProc
= GETPFNCLIENTW(pWnd
->pcls
->fnid
);
1689 if (GETPFNCLIENTW(pWnd
->pcls
->fnid
) == pWnd
->lpfnWndProc
)
1690 pWnd
->lpfnWndProc
= GETPFNCLIENTA(pWnd
->pcls
->fnid
);
1694 // If not an Unicode caller, set Ansi creator bit.
1695 if (!bUnicodeWindow
) pWnd
->state
|= WNDS_ANSICREATOR
;
1697 // Clone Class Ansi/Unicode proc type.
1698 if (pWnd
->pcls
->CSF_flags
& CSF_ANSIPROC
)
1700 pWnd
->state
|= WNDS_ANSIWINDOWPROC
;
1701 pWnd
->Unicode
= FALSE
;
1705 It seems there can be both an Ansi creator and Unicode Class Window
1706 WndProc, unless the following overriding conditions occur:
1708 if ( !bUnicodeWindow
&&
1709 ( Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_BUTTON
] ||
1710 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_COMBOBOX
] ||
1711 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_COMBOLBOX
] ||
1712 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_DIALOG
] ||
1713 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_EDIT
] ||
1714 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_IME
] ||
1715 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_LISTBOX
] ||
1716 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_MDICLIENT
] ||
1717 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_STATIC
] ) )
1718 { // Override Class and set the window Ansi WndProc.
1719 pWnd
->state
|= WNDS_ANSIWINDOWPROC
;
1720 pWnd
->Unicode
= FALSE
;
1723 { // Set the window Unicode WndProc.
1724 pWnd
->state
&= ~WNDS_ANSIWINDOWPROC
;
1725 pWnd
->Unicode
= TRUE
;
1729 /* BugBoy Comments: if the window being created is a edit control, ATOM 0xCxxx,
1730 then my testing shows that windows (2k and XP) creates a CallProc for it immediately
1731 Dont understand why it does this. */
1732 if (Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_EDIT
])
1734 PCALLPROCDATA CallProc
;
1735 CallProc
= CreateCallProc(NULL
, pWnd
->lpfnWndProc
, pWnd
->Unicode
, pWnd
->head
.pti
->ppi
);
1739 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
1740 DPRINT1("Warning: Unable to create CallProc for edit control. Control may not operate correctly! hwnd %x\n",hWnd
);
1744 UserAddCallProcToClass(pWnd
->pcls
, CallProc
);
1748 InitializeListHead(&pWnd
->PropListHead
);
1750 if ( WindowName
->Buffer
!= NULL
&& WindowName
->Length
> 0 )
1752 pWnd
->strName
.Buffer
= DesktopHeapAlloc(pWnd
->head
.rpdesk
,
1753 WindowName
->Length
+ sizeof(UNICODE_NULL
));
1754 if (pWnd
->strName
.Buffer
== NULL
)
1759 RtlCopyMemory(pWnd
->strName
.Buffer
, WindowName
->Buffer
, WindowName
->Length
);
1760 pWnd
->strName
.Buffer
[WindowName
->Length
/ sizeof(WCHAR
)] = L
'\0';
1761 pWnd
->strName
.Length
= WindowName
->Length
;
1762 pWnd
->strName
.MaximumLength
= WindowName
->Length
+ sizeof(UNICODE_NULL
);
1765 /* Correct the window style. */
1766 if ((pWnd
->style
& (WS_CHILD
| WS_POPUP
)) != WS_CHILD
)
1768 pWnd
->style
|= WS_CLIPSIBLINGS
;
1769 if (!(pWnd
->style
& WS_POPUP
))
1771 pWnd
->style
|= WS_CAPTION
;
1772 pWnd
->state
|= WNDS_SENDSIZEMOVEMSGS
;
1776 if ((pWnd
->ExStyle
& WS_EX_DLGMODALFRAME
) ||
1777 (pWnd
->style
& (WS_DLGFRAME
| WS_THICKFRAME
)))
1778 pWnd
->ExStyle
|= WS_EX_WINDOWEDGE
;
1780 pWnd
->ExStyle
&= ~WS_EX_WINDOWEDGE
;
1782 /* create system menu */
1783 if((Cs
->style
& WS_SYSMENU
) )//&& (dwStyle & WS_CAPTION) == WS_CAPTION)
1785 SystemMenu
= IntGetSystemMenu(pWnd
, TRUE
, TRUE
);
1788 pWnd
->SystemMenu
= SystemMenu
->MenuInfo
.Self
;
1789 IntReleaseMenuObject(SystemMenu
);
1793 /* Set the window menu */
1794 if ((Cs
->style
& (WS_CHILD
| WS_POPUP
)) != WS_CHILD
)
1797 IntSetMenu(pWnd
, Cs
->hMenu
, &MenuChanged
);
1798 else if (pWnd
->pcls
->lpszMenuName
) // Take it from the parent.
1800 UNICODE_STRING MenuName
;
1803 if (IS_INTRESOURCE(pWnd
->pcls
->lpszMenuName
))
1805 MenuName
.Length
= 0;
1806 MenuName
.MaximumLength
= 0;
1807 MenuName
.Buffer
= pWnd
->pcls
->lpszMenuName
;
1811 RtlInitUnicodeString( &MenuName
, pWnd
->pcls
->lpszMenuName
);
1813 hMenu
= co_IntCallLoadMenu( pWnd
->pcls
->hModule
, &MenuName
);
1814 if (hMenu
) IntSetMenu(pWnd
, hMenu
, &MenuChanged
);
1818 pWnd
->IDMenu
= (UINT
) Cs
->hMenu
;
1820 /* Insert the window into the thread's window list. */
1821 InsertTailList (&pti
->WindowListHead
, &pWnd
->ThreadListEntry
);
1823 /* Handle "CS_CLASSDC", it is tested first. */
1824 if ( (pWnd
->pcls
->style
& CS_CLASSDC
) && !(pWnd
->pcls
->pdce
) )
1825 { /* One DCE per class to have CLASS. */
1826 pWnd
->pcls
->pdce
= DceAllocDCE( pWnd
, DCE_CLASS_DC
);
1828 else if ( pWnd
->pcls
->style
& CS_OWNDC
)
1829 { /* Allocate a DCE for this window. */
1830 DceAllocDCE(pWnd
, DCE_WINDOW_DC
);
1838 UserDereferenceObject(pWnd
);
1840 SetLastNtError(STATUS_INSUFFICIENT_RESOURCES
);
1848 co_UserCreateWindowEx(CREATESTRUCTW
* Cs
,
1849 PUNICODE_STRING ClassName
,
1850 PLARGE_STRING WindowName
)
1852 PWND Window
= NULL
, ParentWindow
= NULL
, OwnerWindow
;
1853 HWND hWnd
, hWndParent
, hWndOwner
, hwndInsertAfter
;
1854 PWINSTATION_OBJECT WinSta
;
1858 CBT_CREATEWNDW
* pCbtCreate
;
1860 USER_REFERENCE_ENTRY ParentRef
, Ref
;
1862 DWORD dwShowMode
= SW_SHOW
;
1863 CREATESTRUCTW
*pCsw
= NULL
;
1864 PVOID pszClass
= NULL
, pszName
= NULL
;
1865 DECLARE_RETURN(PWND
);
1867 /* Get the current window station and reference it */
1868 pti
= GetW32ThreadInfo();
1869 if (pti
== NULL
|| pti
->rpdesk
== NULL
)
1871 DPRINT1("Thread is not attached to a desktop! Cannot create window!\n");
1872 return NULL
; //There is nothing to cleanup
1874 WinSta
= pti
->rpdesk
->rpwinstaParent
;
1875 ObReferenceObjectByPointer(WinSta
, KernelMode
, ExWindowStationObjectType
, 0);
1880 /* Get the class and reference it*/
1881 Class
= IntGetAndReferenceClass(ClassName
, Cs
->hInstance
);
1884 DPRINT1("Failed to find class %wZ\n", ClassName
);
1888 /* Now find the parent and the owner window */
1889 hWndParent
= IntGetDesktopWindow();
1892 if (Cs
->hwndParent
== HWND_MESSAGE
)
1894 Cs
->hwndParent
= hWndParent
= IntGetMessageWindow();
1896 else if (Cs
->hwndParent
)
1898 if ((Cs
->style
& (WS_CHILD
|WS_POPUP
)) != WS_CHILD
)
1899 hWndOwner
= Cs
->hwndParent
;
1901 hWndParent
= Cs
->hwndParent
;
1903 else if ((Cs
->style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
)
1905 DPRINT1("Cannot create a child window without a parrent!\n");
1906 SetLastWin32Error(ERROR_TLW_WITH_WSCHILD
);
1907 RETURN(NULL
); /* WS_CHILD needs a parent, but WS_POPUP doesn't */
1910 ParentWindow
= hWndParent
? UserGetWindowObject(hWndParent
): NULL
;
1911 OwnerWindow
= hWndOwner
? UserGetWindowObject(hWndOwner
): NULL
;
1913 /* FIXME: is this correct?*/
1915 OwnerWindow
= UserGetAncestor(OwnerWindow
, GA_ROOT
);
1917 /* Fix the position and the size of the window */
1920 UserRefObjectCo(ParentWindow
, &ParentRef
);
1921 IntFixWindowCoordinates(Cs
, ParentWindow
, &dwShowMode
);
1924 /* Allocate and initialize the new window */
1925 Window
= IntCreateWindow(Cs
,
1932 DPRINT1("IntCreateWindow failed!\n");
1936 hWnd
= UserHMGetHandle(Window
);
1937 hwndInsertAfter
= HWND_TOP
;
1939 UserRefObjectCo(Window
, &Ref
);
1940 ObDereferenceObject(WinSta
);
1942 //// Check for a hook to eliminate overhead. ////
1943 if ( ISITHOOKED(WH_CBT
) || (pti
->rpdesk
->pDeskInfo
->fsHooks
& HOOKID_TO_FLAG(WH_CBT
)) )
1945 // Allocate the calling structures Justin Case this goes Global.
1946 pCsw
= ExAllocatePoolWithTag(NonPagedPool
, sizeof(CREATESTRUCTW
), TAG_HOOK
);
1947 pCbtCreate
= ExAllocatePoolWithTag(NonPagedPool
, sizeof(CBT_CREATEWNDW
), TAG_HOOK
);
1949 /* Fill the new CREATESTRUCTW */
1950 RtlCopyMemory(pCsw
, Cs
, sizeof(CREATESTRUCTW
));
1951 pCsw
->style
= Window
->style
; /* HCBT_CREATEWND needs the real window style */
1953 // Based on the assumption this is from "unicode source" user32, ReactOS, answer is yes.
1954 if (!IS_ATOM(ClassName
->Buffer
))
1956 if (Window
->state
& WNDS_ANSICREATOR
)
1958 ANSI_STRING AnsiString
;
1959 AnsiString
.MaximumLength
= RtlUnicodeStringToAnsiSize(ClassName
)+sizeof(CHAR
);
1960 pszClass
= UserHeapAlloc(AnsiString
.MaximumLength
);
1961 RtlZeroMemory(pszClass
, AnsiString
.MaximumLength
);
1962 AnsiString
.Buffer
= (PCHAR
)pszClass
;
1963 RtlUnicodeStringToAnsiString(&AnsiString
, ClassName
, FALSE
);
1967 UNICODE_STRING UnicodeString
;
1968 UnicodeString
.MaximumLength
= ClassName
->Length
+ sizeof(UNICODE_NULL
);
1969 pszClass
= UserHeapAlloc(UnicodeString
.MaximumLength
);
1970 RtlZeroMemory(pszClass
, UnicodeString
.MaximumLength
);
1971 UnicodeString
.Buffer
= (PWSTR
)pszClass
;
1972 RtlCopyUnicodeString(&UnicodeString
, ClassName
);
1974 if (pszClass
) pCsw
->lpszClass
= UserHeapAddressToUser(pszClass
);
1976 if (WindowName
->Length
)
1978 UNICODE_STRING Name
;
1979 Name
.Buffer
= WindowName
->Buffer
;
1980 Name
.Length
= WindowName
->Length
;
1981 Name
.MaximumLength
= WindowName
->MaximumLength
;
1983 if (Window
->state
& WNDS_ANSICREATOR
)
1985 ANSI_STRING AnsiString
;
1986 AnsiString
.MaximumLength
= RtlUnicodeStringToAnsiSize(&Name
)+sizeof(CHAR
);
1987 pszName
= UserHeapAlloc(AnsiString
.MaximumLength
);
1988 RtlZeroMemory(pszName
, AnsiString
.MaximumLength
);
1989 AnsiString
.Buffer
= (PCHAR
)pszName
;
1990 RtlUnicodeStringToAnsiString(&AnsiString
, &Name
, FALSE
);
1994 UNICODE_STRING UnicodeString
;
1995 UnicodeString
.MaximumLength
= Name
.Length
+ sizeof(UNICODE_NULL
);
1996 pszName
= UserHeapAlloc(UnicodeString
.MaximumLength
);
1997 RtlZeroMemory(pszName
, UnicodeString
.MaximumLength
);
1998 UnicodeString
.Buffer
= (PWSTR
)pszName
;
1999 RtlCopyUnicodeString(&UnicodeString
, &Name
);
2001 if (pszName
) pCsw
->lpszName
= UserHeapAddressToUser(pszName
);
2004 pCbtCreate
->lpcs
= pCsw
;
2005 pCbtCreate
->hwndInsertAfter
= hwndInsertAfter
;
2007 //// Call the WH_CBT hook ////
2008 Result
= co_HOOK_CallHooks(WH_CBT
, HCBT_CREATEWND
, (WPARAM
) hWnd
, (LPARAM
) pCbtCreate
);
2011 DPRINT1("WH_CBT HCBT_CREATEWND hook failed! 0x%x\n", Result
);
2012 RETURN( (PWND
) NULL
);
2014 // Write back changes.
2019 hwndInsertAfter
= pCbtCreate
->hwndInsertAfter
;
2022 /* NCCREATE and WM_NCCALCSIZE need the original values */
2023 Cs
->lpszName
= (LPCWSTR
) WindowName
;
2024 Cs
->lpszClass
= (LPCWSTR
) ClassName
;
2026 /* Send the WM_GETMINMAXINFO message*/
2030 if ((Cs
->style
& WS_THICKFRAME
) || !(Cs
->style
& (WS_POPUP
| WS_CHILD
)))
2032 POINT MaxSize
, MaxPos
, MinTrack
, MaxTrack
;
2034 co_WinPosGetMinMaxInfo(Window
, &MaxSize
, &MaxPos
, &MinTrack
, &MaxTrack
);
2035 if (Size
.cx
> MaxTrack
.x
) Size
.cx
= MaxTrack
.x
;
2036 if (Size
.cy
> MaxTrack
.y
) Size
.cy
= MaxTrack
.y
;
2037 if (Size
.cx
< MinTrack
.x
) Size
.cx
= MinTrack
.x
;
2038 if (Size
.cy
< MinTrack
.y
) Size
.cy
= MinTrack
.y
;
2041 Window
->rcWindow
.left
= Cs
->x
;
2042 Window
->rcWindow
.top
= Cs
->y
;
2043 Window
->rcWindow
.right
= Cs
->x
+ Size
.cx
;
2044 Window
->rcWindow
.bottom
= Cs
->y
+ Size
.cy
;
2045 if (0 != (Window
->style
& WS_CHILD
) && ParentWindow
)
2047 RECTL_vOffsetRect(&Window
->rcWindow
,
2048 ParentWindow
->rcClient
.left
,
2049 ParentWindow
->rcClient
.top
);
2051 Window
->rcClient
= Window
->rcWindow
;
2054 /* Link the window*/
2055 if (NULL
!= ParentWindow
)
2057 /* link the window into the siblings list */
2058 if ((Cs
->style
& (WS_CHILD
|WS_MAXIMIZE
)) == WS_CHILD
)
2059 IntLinkHwnd(Window
, HWND_BOTTOM
);
2061 IntLinkHwnd(Window
, hwndInsertAfter
);
2064 /* Send the NCCREATE message */
2065 Result
= co_IntSendMessage(UserHMGetHandle(Window
), WM_NCCREATE
, 0, (LPARAM
) Cs
);
2068 DPRINT1("co_UserCreateWindowEx(): NCCREATE message failed\n");
2072 /* Send the WM_NCCALCSIZE message */
2073 MaxPos
.x
= Window
->rcWindow
.left
;
2074 MaxPos
.y
= Window
->rcWindow
.top
;
2076 Result
= co_WinPosGetNonClientSize(Window
, &Window
->rcWindow
, &Window
->rcClient
);
2078 RECTL_vOffsetRect(&Window
->rcWindow
, MaxPos
.x
- Window
->rcWindow
.left
,
2079 MaxPos
.y
- Window
->rcWindow
.top
);
2082 /* Send the WM_CREATE message. */
2083 Result
= co_IntSendMessage(UserHMGetHandle(Window
), WM_CREATE
, 0, (LPARAM
) Cs
);
2084 if (Result
== (LRESULT
)-1)
2086 DPRINT1("co_UserCreateWindowEx(): WM_CREATE message failed\n");
2090 /* Send the EVENT_OBJECT_CREATE event*/
2091 IntNotifyWinEvent(EVENT_OBJECT_CREATE
, Window
, OBJID_WINDOW
, CHILDID_SELF
, 0);
2093 /* By setting the flag below it can be examined to determine if the window
2094 was created successfully and a valid pwnd was passed back to caller since
2095 from here the function has to succeed. */
2096 Window
->state2
|= WNDS2_WMCREATEMSGPROCESSED
;
2098 /* Send the WM_SIZE and WM_MOVE messages. */
2099 if (!(Window
->state
& WNDS_SENDSIZEMOVEMSGS
))
2101 co_WinPosSendSizeMove(Window
);
2104 /* Show or maybe minimize or maximize the window. */
2105 if (Window
->style
& (WS_MINIMIZE
| WS_MAXIMIZE
))
2110 SwFlag
= (Window
->style
& WS_MINIMIZE
) ? SW_MINIMIZE
: SW_MAXIMIZE
;
2112 co_WinPosMinMaximize(Window
, SwFlag
, &NewPos
);
2114 SwFlag
= ((Window
->style
& WS_CHILD
) || UserGetActiveWindow()) ?
2115 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
:
2116 SWP_NOZORDER
| SWP_FRAMECHANGED
;
2118 co_WinPosSetWindowPos(Window
, 0, NewPos
.left
, NewPos
.top
,
2119 NewPos
.right
, NewPos
.bottom
, SwFlag
);
2122 /* Send the WM_PARENTNOTIFY message */
2123 IntSendParentNotify(Window
, WM_CREATE
);
2125 /* Notify the shell that a new window was created */
2126 if ((!hWndParent
) && (!hWndOwner
))
2128 co_IntShellHookNotify(HSHELL_WINDOWCREATED
, (LPARAM
)hWnd
);
2131 /* Initialize and show the window's scrollbars */
2132 if (Window
->style
& WS_VSCROLL
)
2134 co_UserShowScrollBar(Window
, SB_VERT
, TRUE
);
2136 if (Window
->style
& WS_HSCROLL
)
2138 co_UserShowScrollBar(Window
, SB_HORZ
, TRUE
);
2141 /* Show the new window */
2142 if (Cs
->style
& WS_VISIBLE
)
2144 if (Window
->style
& WS_MAXIMIZE
)
2145 dwShowMode
= SW_SHOW
;
2146 else if (Window
->style
& WS_MINIMIZE
)
2147 dwShowMode
= SW_SHOWMINIMIZED
;
2149 co_WinPosShowWindow(Window
, dwShowMode
);
2151 if (Window
->ExStyle
& WS_EX_MDICHILD
)
2153 co_IntSendMessage(UserHMGetHandle(ParentWindow
), WM_MDIREFRESHMENU
, 0, 0);
2154 /* ShowWindow won't activate child windows */
2155 co_WinPosSetWindowPos(Window
, HWND_TOP
, 0, 0, 0, 0, SWP_SHOWWINDOW
| SWP_NOMOVE
| SWP_NOSIZE
);
2159 DPRINT("co_UserCreateWindowEx(): Created window %X\n", hWnd
);
2165 DPRINT("co_UserCreateWindowEx(): Error Created window!\n");
2166 /* If the window was created, the class will be dereferenced by co_UserDestroyWindow */
2168 co_UserDestroyWindow(Window
);
2170 IntDereferenceClass(Class
, pti
->pDeskInfo
, pti
->ppi
);
2173 if (pCsw
) ExFreePoolWithTag(pCsw
, TAG_HOOK
);
2174 if (pCbtCreate
) ExFreePoolWithTag(pCbtCreate
, TAG_HOOK
);
2175 if (pszName
) UserHeapFree(pszName
);
2176 if (pszClass
) UserHeapFree(pszClass
);
2180 UserDerefObjectCo(Window
);
2181 UserDereferenceObject(Window
);
2183 if (ParentWindow
) UserDerefObjectCo(ParentWindow
);
2190 ProbeAndCaptureLargeString(
2191 OUT PLARGE_STRING plstrSafe
,
2192 IN PLARGE_STRING plstrUnsafe
)
2194 LARGE_STRING lstrTemp
;
2195 PVOID pvBuffer
= NULL
;
2199 /* Probe and copy the string */
2200 ProbeForRead(plstrUnsafe
, sizeof(LARGE_STRING
), sizeof(ULONG
));
2201 lstrTemp
= *plstrUnsafe
;
2203 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2206 _SEH2_YIELD(return _SEH2_GetExceptionCode();)
2210 if (lstrTemp
.Length
!= 0)
2212 /* Allocate a buffer from paged pool */
2213 pvBuffer
= ExAllocatePoolWithTag(PagedPool
, lstrTemp
.Length
, TAG_STRING
);
2216 return STATUS_NO_MEMORY
;
2221 /* Probe and copy the buffer */
2222 ProbeForRead(lstrTemp
.Buffer
, lstrTemp
.Length
, sizeof(WCHAR
));
2223 RtlCopyMemory(pvBuffer
, lstrTemp
.Buffer
, lstrTemp
.Length
);
2225 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2227 /* Cleanup and fail */
2228 ExFreePool(pvBuffer
);
2229 _SEH2_YIELD(return _SEH2_GetExceptionCode();)
2234 /* Set the output string */
2235 plstrSafe
->Buffer
= pvBuffer
;
2236 plstrSafe
->Length
= lstrTemp
.Length
;
2237 plstrSafe
->MaximumLength
= lstrTemp
.Length
;
2239 return STATUS_SUCCESS
;
2243 * \todo Allow passing plstrClassName as ANSI.
2247 NtUserCreateWindowEx(
2249 PLARGE_STRING plstrClassName
,
2250 PLARGE_STRING plstrClsVersion
,
2251 PLARGE_STRING plstrWindowName
,
2259 HINSTANCE hInstance
,
2265 LARGE_STRING lstrWindowName
;
2266 LARGE_STRING lstrClassName
;
2267 UNICODE_STRING ustrClassName
;
2272 lstrWindowName
.Buffer
= NULL
;
2273 lstrClassName
.Buffer
= NULL
;
2275 /* Check if we got a Window name */
2276 if (plstrWindowName
)
2278 /* Copy the string to kernel mode */
2279 Status
= ProbeAndCaptureLargeString(&lstrWindowName
, plstrWindowName
);
2280 if (!NT_SUCCESS(Status
))
2282 DPRINT1("NtUserCreateWindowEx: failed to capture plstrWindowName\n");
2283 SetLastNtError(Status
);
2286 plstrWindowName
= &lstrWindowName
;
2289 /* Check if the class is an atom */
2290 if (IS_ATOM(plstrClassName
))
2292 /* It is, pass the atom in the UNICODE_STRING */
2293 ustrClassName
.Buffer
= (PVOID
)plstrClassName
;
2294 ustrClassName
.Length
= 0;
2295 ustrClassName
.MaximumLength
= 0;
2299 /* It's not, capture the class name */
2300 Status
= ProbeAndCaptureLargeString(&lstrClassName
, plstrClassName
);
2301 if (!NT_SUCCESS(Status
))
2303 DPRINT1("NtUserCreateWindowEx: failed to capture plstrClassName\n");
2304 /* Set last error, cleanup and return */
2305 SetLastNtError(Status
);
2309 /* We pass it on as a UNICODE_STRING */
2310 ustrClassName
.Buffer
= lstrClassName
.Buffer
;
2311 ustrClassName
.Length
= lstrClassName
.Length
;
2312 ustrClassName
.MaximumLength
= lstrClassName
.MaximumLength
;
2315 /* Fill the CREATESTRUCTW */
2316 /* we will keep here the original parameters */
2318 Cs
.lpCreateParams
= lpParam
;
2319 Cs
.hInstance
= hInstance
;
2321 Cs
.hwndParent
= hWndParent
;
2326 Cs
.lpszName
= (LPCWSTR
) plstrWindowName
->Buffer
;
2327 if (IS_ATOM(plstrClassName
))
2328 Cs
.lpszClass
= (LPCWSTR
) plstrClassName
;
2330 Cs
.lpszClass
= (LPCWSTR
) plstrClassName
->Buffer
;
2331 Cs
.dwExStyle
= dwExStyle
;
2333 UserEnterExclusive();
2335 /* Call the internal function */
2336 pwnd
= co_UserCreateWindowEx(&Cs
, &ustrClassName
, plstrWindowName
);
2340 DPRINT1("co_UserCreateWindowEx failed!\n");
2342 hwnd
= pwnd
? UserHMGetHandle(pwnd
) : NULL
;
2347 if (lstrWindowName
.Buffer
)
2349 ExFreePoolWithTag(lstrWindowName
.Buffer
, TAG_STRING
);
2351 if (lstrClassName
.Buffer
)
2353 ExFreePoolWithTag(lstrClassName
.Buffer
, TAG_STRING
);
2360 BOOLEAN FASTCALL
co_UserDestroyWindow(PWND Window
)
2366 ASSERT_REFS_CO(Window
); // FIXME: temp hack?
2368 hWnd
= Window
->head
.h
;
2370 DPRINT("co_UserDestroyWindow \n");
2372 /* Check for owner thread */
2373 if ( (Window
->head
.pti
->pEThread
!= PsGetCurrentThread()) ||
2374 Window
->head
.pti
!= PsGetCurrentThreadWin32Thread() )
2376 SetLastWin32Error(ERROR_ACCESS_DENIED
);
2380 /* If window was created successfully and it is hooked */
2381 if ((Window
->state2
& WNDS2_WMCREATEMSGPROCESSED
))
2383 if (co_HOOK_CallHooks(WH_CBT
, HCBT_DESTROYWND
, (WPARAM
) hWnd
, 0))
2385 DPRINT1("Destroy Window WH_CBT Call Hook return!\n");
2390 /* Inform the parent */
2391 if (Window
->style
& WS_CHILD
)
2393 IntSendParentNotify(Window
, WM_DESTROY
);
2396 /* Look whether the focus is within the tree of windows we will
2399 if (!co_WinPosShowWindow(Window
, SW_HIDE
))
2401 if (UserGetActiveWindow() == Window
->head
.h
)
2403 co_WinPosActivateOtherWindow(Window
);
2407 if (Window
->head
.pti
->MessageQueue
->ActiveWindow
== Window
->head
.h
)
2408 Window
->head
.pti
->MessageQueue
->ActiveWindow
= NULL
;
2409 if (Window
->head
.pti
->MessageQueue
->FocusWindow
== Window
->head
.h
)
2410 Window
->head
.pti
->MessageQueue
->FocusWindow
= NULL
;
2411 if (Window
->head
.pti
->MessageQueue
->CaptureWindow
== Window
->head
.h
)
2412 Window
->head
.pti
->MessageQueue
->CaptureWindow
= NULL
;
2415 * Check if this window is the Shell's Desktop Window. If so set hShellWindow to NULL
2418 ti
= PsGetCurrentThreadWin32Thread();
2420 if ((ti
!= NULL
) & (ti
->pDeskInfo
!= NULL
))
2422 if (ti
->pDeskInfo
->hShellWindow
== hWnd
)
2424 DPRINT1("Destroying the ShellWindow!\n");
2425 ti
->pDeskInfo
->hShellWindow
= NULL
;
2429 IntDereferenceMessageQueue(Window
->head
.pti
->MessageQueue
);
2431 IntEngWindowChanged(Window
, WOC_DELETE
);
2433 if (!IntIsWindow(Window
->head
.h
))
2438 /* Recursively destroy owned windows */
2440 if (! (Window
->style
& WS_CHILD
))
2444 BOOL GotOne
= FALSE
;
2447 PWND Child
, Desktop
;
2449 Desktop
= IntIsDesktopWindow(Window
) ? Window
:
2450 UserGetWindowObject(IntGetDesktopWindow());
2451 Children
= IntWinListChildren(Desktop
);
2455 for (ChildHandle
= Children
; *ChildHandle
; ++ChildHandle
)
2457 Child
= UserGetWindowObject(*ChildHandle
);
2460 if (Child
->spwndOwner
!= Window
)
2465 if (IntWndBelongsToThread(Child
, PsGetCurrentThreadWin32Thread()))
2467 USER_REFERENCE_ENTRY ChildRef
;
2468 UserRefObjectCo(Child
, &ChildRef
);//temp hack?
2469 co_UserDestroyWindow(Child
);
2470 UserDerefObjectCo(Child
);//temp hack?
2476 if (Child
->spwndOwner
!= NULL
)
2478 Child
->spwndOwner
= NULL
;
2482 ExFreePool(Children
);
2491 /* Generate mouse move message for the next window */
2492 msg
.message
= WM_MOUSEMOVE
;
2493 msg
.wParam
= IntGetSysCursorInfo()->ButtonsDown
;
2494 msg
.lParam
= MAKELPARAM(gpsi
->ptCursor
.x
, gpsi
->ptCursor
.y
);
2495 msg
.pt
= gpsi
->ptCursor
;
2496 co_MsqInsertMouseMessage(&msg
);
2498 if (!IntIsWindow(Window
->head
.h
))
2503 /* Destroy the window storage */
2504 co_UserFreeWindow(Window
, PsGetCurrentProcessWin32Process(), PsGetCurrentThreadWin32Thread(), TRUE
);
2514 NtUserDestroyWindow(HWND Wnd
)
2517 DECLARE_RETURN(BOOLEAN
);
2519 USER_REFERENCE_ENTRY Ref
;
2521 DPRINT("Enter NtUserDestroyWindow\n");
2522 UserEnterExclusive();
2524 if (!(Window
= UserGetWindowObject(Wnd
)))
2529 UserRefObjectCo(Window
, &Ref
);//faxme: dunno if win should be reffed during destroy..
2530 ret
= co_UserDestroyWindow(Window
);
2531 UserDerefObjectCo(Window
);//faxme: dunno if win should be reffed during destroy..
2536 DPRINT("Leave NtUserDestroyWindow, ret=%i\n",_ret_
);
2542 static HWND FASTCALL
2543 IntFindWindow(PWND Parent
,
2546 PUNICODE_STRING WindowName
)
2548 BOOL CheckWindowName
;
2551 UNICODE_STRING CurrentWindowName
;
2555 CheckWindowName
= WindowName
->Length
!= 0;
2557 if((List
= IntWinListChildren(Parent
)))
2562 /* skip handles before and including ChildAfter */
2563 while(*phWnd
&& (*(phWnd
++) != ChildAfter
->head
.h
))
2567 /* search children */
2571 if(!(Child
= UserGetWindowObject(*(phWnd
++))))
2576 /* Do not send WM_GETTEXT messages in the kernel mode version!
2577 The user mode version however calls GetWindowText() which will
2578 send WM_GETTEXT messages to windows belonging to its processes */
2579 if (!ClassAtom
|| Child
->pcls
->atomClassName
== ClassAtom
)
2581 // HACK: use UNICODE_STRING instead of LARGE_STRING
2582 CurrentWindowName
.Buffer
= Child
->strName
.Buffer
;
2583 CurrentWindowName
.Length
= Child
->strName
.Length
;
2584 CurrentWindowName
.MaximumLength
= Child
->strName
.MaximumLength
;
2585 if(!CheckWindowName
||
2586 (Child
->strName
.Length
< 0xFFFF &&
2587 !RtlCompareUnicodeString(WindowName
, &CurrentWindowName
, TRUE
)))
2589 Ret
= Child
->head
.h
;
2602 * Searches a window's children for a window with the specified
2605 * hwndParent = The window whose childs are to be searched.
2607 * HWND_MESSAGE = message-only windows
2609 * hwndChildAfter = Search starts after this child window.
2610 * NULL = start from beginning
2612 * ucClassName = Class name to search for
2613 * Reguired parameter.
2615 * ucWindowName = Window name
2616 * ->Buffer == NULL = don't care
2619 * The HWND of the window if it was found, otherwise NULL
2625 NtUserFindWindowEx(HWND hwndParent
,
2626 HWND hwndChildAfter
,
2627 PUNICODE_STRING ucClassName
,
2628 PUNICODE_STRING ucWindowName
,
2631 PWND Parent
, ChildAfter
;
2632 UNICODE_STRING ClassName
= {0}, WindowName
= {0};
2633 HWND Desktop
, Ret
= NULL
;
2634 RTL_ATOM ClassAtom
= (RTL_ATOM
)0;
2635 DECLARE_RETURN(HWND
);
2637 DPRINT("Enter NtUserFindWindowEx\n");
2640 if (ucClassName
!= NULL
|| ucWindowName
!= NULL
)
2644 if (ucClassName
!= NULL
)
2646 ClassName
= ProbeForReadUnicodeString(ucClassName
);
2647 if (ClassName
.Length
!= 0)
2649 ProbeForRead(ClassName
.Buffer
,
2653 else if (!IS_ATOM(ClassName
.Buffer
))
2655 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
2659 if (!IntGetAtomFromStringOrAtom(&ClassName
,
2666 if (ucWindowName
!= NULL
)
2668 WindowName
= ProbeForReadUnicodeString(ucWindowName
);
2669 if (WindowName
.Length
!= 0)
2671 ProbeForRead(WindowName
.Buffer
,
2677 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2679 SetLastNtError(_SEH2_GetExceptionCode());
2680 _SEH2_YIELD(RETURN(NULL
));
2684 if (ucClassName
!= NULL
)
2686 if (ClassName
.Length
== 0 && ClassName
.Buffer
!= NULL
&&
2687 !IS_ATOM(ClassName
.Buffer
))
2689 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
2692 else if (ClassAtom
== (RTL_ATOM
)0)
2694 /* LastError code was set by IntGetAtomFromStringOrAtom */
2700 Desktop
= IntGetCurrentThreadDesktopWindow();
2702 if(hwndParent
== NULL
)
2703 hwndParent
= Desktop
;
2704 else if(hwndParent
== HWND_MESSAGE
)
2706 hwndParent
= IntGetMessageWindow();
2709 if(!(Parent
= UserGetWindowObject(hwndParent
)))
2715 if(hwndChildAfter
&& !(ChildAfter
= UserGetWindowObject(hwndChildAfter
)))
2722 if(Parent
->head
.h
== Desktop
)
2725 PWND TopLevelWindow
;
2726 BOOLEAN CheckWindowName
;
2727 BOOLEAN WindowMatches
;
2728 BOOLEAN ClassMatches
;
2730 /* windows searches through all top-level windows if the parent is the desktop
2733 if((List
= IntWinListChildren(Parent
)))
2739 /* skip handles before and including ChildAfter */
2740 while(*phWnd
&& (*(phWnd
++) != ChildAfter
->head
.h
))
2744 CheckWindowName
= WindowName
.Length
!= 0;
2746 /* search children */
2749 UNICODE_STRING ustr
;
2751 if(!(TopLevelWindow
= UserGetWindowObject(*(phWnd
++))))
2756 /* Do not send WM_GETTEXT messages in the kernel mode version!
2757 The user mode version however calls GetWindowText() which will
2758 send WM_GETTEXT messages to windows belonging to its processes */
2759 ustr
.Buffer
= TopLevelWindow
->strName
.Buffer
;
2760 ustr
.Length
= TopLevelWindow
->strName
.Length
;
2761 ustr
.MaximumLength
= TopLevelWindow
->strName
.MaximumLength
;
2762 WindowMatches
= !CheckWindowName
||
2763 (TopLevelWindow
->strName
.Length
< 0xFFFF &&
2764 !RtlCompareUnicodeString(&WindowName
, &ustr
, TRUE
));
2765 ClassMatches
= (ClassAtom
== (RTL_ATOM
)0) ||
2766 ClassAtom
== TopLevelWindow
->pcls
->atomClassName
;
2768 if (WindowMatches
&& ClassMatches
)
2770 Ret
= TopLevelWindow
->head
.h
;
2774 if (IntFindWindow(TopLevelWindow
, NULL
, ClassAtom
, &WindowName
))
2776 /* window returns the handle of the top-level window, in case it found
2778 Ret
= TopLevelWindow
->head
.h
;
2787 Ret
= IntFindWindow(Parent
, ChildAfter
, ClassAtom
, &WindowName
);
2791 if(Ret
== NULL
&& hwndParent
== NULL
&& hwndChildAfter
== NULL
)
2793 /* FIXME - if both hwndParent and hwndChildAfter are NULL, we also should
2794 search the message-only windows. Should this also be done if
2795 Parent is the desktop window??? */
2798 if((MsgWindows
= UserGetWindowObject(IntGetMessageWindow())))
2800 Ret
= IntFindWindow(MsgWindows
, ChildAfter
, ClassAtom
, &WindowName
);
2805 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2807 SetLastNtError(_SEH2_GetExceptionCode());
2815 DPRINT("Leave NtUserFindWindowEx, ret %i\n",_ret_
);
2824 PWND FASTCALL
UserGetAncestor(PWND Wnd
, UINT Type
)
2826 PWND WndAncestor
, Parent
;
2828 if (Wnd
->head
.h
== IntGetDesktopWindow())
2837 WndAncestor
= Wnd
->spwndParent
;
2848 if(!(Parent
= WndAncestor
->spwndParent
))
2852 if(IntIsDesktopWindow(Parent
))
2857 WndAncestor
= Parent
;
2870 Parent
= IntGetParent(WndAncestor
);
2877 WndAncestor
= Parent
;
2895 NtUserGetAncestor(HWND hWnd
, UINT Type
)
2897 PWND Window
, Ancestor
;
2898 DECLARE_RETURN(HWND
);
2900 DPRINT("Enter NtUserGetAncestor\n");
2901 UserEnterExclusive();
2903 if (!(Window
= UserGetWindowObject(hWnd
)))
2908 Ancestor
= UserGetAncestor(Window
, Type
);
2909 /* faxme: can UserGetAncestor ever return NULL for a valid window? */
2911 RETURN(Ancestor
? Ancestor
->head
.h
: NULL
);
2914 DPRINT("Leave NtUserGetAncestor, ret=%i\n",_ret_
);
2922 NtUserGetComboBoxInfo(
2927 DECLARE_RETURN(BOOL
);
2929 DPRINT("Enter NtUserGetComboBoxInfo\n");
2932 if (!(Wnd
= UserGetWindowObject(hWnd
)))
2941 sizeof(COMBOBOXINFO
),
2945 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2947 SetLastNtError(_SEH2_GetExceptionCode());
2948 _SEH2_YIELD(RETURN(FALSE
));
2952 // Pass the user pointer, it was already probed.
2953 RETURN( (BOOL
) co_IntSendMessage( Wnd
->head
.h
, CB_GETCOMBOBOXINFO
, 0, (LPARAM
)pcbi
));
2956 DPRINT("Leave NtUserGetComboBoxInfo, ret=%i\n",_ret_
);
2966 NtUserGetInternalWindowPos( HWND hWnd
,
2973 WINDOWPLACEMENT wndpl
;
2977 if (!(Window
= UserGetWindowObject(hWnd
)))
2987 ProbeForWrite(rectWnd
,
2993 ProbeForWrite(ptIcon
,
2999 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
3001 SetLastNtError(_SEH2_GetExceptionCode());
3006 wndpl
.length
= sizeof(WINDOWPLACEMENT
);
3008 if (IntGetWindowPlacement(Window
, &wndpl
) && !Hit
)
3014 RtlCopyMemory(rectWnd
, &wndpl
.rcNormalPosition
, sizeof(RECT
));
3018 RtlCopyMemory(ptIcon
, &wndpl
.ptMinPosition
, sizeof(POINT
));
3022 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
3024 SetLastNtError(_SEH2_GetExceptionCode());
3029 if (!Hit
) Ret
= wndpl
.showCmd
;
3038 NtUserGetListBoxInfo(
3042 DECLARE_RETURN(DWORD
);
3044 DPRINT("Enter NtUserGetListBoxInfo\n");
3047 if (!(Wnd
= UserGetWindowObject(hWnd
)))
3052 RETURN( (DWORD
) co_IntSendMessage( Wnd
->head
.h
, LB_GETLISTBOXINFO
, 0, 0 ));
3055 DPRINT("Leave NtUserGetListBoxInfo, ret=%i\n",_ret_
);
3062 co_UserSetParent(HWND hWndChild
, HWND hWndNewParent
)
3064 PWND Wnd
= NULL
, WndParent
= NULL
, WndOldParent
;
3065 HWND hWndOldParent
= NULL
;
3066 USER_REFERENCE_ENTRY Ref
, ParentRef
;
3068 if (IntIsBroadcastHwnd(hWndChild
) || IntIsBroadcastHwnd(hWndNewParent
))
3070 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
3074 if (hWndChild
== IntGetDesktopWindow())
3076 SetLastWin32Error(ERROR_ACCESS_DENIED
);
3082 if (!(WndParent
= UserGetWindowObject(hWndNewParent
)))
3089 if (!(WndParent
= UserGetWindowObject(IntGetDesktopWindow())))
3095 if (!(Wnd
= UserGetWindowObject(hWndChild
)))
3100 UserRefObjectCo(Wnd
, &Ref
);
3101 UserRefObjectCo(WndParent
, &ParentRef
);
3103 WndOldParent
= co_IntSetParent(Wnd
, WndParent
);
3105 UserDerefObjectCo(WndParent
);
3106 UserDerefObjectCo(Wnd
);
3110 hWndOldParent
= WndOldParent
->head
.h
;
3111 UserDereferenceObject(WndOldParent
);
3114 return( hWndOldParent
);
3120 * The NtUserSetParent function changes the parent window of the specified
3124 * The new parent window and the child window must belong to the same
3125 * application. If the window identified by the hWndChild parameter is
3126 * visible, the system performs the appropriate redrawing and repainting.
3127 * For compatibility reasons, NtUserSetParent does not modify the WS_CHILD
3128 * or WS_POPUP window styles of the window whose parent is being changed.
3135 NtUserSetParent(HWND hWndChild
, HWND hWndNewParent
)
3137 DECLARE_RETURN(HWND
);
3139 DPRINT("Enter NtUserSetParent\n");
3140 UserEnterExclusive();
3143 Check Parent first from user space, set it here.
3147 hWndNewParent
= IntGetDesktopWindow();
3149 else if (hWndNewParent
== HWND_MESSAGE
)
3151 hWndNewParent
= IntGetMessageWindow();
3154 RETURN( co_UserSetParent(hWndChild
, hWndNewParent
));
3157 DPRINT("Leave NtUserSetParent, ret=%i\n",_ret_
);
3163 * UserGetShellWindow
3165 * Returns a handle to shell window that was set by NtUserSetShellWindowEx.
3170 HWND FASTCALL
UserGetShellWindow(VOID
)
3172 PWINSTATION_OBJECT WinStaObject
;
3175 NTSTATUS Status
= IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation
,
3180 if (!NT_SUCCESS(Status
))
3182 SetLastNtError(Status
);
3186 Ret
= (HWND
)WinStaObject
->ShellWindow
;
3188 ObDereferenceObject(WinStaObject
);
3193 * NtUserSetShellWindowEx
3195 * This is undocumented function to set global shell window. The global
3196 * shell window has special handling of window position.
3202 NtUserSetShellWindowEx(HWND hwndShell
, HWND hwndListView
)
3204 PWINSTATION_OBJECT WinStaObject
;
3205 PWND WndShell
, WndListView
;
3206 DECLARE_RETURN(BOOL
);
3207 USER_REFERENCE_ENTRY Ref
;
3211 DPRINT("Enter NtUserSetShellWindowEx\n");
3212 UserEnterExclusive();
3214 if (!(WndShell
= UserGetWindowObject(hwndShell
)))
3219 if(!(WndListView
= UserGetWindowObject(hwndListView
)))
3224 Status
= IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation
,
3229 if (!NT_SUCCESS(Status
))
3231 SetLastNtError(Status
);
3236 * Test if we are permitted to change the shell window.
3238 if (WinStaObject
->ShellWindow
)
3240 ObDereferenceObject(WinStaObject
);
3245 * Move shell window into background.
3247 if (hwndListView
&& hwndListView
!= hwndShell
)
3250 * Disabled for now to get Explorer working.
3251 * -- Filip, 01/nov/2003
3254 co_WinPosSetWindowPos(hwndListView
, HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
);
3257 if (WndListView
->ExStyle
& WS_EX_TOPMOST
)
3259 ObDereferenceObject(WinStaObject
);
3264 if (WndShell
->ExStyle
& WS_EX_TOPMOST
)
3266 ObDereferenceObject(WinStaObject
);
3270 UserRefObjectCo(WndShell
, &Ref
);
3271 co_WinPosSetWindowPos(WndShell
, HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
);
3273 WinStaObject
->ShellWindow
= hwndShell
;
3274 WinStaObject
->ShellListView
= hwndListView
;
3276 ti
= GetW32ThreadInfo();
3277 if (ti
->pDeskInfo
) ti
->pDeskInfo
->hShellWindow
= hwndShell
;
3279 UserDerefObjectCo(WndShell
);
3281 ObDereferenceObject(WinStaObject
);
3285 DPRINT("Leave NtUserSetShellWindowEx, ret=%i\n",_ret_
);
3291 * NtUserGetSystemMenu
3293 * The NtUserGetSystemMenu function allows the application to access the
3294 * window menu (also known as the system menu or the control menu) for
3295 * copying and modifying.
3299 * Handle to the window that will own a copy of the window menu.
3301 * Specifies the action to be taken. If this parameter is FALSE,
3302 * NtUserGetSystemMenu returns a handle to the copy of the window menu
3303 * currently in use. The copy is initially identical to the window menu
3304 * but it can be modified.
3305 * If this parameter is TRUE, GetSystemMenu resets the window menu back
3306 * to the default state. The previous window menu, if any, is destroyed.
3309 * If the bRevert parameter is FALSE, the return value is a handle to a
3310 * copy of the window menu. If the bRevert parameter is TRUE, the return
3318 NtUserGetSystemMenu(HWND hWnd
, BOOL bRevert
)
3322 DECLARE_RETURN(HMENU
);
3324 DPRINT("Enter NtUserGetSystemMenu\n");
3327 if (!(Window
= UserGetWindowObject(hWnd
)))
3332 if (!(Menu
= IntGetSystemMenu(Window
, bRevert
, FALSE
)))
3337 RETURN(Menu
->MenuInfo
.Self
);
3340 DPRINT("Leave NtUserGetSystemMenu, ret=%i\n",_ret_
);
3346 * NtUserSetSystemMenu
3353 NtUserSetSystemMenu(HWND hWnd
, HMENU hMenu
)
3355 BOOL Result
= FALSE
;
3358 DECLARE_RETURN(BOOL
);
3360 DPRINT("Enter NtUserSetSystemMenu\n");
3361 UserEnterExclusive();
3363 if (!(Window
= UserGetWindowObject(hWnd
)))
3371 * Assign new menu handle.
3373 if (!(Menu
= UserGetMenuObject(hMenu
)))
3378 Result
= IntSetSystemMenu(Window
, Menu
);
3384 DPRINT("Leave NtUserSetSystemMenu, ret=%i\n",_ret_
);
3390 co_UserSetWindowLong(HWND hWnd
, DWORD Index
, LONG NewValue
, BOOL Ansi
)
3392 PWND Window
, Parent
;
3393 PWINSTATION_OBJECT WindowStation
;
3397 if (hWnd
== IntGetDesktopWindow())
3399 SetLastWin32Error(STATUS_ACCESS_DENIED
);
3403 if (!(Window
= UserGetWindowObject(hWnd
)))
3408 if ((INT
)Index
>= 0)
3410 if ((Index
+ sizeof(LONG
)) > Window
->cbwndExtra
)
3412 SetLastWin32Error(ERROR_INVALID_INDEX
);
3416 OldValue
= *((LONG
*)((PCHAR
)(Window
+ 1) + Index
));
3418 if ( Index == DWLP_DLGPROC && Wnd->state & WNDS_DIALOGWINDOW)
3420 OldValue = (LONG)IntSetWindowProc( Wnd,
3423 if (!OldValue) return 0;
3426 *((LONG
*)((PCHAR
)(Window
+ 1) + Index
)) = NewValue
;
3433 OldValue
= (LONG
) Window
->ExStyle
;
3434 Style
.styleOld
= OldValue
;
3435 Style
.styleNew
= NewValue
;
3438 * Remove extended window style bit WS_EX_TOPMOST for shell windows.
3440 WindowStation
= Window
->head
.pti
->rpdesk
->rpwinstaParent
;
3443 if (hWnd
== WindowStation
->ShellWindow
|| hWnd
== WindowStation
->ShellListView
)
3444 Style
.styleNew
&= ~WS_EX_TOPMOST
;
3447 co_IntSendMessage(hWnd
, WM_STYLECHANGING
, GWL_EXSTYLE
, (LPARAM
) &Style
);
3448 Window
->ExStyle
= (DWORD
)Style
.styleNew
;
3449 co_IntSendMessage(hWnd
, WM_STYLECHANGED
, GWL_EXSTYLE
, (LPARAM
) &Style
);
3453 OldValue
= (LONG
) Window
->style
;
3454 Style
.styleOld
= OldValue
;
3455 Style
.styleNew
= NewValue
;
3456 co_IntSendMessage(hWnd
, WM_STYLECHANGING
, GWL_STYLE
, (LPARAM
) &Style
);
3457 Window
->style
= (DWORD
)Style
.styleNew
;
3458 co_IntSendMessage(hWnd
, WM_STYLECHANGED
, GWL_STYLE
, (LPARAM
) &Style
);
3463 if ( Window
->head
.pti
->ppi
!= PsGetCurrentProcessWin32Process() ||
3464 Window
->fnid
& FNID_FREED
)
3466 SetLastWin32Error(ERROR_ACCESS_DENIED
);
3469 OldValue
= (LONG
)IntSetWindowProc(Window
,
3476 OldValue
= (LONG
) Window
->hModule
;
3477 Window
->hModule
= (HINSTANCE
) NewValue
;
3480 case GWL_HWNDPARENT
:
3481 Parent
= Window
->spwndParent
;
3482 if (Parent
&& (Parent
->head
.h
== IntGetDesktopWindow()))
3483 OldValue
= (LONG
) IntSetOwner(Window
->head
.h
, (HWND
) NewValue
);
3485 OldValue
= (LONG
) co_UserSetParent(Window
->head
.h
, (HWND
) NewValue
);
3489 OldValue
= (LONG
) Window
->IDMenu
;
3490 Window
->IDMenu
= (UINT
) NewValue
;
3494 OldValue
= Window
->dwUserData
;
3495 Window
->dwUserData
= NewValue
;
3499 DPRINT1("NtUserSetWindowLong(): Unsupported index %d\n", Index
);
3500 SetLastWin32Error(ERROR_INVALID_INDEX
);
3510 * NtUserSetWindowLong
3512 * The NtUserSetWindowLong function changes an attribute of the specified
3513 * window. The function also sets the 32-bit (long) value at the specified
3514 * offset into the extra window memory.
3521 NtUserSetWindowLong(HWND hWnd
, DWORD Index
, LONG NewValue
, BOOL Ansi
)
3523 DECLARE_RETURN(LONG
);
3525 DPRINT("Enter NtUserSetWindowLong\n");
3526 UserEnterExclusive();
3528 RETURN( co_UserSetWindowLong(hWnd
, Index
, NewValue
, Ansi
));
3531 DPRINT("Leave NtUserSetWindowLong, ret=%i\n",_ret_
);
3537 * NtUserSetWindowWord
3539 * Legacy function similar to NtUserSetWindowLong.
3546 NtUserSetWindowWord(HWND hWnd
, INT Index
, WORD NewValue
)
3550 DECLARE_RETURN(WORD
);
3552 DPRINT("Enter NtUserSetWindowWord\n");
3553 UserEnterExclusive();
3555 if (!(Window
= UserGetWindowObject(hWnd
)))
3564 case GWL_HWNDPARENT
:
3565 RETURN( co_UserSetWindowLong(Window
->head
.h
, Index
, (UINT
)NewValue
, TRUE
));
3569 SetLastWin32Error(ERROR_INVALID_INDEX
);
3574 if (Index
> Window
->cbwndExtra
- sizeof(WORD
))
3576 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
3580 OldValue
= *((WORD
*)((PCHAR
)(Window
+ 1) + Index
));
3581 *((WORD
*)((PCHAR
)(Window
+ 1) + Index
)) = NewValue
;
3586 DPRINT("Leave NtUserSetWindowWord, ret=%i\n",_ret_
);
3595 NtUserGetWindowPlacement(HWND hWnd
,
3596 WINDOWPLACEMENT
*lpwndpl
)
3600 WINDOWPLACEMENT Safepl
;
3602 DECLARE_RETURN(BOOL
);
3604 DPRINT("Enter NtUserGetWindowPlacement\n");
3607 if (!(Wnd
= UserGetWindowObject(hWnd
)))
3612 Status
= MmCopyFromCaller(&Safepl
, lpwndpl
, sizeof(WINDOWPLACEMENT
));
3613 if(!NT_SUCCESS(Status
))
3615 SetLastNtError(Status
);
3618 if(Safepl
.length
!= sizeof(WINDOWPLACEMENT
))
3624 if (0 == (Wnd
->style
& WS_VISIBLE
))
3626 Safepl
.showCmd
= SW_HIDE
;
3628 else if ((0 != (Wnd
->state2
& WNDS2_MAXIMIZEBUTTONDOWN
) ||
3629 0 != (Wnd
->style
& WS_MAXIMIZE
)) &&
3630 0 == (Wnd
->style
& WS_MINIMIZE
))
3632 Safepl
.showCmd
= SW_SHOWMAXIMIZED
;
3634 else if (0 != (Wnd
->style
& WS_MINIMIZE
))
3636 Safepl
.showCmd
= SW_SHOWMINIMIZED
;
3638 else if (0 != (Wnd
->style
& WS_VISIBLE
))
3640 Safepl
.showCmd
= SW_SHOWNORMAL
;
3643 Size
.x
= Wnd
->rcWindow
.left
;
3644 Size
.y
= Wnd
->rcWindow
.top
;
3645 WinPosInitInternalPos(Wnd
, &Size
,
3648 Safepl
.rcNormalPosition
= Wnd
->InternalPos
.NormalRect
;
3649 Safepl
.ptMinPosition
= Wnd
->InternalPos
.IconPos
;
3650 Safepl
.ptMaxPosition
= Wnd
->InternalPos
.MaxPos
;
3652 Status
= MmCopyToCaller(lpwndpl
, &Safepl
, sizeof(WINDOWPLACEMENT
));
3653 if(!NT_SUCCESS(Status
))
3655 SetLastNtError(Status
);
3662 DPRINT("Leave NtUserGetWindowPlacement, ret=%i\n",_ret_
);
3679 return NtUserSetWindowPos(hWnd
, 0, X
, Y
, nWidth
, nHeight
,
3680 (bRepaint
? SWP_NOZORDER
| SWP_NOACTIVATE
:
3681 SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOREDRAW
));
3685 QueryWindow based on KJK::Hyperion and James Tabor.
3687 0 = QWUniqueProcessId
3688 1 = QWUniqueThreadId
3691 4 = QWIsHung Implements IsHungAppWindow found
3694 9 = QWKillWindow When I called this with hWnd ==
3695 DesktopWindow, it shutdown the system
3702 NtUserQueryWindow(HWND hWnd
, DWORD Index
)
3706 DECLARE_RETURN(UINT
);
3708 DPRINT("Enter NtUserQueryWindow\n");
3711 if (!(pWnd
= UserGetWindowObject(hWnd
)))
3718 case QUERY_WINDOW_UNIQUE_PROCESS_ID
:
3719 Result
= (DWORD
)IntGetWndProcessId(pWnd
);
3722 case QUERY_WINDOW_UNIQUE_THREAD_ID
:
3723 Result
= (DWORD
)IntGetWndThreadId(pWnd
);
3726 case QUERY_WINDOW_ACTIVE
:
3727 Result
= (DWORD
)UserGetActiveWindow();
3730 case QUERY_WINDOW_FOCUS
:
3731 Result
= (DWORD
)IntGetFocusWindow();
3734 case QUERY_WINDOW_ISHUNG
:
3735 Result
= (DWORD
)MsqIsHung(pWnd
->head
.pti
->MessageQueue
);
3738 case QUERY_WINDOW_REAL_ID
:
3739 Result
= (DWORD
)pWnd
->head
.pti
->pEThread
->Cid
.UniqueProcess
;
3742 Result
= (DWORD
)NULL
;
3749 DPRINT("Leave NtUserQueryWindow, ret=%i\n",_ret_
);
3759 NtUserRegisterWindowMessage(PUNICODE_STRING MessageNameUnsafe
)
3761 UNICODE_STRING SafeMessageName
;
3764 DECLARE_RETURN(UINT
);
3766 DPRINT("Enter NtUserRegisterWindowMessage\n");
3767 UserEnterExclusive();
3769 if(MessageNameUnsafe
== NULL
)
3771 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
3775 Status
= IntSafeCopyUnicodeStringTerminateNULL(&SafeMessageName
, MessageNameUnsafe
);
3776 if(!NT_SUCCESS(Status
))
3778 SetLastNtError(Status
);
3782 Ret
= (UINT
)IntAddAtom(SafeMessageName
.Buffer
);
3783 if (SafeMessageName
.Buffer
)
3784 ExFreePoolWithTag(SafeMessageName
.Buffer
, TAG_STRING
);
3788 DPRINT("Leave NtUserRegisterWindowMessage, ret=%i\n",_ret_
);
3805 DECLARE_RETURN(BOOL
);
3807 DPRINT("Enter NtUserSetMenu\n");
3808 UserEnterExclusive();
3810 if (!(Window
= UserGetWindowObject(hWnd
)))
3815 if (! IntSetMenu(Window
, Menu
, &Changed
))
3820 if (Changed
&& Repaint
)
3822 USER_REFERENCE_ENTRY Ref
;
3824 UserRefObjectCo(Window
, &Ref
);
3825 co_WinPosSetWindowPos(Window
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
3826 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
3828 UserDerefObjectCo(Window
);
3834 DPRINT("Leave NtUserSetMenu, ret=%i\n",_ret_
);
3844 NtUserSetWindowFNID(HWND hWnd
,
3848 DECLARE_RETURN(BOOL
);
3850 DPRINT("Enter NtUserSetWindowFNID\n");
3851 UserEnterExclusive();
3853 if (!(Wnd
= UserGetWindowObject(hWnd
)))
3859 { // From user land we only set these.
3860 if ((fnID
!= FNID_DESTROY
) || ((fnID
< FNID_BUTTON
) && (fnID
> FNID_IME
)) )
3865 Wnd
->pcls
->fnid
|= fnID
;
3870 DPRINT("Leave NtUserSetWindowFNID\n");
3880 NtUserSetWindowPlacement(HWND hWnd
,
3881 WINDOWPLACEMENT
*lpwndpl
)
3884 WINDOWPLACEMENT Safepl
;
3886 DECLARE_RETURN(BOOL
);
3887 USER_REFERENCE_ENTRY Ref
;
3889 DPRINT("Enter NtUserSetWindowPlacement\n");
3890 UserEnterExclusive();
3892 if (!(Wnd
= UserGetWindowObject(hWnd
)))
3897 Status
= MmCopyFromCaller(&Safepl
, lpwndpl
, sizeof(WINDOWPLACEMENT
));
3898 if(!NT_SUCCESS(Status
))
3900 SetLastNtError(Status
);
3903 if(Safepl
.length
!= sizeof(WINDOWPLACEMENT
))
3908 UserRefObjectCo(Wnd
, &Ref
);
3910 if ((Wnd
->style
& (WS_MAXIMIZE
| WS_MINIMIZE
)) == 0)
3912 co_WinPosSetWindowPos(Wnd
, NULL
,
3913 Safepl
.rcNormalPosition
.left
, Safepl
.rcNormalPosition
.top
,
3914 Safepl
.rcNormalPosition
.right
- Safepl
.rcNormalPosition
.left
,
3915 Safepl
.rcNormalPosition
.bottom
- Safepl
.rcNormalPosition
.top
,
3916 SWP_NOZORDER
| SWP_NOACTIVATE
);
3919 /* FIXME - change window status */
3920 co_WinPosShowWindow(Wnd
, Safepl
.showCmd
);
3922 Wnd
->InternalPosInitialized
= TRUE
;
3923 Wnd
->InternalPos
.NormalRect
= Safepl
.rcNormalPosition
;
3924 Wnd
->InternalPos
.IconPos
= Safepl
.ptMinPosition
;
3925 Wnd
->InternalPos
.MaxPos
= Safepl
.ptMaxPosition
;
3927 UserDerefObjectCo(Wnd
);
3931 DPRINT("Leave NtUserSetWindowPlacement, ret=%i\n",_ret_
);
3943 HWND hWndInsertAfter
,
3950 DECLARE_RETURN(BOOL
);
3953 USER_REFERENCE_ENTRY Ref
;
3955 DPRINT("Enter NtUserSetWindowPos\n");
3956 UserEnterExclusive();
3958 if (!(Window
= UserGetWindowObject(hWnd
)))
3963 /* First make sure that coordinates are valid for WM_WINDOWPOSCHANGING */
3964 if (!(uFlags
& SWP_NOMOVE
))
3966 if (X
< -32768) X
= -32768;
3967 else if (X
> 32767) X
= 32767;
3968 if (Y
< -32768) Y
= -32768;
3969 else if (Y
> 32767) Y
= 32767;
3971 if (!(uFlags
& SWP_NOSIZE
))
3974 else if (cx
> 32767) cx
= 32767;
3976 else if (cy
> 32767) cy
= 32767;
3979 UserRefObjectCo(Window
, &Ref
);
3980 ret
= co_WinPosSetWindowPos(Window
, hWndInsertAfter
, X
, Y
, cx
, cy
, uFlags
);
3981 UserDerefObjectCo(Window
);
3986 DPRINT("Leave NtUserSetWindowPos, ret=%i\n",_ret_
);
3993 IntGetWindowRgn(PWND Window
, HRGN hRgn
)
4008 /* Create a new window region using the window rectangle */
4009 VisRgn
= IntSysCreateRectRgnIndirect(&Window
->rcWindow
);
4010 NtGdiOffsetRgn(VisRgn
, -Window
->rcWindow
.left
, -Window
->rcWindow
.top
);
4011 /* if there's a region assigned to the window, combine them both */
4012 if(Window
->hrgnClip
&& !(Window
->style
& WS_MINIMIZE
))
4013 NtGdiCombineRgn(VisRgn
, VisRgn
, Window
->hrgnClip
, RGN_AND
);
4014 /* Copy the region into hRgn */
4015 NtGdiCombineRgn(hRgn
, VisRgn
, NULL
, RGN_COPY
);
4017 if((pRgn
= RGNOBJAPI_Lock(hRgn
, NULL
)))
4019 Ret
= REGION_Complexity(pRgn
);
4020 RGNOBJAPI_Unlock(pRgn
);
4025 REGION_FreeRgnByHandle(VisRgn
);
4031 IntGetWindowRgnBox(PWND Window
, RECTL
*Rect
)
4046 /* Create a new window region using the window rectangle */
4047 VisRgn
= IntSysCreateRectRgnIndirect(&Window
->rcWindow
);
4048 NtGdiOffsetRgn(VisRgn
, -Window
->rcWindow
.left
, -Window
->rcWindow
.top
);
4049 /* if there's a region assigned to the window, combine them both */
4050 if(Window
->hrgnClip
&& !(Window
->style
& WS_MINIMIZE
))
4051 NtGdiCombineRgn(VisRgn
, VisRgn
, Window
->hrgnClip
, RGN_AND
);
4053 if((pRgn
= RGNOBJAPI_Lock(VisRgn
, NULL
)))
4055 Ret
= REGION_Complexity(pRgn
);
4056 *Rect
= pRgn
->rdh
.rcBound
;
4057 RGNOBJAPI_Unlock(pRgn
);
4062 REGION_FreeRgnByHandle(VisRgn
);
4079 DECLARE_RETURN(INT
);
4081 DPRINT("Enter NtUserSetWindowRgn\n");
4082 UserEnterExclusive();
4084 if (!(Window
= UserGetWindowObject(hWnd
)))
4089 if (hRgn
) // The region will be deleted in user32.
4091 if (GDIOBJ_ValidateHandle(hRgn
, GDI_OBJECT_TYPE_REGION
))
4093 hrgnCopy
= IntSysCreateRectRgn(0, 0, 0, 0);
4094 NtGdiCombineRgn(hrgnCopy
, hRgn
, 0, RGN_COPY
);
4100 hrgnCopy
= (HRGN
) 1;
4102 if (Window
->hrgnClip
)
4104 /* Delete no longer needed region handle */
4105 GreDeleteObject(Window
->hrgnClip
);
4107 Window
->hrgnClip
= hrgnCopy
;
4109 /* FIXME - send WM_WINDOWPOSCHANGING and WM_WINDOWPOSCHANGED messages to the window */
4113 USER_REFERENCE_ENTRY Ref
;
4114 UserRefObjectCo(Window
, &Ref
);
4115 co_UserRedrawWindow(Window
, NULL
, NULL
, RDW_INVALIDATE
);
4116 UserDerefObjectCo(Window
);
4122 DPRINT("Leave NtUserSetWindowRgn, ret=%i\n",_ret_
);
4132 NtUserShowWindow(HWND hWnd
, LONG nCmdShow
)
4136 DECLARE_RETURN(BOOL
);
4137 USER_REFERENCE_ENTRY Ref
;
4139 DPRINT("Enter NtUserShowWindow\n");
4140 UserEnterExclusive();
4142 if (!(Window
= UserGetWindowObject(hWnd
)))
4147 UserRefObjectCo(Window
, &Ref
);
4148 ret
= co_WinPosShowWindow(Window
, nCmdShow
);
4149 UserDerefObjectCo(Window
);
4154 DPRINT("Leave NtUserShowWindow, ret=%i\n",_ret_
);
4164 NtUserShowWindowAsync(HWND hWnd
, LONG nCmdShow
)
4170 return NtUserShowWindow(hWnd
, nCmdShow
);
4178 NtUserWindowFromPoint(LONG X
, LONG Y
)
4182 PWND DesktopWindow
= NULL
, Window
= NULL
;
4184 DECLARE_RETURN(HWND
);
4185 USER_REFERENCE_ENTRY Ref
;
4187 DPRINT("Enter NtUserWindowFromPoint\n");
4188 UserEnterExclusive();
4190 if ((DesktopWindow
= UserGetWindowObject(IntGetDesktopWindow())))
4197 //hmm... threads live on desktops thus we have a reference on the desktop and indirectly the desktop window
4198 //its possible this referencing is useless, thou it shouldnt hurt...
4199 UserRefObjectCo(DesktopWindow
, &Ref
);
4201 pti
= PsGetCurrentThreadWin32Thread();
4202 Window
= co_WinPosWindowFromPoint(DesktopWindow
, &pt
, &hittest
);
4206 Ret
= Window
->head
.h
;
4215 if (Window
) UserDereferenceObject(Window
);
4216 if (DesktopWindow
) UserDerefObjectCo(DesktopWindow
);
4218 DPRINT("Leave NtUserWindowFromPoint, ret=%i\n",_ret_
);
4228 * Undocumented function that is called from DefWindowProc to set
4235 NtUserDefSetText(HWND hWnd
, PLARGE_STRING WindowText
)
4238 LARGE_STRING SafeText
;
4239 UNICODE_STRING UnicodeString
;
4242 DPRINT("Enter NtUserDefSetText\n");
4244 if (WindowText
!= NULL
)
4248 SafeText
= ProbeForReadLargeString(WindowText
);
4250 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
4253 SetLastNtError(_SEH2_GetExceptionCode());
4263 UserEnterExclusive();
4265 if(!(Wnd
= UserGetWindowObject(hWnd
)))
4271 // ReactOS uses Unicode and not mixed. Up/Down converting will take time.
4272 // Brought to you by: The Wine Project! Dysfunctional Thought Processes!
4273 // Now we know what the bAnsi is for.
4274 RtlInitUnicodeString(&UnicodeString
, NULL
);
4275 if (SafeText
.Buffer
)
4280 ProbeForRead(SafeText
.Buffer
, SafeText
.Length
, sizeof(CHAR
));
4282 ProbeForRead(SafeText
.Buffer
, SafeText
.Length
, sizeof(WCHAR
));
4283 Ret
= RtlLargeStringToUnicodeString(&UnicodeString
, &SafeText
);
4285 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
4288 SetLastNtError(_SEH2_GetExceptionCode());
4291 if (!Ret
) goto Exit
;
4294 if (UnicodeString
.Length
!= 0)
4296 if (Wnd
->strName
.MaximumLength
> 0 &&
4297 UnicodeString
.Length
<= Wnd
->strName
.MaximumLength
- sizeof(UNICODE_NULL
))
4299 ASSERT(Wnd
->strName
.Buffer
!= NULL
);
4301 Wnd
->strName
.Length
= UnicodeString
.Length
;
4302 Wnd
->strName
.Buffer
[UnicodeString
.Length
/ sizeof(WCHAR
)] = L
'\0';
4303 RtlCopyMemory(Wnd
->strName
.Buffer
,
4304 UnicodeString
.Buffer
,
4305 UnicodeString
.Length
);
4310 Wnd
->strName
.MaximumLength
= Wnd
->strName
.Length
= 0;
4311 buf
= Wnd
->strName
.Buffer
;
4312 Wnd
->strName
.Buffer
= NULL
;
4315 DesktopHeapFree(Wnd
->head
.rpdesk
, buf
);
4318 Wnd
->strName
.Buffer
= DesktopHeapAlloc(Wnd
->head
.rpdesk
,
4319 UnicodeString
.Length
+ sizeof(UNICODE_NULL
));
4320 if (Wnd
->strName
.Buffer
!= NULL
)
4322 Wnd
->strName
.Buffer
[UnicodeString
.Length
/ sizeof(WCHAR
)] = L
'\0';
4323 RtlCopyMemory(Wnd
->strName
.Buffer
,
4324 UnicodeString
.Buffer
,
4325 UnicodeString
.Length
);
4326 Wnd
->strName
.MaximumLength
= UnicodeString
.Length
+ sizeof(UNICODE_NULL
);
4327 Wnd
->strName
.Length
= UnicodeString
.Length
;
4331 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
4339 Wnd
->strName
.Length
= 0;
4340 if (Wnd
->strName
.Buffer
!= NULL
)
4341 Wnd
->strName
.Buffer
[0] = L
'\0';
4344 // HAX! FIXME! Windows does not do this in here!
4345 // In User32, these are called after: NotifyWinEvent EVENT_OBJECT_NAMECHANGE than
4346 // RepaintButton, StaticRepaint, NtUserCallHwndLock HWNDLOCK_ROUTINE_REDRAWFRAMEANDHOOK, etc.
4347 /* Send shell notifications */
4348 if (!Wnd
->spwndOwner
&& !IntGetParent(Wnd
))
4350 co_IntShellHookNotify(HSHELL_REDRAW
, (LPARAM
) hWnd
);
4355 if (UnicodeString
.Buffer
) RtlFreeUnicodeString(&UnicodeString
);
4356 DPRINT("Leave NtUserDefSetText, ret=%i\n", Ret
);
4362 * NtUserInternalGetWindowText
4369 NtUserInternalGetWindowText(HWND hWnd
, LPWSTR lpString
, INT nMaxCount
)
4374 DECLARE_RETURN(INT
);
4376 DPRINT("Enter NtUserInternalGetWindowText\n");
4379 if(lpString
&& (nMaxCount
<= 1))
4381 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
4385 if(!(Wnd
= UserGetWindowObject(hWnd
)))
4390 Result
= Wnd
->strName
.Length
/ sizeof(WCHAR
);
4393 const WCHAR Terminator
= L
'\0';
4395 WCHAR
*Buffer
= (WCHAR
*)lpString
;
4397 Copy
= min(nMaxCount
- 1, Result
);
4400 Status
= MmCopyToCaller(Buffer
, Wnd
->strName
.Buffer
, Copy
* sizeof(WCHAR
));
4401 if(!NT_SUCCESS(Status
))
4403 SetLastNtError(Status
);
4409 Status
= MmCopyToCaller(Buffer
, &Terminator
, sizeof(WCHAR
));
4410 if(!NT_SUCCESS(Status
))
4412 SetLastNtError(Status
);
4422 DPRINT("Leave NtUserInternalGetWindowText, ret=%i\n",_ret_
);
4430 IntShowOwnedPopups(PWND OwnerWnd
, BOOL fShow
)
4436 // ASSERT(OwnerWnd);
4438 win_array
= IntWinListChildren(UserGetWindowObject(IntGetDesktopWindow()));
4443 while (win_array
[count
])
4445 while (--count
>= 0)
4447 if (!(pWnd
= UserGetWindowObject( win_array
[count
] )))
4449 if (pWnd
->spwndOwner
!= OwnerWnd
)
4454 if (pWnd
->state
& WNDS_HIDDENPOPUP
)
4456 /* In Windows, ShowOwnedPopups(TRUE) generates
4457 * WM_SHOWWINDOW messages with SW_PARENTOPENING,
4458 * regardless of the state of the owner
4460 co_IntSendMessage(win_array
[count
], WM_SHOWWINDOW
, SW_SHOWNORMAL
, SW_PARENTOPENING
);
4466 if (pWnd
->style
& WS_VISIBLE
)
4468 /* In Windows, ShowOwnedPopups(FALSE) generates
4469 * WM_SHOWWINDOW messages with SW_PARENTCLOSING,
4470 * regardless of the state of the owner
4472 co_IntSendMessage(win_array
[count
], WM_SHOWWINDOW
, SW_HIDE
, SW_PARENTCLOSING
);
4478 ExFreePool( win_array
);
4483 * NtUserValidateHandleSecure
4491 NtUserValidateHandleSecure(
4499 PUSER_HANDLE_ENTRY entry
;
4500 if (!(entry
= handle_to_entry(gHandleTable
, handle
)))
4502 SetLastWin32Error(ERROR_INVALID_HANDLE
);
4505 uType
= entry
->type
;
4512 if ((Window
= UserGetWindowObject((HWND
) handle
))) return TRUE
;
4518 if ((Menu
= UserGetMenuObject((HMENU
) handle
))) return TRUE
;
4523 PACCELERATOR_TABLE Accel
;
4524 if ((Accel
= UserGetAccelObject((HACCEL
) handle
))) return TRUE
;
4529 PCURICON_OBJECT Cursor
;
4530 if ((Cursor
= UserGetCurIconObject((HCURSOR
) handle
))) return TRUE
;
4536 if ((Hook
= IntGetHookObject((HHOOK
) handle
))) return TRUE
;
4542 if ((Monitor
= UserGetMonitorObject((HMONITOR
) handle
))) return TRUE
;
4548 return UserGetCallProcInfo( handle
, &Proc
);
4551 SetLastWin32Error(ERROR_INVALID_HANDLE
);
4555 { /* Is handle entry restricted? */