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.
37 return STATUS_SUCCESS
;
43 * Cleanup windowing implementation.
47 CleanupWindowImpl(VOID
)
49 return STATUS_SUCCESS
;
52 /* HELPER FUNCTIONS ***********************************************************/
54 BOOL FASTCALL
UserUpdateUiState(PWND Wnd
, WPARAM wParam
)
56 WORD Action
= LOWORD(wParam
);
57 WORD Flags
= HIWORD(wParam
);
59 if (Flags
& ~(UISF_HIDEFOCUS
| UISF_HIDEACCEL
| UISF_ACTIVE
))
61 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
68 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
72 if (Flags
& UISF_HIDEFOCUS
)
73 Wnd
->HideFocus
= TRUE
;
74 if (Flags
& UISF_HIDEACCEL
)
75 Wnd
->HideAccel
= TRUE
;
79 if (Flags
& UISF_HIDEFOCUS
)
80 Wnd
->HideFocus
= FALSE
;
81 if (Flags
& UISF_HIDEACCEL
)
82 Wnd
->HideAccel
= FALSE
;
89 PWND FASTCALL
IntGetWindowObject(HWND hWnd
)
93 if (!hWnd
) return NULL
;
95 Window
= UserGetWindowObject(hWnd
);
98 ASSERT(Window
->head
.cLockObj
>= 0);
100 Window
->head
.cLockObj
++;
106 PWND FASTCALL
UserGetWindowObject(HWND hWnd
)
111 if (PsGetCurrentProcess() != PsInitialSystemProcess
)
113 ti
= GetW32ThreadInfo();
116 SetLastWin32Error(ERROR_ACCESS_DENIED
);
123 SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE
);
127 Window
= (PWND
)UserGetObject(gHandleTable
, hWnd
, otWindow
);
128 if (!Window
|| 0 != (Window
->state
& WNDS_DESTROYED
))
130 SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE
);
134 ASSERT(Window
->head
.cLockObj
>= 0);
143 * The function determines whether the specified window handle identifies
144 * an existing window.
148 * Handle to the window to test.
151 * If the window handle identifies an existing window, the return value
152 * is TRUE. If the window handle does not identify an existing window,
153 * the return value is FALSE.
157 IntIsWindow(HWND hWnd
)
161 if (!(Window
= UserGetWindowObject(hWnd
)))
169 IntGetParent(PWND Wnd
)
171 if (Wnd
->style
& WS_POPUP
)
173 return Wnd
->spwndOwner
;
175 else if (Wnd
->style
& WS_CHILD
)
177 return Wnd
->spwndParent
;
186 * Compile a list of all child window handles from given window.
189 * This function is similar to Wine WIN_ListChildren. The caller
190 * must free the returned list with ExFreePool.
194 IntWinListChildren(PWND Window
)
198 UINT Index
, NumChildren
= 0;
200 if (!Window
) return NULL
;
202 for (Child
= Window
->spwndChild
; Child
; Child
= Child
->spwndNext
)
205 List
= ExAllocatePoolWithTag(PagedPool
, (NumChildren
+ 1) * sizeof(HWND
), TAG_WINLIST
);
208 DPRINT1("Failed to allocate memory for children array\n");
209 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
212 for (Child
= Window
->spwndChild
, Index
= 0;
214 Child
= Child
->spwndNext
, ++Index
)
215 List
[Index
] = Child
->head
.h
;
221 /***********************************************************************
224 static void IntSendDestroyMsg(HWND hWnd
)
232 if (GetGUIThreadInfo(GetCurrentThreadId(), &info
))
234 if (hWnd
== info
.hwndCaret
)
241 Window
= UserGetWindowObject(hWnd
);
244 // USER_REFERENCE_ENTRY Ref;
245 // UserRefObjectCo(Window, &Ref);
247 if (!Window
->spwndOwner
&& !IntGetParent(Window
))
249 co_IntShellHookNotify(HSHELL_WINDOWDESTROYED
, (LPARAM
) hWnd
);
252 // UserDerefObjectCo(Window);
255 /* The window could already be destroyed here */
258 * Send the WM_DESTROY to the window.
261 co_IntSendMessage(hWnd
, WM_DESTROY
, 0, 0);
264 * This WM_DESTROY message can trigger re-entrant calls to DestroyWindow
265 * make sure that the window still exists when we come back.
274 if (!(pWndArray
= WIN_ListChildren( hwnd
)))
277 /* start from the end (FIXME: is this needed?) */
278 for (i
= 0; pWndArray
[i
]; i
++)
283 if (IsWindow( pWndArray
[i
] ))
284 WIN_SendDestroyMsg( pWndArray
[i
] );
286 HeapFree(GetProcessHeap(), 0, pWndArray
);
290 DPRINT("destroyed itself while in WM_DESTROY!\n");
296 UserFreeWindowInfo(PTHREADINFO ti
, PWND Wnd
)
298 PCLIENTINFO ClientInfo
= GetWin32ClientInfo();
302 if (ClientInfo
->CallbackWnd
.pWnd
== DesktopHeapAddressToUser(Wnd
))
304 ClientInfo
->CallbackWnd
.hWnd
= NULL
;
305 ClientInfo
->CallbackWnd
.pWnd
= NULL
;
308 if (Wnd
->strName
.Buffer
!= NULL
)
310 Wnd
->strName
.Length
= 0;
311 Wnd
->strName
.MaximumLength
= 0;
312 DesktopHeapFree(Wnd
->head
.rpdesk
,
313 Wnd
->strName
.Buffer
);
314 Wnd
->strName
.Buffer
= NULL
;
317 // DesktopHeapFree(Wnd->head.rpdesk, Wnd);
318 // WindowObject->Wnd = NULL;
321 /***********************************************************************
324 * Destroy storage associated to a window. "Internals" p.358
326 * This is the "functional" DestroyWindows function ei. all stuff
327 * done in CreateWindow is undone here and not in DestroyWindow:-P
330 static LRESULT
co_UserFreeWindow(PWND Window
,
331 PPROCESSINFO ProcessData
,
332 PTHREADINFO ThreadData
,
333 BOOLEAN SendMessages
)
339 BOOLEAN BelongsToThreadData
;
343 if(Window
->state2
& WNDS2_INDESTROY
)
345 DPRINT("Tried to call IntDestroyWindow() twice\n");
348 Window
->state2
|= WNDS2_INDESTROY
;
349 Window
->style
&= ~WS_VISIBLE
;
351 IntNotifyWinEvent(EVENT_OBJECT_DESTROY
, Window
, OBJID_WINDOW
, CHILDID_SELF
, 0);
353 /* remove the window already at this point from the thread window list so we
354 don't get into trouble when destroying the thread windows while we're still
355 in IntDestroyWindow() */
356 RemoveEntryList(&Window
->ThreadListEntry
);
358 BelongsToThreadData
= IntWndBelongsToThread(Window
, ThreadData
);
360 IntDeRegisterShellHookWindow(Window
->head
.h
);
364 /* Send destroy messages */
365 IntSendDestroyMsg(Window
->head
.h
);
368 /* free child windows */
369 Children
= IntWinListChildren(Window
);
372 for (ChildHandle
= Children
; *ChildHandle
; ++ChildHandle
)
374 if ((Child
= IntGetWindowObject(*ChildHandle
)))
376 if(!IntWndBelongsToThread(Child
, ThreadData
))
378 /* send WM_DESTROY messages to windows not belonging to the same thread */
379 IntSendDestroyMsg(Child
->head
.h
);
382 co_UserFreeWindow(Child
, ProcessData
, ThreadData
, SendMessages
);
384 UserDereferenceObject(Child
);
387 ExFreePool(Children
);
393 * Clear the update region to make sure no WM_PAINT messages will be
394 * generated for this window while processing the WM_NCDESTROY.
396 co_UserRedrawWindow(Window
, NULL
, 0,
397 RDW_VALIDATE
| RDW_NOFRAME
| RDW_NOERASE
|
398 RDW_NOINTERNALPAINT
| RDW_NOCHILDREN
);
399 if(BelongsToThreadData
)
400 co_IntSendMessage(Window
->head
.h
, WM_NCDESTROY
, 0, 0);
403 DestroyTimersForWindow(ThreadData
, Window
);
405 HOOK_DestroyThreadHooks(ThreadData
->pEThread
); // This is needed here too!
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 /* Unregister hot keys */
427 UnregisterWindowHotKeys (Window
);
429 /* FIXME: do we need to fake QS_MOUSEMOVE wakebit? */
433 WinPosCheckInternalPos(Window
->head
.h
);
434 if (Window
->head
.h
== GetCapture())
439 /* free resources associated with the window */
440 TIMER_RemoveWindowTimers(Window
->head
.h
);
443 if (!(Window
->style
& WS_CHILD
) && Window
->IDMenu
444 && (Menu
= UserGetMenuObject((HMENU
)Window
->IDMenu
)))
446 IntDestroyMenuObject(Menu
, TRUE
, TRUE
);
450 if(Window
->SystemMenu
451 && (Menu
= UserGetMenuObject(Window
->SystemMenu
)))
453 IntDestroyMenuObject(Menu
, TRUE
, TRUE
);
454 Window
->SystemMenu
= (HMENU
)0;
457 DceFreeWindowDCE(Window
); /* Always do this to catch orphaned DCs */
460 WINPROC_FreeProc(Window
->winproc
, WIN_PROC_WINDOW
);
461 CLASS_RemoveWindow(Window
->Class
);
464 IntUnlinkWindow(Window
);
466 UserReferenceObject(Window
);
467 UserDeleteObject(Window
->head
.h
, otWindow
);
469 IntDestroyScrollBars(Window
);
471 /* dereference the class */
472 IntDereferenceClass(Window
->pcls
,
473 Window
->head
.pti
->pDeskInfo
,
474 Window
->head
.pti
->ppi
);
479 GreDeleteObject(Window
->hrgnClip
);
482 // ASSERT(Window != NULL);
483 UserFreeWindowInfo(Window
->head
.pti
, Window
);
485 UserDereferenceObject(Window
);
487 IntClipboardFreeWindow(Window
);
493 IntGetWindowBorderMeasures(PWND Wnd
, UINT
*cx
, UINT
*cy
)
495 if(HAS_DLGFRAME(Wnd
->style
, Wnd
->ExStyle
) && !(Wnd
->style
& WS_MINIMIZE
))
497 *cx
= UserGetSystemMetrics(SM_CXDLGFRAME
);
498 *cy
= UserGetSystemMetrics(SM_CYDLGFRAME
);
502 if(HAS_THICKFRAME(Wnd
->style
, Wnd
->ExStyle
)&& !(Wnd
->style
& WS_MINIMIZE
))
504 *cx
= UserGetSystemMetrics(SM_CXFRAME
);
505 *cy
= UserGetSystemMetrics(SM_CYFRAME
);
507 else if(HAS_THINFRAME(Wnd
->style
, Wnd
->ExStyle
))
509 *cx
= UserGetSystemMetrics(SM_CXBORDER
);
510 *cy
= UserGetSystemMetrics(SM_CYBORDER
);
520 // Same as User32:IntGetWndProc.
523 IntGetWindowProc(PWND pWnd
,
528 WNDPROC gcpd
, Ret
= 0;
530 ASSERT(UserIsEnteredExclusive() == TRUE
);
534 if (pWnd
->state
& WNDS_SERVERSIDEWINDOWPROC
)
536 for ( i
= FNID_FIRST
; i
<= FNID_SWITCH
; i
++)
538 if (GETPFNSERVER(i
) == pWnd
->lpfnWndProc
)
541 Ret
= GETPFNCLIENTA(i
);
543 Ret
= GETPFNCLIENTW(i
);
549 if (Class
->fnid
== FNID_EDIT
)
550 Ret
= pWnd
->lpfnWndProc
;
553 Ret
= pWnd
->lpfnWndProc
;
555 if (Class
->fnid
<= FNID_GHOST
&& Class
->fnid
>= FNID_BUTTON
)
559 if (GETPFNCLIENTW(Class
->fnid
) == pWnd
->lpfnWndProc
)
560 Ret
= GETPFNCLIENTA(Class
->fnid
);
564 if (GETPFNCLIENTA(Class
->fnid
) == pWnd
->lpfnWndProc
)
565 Ret
= GETPFNCLIENTW(Class
->fnid
);
568 if ( Ret
!= pWnd
->lpfnWndProc
)
571 if ( Ansi
== !!(pWnd
->state
& WNDS_ANSIWINDOWPROC
) )
574 gcpd
= (WNDPROC
)UserGetCPD(
576 (Ansi
? UserGetCPDA2U
: UserGetCPDU2A
)|UserGetCPDWindow
,
579 return (gcpd
? gcpd
: Ret
);
583 IntSetWindowProc(PWND pWnd
,
588 PCALLPROCDATA CallProc
;
590 WNDPROC Ret
, chWndProc
= NULL
;
592 // Retrieve previous window proc.
593 Ret
= IntGetWindowProc(pWnd
, Ansi
);
597 if (IsCallProcHandle(NewWndProc
))
599 CallProc
= UserGetObject(gHandleTable
, NewWndProc
, otCallProc
);
601 { // Reset new WndProc.
602 NewWndProc
= CallProc
->pfnClientPrevious
;
603 // Reset Ansi from CallProc handle. This is expected with wine "deftest".
604 Ansi
= !!(CallProc
->wType
& UserGetCPDU2A
);
607 // Switch from Client Side call to Server Side call if match. Ref: "deftest".
608 for ( i
= FNID_FIRST
; i
<= FNID_SWITCH
; i
++)
610 if (GETPFNCLIENTW(i
) == NewWndProc
)
612 chWndProc
= GETPFNSERVER(i
);
615 if (GETPFNCLIENTA(i
) == NewWndProc
)
617 chWndProc
= GETPFNSERVER(i
);
621 // If match, set/reset to Server Side and clear ansi.
624 pWnd
->lpfnWndProc
= chWndProc
;
625 pWnd
->Unicode
= TRUE
;
626 pWnd
->state
&= ~WNDS_ANSIWINDOWPROC
;
627 pWnd
->state
|= WNDS_SERVERSIDEWINDOWPROC
;
631 pWnd
->Unicode
= !Ansi
;
632 // Handle the state change in here.
634 pWnd
->state
|= WNDS_ANSIWINDOWPROC
;
636 pWnd
->state
&= ~WNDS_ANSIWINDOWPROC
;
638 if (pWnd
->state
& WNDS_SERVERSIDEWINDOWPROC
)
639 pWnd
->state
&= ~WNDS_SERVERSIDEWINDOWPROC
;
641 if (!NewWndProc
) NewWndProc
= pWnd
->lpfnWndProc
;
643 if (Class
->fnid
<= FNID_GHOST
&& Class
->fnid
>= FNID_BUTTON
)
647 if (GETPFNCLIENTW(Class
->fnid
) == NewWndProc
)
648 chWndProc
= GETPFNCLIENTA(Class
->fnid
);
652 if (GETPFNCLIENTA(Class
->fnid
) == NewWndProc
)
653 chWndProc
= GETPFNCLIENTW(Class
->fnid
);
656 // Now set the new window proc.
657 pWnd
->lpfnWndProc
= (chWndProc
? chWndProc
: NewWndProc
);
662 // Move this to user space!
664 IntGetWindowInfo(PWND Wnd
, PWINDOWINFO pwi
)
666 pwi
->cbSize
= sizeof(WINDOWINFO
);
667 pwi
->rcWindow
= Wnd
->rcWindow
;
668 pwi
->rcClient
= Wnd
->rcClient
;
669 pwi
->dwStyle
= Wnd
->style
;
670 pwi
->dwExStyle
= Wnd
->ExStyle
;
671 pwi
->dwWindowStatus
= (UserGetForegroundWindow() == Wnd
->head
.h
); /* WS_ACTIVECAPTION */
672 IntGetWindowBorderMeasures(Wnd
, &pwi
->cxWindowBorders
, &pwi
->cyWindowBorders
);
673 pwi
->atomWindowType
= (Wnd
->pcls
? Wnd
->pcls
->atomClassName
: 0);
674 pwi
->wCreatorVersion
= 0x400; /* FIXME - return a real version number */
684 PMENU_OBJECT OldMenu
, NewMenu
= NULL
;
686 if ((Wnd
->style
& (WS_CHILD
| WS_POPUP
)) == WS_CHILD
)
688 SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE
);
692 *Changed
= (Wnd
->IDMenu
!= (UINT
) Menu
);
700 OldMenu
= IntGetMenuObject((HMENU
) Wnd
->IDMenu
);
701 ASSERT(NULL
== OldMenu
|| OldMenu
->MenuInfo
.Wnd
== Wnd
->head
.h
);
710 NewMenu
= IntGetMenuObject(Menu
);
715 IntReleaseMenuObject(OldMenu
);
717 SetLastWin32Error(ERROR_INVALID_MENU_HANDLE
);
720 if (NULL
!= NewMenu
->MenuInfo
.Wnd
)
722 /* Can't use the same menu for two windows */
725 IntReleaseMenuObject(OldMenu
);
727 SetLastWin32Error(ERROR_INVALID_MENU_HANDLE
);
733 Wnd
->IDMenu
= (UINT
) Menu
;
736 NewMenu
->MenuInfo
.Wnd
= Wnd
->head
.h
;
737 IntReleaseMenuObject(NewMenu
);
741 OldMenu
->MenuInfo
.Wnd
= NULL
;
742 IntReleaseMenuObject(OldMenu
);
749 /* INTERNAL ******************************************************************/
753 co_DestroyThreadWindows(struct _ETHREAD
*Thread
)
758 USER_REFERENCE_ENTRY Ref
;
759 WThread
= (PTHREADINFO
)Thread
->Tcb
.Win32Thread
;
761 while (!IsListEmpty(&WThread
->WindowListHead
))
763 Current
= WThread
->WindowListHead
.Flink
;
764 Wnd
= CONTAINING_RECORD(Current
, WND
, ThreadListEntry
);
766 DPRINT("thread cleanup: while destroy wnds, wnd=0x%x\n",Wnd
);
768 /* window removes itself from the list */
771 fixme: it is critical that the window removes itself! if now, we will loop
775 //ASSERT(co_UserDestroyWindow(Wnd));
777 UserRefObjectCo(Wnd
, &Ref
);//faxme: temp hack??
778 if (!co_UserDestroyWindow(Wnd
))
780 DPRINT1("Unable to destroy window 0x%x at thread cleanup... This is _VERY_ bad!\n", Wnd
);
782 UserDerefObjectCo(Wnd
);//faxme: temp hack??
790 * Returns client window rectangle relative to the upper-left corner of client area.
792 * \note Does not check the validity of the parameters
795 IntGetClientRect(PWND Window
, RECTL
*Rect
)
800 Rect
->left
= Rect
->top
= 0;
801 Rect
->right
= Window
->rcClient
.right
- Window
->rcClient
.left
;
802 Rect
->bottom
= Window
->rcClient
.bottom
- Window
->rcClient
.top
;
808 IntGetFocusWindow(VOID
)
810 PUSER_MESSAGE_QUEUE Queue
;
811 PDESKTOP pdo
= IntGetActiveDesktop();
816 Queue
= (PUSER_MESSAGE_QUEUE
)pdo
->ActiveMessageQueue
;
821 return(Queue
->FocusWindow
);
825 PMENU_OBJECT FASTCALL
826 IntGetSystemMenu(PWND Window
, BOOL bRevert
, BOOL RetMenu
)
828 PMENU_OBJECT Menu
, NewMenu
= NULL
, SysMenu
= NULL
, ret
= NULL
;
829 PTHREADINFO W32Thread
;
830 HMENU hNewMenu
, hSysMenu
;
831 ROSMENUITEMINFO ItemInfo
;
835 W32Thread
= PsGetCurrentThreadWin32Thread();
837 if(!W32Thread
->rpdesk
)
840 if(Window
->SystemMenu
)
842 Menu
= UserGetMenuObject(Window
->SystemMenu
);
845 IntDestroyMenuObject(Menu
, TRUE
, TRUE
);
846 Window
->SystemMenu
= (HMENU
)0;
850 if(W32Thread
->rpdesk
->rpwinstaParent
->SystemMenuTemplate
)
852 /* clone system menu */
853 Menu
= UserGetMenuObject(W32Thread
->rpdesk
->rpwinstaParent
->SystemMenuTemplate
);
857 NewMenu
= IntCloneMenu(Menu
);
860 Window
->SystemMenu
= NewMenu
->MenuInfo
.Self
;
861 NewMenu
->MenuInfo
.Flags
|= MF_SYSMENU
;
862 NewMenu
->MenuInfo
.Wnd
= Window
->head
.h
;
864 //IntReleaseMenuObject(NewMenu);
869 hSysMenu
= UserCreateMenu(FALSE
);
870 if (NULL
== hSysMenu
)
874 SysMenu
= IntGetMenuObject(hSysMenu
);
877 UserDestroyMenu(hSysMenu
);
880 SysMenu
->MenuInfo
.Flags
|= MF_SYSMENU
;
881 SysMenu
->MenuInfo
.Wnd
= Window
->head
.h
;
882 hNewMenu
= co_IntLoadSysMenuTemplate();
885 IntReleaseMenuObject(SysMenu
);
886 UserDestroyMenu(hSysMenu
);
889 Menu
= IntGetMenuObject(hNewMenu
);
892 IntReleaseMenuObject(SysMenu
);
893 UserDestroyMenu(hSysMenu
);
897 NewMenu
= IntCloneMenu(Menu
);
900 NewMenu
->MenuInfo
.Flags
|= MF_SYSMENU
| MF_POPUP
;
901 IntReleaseMenuObject(NewMenu
);
902 UserSetMenuDefaultItem(NewMenu
, SC_CLOSE
, FALSE
);
904 ItemInfo
.cbSize
= sizeof(MENUITEMINFOW
);
905 ItemInfo
.fMask
= MIIM_FTYPE
| MIIM_STRING
| MIIM_STATE
| MIIM_SUBMENU
;
906 ItemInfo
.fType
= MF_POPUP
;
907 ItemInfo
.fState
= MFS_ENABLED
;
908 ItemInfo
.dwTypeData
= NULL
;
910 ItemInfo
.hSubMenu
= NewMenu
->MenuInfo
.Self
;
911 IntInsertMenuItem(SysMenu
, (UINT
) -1, TRUE
, &ItemInfo
);
913 Window
->SystemMenu
= SysMenu
->MenuInfo
.Self
;
917 IntDestroyMenuObject(Menu
, FALSE
, TRUE
);
926 if(Window
->SystemMenu
)
927 return IntGetMenuObject((HMENU
)Window
->SystemMenu
);
935 IntIsChildWindow(PWND Parent
, PWND BaseWindow
)
942 if (Window
== Parent
)
946 if(!(Window
->style
& WS_CHILD
))
951 Window
= Window
->spwndParent
;
958 IntIsWindowVisible(PWND BaseWindow
)
965 if(!(Window
->style
& WS_CHILD
))
969 if(!(Window
->style
& WS_VISIBLE
))
974 Window
= Window
->spwndParent
;
977 if(Window
&& Window
->style
& WS_VISIBLE
)
987 link the window into siblings list
988 children and parent are kept in place.
993 PWND WndInsertAfter
/* set to NULL if top sibling */
996 if ((Wnd
->spwndPrev
= WndInsertAfter
))
998 /* link after WndInsertAfter */
999 if ((Wnd
->spwndNext
= WndInsertAfter
->spwndNext
))
1000 Wnd
->spwndNext
->spwndPrev
= Wnd
;
1002 Wnd
->spwndPrev
->spwndNext
= Wnd
;
1007 if ((Wnd
->spwndNext
= Wnd
->spwndParent
->spwndChild
))
1008 Wnd
->spwndNext
->spwndPrev
= Wnd
;
1010 Wnd
->spwndParent
->spwndChild
= Wnd
;
1015 VOID FASTCALL
IntLinkHwnd(PWND Wnd
, HWND hWndPrev
)
1017 if (hWndPrev
== HWND_NOTOPMOST
)
1019 if (!(Wnd
->ExStyle
& WS_EX_TOPMOST
) &&
1020 (Wnd
->ExStyle2
& WS_EX2_LINKED
)) return; /* nothing to do */
1021 Wnd
->ExStyle
&= ~WS_EX_TOPMOST
;
1022 hWndPrev
= HWND_TOP
; /* fallback to the HWND_TOP case */
1025 IntUnlinkWindow(Wnd
); /* unlink it from the previous location */
1027 if (hWndPrev
== HWND_BOTTOM
)
1029 /* Link in the bottom of the list */
1030 PWND WndInsertAfter
;
1032 WndInsertAfter
= Wnd
->spwndParent
->spwndChild
;
1033 while( WndInsertAfter
&& WndInsertAfter
->spwndNext
)
1034 WndInsertAfter
= WndInsertAfter
->spwndNext
;
1036 IntLinkWindow(Wnd
, WndInsertAfter
);
1037 Wnd
->ExStyle
&= ~WS_EX_TOPMOST
;
1039 else if (hWndPrev
== HWND_TOPMOST
)
1041 /* Link in the top of the list */
1042 IntLinkWindow(Wnd
, NULL
);
1044 Wnd
->ExStyle
|= WS_EX_TOPMOST
;
1046 else if (hWndPrev
== HWND_TOP
)
1048 /* Link it after the last topmost window */
1049 PWND WndInsertBefore
;
1051 WndInsertBefore
= Wnd
->spwndParent
->spwndChild
;
1053 if (!(Wnd
->ExStyle
& WS_EX_TOPMOST
)) /* put it above the first non-topmost window */
1055 while (WndInsertBefore
!= NULL
&& WndInsertBefore
->spwndNext
!= NULL
)
1057 if (!(WndInsertBefore
->ExStyle
& WS_EX_TOPMOST
)) break;
1058 if (WndInsertBefore
== Wnd
->spwndOwner
) /* keep it above owner */
1060 Wnd
->ExStyle
|= WS_EX_TOPMOST
;
1063 WndInsertBefore
= WndInsertBefore
->spwndNext
;
1067 IntLinkWindow(Wnd
, WndInsertBefore
? WndInsertBefore
->spwndPrev
: NULL
);
1071 /* Link it after hWndPrev */
1072 PWND WndInsertAfter
;
1074 WndInsertAfter
= UserGetWindowObject(hWndPrev
);
1075 /* Are we called with an erroneous handle */
1076 if(WndInsertAfter
== NULL
)
1078 /* Link in a default position */
1079 IntLinkHwnd(Wnd
, HWND_TOP
);
1083 IntLinkWindow(Wnd
, WndInsertAfter
);
1085 /* Fix the WS_EX_TOPMOST flag */
1086 if (!(WndInsertAfter
->ExStyle
& WS_EX_TOPMOST
))
1088 Wnd
->ExStyle
&= ~WS_EX_TOPMOST
;
1092 if(WndInsertAfter
->spwndNext
&&
1093 WndInsertAfter
->spwndNext
->ExStyle
& WS_EX_TOPMOST
)
1095 Wnd
->ExStyle
|= WS_EX_TOPMOST
;
1102 IntSetOwner(HWND hWnd
, HWND hWndNewOwner
)
1104 PWND Wnd
, WndOldOwner
, WndNewOwner
;
1107 Wnd
= IntGetWindowObject(hWnd
);
1111 WndOldOwner
= Wnd
->spwndOwner
;
1113 ret
= WndOldOwner
? WndOldOwner
->head
.h
: 0;
1115 if((WndNewOwner
= UserGetWindowObject(hWndNewOwner
)))
1117 Wnd
->spwndOwner
= WndNewOwner
;
1121 Wnd
->spwndOwner
= NULL
;
1124 UserDereferenceObject(Wnd
);
1129 co_IntSetParent(PWND Wnd
, PWND WndNewParent
)
1135 ASSERT(WndNewParent
);
1136 ASSERT_REFS_CO(Wnd
);
1137 ASSERT_REFS_CO(WndNewParent
);
1139 /* Some applications try to set a child as a parent */
1140 if (IntIsChildWindow(Wnd
, WndNewParent
))
1142 SetLastWin32Error( ERROR_INVALID_PARAMETER
);
1147 * Windows hides the window first, then shows it again
1148 * including the WM_SHOWWINDOW messages and all
1150 WasVisible
= co_WinPosShowWindow(Wnd
, SW_HIDE
);
1152 /* Window must belong to current process */
1153 if (Wnd
->head
.pti
->pEThread
->ThreadsProcess
!= PsGetCurrentProcess())
1156 WndOldParent
= Wnd
->spwndParent
;
1158 if (WndOldParent
) UserReferenceObject(WndOldParent
); /* caller must deref */
1160 if (WndNewParent
!= WndOldParent
)
1162 /* Unlink the window from the siblings list */
1163 IntUnlinkWindow(Wnd
);
1165 /* Set the new parent */
1166 Wnd
->spwndParent
= WndNewParent
;
1168 /* Link the window with its new siblings*/
1169 IntLinkHwnd(Wnd
, HWND_TOP
);
1173 IntNotifyWinEvent(EVENT_OBJECT_PARENTCHANGE
, Wnd
,OBJID_WINDOW
, CHILDID_SELF
, WEF_SETBYWNDPTI
);
1175 * SetParent additionally needs to make hwnd the top window
1176 * in the z-order and send the expected WM_WINDOWPOSCHANGING and
1177 * WM_WINDOWPOSCHANGED notification messages.
1179 co_WinPosSetWindowPos(Wnd
, (0 == (Wnd
->ExStyle
& WS_EX_TOPMOST
) ? HWND_TOP
: HWND_TOPMOST
),
1180 0, 0, 0, 0, SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOSIZE
1181 | (WasVisible
? SWP_SHOWWINDOW
: 0));
1184 * FIXME: a WM_MOVE is also generated (in the DefWindowProc handler
1185 * for WM_WINDOWPOSCHANGED) in Windows, should probably remove SWP_NOMOVE
1188 return WndOldParent
;
1192 IntSetSystemMenu(PWND Window
, PMENU_OBJECT Menu
)
1194 PMENU_OBJECT OldMenu
;
1195 if(Window
->SystemMenu
)
1197 OldMenu
= IntGetMenuObject(Window
->SystemMenu
);
1200 OldMenu
->MenuInfo
.Flags
&= ~ MF_SYSMENU
;
1201 IntReleaseMenuObject(OldMenu
);
1207 /* FIXME check window style, propably return FALSE ? */
1208 Window
->SystemMenu
= Menu
->MenuInfo
.Self
;
1209 Menu
->MenuInfo
.Flags
|= MF_SYSMENU
;
1212 Window
->SystemMenu
= (HMENU
)0;
1217 /* unlink the window from siblings. children and parent are kept in place. */
1219 IntUnlinkWindow(PWND Wnd
)
1222 Wnd
->spwndNext
->spwndPrev
= Wnd
->spwndPrev
;
1225 Wnd
->spwndPrev
->spwndNext
= Wnd
->spwndNext
;
1227 if (Wnd
->spwndParent
&& Wnd
->spwndParent
->spwndChild
== Wnd
)
1228 Wnd
->spwndParent
->spwndChild
= Wnd
->spwndNext
;
1230 Wnd
->spwndPrev
= Wnd
->spwndNext
= NULL
;
1235 IntGetWindowPlacement(PWND Wnd
, WINDOWPLACEMENT
*lpwndpl
)
1239 if (!Wnd
) return FALSE
;
1241 if(lpwndpl
->length
!= sizeof(WINDOWPLACEMENT
))
1247 if (0 == (Wnd
->style
& WS_VISIBLE
))
1249 lpwndpl
->showCmd
= SW_HIDE
;
1251 else if (0 != (Wnd
->state2
& WNDS2_MAXIMIZEBUTTONDOWN
) ||
1252 0 != (Wnd
->style
& WS_MAXIMIZE
))
1254 lpwndpl
->showCmd
= SW_MAXIMIZE
;
1256 else if (0 != (Wnd
->style
& WS_MINIMIZE
))
1258 lpwndpl
->showCmd
= SW_MINIMIZE
;
1260 else if (0 != (Wnd
->style
& WS_VISIBLE
))
1262 lpwndpl
->showCmd
= SW_SHOWNORMAL
;
1265 Size
.x
= Wnd
->rcWindow
.left
;
1266 Size
.y
= Wnd
->rcWindow
.top
;
1267 WinPosInitInternalPos(Wnd
, &Size
,
1270 lpwndpl
->rcNormalPosition
= Wnd
->InternalPos
.NormalRect
;
1271 lpwndpl
->ptMinPosition
= Wnd
->InternalPos
.IconPos
;
1272 lpwndpl
->ptMaxPosition
= Wnd
->InternalPos
.MaxPos
;
1278 /* FUNCTIONS *****************************************************************/
1284 NtUserAlterWindowStyle(DWORD Unknown0
,
1294 * As best as I can figure, this function is used by EnumWindows,
1295 * EnumChildWindows, EnumDesktopWindows, & EnumThreadWindows.
1297 * It's supposed to build a list of HWNDs to return to the caller.
1298 * We can figure out what kind of list by what parameters are
1306 NtUserBuildHwndList(
1319 return ERROR_INVALID_PARAMETER
;
1321 if (hwndParent
|| !dwThreadId
)
1324 PWND Parent
, Window
;
1328 if(hDesktop
== NULL
&& !(Desktop
= IntGetActiveDesktop()))
1330 return ERROR_INVALID_HANDLE
;
1335 Status
= IntValidateDesktopHandle(hDesktop
,
1339 if(!NT_SUCCESS(Status
))
1341 return ERROR_INVALID_HANDLE
;
1344 hwndParent
= Desktop
->DesktopWindow
;
1351 if((Parent
= UserGetWindowObject(hwndParent
)) &&
1352 (Window
= Parent
->spwndChild
))
1354 BOOL bGoDown
= TRUE
;
1356 Status
= STATUS_SUCCESS
;
1361 if(dwCount
++ < *pBufSize
&& pWnd
)
1365 ProbeForWrite(pWnd
, sizeof(HWND
), 1);
1366 *pWnd
= Window
->head
.h
;
1369 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1371 Status
= _SEH2_GetExceptionCode();
1374 if(!NT_SUCCESS(Status
))
1376 SetLastNtError(Status
);
1380 if (Window
->spwndChild
&& bChildren
)
1382 Window
= Window
->spwndChild
;
1387 if (Window
->spwndNext
)
1389 Window
= Window
->spwndNext
;
1393 Window
= Window
->spwndParent
;
1394 if (Window
== Parent
)
1403 ObDereferenceObject(Desktop
);
1409 PTHREADINFO W32Thread
;
1410 PLIST_ENTRY Current
;
1413 Status
= PsLookupThreadByThreadId((HANDLE
)dwThreadId
, &Thread
);
1414 if(!NT_SUCCESS(Status
))
1416 return ERROR_INVALID_PARAMETER
;
1418 if(!(W32Thread
= (PTHREADINFO
)Thread
->Tcb
.Win32Thread
))
1420 ObDereferenceObject(Thread
);
1421 DPRINT("Thread is not a GUI Thread!\n");
1422 return ERROR_INVALID_PARAMETER
;
1425 Current
= W32Thread
->WindowListHead
.Flink
;
1426 while(Current
!= &(W32Thread
->WindowListHead
))
1428 Window
= CONTAINING_RECORD(Current
, WND
, ThreadListEntry
);
1431 if(bChildren
|| Window
->spwndOwner
!= NULL
)
1433 if(dwCount
< *pBufSize
&& pWnd
)
1435 Status
= MmCopyToCaller(pWnd
++, &Window
->head
.h
, sizeof(HWND
));
1436 if(!NT_SUCCESS(Status
))
1438 SetLastNtError(Status
);
1444 Current
= Current
->Flink
;
1447 ObDereferenceObject(Thread
);
1450 *pBufSize
= dwCount
;
1451 return STATUS_SUCCESS
;
1459 NtUserChildWindowFromPointEx(HWND hwndParent
,
1469 if(!(Parent
= UserGetWindowObject(hwndParent
)))
1477 if(Parent
->head
.h
!= IntGetDesktopWindow())
1479 Pt
.x
+= Parent
->rcClient
.left
;
1480 Pt
.y
+= Parent
->rcClient
.top
;
1483 if(!IntPtInWindow(Parent
, Pt
.x
, Pt
.y
))
1488 Ret
= Parent
->head
.h
;
1489 if((List
= IntWinListChildren(Parent
)))
1491 for(phWnd
= List
; *phWnd
; phWnd
++)
1494 if((Child
= UserGetWindowObject(*phWnd
)))
1496 if(!(Child
->style
& WS_VISIBLE
) && (uiFlags
& CWP_SKIPINVISIBLE
))
1500 if((Child
->style
& WS_DISABLED
) && (uiFlags
& CWP_SKIPDISABLED
))
1504 if((Child
->ExStyle
& WS_EX_TRANSPARENT
) && (uiFlags
& CWP_SKIPTRANSPARENT
))
1508 if(IntPtInWindow(Child
, Pt
.x
, Pt
.y
))
1510 Ret
= Child
->head
.h
;
1521 static void IntSendParentNotify( PWND pWindow
, UINT msg
)
1523 if ( (pWindow
->style
& (WS_CHILD
| WS_POPUP
)) == WS_CHILD
&&
1524 !(pWindow
->style
& WS_EX_NOPARENTNOTIFY
))
1526 if (pWindow
->spwndParent
&& pWindow
->spwndParent
!= UserGetDesktopWindow())
1528 co_IntSendMessage( pWindow
->spwndParent
->head
.h
,
1530 MAKEWPARAM( msg
, pWindow
->IDMenu
),
1531 (LPARAM
)pWindow
->head
.h
);
1537 IntFixWindowCoordinates(CREATESTRUCTW
* Cs
, PWND ParentWindow
, DWORD
* dwShowMode
)
1539 #define IS_DEFAULT(x) ((x) == CW_USEDEFAULT || (x) == (SHORT)0x8000)
1541 /* default positioning for overlapped windows */
1542 if(!(Cs
->style
& (WS_POPUP
| WS_CHILD
)))
1545 PRTL_USER_PROCESS_PARAMETERS ProcessParams
;
1547 pMonitor
= IntGetPrimaryMonitor();
1550 ProcessParams
= PsGetCurrentProcess()->Peb
->ProcessParameters
;
1552 if (IS_DEFAULT(Cs
->x
))
1554 if (!IS_DEFAULT(Cs
->y
)) *dwShowMode
= Cs
->y
;
1556 if(ProcessParams
->WindowFlags
& STARTF_USEPOSITION
)
1558 Cs
->x
= ProcessParams
->StartingX
;
1559 Cs
->y
= ProcessParams
->StartingY
;
1563 Cs
->x
= pMonitor
->cWndStack
* (UserGetSystemMetrics(SM_CXSIZE
) + UserGetSystemMetrics(SM_CXFRAME
));
1564 Cs
->y
= pMonitor
->cWndStack
* (UserGetSystemMetrics(SM_CYSIZE
) + UserGetSystemMetrics(SM_CYFRAME
));
1565 if (Cs
->x
> ((pMonitor
->rcWork
.right
- pMonitor
->rcWork
.left
) / 4) ||
1566 Cs
->y
> ((pMonitor
->rcWork
.bottom
- pMonitor
->rcWork
.top
) / 4))
1568 /* reset counter and position */
1571 pMonitor
->cWndStack
= 0;
1573 pMonitor
->cWndStack
++;
1577 if (IS_DEFAULT(Cs
->cx
))
1579 if (ProcessParams
->WindowFlags
& STARTF_USEPOSITION
)
1581 Cs
->cx
= ProcessParams
->CountX
;
1582 Cs
->cy
= ProcessParams
->CountY
;
1586 Cs
->cx
= (pMonitor
->rcWork
.right
- pMonitor
->rcWork
.left
) * 3 / 4;
1587 Cs
->cy
= (pMonitor
->rcWork
.bottom
- pMonitor
->rcWork
.top
) * 3 / 4;
1590 /* neither x nor cx are default. Check the y values .
1591 * In the trace we see Outlook and Outlook Express using
1592 * cy set to CW_USEDEFAULT when opening the address book.
1594 else if (IS_DEFAULT(Cs
->cy
))
1596 DPRINT("Strange use of CW_USEDEFAULT in nHeight\n");
1597 Cs
->cy
= (pMonitor
->rcWork
.bottom
- pMonitor
->rcWork
.top
) * 3 / 4;
1602 /* if CW_USEDEFAULT is set for non-overlapped windows, both values are set to zero */
1603 if(IS_DEFAULT(Cs
->x
))
1608 if(IS_DEFAULT(Cs
->cx
))
1618 /* Allocates and initializes a window*/
1619 PWND FASTCALL
IntCreateWindow(CREATESTRUCTW
* Cs
,
1620 PLARGE_STRING WindowName
,
1627 PTHREADINFO pti
= NULL
;
1628 PMENU_OBJECT SystemMenu
;
1630 BOOL bUnicodeWindow
;
1632 pti
= PsGetCurrentThreadWin32Thread();
1634 if (!(Cs
->dwExStyle
& WS_EX_LAYOUTRTL
))
1638 if ( (Cs
->style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
&&
1639 ParentWindow
->ExStyle
& WS_EX_LAYOUTRTL
&&
1640 !(ParentWindow
->ExStyle
& WS_EX_NOINHERITLAYOUT
) )
1641 Cs
->dwExStyle
|= WS_EX_LAYOUTRTL
;
1645 Note from MSDN http://msdn.microsoft.com/en-us/library/aa913269.aspx :
1647 Dialog boxes and message boxes do not inherit layout, so you must
1648 set the layout explicitly.
1650 if ( Class
&& Class
->fnid
!= FNID_DIALOG
)
1652 PPROCESSINFO ppi
= PsGetCurrentProcessWin32Process();
1653 if (ppi
->dwLayout
& LAYOUT_RTL
)
1655 Cs
->dwExStyle
|= WS_EX_LAYOUTRTL
;
1661 /* Automatically add WS_EX_WINDOWEDGE */
1662 if ((Cs
->dwExStyle
& WS_EX_DLGMODALFRAME
) ||
1663 ((!(Cs
->dwExStyle
& WS_EX_STATICEDGE
)) &&
1664 (Cs
->style
& (WS_DLGFRAME
| WS_THICKFRAME
))))
1665 Cs
->dwExStyle
|= WS_EX_WINDOWEDGE
;
1667 Cs
->dwExStyle
&= ~WS_EX_WINDOWEDGE
;
1669 /* Is it a unicode window? */
1670 bUnicodeWindow
=!(Cs
->dwExStyle
& WS_EX_SETANSICREATOR
);
1671 Cs
->dwExStyle
&= ~WS_EX_SETANSICREATOR
;
1673 /* Allocate the new window */
1674 pWnd
= (PWND
) UserCreateObject( gHandleTable
,
1678 sizeof(WND
) + Class
->cbwndExtra
);
1685 DPRINT("Created object with handle %X\n", hWnd
);
1687 if (NULL
== pti
->rpdesk
->DesktopWindow
)
1689 /* If there is no desktop window yet, we must be creating it */
1690 pti
->rpdesk
->DesktopWindow
= hWnd
;
1691 pti
->rpdesk
->pDeskInfo
->spwnd
= pWnd
;
1695 * Fill out the structure describing it.
1697 /* Remember, pWnd->head is setup in object.c ...*/
1698 pWnd
->spwndParent
= ParentWindow
;
1699 pWnd
->spwndOwner
= OwnerWindow
;
1701 pWnd
->hWndLastActive
= hWnd
;
1702 pWnd
->state2
|= WNDS2_WIN40COMPAT
;
1704 pWnd
->hModule
= Cs
->hInstance
;
1705 pWnd
->style
= Cs
->style
& ~WS_VISIBLE
;
1706 pWnd
->ExStyle
= Cs
->dwExStyle
;
1707 pWnd
->cbwndExtra
= pWnd
->pcls
->cbwndExtra
;
1709 IntReferenceMessageQueue(pWnd
->head
.pti
->MessageQueue
);
1710 if (pWnd
->spwndParent
!= NULL
&& Cs
->hwndParent
!= 0)
1712 pWnd
->HideFocus
= pWnd
->spwndParent
->HideFocus
;
1713 pWnd
->HideAccel
= pWnd
->spwndParent
->HideAccel
;
1716 if (pWnd
->pcls
->CSF_flags
& CSF_SERVERSIDEPROC
)
1717 pWnd
->state
|= WNDS_SERVERSIDEWINDOWPROC
;
1719 /* BugBoy Comments: Comment below say that System classes are always created
1720 as UNICODE. In windows, creating a window with the ANSI version of CreateWindow
1721 sets the window to ansi as verified by testing with IsUnicodeWindow API.
1723 No where can I see in code or through testing does the window change back
1724 to ANSI after being created as UNICODE in ROS. I didnt do more testing to
1725 see what problems this would cause.*/
1727 // Set WndProc from Class.
1728 pWnd
->lpfnWndProc
= pWnd
->pcls
->lpfnWndProc
;
1730 // GetWindowProc, test for non server side default classes and set WndProc.
1731 if ( pWnd
->pcls
->fnid
<= FNID_GHOST
&& pWnd
->pcls
->fnid
>= FNID_BUTTON
)
1735 if (GETPFNCLIENTA(pWnd
->pcls
->fnid
) == pWnd
->lpfnWndProc
)
1736 pWnd
->lpfnWndProc
= GETPFNCLIENTW(pWnd
->pcls
->fnid
);
1740 if (GETPFNCLIENTW(pWnd
->pcls
->fnid
) == pWnd
->lpfnWndProc
)
1741 pWnd
->lpfnWndProc
= GETPFNCLIENTA(pWnd
->pcls
->fnid
);
1745 // If not an Unicode caller, set Ansi creator bit.
1746 if (!bUnicodeWindow
) pWnd
->state
|= WNDS_ANSICREATOR
;
1748 // Clone Class Ansi/Unicode proc type.
1749 if (pWnd
->pcls
->CSF_flags
& CSF_ANSIPROC
)
1751 pWnd
->state
|= WNDS_ANSIWINDOWPROC
;
1752 pWnd
->Unicode
= FALSE
;
1756 It seems there can be both an Ansi creator and Unicode Class Window
1757 WndProc, unless the following overriding conditions occur:
1759 if ( !bUnicodeWindow
&&
1760 ( Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_BUTTON
] ||
1761 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_COMBOBOX
] ||
1762 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_COMBOLBOX
] ||
1763 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_DIALOG
] ||
1764 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_EDIT
] ||
1765 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_IME
] ||
1766 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_LISTBOX
] ||
1767 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_MDICLIENT
] ||
1768 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_STATIC
] ) )
1769 { // Override Class and set the window Ansi WndProc.
1770 pWnd
->state
|= WNDS_ANSIWINDOWPROC
;
1771 pWnd
->Unicode
= FALSE
;
1774 { // Set the window Unicode WndProc.
1775 pWnd
->state
&= ~WNDS_ANSIWINDOWPROC
;
1776 pWnd
->Unicode
= TRUE
;
1780 /* BugBoy Comments: if the window being created is a edit control, ATOM 0xCxxx,
1781 then my testing shows that windows (2k and XP) creates a CallProc for it immediately
1782 Dont understand why it does this. */
1783 if (Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_EDIT
])
1785 PCALLPROCDATA CallProc
;
1786 CallProc
= CreateCallProc(NULL
, pWnd
->lpfnWndProc
, pWnd
->Unicode
, pWnd
->head
.pti
->ppi
);
1790 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
1791 DPRINT1("Warning: Unable to create CallProc for edit control. Control may not operate correctly! hwnd %x\n",hWnd
);
1795 UserAddCallProcToClass(pWnd
->pcls
, CallProc
);
1799 InitializeListHead(&pWnd
->PropListHead
);
1801 if ( WindowName
->Buffer
!= NULL
&& WindowName
->Length
> 0 )
1803 pWnd
->strName
.Buffer
= DesktopHeapAlloc(pWnd
->head
.rpdesk
,
1804 WindowName
->Length
+ sizeof(UNICODE_NULL
));
1805 if (pWnd
->strName
.Buffer
== NULL
)
1810 RtlCopyMemory(pWnd
->strName
.Buffer
, WindowName
->Buffer
, WindowName
->Length
);
1811 pWnd
->strName
.Buffer
[WindowName
->Length
/ sizeof(WCHAR
)] = L
'\0';
1812 pWnd
->strName
.Length
= WindowName
->Length
;
1815 /* Correct the window style. */
1816 if ((pWnd
->style
& (WS_CHILD
| WS_POPUP
)) != WS_CHILD
)
1818 pWnd
->style
|= WS_CLIPSIBLINGS
;
1819 if (!(pWnd
->style
& WS_POPUP
))
1821 pWnd
->style
|= WS_CAPTION
;
1822 pWnd
->state
|= WNDS_SENDSIZEMOVEMSGS
;
1826 if ((pWnd
->ExStyle
& WS_EX_DLGMODALFRAME
) ||
1827 (pWnd
->style
& (WS_DLGFRAME
| WS_THICKFRAME
)))
1828 pWnd
->ExStyle
|= WS_EX_WINDOWEDGE
;
1830 pWnd
->ExStyle
&= ~WS_EX_WINDOWEDGE
;
1832 /* create system menu */
1833 if((Cs
->style
& WS_SYSMENU
) )//&& (dwStyle & WS_CAPTION) == WS_CAPTION)
1835 SystemMenu
= IntGetSystemMenu(pWnd
, TRUE
, TRUE
);
1838 pWnd
->SystemMenu
= SystemMenu
->MenuInfo
.Self
;
1839 IntReleaseMenuObject(SystemMenu
);
1843 /* Set the window menu */
1844 if ((Cs
->style
& (WS_CHILD
| WS_POPUP
)) != WS_CHILD
)
1847 IntSetMenu(pWnd
, Cs
->hMenu
, &MenuChanged
);
1848 else if (pWnd
->pcls
->lpszMenuName
) // Take it from the parent.
1850 UNICODE_STRING MenuName
;
1853 if (IS_INTRESOURCE(pWnd
->pcls
->lpszMenuName
))
1855 MenuName
.Length
= 0;
1856 MenuName
.MaximumLength
= 0;
1857 MenuName
.Buffer
= pWnd
->pcls
->lpszMenuName
;
1861 RtlInitUnicodeString( &MenuName
, pWnd
->pcls
->lpszMenuName
);
1863 hMenu
= co_IntCallLoadMenu( pWnd
->pcls
->hModule
, &MenuName
);
1864 if (hMenu
) IntSetMenu(pWnd
, hMenu
, &MenuChanged
);
1868 pWnd
->IDMenu
= (UINT
) Cs
->hMenu
;
1870 /* Insert the window into the thread's window list. */
1871 InsertTailList (&pti
->WindowListHead
, &pWnd
->ThreadListEntry
);
1873 /* Handle "CS_CLASSDC", it is tested first. */
1874 if ( (pWnd
->pcls
->style
& CS_CLASSDC
) && !(pWnd
->pcls
->pdce
) )
1875 { /* One DCE per class to have CLASS. */
1876 pWnd
->pcls
->pdce
= DceAllocDCE( pWnd
, DCE_CLASS_DC
);
1878 else if ( pWnd
->pcls
->style
& CS_OWNDC
)
1879 { /* Allocate a DCE for this window. */
1880 DceAllocDCE(pWnd
, DCE_WINDOW_DC
);
1888 UserDereferenceObject(pWnd
);
1890 SetLastNtError(STATUS_INSUFFICIENT_RESOURCES
);
1898 co_UserCreateWindowEx(CREATESTRUCTW
* Cs
,
1899 PUNICODE_STRING ClassName
,
1900 PLARGE_STRING WindowName
)
1902 PWND Window
= NULL
, ParentWindow
= NULL
, OwnerWindow
;
1903 HWND hWnd
, hWndParent
, hWndOwner
, hwndInsertAfter
;
1905 PWINSTATION_OBJECT WinSta
;
1909 CBT_CREATEWNDW
* pCbtCreate
;
1911 USER_REFERENCE_ENTRY ParentRef
, Ref
;
1913 ANSI_STRING asClassName
;
1914 DWORD dwShowMode
= SW_SHOW
;
1915 CREATESTRUCTW
*pCsw
;
1916 DECLARE_RETURN(PWND
);
1918 /* Get the current window station and reference it */
1919 pti
= GetW32ThreadInfo();
1920 if (pti
== NULL
|| pti
->rpdesk
== NULL
)
1922 DPRINT1("Thread is not attached to a desktop! Cannot create window!\n");
1923 return NULL
; //There is nothing to cleanup
1925 WinSta
= pti
->rpdesk
->rpwinstaParent
;
1926 ObReferenceObjectByPointer(WinSta
, KernelMode
, ExWindowStationObjectType
, 0);
1930 RtlInitAnsiString(&asClassName
, NULL
);
1932 /* Get the class and reference it*/
1933 Class
= IntGetAndReferenceClass(ClassName
, Cs
->hInstance
);
1936 DPRINT1("Failed to find class %wZ\n", ClassName
);
1940 /* Now find the parent and the owner window */
1941 hWndParent
= IntGetDesktopWindow();
1944 if (Cs
->hwndParent
== HWND_MESSAGE
)
1946 Cs
->hwndParent
= hWndParent
= IntGetMessageWindow();
1948 else if (Cs
->hwndParent
)
1950 if ((Cs
->style
& (WS_CHILD
|WS_POPUP
)) != WS_CHILD
)
1951 hWndOwner
= Cs
->hwndParent
;
1953 hWndParent
= Cs
->hwndParent
;
1955 else if ((Cs
->style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
)
1957 DPRINT1("Cannot create a child window without a parrent!\n");
1958 SetLastWin32Error(ERROR_TLW_WITH_WSCHILD
);
1959 RETURN(NULL
); /* WS_CHILD needs a parent, but WS_POPUP doesn't */
1962 ParentWindow
= hWndParent
? UserGetWindowObject(hWndParent
): NULL
;
1963 OwnerWindow
= hWndOwner
? UserGetWindowObject(hWndOwner
): NULL
;
1965 /* FIXME: is this correct?*/
1967 OwnerWindow
= UserGetAncestor(OwnerWindow
, GA_ROOT
);
1969 /* Fix the position and the size of the window */
1972 UserRefObjectCo(ParentWindow
, &ParentRef
);
1973 IntFixWindowCoordinates(Cs
, ParentWindow
, &dwShowMode
);
1976 /* Allocate and initialize the new window */
1977 Window
= IntCreateWindow(Cs
,
1984 DPRINT1("IntCreateWindow failed!\n");
1988 hWnd
= UserHMGetHandle(Window
);
1990 UserRefObjectCo(Window
, &Ref
);
1991 ObDereferenceObject(WinSta
);
1993 //// Call the WH_CBT hook ////
1995 // Allocate the calling structures Justin Case this goes Global.
1996 pCsw
= ExAllocatePoolWithTag(NonPagedPool
, sizeof(CREATESTRUCTW
), TAG_HOOK
);
1997 pCbtCreate
= ExAllocatePoolWithTag(NonPagedPool
, sizeof(CBT_CREATEWNDW
), TAG_HOOK
);
1999 /* Fill the new CREATESTRUCTW */
2000 pCsw
->lpCreateParams
= Cs
->lpCreateParams
;
2001 pCsw
->hInstance
= Cs
->hInstance
;
2002 pCsw
->hMenu
= Cs
->hMenu
;
2003 pCsw
->hwndParent
= Cs
->hwndParent
;
2008 pCsw
->dwExStyle
= Cs
->dwExStyle
;
2009 dwStyle
= Cs
->style
; // Save it anyway.
2010 pCsw
->style
= Window
->style
; /* HCBT_CREATEWND needs the real window style */
2012 pCsw
->lpszName
= (LPCWSTR
) WindowName
->Buffer
;
2013 pCsw
->lpszClass
= (LPCWSTR
) ClassName
->Buffer
;
2015 if (Window
->state
& WNDS_ANSICREATOR
)
2017 if (!IS_ATOM(ClassName
->Buffer
))
2019 RtlUnicodeStringToAnsiString(&asClassName
, ClassName
, TRUE
);
2020 pCsw
->lpszClass
= (LPCWSTR
) asClassName
.Buffer
;
2024 pCbtCreate
->lpcs
= pCsw
;
2025 pCbtCreate
->hwndInsertAfter
= HWND_TOP
;
2027 Result
= co_HOOK_CallHooks(WH_CBT
, HCBT_CREATEWND
, (WPARAM
) hWnd
, (LPARAM
) pCbtCreate
);
2030 DPRINT1("WH_CBT HCBT_CREATEWND hook failed! 0x%x\n", Result
);
2031 RETURN( (PWND
) NULL
);
2033 // Write back changes.
2038 hwndInsertAfter
= pCbtCreate
->hwndInsertAfter
;
2040 Cs
->style
= dwStyle
; /* NCCREATE and WM_NCCALCSIZE need the original values*/
2042 /* Send the WM_GETMINMAXINFO message*/
2046 if ((dwStyle
& WS_THICKFRAME
) || !(dwStyle
& (WS_POPUP
| WS_CHILD
)))
2048 POINT MaxSize
, MaxPos
, MinTrack
, MaxTrack
;
2050 co_WinPosGetMinMaxInfo(Window
, &MaxSize
, &MaxPos
, &MinTrack
, &MaxTrack
);
2051 if (Size
.cx
> MaxTrack
.x
) Size
.cx
= MaxTrack
.x
;
2052 if (Size
.cy
> MaxTrack
.y
) Size
.cy
= MaxTrack
.y
;
2053 if (Size
.cx
< MinTrack
.x
) Size
.cx
= MinTrack
.x
;
2054 if (Size
.cy
< MinTrack
.y
) Size
.cy
= MinTrack
.y
;
2057 Window
->rcWindow
.left
= Cs
->x
;
2058 Window
->rcWindow
.top
= Cs
->y
;
2059 Window
->rcWindow
.right
= Cs
->x
+ Size
.cx
;
2060 Window
->rcWindow
.bottom
= Cs
->y
+ Size
.cy
;
2061 if (0 != (Window
->style
& WS_CHILD
) && ParentWindow
)
2063 RECTL_vOffsetRect(&Window
->rcWindow
,
2064 ParentWindow
->rcClient
.left
,
2065 ParentWindow
->rcClient
.top
);
2067 Window
->rcClient
= Window
->rcWindow
;
2070 /* Link the window*/
2071 if (NULL
!= ParentWindow
)
2073 /* link the window into the siblings list */
2074 if ((dwStyle
& (WS_CHILD
|WS_MAXIMIZE
)) == WS_CHILD
)
2075 IntLinkHwnd(Window
, HWND_BOTTOM
);
2077 IntLinkHwnd(Window
, HWND_TOP
);
2080 /* Send the NCCREATE message */
2081 Result
= co_IntSendMessage(UserHMGetHandle(Window
), WM_NCCREATE
, 0, (LPARAM
) Cs
);
2084 DPRINT1("co_UserCreateWindowEx(): NCCREATE message failed\n");
2088 /* Send the WM_NCCALCSIZE message */
2089 MaxPos
.x
= Window
->rcWindow
.left
;
2090 MaxPos
.y
= Window
->rcWindow
.top
;
2092 Result
= co_WinPosGetNonClientSize(Window
, &Window
->rcWindow
, &Window
->rcClient
);
2094 RECTL_vOffsetRect(&Window
->rcWindow
, MaxPos
.x
- Window
->rcWindow
.left
,
2095 MaxPos
.y
- Window
->rcWindow
.top
);
2098 /* Send the WM_CREATE message. */
2099 Result
= co_IntSendMessage(UserHMGetHandle(Window
), WM_CREATE
, 0, (LPARAM
) Cs
);
2100 if (Result
== (LRESULT
)-1)
2102 DPRINT1("co_UserCreateWindowEx(): WM_CREATE message failed\n");
2106 /* Send the EVENT_OBJECT_CREATE event*/
2107 IntNotifyWinEvent(EVENT_OBJECT_CREATE
, Window
, OBJID_WINDOW
, CHILDID_SELF
, 0);
2109 /* By setting the flag below it can be examined to determine if the window
2110 was created successfully and a valid pwnd was passed back to caller since
2111 from here the function has to succeed. */
2112 Window
->state2
|= WNDS2_WMCREATEMSGPROCESSED
;
2114 /* Send the WM_SIZE and WM_MOVE messages. */
2115 if (!(Window
->state
& WNDS_SENDSIZEMOVEMSGS
))
2117 co_WinPosSendSizeMove(Window
);
2120 /* Show or maybe minimize or maximize the window. */
2121 if (Window
->style
& (WS_MINIMIZE
| WS_MAXIMIZE
))
2126 SwFlag
= (Window
->style
& WS_MINIMIZE
) ? SW_MINIMIZE
: SW_MAXIMIZE
;
2128 co_WinPosMinMaximize(Window
, SwFlag
, &NewPos
);
2130 SwFlag
= ((Window
->style
& WS_CHILD
) || UserGetActiveWindow()) ?
2131 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
:
2132 SWP_NOZORDER
| SWP_FRAMECHANGED
;
2134 co_WinPosSetWindowPos(Window
, 0, NewPos
.left
, NewPos
.top
,
2135 NewPos
.right
, NewPos
.bottom
, SwFlag
);
2138 /* Send the WM_PARENTNOTIFY message */
2139 IntSendParentNotify(Window
, WM_CREATE
);
2141 /* Notify the shell that a new window was created */
2142 if ((!hWndParent
) && (!hWndOwner
))
2144 co_IntShellHookNotify(HSHELL_WINDOWCREATED
, (LPARAM
)hWnd
);
2147 /* Initialize and show the window's scrollbars */
2148 if (Window
->style
& WS_VSCROLL
)
2150 co_UserShowScrollBar(Window
, SB_VERT
, TRUE
);
2152 if (Window
->style
& WS_HSCROLL
)
2154 co_UserShowScrollBar(Window
, SB_HORZ
, TRUE
);
2157 /* Show the new window */
2158 if (Cs
->style
& WS_VISIBLE
)
2160 if (Window
->style
& WS_MAXIMIZE
)
2161 dwShowMode
= SW_SHOW
;
2162 else if (Window
->style
& WS_MINIMIZE
)
2163 dwShowMode
= SW_SHOWMINIMIZED
;
2165 co_WinPosShowWindow(Window
, dwShowMode
);
2167 if (Window
->ExStyle
& WS_EX_MDICHILD
)
2169 co_IntSendMessage(UserHMGetHandle(ParentWindow
), WM_MDIREFRESHMENU
, 0, 0);
2170 /* ShowWindow won't activate child windows */
2171 co_WinPosSetWindowPos(Window
, HWND_TOP
, 0, 0, 0, 0, SWP_SHOWWINDOW
| SWP_NOMOVE
| SWP_NOSIZE
);
2175 DPRINT("co_UserCreateWindowEx(): Created window %X\n", hWnd
);
2181 /* If the window was created, the class will be dereferenced by co_UserDestroyWindow */
2183 co_UserDestroyWindow(Window
);
2185 IntDereferenceClass(Class
, pti
->pDeskInfo
, pti
->ppi
);
2188 if (pCsw
) ExFreePoolWithTag(pCsw
, TAG_HOOK
);
2189 if (pCbtCreate
) ExFreePoolWithTag(pCbtCreate
, TAG_HOOK
);
2190 RtlFreeAnsiString(&asClassName
);
2194 UserDerefObjectCo(Window
);
2195 UserDereferenceObject(Window
);
2197 if (ParentWindow
) UserDerefObjectCo(ParentWindow
);
2204 ProbeAndCaptureLargeString(
2205 OUT PLARGE_STRING plstrSafe
,
2206 IN PLARGE_STRING plstrUnsafe
)
2208 LARGE_STRING lstrTemp
;
2209 PVOID pvBuffer
= NULL
;
2213 /* Probe and copy the string */
2214 ProbeForRead(plstrUnsafe
, sizeof(LARGE_STRING
), sizeof(ULONG
));
2215 lstrTemp
= *plstrUnsafe
;
2217 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2220 _SEH2_YIELD(return _SEH2_GetExceptionCode();)
2224 if (lstrTemp
.Length
!= 0)
2226 /* Allocate a buffer from paged pool */
2227 pvBuffer
= ExAllocatePoolWithTag(PagedPool
, lstrTemp
.Length
, TAG_STRING
);
2230 return STATUS_NO_MEMORY
;
2235 /* Probe and copy the buffer */
2236 ProbeForRead(lstrTemp
.Buffer
, lstrTemp
.Length
, sizeof(WCHAR
));
2237 RtlCopyMemory(pvBuffer
, lstrTemp
.Buffer
, lstrTemp
.Length
);
2239 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2241 /* Cleanup and fail */
2242 ExFreePool(pvBuffer
);
2243 _SEH2_YIELD(return _SEH2_GetExceptionCode();)
2248 /* Set the output string */
2249 plstrSafe
->Buffer
= pvBuffer
;
2250 plstrSafe
->Length
= lstrTemp
.Length
;
2251 plstrSafe
->MaximumLength
= lstrTemp
.Length
;
2253 return STATUS_SUCCESS
;
2257 * \todo Allow passing plstrClassName as ANSI.
2261 NtUserCreateWindowEx(
2263 PLARGE_STRING plstrClassName
,
2264 PLARGE_STRING plstrClsVersion
,
2265 PLARGE_STRING plstrWindowName
,
2273 HINSTANCE hInstance
,
2279 LARGE_STRING lstrWindowName
;
2280 LARGE_STRING lstrClassName
;
2281 UNICODE_STRING ustrClassName
;
2286 lstrWindowName
.Buffer
= NULL
;
2287 lstrClassName
.Buffer
= NULL
;
2289 /* Check if we got a Window name */
2290 if (plstrWindowName
)
2292 /* Copy the string to kernel mode */
2293 Status
= ProbeAndCaptureLargeString(&lstrWindowName
, plstrWindowName
);
2294 if (!NT_SUCCESS(Status
))
2296 DPRINT1("NtUserCreateWindowEx: failed to capture plstrWindowName\n");
2297 SetLastNtError(Status
);
2300 plstrWindowName
= &lstrWindowName
;
2303 /* Check if the class is an atom */
2304 if (IS_ATOM(plstrClassName
))
2306 /* It is, pass the atom in the UNICODE_STRING */
2307 ustrClassName
.Buffer
= (PVOID
)plstrClassName
;
2308 ustrClassName
.Length
= 0;
2309 ustrClassName
.MaximumLength
= 0;
2313 /* It's not, capture the class name */
2314 Status
= ProbeAndCaptureLargeString(&lstrClassName
, plstrClassName
);
2315 if (!NT_SUCCESS(Status
))
2317 DPRINT1("NtUserCreateWindowEx: failed to capture plstrClassName\n");
2318 /* Set last error, cleanup and return */
2319 SetLastNtError(Status
);
2323 /* We pass it on as a UNICODE_STRING */
2324 ustrClassName
.Buffer
= lstrClassName
.Buffer
;
2325 ustrClassName
.Length
= lstrClassName
.Length
;
2326 ustrClassName
.MaximumLength
= lstrClassName
.MaximumLength
;
2329 /* Fill the CREATESTRUCTW */
2330 /* we will keep here the original parameters */
2332 Cs
.lpCreateParams
= lpParam
;
2333 Cs
.hInstance
= hInstance
;
2335 Cs
.hwndParent
= hWndParent
;
2340 // Cs.lpszName = (LPCWSTR) WindowName->Buffer;
2341 // Cs.lpszClass = (LPCWSTR) ClassName->Buffer;
2342 Cs
.lpszName
= (LPCWSTR
) plstrWindowName
;
2343 Cs
.lpszClass
= (LPCWSTR
) &ustrClassName
;
2344 Cs
.dwExStyle
= dwExStyle
;
2346 UserEnterExclusive();
2348 /* Call the internal function */
2349 pwnd
= co_UserCreateWindowEx(&Cs
, &ustrClassName
, plstrWindowName
);
2353 DPRINT1("co_UserCreateWindowEx failed!\n");
2355 hwnd
= pwnd
? UserHMGetHandle(pwnd
) : NULL
;
2360 if (lstrWindowName
.Buffer
)
2362 ExFreePoolWithTag(lstrWindowName
.Buffer
, TAG_STRING
);
2364 if (lstrClassName
.Buffer
)
2366 ExFreePoolWithTag(lstrClassName
.Buffer
, TAG_STRING
);
2376 NtUserDeferWindowPos(HDWP WinPosInfo
,
2378 HWND WndInsertAfter
,
2391 BOOLEAN FASTCALL
co_UserDestroyWindow(PWND Window
)
2397 ASSERT_REFS_CO(Window
); // FIXME: temp hack?
2399 hWnd
= Window
->head
.h
;
2401 DPRINT("co_UserDestroyWindow \n");
2403 /* Check for owner thread */
2404 if ( (Window
->head
.pti
->pEThread
!= PsGetCurrentThread()) ||
2405 Window
->head
.pti
!= PsGetCurrentThreadWin32Thread() )
2407 SetLastWin32Error(ERROR_ACCESS_DENIED
);
2411 /* If window was created successfully and it is hooked */
2412 if ((Window
->state2
& WNDS2_WMCREATEMSGPROCESSED
))
2414 if (co_HOOK_CallHooks(WH_CBT
, HCBT_DESTROYWND
, (WPARAM
) hWnd
, 0))
2416 DPRINT1("Destroy Window WH_CBT Call Hook return!\n");
2421 /* Inform the parent */
2422 if (Window
->style
& WS_CHILD
)
2424 IntSendParentNotify(Window
, WM_DESTROY
);
2427 /* Look whether the focus is within the tree of windows we will
2430 if (!co_WinPosShowWindow(Window
, SW_HIDE
))
2432 if (UserGetActiveWindow() == Window
->head
.h
)
2434 co_WinPosActivateOtherWindow(Window
);
2438 if (Window
->head
.pti
->MessageQueue
->ActiveWindow
== Window
->head
.h
)
2439 Window
->head
.pti
->MessageQueue
->ActiveWindow
= NULL
;
2440 if (Window
->head
.pti
->MessageQueue
->FocusWindow
== Window
->head
.h
)
2441 Window
->head
.pti
->MessageQueue
->FocusWindow
= NULL
;
2442 if (Window
->head
.pti
->MessageQueue
->CaptureWindow
== Window
->head
.h
)
2443 Window
->head
.pti
->MessageQueue
->CaptureWindow
= NULL
;
2446 * Check if this window is the Shell's Desktop Window. If so set hShellWindow to NULL
2449 ti
= PsGetCurrentThreadWin32Thread();
2451 if ((ti
!= NULL
) & (ti
->pDeskInfo
!= NULL
))
2453 if (ti
->pDeskInfo
->hShellWindow
== hWnd
)
2455 DPRINT1("Destroying the ShellWindow!\n");
2456 ti
->pDeskInfo
->hShellWindow
= NULL
;
2460 IntDereferenceMessageQueue(Window
->head
.pti
->MessageQueue
);
2462 IntEngWindowChanged(Window
, WOC_DELETE
);
2464 if (!IntIsWindow(Window
->head
.h
))
2469 /* Recursively destroy owned windows */
2471 if (! (Window
->style
& WS_CHILD
))
2475 BOOL GotOne
= FALSE
;
2478 PWND Child
, Desktop
;
2480 Desktop
= IntIsDesktopWindow(Window
) ? Window
:
2481 UserGetWindowObject(IntGetDesktopWindow());
2482 Children
= IntWinListChildren(Desktop
);
2486 for (ChildHandle
= Children
; *ChildHandle
; ++ChildHandle
)
2488 Child
= UserGetWindowObject(*ChildHandle
);
2491 if (Child
->spwndOwner
!= Window
)
2496 if (IntWndBelongsToThread(Child
, PsGetCurrentThreadWin32Thread()))
2498 USER_REFERENCE_ENTRY ChildRef
;
2499 UserRefObjectCo(Child
, &ChildRef
);//temp hack?
2500 co_UserDestroyWindow(Child
);
2501 UserDerefObjectCo(Child
);//temp hack?
2507 if (Child
->spwndOwner
!= NULL
)
2509 Child
->spwndOwner
= NULL
;
2513 ExFreePool(Children
);
2522 /* Generate mouse move message for the next window */
2523 msg
.message
= WM_MOUSEMOVE
;
2524 msg
.wParam
= IntGetSysCursorInfo()->ButtonsDown
;
2525 msg
.lParam
= MAKELPARAM(gpsi
->ptCursor
.x
, gpsi
->ptCursor
.y
);
2526 msg
.pt
= gpsi
->ptCursor
;
2527 MsqInsertSystemMessage(&msg
);
2529 if (!IntIsWindow(Window
->head
.h
))
2534 /* Destroy the window storage */
2535 co_UserFreeWindow(Window
, PsGetCurrentProcessWin32Process(), PsGetCurrentThreadWin32Thread(), TRUE
);
2545 NtUserDestroyWindow(HWND Wnd
)
2548 DECLARE_RETURN(BOOLEAN
);
2550 USER_REFERENCE_ENTRY Ref
;
2552 DPRINT("Enter NtUserDestroyWindow\n");
2553 UserEnterExclusive();
2555 if (!(Window
= UserGetWindowObject(Wnd
)))
2560 UserRefObjectCo(Window
, &Ref
);//faxme: dunno if win should be reffed during destroy..
2561 ret
= co_UserDestroyWindow(Window
);
2562 UserDerefObjectCo(Window
);//faxme: dunno if win should be reffed during destroy..
2567 DPRINT("Leave NtUserDestroyWindow, ret=%i\n",_ret_
);
2579 NtUserDrawMenuBarTemp(
2586 /* we'll use this function just for caching the menu bar */
2596 NtUserEndDeferWindowPosEx(DWORD Unknown0
,
2606 * FillWindow: Called from User; Dialog, Edit and ListBox procs during a WM_ERASEBKGND.
2612 NtUserFillWindow(HWND hWndPaint
,
2623 static HWND FASTCALL
2624 IntFindWindow(PWND Parent
,
2627 PUNICODE_STRING WindowName
)
2629 BOOL CheckWindowName
;
2632 UNICODE_STRING CurrentWindowName
;
2636 CheckWindowName
= WindowName
->Length
!= 0;
2638 if((List
= IntWinListChildren(Parent
)))
2643 /* skip handles before and including ChildAfter */
2644 while(*phWnd
&& (*(phWnd
++) != ChildAfter
->head
.h
))
2648 /* search children */
2652 if(!(Child
= UserGetWindowObject(*(phWnd
++))))
2657 /* Do not send WM_GETTEXT messages in the kernel mode version!
2658 The user mode version however calls GetWindowText() which will
2659 send WM_GETTEXT messages to windows belonging to its processes */
2660 if (!ClassAtom
|| Child
->pcls
->atomClassName
== ClassAtom
)
2662 // HACK: use UNICODE_STRING instead of LARGE_STRING
2663 CurrentWindowName
.Buffer
= Child
->strName
.Buffer
;
2664 CurrentWindowName
.Length
= Child
->strName
.Length
;
2665 CurrentWindowName
.MaximumLength
= Child
->strName
.MaximumLength
;
2666 if(!CheckWindowName
||
2667 (Child
->strName
.Length
< 0xFFFF &&
2668 !RtlCompareUnicodeString(WindowName
, &CurrentWindowName
, TRUE
)))
2670 Ret
= Child
->head
.h
;
2683 * Searches a window's children for a window with the specified
2686 * hwndParent = The window whose childs are to be searched.
2688 * HWND_MESSAGE = message-only windows
2690 * hwndChildAfter = Search starts after this child window.
2691 * NULL = start from beginning
2693 * ucClassName = Class name to search for
2694 * Reguired parameter.
2696 * ucWindowName = Window name
2697 * ->Buffer == NULL = don't care
2700 * The HWND of the window if it was found, otherwise NULL
2706 NtUserFindWindowEx(HWND hwndParent
,
2707 HWND hwndChildAfter
,
2708 PUNICODE_STRING ucClassName
,
2709 PUNICODE_STRING ucWindowName
,
2712 PWND Parent
, ChildAfter
;
2713 UNICODE_STRING ClassName
= {0}, WindowName
= {0};
2714 HWND Desktop
, Ret
= NULL
;
2715 RTL_ATOM ClassAtom
= (RTL_ATOM
)0;
2716 DECLARE_RETURN(HWND
);
2718 DPRINT("Enter NtUserFindWindowEx\n");
2721 if (ucClassName
!= NULL
|| ucWindowName
!= NULL
)
2725 if (ucClassName
!= NULL
)
2727 ClassName
= ProbeForReadUnicodeString(ucClassName
);
2728 if (ClassName
.Length
!= 0)
2730 ProbeForRead(ClassName
.Buffer
,
2734 else if (!IS_ATOM(ClassName
.Buffer
))
2736 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
2740 if (!IntGetAtomFromStringOrAtom(&ClassName
,
2747 if (ucWindowName
!= NULL
)
2749 WindowName
= ProbeForReadUnicodeString(ucWindowName
);
2750 if (WindowName
.Length
!= 0)
2752 ProbeForRead(WindowName
.Buffer
,
2758 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2760 SetLastNtError(_SEH2_GetExceptionCode());
2761 _SEH2_YIELD(RETURN(NULL
));
2765 if (ucClassName
!= NULL
)
2767 if (ClassName
.Length
== 0 && ClassName
.Buffer
!= NULL
&&
2768 !IS_ATOM(ClassName
.Buffer
))
2770 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
2773 else if (ClassAtom
== (RTL_ATOM
)0)
2775 /* LastError code was set by IntGetAtomFromStringOrAtom */
2781 Desktop
= IntGetCurrentThreadDesktopWindow();
2783 if(hwndParent
== NULL
)
2784 hwndParent
= Desktop
;
2785 else if(hwndParent
== HWND_MESSAGE
)
2787 hwndParent
= IntGetMessageWindow();
2790 if(!(Parent
= UserGetWindowObject(hwndParent
)))
2796 if(hwndChildAfter
&& !(ChildAfter
= UserGetWindowObject(hwndChildAfter
)))
2803 if(Parent
->head
.h
== Desktop
)
2806 PWND TopLevelWindow
;
2807 BOOLEAN CheckWindowName
;
2808 BOOLEAN WindowMatches
;
2809 BOOLEAN ClassMatches
;
2811 /* windows searches through all top-level windows if the parent is the desktop
2814 if((List
= IntWinListChildren(Parent
)))
2820 /* skip handles before and including ChildAfter */
2821 while(*phWnd
&& (*(phWnd
++) != ChildAfter
->head
.h
))
2825 CheckWindowName
= WindowName
.Length
!= 0;
2827 /* search children */
2830 UNICODE_STRING ustr
;
2832 if(!(TopLevelWindow
= UserGetWindowObject(*(phWnd
++))))
2837 /* Do not send WM_GETTEXT messages in the kernel mode version!
2838 The user mode version however calls GetWindowText() which will
2839 send WM_GETTEXT messages to windows belonging to its processes */
2840 ustr
.Buffer
= TopLevelWindow
->strName
.Buffer
;
2841 ustr
.Length
= TopLevelWindow
->strName
.Length
;
2842 ustr
.MaximumLength
= TopLevelWindow
->strName
.MaximumLength
;
2843 WindowMatches
= !CheckWindowName
||
2844 (TopLevelWindow
->strName
.Length
< 0xFFFF &&
2845 !RtlCompareUnicodeString(&WindowName
, &ustr
, TRUE
));
2846 ClassMatches
= (ClassAtom
== (RTL_ATOM
)0) ||
2847 ClassAtom
== TopLevelWindow
->pcls
->atomClassName
;
2849 if (WindowMatches
&& ClassMatches
)
2851 Ret
= TopLevelWindow
->head
.h
;
2855 if (IntFindWindow(TopLevelWindow
, NULL
, ClassAtom
, &WindowName
))
2857 /* window returns the handle of the top-level window, in case it found
2859 Ret
= TopLevelWindow
->head
.h
;
2868 Ret
= IntFindWindow(Parent
, ChildAfter
, ClassAtom
, &WindowName
);
2872 if(Ret
== NULL
&& hwndParent
== NULL
&& hwndChildAfter
== NULL
)
2874 /* FIXME - if both hwndParent and hwndChildAfter are NULL, we also should
2875 search the message-only windows. Should this also be done if
2876 Parent is the desktop window??? */
2879 if((MsgWindows
= UserGetWindowObject(IntGetMessageWindow())))
2881 Ret
= IntFindWindow(MsgWindows
, ChildAfter
, ClassAtom
, &WindowName
);
2886 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2888 SetLastNtError(_SEH2_GetExceptionCode());
2896 DPRINT("Leave NtUserFindWindowEx, ret %i\n",_ret_
);
2906 NtUserFlashWindowEx(IN PFLASHWINFO pfwi
)
2917 PWND FASTCALL
UserGetAncestor(PWND Wnd
, UINT Type
)
2919 PWND WndAncestor
, Parent
;
2921 if (Wnd
->head
.h
== IntGetDesktopWindow())
2930 WndAncestor
= Wnd
->spwndParent
;
2941 if(!(Parent
= WndAncestor
->spwndParent
))
2945 if(IntIsDesktopWindow(Parent
))
2950 WndAncestor
= Parent
;
2963 Parent
= IntGetParent(WndAncestor
);
2970 WndAncestor
= Parent
;
2988 NtUserGetAncestor(HWND hWnd
, UINT Type
)
2990 PWND Window
, Ancestor
;
2991 DECLARE_RETURN(HWND
);
2993 DPRINT("Enter NtUserGetAncestor\n");
2994 UserEnterExclusive();
2996 if (!(Window
= UserGetWindowObject(hWnd
)))
3001 Ancestor
= UserGetAncestor(Window
, Type
);
3002 /* faxme: can UserGetAncestor ever return NULL for a valid window? */
3004 RETURN(Ancestor
? Ancestor
->head
.h
: NULL
);
3007 DPRINT("Leave NtUserGetAncestor, ret=%i\n",_ret_
);
3015 NtUserGetComboBoxInfo(
3020 DECLARE_RETURN(BOOL
);
3022 DPRINT("Enter NtUserGetComboBoxInfo\n");
3025 if (!(Wnd
= UserGetWindowObject(hWnd
)))
3034 sizeof(COMBOBOXINFO
),
3038 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
3040 SetLastNtError(_SEH2_GetExceptionCode());
3041 _SEH2_YIELD(RETURN(FALSE
));
3045 // Pass the user pointer, it was already probed.
3046 RETURN( (BOOL
) co_IntSendMessage( Wnd
->head
.h
, CB_GETCOMBOBOXINFO
, 0, (LPARAM
)pcbi
));
3049 DPRINT("Leave NtUserGetComboBoxInfo, ret=%i\n",_ret_
);
3059 NtUserGetInternalWindowPos( HWND hWnd
,
3066 WINDOWPLACEMENT wndpl
;
3070 if (!(Window
= UserGetWindowObject(hWnd
)))
3080 ProbeForWrite(rectWnd
,
3086 ProbeForWrite(ptIcon
,
3092 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
3094 SetLastNtError(_SEH2_GetExceptionCode());
3099 wndpl
.length
= sizeof(WINDOWPLACEMENT
);
3101 if (IntGetWindowPlacement(Window
, &wndpl
) && !Hit
)
3107 RtlCopyMemory(rectWnd
, &wndpl
.rcNormalPosition
, sizeof(RECT
));
3111 RtlCopyMemory(ptIcon
, &wndpl
.ptMinPosition
, sizeof(POINT
));
3115 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
3117 SetLastNtError(_SEH2_GetExceptionCode());
3122 if (!Hit
) Ret
= wndpl
.showCmd
;
3131 NtUserGetListBoxInfo(
3135 DECLARE_RETURN(DWORD
);
3137 DPRINT("Enter NtUserGetListBoxInfo\n");
3140 if (!(Wnd
= UserGetWindowObject(hWnd
)))
3145 RETURN( (DWORD
) co_IntSendMessage( Wnd
->head
.h
, LB_GETLISTBOXINFO
, 0, 0 ));
3148 DPRINT("Leave NtUserGetListBoxInfo, ret=%i\n",_ret_
);
3155 co_UserSetParent(HWND hWndChild
, HWND hWndNewParent
)
3157 PWND Wnd
= NULL
, WndParent
= NULL
, WndOldParent
;
3158 HWND hWndOldParent
= NULL
;
3159 USER_REFERENCE_ENTRY Ref
, ParentRef
;
3161 if (IntIsBroadcastHwnd(hWndChild
) || IntIsBroadcastHwnd(hWndNewParent
))
3163 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
3167 if (hWndChild
== IntGetDesktopWindow())
3169 SetLastWin32Error(ERROR_ACCESS_DENIED
);
3175 if (!(WndParent
= UserGetWindowObject(hWndNewParent
)))
3182 if (!(WndParent
= UserGetWindowObject(IntGetDesktopWindow())))
3188 if (!(Wnd
= UserGetWindowObject(hWndChild
)))
3193 UserRefObjectCo(Wnd
, &Ref
);
3194 UserRefObjectCo(WndParent
, &ParentRef
);
3196 WndOldParent
= co_IntSetParent(Wnd
, WndParent
);
3198 UserDerefObjectCo(WndParent
);
3199 UserDerefObjectCo(Wnd
);
3203 hWndOldParent
= WndOldParent
->head
.h
;
3204 UserDereferenceObject(WndOldParent
);
3207 return( hWndOldParent
);
3213 * The NtUserSetParent function changes the parent window of the specified
3217 * The new parent window and the child window must belong to the same
3218 * application. If the window identified by the hWndChild parameter is
3219 * visible, the system performs the appropriate redrawing and repainting.
3220 * For compatibility reasons, NtUserSetParent does not modify the WS_CHILD
3221 * or WS_POPUP window styles of the window whose parent is being changed.
3228 NtUserSetParent(HWND hWndChild
, HWND hWndNewParent
)
3230 DECLARE_RETURN(HWND
);
3232 DPRINT("Enter NtUserSetParent\n");
3233 UserEnterExclusive();
3236 Check Parent first from user space, set it here.
3240 hWndNewParent
= IntGetDesktopWindow();
3242 else if (hWndNewParent
== HWND_MESSAGE
)
3244 hWndNewParent
= IntGetMessageWindow();
3247 RETURN( co_UserSetParent(hWndChild
, hWndNewParent
));
3250 DPRINT("Leave NtUserSetParent, ret=%i\n",_ret_
);
3256 * UserGetShellWindow
3258 * Returns a handle to shell window that was set by NtUserSetShellWindowEx.
3263 HWND FASTCALL
UserGetShellWindow(VOID
)
3265 PWINSTATION_OBJECT WinStaObject
;
3268 NTSTATUS Status
= IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation
,
3273 if (!NT_SUCCESS(Status
))
3275 SetLastNtError(Status
);
3279 Ret
= (HWND
)WinStaObject
->ShellWindow
;
3281 ObDereferenceObject(WinStaObject
);
3286 * NtUserSetShellWindowEx
3288 * This is undocumented function to set global shell window. The global
3289 * shell window has special handling of window position.
3295 NtUserSetShellWindowEx(HWND hwndShell
, HWND hwndListView
)
3297 PWINSTATION_OBJECT WinStaObject
;
3298 PWND WndShell
, WndListView
;
3299 DECLARE_RETURN(BOOL
);
3300 USER_REFERENCE_ENTRY Ref
;
3304 DPRINT("Enter NtUserSetShellWindowEx\n");
3305 UserEnterExclusive();
3307 if (!(WndShell
= UserGetWindowObject(hwndShell
)))
3312 if(!(WndListView
= UserGetWindowObject(hwndListView
)))
3317 Status
= IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation
,
3322 if (!NT_SUCCESS(Status
))
3324 SetLastNtError(Status
);
3329 * Test if we are permitted to change the shell window.
3331 if (WinStaObject
->ShellWindow
)
3333 ObDereferenceObject(WinStaObject
);
3338 * Move shell window into background.
3340 if (hwndListView
&& hwndListView
!= hwndShell
)
3343 * Disabled for now to get Explorer working.
3344 * -- Filip, 01/nov/2003
3347 co_WinPosSetWindowPos(hwndListView
, HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
);
3350 if (WndListView
->ExStyle
& WS_EX_TOPMOST
)
3352 ObDereferenceObject(WinStaObject
);
3357 if (WndShell
->ExStyle
& WS_EX_TOPMOST
)
3359 ObDereferenceObject(WinStaObject
);
3363 UserRefObjectCo(WndShell
, &Ref
);
3364 co_WinPosSetWindowPos(WndShell
, HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
);
3366 WinStaObject
->ShellWindow
= hwndShell
;
3367 WinStaObject
->ShellListView
= hwndListView
;
3369 ti
= GetW32ThreadInfo();
3370 if (ti
->pDeskInfo
) ti
->pDeskInfo
->hShellWindow
= hwndShell
;
3372 UserDerefObjectCo(WndShell
);
3374 ObDereferenceObject(WinStaObject
);
3378 DPRINT("Leave NtUserSetShellWindowEx, ret=%i\n",_ret_
);
3384 * NtUserGetSystemMenu
3386 * The NtUserGetSystemMenu function allows the application to access the
3387 * window menu (also known as the system menu or the control menu) for
3388 * copying and modifying.
3392 * Handle to the window that will own a copy of the window menu.
3394 * Specifies the action to be taken. If this parameter is FALSE,
3395 * NtUserGetSystemMenu returns a handle to the copy of the window menu
3396 * currently in use. The copy is initially identical to the window menu
3397 * but it can be modified.
3398 * If this parameter is TRUE, GetSystemMenu resets the window menu back
3399 * to the default state. The previous window menu, if any, is destroyed.
3402 * If the bRevert parameter is FALSE, the return value is a handle to a
3403 * copy of the window menu. If the bRevert parameter is TRUE, the return
3411 NtUserGetSystemMenu(HWND hWnd
, BOOL bRevert
)
3415 DECLARE_RETURN(HMENU
);
3417 DPRINT("Enter NtUserGetSystemMenu\n");
3420 if (!(Window
= UserGetWindowObject(hWnd
)))
3425 if (!(Menu
= IntGetSystemMenu(Window
, bRevert
, FALSE
)))
3430 RETURN(Menu
->MenuInfo
.Self
);
3433 DPRINT("Leave NtUserGetSystemMenu, ret=%i\n",_ret_
);
3439 * NtUserSetSystemMenu
3446 NtUserSetSystemMenu(HWND hWnd
, HMENU hMenu
)
3448 BOOL Result
= FALSE
;
3451 DECLARE_RETURN(BOOL
);
3453 DPRINT("Enter NtUserSetSystemMenu\n");
3454 UserEnterExclusive();
3456 if (!(Window
= UserGetWindowObject(hWnd
)))
3464 * Assign new menu handle.
3466 if (!(Menu
= UserGetMenuObject(hMenu
)))
3471 Result
= IntSetSystemMenu(Window
, Menu
);
3477 DPRINT("Leave NtUserSetSystemMenu, ret=%i\n",_ret_
);
3483 co_UserSetWindowLong(HWND hWnd
, DWORD Index
, LONG NewValue
, BOOL Ansi
)
3485 PWND Window
, Parent
;
3486 PWINSTATION_OBJECT WindowStation
;
3490 if (hWnd
== IntGetDesktopWindow())
3492 SetLastWin32Error(STATUS_ACCESS_DENIED
);
3496 if (!(Window
= UserGetWindowObject(hWnd
)))
3501 if ((INT
)Index
>= 0)
3503 if ((Index
+ sizeof(LONG
)) > Window
->cbwndExtra
)
3505 SetLastWin32Error(ERROR_INVALID_INDEX
);
3509 OldValue
= *((LONG
*)((PCHAR
)(Window
+ 1) + Index
));
3511 if ( Index == DWLP_DLGPROC && Wnd->state & WNDS_DIALOGWINDOW)
3513 OldValue = (LONG)IntSetWindowProc( Wnd,
3516 if (!OldValue) return 0;
3519 *((LONG
*)((PCHAR
)(Window
+ 1) + Index
)) = NewValue
;
3526 OldValue
= (LONG
) Window
->ExStyle
;
3527 Style
.styleOld
= OldValue
;
3528 Style
.styleNew
= NewValue
;
3531 * Remove extended window style bit WS_EX_TOPMOST for shell windows.
3533 WindowStation
= Window
->head
.pti
->rpdesk
->rpwinstaParent
;
3536 if (hWnd
== WindowStation
->ShellWindow
|| hWnd
== WindowStation
->ShellListView
)
3537 Style
.styleNew
&= ~WS_EX_TOPMOST
;
3540 co_IntSendMessage(hWnd
, WM_STYLECHANGING
, GWL_EXSTYLE
, (LPARAM
) &Style
);
3541 Window
->ExStyle
= (DWORD
)Style
.styleNew
;
3542 co_IntSendMessage(hWnd
, WM_STYLECHANGED
, GWL_EXSTYLE
, (LPARAM
) &Style
);
3546 OldValue
= (LONG
) Window
->style
;
3547 Style
.styleOld
= OldValue
;
3548 Style
.styleNew
= NewValue
;
3549 co_IntSendMessage(hWnd
, WM_STYLECHANGING
, GWL_STYLE
, (LPARAM
) &Style
);
3550 Window
->style
= (DWORD
)Style
.styleNew
;
3551 co_IntSendMessage(hWnd
, WM_STYLECHANGED
, GWL_STYLE
, (LPARAM
) &Style
);
3556 if ( Window
->head
.pti
->ppi
!= PsGetCurrentProcessWin32Process() ||
3557 Window
->fnid
& FNID_FREED
)
3559 SetLastWin32Error(ERROR_ACCESS_DENIED
);
3562 OldValue
= (LONG
)IntSetWindowProc(Window
,
3569 OldValue
= (LONG
) Window
->hModule
;
3570 Window
->hModule
= (HINSTANCE
) NewValue
;
3573 case GWL_HWNDPARENT
:
3574 Parent
= Window
->spwndParent
;
3575 if (Parent
&& (Parent
->head
.h
== IntGetDesktopWindow()))
3576 OldValue
= (LONG
) IntSetOwner(Window
->head
.h
, (HWND
) NewValue
);
3578 OldValue
= (LONG
) co_UserSetParent(Window
->head
.h
, (HWND
) NewValue
);
3582 OldValue
= (LONG
) Window
->IDMenu
;
3583 Window
->IDMenu
= (UINT
) NewValue
;
3587 OldValue
= Window
->dwUserData
;
3588 Window
->dwUserData
= NewValue
;
3592 DPRINT1("NtUserSetWindowLong(): Unsupported index %d\n", Index
);
3593 SetLastWin32Error(ERROR_INVALID_INDEX
);
3603 * NtUserSetWindowLong
3605 * The NtUserSetWindowLong function changes an attribute of the specified
3606 * window. The function also sets the 32-bit (long) value at the specified
3607 * offset into the extra window memory.
3614 NtUserSetWindowLong(HWND hWnd
, DWORD Index
, LONG NewValue
, BOOL Ansi
)
3616 DECLARE_RETURN(LONG
);
3618 DPRINT("Enter NtUserSetWindowLong\n");
3619 UserEnterExclusive();
3621 RETURN( co_UserSetWindowLong(hWnd
, Index
, NewValue
, Ansi
));
3624 DPRINT("Leave NtUserSetWindowLong, ret=%i\n",_ret_
);
3630 * NtUserSetWindowWord
3632 * Legacy function similar to NtUserSetWindowLong.
3639 NtUserSetWindowWord(HWND hWnd
, INT Index
, WORD NewValue
)
3643 DECLARE_RETURN(WORD
);
3645 DPRINT("Enter NtUserSetWindowWord\n");
3646 UserEnterExclusive();
3648 if (!(Window
= UserGetWindowObject(hWnd
)))
3657 case GWL_HWNDPARENT
:
3658 RETURN( co_UserSetWindowLong(Window
->head
.h
, Index
, (UINT
)NewValue
, TRUE
));
3662 SetLastWin32Error(ERROR_INVALID_INDEX
);
3667 if (Index
> Window
->cbwndExtra
- sizeof(WORD
))
3669 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
3673 OldValue
= *((WORD
*)((PCHAR
)(Window
+ 1) + Index
));
3674 *((WORD
*)((PCHAR
)(Window
+ 1) + Index
)) = NewValue
;
3679 DPRINT("Leave NtUserSetWindowWord, ret=%i\n",_ret_
);
3688 NtUserGetWindowPlacement(HWND hWnd
,
3689 WINDOWPLACEMENT
*lpwndpl
)
3693 WINDOWPLACEMENT Safepl
;
3695 DECLARE_RETURN(BOOL
);
3697 DPRINT("Enter NtUserGetWindowPlacement\n");
3700 if (!(Wnd
= UserGetWindowObject(hWnd
)))
3705 Status
= MmCopyFromCaller(&Safepl
, lpwndpl
, sizeof(WINDOWPLACEMENT
));
3706 if(!NT_SUCCESS(Status
))
3708 SetLastNtError(Status
);
3711 if(Safepl
.length
!= sizeof(WINDOWPLACEMENT
))
3717 if (0 == (Wnd
->style
& WS_VISIBLE
))
3719 Safepl
.showCmd
= SW_HIDE
;
3721 else if ((0 != (Wnd
->state2
& WNDS2_MAXIMIZEBUTTONDOWN
) ||
3722 0 != (Wnd
->style
& WS_MAXIMIZE
)) &&
3723 0 == (Wnd
->style
& WS_MINIMIZE
))
3725 Safepl
.showCmd
= SW_SHOWMAXIMIZED
;
3727 else if (0 != (Wnd
->style
& WS_MINIMIZE
))
3729 Safepl
.showCmd
= SW_SHOWMINIMIZED
;
3731 else if (0 != (Wnd
->style
& WS_VISIBLE
))
3733 Safepl
.showCmd
= SW_SHOWNORMAL
;
3736 Size
.x
= Wnd
->rcWindow
.left
;
3737 Size
.y
= Wnd
->rcWindow
.top
;
3738 WinPosInitInternalPos(Wnd
, &Size
,
3741 Safepl
.rcNormalPosition
= Wnd
->InternalPos
.NormalRect
;
3742 Safepl
.ptMinPosition
= Wnd
->InternalPos
.IconPos
;
3743 Safepl
.ptMaxPosition
= Wnd
->InternalPos
.MaxPos
;
3745 Status
= MmCopyToCaller(lpwndpl
, &Safepl
, sizeof(WINDOWPLACEMENT
));
3746 if(!NT_SUCCESS(Status
))
3748 SetLastNtError(Status
);
3755 DPRINT("Leave NtUserGetWindowPlacement, ret=%i\n",_ret_
);
3765 NtUserLockWindowUpdate(HWND hWnd
)
3785 return NtUserSetWindowPos(hWnd
, 0, X
, Y
, nWidth
, nHeight
,
3786 (bRepaint
? SWP_NOZORDER
| SWP_NOACTIVATE
:
3787 SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOREDRAW
));
3791 QueryWindow based on KJK::Hyperion and James Tabor.
3793 0 = QWUniqueProcessId
3794 1 = QWUniqueThreadId
3797 4 = QWIsHung Implements IsHungAppWindow found
3800 9 = QWKillWindow When I called this with hWnd ==
3801 DesktopWindow, it shutdown the system
3808 NtUserQueryWindow(HWND hWnd
, DWORD Index
)
3812 DECLARE_RETURN(UINT
);
3814 DPRINT("Enter NtUserQueryWindow\n");
3817 if (!(pWnd
= UserGetWindowObject(hWnd
)))
3824 case QUERY_WINDOW_UNIQUE_PROCESS_ID
:
3825 Result
= (DWORD
)IntGetWndProcessId(pWnd
);
3828 case QUERY_WINDOW_UNIQUE_THREAD_ID
:
3829 Result
= (DWORD
)IntGetWndThreadId(pWnd
);
3832 case QUERY_WINDOW_ACTIVE
:
3833 Result
= (DWORD
)UserGetActiveWindow();
3836 case QUERY_WINDOW_FOCUS
:
3837 Result
= (DWORD
)IntGetFocusWindow();
3840 case QUERY_WINDOW_ISHUNG
:
3841 Result
= (DWORD
)MsqIsHung(pWnd
->head
.pti
->MessageQueue
);
3844 case QUERY_WINDOW_REAL_ID
:
3845 Result
= (DWORD
)pWnd
->head
.pti
->pEThread
->Cid
.UniqueProcess
;
3848 Result
= (DWORD
)NULL
;
3855 DPRINT("Leave NtUserQueryWindow, ret=%i\n",_ret_
);
3865 NtUserRealChildWindowFromPoint(DWORD Unknown0
,
3879 NtUserRegisterWindowMessage(PUNICODE_STRING MessageNameUnsafe
)
3881 UNICODE_STRING SafeMessageName
;
3884 DECLARE_RETURN(UINT
);
3886 DPRINT("Enter NtUserRegisterWindowMessage\n");
3887 UserEnterExclusive();
3889 if(MessageNameUnsafe
== NULL
)
3891 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
3895 Status
= IntSafeCopyUnicodeStringTerminateNULL(&SafeMessageName
, MessageNameUnsafe
);
3896 if(!NT_SUCCESS(Status
))
3898 SetLastNtError(Status
);
3902 Ret
= (UINT
)IntAddAtom(SafeMessageName
.Buffer
);
3903 if (SafeMessageName
.Buffer
)
3904 ExFreePoolWithTag(SafeMessageName
.Buffer
, TAG_STRING
);
3908 DPRINT("Leave NtUserRegisterWindowMessage, ret=%i\n",_ret_
);
3918 NtUserSetImeOwnerWindow(DWORD Unknown0
,
3931 NtUserSetInternalWindowPos(
3948 NtUserSetLayeredWindowAttributes(HWND hwnd
,
3962 NtUserSetLogonNotifyWindow(HWND hWnd
)
3981 DECLARE_RETURN(BOOL
);
3983 DPRINT("Enter NtUserSetMenu\n");
3984 UserEnterExclusive();
3986 if (!(Window
= UserGetWindowObject(hWnd
)))
3991 if (! IntSetMenu(Window
, Menu
, &Changed
))
3996 if (Changed
&& Repaint
)
3998 USER_REFERENCE_ENTRY Ref
;
4000 UserRefObjectCo(Window
, &Ref
);
4001 co_WinPosSetWindowPos(Window
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
4002 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
4004 UserDerefObjectCo(Window
);
4010 DPRINT("Leave NtUserSetMenu, ret=%i\n",_ret_
);
4020 NtUserSetWindowFNID(HWND hWnd
,
4024 DECLARE_RETURN(BOOL
);
4026 DPRINT("Enter NtUserSetWindowFNID\n");
4027 UserEnterExclusive();
4029 if (!(Wnd
= UserGetWindowObject(hWnd
)))
4035 { // From user land we only set these.
4036 if ((fnID
!= FNID_DESTROY
) || ((fnID
< FNID_BUTTON
) && (fnID
> FNID_IME
)) )
4041 Wnd
->pcls
->fnid
|= fnID
;
4046 DPRINT("Leave NtUserSetWindowFNID\n");
4056 NtUserSetWindowPlacement(HWND hWnd
,
4057 WINDOWPLACEMENT
*lpwndpl
)
4060 WINDOWPLACEMENT Safepl
;
4062 DECLARE_RETURN(BOOL
);
4063 USER_REFERENCE_ENTRY Ref
;
4065 DPRINT("Enter NtUserSetWindowPlacement\n");
4066 UserEnterExclusive();
4068 if (!(Wnd
= UserGetWindowObject(hWnd
)))
4073 Status
= MmCopyFromCaller(&Safepl
, lpwndpl
, sizeof(WINDOWPLACEMENT
));
4074 if(!NT_SUCCESS(Status
))
4076 SetLastNtError(Status
);
4079 if(Safepl
.length
!= sizeof(WINDOWPLACEMENT
))
4084 UserRefObjectCo(Wnd
, &Ref
);
4086 if ((Wnd
->style
& (WS_MAXIMIZE
| WS_MINIMIZE
)) == 0)
4088 co_WinPosSetWindowPos(Wnd
, NULL
,
4089 Safepl
.rcNormalPosition
.left
, Safepl
.rcNormalPosition
.top
,
4090 Safepl
.rcNormalPosition
.right
- Safepl
.rcNormalPosition
.left
,
4091 Safepl
.rcNormalPosition
.bottom
- Safepl
.rcNormalPosition
.top
,
4092 SWP_NOZORDER
| SWP_NOACTIVATE
);
4095 /* FIXME - change window status */
4096 co_WinPosShowWindow(Wnd
, Safepl
.showCmd
);
4098 Wnd
->InternalPosInitialized
= TRUE
;
4099 Wnd
->InternalPos
.NormalRect
= Safepl
.rcNormalPosition
;
4100 Wnd
->InternalPos
.IconPos
= Safepl
.ptMinPosition
;
4101 Wnd
->InternalPos
.MaxPos
= Safepl
.ptMaxPosition
;
4103 UserDerefObjectCo(Wnd
);
4107 DPRINT("Leave NtUserSetWindowPlacement, ret=%i\n",_ret_
);
4119 HWND hWndInsertAfter
,
4126 DECLARE_RETURN(BOOL
);
4129 USER_REFERENCE_ENTRY Ref
;
4131 DPRINT("Enter NtUserSetWindowPos\n");
4132 UserEnterExclusive();
4134 if (!(Window
= UserGetWindowObject(hWnd
)))
4139 /* First make sure that coordinates are valid for WM_WINDOWPOSCHANGING */
4140 if (!(uFlags
& SWP_NOMOVE
))
4142 if (X
< -32768) X
= -32768;
4143 else if (X
> 32767) X
= 32767;
4144 if (Y
< -32768) Y
= -32768;
4145 else if (Y
> 32767) Y
= 32767;
4147 if (!(uFlags
& SWP_NOSIZE
))
4150 else if (cx
> 32767) cx
= 32767;
4152 else if (cy
> 32767) cy
= 32767;
4155 UserRefObjectCo(Window
, &Ref
);
4156 ret
= co_WinPosSetWindowPos(Window
, hWndInsertAfter
, X
, Y
, cx
, cy
, uFlags
);
4157 UserDerefObjectCo(Window
);
4162 DPRINT("Leave NtUserSetWindowPos, ret=%i\n",_ret_
);
4169 IntGetWindowRgn(PWND Window
, HRGN hRgn
)
4184 /* Create a new window region using the window rectangle */
4185 VisRgn
= IntSysCreateRectRgnIndirect(&Window
->rcWindow
);
4186 NtGdiOffsetRgn(VisRgn
, -Window
->rcWindow
.left
, -Window
->rcWindow
.top
);
4187 /* if there's a region assigned to the window, combine them both */
4188 if(Window
->hrgnClip
&& !(Window
->style
& WS_MINIMIZE
))
4189 NtGdiCombineRgn(VisRgn
, VisRgn
, Window
->hrgnClip
, RGN_AND
);
4190 /* Copy the region into hRgn */
4191 NtGdiCombineRgn(hRgn
, VisRgn
, NULL
, RGN_COPY
);
4193 if((pRgn
= RGNOBJAPI_Lock(hRgn
, NULL
)))
4195 Ret
= REGION_Complexity(pRgn
);
4196 RGNOBJAPI_Unlock(pRgn
);
4201 REGION_FreeRgnByHandle(VisRgn
);
4207 IntGetWindowRgnBox(PWND Window
, RECTL
*Rect
)
4222 /* Create a new window region using the window rectangle */
4223 VisRgn
= IntSysCreateRectRgnIndirect(&Window
->rcWindow
);
4224 NtGdiOffsetRgn(VisRgn
, -Window
->rcWindow
.left
, -Window
->rcWindow
.top
);
4225 /* if there's a region assigned to the window, combine them both */
4226 if(Window
->hrgnClip
&& !(Window
->style
& WS_MINIMIZE
))
4227 NtGdiCombineRgn(VisRgn
, VisRgn
, Window
->hrgnClip
, RGN_AND
);
4229 if((pRgn
= RGNOBJAPI_Lock(VisRgn
, NULL
)))
4231 Ret
= REGION_Complexity(pRgn
);
4232 *Rect
= pRgn
->rdh
.rcBound
;
4233 RGNOBJAPI_Unlock(pRgn
);
4238 REGION_FreeRgnByHandle(VisRgn
);
4255 DECLARE_RETURN(INT
);
4257 DPRINT("Enter NtUserSetWindowRgn\n");
4258 UserEnterExclusive();
4260 if (!(Window
= UserGetWindowObject(hWnd
)))
4265 if (hRgn
) // The region will be deleted in user32.
4267 if (GDIOBJ_ValidateHandle(hRgn
, GDI_OBJECT_TYPE_REGION
))
4269 hrgnCopy
= IntSysCreateRectRgn(0, 0, 0, 0);
4270 NtGdiCombineRgn(hrgnCopy
, hRgn
, 0, RGN_COPY
);
4276 hrgnCopy
= (HRGN
) 1;
4278 if (Window
->hrgnClip
)
4280 /* Delete no longer needed region handle */
4281 GreDeleteObject(Window
->hrgnClip
);
4283 Window
->hrgnClip
= hrgnCopy
;
4285 /* FIXME - send WM_WINDOWPOSCHANGING and WM_WINDOWPOSCHANGED messages to the window */
4289 USER_REFERENCE_ENTRY Ref
;
4290 UserRefObjectCo(Window
, &Ref
);
4291 co_UserRedrawWindow(Window
, NULL
, NULL
, RDW_INVALIDATE
);
4292 UserDerefObjectCo(Window
);
4298 DPRINT("Leave NtUserSetWindowRgn, ret=%i\n",_ret_
);
4308 NtUserShowWindow(HWND hWnd
, LONG nCmdShow
)
4312 DECLARE_RETURN(BOOL
);
4313 USER_REFERENCE_ENTRY Ref
;
4315 DPRINT("Enter NtUserShowWindow\n");
4316 UserEnterExclusive();
4318 if (!(Window
= UserGetWindowObject(hWnd
)))
4323 UserRefObjectCo(Window
, &Ref
);
4324 ret
= co_WinPosShowWindow(Window
, nCmdShow
);
4325 UserDerefObjectCo(Window
);
4330 DPRINT("Leave NtUserShowWindow, ret=%i\n",_ret_
);
4340 NtUserShowWindowAsync(HWND hWnd
, LONG nCmdShow
)
4346 return NtUserShowWindow(hWnd
, nCmdShow
);
4356 NtUserUpdateLayeredWindow(
4364 BLENDFUNCTION
*pblend
,
4377 NtUserWindowFromPhysicalPoint(POINT Point
)
4388 NtUserWindowFromPoint(LONG X
, LONG Y
)
4392 PWND DesktopWindow
= NULL
, Window
= NULL
;
4393 DECLARE_RETURN(HWND
);
4394 USER_REFERENCE_ENTRY Ref
;
4396 DPRINT("Enter NtUserWindowFromPoint\n");
4397 UserEnterExclusive();
4399 if ((DesktopWindow
= UserGetWindowObject(IntGetDesktopWindow())))
4406 //hmm... threads live on desktops thus we have a reference on the desktop and indirectly the desktop window
4407 //its possible this referencing is useless, thou it shouldnt hurt...
4408 UserRefObjectCo(DesktopWindow
, &Ref
);
4410 pti
= PsGetCurrentThreadWin32Thread();
4411 co_WinPosWindowFromPoint(DesktopWindow
, pti
->MessageQueue
, &pt
, &Window
);
4415 Ret
= Window
->head
.h
;
4424 if (Window
) UserDereferenceObject(Window
);
4425 if (DesktopWindow
) UserDerefObjectCo(DesktopWindow
);
4427 DPRINT("Leave NtUserWindowFromPoint, ret=%i\n",_ret_
);
4437 * Undocumented function that is called from DefWindowProc to set
4444 NtUserDefSetText(HWND hWnd
, PLARGE_STRING WindowText
)
4447 LARGE_STRING SafeText
;
4448 UNICODE_STRING UnicodeString
;
4451 DPRINT("Enter NtUserDefSetText\n");
4453 if (WindowText
!= NULL
)
4457 SafeText
= ProbeForReadLargeString(WindowText
);
4459 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
4462 SetLastNtError(_SEH2_GetExceptionCode());
4472 UserEnterExclusive();
4474 if(!(Wnd
= UserGetWindowObject(hWnd
)))
4480 // ReactOS uses Unicode and not mixed. Up/Down converting will take time.
4481 // Brought to you by: The Wine Project! Dysfunctional Thought Processes!
4482 // Now we know what the bAnsi is for.
4483 RtlInitUnicodeString(&UnicodeString
, NULL
);
4484 if (SafeText
.Buffer
)
4489 ProbeForRead(SafeText
.Buffer
, SafeText
.Length
, sizeof(CHAR
));
4491 ProbeForRead(SafeText
.Buffer
, SafeText
.Length
, sizeof(WCHAR
));
4492 Ret
= RtlLargeStringToUnicodeString(&UnicodeString
, &SafeText
);
4494 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
4497 SetLastNtError(_SEH2_GetExceptionCode());
4500 if (!Ret
) goto Exit
;
4503 if (UnicodeString
.Length
!= 0)
4505 if (Wnd
->strName
.MaximumLength
> 0 &&
4506 UnicodeString
.Length
<= Wnd
->strName
.MaximumLength
- sizeof(UNICODE_NULL
))
4508 ASSERT(Wnd
->strName
.Buffer
!= NULL
);
4510 Wnd
->strName
.Length
= UnicodeString
.Length
;
4511 Wnd
->strName
.Buffer
[UnicodeString
.Length
/ sizeof(WCHAR
)] = L
'\0';
4512 RtlCopyMemory(Wnd
->strName
.Buffer
,
4513 UnicodeString
.Buffer
,
4514 UnicodeString
.Length
);
4519 Wnd
->strName
.MaximumLength
= Wnd
->strName
.Length
= 0;
4520 buf
= Wnd
->strName
.Buffer
;
4521 Wnd
->strName
.Buffer
= NULL
;
4524 DesktopHeapFree(Wnd
->head
.rpdesk
, buf
);
4527 Wnd
->strName
.Buffer
= DesktopHeapAlloc(Wnd
->head
.rpdesk
,
4528 UnicodeString
.Length
+ sizeof(UNICODE_NULL
));
4529 if (Wnd
->strName
.Buffer
!= NULL
)
4531 Wnd
->strName
.Buffer
[UnicodeString
.Length
/ sizeof(WCHAR
)] = L
'\0';
4532 RtlCopyMemory(Wnd
->strName
.Buffer
,
4533 UnicodeString
.Buffer
,
4534 UnicodeString
.Length
);
4535 Wnd
->strName
.MaximumLength
= UnicodeString
.Length
+ sizeof(UNICODE_NULL
);
4536 Wnd
->strName
.Length
= UnicodeString
.Length
;
4540 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
4548 Wnd
->strName
.Length
= 0;
4549 if (Wnd
->strName
.Buffer
!= NULL
)
4550 Wnd
->strName
.Buffer
[0] = L
'\0';
4553 // HAX! FIXME! Windows does not do this in here!
4554 // In User32, these are called after: NotifyWinEvent EVENT_OBJECT_NAMECHANGE than
4555 // RepaintButton, StaticRepaint, NtUserCallHwndLock HWNDLOCK_ROUTINE_REDRAWFRAMEANDHOOK, etc.
4556 /* Send shell notifications */
4557 if (!Wnd
->spwndOwner
&& !IntGetParent(Wnd
))
4559 co_IntShellHookNotify(HSHELL_REDRAW
, (LPARAM
) hWnd
);
4564 if (UnicodeString
.Buffer
) RtlFreeUnicodeString(&UnicodeString
);
4565 DPRINT("Leave NtUserDefSetText, ret=%i\n", Ret
);
4571 * NtUserInternalGetWindowText
4578 NtUserInternalGetWindowText(HWND hWnd
, LPWSTR lpString
, INT nMaxCount
)
4583 DECLARE_RETURN(INT
);
4585 DPRINT("Enter NtUserInternalGetWindowText\n");
4588 if(lpString
&& (nMaxCount
<= 1))
4590 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
4594 if(!(Wnd
= UserGetWindowObject(hWnd
)))
4599 Result
= Wnd
->strName
.Length
/ sizeof(WCHAR
);
4602 const WCHAR Terminator
= L
'\0';
4604 WCHAR
*Buffer
= (WCHAR
*)lpString
;
4606 Copy
= min(nMaxCount
- 1, Result
);
4609 Status
= MmCopyToCaller(Buffer
, Wnd
->strName
.Buffer
, Copy
* sizeof(WCHAR
));
4610 if(!NT_SUCCESS(Status
))
4612 SetLastNtError(Status
);
4618 Status
= MmCopyToCaller(Buffer
, &Terminator
, sizeof(WCHAR
));
4619 if(!NT_SUCCESS(Status
))
4621 SetLastNtError(Status
);
4631 DPRINT("Leave NtUserInternalGetWindowText, ret=%i\n",_ret_
);
4639 IntShowOwnedPopups(PWND OwnerWnd
, BOOL fShow
)
4645 // ASSERT(OwnerWnd);
4647 win_array
= IntWinListChildren(UserGetWindowObject(IntGetDesktopWindow()));
4652 while (win_array
[count
])
4654 while (--count
>= 0)
4656 if (!(pWnd
= UserGetWindowObject( win_array
[count
] )))
4658 if (pWnd
->spwndOwner
!= OwnerWnd
)
4663 if (pWnd
->state
& WNDS_HIDDENPOPUP
)
4665 /* In Windows, ShowOwnedPopups(TRUE) generates
4666 * WM_SHOWWINDOW messages with SW_PARENTOPENING,
4667 * regardless of the state of the owner
4669 co_IntSendMessage(win_array
[count
], WM_SHOWWINDOW
, SW_SHOWNORMAL
, SW_PARENTOPENING
);
4675 if (pWnd
->style
& WS_VISIBLE
)
4677 /* In Windows, ShowOwnedPopups(FALSE) generates
4678 * WM_SHOWWINDOW messages with SW_PARENTCLOSING,
4679 * regardless of the state of the owner
4681 co_IntSendMessage(win_array
[count
], WM_SHOWWINDOW
, SW_HIDE
, SW_PARENTCLOSING
);
4687 ExFreePool( win_array
);
4692 * NtUserValidateHandleSecure
4700 NtUserValidateHandleSecure(
4708 PUSER_HANDLE_ENTRY entry
;
4709 if (!(entry
= handle_to_entry(gHandleTable
, handle
)))
4711 SetLastWin32Error(ERROR_INVALID_HANDLE
);
4714 uType
= entry
->type
;
4721 if ((Window
= UserGetWindowObject((HWND
) handle
))) return TRUE
;
4727 if ((Menu
= UserGetMenuObject((HMENU
) handle
))) return TRUE
;
4732 PACCELERATOR_TABLE Accel
;
4733 if ((Accel
= UserGetAccelObject((HACCEL
) handle
))) return TRUE
;
4738 PCURICON_OBJECT Cursor
;
4739 if ((Cursor
= UserGetCurIconObject((HCURSOR
) handle
))) return TRUE
;
4745 if ((Hook
= IntGetHookObject((HHOOK
) handle
))) return TRUE
;
4751 if ((Monitor
= UserGetMonitorObject((HMONITOR
) handle
))) return TRUE
;
4757 return UserGetCallProcInfo( handle
, &Proc
);
4760 SetLastWin32Error(ERROR_INVALID_HANDLE
);
4764 { /* Is handle entry restricted? */