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 PWND FASTCALL
IntGetWindowObject(HWND hWnd
)
91 if (!hWnd
) return NULL
;
93 Window
= UserGetWindowObject(hWnd
);
96 ASSERT(Window
->head
.cLockObj
>= 0);
98 Window
->head
.cLockObj
++;
104 PWND FASTCALL
UserGetWindowObject(HWND hWnd
)
109 if (PsGetCurrentProcess() != PsInitialSystemProcess
)
111 ti
= GetW32ThreadInfo();
114 SetLastWin32Error(ERROR_ACCESS_DENIED
);
121 SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE
);
125 Window
= (PWND
)UserGetObject(gHandleTable
, hWnd
, otWindow
);
126 if (!Window
|| 0 != (Window
->state
& WNDS_DESTROYED
))
128 SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE
);
132 ASSERT(Window
->head
.cLockObj
>= 0);
141 * The function determines whether the specified window handle identifies
142 * an existing window.
146 * Handle to the window to test.
149 * If the window handle identifies an existing window, the return value
150 * is TRUE. If the window handle does not identify an existing window,
151 * the return value is FALSE.
155 IntIsWindow(HWND hWnd
)
159 if (!(Window
= UserGetWindowObject(hWnd
)))
167 IntGetParent(PWND Wnd
)
169 if (Wnd
->style
& WS_POPUP
)
171 return Wnd
->spwndOwner
;
173 else if (Wnd
->style
& WS_CHILD
)
175 return Wnd
->spwndParent
;
184 * Compile a list of all child window handles from given window.
187 * This function is similar to Wine WIN_ListChildren. The caller
188 * must free the returned list with ExFreePool.
192 IntWinListChildren(PWND Window
)
196 UINT Index
, NumChildren
= 0;
198 if (!Window
) return NULL
;
200 for (Child
= Window
->spwndChild
; Child
; Child
= Child
->spwndNext
)
203 List
= ExAllocatePoolWithTag(PagedPool
, (NumChildren
+ 1) * sizeof(HWND
), TAG_WINLIST
);
206 DPRINT1("Failed to allocate memory for children array\n");
207 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
210 for (Child
= Window
->spwndChild
, Index
= 0;
212 Child
= Child
->spwndNext
, ++Index
)
213 List
[Index
] = Child
->head
.h
;
219 /***********************************************************************
222 static void IntSendDestroyMsg(HWND hWnd
)
230 if (GetGUIThreadInfo(GetCurrentThreadId(), &info
))
232 if (hWnd
== info
.hwndCaret
)
239 Window
= UserGetWindowObject(hWnd
);
242 // USER_REFERENCE_ENTRY Ref;
243 // UserRefObjectCo(Window, &Ref);
245 if (!Window
->spwndOwner
&& !IntGetParent(Window
))
247 co_IntShellHookNotify(HSHELL_WINDOWDESTROYED
, (LPARAM
) hWnd
);
250 // UserDerefObjectCo(Window);
253 /* The window could already be destroyed here */
256 * Send the WM_DESTROY to the window.
259 co_IntSendMessage(hWnd
, WM_DESTROY
, 0, 0);
262 * This WM_DESTROY message can trigger re-entrant calls to DestroyWindow
263 * make sure that the window still exists when we come back.
272 if (!(pWndArray
= WIN_ListChildren( hwnd
)))
275 /* start from the end (FIXME: is this needed?) */
276 for (i
= 0; pWndArray
[i
]; i
++)
281 if (IsWindow( pWndArray
[i
] ))
282 WIN_SendDestroyMsg( pWndArray
[i
] );
284 HeapFree(GetProcessHeap(), 0, pWndArray
);
288 DPRINT("destroyed itself while in WM_DESTROY!\n");
294 UserFreeWindowInfo(PTHREADINFO ti
, PWND Wnd
)
296 PCLIENTINFO ClientInfo
= GetWin32ClientInfo();
300 if (ClientInfo
->CallbackWnd
.pWnd
== DesktopHeapAddressToUser(Wnd
))
302 ClientInfo
->CallbackWnd
.hWnd
= NULL
;
303 ClientInfo
->CallbackWnd
.pWnd
= NULL
;
306 if (Wnd
->strName
.Buffer
!= NULL
)
308 Wnd
->strName
.Length
= 0;
309 Wnd
->strName
.MaximumLength
= 0;
310 DesktopHeapFree(Wnd
->head
.rpdesk
,
311 Wnd
->strName
.Buffer
);
312 Wnd
->strName
.Buffer
= NULL
;
315 // DesktopHeapFree(Wnd->head.rpdesk, Wnd);
316 // WindowObject->Wnd = NULL;
319 /***********************************************************************
322 * Destroy storage associated to a window. "Internals" p.358
324 * This is the "functional" DestroyWindows function ei. all stuff
325 * done in CreateWindow is undone here and not in DestroyWindow:-P
328 static LRESULT
co_UserFreeWindow(PWND Window
,
329 PPROCESSINFO ProcessData
,
330 PTHREADINFO ThreadData
,
331 BOOLEAN SendMessages
)
337 BOOLEAN BelongsToThreadData
;
341 if(Window
->state2
& WNDS2_INDESTROY
)
343 DPRINT("Tried to call IntDestroyWindow() twice\n");
346 Window
->state2
|= WNDS2_INDESTROY
;
347 Window
->style
&= ~WS_VISIBLE
;
349 IntNotifyWinEvent(EVENT_OBJECT_DESTROY
, Window
, OBJID_WINDOW
, CHILDID_SELF
, 0);
351 /* remove the window already at this point from the thread window list so we
352 don't get into trouble when destroying the thread windows while we're still
353 in IntDestroyWindow() */
354 RemoveEntryList(&Window
->ThreadListEntry
);
356 BelongsToThreadData
= IntWndBelongsToThread(Window
, ThreadData
);
358 IntDeRegisterShellHookWindow(Window
->head
.h
);
362 /* Send destroy messages */
363 IntSendDestroyMsg(Window
->head
.h
);
366 /* free child windows */
367 Children
= IntWinListChildren(Window
);
370 for (ChildHandle
= Children
; *ChildHandle
; ++ChildHandle
)
372 if ((Child
= IntGetWindowObject(*ChildHandle
)))
374 if(!IntWndBelongsToThread(Child
, ThreadData
))
376 /* send WM_DESTROY messages to windows not belonging to the same thread */
377 IntSendDestroyMsg(Child
->head
.h
);
380 co_UserFreeWindow(Child
, ProcessData
, ThreadData
, SendMessages
);
382 UserDereferenceObject(Child
);
385 ExFreePool(Children
);
391 * Clear the update region to make sure no WM_PAINT messages will be
392 * generated for this window while processing the WM_NCDESTROY.
394 co_UserRedrawWindow(Window
, NULL
, 0,
395 RDW_VALIDATE
| RDW_NOFRAME
| RDW_NOERASE
|
396 RDW_NOINTERNALPAINT
| RDW_NOCHILDREN
);
397 if(BelongsToThreadData
)
398 co_IntSendMessage(Window
->head
.h
, WM_NCDESTROY
, 0, 0);
401 DestroyTimersForWindow(ThreadData
, Window
);
403 HOOK_DestroyThreadHooks(ThreadData
->pEThread
); // This is needed here too!
405 /* flush the message queue */
406 MsqRemoveWindowMessagesFromQueue(Window
);
408 /* from now on no messages can be sent to this window anymore */
409 Window
->state
|= WNDS_DESTROYED
;
410 Window
->fnid
|= FNID_FREED
;
412 /* don't remove the WINDOWSTATUS_DESTROYING bit */
414 /* reset shell window handles */
415 if(ThreadData
->rpdesk
)
417 if (Window
->head
.h
== ThreadData
->rpdesk
->rpwinstaParent
->ShellWindow
)
418 ThreadData
->rpdesk
->rpwinstaParent
->ShellWindow
= NULL
;
420 if (Window
->head
.h
== ThreadData
->rpdesk
->rpwinstaParent
->ShellListView
)
421 ThreadData
->rpdesk
->rpwinstaParent
->ShellListView
= NULL
;
424 /* Unregister hot keys */
425 UnregisterWindowHotKeys (Window
);
427 /* FIXME: do we need to fake QS_MOUSEMOVE wakebit? */
431 WinPosCheckInternalPos(Window
->head
.h
);
432 if (Window
->head
.h
== GetCapture())
437 /* free resources associated with the window */
438 TIMER_RemoveWindowTimers(Window
->head
.h
);
441 if (!(Window
->style
& WS_CHILD
) && Window
->IDMenu
442 && (Menu
= UserGetMenuObject((HMENU
)Window
->IDMenu
)))
444 IntDestroyMenuObject(Menu
, TRUE
, TRUE
);
448 if(Window
->SystemMenu
449 && (Menu
= UserGetMenuObject(Window
->SystemMenu
)))
451 IntDestroyMenuObject(Menu
, TRUE
, TRUE
);
452 Window
->SystemMenu
= (HMENU
)0;
455 DceFreeWindowDCE(Window
); /* Always do this to catch orphaned DCs */
458 WINPROC_FreeProc(Window
->winproc
, WIN_PROC_WINDOW
);
459 CLASS_RemoveWindow(Window
->Class
);
462 IntUnlinkWindow(Window
);
464 UserReferenceObject(Window
);
465 UserDeleteObject(Window
->head
.h
, otWindow
);
467 IntDestroyScrollBars(Window
);
469 /* dereference the class */
470 IntDereferenceClass(Window
->pcls
,
471 Window
->head
.pti
->pDeskInfo
,
472 Window
->head
.pti
->ppi
);
477 GreDeleteObject(Window
->hrgnClip
);
480 // ASSERT(Window != NULL);
481 UserFreeWindowInfo(Window
->head
.pti
, Window
);
483 UserDereferenceObject(Window
);
485 IntClipboardFreeWindow(Window
);
491 IntGetWindowBorderMeasures(PWND Wnd
, UINT
*cx
, UINT
*cy
)
493 if(HAS_DLGFRAME(Wnd
->style
, Wnd
->ExStyle
) && !(Wnd
->style
& WS_MINIMIZE
))
495 *cx
= UserGetSystemMetrics(SM_CXDLGFRAME
);
496 *cy
= UserGetSystemMetrics(SM_CYDLGFRAME
);
500 if(HAS_THICKFRAME(Wnd
->style
, Wnd
->ExStyle
)&& !(Wnd
->style
& WS_MINIMIZE
))
502 *cx
= UserGetSystemMetrics(SM_CXFRAME
);
503 *cy
= UserGetSystemMetrics(SM_CYFRAME
);
505 else if(HAS_THINFRAME(Wnd
->style
, Wnd
->ExStyle
))
507 *cx
= UserGetSystemMetrics(SM_CXBORDER
);
508 *cy
= UserGetSystemMetrics(SM_CYBORDER
);
518 // Same as User32:IntGetWndProc.
521 IntGetWindowProc(PWND pWnd
,
526 WNDPROC gcpd
, Ret
= 0;
528 ASSERT(UserIsEnteredExclusive() == TRUE
);
532 if (pWnd
->state
& WNDS_SERVERSIDEWINDOWPROC
)
534 for ( i
= FNID_FIRST
; i
<= FNID_SWITCH
; i
++)
536 if (GETPFNSERVER(i
) == pWnd
->lpfnWndProc
)
539 Ret
= GETPFNCLIENTA(i
);
541 Ret
= GETPFNCLIENTW(i
);
547 if (Class
->fnid
== FNID_EDIT
)
548 Ret
= pWnd
->lpfnWndProc
;
551 Ret
= pWnd
->lpfnWndProc
;
553 if (Class
->fnid
<= FNID_GHOST
&& Class
->fnid
>= FNID_BUTTON
)
557 if (GETPFNCLIENTW(Class
->fnid
) == pWnd
->lpfnWndProc
)
558 Ret
= GETPFNCLIENTA(Class
->fnid
);
562 if (GETPFNCLIENTA(Class
->fnid
) == pWnd
->lpfnWndProc
)
563 Ret
= GETPFNCLIENTW(Class
->fnid
);
566 if ( Ret
!= pWnd
->lpfnWndProc
)
569 if ( Ansi
== !!(pWnd
->state
& WNDS_ANSIWINDOWPROC
) )
572 gcpd
= (WNDPROC
)UserGetCPD(
574 (Ansi
? UserGetCPDA2U
: UserGetCPDU2A
)|UserGetCPDWindow
,
577 return (gcpd
? gcpd
: Ret
);
581 IntSetWindowProc(PWND pWnd
,
586 PCALLPROCDATA CallProc
;
588 WNDPROC Ret
, chWndProc
= NULL
;
590 // Retrieve previous window proc.
591 Ret
= IntGetWindowProc(pWnd
, Ansi
);
595 if (IsCallProcHandle(NewWndProc
))
597 CallProc
= UserGetObject(gHandleTable
, NewWndProc
, otCallProc
);
599 { // Reset new WndProc.
600 NewWndProc
= CallProc
->pfnClientPrevious
;
601 // Reset Ansi from CallProc handle. This is expected with wine "deftest".
602 Ansi
= !!(CallProc
->wType
& UserGetCPDU2A
);
605 // Switch from Client Side call to Server Side call if match. Ref: "deftest".
606 for ( i
= FNID_FIRST
; i
<= FNID_SWITCH
; i
++)
608 if (GETPFNCLIENTW(i
) == NewWndProc
)
610 chWndProc
= GETPFNSERVER(i
);
613 if (GETPFNCLIENTA(i
) == NewWndProc
)
615 chWndProc
= GETPFNSERVER(i
);
619 // If match, set/reset to Server Side and clear ansi.
622 pWnd
->lpfnWndProc
= chWndProc
;
623 pWnd
->Unicode
= TRUE
;
624 pWnd
->state
&= ~WNDS_ANSIWINDOWPROC
;
625 pWnd
->state
|= WNDS_SERVERSIDEWINDOWPROC
;
629 pWnd
->Unicode
= !Ansi
;
630 // Handle the state change in here.
632 pWnd
->state
|= WNDS_ANSIWINDOWPROC
;
634 pWnd
->state
&= ~WNDS_ANSIWINDOWPROC
;
636 if (pWnd
->state
& WNDS_SERVERSIDEWINDOWPROC
)
637 pWnd
->state
&= ~WNDS_SERVERSIDEWINDOWPROC
;
639 if (!NewWndProc
) NewWndProc
= pWnd
->lpfnWndProc
;
641 if (Class
->fnid
<= FNID_GHOST
&& Class
->fnid
>= FNID_BUTTON
)
645 if (GETPFNCLIENTW(Class
->fnid
) == NewWndProc
)
646 chWndProc
= GETPFNCLIENTA(Class
->fnid
);
650 if (GETPFNCLIENTA(Class
->fnid
) == NewWndProc
)
651 chWndProc
= GETPFNCLIENTW(Class
->fnid
);
654 // Now set the new window proc.
655 pWnd
->lpfnWndProc
= (chWndProc
? chWndProc
: NewWndProc
);
660 // Move this to user space!
662 IntGetWindowInfo(PWND Wnd
, PWINDOWINFO pwi
)
664 pwi
->cbSize
= sizeof(WINDOWINFO
);
665 pwi
->rcWindow
= Wnd
->rcWindow
;
666 pwi
->rcClient
= Wnd
->rcClient
;
667 pwi
->dwStyle
= Wnd
->style
;
668 pwi
->dwExStyle
= Wnd
->ExStyle
;
669 pwi
->dwWindowStatus
= (UserGetForegroundWindow() == Wnd
->head
.h
); /* WS_ACTIVECAPTION */
670 IntGetWindowBorderMeasures(Wnd
, &pwi
->cxWindowBorders
, &pwi
->cyWindowBorders
);
671 pwi
->atomWindowType
= (Wnd
->pcls
? Wnd
->pcls
->atomClassName
: 0);
672 pwi
->wCreatorVersion
= 0x400; /* FIXME - return a real version number */
682 PMENU_OBJECT OldMenu
, NewMenu
= NULL
;
684 if ((Wnd
->style
& (WS_CHILD
| WS_POPUP
)) == WS_CHILD
)
686 SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE
);
690 *Changed
= (Wnd
->IDMenu
!= (UINT
) Menu
);
698 OldMenu
= IntGetMenuObject((HMENU
) Wnd
->IDMenu
);
699 ASSERT(NULL
== OldMenu
|| OldMenu
->MenuInfo
.Wnd
== Wnd
->head
.h
);
708 NewMenu
= IntGetMenuObject(Menu
);
713 IntReleaseMenuObject(OldMenu
);
715 SetLastWin32Error(ERROR_INVALID_MENU_HANDLE
);
718 if (NULL
!= NewMenu
->MenuInfo
.Wnd
)
720 /* Can't use the same menu for two windows */
723 IntReleaseMenuObject(OldMenu
);
725 SetLastWin32Error(ERROR_INVALID_MENU_HANDLE
);
731 Wnd
->IDMenu
= (UINT
) Menu
;
734 NewMenu
->MenuInfo
.Wnd
= Wnd
->head
.h
;
735 IntReleaseMenuObject(NewMenu
);
739 OldMenu
->MenuInfo
.Wnd
= NULL
;
740 IntReleaseMenuObject(OldMenu
);
747 /* INTERNAL ******************************************************************/
751 co_DestroyThreadWindows(struct _ETHREAD
*Thread
)
756 USER_REFERENCE_ENTRY Ref
;
757 WThread
= (PTHREADINFO
)Thread
->Tcb
.Win32Thread
;
759 while (!IsListEmpty(&WThread
->WindowListHead
))
761 Current
= WThread
->WindowListHead
.Flink
;
762 Wnd
= CONTAINING_RECORD(Current
, WND
, ThreadListEntry
);
764 DPRINT("thread cleanup: while destroy wnds, wnd=0x%x\n",Wnd
);
766 /* window removes itself from the list */
769 fixme: it is critical that the window removes itself! if now, we will loop
773 //ASSERT(co_UserDestroyWindow(Wnd));
775 UserRefObjectCo(Wnd
, &Ref
);//faxme: temp hack??
776 if (!co_UserDestroyWindow(Wnd
))
778 DPRINT1("Unable to destroy window 0x%x at thread cleanup... This is _VERY_ bad!\n", Wnd
);
780 UserDerefObjectCo(Wnd
);//faxme: temp hack??
788 * Returns client window rectangle relative to the upper-left corner of client area.
790 * \note Does not check the validity of the parameters
793 IntGetClientRect(PWND Window
, RECTL
*Rect
)
798 Rect
->left
= Rect
->top
= 0;
799 Rect
->right
= Window
->rcClient
.right
- Window
->rcClient
.left
;
800 Rect
->bottom
= Window
->rcClient
.bottom
- Window
->rcClient
.top
;
806 IntGetFocusWindow(VOID
)
808 PUSER_MESSAGE_QUEUE Queue
;
809 PDESKTOP pdo
= IntGetActiveDesktop();
814 Queue
= (PUSER_MESSAGE_QUEUE
)pdo
->ActiveMessageQueue
;
819 return(Queue
->FocusWindow
);
823 PMENU_OBJECT FASTCALL
824 IntGetSystemMenu(PWND Window
, BOOL bRevert
, BOOL RetMenu
)
826 PMENU_OBJECT Menu
, NewMenu
= NULL
, SysMenu
= NULL
, ret
= NULL
;
827 PTHREADINFO W32Thread
;
828 HMENU hNewMenu
, hSysMenu
;
829 ROSMENUITEMINFO ItemInfo
;
833 W32Thread
= PsGetCurrentThreadWin32Thread();
835 if(!W32Thread
->rpdesk
)
838 if(Window
->SystemMenu
)
840 Menu
= UserGetMenuObject(Window
->SystemMenu
);
843 IntDestroyMenuObject(Menu
, TRUE
, TRUE
);
844 Window
->SystemMenu
= (HMENU
)0;
848 if(W32Thread
->rpdesk
->rpwinstaParent
->SystemMenuTemplate
)
850 /* clone system menu */
851 Menu
= UserGetMenuObject(W32Thread
->rpdesk
->rpwinstaParent
->SystemMenuTemplate
);
855 NewMenu
= IntCloneMenu(Menu
);
858 Window
->SystemMenu
= NewMenu
->MenuInfo
.Self
;
859 NewMenu
->MenuInfo
.Flags
|= MF_SYSMENU
;
860 NewMenu
->MenuInfo
.Wnd
= Window
->head
.h
;
862 //IntReleaseMenuObject(NewMenu);
867 hSysMenu
= UserCreateMenu(FALSE
);
868 if (NULL
== hSysMenu
)
872 SysMenu
= IntGetMenuObject(hSysMenu
);
875 UserDestroyMenu(hSysMenu
);
878 SysMenu
->MenuInfo
.Flags
|= MF_SYSMENU
;
879 SysMenu
->MenuInfo
.Wnd
= Window
->head
.h
;
880 hNewMenu
= co_IntLoadSysMenuTemplate();
883 IntReleaseMenuObject(SysMenu
);
884 UserDestroyMenu(hSysMenu
);
887 Menu
= IntGetMenuObject(hNewMenu
);
890 IntReleaseMenuObject(SysMenu
);
891 UserDestroyMenu(hSysMenu
);
895 NewMenu
= IntCloneMenu(Menu
);
898 NewMenu
->MenuInfo
.Flags
|= MF_SYSMENU
| MF_POPUP
;
899 IntReleaseMenuObject(NewMenu
);
900 UserSetMenuDefaultItem(NewMenu
, SC_CLOSE
, FALSE
);
902 ItemInfo
.cbSize
= sizeof(MENUITEMINFOW
);
903 ItemInfo
.fMask
= MIIM_FTYPE
| MIIM_STRING
| MIIM_STATE
| MIIM_SUBMENU
;
904 ItemInfo
.fType
= MF_POPUP
;
905 ItemInfo
.fState
= MFS_ENABLED
;
906 ItemInfo
.dwTypeData
= NULL
;
908 ItemInfo
.hSubMenu
= NewMenu
->MenuInfo
.Self
;
909 IntInsertMenuItem(SysMenu
, (UINT
) -1, TRUE
, &ItemInfo
);
911 Window
->SystemMenu
= SysMenu
->MenuInfo
.Self
;
915 IntDestroyMenuObject(Menu
, FALSE
, TRUE
);
924 if(Window
->SystemMenu
)
925 return IntGetMenuObject((HMENU
)Window
->SystemMenu
);
933 IntIsChildWindow(PWND Parent
, PWND BaseWindow
)
940 if (Window
== Parent
)
944 if(!(Window
->style
& WS_CHILD
))
949 Window
= Window
->spwndParent
;
956 IntIsWindowVisible(PWND BaseWindow
)
963 if(!(Window
->style
& WS_CHILD
))
967 if(!(Window
->style
& WS_VISIBLE
))
972 Window
= Window
->spwndParent
;
975 if(Window
&& Window
->style
& WS_VISIBLE
)
985 link the window into siblings list
986 children and parent are kept in place.
991 PWND WndInsertAfter
/* set to NULL if top sibling */
994 if ((Wnd
->spwndPrev
= WndInsertAfter
))
996 /* link after WndInsertAfter */
997 if ((Wnd
->spwndNext
= WndInsertAfter
->spwndNext
))
998 Wnd
->spwndNext
->spwndPrev
= Wnd
;
1000 Wnd
->spwndPrev
->spwndNext
= Wnd
;
1005 if ((Wnd
->spwndNext
= Wnd
->spwndParent
->spwndChild
))
1006 Wnd
->spwndNext
->spwndPrev
= Wnd
;
1008 Wnd
->spwndParent
->spwndChild
= Wnd
;
1013 VOID FASTCALL
IntLinkHwnd(PWND Wnd
, HWND hWndPrev
)
1015 if (hWndPrev
== HWND_NOTOPMOST
)
1017 if (!(Wnd
->ExStyle
& WS_EX_TOPMOST
) &&
1018 (Wnd
->ExStyle2
& WS_EX2_LINKED
)) return; /* nothing to do */
1019 Wnd
->ExStyle
&= ~WS_EX_TOPMOST
;
1020 hWndPrev
= HWND_TOP
; /* fallback to the HWND_TOP case */
1023 IntUnlinkWindow(Wnd
); /* unlink it from the previous location */
1025 if (hWndPrev
== HWND_BOTTOM
)
1027 /* Link in the bottom of the list */
1028 PWND WndInsertAfter
;
1030 WndInsertAfter
= Wnd
->spwndParent
->spwndChild
;
1031 while( WndInsertAfter
&& WndInsertAfter
->spwndNext
)
1032 WndInsertAfter
= WndInsertAfter
->spwndNext
;
1034 IntLinkWindow(Wnd
, WndInsertAfter
);
1035 Wnd
->ExStyle
&= ~WS_EX_TOPMOST
;
1037 else if (hWndPrev
== HWND_TOPMOST
)
1039 /* Link in the top of the list */
1040 IntLinkWindow(Wnd
, NULL
);
1042 Wnd
->ExStyle
|= WS_EX_TOPMOST
;
1044 else if (hWndPrev
== HWND_TOP
)
1046 /* Link it after the last topmost window */
1047 PWND WndInsertBefore
;
1049 WndInsertBefore
= Wnd
->spwndParent
->spwndChild
;
1051 if (!(Wnd
->ExStyle
& WS_EX_TOPMOST
)) /* put it above the first non-topmost window */
1053 while (WndInsertBefore
!= NULL
&& WndInsertBefore
->spwndNext
!= NULL
)
1055 if (!(WndInsertBefore
->ExStyle
& WS_EX_TOPMOST
)) break;
1056 if (WndInsertBefore
== Wnd
->spwndOwner
) /* keep it above owner */
1058 Wnd
->ExStyle
|= WS_EX_TOPMOST
;
1061 WndInsertBefore
= WndInsertBefore
->spwndNext
;
1065 IntLinkWindow(Wnd
, WndInsertBefore
? WndInsertBefore
->spwndPrev
: NULL
);
1069 /* Link it after hWndPrev */
1070 PWND WndInsertAfter
;
1072 WndInsertAfter
= UserGetWindowObject(hWndPrev
);
1073 /* Are we called with an erroneous handle */
1074 if(WndInsertAfter
== NULL
)
1076 /* Link in a default position */
1077 IntLinkHwnd(Wnd
, HWND_TOP
);
1081 IntLinkWindow(Wnd
, WndInsertAfter
);
1083 /* Fix the WS_EX_TOPMOST flag */
1084 if (!(WndInsertAfter
->ExStyle
& WS_EX_TOPMOST
))
1086 Wnd
->ExStyle
&= ~WS_EX_TOPMOST
;
1090 if(WndInsertAfter
->spwndNext
&&
1091 WndInsertAfter
->spwndNext
->ExStyle
& WS_EX_TOPMOST
)
1093 Wnd
->ExStyle
|= WS_EX_TOPMOST
;
1100 IntSetOwner(HWND hWnd
, HWND hWndNewOwner
)
1102 PWND Wnd
, WndOldOwner
, WndNewOwner
;
1105 Wnd
= IntGetWindowObject(hWnd
);
1109 WndOldOwner
= Wnd
->spwndOwner
;
1111 ret
= WndOldOwner
? WndOldOwner
->head
.h
: 0;
1113 if((WndNewOwner
= UserGetWindowObject(hWndNewOwner
)))
1115 Wnd
->spwndOwner
= WndNewOwner
;
1119 Wnd
->spwndOwner
= NULL
;
1122 UserDereferenceObject(Wnd
);
1127 co_IntSetParent(PWND Wnd
, PWND WndNewParent
)
1133 ASSERT(WndNewParent
);
1134 ASSERT_REFS_CO(Wnd
);
1135 ASSERT_REFS_CO(WndNewParent
);
1137 /* Some applications try to set a child as a parent */
1138 if (IntIsChildWindow(Wnd
, WndNewParent
))
1140 SetLastWin32Error( ERROR_INVALID_PARAMETER
);
1145 * Windows hides the window first, then shows it again
1146 * including the WM_SHOWWINDOW messages and all
1148 WasVisible
= co_WinPosShowWindow(Wnd
, SW_HIDE
);
1150 /* Window must belong to current process */
1151 if (Wnd
->head
.pti
->pEThread
->ThreadsProcess
!= PsGetCurrentProcess())
1154 WndOldParent
= Wnd
->spwndParent
;
1156 if (WndOldParent
) UserReferenceObject(WndOldParent
); /* caller must deref */
1158 if (WndNewParent
!= WndOldParent
)
1160 /* Unlink the window from the siblings list */
1161 IntUnlinkWindow(Wnd
);
1163 /* Set the new parent */
1164 Wnd
->spwndParent
= WndNewParent
;
1166 /* Link the window with its new siblings*/
1167 IntLinkHwnd(Wnd
, HWND_TOP
);
1171 IntNotifyWinEvent(EVENT_OBJECT_PARENTCHANGE
, Wnd
,OBJID_WINDOW
, CHILDID_SELF
, WEF_SETBYWNDPTI
);
1173 * SetParent additionally needs to make hwnd the top window
1174 * in the z-order and send the expected WM_WINDOWPOSCHANGING and
1175 * WM_WINDOWPOSCHANGED notification messages.
1177 co_WinPosSetWindowPos(Wnd
, (0 == (Wnd
->ExStyle
& WS_EX_TOPMOST
) ? HWND_TOP
: HWND_TOPMOST
),
1178 0, 0, 0, 0, SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOSIZE
1179 | (WasVisible
? SWP_SHOWWINDOW
: 0));
1182 * FIXME: a WM_MOVE is also generated (in the DefWindowProc handler
1183 * for WM_WINDOWPOSCHANGED) in Windows, should probably remove SWP_NOMOVE
1186 return WndOldParent
;
1190 IntSetSystemMenu(PWND Window
, PMENU_OBJECT Menu
)
1192 PMENU_OBJECT OldMenu
;
1193 if(Window
->SystemMenu
)
1195 OldMenu
= IntGetMenuObject(Window
->SystemMenu
);
1198 OldMenu
->MenuInfo
.Flags
&= ~ MF_SYSMENU
;
1199 IntReleaseMenuObject(OldMenu
);
1205 /* FIXME check window style, propably return FALSE ? */
1206 Window
->SystemMenu
= Menu
->MenuInfo
.Self
;
1207 Menu
->MenuInfo
.Flags
|= MF_SYSMENU
;
1210 Window
->SystemMenu
= (HMENU
)0;
1215 /* unlink the window from siblings. children and parent are kept in place. */
1217 IntUnlinkWindow(PWND Wnd
)
1220 Wnd
->spwndNext
->spwndPrev
= Wnd
->spwndPrev
;
1223 Wnd
->spwndPrev
->spwndNext
= Wnd
->spwndNext
;
1225 if (Wnd
->spwndParent
&& Wnd
->spwndParent
->spwndChild
== Wnd
)
1226 Wnd
->spwndParent
->spwndChild
= Wnd
->spwndNext
;
1228 Wnd
->spwndPrev
= Wnd
->spwndNext
= NULL
;
1233 IntGetWindowPlacement(PWND Wnd
, WINDOWPLACEMENT
*lpwndpl
)
1237 if (!Wnd
) return FALSE
;
1239 if(lpwndpl
->length
!= sizeof(WINDOWPLACEMENT
))
1245 if (0 == (Wnd
->style
& WS_VISIBLE
))
1247 lpwndpl
->showCmd
= SW_HIDE
;
1249 else if (0 != (Wnd
->state2
& WNDS2_MAXIMIZEBUTTONDOWN
) ||
1250 0 != (Wnd
->style
& WS_MAXIMIZE
))
1252 lpwndpl
->showCmd
= SW_MAXIMIZE
;
1254 else if (0 != (Wnd
->style
& WS_MINIMIZE
))
1256 lpwndpl
->showCmd
= SW_MINIMIZE
;
1258 else if (0 != (Wnd
->style
& WS_VISIBLE
))
1260 lpwndpl
->showCmd
= SW_SHOWNORMAL
;
1263 Size
.x
= Wnd
->rcWindow
.left
;
1264 Size
.y
= Wnd
->rcWindow
.top
;
1265 WinPosInitInternalPos(Wnd
, &Size
,
1268 lpwndpl
->rcNormalPosition
= Wnd
->InternalPos
.NormalRect
;
1269 lpwndpl
->ptMinPosition
= Wnd
->InternalPos
.IconPos
;
1270 lpwndpl
->ptMaxPosition
= Wnd
->InternalPos
.MaxPos
;
1276 /* FUNCTIONS *****************************************************************/
1282 NtUserAlterWindowStyle(DWORD Unknown0
,
1292 * As best as I can figure, this function is used by EnumWindows,
1293 * EnumChildWindows, EnumDesktopWindows, & EnumThreadWindows.
1295 * It's supposed to build a list of HWNDs to return to the caller.
1296 * We can figure out what kind of list by what parameters are
1304 NtUserBuildHwndList(
1317 return ERROR_INVALID_PARAMETER
;
1319 if (hwndParent
|| !dwThreadId
)
1322 PWND Parent
, Window
;
1326 if(hDesktop
== NULL
&& !(Desktop
= IntGetActiveDesktop()))
1328 return ERROR_INVALID_HANDLE
;
1333 Status
= IntValidateDesktopHandle(hDesktop
,
1337 if(!NT_SUCCESS(Status
))
1339 return ERROR_INVALID_HANDLE
;
1342 hwndParent
= Desktop
->DesktopWindow
;
1349 if((Parent
= UserGetWindowObject(hwndParent
)) &&
1350 (Window
= Parent
->spwndChild
))
1352 BOOL bGoDown
= TRUE
;
1354 Status
= STATUS_SUCCESS
;
1359 if(dwCount
++ < *pBufSize
&& pWnd
)
1363 ProbeForWrite(pWnd
, sizeof(HWND
), 1);
1364 *pWnd
= Window
->head
.h
;
1367 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1369 Status
= _SEH2_GetExceptionCode();
1372 if(!NT_SUCCESS(Status
))
1374 SetLastNtError(Status
);
1378 if (Window
->spwndChild
&& bChildren
)
1380 Window
= Window
->spwndChild
;
1385 if (Window
->spwndNext
)
1387 Window
= Window
->spwndNext
;
1391 Window
= Window
->spwndParent
;
1392 if (Window
== Parent
)
1401 ObDereferenceObject(Desktop
);
1407 PTHREADINFO W32Thread
;
1408 PLIST_ENTRY Current
;
1411 Status
= PsLookupThreadByThreadId((HANDLE
)dwThreadId
, &Thread
);
1412 if(!NT_SUCCESS(Status
))
1414 return ERROR_INVALID_PARAMETER
;
1416 if(!(W32Thread
= (PTHREADINFO
)Thread
->Tcb
.Win32Thread
))
1418 ObDereferenceObject(Thread
);
1419 DPRINT("Thread is not a GUI Thread!\n");
1420 return ERROR_INVALID_PARAMETER
;
1423 Current
= W32Thread
->WindowListHead
.Flink
;
1424 while(Current
!= &(W32Thread
->WindowListHead
))
1426 Window
= CONTAINING_RECORD(Current
, WND
, ThreadListEntry
);
1429 if(bChildren
|| Window
->spwndOwner
!= NULL
)
1431 if(dwCount
< *pBufSize
&& pWnd
)
1433 Status
= MmCopyToCaller(pWnd
++, &Window
->head
.h
, sizeof(HWND
));
1434 if(!NT_SUCCESS(Status
))
1436 SetLastNtError(Status
);
1442 Current
= Current
->Flink
;
1445 ObDereferenceObject(Thread
);
1448 *pBufSize
= dwCount
;
1449 return STATUS_SUCCESS
;
1457 NtUserChildWindowFromPointEx(HWND hwndParent
,
1467 if(!(Parent
= UserGetWindowObject(hwndParent
)))
1475 if(Parent
->head
.h
!= IntGetDesktopWindow())
1477 Pt
.x
+= Parent
->rcClient
.left
;
1478 Pt
.y
+= Parent
->rcClient
.top
;
1481 if(!IntPtInWindow(Parent
, Pt
.x
, Pt
.y
))
1486 Ret
= Parent
->head
.h
;
1487 if((List
= IntWinListChildren(Parent
)))
1489 for(phWnd
= List
; *phWnd
; phWnd
++)
1492 if((Child
= UserGetWindowObject(*phWnd
)))
1494 if(!(Child
->style
& WS_VISIBLE
) && (uiFlags
& CWP_SKIPINVISIBLE
))
1498 if((Child
->style
& WS_DISABLED
) && (uiFlags
& CWP_SKIPDISABLED
))
1502 if((Child
->ExStyle
& WS_EX_TRANSPARENT
) && (uiFlags
& CWP_SKIPTRANSPARENT
))
1506 if(IntPtInWindow(Child
, Pt
.x
, Pt
.y
))
1508 Ret
= Child
->head
.h
;
1519 static void IntSendParentNotify( PWND pWindow
, UINT msg
)
1521 if ( (pWindow
->style
& (WS_CHILD
| WS_POPUP
)) == WS_CHILD
&&
1522 !(pWindow
->style
& WS_EX_NOPARENTNOTIFY
))
1524 if (pWindow
->spwndParent
&& pWindow
->spwndParent
!= UserGetDesktopWindow())
1526 co_IntSendMessage( pWindow
->spwndParent
->head
.h
,
1528 MAKEWPARAM( msg
, pWindow
->IDMenu
),
1529 (LPARAM
)pWindow
->head
.h
);
1535 IntFixWindowCoordinates(CREATESTRUCTW
* Cs
, PWND ParentWindow
, DWORD
* dwShowMode
)
1537 #define IS_DEFAULT(x) ((x) == CW_USEDEFAULT || (x) == (SHORT)0x8000)
1539 /* default positioning for overlapped windows */
1540 if(!(Cs
->style
& (WS_POPUP
| WS_CHILD
)))
1543 PRTL_USER_PROCESS_PARAMETERS ProcessParams
;
1545 pMonitor
= IntGetPrimaryMonitor();
1548 ProcessParams
= PsGetCurrentProcess()->Peb
->ProcessParameters
;
1550 if (IS_DEFAULT(Cs
->x
))
1552 if (!IS_DEFAULT(Cs
->y
)) *dwShowMode
= Cs
->y
;
1554 if(ProcessParams
->WindowFlags
& STARTF_USEPOSITION
)
1556 Cs
->x
= ProcessParams
->StartingX
;
1557 Cs
->y
= ProcessParams
->StartingY
;
1561 Cs
->x
= pMonitor
->cWndStack
* (UserGetSystemMetrics(SM_CXSIZE
) + UserGetSystemMetrics(SM_CXFRAME
));
1562 Cs
->y
= pMonitor
->cWndStack
* (UserGetSystemMetrics(SM_CYSIZE
) + UserGetSystemMetrics(SM_CYFRAME
));
1563 if (Cs
->x
> ((pMonitor
->rcWork
.right
- pMonitor
->rcWork
.left
) / 4) ||
1564 Cs
->y
> ((pMonitor
->rcWork
.bottom
- pMonitor
->rcWork
.top
) / 4))
1566 /* reset counter and position */
1569 pMonitor
->cWndStack
= 0;
1571 pMonitor
->cWndStack
++;
1575 if (IS_DEFAULT(Cs
->cx
))
1577 if (ProcessParams
->WindowFlags
& STARTF_USEPOSITION
)
1579 Cs
->cx
= ProcessParams
->CountX
;
1580 Cs
->cy
= ProcessParams
->CountY
;
1584 Cs
->cx
= (pMonitor
->rcWork
.right
- pMonitor
->rcWork
.left
) * 3 / 4;
1585 Cs
->cy
= (pMonitor
->rcWork
.bottom
- pMonitor
->rcWork
.top
) * 3 / 4;
1588 /* neither x nor cx are default. Check the y values .
1589 * In the trace we see Outlook and Outlook Express using
1590 * cy set to CW_USEDEFAULT when opening the address book.
1592 else if (IS_DEFAULT(Cs
->cy
))
1594 DPRINT("Strange use of CW_USEDEFAULT in nHeight\n");
1595 Cs
->cy
= (pMonitor
->rcWork
.bottom
- pMonitor
->rcWork
.top
) * 3 / 4;
1600 /* if CW_USEDEFAULT is set for non-overlapped windows, both values are set to zero */
1601 if(IS_DEFAULT(Cs
->x
))
1606 if(IS_DEFAULT(Cs
->cx
))
1616 /* Allocates and initializes a window*/
1617 PWND FASTCALL
IntCreateWindow(CREATESTRUCTW
* Cs
,
1618 PLARGE_STRING WindowName
,
1625 PTHREADINFO pti
= NULL
;
1626 PMENU_OBJECT SystemMenu
;
1628 BOOL bUnicodeWindow
;
1630 pti
= PsGetCurrentThreadWin32Thread();
1632 if (!(Cs
->dwExStyle
& WS_EX_LAYOUTRTL
))
1636 if ( (Cs
->style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
&&
1637 ParentWindow
->ExStyle
& WS_EX_LAYOUTRTL
&&
1638 !(ParentWindow
->ExStyle
& WS_EX_NOINHERITLAYOUT
) )
1639 Cs
->dwExStyle
|= WS_EX_LAYOUTRTL
;
1643 Note from MSDN http://msdn.microsoft.com/en-us/library/aa913269.aspx :
1645 Dialog boxes and message boxes do not inherit layout, so you must
1646 set the layout explicitly.
1648 if ( Class
&& Class
->fnid
!= FNID_DIALOG
)
1650 PPROCESSINFO ppi
= PsGetCurrentProcessWin32Process();
1651 if (ppi
->dwLayout
& LAYOUT_RTL
)
1653 Cs
->dwExStyle
|= WS_EX_LAYOUTRTL
;
1659 /* Automatically add WS_EX_WINDOWEDGE */
1660 if ((Cs
->dwExStyle
& WS_EX_DLGMODALFRAME
) ||
1661 ((!(Cs
->dwExStyle
& WS_EX_STATICEDGE
)) &&
1662 (Cs
->style
& (WS_DLGFRAME
| WS_THICKFRAME
))))
1663 Cs
->dwExStyle
|= WS_EX_WINDOWEDGE
;
1665 Cs
->dwExStyle
&= ~WS_EX_WINDOWEDGE
;
1667 /* Is it a unicode window? */
1668 bUnicodeWindow
=!(Cs
->dwExStyle
& WS_EX_SETANSICREATOR
);
1669 Cs
->dwExStyle
&= ~WS_EX_SETANSICREATOR
;
1671 /* Allocate the new window */
1672 pWnd
= (PWND
) UserCreateObject( gHandleTable
,
1676 sizeof(WND
) + Class
->cbwndExtra
);
1683 DPRINT("Created object with handle %X\n", hWnd
);
1685 if (NULL
== pti
->rpdesk
->DesktopWindow
)
1687 /* If there is no desktop window yet, we must be creating it */
1688 pti
->rpdesk
->DesktopWindow
= hWnd
;
1689 pti
->rpdesk
->pDeskInfo
->spwnd
= pWnd
;
1693 * Fill out the structure describing it.
1695 /* Remember, pWnd->head is setup in object.c ...*/
1696 pWnd
->spwndParent
= ParentWindow
;
1697 pWnd
->spwndOwner
= OwnerWindow
;
1699 pWnd
->hWndLastActive
= hWnd
;
1700 pWnd
->state2
|= WNDS2_WIN40COMPAT
;
1702 pWnd
->hModule
= Cs
->hInstance
;
1703 pWnd
->style
= Cs
->style
& ~WS_VISIBLE
;
1704 pWnd
->ExStyle
= Cs
->dwExStyle
;
1705 pWnd
->cbwndExtra
= pWnd
->pcls
->cbwndExtra
;
1707 IntReferenceMessageQueue(pWnd
->head
.pti
->MessageQueue
);
1708 if (pWnd
->spwndParent
!= NULL
&& Cs
->hwndParent
!= 0)
1710 pWnd
->HideFocus
= pWnd
->spwndParent
->HideFocus
;
1711 pWnd
->HideAccel
= pWnd
->spwndParent
->HideAccel
;
1714 if (pWnd
->pcls
->CSF_flags
& CSF_SERVERSIDEPROC
)
1715 pWnd
->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 pWnd
->lpfnWndProc
= pWnd
->pcls
->lpfnWndProc
;
1728 // GetWindowProc, test for non server side default classes and set WndProc.
1729 if ( pWnd
->pcls
->fnid
<= FNID_GHOST
&& pWnd
->pcls
->fnid
>= FNID_BUTTON
)
1733 if (GETPFNCLIENTA(pWnd
->pcls
->fnid
) == pWnd
->lpfnWndProc
)
1734 pWnd
->lpfnWndProc
= GETPFNCLIENTW(pWnd
->pcls
->fnid
);
1738 if (GETPFNCLIENTW(pWnd
->pcls
->fnid
) == pWnd
->lpfnWndProc
)
1739 pWnd
->lpfnWndProc
= GETPFNCLIENTA(pWnd
->pcls
->fnid
);
1743 // If not an Unicode caller, set Ansi creator bit.
1744 if (!bUnicodeWindow
) pWnd
->state
|= WNDS_ANSICREATOR
;
1746 // Clone Class Ansi/Unicode proc type.
1747 if (pWnd
->pcls
->CSF_flags
& CSF_ANSIPROC
)
1749 pWnd
->state
|= WNDS_ANSIWINDOWPROC
;
1750 pWnd
->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 pWnd
->state
|= WNDS_ANSIWINDOWPROC
;
1769 pWnd
->Unicode
= FALSE
;
1772 { // Set the window Unicode WndProc.
1773 pWnd
->state
&= ~WNDS_ANSIWINDOWPROC
;
1774 pWnd
->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
, pWnd
->lpfnWndProc
, pWnd
->Unicode
, pWnd
->head
.pti
->ppi
);
1788 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
1789 DPRINT1("Warning: Unable to create CallProc for edit control. Control may not operate correctly! hwnd %x\n",hWnd
);
1793 UserAddCallProcToClass(pWnd
->pcls
, CallProc
);
1797 InitializeListHead(&pWnd
->PropListHead
);
1799 if ( WindowName
->Buffer
!= NULL
&& WindowName
->Length
> 0 )
1801 pWnd
->strName
.Buffer
= DesktopHeapAlloc(pWnd
->head
.rpdesk
,
1802 WindowName
->Length
+ sizeof(UNICODE_NULL
));
1803 if (pWnd
->strName
.Buffer
== NULL
)
1808 RtlCopyMemory(pWnd
->strName
.Buffer
, WindowName
->Buffer
, WindowName
->Length
);
1809 pWnd
->strName
.Buffer
[WindowName
->Length
/ sizeof(WCHAR
)] = L
'\0';
1810 pWnd
->strName
.Length
= WindowName
->Length
;
1813 /* Correct the window style. */
1814 if ((pWnd
->style
& (WS_CHILD
| WS_POPUP
)) != WS_CHILD
)
1816 pWnd
->style
|= WS_CLIPSIBLINGS
;
1817 if (!(pWnd
->style
& WS_POPUP
))
1819 pWnd
->style
|= WS_CAPTION
;
1820 pWnd
->state
|= WNDS_SENDSIZEMOVEMSGS
;
1824 if ((pWnd
->ExStyle
& WS_EX_DLGMODALFRAME
) ||
1825 (pWnd
->style
& (WS_DLGFRAME
| WS_THICKFRAME
)))
1826 pWnd
->ExStyle
|= WS_EX_WINDOWEDGE
;
1828 pWnd
->ExStyle
&= ~WS_EX_WINDOWEDGE
;
1830 /* create system menu */
1831 if((Cs
->style
& WS_SYSMENU
) )//&& (dwStyle & WS_CAPTION) == WS_CAPTION)
1833 SystemMenu
= IntGetSystemMenu(pWnd
, TRUE
, TRUE
);
1836 pWnd
->SystemMenu
= SystemMenu
->MenuInfo
.Self
;
1837 IntReleaseMenuObject(SystemMenu
);
1841 /* Set the window menu */
1842 if ((Cs
->style
& (WS_CHILD
| WS_POPUP
)) != WS_CHILD
)
1845 IntSetMenu(pWnd
, Cs
->hMenu
, &MenuChanged
);
1846 else if (pWnd
->pcls
->lpszMenuName
) // Take it from the parent.
1848 UNICODE_STRING MenuName
;
1851 if (IS_INTRESOURCE(pWnd
->pcls
->lpszMenuName
))
1853 MenuName
.Length
= 0;
1854 MenuName
.MaximumLength
= 0;
1855 MenuName
.Buffer
= pWnd
->pcls
->lpszMenuName
;
1859 RtlInitUnicodeString( &MenuName
, pWnd
->pcls
->lpszMenuName
);
1861 hMenu
= co_IntCallLoadMenu( pWnd
->pcls
->hModule
, &MenuName
);
1862 if (hMenu
) IntSetMenu(pWnd
, hMenu
, &MenuChanged
);
1866 pWnd
->IDMenu
= (UINT
) Cs
->hMenu
;
1868 /* Insert the window into the thread's window list. */
1869 InsertTailList (&pti
->WindowListHead
, &pWnd
->ThreadListEntry
);
1871 /* Handle "CS_CLASSDC", it is tested first. */
1872 if ( (pWnd
->pcls
->style
& CS_CLASSDC
) && !(pWnd
->pcls
->pdce
) )
1873 { /* One DCE per class to have CLASS. */
1874 pWnd
->pcls
->pdce
= DceAllocDCE( pWnd
, DCE_CLASS_DC
);
1876 else if ( pWnd
->pcls
->style
& CS_OWNDC
)
1877 { /* Allocate a DCE for this window. */
1878 DceAllocDCE(pWnd
, DCE_WINDOW_DC
);
1886 UserDereferenceObject(pWnd
);
1888 SetLastNtError(STATUS_INSUFFICIENT_RESOURCES
);
1896 co_UserCreateWindowEx(CREATESTRUCTW
* Cs
,
1897 PUNICODE_STRING ClassName
,
1898 PLARGE_STRING WindowName
)
1900 PWND Window
= NULL
, ParentWindow
= NULL
, OwnerWindow
;
1901 HWND hWnd
, hWndParent
, hWndOwner
, hwndInsertAfter
;
1903 PWINSTATION_OBJECT WinSta
;
1907 CBT_CREATEWNDW
* pCbtCreate
;
1909 USER_REFERENCE_ENTRY ParentRef
, Ref
;
1911 ANSI_STRING asClassName
;
1912 DWORD dwShowMode
= SW_SHOW
;
1913 CREATESTRUCTW
*pCsw
;
1914 DECLARE_RETURN(PWND
);
1916 /* Get the current window station and reference it */
1917 pti
= GetW32ThreadInfo();
1918 if (pti
== NULL
|| pti
->rpdesk
== NULL
)
1920 DPRINT1("Thread is not attached to a desktop! Cannot create window!\n");
1921 return NULL
; //There is nothing to cleanup
1923 WinSta
= pti
->rpdesk
->rpwinstaParent
;
1924 ObReferenceObjectByPointer(WinSta
, KernelMode
, ExWindowStationObjectType
, 0);
1928 RtlInitAnsiString(&asClassName
, NULL
);
1930 /* Get the class and reference it*/
1931 Class
= IntGetAndReferenceClass(ClassName
, Cs
->hInstance
);
1934 DPRINT1("Failed to find class %wZ\n", ClassName
);
1938 /* Now find the parent and the owner window */
1939 hWndParent
= IntGetDesktopWindow();
1942 if (Cs
->hwndParent
== HWND_MESSAGE
)
1944 Cs
->hwndParent
= hWndParent
= IntGetMessageWindow();
1946 else if (Cs
->hwndParent
)
1948 if ((Cs
->style
& (WS_CHILD
|WS_POPUP
)) != WS_CHILD
)
1949 hWndOwner
= Cs
->hwndParent
;
1951 hWndParent
= Cs
->hwndParent
;
1953 else if ((Cs
->style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
)
1955 DPRINT1("Cannot create a child window without a parrent!\n");
1956 SetLastWin32Error(ERROR_TLW_WITH_WSCHILD
);
1957 RETURN(NULL
); /* WS_CHILD needs a parent, but WS_POPUP doesn't */
1960 ParentWindow
= hWndParent
? UserGetWindowObject(hWndParent
): NULL
;
1961 OwnerWindow
= hWndOwner
? UserGetWindowObject(hWndOwner
): NULL
;
1963 /* FIXME: is this correct?*/
1965 OwnerWindow
= UserGetAncestor(OwnerWindow
, GA_ROOT
);
1967 /* Fix the position and the size of the window */
1970 UserRefObjectCo(ParentWindow
, &ParentRef
);
1971 IntFixWindowCoordinates(Cs
, ParentWindow
, &dwShowMode
);
1974 /* Allocate and initialize the new window */
1975 Window
= IntCreateWindow(Cs
,
1982 DPRINT1("IntCreateWindow failed!\n");
1986 hWnd
= UserHMGetHandle(Window
);
1988 UserRefObjectCo(Window
, &Ref
);
1989 ObDereferenceObject(WinSta
);
1991 //// Call the WH_CBT hook ////
1993 // Allocate the calling structures Justin Case this goes Global.
1994 pCsw
= ExAllocatePoolWithTag(NonPagedPool
, sizeof(CREATESTRUCTW
), TAG_HOOK
);
1995 pCbtCreate
= ExAllocatePoolWithTag(NonPagedPool
, sizeof(CBT_CREATEWNDW
), TAG_HOOK
);
1997 /* Fill the new CREATESTRUCTW */
1998 pCsw
->lpCreateParams
= Cs
->lpCreateParams
;
1999 pCsw
->hInstance
= Cs
->hInstance
;
2000 pCsw
->hMenu
= Cs
->hMenu
;
2001 pCsw
->hwndParent
= Cs
->hwndParent
;
2006 pCsw
->dwExStyle
= Cs
->dwExStyle
;
2007 dwStyle
= Cs
->style
; // Save it anyway.
2008 pCsw
->style
= Window
->style
; /* HCBT_CREATEWND needs the real window style */
2010 pCsw
->lpszName
= (LPCWSTR
) WindowName
->Buffer
;
2011 pCsw
->lpszClass
= (LPCWSTR
) ClassName
->Buffer
;
2013 if (Window
->state
& WNDS_ANSICREATOR
)
2015 if (!IS_ATOM(ClassName
->Buffer
))
2017 RtlUnicodeStringToAnsiString(&asClassName
, ClassName
, TRUE
);
2018 pCsw
->lpszClass
= (LPCWSTR
) asClassName
.Buffer
;
2022 pCbtCreate
->lpcs
= pCsw
;
2023 pCbtCreate
->hwndInsertAfter
= HWND_TOP
;
2025 Result
= co_HOOK_CallHooks(WH_CBT
, HCBT_CREATEWND
, (WPARAM
) hWnd
, (LPARAM
) pCbtCreate
);
2028 DPRINT1("WH_CBT HCBT_CREATEWND hook failed! 0x%x\n", Result
);
2029 RETURN( (PWND
) NULL
);
2031 // Write back changes.
2036 hwndInsertAfter
= pCbtCreate
->hwndInsertAfter
;
2038 Cs
->style
= dwStyle
; /* NCCREATE and WM_NCCALCSIZE need the original values*/
2040 /* Send the WM_GETMINMAXINFO message*/
2044 if ((dwStyle
& WS_THICKFRAME
) || !(dwStyle
& (WS_POPUP
| WS_CHILD
)))
2046 POINT MaxSize
, MaxPos
, MinTrack
, MaxTrack
;
2048 co_WinPosGetMinMaxInfo(Window
, &MaxSize
, &MaxPos
, &MinTrack
, &MaxTrack
);
2049 if (Size
.cx
> MaxTrack
.x
) Size
.cx
= MaxTrack
.x
;
2050 if (Size
.cy
> MaxTrack
.y
) Size
.cy
= MaxTrack
.y
;
2051 if (Size
.cx
< MinTrack
.x
) Size
.cx
= MinTrack
.x
;
2052 if (Size
.cy
< MinTrack
.y
) Size
.cy
= MinTrack
.y
;
2055 Window
->rcWindow
.left
= Cs
->x
;
2056 Window
->rcWindow
.top
= Cs
->y
;
2057 Window
->rcWindow
.right
= Cs
->x
+ Size
.cx
;
2058 Window
->rcWindow
.bottom
= Cs
->y
+ Size
.cy
;
2059 if (0 != (Window
->style
& WS_CHILD
) && ParentWindow
)
2061 RECTL_vOffsetRect(&Window
->rcWindow
,
2062 ParentWindow
->rcClient
.left
,
2063 ParentWindow
->rcClient
.top
);
2065 Window
->rcClient
= Window
->rcWindow
;
2068 /* Link the window*/
2069 if (NULL
!= ParentWindow
)
2071 /* link the window into the siblings list */
2072 if ((dwStyle
& (WS_CHILD
|WS_MAXIMIZE
)) == WS_CHILD
)
2073 IntLinkHwnd(Window
, HWND_BOTTOM
);
2075 IntLinkHwnd(Window
, HWND_TOP
);
2078 /* Send the NCCREATE message */
2079 Result
= co_IntSendMessage(UserHMGetHandle(Window
), WM_NCCREATE
, 0, (LPARAM
) Cs
);
2082 DPRINT1("co_UserCreateWindowEx(): NCCREATE message failed\n");
2086 /* Send the WM_NCCALCSIZE message */
2087 MaxPos
.x
= Window
->rcWindow
.left
;
2088 MaxPos
.y
= Window
->rcWindow
.top
;
2090 Result
= co_WinPosGetNonClientSize(Window
, &Window
->rcWindow
, &Window
->rcClient
);
2092 RECTL_vOffsetRect(&Window
->rcWindow
, MaxPos
.x
- Window
->rcWindow
.left
,
2093 MaxPos
.y
- Window
->rcWindow
.top
);
2096 /* Send the WM_CREATE message. */
2097 Result
= co_IntSendMessage(UserHMGetHandle(Window
), WM_CREATE
, 0, (LPARAM
) Cs
);
2098 if (Result
== (LRESULT
)-1)
2100 DPRINT1("co_UserCreateWindowEx(): WM_CREATE message failed\n");
2104 /* Send the EVENT_OBJECT_CREATE event*/
2105 IntNotifyWinEvent(EVENT_OBJECT_CREATE
, Window
, OBJID_WINDOW
, CHILDID_SELF
, 0);
2107 /* By setting the flag below it can be examined to determine if the window
2108 was created successfully and a valid pwnd was passed back to caller since
2109 from here the function has to succeed. */
2110 Window
->state2
|= WNDS2_WMCREATEMSGPROCESSED
;
2112 /* Send the WM_SIZE and WM_MOVE messages. */
2113 if (!(Window
->state
& WNDS_SENDSIZEMOVEMSGS
))
2115 co_WinPosSendSizeMove(Window
);
2118 /* Show or maybe minimize or maximize the window. */
2119 if (Window
->style
& (WS_MINIMIZE
| WS_MAXIMIZE
))
2124 SwFlag
= (Window
->style
& WS_MINIMIZE
) ? SW_MINIMIZE
: SW_MAXIMIZE
;
2126 co_WinPosMinMaximize(Window
, SwFlag
, &NewPos
);
2128 SwFlag
= ((Window
->style
& WS_CHILD
) || UserGetActiveWindow()) ?
2129 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
:
2130 SWP_NOZORDER
| SWP_FRAMECHANGED
;
2132 co_WinPosSetWindowPos(Window
, 0, NewPos
.left
, NewPos
.top
,
2133 NewPos
.right
, NewPos
.bottom
, SwFlag
);
2136 /* Send the WM_PARENTNOTIFY message */
2137 IntSendParentNotify(Window
, WM_CREATE
);
2139 /* Notify the shell that a new window was created */
2140 if ((!hWndParent
) && (!hWndOwner
))
2142 co_IntShellHookNotify(HSHELL_WINDOWCREATED
, (LPARAM
)hWnd
);
2145 /* Initialize and show the window's scrollbars */
2146 if (Window
->style
& WS_VSCROLL
)
2148 co_UserShowScrollBar(Window
, SB_VERT
, TRUE
);
2150 if (Window
->style
& WS_HSCROLL
)
2152 co_UserShowScrollBar(Window
, SB_HORZ
, TRUE
);
2155 /* Show the new window */
2156 if (Cs
->style
& WS_VISIBLE
)
2158 if (Window
->style
& WS_MAXIMIZE
)
2159 dwShowMode
= SW_SHOW
;
2160 else if (Window
->style
& WS_MINIMIZE
)
2161 dwShowMode
= SW_SHOWMINIMIZED
;
2163 co_WinPosShowWindow(Window
, dwShowMode
);
2165 if (Window
->ExStyle
& WS_EX_MDICHILD
)
2167 co_IntSendMessage(UserHMGetHandle(ParentWindow
), WM_MDIREFRESHMENU
, 0, 0);
2168 /* ShowWindow won't activate child windows */
2169 co_WinPosSetWindowPos(Window
, HWND_TOP
, 0, 0, 0, 0, SWP_SHOWWINDOW
| SWP_NOMOVE
| SWP_NOSIZE
);
2173 DPRINT("co_UserCreateWindowEx(): Created window %X\n", hWnd
);
2179 /* If the window was created, the class will be dereferenced by co_UserDestroyWindow */
2181 co_UserDestroyWindow(Window
);
2183 IntDereferenceClass(Class
, pti
->pDeskInfo
, pti
->ppi
);
2186 if (pCsw
) ExFreePoolWithTag(pCsw
, TAG_HOOK
);
2187 if (pCbtCreate
) ExFreePoolWithTag(pCbtCreate
, TAG_HOOK
);
2188 RtlFreeAnsiString(&asClassName
);
2192 UserDerefObjectCo(Window
);
2193 UserDereferenceObject(Window
);
2195 if (ParentWindow
) UserDerefObjectCo(ParentWindow
);
2202 ProbeAndCaptureLargeString(
2203 OUT PLARGE_STRING plstrSafe
,
2204 IN PLARGE_STRING plstrUnsafe
)
2206 LARGE_STRING lstrTemp
;
2207 PVOID pvBuffer
= NULL
;
2211 /* Probe and copy the string */
2212 ProbeForRead(plstrUnsafe
, sizeof(LARGE_STRING
), sizeof(ULONG
));
2213 lstrTemp
= *plstrUnsafe
;
2215 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2218 _SEH2_YIELD(return _SEH2_GetExceptionCode();)
2222 if (lstrTemp
.Length
!= 0)
2224 /* Allocate a buffer from paged pool */
2225 pvBuffer
= ExAllocatePoolWithTag(PagedPool
, lstrTemp
.Length
, TAG_STRING
);
2228 return STATUS_NO_MEMORY
;
2233 /* Probe and copy the buffer */
2234 ProbeForRead(lstrTemp
.Buffer
, lstrTemp
.Length
, sizeof(WCHAR
));
2235 RtlCopyMemory(pvBuffer
, lstrTemp
.Buffer
, lstrTemp
.Length
);
2237 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2239 /* Cleanup and fail */
2240 ExFreePool(pvBuffer
);
2241 _SEH2_YIELD(return _SEH2_GetExceptionCode();)
2246 /* Set the output string */
2247 plstrSafe
->Buffer
= pvBuffer
;
2248 plstrSafe
->Length
= lstrTemp
.Length
;
2249 plstrSafe
->MaximumLength
= lstrTemp
.Length
;
2251 return STATUS_SUCCESS
;
2255 * \todo Allow passing plstrClassName as ANSI.
2259 NtUserCreateWindowEx(
2261 PLARGE_STRING plstrClassName
,
2262 PLARGE_STRING plstrClsVersion
,
2263 PLARGE_STRING plstrWindowName
,
2271 HINSTANCE hInstance
,
2277 LARGE_STRING lstrWindowName
;
2278 LARGE_STRING lstrClassName
;
2279 UNICODE_STRING ustrClassName
;
2284 lstrWindowName
.Buffer
= NULL
;
2285 lstrClassName
.Buffer
= NULL
;
2287 /* Check if we got a Window name */
2288 if (plstrWindowName
)
2290 /* Copy the string to kernel mode */
2291 Status
= ProbeAndCaptureLargeString(&lstrWindowName
, plstrWindowName
);
2292 if (!NT_SUCCESS(Status
))
2294 DPRINT1("NtUserCreateWindowEx: failed to capture plstrWindowName\n");
2295 SetLastNtError(Status
);
2298 plstrWindowName
= &lstrWindowName
;
2301 /* Check if the class is an atom */
2302 if (IS_ATOM(plstrClassName
))
2304 /* It is, pass the atom in the UNICODE_STRING */
2305 ustrClassName
.Buffer
= (PVOID
)plstrClassName
;
2306 ustrClassName
.Length
= 0;
2307 ustrClassName
.MaximumLength
= 0;
2311 /* It's not, capture the class name */
2312 Status
= ProbeAndCaptureLargeString(&lstrClassName
, plstrClassName
);
2313 if (!NT_SUCCESS(Status
))
2315 DPRINT1("NtUserCreateWindowEx: failed to capture plstrClassName\n");
2316 /* Set last error, cleanup and return */
2317 SetLastNtError(Status
);
2321 /* We pass it on as a UNICODE_STRING */
2322 ustrClassName
.Buffer
= lstrClassName
.Buffer
;
2323 ustrClassName
.Length
= lstrClassName
.Length
;
2324 ustrClassName
.MaximumLength
= lstrClassName
.MaximumLength
;
2327 /* Fill the CREATESTRUCTW */
2328 /* we will keep here the original parameters */
2330 Cs
.lpCreateParams
= lpParam
;
2331 Cs
.hInstance
= hInstance
;
2333 Cs
.hwndParent
= hWndParent
;
2338 // Cs.lpszName = (LPCWSTR) WindowName->Buffer;
2339 // Cs.lpszClass = (LPCWSTR) ClassName->Buffer;
2340 Cs
.lpszName
= (LPCWSTR
) plstrWindowName
;
2341 Cs
.lpszClass
= (LPCWSTR
) &ustrClassName
;
2342 Cs
.dwExStyle
= dwExStyle
;
2344 UserEnterExclusive();
2346 /* Call the internal function */
2347 pwnd
= co_UserCreateWindowEx(&Cs
, &ustrClassName
, plstrWindowName
);
2351 DPRINT1("co_UserCreateWindowEx failed!\n");
2353 hwnd
= pwnd
? UserHMGetHandle(pwnd
) : NULL
;
2358 if (lstrWindowName
.Buffer
)
2360 ExFreePoolWithTag(lstrWindowName
.Buffer
, TAG_STRING
);
2362 if (lstrClassName
.Buffer
)
2364 ExFreePoolWithTag(lstrClassName
.Buffer
, TAG_STRING
);
2374 NtUserDeferWindowPos(HDWP WinPosInfo
,
2376 HWND WndInsertAfter
,
2389 BOOLEAN FASTCALL
co_UserDestroyWindow(PWND Window
)
2395 ASSERT_REFS_CO(Window
); // FIXME: temp hack?
2397 hWnd
= Window
->head
.h
;
2399 DPRINT("co_UserDestroyWindow \n");
2401 /* Check for owner thread */
2402 if ( (Window
->head
.pti
->pEThread
!= PsGetCurrentThread()) ||
2403 Window
->head
.pti
!= PsGetCurrentThreadWin32Thread() )
2405 SetLastWin32Error(ERROR_ACCESS_DENIED
);
2409 /* If window was created successfully and it is hooked */
2410 if ((Window
->state2
& WNDS2_WMCREATEMSGPROCESSED
))
2412 if (co_HOOK_CallHooks(WH_CBT
, HCBT_DESTROYWND
, (WPARAM
) hWnd
, 0))
2414 DPRINT1("Destroy Window WH_CBT Call Hook return!\n");
2419 /* Inform the parent */
2420 if (Window
->style
& WS_CHILD
)
2422 IntSendParentNotify(Window
, WM_DESTROY
);
2425 /* Look whether the focus is within the tree of windows we will
2428 if (!co_WinPosShowWindow(Window
, SW_HIDE
))
2430 if (UserGetActiveWindow() == Window
->head
.h
)
2432 co_WinPosActivateOtherWindow(Window
);
2436 if (Window
->head
.pti
->MessageQueue
->ActiveWindow
== Window
->head
.h
)
2437 Window
->head
.pti
->MessageQueue
->ActiveWindow
= NULL
;
2438 if (Window
->head
.pti
->MessageQueue
->FocusWindow
== Window
->head
.h
)
2439 Window
->head
.pti
->MessageQueue
->FocusWindow
= NULL
;
2440 if (Window
->head
.pti
->MessageQueue
->CaptureWindow
== Window
->head
.h
)
2441 Window
->head
.pti
->MessageQueue
->CaptureWindow
= NULL
;
2444 * Check if this window is the Shell's Desktop Window. If so set hShellWindow to NULL
2447 ti
= PsGetCurrentThreadWin32Thread();
2449 if ((ti
!= NULL
) & (ti
->pDeskInfo
!= NULL
))
2451 if (ti
->pDeskInfo
->hShellWindow
== hWnd
)
2453 DPRINT1("Destroying the ShellWindow!\n");
2454 ti
->pDeskInfo
->hShellWindow
= NULL
;
2458 IntDereferenceMessageQueue(Window
->head
.pti
->MessageQueue
);
2460 IntEngWindowChanged(Window
, WOC_DELETE
);
2462 if (!IntIsWindow(Window
->head
.h
))
2467 /* Recursively destroy owned windows */
2469 if (! (Window
->style
& WS_CHILD
))
2473 BOOL GotOne
= FALSE
;
2476 PWND Child
, Desktop
;
2478 Desktop
= IntIsDesktopWindow(Window
) ? Window
:
2479 UserGetWindowObject(IntGetDesktopWindow());
2480 Children
= IntWinListChildren(Desktop
);
2484 for (ChildHandle
= Children
; *ChildHandle
; ++ChildHandle
)
2486 Child
= UserGetWindowObject(*ChildHandle
);
2489 if (Child
->spwndOwner
!= Window
)
2494 if (IntWndBelongsToThread(Child
, PsGetCurrentThreadWin32Thread()))
2496 USER_REFERENCE_ENTRY ChildRef
;
2497 UserRefObjectCo(Child
, &ChildRef
);//temp hack?
2498 co_UserDestroyWindow(Child
);
2499 UserDerefObjectCo(Child
);//temp hack?
2505 if (Child
->spwndOwner
!= NULL
)
2507 Child
->spwndOwner
= NULL
;
2511 ExFreePool(Children
);
2520 /* Generate mouse move message for the next window */
2521 msg
.message
= WM_MOUSEMOVE
;
2522 msg
.wParam
= IntGetSysCursorInfo()->ButtonsDown
;
2523 msg
.lParam
= MAKELPARAM(gpsi
->ptCursor
.x
, gpsi
->ptCursor
.y
);
2524 msg
.pt
= gpsi
->ptCursor
;
2525 MsqInsertSystemMessage(&msg
);
2527 if (!IntIsWindow(Window
->head
.h
))
2532 /* Destroy the window storage */
2533 co_UserFreeWindow(Window
, PsGetCurrentProcessWin32Process(), PsGetCurrentThreadWin32Thread(), TRUE
);
2543 NtUserDestroyWindow(HWND Wnd
)
2546 DECLARE_RETURN(BOOLEAN
);
2548 USER_REFERENCE_ENTRY Ref
;
2550 DPRINT("Enter NtUserDestroyWindow\n");
2551 UserEnterExclusive();
2553 if (!(Window
= UserGetWindowObject(Wnd
)))
2558 UserRefObjectCo(Window
, &Ref
);//faxme: dunno if win should be reffed during destroy..
2559 ret
= co_UserDestroyWindow(Window
);
2560 UserDerefObjectCo(Window
);//faxme: dunno if win should be reffed during destroy..
2565 DPRINT("Leave NtUserDestroyWindow, ret=%i\n",_ret_
);
2577 NtUserDrawMenuBarTemp(
2584 /* we'll use this function just for caching the menu bar */
2594 NtUserEndDeferWindowPosEx(DWORD Unknown0
,
2604 * FillWindow: Called from User; Dialog, Edit and ListBox procs during a WM_ERASEBKGND.
2610 NtUserFillWindow(HWND hWndPaint
,
2621 static HWND FASTCALL
2622 IntFindWindow(PWND Parent
,
2625 PUNICODE_STRING WindowName
)
2627 BOOL CheckWindowName
;
2630 UNICODE_STRING CurrentWindowName
;
2634 CheckWindowName
= WindowName
->Length
!= 0;
2636 if((List
= IntWinListChildren(Parent
)))
2641 /* skip handles before and including ChildAfter */
2642 while(*phWnd
&& (*(phWnd
++) != ChildAfter
->head
.h
))
2646 /* search children */
2650 if(!(Child
= UserGetWindowObject(*(phWnd
++))))
2655 /* Do not send WM_GETTEXT messages in the kernel mode version!
2656 The user mode version however calls GetWindowText() which will
2657 send WM_GETTEXT messages to windows belonging to its processes */
2658 if (!ClassAtom
|| Child
->pcls
->atomClassName
== ClassAtom
)
2660 // HACK: use UNICODE_STRING instead of LARGE_STRING
2661 CurrentWindowName
.Buffer
= Child
->strName
.Buffer
;
2662 CurrentWindowName
.Length
= Child
->strName
.Length
;
2663 CurrentWindowName
.MaximumLength
= Child
->strName
.MaximumLength
;
2664 if(!CheckWindowName
||
2665 (Child
->strName
.Length
< 0xFFFF &&
2666 !RtlCompareUnicodeString(WindowName
, &CurrentWindowName
, TRUE
)))
2668 Ret
= Child
->head
.h
;
2681 * Searches a window's children for a window with the specified
2684 * hwndParent = The window whose childs are to be searched.
2686 * HWND_MESSAGE = message-only windows
2688 * hwndChildAfter = Search starts after this child window.
2689 * NULL = start from beginning
2691 * ucClassName = Class name to search for
2692 * Reguired parameter.
2694 * ucWindowName = Window name
2695 * ->Buffer == NULL = don't care
2698 * The HWND of the window if it was found, otherwise NULL
2704 NtUserFindWindowEx(HWND hwndParent
,
2705 HWND hwndChildAfter
,
2706 PUNICODE_STRING ucClassName
,
2707 PUNICODE_STRING ucWindowName
,
2710 PWND Parent
, ChildAfter
;
2711 UNICODE_STRING ClassName
= {0}, WindowName
= {0};
2712 HWND Desktop
, Ret
= NULL
;
2713 RTL_ATOM ClassAtom
= (RTL_ATOM
)0;
2714 DECLARE_RETURN(HWND
);
2716 DPRINT("Enter NtUserFindWindowEx\n");
2719 if (ucClassName
!= NULL
|| ucWindowName
!= NULL
)
2723 if (ucClassName
!= NULL
)
2725 ClassName
= ProbeForReadUnicodeString(ucClassName
);
2726 if (ClassName
.Length
!= 0)
2728 ProbeForRead(ClassName
.Buffer
,
2732 else if (!IS_ATOM(ClassName
.Buffer
))
2734 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
2738 if (!IntGetAtomFromStringOrAtom(&ClassName
,
2745 if (ucWindowName
!= NULL
)
2747 WindowName
= ProbeForReadUnicodeString(ucWindowName
);
2748 if (WindowName
.Length
!= 0)
2750 ProbeForRead(WindowName
.Buffer
,
2756 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2758 SetLastNtError(_SEH2_GetExceptionCode());
2759 _SEH2_YIELD(RETURN(NULL
));
2763 if (ucClassName
!= NULL
)
2765 if (ClassName
.Length
== 0 && ClassName
.Buffer
!= NULL
&&
2766 !IS_ATOM(ClassName
.Buffer
))
2768 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
2771 else if (ClassAtom
== (RTL_ATOM
)0)
2773 /* LastError code was set by IntGetAtomFromStringOrAtom */
2779 Desktop
= IntGetCurrentThreadDesktopWindow();
2781 if(hwndParent
== NULL
)
2782 hwndParent
= Desktop
;
2783 else if(hwndParent
== HWND_MESSAGE
)
2785 hwndParent
= IntGetMessageWindow();
2788 if(!(Parent
= UserGetWindowObject(hwndParent
)))
2794 if(hwndChildAfter
&& !(ChildAfter
= UserGetWindowObject(hwndChildAfter
)))
2801 if(Parent
->head
.h
== Desktop
)
2804 PWND TopLevelWindow
;
2805 BOOLEAN CheckWindowName
;
2806 BOOLEAN WindowMatches
;
2807 BOOLEAN ClassMatches
;
2809 /* windows searches through all top-level windows if the parent is the desktop
2812 if((List
= IntWinListChildren(Parent
)))
2818 /* skip handles before and including ChildAfter */
2819 while(*phWnd
&& (*(phWnd
++) != ChildAfter
->head
.h
))
2823 CheckWindowName
= WindowName
.Length
!= 0;
2825 /* search children */
2828 UNICODE_STRING ustr
;
2830 if(!(TopLevelWindow
= UserGetWindowObject(*(phWnd
++))))
2835 /* Do not send WM_GETTEXT messages in the kernel mode version!
2836 The user mode version however calls GetWindowText() which will
2837 send WM_GETTEXT messages to windows belonging to its processes */
2838 ustr
.Buffer
= TopLevelWindow
->strName
.Buffer
;
2839 ustr
.Length
= TopLevelWindow
->strName
.Length
;
2840 ustr
.MaximumLength
= TopLevelWindow
->strName
.MaximumLength
;
2841 WindowMatches
= !CheckWindowName
||
2842 (TopLevelWindow
->strName
.Length
< 0xFFFF &&
2843 !RtlCompareUnicodeString(&WindowName
, &ustr
, TRUE
));
2844 ClassMatches
= (ClassAtom
== (RTL_ATOM
)0) ||
2845 ClassAtom
== TopLevelWindow
->pcls
->atomClassName
;
2847 if (WindowMatches
&& ClassMatches
)
2849 Ret
= TopLevelWindow
->head
.h
;
2853 if (IntFindWindow(TopLevelWindow
, NULL
, ClassAtom
, &WindowName
))
2855 /* window returns the handle of the top-level window, in case it found
2857 Ret
= TopLevelWindow
->head
.h
;
2866 Ret
= IntFindWindow(Parent
, ChildAfter
, ClassAtom
, &WindowName
);
2870 if(Ret
== NULL
&& hwndParent
== NULL
&& hwndChildAfter
== NULL
)
2872 /* FIXME - if both hwndParent and hwndChildAfter are NULL, we also should
2873 search the message-only windows. Should this also be done if
2874 Parent is the desktop window??? */
2877 if((MsgWindows
= UserGetWindowObject(IntGetMessageWindow())))
2879 Ret
= IntFindWindow(MsgWindows
, ChildAfter
, ClassAtom
, &WindowName
);
2884 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2886 SetLastNtError(_SEH2_GetExceptionCode());
2894 DPRINT("Leave NtUserFindWindowEx, ret %i\n",_ret_
);
2904 NtUserFlashWindowEx(IN PFLASHWINFO pfwi
)
2915 PWND FASTCALL
UserGetAncestor(PWND Wnd
, UINT Type
)
2917 PWND WndAncestor
, Parent
;
2919 if (Wnd
->head
.h
== IntGetDesktopWindow())
2928 WndAncestor
= Wnd
->spwndParent
;
2939 if(!(Parent
= WndAncestor
->spwndParent
))
2943 if(IntIsDesktopWindow(Parent
))
2948 WndAncestor
= Parent
;
2961 Parent
= IntGetParent(WndAncestor
);
2968 WndAncestor
= Parent
;
2986 NtUserGetAncestor(HWND hWnd
, UINT Type
)
2988 PWND Window
, Ancestor
;
2989 DECLARE_RETURN(HWND
);
2991 DPRINT("Enter NtUserGetAncestor\n");
2992 UserEnterExclusive();
2994 if (!(Window
= UserGetWindowObject(hWnd
)))
2999 Ancestor
= UserGetAncestor(Window
, Type
);
3000 /* faxme: can UserGetAncestor ever return NULL for a valid window? */
3002 RETURN(Ancestor
? Ancestor
->head
.h
: NULL
);
3005 DPRINT("Leave NtUserGetAncestor, ret=%i\n",_ret_
);
3013 NtUserGetComboBoxInfo(
3018 DECLARE_RETURN(BOOL
);
3020 DPRINT("Enter NtUserGetComboBoxInfo\n");
3023 if (!(Wnd
= UserGetWindowObject(hWnd
)))
3032 sizeof(COMBOBOXINFO
),
3036 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
3038 SetLastNtError(_SEH2_GetExceptionCode());
3039 _SEH2_YIELD(RETURN(FALSE
));
3043 // Pass the user pointer, it was already probed.
3044 RETURN( (BOOL
) co_IntSendMessage( Wnd
->head
.h
, CB_GETCOMBOBOXINFO
, 0, (LPARAM
)pcbi
));
3047 DPRINT("Leave NtUserGetComboBoxInfo, ret=%i\n",_ret_
);
3057 NtUserGetInternalWindowPos( HWND hWnd
,
3064 WINDOWPLACEMENT wndpl
;
3068 if (!(Window
= UserGetWindowObject(hWnd
)))
3078 ProbeForWrite(rectWnd
,
3084 ProbeForWrite(ptIcon
,
3090 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
3092 SetLastNtError(_SEH2_GetExceptionCode());
3097 wndpl
.length
= sizeof(WINDOWPLACEMENT
);
3099 if (IntGetWindowPlacement(Window
, &wndpl
) && !Hit
)
3105 RtlCopyMemory(rectWnd
, &wndpl
.rcNormalPosition
, sizeof(RECT
));
3109 RtlCopyMemory(ptIcon
, &wndpl
.ptMinPosition
, sizeof(POINT
));
3113 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
3115 SetLastNtError(_SEH2_GetExceptionCode());
3120 if (!Hit
) Ret
= wndpl
.showCmd
;
3129 NtUserGetListBoxInfo(
3133 DECLARE_RETURN(DWORD
);
3135 DPRINT("Enter NtUserGetListBoxInfo\n");
3138 if (!(Wnd
= UserGetWindowObject(hWnd
)))
3143 RETURN( (DWORD
) co_IntSendMessage( Wnd
->head
.h
, LB_GETLISTBOXINFO
, 0, 0 ));
3146 DPRINT("Leave NtUserGetListBoxInfo, ret=%i\n",_ret_
);
3153 co_UserSetParent(HWND hWndChild
, HWND hWndNewParent
)
3155 PWND Wnd
= NULL
, WndParent
= NULL
, WndOldParent
;
3156 HWND hWndOldParent
= NULL
;
3157 USER_REFERENCE_ENTRY Ref
, ParentRef
;
3159 if (IntIsBroadcastHwnd(hWndChild
) || IntIsBroadcastHwnd(hWndNewParent
))
3161 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
3165 if (hWndChild
== IntGetDesktopWindow())
3167 SetLastWin32Error(ERROR_ACCESS_DENIED
);
3173 if (!(WndParent
= UserGetWindowObject(hWndNewParent
)))
3180 if (!(WndParent
= UserGetWindowObject(IntGetDesktopWindow())))
3186 if (!(Wnd
= UserGetWindowObject(hWndChild
)))
3191 UserRefObjectCo(Wnd
, &Ref
);
3192 UserRefObjectCo(WndParent
, &ParentRef
);
3194 WndOldParent
= co_IntSetParent(Wnd
, WndParent
);
3196 UserDerefObjectCo(WndParent
);
3197 UserDerefObjectCo(Wnd
);
3201 hWndOldParent
= WndOldParent
->head
.h
;
3202 UserDereferenceObject(WndOldParent
);
3205 return( hWndOldParent
);
3211 * The NtUserSetParent function changes the parent window of the specified
3215 * The new parent window and the child window must belong to the same
3216 * application. If the window identified by the hWndChild parameter is
3217 * visible, the system performs the appropriate redrawing and repainting.
3218 * For compatibility reasons, NtUserSetParent does not modify the WS_CHILD
3219 * or WS_POPUP window styles of the window whose parent is being changed.
3226 NtUserSetParent(HWND hWndChild
, HWND hWndNewParent
)
3228 DECLARE_RETURN(HWND
);
3230 DPRINT("Enter NtUserSetParent\n");
3231 UserEnterExclusive();
3234 Check Parent first from user space, set it here.
3238 hWndNewParent
= IntGetDesktopWindow();
3240 else if (hWndNewParent
== HWND_MESSAGE
)
3242 hWndNewParent
= IntGetMessageWindow();
3245 RETURN( co_UserSetParent(hWndChild
, hWndNewParent
));
3248 DPRINT("Leave NtUserSetParent, ret=%i\n",_ret_
);
3254 * UserGetShellWindow
3256 * Returns a handle to shell window that was set by NtUserSetShellWindowEx.
3261 HWND FASTCALL
UserGetShellWindow(VOID
)
3263 PWINSTATION_OBJECT WinStaObject
;
3266 NTSTATUS Status
= IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation
,
3271 if (!NT_SUCCESS(Status
))
3273 SetLastNtError(Status
);
3277 Ret
= (HWND
)WinStaObject
->ShellWindow
;
3279 ObDereferenceObject(WinStaObject
);
3284 * NtUserSetShellWindowEx
3286 * This is undocumented function to set global shell window. The global
3287 * shell window has special handling of window position.
3293 NtUserSetShellWindowEx(HWND hwndShell
, HWND hwndListView
)
3295 PWINSTATION_OBJECT WinStaObject
;
3296 PWND WndShell
, WndListView
;
3297 DECLARE_RETURN(BOOL
);
3298 USER_REFERENCE_ENTRY Ref
;
3302 DPRINT("Enter NtUserSetShellWindowEx\n");
3303 UserEnterExclusive();
3305 if (!(WndShell
= UserGetWindowObject(hwndShell
)))
3310 if(!(WndListView
= UserGetWindowObject(hwndListView
)))
3315 Status
= IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation
,
3320 if (!NT_SUCCESS(Status
))
3322 SetLastNtError(Status
);
3327 * Test if we are permitted to change the shell window.
3329 if (WinStaObject
->ShellWindow
)
3331 ObDereferenceObject(WinStaObject
);
3336 * Move shell window into background.
3338 if (hwndListView
&& hwndListView
!= hwndShell
)
3341 * Disabled for now to get Explorer working.
3342 * -- Filip, 01/nov/2003
3345 co_WinPosSetWindowPos(hwndListView
, HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
);
3348 if (WndListView
->ExStyle
& WS_EX_TOPMOST
)
3350 ObDereferenceObject(WinStaObject
);
3355 if (WndShell
->ExStyle
& WS_EX_TOPMOST
)
3357 ObDereferenceObject(WinStaObject
);
3361 UserRefObjectCo(WndShell
, &Ref
);
3362 co_WinPosSetWindowPos(WndShell
, HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
);
3364 WinStaObject
->ShellWindow
= hwndShell
;
3365 WinStaObject
->ShellListView
= hwndListView
;
3367 ti
= GetW32ThreadInfo();
3368 if (ti
->pDeskInfo
) ti
->pDeskInfo
->hShellWindow
= hwndShell
;
3370 UserDerefObjectCo(WndShell
);
3372 ObDereferenceObject(WinStaObject
);
3376 DPRINT("Leave NtUserSetShellWindowEx, ret=%i\n",_ret_
);
3382 * NtUserGetSystemMenu
3384 * The NtUserGetSystemMenu function allows the application to access the
3385 * window menu (also known as the system menu or the control menu) for
3386 * copying and modifying.
3390 * Handle to the window that will own a copy of the window menu.
3392 * Specifies the action to be taken. If this parameter is FALSE,
3393 * NtUserGetSystemMenu returns a handle to the copy of the window menu
3394 * currently in use. The copy is initially identical to the window menu
3395 * but it can be modified.
3396 * If this parameter is TRUE, GetSystemMenu resets the window menu back
3397 * to the default state. The previous window menu, if any, is destroyed.
3400 * If the bRevert parameter is FALSE, the return value is a handle to a
3401 * copy of the window menu. If the bRevert parameter is TRUE, the return
3409 NtUserGetSystemMenu(HWND hWnd
, BOOL bRevert
)
3413 DECLARE_RETURN(HMENU
);
3415 DPRINT("Enter NtUserGetSystemMenu\n");
3418 if (!(Window
= UserGetWindowObject(hWnd
)))
3423 if (!(Menu
= IntGetSystemMenu(Window
, bRevert
, FALSE
)))
3428 RETURN(Menu
->MenuInfo
.Self
);
3431 DPRINT("Leave NtUserGetSystemMenu, ret=%i\n",_ret_
);
3437 * NtUserSetSystemMenu
3444 NtUserSetSystemMenu(HWND hWnd
, HMENU hMenu
)
3446 BOOL Result
= FALSE
;
3449 DECLARE_RETURN(BOOL
);
3451 DPRINT("Enter NtUserSetSystemMenu\n");
3452 UserEnterExclusive();
3454 if (!(Window
= UserGetWindowObject(hWnd
)))
3462 * Assign new menu handle.
3464 if (!(Menu
= UserGetMenuObject(hMenu
)))
3469 Result
= IntSetSystemMenu(Window
, Menu
);
3475 DPRINT("Leave NtUserSetSystemMenu, ret=%i\n",_ret_
);
3481 co_UserSetWindowLong(HWND hWnd
, DWORD Index
, LONG NewValue
, BOOL Ansi
)
3483 PWND Window
, Parent
;
3484 PWINSTATION_OBJECT WindowStation
;
3488 if (hWnd
== IntGetDesktopWindow())
3490 SetLastWin32Error(STATUS_ACCESS_DENIED
);
3494 if (!(Window
= UserGetWindowObject(hWnd
)))
3499 if ((INT
)Index
>= 0)
3501 if ((Index
+ sizeof(LONG
)) > Window
->cbwndExtra
)
3503 SetLastWin32Error(ERROR_INVALID_INDEX
);
3507 OldValue
= *((LONG
*)((PCHAR
)(Window
+ 1) + Index
));
3509 if ( Index == DWLP_DLGPROC && Wnd->state & WNDS_DIALOGWINDOW)
3511 OldValue = (LONG)IntSetWindowProc( Wnd,
3514 if (!OldValue) return 0;
3517 *((LONG
*)((PCHAR
)(Window
+ 1) + Index
)) = NewValue
;
3524 OldValue
= (LONG
) Window
->ExStyle
;
3525 Style
.styleOld
= OldValue
;
3526 Style
.styleNew
= NewValue
;
3529 * Remove extended window style bit WS_EX_TOPMOST for shell windows.
3531 WindowStation
= Window
->head
.pti
->rpdesk
->rpwinstaParent
;
3534 if (hWnd
== WindowStation
->ShellWindow
|| hWnd
== WindowStation
->ShellListView
)
3535 Style
.styleNew
&= ~WS_EX_TOPMOST
;
3538 co_IntSendMessage(hWnd
, WM_STYLECHANGING
, GWL_EXSTYLE
, (LPARAM
) &Style
);
3539 Window
->ExStyle
= (DWORD
)Style
.styleNew
;
3540 co_IntSendMessage(hWnd
, WM_STYLECHANGED
, GWL_EXSTYLE
, (LPARAM
) &Style
);
3544 OldValue
= (LONG
) Window
->style
;
3545 Style
.styleOld
= OldValue
;
3546 Style
.styleNew
= NewValue
;
3547 co_IntSendMessage(hWnd
, WM_STYLECHANGING
, GWL_STYLE
, (LPARAM
) &Style
);
3548 Window
->style
= (DWORD
)Style
.styleNew
;
3549 co_IntSendMessage(hWnd
, WM_STYLECHANGED
, GWL_STYLE
, (LPARAM
) &Style
);
3554 if ( Window
->head
.pti
->ppi
!= PsGetCurrentProcessWin32Process() ||
3555 Window
->fnid
& FNID_FREED
)
3557 SetLastWin32Error(ERROR_ACCESS_DENIED
);
3560 OldValue
= (LONG
)IntSetWindowProc(Window
,
3567 OldValue
= (LONG
) Window
->hModule
;
3568 Window
->hModule
= (HINSTANCE
) NewValue
;
3571 case GWL_HWNDPARENT
:
3572 Parent
= Window
->spwndParent
;
3573 if (Parent
&& (Parent
->head
.h
== IntGetDesktopWindow()))
3574 OldValue
= (LONG
) IntSetOwner(Window
->head
.h
, (HWND
) NewValue
);
3576 OldValue
= (LONG
) co_UserSetParent(Window
->head
.h
, (HWND
) NewValue
);
3580 OldValue
= (LONG
) Window
->IDMenu
;
3581 Window
->IDMenu
= (UINT
) NewValue
;
3585 OldValue
= Window
->dwUserData
;
3586 Window
->dwUserData
= NewValue
;
3590 DPRINT1("NtUserSetWindowLong(): Unsupported index %d\n", Index
);
3591 SetLastWin32Error(ERROR_INVALID_INDEX
);
3601 * NtUserSetWindowLong
3603 * The NtUserSetWindowLong function changes an attribute of the specified
3604 * window. The function also sets the 32-bit (long) value at the specified
3605 * offset into the extra window memory.
3612 NtUserSetWindowLong(HWND hWnd
, DWORD Index
, LONG NewValue
, BOOL Ansi
)
3614 DECLARE_RETURN(LONG
);
3616 DPRINT("Enter NtUserSetWindowLong\n");
3617 UserEnterExclusive();
3619 RETURN( co_UserSetWindowLong(hWnd
, Index
, NewValue
, Ansi
));
3622 DPRINT("Leave NtUserSetWindowLong, ret=%i\n",_ret_
);
3628 * NtUserSetWindowWord
3630 * Legacy function similar to NtUserSetWindowLong.
3637 NtUserSetWindowWord(HWND hWnd
, INT Index
, WORD NewValue
)
3641 DECLARE_RETURN(WORD
);
3643 DPRINT("Enter NtUserSetWindowWord\n");
3644 UserEnterExclusive();
3646 if (!(Window
= UserGetWindowObject(hWnd
)))
3655 case GWL_HWNDPARENT
:
3656 RETURN( co_UserSetWindowLong(Window
->head
.h
, Index
, (UINT
)NewValue
, TRUE
));
3660 SetLastWin32Error(ERROR_INVALID_INDEX
);
3665 if (Index
> Window
->cbwndExtra
- sizeof(WORD
))
3667 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
3671 OldValue
= *((WORD
*)((PCHAR
)(Window
+ 1) + Index
));
3672 *((WORD
*)((PCHAR
)(Window
+ 1) + Index
)) = NewValue
;
3677 DPRINT("Leave NtUserSetWindowWord, ret=%i\n",_ret_
);
3686 NtUserGetWindowPlacement(HWND hWnd
,
3687 WINDOWPLACEMENT
*lpwndpl
)
3691 WINDOWPLACEMENT Safepl
;
3693 DECLARE_RETURN(BOOL
);
3695 DPRINT("Enter NtUserGetWindowPlacement\n");
3698 if (!(Wnd
= UserGetWindowObject(hWnd
)))
3703 Status
= MmCopyFromCaller(&Safepl
, lpwndpl
, sizeof(WINDOWPLACEMENT
));
3704 if(!NT_SUCCESS(Status
))
3706 SetLastNtError(Status
);
3709 if(Safepl
.length
!= sizeof(WINDOWPLACEMENT
))
3715 if (0 == (Wnd
->style
& WS_VISIBLE
))
3717 Safepl
.showCmd
= SW_HIDE
;
3719 else if ((0 != (Wnd
->state2
& WNDS2_MAXIMIZEBUTTONDOWN
) ||
3720 0 != (Wnd
->style
& WS_MAXIMIZE
)) &&
3721 0 == (Wnd
->style
& WS_MINIMIZE
))
3723 Safepl
.showCmd
= SW_SHOWMAXIMIZED
;
3725 else if (0 != (Wnd
->style
& WS_MINIMIZE
))
3727 Safepl
.showCmd
= SW_SHOWMINIMIZED
;
3729 else if (0 != (Wnd
->style
& WS_VISIBLE
))
3731 Safepl
.showCmd
= SW_SHOWNORMAL
;
3734 Size
.x
= Wnd
->rcWindow
.left
;
3735 Size
.y
= Wnd
->rcWindow
.top
;
3736 WinPosInitInternalPos(Wnd
, &Size
,
3739 Safepl
.rcNormalPosition
= Wnd
->InternalPos
.NormalRect
;
3740 Safepl
.ptMinPosition
= Wnd
->InternalPos
.IconPos
;
3741 Safepl
.ptMaxPosition
= Wnd
->InternalPos
.MaxPos
;
3743 Status
= MmCopyToCaller(lpwndpl
, &Safepl
, sizeof(WINDOWPLACEMENT
));
3744 if(!NT_SUCCESS(Status
))
3746 SetLastNtError(Status
);
3753 DPRINT("Leave NtUserGetWindowPlacement, ret=%i\n",_ret_
);
3763 NtUserLockWindowUpdate(HWND hWnd
)
3783 return NtUserSetWindowPos(hWnd
, 0, X
, Y
, nWidth
, nHeight
,
3784 (bRepaint
? SWP_NOZORDER
| SWP_NOACTIVATE
:
3785 SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOREDRAW
));
3789 QueryWindow based on KJK::Hyperion and James Tabor.
3791 0 = QWUniqueProcessId
3792 1 = QWUniqueThreadId
3795 4 = QWIsHung Implements IsHungAppWindow found
3798 9 = QWKillWindow When I called this with hWnd ==
3799 DesktopWindow, it shutdown the system
3806 NtUserQueryWindow(HWND hWnd
, DWORD Index
)
3810 DECLARE_RETURN(UINT
);
3812 DPRINT("Enter NtUserQueryWindow\n");
3815 if (!(pWnd
= UserGetWindowObject(hWnd
)))
3822 case QUERY_WINDOW_UNIQUE_PROCESS_ID
:
3823 Result
= (DWORD
)IntGetWndProcessId(pWnd
);
3826 case QUERY_WINDOW_UNIQUE_THREAD_ID
:
3827 Result
= (DWORD
)IntGetWndThreadId(pWnd
);
3830 case QUERY_WINDOW_ACTIVE
:
3831 Result
= (DWORD
)UserGetActiveWindow();
3834 case QUERY_WINDOW_FOCUS
:
3835 Result
= (DWORD
)IntGetFocusWindow();
3838 case QUERY_WINDOW_ISHUNG
:
3839 Result
= (DWORD
)MsqIsHung(pWnd
->head
.pti
->MessageQueue
);
3842 case QUERY_WINDOW_REAL_ID
:
3843 Result
= (DWORD
)pWnd
->head
.pti
->pEThread
->Cid
.UniqueProcess
;
3846 Result
= (DWORD
)NULL
;
3853 DPRINT("Leave NtUserQueryWindow, ret=%i\n",_ret_
);
3863 NtUserRealChildWindowFromPoint(DWORD Unknown0
,
3877 NtUserRegisterWindowMessage(PUNICODE_STRING MessageNameUnsafe
)
3879 UNICODE_STRING SafeMessageName
;
3882 DECLARE_RETURN(UINT
);
3884 DPRINT("Enter NtUserRegisterWindowMessage\n");
3885 UserEnterExclusive();
3887 if(MessageNameUnsafe
== NULL
)
3889 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
3893 Status
= IntSafeCopyUnicodeStringTerminateNULL(&SafeMessageName
, MessageNameUnsafe
);
3894 if(!NT_SUCCESS(Status
))
3896 SetLastNtError(Status
);
3900 Ret
= (UINT
)IntAddAtom(SafeMessageName
.Buffer
);
3901 if (SafeMessageName
.Buffer
)
3902 ExFreePoolWithTag(SafeMessageName
.Buffer
, TAG_STRING
);
3906 DPRINT("Leave NtUserRegisterWindowMessage, ret=%i\n",_ret_
);
3916 NtUserSetImeOwnerWindow(DWORD Unknown0
,
3929 NtUserSetInternalWindowPos(
3946 NtUserSetLayeredWindowAttributes(HWND hwnd
,
3960 NtUserSetLogonNotifyWindow(HWND hWnd
)
3979 DECLARE_RETURN(BOOL
);
3981 DPRINT("Enter NtUserSetMenu\n");
3982 UserEnterExclusive();
3984 if (!(Window
= UserGetWindowObject(hWnd
)))
3989 if (! IntSetMenu(Window
, Menu
, &Changed
))
3994 if (Changed
&& Repaint
)
3996 USER_REFERENCE_ENTRY Ref
;
3998 UserRefObjectCo(Window
, &Ref
);
3999 co_WinPosSetWindowPos(Window
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
4000 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
4002 UserDerefObjectCo(Window
);
4008 DPRINT("Leave NtUserSetMenu, ret=%i\n",_ret_
);
4018 NtUserSetWindowFNID(HWND hWnd
,
4022 DECLARE_RETURN(BOOL
);
4024 DPRINT("Enter NtUserSetWindowFNID\n");
4025 UserEnterExclusive();
4027 if (!(Wnd
= UserGetWindowObject(hWnd
)))
4033 { // From user land we only set these.
4034 if ((fnID
!= FNID_DESTROY
) || ((fnID
< FNID_BUTTON
) && (fnID
> FNID_IME
)) )
4039 Wnd
->pcls
->fnid
|= fnID
;
4044 DPRINT("Leave NtUserSetWindowFNID\n");
4054 NtUserSetWindowPlacement(HWND hWnd
,
4055 WINDOWPLACEMENT
*lpwndpl
)
4058 WINDOWPLACEMENT Safepl
;
4060 DECLARE_RETURN(BOOL
);
4061 USER_REFERENCE_ENTRY Ref
;
4063 DPRINT("Enter NtUserSetWindowPlacement\n");
4064 UserEnterExclusive();
4066 if (!(Wnd
= UserGetWindowObject(hWnd
)))
4071 Status
= MmCopyFromCaller(&Safepl
, lpwndpl
, sizeof(WINDOWPLACEMENT
));
4072 if(!NT_SUCCESS(Status
))
4074 SetLastNtError(Status
);
4077 if(Safepl
.length
!= sizeof(WINDOWPLACEMENT
))
4082 UserRefObjectCo(Wnd
, &Ref
);
4084 if ((Wnd
->style
& (WS_MAXIMIZE
| WS_MINIMIZE
)) == 0)
4086 co_WinPosSetWindowPos(Wnd
, NULL
,
4087 Safepl
.rcNormalPosition
.left
, Safepl
.rcNormalPosition
.top
,
4088 Safepl
.rcNormalPosition
.right
- Safepl
.rcNormalPosition
.left
,
4089 Safepl
.rcNormalPosition
.bottom
- Safepl
.rcNormalPosition
.top
,
4090 SWP_NOZORDER
| SWP_NOACTIVATE
);
4093 /* FIXME - change window status */
4094 co_WinPosShowWindow(Wnd
, Safepl
.showCmd
);
4096 Wnd
->InternalPosInitialized
= TRUE
;
4097 Wnd
->InternalPos
.NormalRect
= Safepl
.rcNormalPosition
;
4098 Wnd
->InternalPos
.IconPos
= Safepl
.ptMinPosition
;
4099 Wnd
->InternalPos
.MaxPos
= Safepl
.ptMaxPosition
;
4101 UserDerefObjectCo(Wnd
);
4105 DPRINT("Leave NtUserSetWindowPlacement, ret=%i\n",_ret_
);
4117 HWND hWndInsertAfter
,
4124 DECLARE_RETURN(BOOL
);
4127 USER_REFERENCE_ENTRY Ref
;
4129 DPRINT("Enter NtUserSetWindowPos\n");
4130 UserEnterExclusive();
4132 if (!(Window
= UserGetWindowObject(hWnd
)))
4137 /* First make sure that coordinates are valid for WM_WINDOWPOSCHANGING */
4138 if (!(uFlags
& SWP_NOMOVE
))
4140 if (X
< -32768) X
= -32768;
4141 else if (X
> 32767) X
= 32767;
4142 if (Y
< -32768) Y
= -32768;
4143 else if (Y
> 32767) Y
= 32767;
4145 if (!(uFlags
& SWP_NOSIZE
))
4148 else if (cx
> 32767) cx
= 32767;
4150 else if (cy
> 32767) cy
= 32767;
4153 UserRefObjectCo(Window
, &Ref
);
4154 ret
= co_WinPosSetWindowPos(Window
, hWndInsertAfter
, X
, Y
, cx
, cy
, uFlags
);
4155 UserDerefObjectCo(Window
);
4160 DPRINT("Leave NtUserSetWindowPos, ret=%i\n",_ret_
);
4167 IntGetWindowRgn(PWND Window
, HRGN hRgn
)
4182 /* Create a new window region using the window rectangle */
4183 VisRgn
= IntSysCreateRectRgnIndirect(&Window
->rcWindow
);
4184 NtGdiOffsetRgn(VisRgn
, -Window
->rcWindow
.left
, -Window
->rcWindow
.top
);
4185 /* if there's a region assigned to the window, combine them both */
4186 if(Window
->hrgnClip
&& !(Window
->style
& WS_MINIMIZE
))
4187 NtGdiCombineRgn(VisRgn
, VisRgn
, Window
->hrgnClip
, RGN_AND
);
4188 /* Copy the region into hRgn */
4189 NtGdiCombineRgn(hRgn
, VisRgn
, NULL
, RGN_COPY
);
4191 if((pRgn
= RGNOBJAPI_Lock(hRgn
, NULL
)))
4193 Ret
= REGION_Complexity(pRgn
);
4194 RGNOBJAPI_Unlock(pRgn
);
4199 REGION_FreeRgnByHandle(VisRgn
);
4205 IntGetWindowRgnBox(PWND Window
, RECTL
*Rect
)
4220 /* Create a new window region using the window rectangle */
4221 VisRgn
= IntSysCreateRectRgnIndirect(&Window
->rcWindow
);
4222 NtGdiOffsetRgn(VisRgn
, -Window
->rcWindow
.left
, -Window
->rcWindow
.top
);
4223 /* if there's a region assigned to the window, combine them both */
4224 if(Window
->hrgnClip
&& !(Window
->style
& WS_MINIMIZE
))
4225 NtGdiCombineRgn(VisRgn
, VisRgn
, Window
->hrgnClip
, RGN_AND
);
4227 if((pRgn
= RGNOBJAPI_Lock(VisRgn
, NULL
)))
4229 Ret
= REGION_Complexity(pRgn
);
4230 *Rect
= pRgn
->rdh
.rcBound
;
4231 RGNOBJAPI_Unlock(pRgn
);
4236 REGION_FreeRgnByHandle(VisRgn
);
4253 DECLARE_RETURN(INT
);
4255 DPRINT("Enter NtUserSetWindowRgn\n");
4256 UserEnterExclusive();
4258 if (!(Window
= UserGetWindowObject(hWnd
)))
4263 if (hRgn
) // The region will be deleted in user32.
4265 if (GDIOBJ_ValidateHandle(hRgn
, GDI_OBJECT_TYPE_REGION
))
4267 hrgnCopy
= IntSysCreateRectRgn(0, 0, 0, 0);
4268 NtGdiCombineRgn(hrgnCopy
, hRgn
, 0, RGN_COPY
);
4274 hrgnCopy
= (HRGN
) 1;
4276 if (Window
->hrgnClip
)
4278 /* Delete no longer needed region handle */
4279 GreDeleteObject(Window
->hrgnClip
);
4281 Window
->hrgnClip
= hrgnCopy
;
4283 /* FIXME - send WM_WINDOWPOSCHANGING and WM_WINDOWPOSCHANGED messages to the window */
4287 USER_REFERENCE_ENTRY Ref
;
4288 UserRefObjectCo(Window
, &Ref
);
4289 co_UserRedrawWindow(Window
, NULL
, NULL
, RDW_INVALIDATE
);
4290 UserDerefObjectCo(Window
);
4296 DPRINT("Leave NtUserSetWindowRgn, ret=%i\n",_ret_
);
4306 NtUserShowWindow(HWND hWnd
, LONG nCmdShow
)
4310 DECLARE_RETURN(BOOL
);
4311 USER_REFERENCE_ENTRY Ref
;
4313 DPRINT("Enter NtUserShowWindow\n");
4314 UserEnterExclusive();
4316 if (!(Window
= UserGetWindowObject(hWnd
)))
4321 UserRefObjectCo(Window
, &Ref
);
4322 ret
= co_WinPosShowWindow(Window
, nCmdShow
);
4323 UserDerefObjectCo(Window
);
4328 DPRINT("Leave NtUserShowWindow, ret=%i\n",_ret_
);
4338 NtUserShowWindowAsync(HWND hWnd
, LONG nCmdShow
)
4344 return NtUserShowWindow(hWnd
, nCmdShow
);
4354 NtUserUpdateLayeredWindow(
4362 BLENDFUNCTION
*pblend
,
4375 NtUserWindowFromPhysicalPoint(POINT Point
)
4386 NtUserWindowFromPoint(LONG X
, LONG Y
)
4390 PWND DesktopWindow
= NULL
, Window
= NULL
;
4391 DECLARE_RETURN(HWND
);
4392 USER_REFERENCE_ENTRY Ref
;
4394 DPRINT("Enter NtUserWindowFromPoint\n");
4395 UserEnterExclusive();
4397 if ((DesktopWindow
= UserGetWindowObject(IntGetDesktopWindow())))
4404 //hmm... threads live on desktops thus we have a reference on the desktop and indirectly the desktop window
4405 //its possible this referencing is useless, thou it shouldnt hurt...
4406 UserRefObjectCo(DesktopWindow
, &Ref
);
4408 pti
= PsGetCurrentThreadWin32Thread();
4409 co_WinPosWindowFromPoint(DesktopWindow
, pti
->MessageQueue
, &pt
, &Window
);
4413 Ret
= Window
->head
.h
;
4422 if (Window
) UserDereferenceObject(Window
);
4423 if (DesktopWindow
) UserDerefObjectCo(DesktopWindow
);
4425 DPRINT("Leave NtUserWindowFromPoint, ret=%i\n",_ret_
);
4435 * Undocumented function that is called from DefWindowProc to set
4442 NtUserDefSetText(HWND hWnd
, PLARGE_STRING WindowText
)
4445 LARGE_STRING SafeText
;
4446 UNICODE_STRING UnicodeString
;
4449 DPRINT("Enter NtUserDefSetText\n");
4451 if (WindowText
!= NULL
)
4455 SafeText
= ProbeForReadLargeString(WindowText
);
4457 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
4460 SetLastNtError(_SEH2_GetExceptionCode());
4470 UserEnterExclusive();
4472 if(!(Wnd
= UserGetWindowObject(hWnd
)))
4478 // ReactOS uses Unicode and not mixed. Up/Down converting will take time.
4479 // Brought to you by: The Wine Project! Dysfunctional Thought Processes!
4480 // Now we know what the bAnsi is for.
4481 RtlInitUnicodeString(&UnicodeString
, NULL
);
4482 if (SafeText
.Buffer
)
4487 ProbeForRead(SafeText
.Buffer
, SafeText
.Length
, sizeof(CHAR
));
4489 ProbeForRead(SafeText
.Buffer
, SafeText
.Length
, sizeof(WCHAR
));
4490 Ret
= RtlLargeStringToUnicodeString(&UnicodeString
, &SafeText
);
4492 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
4495 SetLastNtError(_SEH2_GetExceptionCode());
4498 if (!Ret
) goto Exit
;
4501 if (UnicodeString
.Length
!= 0)
4503 if (Wnd
->strName
.MaximumLength
> 0 &&
4504 UnicodeString
.Length
<= Wnd
->strName
.MaximumLength
- sizeof(UNICODE_NULL
))
4506 ASSERT(Wnd
->strName
.Buffer
!= NULL
);
4508 Wnd
->strName
.Length
= UnicodeString
.Length
;
4509 Wnd
->strName
.Buffer
[UnicodeString
.Length
/ sizeof(WCHAR
)] = L
'\0';
4510 RtlCopyMemory(Wnd
->strName
.Buffer
,
4511 UnicodeString
.Buffer
,
4512 UnicodeString
.Length
);
4517 Wnd
->strName
.MaximumLength
= Wnd
->strName
.Length
= 0;
4518 buf
= Wnd
->strName
.Buffer
;
4519 Wnd
->strName
.Buffer
= NULL
;
4522 DesktopHeapFree(Wnd
->head
.rpdesk
, buf
);
4525 Wnd
->strName
.Buffer
= DesktopHeapAlloc(Wnd
->head
.rpdesk
,
4526 UnicodeString
.Length
+ sizeof(UNICODE_NULL
));
4527 if (Wnd
->strName
.Buffer
!= NULL
)
4529 Wnd
->strName
.Buffer
[UnicodeString
.Length
/ sizeof(WCHAR
)] = L
'\0';
4530 RtlCopyMemory(Wnd
->strName
.Buffer
,
4531 UnicodeString
.Buffer
,
4532 UnicodeString
.Length
);
4533 Wnd
->strName
.MaximumLength
= UnicodeString
.Length
+ sizeof(UNICODE_NULL
);
4534 Wnd
->strName
.Length
= UnicodeString
.Length
;
4538 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
4546 Wnd
->strName
.Length
= 0;
4547 if (Wnd
->strName
.Buffer
!= NULL
)
4548 Wnd
->strName
.Buffer
[0] = L
'\0';
4551 // HAX! FIXME! Windows does not do this in here!
4552 // In User32, these are called after: NotifyWinEvent EVENT_OBJECT_NAMECHANGE than
4553 // RepaintButton, StaticRepaint, NtUserCallHwndLock HWNDLOCK_ROUTINE_REDRAWFRAMEANDHOOK, etc.
4554 /* Send shell notifications */
4555 if (!Wnd
->spwndOwner
&& !IntGetParent(Wnd
))
4557 co_IntShellHookNotify(HSHELL_REDRAW
, (LPARAM
) hWnd
);
4562 if (UnicodeString
.Buffer
) RtlFreeUnicodeString(&UnicodeString
);
4563 DPRINT("Leave NtUserDefSetText, ret=%i\n", Ret
);
4569 * NtUserInternalGetWindowText
4576 NtUserInternalGetWindowText(HWND hWnd
, LPWSTR lpString
, INT nMaxCount
)
4581 DECLARE_RETURN(INT
);
4583 DPRINT("Enter NtUserInternalGetWindowText\n");
4586 if(lpString
&& (nMaxCount
<= 1))
4588 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
4592 if(!(Wnd
= UserGetWindowObject(hWnd
)))
4597 Result
= Wnd
->strName
.Length
/ sizeof(WCHAR
);
4600 const WCHAR Terminator
= L
'\0';
4602 WCHAR
*Buffer
= (WCHAR
*)lpString
;
4604 Copy
= min(nMaxCount
- 1, Result
);
4607 Status
= MmCopyToCaller(Buffer
, Wnd
->strName
.Buffer
, Copy
* sizeof(WCHAR
));
4608 if(!NT_SUCCESS(Status
))
4610 SetLastNtError(Status
);
4616 Status
= MmCopyToCaller(Buffer
, &Terminator
, sizeof(WCHAR
));
4617 if(!NT_SUCCESS(Status
))
4619 SetLastNtError(Status
);
4629 DPRINT("Leave NtUserInternalGetWindowText, ret=%i\n",_ret_
);
4637 IntShowOwnedPopups(PWND OwnerWnd
, BOOL fShow
)
4643 // ASSERT(OwnerWnd);
4645 win_array
= IntWinListChildren(UserGetWindowObject(IntGetDesktopWindow()));
4650 while (win_array
[count
])
4652 while (--count
>= 0)
4654 if (!(pWnd
= UserGetWindowObject( win_array
[count
] )))
4656 if (pWnd
->spwndOwner
!= OwnerWnd
)
4661 if (pWnd
->state
& WNDS_HIDDENPOPUP
)
4663 /* In Windows, ShowOwnedPopups(TRUE) generates
4664 * WM_SHOWWINDOW messages with SW_PARENTOPENING,
4665 * regardless of the state of the owner
4667 co_IntSendMessage(win_array
[count
], WM_SHOWWINDOW
, SW_SHOWNORMAL
, SW_PARENTOPENING
);
4673 if (pWnd
->style
& WS_VISIBLE
)
4675 /* In Windows, ShowOwnedPopups(FALSE) generates
4676 * WM_SHOWWINDOW messages with SW_PARENTCLOSING,
4677 * regardless of the state of the owner
4679 co_IntSendMessage(win_array
[count
], WM_SHOWWINDOW
, SW_HIDE
, SW_PARENTCLOSING
);
4685 ExFreePool( win_array
);
4690 * NtUserValidateHandleSecure
4698 NtUserValidateHandleSecure(
4706 PUSER_HANDLE_ENTRY entry
;
4707 if (!(entry
= handle_to_entry(gHandleTable
, handle
)))
4709 SetLastWin32Error(ERROR_INVALID_HANDLE
);
4712 uType
= entry
->type
;
4719 if ((Window
= UserGetWindowObject((HWND
) handle
))) return TRUE
;
4725 if ((Menu
= UserGetMenuObject((HMENU
) handle
))) return TRUE
;
4730 PACCELERATOR_TABLE Accel
;
4731 if ((Accel
= UserGetAccelObject((HACCEL
) handle
))) return TRUE
;
4736 PCURICON_OBJECT Cursor
;
4737 if ((Cursor
= UserGetCurIconObject((HCURSOR
) handle
))) return TRUE
;
4743 if ((Hook
= IntGetHookObject((HHOOK
) handle
))) return TRUE
;
4749 if ((Monitor
= UserGetMonitorObject((HMONITOR
) handle
))) return TRUE
;
4755 return UserGetCallProcInfo( handle
, &Proc
);
4758 SetLastWin32Error(ERROR_INVALID_HANDLE
);
4762 { /* Is handle entry restricted? */