2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Win32k subsystem
5 * FILE: win32ss/user/ntuser/window.c
6 * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
10 DBG_DEFAULT_CHANNEL(UserWnd
);
12 INT gNestedWindowLimit
= 50;
14 /* HELPER FUNCTIONS ***********************************************************/
16 BOOL FASTCALL
UserUpdateUiState(PWND Wnd
, WPARAM wParam
)
18 WORD Action
= LOWORD(wParam
);
19 WORD Flags
= HIWORD(wParam
);
21 if (Flags
& ~(UISF_HIDEFOCUS
| UISF_HIDEACCEL
| UISF_ACTIVE
))
23 EngSetLastError(ERROR_INVALID_PARAMETER
);
30 EngSetLastError(ERROR_INVALID_PARAMETER
);
34 if (Flags
& UISF_HIDEFOCUS
)
35 Wnd
->HideFocus
= TRUE
;
36 if (Flags
& UISF_HIDEACCEL
)
37 Wnd
->HideAccel
= TRUE
;
41 if (Flags
& UISF_HIDEFOCUS
)
42 Wnd
->HideFocus
= FALSE
;
43 if (Flags
& UISF_HIDEACCEL
)
44 Wnd
->HideAccel
= FALSE
;
51 PWND FASTCALL
IntGetWindowObject(HWND hWnd
)
55 if (!hWnd
) return NULL
;
57 Window
= UserGetWindowObject(hWnd
);
59 Window
->head
.cLockObj
++;
64 PWND FASTCALL
VerifyWnd(PWND pWnd
)
69 if (!pWnd
) return NULL
;
73 hWnd
= UserHMGetHandle(pWnd
);
75 State2
= pWnd
->state2
;
77 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
79 _SEH2_YIELD(return NULL
);
83 if ( UserObjectInDestroy(hWnd
) ||
84 State
& WNDS_DESTROYED
||
85 State2
& WNDS2_INDESTROY
)
91 PWND FASTCALL
ValidateHwndNoErr(HWND hWnd
)
93 if (hWnd
) return (PWND
)UserGetObjectNoErr(gHandleTable
, hWnd
, TYPE_WINDOW
);
98 PWND FASTCALL
UserGetWindowObject(HWND hWnd
)
104 EngSetLastError(ERROR_INVALID_WINDOW_HANDLE
);
108 Window
= (PWND
)UserGetObject(gHandleTable
, hWnd
, TYPE_WINDOW
);
109 if (!Window
|| 0 != (Window
->state
& WNDS_DESTROYED
))
111 EngSetLastError(ERROR_INVALID_WINDOW_HANDLE
);
119 IntSetStyle( PWND pwnd
, ULONG set_bits
, ULONG clear_bits
)
121 ULONG styleOld
, styleNew
;
122 styleOld
= pwnd
->style
;
123 styleNew
= (pwnd
->style
| set_bits
) & ~clear_bits
;
124 if (styleNew
== styleOld
) return styleNew
;
125 pwnd
->style
= styleNew
;
126 if ((styleOld
^ styleNew
) & WS_VISIBLE
) // State Change.
128 if (styleOld
& WS_VISIBLE
) pwnd
->head
.pti
->cVisWindows
--;
129 if (styleNew
& WS_VISIBLE
) pwnd
->head
.pti
->cVisWindows
++;
130 DceResetActiveDCEs( pwnd
);
138 * The function determines whether the specified window handle identifies
139 * an existing window.
143 * Handle to the window to test.
146 * If the window handle identifies an existing window, the return value
147 * is TRUE. If the window handle does not identify an existing window,
148 * the return value is FALSE.
152 IntIsWindow(HWND hWnd
)
156 if (!(Window
= UserGetWindowObject(hWnd
)))
165 IntIsWindowVisible(PWND Wnd
)
170 if (!Temp
) return TRUE
;
171 if (!(Temp
->style
& WS_VISIBLE
)) break;
172 if (Temp
->style
& WS_MINIMIZE
&& Temp
!= Wnd
) break;
173 if (Temp
->fnid
== FNID_DESKTOP
) return TRUE
;
174 Temp
= Temp
->spwndParent
;
180 IntGetParent(PWND Wnd
)
182 if (Wnd
->style
& WS_POPUP
)
184 return Wnd
->spwndOwner
;
186 else if (Wnd
->style
& WS_CHILD
)
188 return Wnd
->spwndParent
;
196 IntEnableWindow( HWND hWnd
, BOOL bEnable
)
202 if(!(pWnd
= UserGetWindowObject(hWnd
)))
207 /* check if updating is needed */
208 bIsDisabled
= !!(pWnd
->style
& WS_DISABLED
);
209 Update
= bIsDisabled
;
213 IntSetStyle( pWnd
, 0, WS_DISABLED
);
217 Update
= !bIsDisabled
;
219 co_IntSendMessage( hWnd
, WM_CANCELMODE
, 0, 0);
221 /* Remove keyboard focus from that window if it had focus */
222 if (hWnd
== IntGetThreadFocusWindow())
224 TRACE("IntEnableWindow SF NULL\n");
225 co_UserSetFocus(NULL
);
227 IntSetStyle( pWnd
, WS_DISABLED
, 0 );
232 IntNotifyWinEvent(EVENT_OBJECT_STATECHANGE
, pWnd
, OBJID_WINDOW
, CHILDID_SELF
, 0);
233 co_IntSendMessage(hWnd
, WM_ENABLE
, (LPARAM
)bEnable
, 0);
235 // Return nonzero if it was disabled, or zero if it wasn't:
242 * Compile a list of all child window handles from given window.
245 * This function is similar to Wine WIN_ListChildren. The caller
246 * must free the returned list with ExFreePool.
250 IntWinListChildren(PWND Window
)
254 UINT Index
, NumChildren
= 0;
256 if (!Window
) return NULL
;
258 for (Child
= Window
->spwndChild
; Child
; Child
= Child
->spwndNext
)
261 List
= ExAllocatePoolWithTag(PagedPool
, (NumChildren
+ 1) * sizeof(HWND
), USERTAG_WINDOWLIST
);
264 ERR("Failed to allocate memory for children array\n");
265 EngSetLastError(ERROR_NOT_ENOUGH_MEMORY
);
268 for (Child
= Window
->spwndChild
, Index
= 0;
270 Child
= Child
->spwndNext
, ++Index
)
271 List
[Index
] = Child
->head
.h
;
278 IntGetNonChildAncestor(PWND pWnd
)
280 while(pWnd
&& (pWnd
->style
& (WS_CHILD
| WS_POPUP
)) == WS_CHILD
)
281 pWnd
= pWnd
->spwndParent
;
286 IntIsTopLevelWindow(PWND pWnd
)
288 if ( pWnd
->spwndParent
&&
289 pWnd
->spwndParent
== co_GetDesktopWindow(pWnd
) ) return TRUE
;
294 IntValidateOwnerDepth(PWND Wnd
, PWND Owner
)
299 if ( !Owner
) return gNestedWindowLimit
>= Depth
;
300 if (Owner
== Wnd
) break;
301 Owner
= Owner
->spwndOwner
;
308 IntGetWindow(HWND hWnd
,
314 Wnd
= ValidateHwndNoErr(hWnd
);
322 if (Wnd
->spwndOwner
!= NULL
)
323 FoundWnd
= Wnd
->spwndOwner
;
327 if(Wnd
->spwndParent
!= NULL
)
329 FoundWnd
= Wnd
->spwndParent
;
330 if (FoundWnd
->spwndChild
!= NULL
)
331 FoundWnd
= FoundWnd
->spwndChild
;
335 if (Wnd
->spwndNext
!= NULL
)
336 FoundWnd
= Wnd
->spwndNext
;
340 if (Wnd
->spwndPrev
!= NULL
)
341 FoundWnd
= Wnd
->spwndPrev
;
345 if (Wnd
->spwndChild
!= NULL
)
346 FoundWnd
= Wnd
->spwndChild
;
351 while ( FoundWnd
->spwndNext
!= NULL
)
352 FoundWnd
= FoundWnd
->spwndNext
;
360 if (FoundWnd
!= NULL
)
361 Ret
= UserHMGetHandle(FoundWnd
);
365 /***********************************************************************
368 static void IntSendDestroyMsg(HWND hWnd
)
373 ti
= PsGetCurrentThreadWin32Thread();
374 Window
= UserGetWindowObject(hWnd
);
378 /* Look whether the focus is within the tree of windows we will
382 if ( ti
->MessageQueue
->spwndActive
== Window
|| // Fixes CORE-106 RegSvr32 exit and return focus to CMD.
383 (ti
->MessageQueue
->spwndActive
== NULL
&& ti
->MessageQueue
== IntGetFocusMessageQueue()) )
385 co_WinPosActivateOtherWindow(Window
);
388 /* Fixes CMD properties closing and returning focus to CMD */
389 if (ti
->MessageQueue
->spwndFocus
== Window
)
391 if ((Window
->style
& (WS_CHILD
| WS_POPUP
)) == WS_CHILD
)
393 co_UserSetFocus(Window
->spwndParent
);
397 co_UserSetFocus(NULL
);
401 if (ti
->MessageQueue
->CaretInfo
->hWnd
== UserHMGetHandle(Window
))
403 co_IntDestroyCaret(ti
);
408 * Send the WM_DESTROY to the window.
411 co_IntSendMessage(hWnd
, WM_DESTROY
, 0, 0);
414 * This WM_DESTROY message can trigger re-entrant calls to DestroyWindow
415 * make sure that the window still exists when we come back.
418 if (IntIsWindow(hWnd
))
423 if (!(pWndArray
= IntWinListChildren( Window
))) return;
425 for (i
= 0; pWndArray
[i
]; i
++)
427 if (IntIsWindow( pWndArray
[i
] )) IntSendDestroyMsg( pWndArray
[i
] );
429 ExFreePoolWithTag(pWndArray
, USERTAG_WINDOWLIST
);
433 TRACE("destroyed itself while in WM_DESTROY!\n");
438 UserFreeWindowInfo(PTHREADINFO ti
, PWND Wnd
)
440 PCLIENTINFO ClientInfo
= GetWin32ClientInfo();
444 if (ClientInfo
->CallbackWnd
.pWnd
== DesktopHeapAddressToUser(Wnd
))
446 ClientInfo
->CallbackWnd
.hWnd
= NULL
;
447 ClientInfo
->CallbackWnd
.pWnd
= NULL
;
450 if (Wnd
->strName
.Buffer
!= NULL
)
452 Wnd
->strName
.Length
= 0;
453 Wnd
->strName
.MaximumLength
= 0;
454 DesktopHeapFree(Wnd
->head
.rpdesk
,
455 Wnd
->strName
.Buffer
);
456 Wnd
->strName
.Buffer
= NULL
;
459 // DesktopHeapFree(Wnd->head.rpdesk, Wnd);
460 // WindowObject->hWnd = NULL;
463 /***********************************************************************
466 * Destroy storage associated to a window. "Internals" p.358
468 * This is the "functional" DestroyWindows function ei. all stuff
469 * done in CreateWindow is undone here and not in DestroyWindow:-P
472 LRESULT
co_UserFreeWindow(PWND Window
,
473 PPROCESSINFO ProcessData
,
474 PTHREADINFO ThreadData
,
475 BOOLEAN SendMessages
)
481 BOOLEAN BelongsToThreadData
;
485 if(Window
->state2
& WNDS2_INDESTROY
)
487 TRACE("Tried to call IntDestroyWindow() twice\n");
490 Window
->state2
|= WNDS2_INDESTROY
;
491 Window
->style
&= ~WS_VISIBLE
;
492 Window
->head
.pti
->cVisWindows
--;
495 /* remove the window already at this point from the thread window list so we
496 don't get into trouble when destroying the thread windows while we're still
497 in IntDestroyWindow() */
498 RemoveEntryList(&Window
->ThreadListEntry
);
500 BelongsToThreadData
= IntWndBelongsToThread(Window
, ThreadData
);
502 IntDeRegisterShellHookWindow(UserHMGetHandle(Window
));
504 /* free child windows */
505 Children
= IntWinListChildren(Window
);
508 for (ChildHandle
= Children
; *ChildHandle
; ++ChildHandle
)
510 if ((Child
= IntGetWindowObject(*ChildHandle
)))
512 if(!IntWndBelongsToThread(Child
, ThreadData
))
514 /* send WM_DESTROY messages to windows not belonging to the same thread */
515 co_IntSendMessage( UserHMGetHandle(Child
), WM_ASYNC_DESTROYWINDOW
, 0, 0 );
518 co_UserFreeWindow(Child
, ProcessData
, ThreadData
, SendMessages
);
520 UserDereferenceObject(Child
);
523 ExFreePoolWithTag(Children
, USERTAG_WINDOWLIST
);
529 * Clear the update region to make sure no WM_PAINT messages will be
530 * generated for this window while processing the WM_NCDESTROY.
532 co_UserRedrawWindow(Window
, NULL
, 0,
533 RDW_VALIDATE
| RDW_NOFRAME
| RDW_NOERASE
|
534 RDW_NOINTERNALPAINT
| RDW_NOCHILDREN
);
535 if(BelongsToThreadData
)
536 co_IntSendMessage(UserHMGetHandle(Window
), WM_NCDESTROY
, 0, 0);
539 DestroyTimersForWindow(ThreadData
, Window
);
541 /* Unregister hot keys */
542 UnregisterWindowHotKeys(Window
);
544 /* flush the message queue */
545 MsqRemoveWindowMessagesFromQueue(Window
);
547 /* from now on no messages can be sent to this window anymore */
548 Window
->state
|= WNDS_DESTROYED
;
549 Window
->fnid
|= FNID_FREED
;
551 /* don't remove the WINDOWSTATUS_DESTROYING bit */
553 /* reset shell window handles */
554 if(ThreadData
->rpdesk
)
556 if (Window
->head
.h
== ThreadData
->rpdesk
->rpwinstaParent
->ShellWindow
)
557 ThreadData
->rpdesk
->rpwinstaParent
->ShellWindow
= NULL
;
559 if (Window
->head
.h
== ThreadData
->rpdesk
->rpwinstaParent
->ShellListView
)
560 ThreadData
->rpdesk
->rpwinstaParent
->ShellListView
= NULL
;
563 /* Fixes dialog test_focus breakage due to r66237. */
564 if (ThreadData
->MessageQueue
->spwndFocus
== Window
)
565 ThreadData
->MessageQueue
->spwndFocus
= NULL
;
567 if (ThreadData
->MessageQueue
->spwndActive
== Window
)
568 ThreadData
->MessageQueue
->spwndActive
= NULL
;
570 if (ThreadData
->MessageQueue
->spwndCapture
== Window
)
575 //// Now kill those remaining "PAINTING BUG: Thread marked as containing dirty windows" spam!!!
576 if ( Window
->hrgnUpdate
!= NULL
|| Window
->state
& WNDS_INTERNALPAINT
)
578 MsqDecPaintCountQueue(Window
->head
.pti
);
579 if (Window
->hrgnUpdate
> HRGN_WINDOW
&& GreIsHandleValid(Window
->hrgnUpdate
))
581 GreDeleteObject(Window
->hrgnUpdate
);
583 Window
->hrgnUpdate
= NULL
;
584 Window
->state
&= ~WNDS_INTERNALPAINT
;
587 if (Window
->state
& (WNDS_SENDERASEBACKGROUND
|WNDS_SENDNCPAINT
))
589 Window
->state
&= ~(WNDS_SENDERASEBACKGROUND
|WNDS_SENDNCPAINT
);
592 if ( ((Window
->style
& (WS_CHILD
|WS_POPUP
)) != WS_CHILD
) &&
594 (Menu
= UserGetMenuObject((HMENU
)Window
->IDMenu
)))
596 IntDestroyMenuObject(Menu
, TRUE
);
600 if(Window
->SystemMenu
601 && (Menu
= UserGetMenuObject(Window
->SystemMenu
)))
603 IntDestroyMenuObject(Menu
, TRUE
);
604 Window
->SystemMenu
= (HMENU
)0;
607 DceFreeWindowDCE(Window
); /* Always do this to catch orphaned DCs */
609 IntUnlinkWindow(Window
);
611 if (Window
->PropListItems
)
613 IntRemoveWindowProp(Window
);
614 TRACE("Window->PropListItems %lu\n",Window
->PropListItems
);
615 ASSERT(Window
->PropListItems
==0);
618 UserReferenceObject(Window
);
619 UserDeleteObject(UserHMGetHandle(Window
), TYPE_WINDOW
);
621 IntDestroyScrollBars(Window
);
623 if (Window
->pcls
->atomClassName
== gaGuiConsoleWndClass
)
625 /* Count only console windows manually */
626 co_IntUserManualGuiCheck(FALSE
);
629 /* dereference the class */
630 NT_ASSERT(Window
->head
.pti
!= NULL
);
631 IntDereferenceClass(Window
->pcls
,
632 Window
->head
.pti
->pDeskInfo
,
633 Window
->head
.pti
->ppi
);
638 IntGdiSetRegionOwner(Window
->hrgnClip
, GDI_OBJ_HMGR_POWNED
);
639 GreDeleteObject(Window
->hrgnClip
);
640 Window
->hrgnClip
= NULL
;
642 Window
->head
.pti
->cWindows
--;
644 // ASSERT(Window != NULL);
645 UserFreeWindowInfo(Window
->head
.pti
, Window
);
647 UserDereferenceObject(Window
);
649 UserClipboardFreeWindow(Window
);
655 // Same as User32:IntGetWndProc.
658 IntGetWindowProc(PWND pWnd
,
663 WNDPROC gcpd
, Ret
= 0;
665 ASSERT(UserIsEnteredExclusive() == TRUE
);
669 if (pWnd
->state
& WNDS_SERVERSIDEWINDOWPROC
)
671 for ( i
= FNID_FIRST
; i
<= FNID_SWITCH
; i
++)
673 if (GETPFNSERVER(i
) == pWnd
->lpfnWndProc
)
676 Ret
= GETPFNCLIENTA(i
);
678 Ret
= GETPFNCLIENTW(i
);
684 if (Class
->fnid
== FNID_EDIT
)
685 Ret
= pWnd
->lpfnWndProc
;
688 Ret
= pWnd
->lpfnWndProc
;
690 if (Class
->fnid
<= FNID_GHOST
&& Class
->fnid
>= FNID_BUTTON
)
694 if (GETPFNCLIENTW(Class
->fnid
) == pWnd
->lpfnWndProc
)
695 Ret
= GETPFNCLIENTA(Class
->fnid
);
699 if (GETPFNCLIENTA(Class
->fnid
) == pWnd
->lpfnWndProc
)
700 Ret
= GETPFNCLIENTW(Class
->fnid
);
703 if ( Ret
!= pWnd
->lpfnWndProc
)
706 if ( Ansi
== !!(pWnd
->state
& WNDS_ANSIWINDOWPROC
) )
709 gcpd
= (WNDPROC
)UserGetCPD(
711 (Ansi
? UserGetCPDA2U
: UserGetCPDU2A
)|UserGetCPDWindow
,
714 return (gcpd
? gcpd
: Ret
);
718 IntSetWindowProc(PWND pWnd
,
723 PCALLPROCDATA CallProc
;
725 WNDPROC Ret
, chWndProc
= NULL
;
727 // Retrieve previous window proc.
728 Ret
= IntGetWindowProc(pWnd
, Ansi
);
732 if (IsCallProcHandle(NewWndProc
))
734 CallProc
= UserGetObject(gHandleTable
, NewWndProc
, TYPE_CALLPROC
);
736 { // Reset new WndProc.
737 NewWndProc
= CallProc
->pfnClientPrevious
;
738 // Reset Ansi from CallProc handle. This is expected with wine "deftest".
739 Ansi
= !!(CallProc
->wType
& UserGetCPDU2A
);
742 // Switch from Client Side call to Server Side call if match. Ref: "deftest".
743 for ( i
= FNID_FIRST
; i
<= FNID_SWITCH
; i
++)
745 if (GETPFNCLIENTW(i
) == NewWndProc
)
747 chWndProc
= GETPFNSERVER(i
);
750 if (GETPFNCLIENTA(i
) == NewWndProc
)
752 chWndProc
= GETPFNSERVER(i
);
756 // If match, set/reset to Server Side and clear ansi.
759 pWnd
->lpfnWndProc
= chWndProc
;
760 pWnd
->Unicode
= TRUE
;
761 pWnd
->state
&= ~WNDS_ANSIWINDOWPROC
;
762 pWnd
->state
|= WNDS_SERVERSIDEWINDOWPROC
;
766 pWnd
->Unicode
= !Ansi
;
767 // Handle the state change in here.
769 pWnd
->state
|= WNDS_ANSIWINDOWPROC
;
771 pWnd
->state
&= ~WNDS_ANSIWINDOWPROC
;
773 if (pWnd
->state
& WNDS_SERVERSIDEWINDOWPROC
)
774 pWnd
->state
&= ~WNDS_SERVERSIDEWINDOWPROC
;
776 if (!NewWndProc
) NewWndProc
= pWnd
->lpfnWndProc
;
778 if (Class
->fnid
<= FNID_GHOST
&& Class
->fnid
>= FNID_BUTTON
)
782 if (GETPFNCLIENTW(Class
->fnid
) == NewWndProc
)
783 chWndProc
= GETPFNCLIENTA(Class
->fnid
);
787 if (GETPFNCLIENTA(Class
->fnid
) == NewWndProc
)
788 chWndProc
= GETPFNCLIENTW(Class
->fnid
);
791 // Now set the new window proc.
792 pWnd
->lpfnWndProc
= (chWndProc
? chWndProc
: NewWndProc
);
798 /* INTERNAL ******************************************************************/
801 // This fixes a check for children messages that need paint while searching the parents messages!
802 // Fixes wine msg:test_paint_messages:WmParentErasePaint ..
805 IntIsChildWindow(PWND Parent
, PWND BaseWindow
)
807 PWND Window
= BaseWindow
;
810 if ( Window
== NULL
|| (Window
->style
& (WS_POPUP
|WS_CHILD
)) != WS_CHILD
)
813 Window
= Window
->spwndParent
;
815 while(Parent
!= Window
);
821 Link the window into siblings list
822 children and parent are kept in place.
827 PWND WndInsertAfter
/* set to NULL if top sibling */
830 if ((Wnd
->spwndPrev
= WndInsertAfter
))
832 /* link after WndInsertAfter */
833 if ((Wnd
->spwndNext
= WndInsertAfter
->spwndNext
))
834 Wnd
->spwndNext
->spwndPrev
= Wnd
;
836 Wnd
->spwndPrev
->spwndNext
= Wnd
;
841 if ((Wnd
->spwndNext
= Wnd
->spwndParent
->spwndChild
))
842 Wnd
->spwndNext
->spwndPrev
= Wnd
;
844 Wnd
->spwndParent
->spwndChild
= Wnd
;
849 Note: Wnd->spwndParent can be null if it is the desktop.
851 VOID FASTCALL
IntLinkHwnd(PWND Wnd
, HWND hWndPrev
)
853 if (hWndPrev
== HWND_NOTOPMOST
)
855 if (!(Wnd
->ExStyle
& WS_EX_TOPMOST
) &&
856 (Wnd
->ExStyle2
& WS_EX2_LINKED
)) return; /* nothing to do */
857 Wnd
->ExStyle
&= ~WS_EX_TOPMOST
;
858 hWndPrev
= HWND_TOP
; /* fallback to the HWND_TOP case */
861 IntUnlinkWindow(Wnd
); /* unlink it from the previous location */
863 if (hWndPrev
== HWND_BOTTOM
)
865 /* Link in the bottom of the list */
868 WndInsertAfter
= Wnd
->spwndParent
->spwndChild
;
869 while( WndInsertAfter
&& WndInsertAfter
->spwndNext
)
870 WndInsertAfter
= WndInsertAfter
->spwndNext
;
872 IntLinkWindow(Wnd
, WndInsertAfter
);
873 Wnd
->ExStyle
&= ~WS_EX_TOPMOST
;
875 else if (hWndPrev
== HWND_TOPMOST
)
877 /* Link in the top of the list */
878 IntLinkWindow(Wnd
, NULL
);
880 Wnd
->ExStyle
|= WS_EX_TOPMOST
;
882 else if (hWndPrev
== HWND_TOP
)
884 /* Link it after the last topmost window */
885 PWND WndInsertBefore
;
887 WndInsertBefore
= Wnd
->spwndParent
->spwndChild
;
889 if (!(Wnd
->ExStyle
& WS_EX_TOPMOST
)) /* put it above the first non-topmost window */
891 while (WndInsertBefore
!= NULL
&& WndInsertBefore
->spwndNext
!= NULL
)
893 if (!(WndInsertBefore
->ExStyle
& WS_EX_TOPMOST
)) break;
894 if (WndInsertBefore
== Wnd
->spwndOwner
) /* keep it above owner */
896 Wnd
->ExStyle
|= WS_EX_TOPMOST
;
899 WndInsertBefore
= WndInsertBefore
->spwndNext
;
903 IntLinkWindow(Wnd
, WndInsertBefore
? WndInsertBefore
->spwndPrev
: NULL
);
907 /* Link it after hWndPrev */
910 WndInsertAfter
= UserGetWindowObject(hWndPrev
);
911 /* Are we called with an erroneous handle */
912 if(WndInsertAfter
== NULL
)
914 /* Link in a default position */
915 IntLinkHwnd(Wnd
, HWND_TOP
);
919 IntLinkWindow(Wnd
, WndInsertAfter
);
921 /* Fix the WS_EX_TOPMOST flag */
922 if (!(WndInsertAfter
->ExStyle
& WS_EX_TOPMOST
))
924 Wnd
->ExStyle
&= ~WS_EX_TOPMOST
;
928 if(WndInsertAfter
->spwndNext
&&
929 WndInsertAfter
->spwndNext
->ExStyle
& WS_EX_TOPMOST
)
931 Wnd
->ExStyle
|= WS_EX_TOPMOST
;
935 Wnd
->ExStyle2
|= WS_EX2_LINKED
;
939 IntProcessOwnerSwap(PWND Wnd
, PWND WndNewOwner
, PWND WndOldOwner
)
943 if (Wnd
->head
.pti
!= WndOldOwner
->head
.pti
)
946 Wnd
->head
.pti
== WndNewOwner
->head
.pti
||
947 WndOldOwner
->head
.pti
!= WndNewOwner
->head
.pti
)
949 //ERR("ProcessOwnerSwap Old out.\n");
950 UserAttachThreadInput(Wnd
->head
.pti
, WndOldOwner
->head
.pti
, FALSE
);
956 if (Wnd
->head
.pti
!= WndNewOwner
->head
.pti
)
959 WndOldOwner
->head
.pti
!= WndNewOwner
->head
.pti
)
961 //ERR("ProcessOwnerSwap New in.\n");
962 UserAttachThreadInput(Wnd
->head
.pti
, WndNewOwner
->head
.pti
, TRUE
);
966 // FIXME: System Tray checks.
970 IntSetOwner(HWND hWnd
, HWND hWndNewOwner
)
972 PWND Wnd
, WndOldOwner
, WndNewOwner
;
975 Wnd
= IntGetWindowObject(hWnd
);
979 WndOldOwner
= Wnd
->spwndOwner
;
981 ret
= WndOldOwner
? UserHMGetHandle(WndOldOwner
) : 0;
982 WndNewOwner
= UserGetWindowObject(hWndNewOwner
);
984 if (!WndNewOwner
&& hWndNewOwner
)
986 EngSetLastError(ERROR_INVALID_PARAMETER
);
991 /* if parent belongs to a different thread and the window isn't */
992 /* top-level, attach the two threads */
993 IntProcessOwnerSwap(Wnd
, WndNewOwner
, WndOldOwner
);
995 if (IntValidateOwnerDepth(Wnd
, WndNewOwner
))
999 Wnd
->spwndOwner
= WndNewOwner
;
1003 Wnd
->spwndOwner
= NULL
;
1008 IntProcessOwnerSwap(Wnd
, WndOldOwner
, WndNewOwner
);
1009 EngSetLastError(ERROR_INVALID_PARAMETER
);
1013 UserDereferenceObject(Wnd
);
1018 co_IntSetParent(PWND Wnd
, PWND WndNewParent
)
1020 PWND WndOldParent
, pWndExam
;
1023 int swFlags
= SWP_NOSIZE
|SWP_NOZORDER
;
1026 ASSERT(WndNewParent
);
1027 ASSERT_REFS_CO(Wnd
);
1028 ASSERT_REFS_CO(WndNewParent
);
1030 if (Wnd
== Wnd
->head
.rpdesk
->spwndMessage
)
1032 EngSetLastError(ERROR_ACCESS_DENIED
);
1036 /* Some applications try to set a child as a parent */
1037 if (IntIsChildWindow(Wnd
, WndNewParent
))
1039 TRACE("IntSetParent try to set a child as a parent.\n");
1040 EngSetLastError( ERROR_INVALID_PARAMETER
);
1044 pWndExam
= WndNewParent
; // Load parent Window to examine.
1045 // Now test for set parent to parent hit.
1048 if (Wnd
== pWndExam
)
1050 TRACE("IntSetParent Failed Test for set parent to parent!\n");
1051 EngSetLastError(ERROR_INVALID_PARAMETER
);
1054 pWndExam
= pWndExam
->spwndParent
;
1058 * Windows hides the window first, then shows it again
1059 * including the WM_SHOWWINDOW messages and all
1061 WasVisible
= co_WinPosShowWindow(Wnd
, SW_HIDE
);
1063 /* Window must belong to current process */
1064 if (Wnd
->head
.pti
->ppi
!= PsGetCurrentProcessWin32Process())
1066 ERR("IntSetParent Window must belong to current process!\n");
1070 WndOldParent
= Wnd
->spwndParent
;
1072 if ( WndOldParent
&&
1073 WndOldParent
->ExStyle
& WS_EX_LAYOUTRTL
)
1074 pt
.x
= Wnd
->rcWindow
.right
;
1076 pt
.x
= Wnd
->rcWindow
.left
;
1077 pt
.y
= Wnd
->rcWindow
.top
;
1079 IntScreenToClient(WndOldParent
, &pt
);
1081 if (WndOldParent
) UserReferenceObject(WndOldParent
); /* Caller must deref */
1083 if (WndNewParent
!= WndOldParent
)
1085 /* Unlink the window from the siblings list */
1086 IntUnlinkWindow(Wnd
);
1087 Wnd
->ExStyle2
&= ~WS_EX2_LINKED
;
1089 /* Set the new parent */
1090 Wnd
->spwndParent
= WndNewParent
;
1092 if ( Wnd
->style
& WS_CHILD
&&
1094 Wnd
->spwndOwner
->ExStyle
& WS_EX_TOPMOST
)
1096 ERR("SetParent Top Most from Pop up!\n");
1097 Wnd
->ExStyle
|= WS_EX_TOPMOST
;
1100 /* Link the window with its new siblings */
1102 ((0 == (Wnd
->ExStyle
& WS_EX_TOPMOST
) &&
1103 WndNewParent
== UserGetDesktopWindow() ) ? HWND_TOP
: HWND_TOPMOST
) );
1107 if ( WndNewParent
== co_GetDesktopWindow(Wnd
) &&
1108 !(Wnd
->style
& WS_CLIPSIBLINGS
) )
1110 Wnd
->style
|= WS_CLIPSIBLINGS
;
1111 DceResetActiveDCEs(Wnd
);
1114 /* if parent belongs to a different thread and the window isn't */
1115 /* top-level, attach the two threads */
1116 if ((Wnd
->style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
)
1118 if ( Wnd
->spwndParent
!= co_GetDesktopWindow(Wnd
))
1120 if (WndOldParent
&& (Wnd
->head
.pti
!= WndOldParent
->head
.pti
))
1122 //ERR("SetParent Old out.\n");
1123 UserAttachThreadInput(Wnd
->head
.pti
, WndOldParent
->head
.pti
, FALSE
);
1126 if ( WndNewParent
!= co_GetDesktopWindow(Wnd
))
1128 if (Wnd
->head
.pti
!= WndNewParent
->head
.pti
)
1130 //ERR("SetParent New in.\n");
1131 UserAttachThreadInput(Wnd
->head
.pti
, WndNewParent
->head
.pti
, TRUE
);
1136 if (WndOldParent
== UserGetMessageWindow() || WndNewParent
== UserGetMessageWindow())
1137 swFlags
|= SWP_NOACTIVATE
;
1139 IntNotifyWinEvent(EVENT_OBJECT_PARENTCHANGE
, Wnd
,OBJID_WINDOW
, CHILDID_SELF
, WEF_SETBYWNDPTI
);
1141 * SetParent additionally needs to make hwnd the top window
1142 * in the z-order and send the expected WM_WINDOWPOSCHANGING and
1143 * WM_WINDOWPOSCHANGED notification messages.
1145 //ERR("IntSetParent SetWindowPos 1\n");
1146 co_WinPosSetWindowPos( Wnd
,
1147 (0 == (Wnd
->ExStyle
& WS_EX_TOPMOST
) ? HWND_TOP
: HWND_TOPMOST
),
1148 pt
.x
, pt
.y
, 0, 0, swFlags
);
1149 //ERR("IntSetParent SetWindowPos 2 X %d Y %d\n",pt.x, pt.y);
1150 if (WasVisible
) co_WinPosShowWindow(Wnd
, SW_SHOWNORMAL
);
1152 return WndOldParent
;
1156 co_UserSetParent(HWND hWndChild
, HWND hWndNewParent
)
1158 PWND Wnd
= NULL
, WndParent
= NULL
, WndOldParent
;
1159 HWND hWndOldParent
= NULL
;
1160 USER_REFERENCE_ENTRY Ref
, ParentRef
;
1162 if (IntIsBroadcastHwnd(hWndChild
) || IntIsBroadcastHwnd(hWndNewParent
))
1164 EngSetLastError(ERROR_INVALID_PARAMETER
);
1168 if (hWndChild
== IntGetDesktopWindow())
1170 ERR("UserSetParent Access Denied!\n");
1171 EngSetLastError(ERROR_ACCESS_DENIED
);
1177 if (!(WndParent
= UserGetWindowObject(hWndNewParent
)))
1179 ERR("UserSetParent Bad New Parent!\n");
1185 if (!(WndParent
= UserGetWindowObject(IntGetDesktopWindow())))
1191 if (!(Wnd
= UserGetWindowObject(hWndChild
)))
1193 ERR("UserSetParent Bad Child!\n");
1197 UserRefObjectCo(Wnd
, &Ref
);
1198 UserRefObjectCo(WndParent
, &ParentRef
);
1199 //ERR("Enter co_IntSetParent\n");
1200 WndOldParent
= co_IntSetParent(Wnd
, WndParent
);
1201 //ERR("Leave co_IntSetParent\n");
1202 UserDerefObjectCo(WndParent
);
1203 UserDerefObjectCo(Wnd
);
1207 hWndOldParent
= WndOldParent
->head
.h
;
1208 UserDereferenceObject(WndOldParent
);
1211 return( hWndOldParent
);
1214 /* Unlink the window from siblings. children and parent are kept in place. */
1216 IntUnlinkWindow(PWND Wnd
)
1219 Wnd
->spwndNext
->spwndPrev
= Wnd
->spwndPrev
;
1222 Wnd
->spwndPrev
->spwndNext
= Wnd
->spwndNext
;
1224 if (Wnd
->spwndParent
&& Wnd
->spwndParent
->spwndChild
== Wnd
)
1225 Wnd
->spwndParent
->spwndChild
= Wnd
->spwndNext
;
1227 Wnd
->spwndPrev
= Wnd
->spwndNext
= NULL
;
1230 /* FUNCTIONS *****************************************************************/
1233 * As best as I can figure, this function is used by EnumWindows,
1234 * EnumChildWindows, EnumDesktopWindows, & EnumThreadWindows.
1236 * It's supposed to build a list of HWNDs to return to the caller.
1237 * We can figure out what kind of list by what parameters are
1245 NtUserBuildHwndList(
1258 return ERROR_INVALID_PARAMETER
;
1260 if (hwndParent
|| !dwThreadId
)
1263 PWND Parent
, Window
;
1267 if(hDesktop
== NULL
&& !(Desktop
= IntGetActiveDesktop()))
1269 return ERROR_INVALID_HANDLE
;
1274 Status
= IntValidateDesktopHandle(hDesktop
,
1278 if(!NT_SUCCESS(Status
))
1280 return ERROR_INVALID_HANDLE
;
1283 hwndParent
= Desktop
->DesktopWindow
;
1290 if((Parent
= UserGetWindowObject(hwndParent
)) &&
1291 (Window
= Parent
->spwndChild
))
1293 BOOL bGoDown
= TRUE
;
1295 Status
= STATUS_SUCCESS
;
1300 if(dwCount
++ < *pBufSize
&& pWnd
)
1304 ProbeForWrite(pWnd
, sizeof(HWND
), 1);
1305 *pWnd
= Window
->head
.h
;
1308 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1310 Status
= _SEH2_GetExceptionCode();
1313 if(!NT_SUCCESS(Status
))
1315 SetLastNtError(Status
);
1319 if (Window
->spwndChild
&& bChildren
)
1321 Window
= Window
->spwndChild
;
1326 if (Window
->spwndNext
)
1328 Window
= Window
->spwndNext
;
1332 Window
= Window
->spwndParent
;
1333 if (Window
== Parent
)
1342 ObDereferenceObject(Desktop
);
1345 else // Build EnumThreadWindows list!
1348 PTHREADINFO W32Thread
;
1352 Status
= PsLookupThreadByThreadId((HANDLE
)dwThreadId
, &Thread
);
1353 if (!NT_SUCCESS(Status
))
1355 ERR("Thread Id is not valid!\n");
1356 return ERROR_INVALID_PARAMETER
;
1358 if (!(W32Thread
= (PTHREADINFO
)Thread
->Tcb
.Win32Thread
))
1360 ObDereferenceObject(Thread
);
1361 TRACE("Tried to enumerate windows of a non gui thread\n");
1362 return ERROR_INVALID_PARAMETER
;
1365 // Do not use Thread link list due to co_UserFreeWindow!!!
1366 // Current = W32Thread->WindowListHead.Flink;
1367 // Fixes Api:CreateWindowEx tests!!!
1368 List
= IntWinListChildren(UserGetDesktopWindow());
1372 for (i
= 0; List
[i
]; i
++)
1374 Window
= ValidateHwndNoErr(List
[i
]);
1375 if (Window
&& Window
->head
.pti
== W32Thread
)
1377 if (dwCount
< *pBufSize
&& pWnd
)
1381 ProbeForWrite(pWnd
, sizeof(HWND
), 1);
1382 *pWnd
= Window
->head
.h
;
1385 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1387 Status
= _SEH2_GetExceptionCode();
1390 if (!NT_SUCCESS(Status
))
1392 ERR("Failure to build window list!\n");
1393 SetLastNtError(Status
);
1400 ExFreePoolWithTag(List
, USERTAG_WINDOWLIST
);
1403 ObDereferenceObject(Thread
);
1406 *pBufSize
= dwCount
;
1407 return STATUS_SUCCESS
;
1410 static void IntSendParentNotify( PWND pWindow
, UINT msg
)
1412 if ( (pWindow
->style
& (WS_CHILD
| WS_POPUP
)) == WS_CHILD
&&
1413 !(pWindow
->ExStyle
& WS_EX_NOPARENTNOTIFY
))
1415 if (VerifyWnd(pWindow
->spwndParent
) && pWindow
->spwndParent
!= UserGetDesktopWindow())
1417 USER_REFERENCE_ENTRY Ref
;
1418 UserRefObjectCo(pWindow
->spwndParent
, &Ref
);
1419 co_IntSendMessage( pWindow
->spwndParent
->head
.h
,
1421 MAKEWPARAM( msg
, pWindow
->IDMenu
),
1422 (LPARAM
)pWindow
->head
.h
);
1423 UserDerefObjectCo(pWindow
->spwndParent
);
1429 IntFixWindowCoordinates(CREATESTRUCTW
* Cs
, PWND ParentWindow
, DWORD
* dwShowMode
)
1431 #define IS_DEFAULT(x) ((x) == CW_USEDEFAULT || (x) == (SHORT)0x8000)
1433 /* default positioning for overlapped windows */
1434 if(!(Cs
->style
& (WS_POPUP
| WS_CHILD
)))
1437 PRTL_USER_PROCESS_PARAMETERS ProcessParams
;
1439 pMonitor
= UserGetPrimaryMonitor();
1441 /* Check if we don't have a monitor attached yet */
1442 if(pMonitor
== NULL
)
1450 ProcessParams
= PsGetCurrentProcess()->Peb
->ProcessParameters
;
1452 if (IS_DEFAULT(Cs
->x
))
1454 if (!IS_DEFAULT(Cs
->y
)) *dwShowMode
= Cs
->y
;
1456 if(ProcessParams
->WindowFlags
& STARTF_USEPOSITION
)
1458 Cs
->x
= ProcessParams
->StartingX
;
1459 Cs
->y
= ProcessParams
->StartingY
;
1463 Cs
->x
= pMonitor
->cWndStack
* (UserGetSystemMetrics(SM_CXSIZE
) + UserGetSystemMetrics(SM_CXFRAME
));
1464 Cs
->y
= pMonitor
->cWndStack
* (UserGetSystemMetrics(SM_CYSIZE
) + UserGetSystemMetrics(SM_CYFRAME
));
1465 if (Cs
->x
> ((pMonitor
->rcWork
.right
- pMonitor
->rcWork
.left
) / 4) ||
1466 Cs
->y
> ((pMonitor
->rcWork
.bottom
- pMonitor
->rcWork
.top
) / 4))
1468 /* reset counter and position */
1471 pMonitor
->cWndStack
= 0;
1473 pMonitor
->cWndStack
++;
1477 if (IS_DEFAULT(Cs
->cx
))
1479 if (ProcessParams
->WindowFlags
& STARTF_USEPOSITION
)
1481 Cs
->cx
= ProcessParams
->CountX
;
1482 Cs
->cy
= ProcessParams
->CountY
;
1486 Cs
->cx
= (pMonitor
->rcWork
.right
- pMonitor
->rcWork
.left
) * 3 / 4;
1487 Cs
->cy
= (pMonitor
->rcWork
.bottom
- pMonitor
->rcWork
.top
) * 3 / 4;
1490 /* neither x nor cx are default. Check the y values .
1491 * In the trace we see Outlook and Outlook Express using
1492 * cy set to CW_USEDEFAULT when opening the address book.
1494 else if (IS_DEFAULT(Cs
->cy
))
1496 TRACE("Strange use of CW_USEDEFAULT in nHeight\n");
1497 Cs
->cy
= (pMonitor
->rcWork
.bottom
- pMonitor
->rcWork
.top
) * 3 / 4;
1502 /* if CW_USEDEFAULT is set for non-overlapped windows, both values are set to zero */
1503 if(IS_DEFAULT(Cs
->x
))
1508 if(IS_DEFAULT(Cs
->cx
))
1518 /* Allocates and initializes a window */
1519 PWND FASTCALL
IntCreateWindow(CREATESTRUCTW
* Cs
,
1520 PLARGE_STRING WindowName
,
1525 PDESKTOP pdeskCreated
)
1529 PTHREADINFO pti
= NULL
;
1531 BOOL bUnicodeWindow
;
1533 pti
= pdeskCreated
? gptiDesktopThread
: GetW32ThreadInfo();
1535 if (!(Cs
->dwExStyle
& WS_EX_LAYOUTRTL
))
1536 { // Need both here for wine win.c test_CreateWindow.
1537 //if (Cs->hwndParent && ParentWindow)
1538 if (ParentWindow
) // It breaks more tests..... WIP.
1540 if ( (Cs
->style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
&&
1541 ParentWindow
->ExStyle
& WS_EX_LAYOUTRTL
&&
1542 !(ParentWindow
->ExStyle
& WS_EX_NOINHERITLAYOUT
) )
1543 Cs
->dwExStyle
|= WS_EX_LAYOUTRTL
;
1547 * Note from MSDN <http://msdn.microsoft.com/en-us/library/aa913269.aspx>:
1549 * Dialog boxes and message boxes do not inherit layout, so you must
1550 * set the layout explicitly.
1552 if ( Class
->fnid
!= FNID_DIALOG
)
1554 if (pti
->ppi
->dwLayout
& LAYOUT_RTL
)
1556 Cs
->dwExStyle
|= WS_EX_LAYOUTRTL
;
1562 /* Automatically add WS_EX_WINDOWEDGE */
1563 if ((Cs
->dwExStyle
& WS_EX_DLGMODALFRAME
) ||
1564 ((!(Cs
->dwExStyle
& WS_EX_STATICEDGE
)) &&
1565 (Cs
->style
& (WS_DLGFRAME
| WS_THICKFRAME
))))
1566 Cs
->dwExStyle
|= WS_EX_WINDOWEDGE
;
1568 Cs
->dwExStyle
&= ~WS_EX_WINDOWEDGE
;
1570 /* Is it a unicode window? */
1571 bUnicodeWindow
=!(Cs
->dwExStyle
& WS_EX_SETANSICREATOR
);
1572 Cs
->dwExStyle
&= ~WS_EX_SETANSICREATOR
;
1574 /* Allocate the new window */
1575 pWnd
= (PWND
) UserCreateObject( gHandleTable
,
1576 pdeskCreated
? pdeskCreated
: pti
->rpdesk
,
1580 sizeof(WND
) + Class
->cbwndExtra
);
1587 TRACE("Created window object with handle %p\n", hWnd
);
1589 if (pdeskCreated
&& pdeskCreated
->DesktopWindow
== NULL
)
1590 { /* HACK: Helper for win32csr/desktopbg.c */
1591 /* If there is no desktop window yet, we must be creating it */
1592 TRACE("CreateWindow setting desktop.\n");
1593 pdeskCreated
->DesktopWindow
= hWnd
;
1594 pdeskCreated
->pDeskInfo
->spwnd
= pWnd
;
1598 * Fill out the structure describing it.
1600 /* Remember, pWnd->head is setup in object.c ... */
1601 pWnd
->spwndParent
= ParentWindow
;
1602 pWnd
->spwndOwner
= OwnerWindow
;
1604 pWnd
->spwndLastActive
= pWnd
;
1605 pWnd
->state2
|= WNDS2_WIN40COMPAT
; // FIXME!!!
1607 pWnd
->hModule
= Cs
->hInstance
;
1608 pWnd
->style
= Cs
->style
& ~WS_VISIBLE
;
1609 pWnd
->ExStyle
= Cs
->dwExStyle
;
1610 pWnd
->cbwndExtra
= pWnd
->pcls
->cbwndExtra
;
1611 pWnd
->pActCtx
= acbiBuffer
;
1612 pWnd
->InternalPos
.MaxPos
.x
= pWnd
->InternalPos
.MaxPos
.y
= -1;
1613 pWnd
->InternalPos
.IconPos
.x
= pWnd
->InternalPos
.IconPos
.y
= -1;
1615 if (pWnd
->spwndParent
!= NULL
&& Cs
->hwndParent
!= 0)
1617 pWnd
->HideFocus
= pWnd
->spwndParent
->HideFocus
;
1618 pWnd
->HideAccel
= pWnd
->spwndParent
->HideAccel
;
1621 pWnd
->head
.pti
->cWindows
++;
1623 if (Class
->spicn
&& !Class
->spicnSm
)
1625 HICON IconSmHandle
= NULL
;
1626 if((Class
->spicn
->CURSORF_flags
& (CURSORF_LRSHARED
| CURSORF_FROMRESOURCE
))
1627 == (CURSORF_LRSHARED
| CURSORF_FROMRESOURCE
))
1629 IconSmHandle
= co_IntCopyImage(
1630 UserHMGetHandle(Class
->spicn
),
1632 UserGetSystemMetrics( SM_CXSMICON
),
1633 UserGetSystemMetrics( SM_CYSMICON
),
1634 LR_COPYFROMRESOURCE
);
1638 /* Retry without copying from resource */
1639 IconSmHandle
= co_IntCopyImage(
1640 UserHMGetHandle(Class
->spicn
),
1642 UserGetSystemMetrics( SM_CXSMICON
),
1643 UserGetSystemMetrics( SM_CYSMICON
),
1649 Class
->spicnSm
= UserGetCurIconObject(IconSmHandle
);
1650 Class
->CSF_flags
|= CSF_CACHEDSMICON
;
1654 if (pWnd
->pcls
->CSF_flags
& CSF_SERVERSIDEPROC
)
1655 pWnd
->state
|= WNDS_SERVERSIDEWINDOWPROC
;
1657 /* BugBoy Comments: Comment below say that System classes are always created
1658 as UNICODE. In windows, creating a window with the ANSI version of CreateWindow
1659 sets the window to ansi as verified by testing with IsUnicodeWindow API.
1661 No where can I see in code or through testing does the window change back
1662 to ANSI after being created as UNICODE in ROS. I didnt do more testing to
1663 see what problems this would cause. */
1665 // Set WndProc from Class.
1666 pWnd
->lpfnWndProc
= pWnd
->pcls
->lpfnWndProc
;
1668 // GetWindowProc, test for non server side default classes and set WndProc.
1669 if ( pWnd
->pcls
->fnid
<= FNID_GHOST
&& pWnd
->pcls
->fnid
>= FNID_BUTTON
)
1673 if (GETPFNCLIENTA(pWnd
->pcls
->fnid
) == pWnd
->lpfnWndProc
)
1674 pWnd
->lpfnWndProc
= GETPFNCLIENTW(pWnd
->pcls
->fnid
);
1678 if (GETPFNCLIENTW(pWnd
->pcls
->fnid
) == pWnd
->lpfnWndProc
)
1679 pWnd
->lpfnWndProc
= GETPFNCLIENTA(pWnd
->pcls
->fnid
);
1683 // If not an Unicode caller, set Ansi creator bit.
1684 if (!bUnicodeWindow
) pWnd
->state
|= WNDS_ANSICREATOR
;
1686 // Clone Class Ansi/Unicode proc type.
1687 if (pWnd
->pcls
->CSF_flags
& CSF_ANSIPROC
)
1689 pWnd
->state
|= WNDS_ANSIWINDOWPROC
;
1690 pWnd
->Unicode
= FALSE
;
1694 * It seems there can be both an Ansi creator and Unicode Class Window
1695 * WndProc, unless the following overriding conditions occur:
1697 if ( !bUnicodeWindow
&&
1698 ( Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_BUTTON
] ||
1699 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_COMBOBOX
] ||
1700 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_COMBOLBOX
] ||
1701 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_DIALOG
] ||
1702 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_EDIT
] ||
1703 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_IME
] ||
1704 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_LISTBOX
] ||
1705 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_MDICLIENT
] ||
1706 Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_STATIC
] ) )
1707 { // Override Class and set the window Ansi WndProc.
1708 pWnd
->state
|= WNDS_ANSIWINDOWPROC
;
1709 pWnd
->Unicode
= FALSE
;
1712 { // Set the window Unicode WndProc.
1713 pWnd
->state
&= ~WNDS_ANSIWINDOWPROC
;
1714 pWnd
->Unicode
= TRUE
;
1718 /* BugBoy Comments: if the window being created is a edit control, ATOM 0xCxxx,
1719 then my testing shows that windows (2k and XP) creates a CallProc for it immediately
1720 Dont understand why it does this. */
1721 if (Class
->atomClassName
== gpsi
->atomSysClass
[ICLS_EDIT
])
1723 PCALLPROCDATA CallProc
;
1724 CallProc
= CreateCallProc(pWnd
->head
.rpdesk
, pWnd
->lpfnWndProc
, pWnd
->Unicode
, pWnd
->head
.pti
->ppi
);
1728 EngSetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1729 ERR("Warning: Unable to create CallProc for edit control. Control may not operate correctly! hwnd %p\n", hWnd
);
1733 UserAddCallProcToClass(pWnd
->pcls
, CallProc
);
1737 InitializeListHead(&pWnd
->PropListHead
);
1738 pWnd
->PropListItems
= 0;
1740 if ( WindowName
->Buffer
!= NULL
&& WindowName
->Length
> 0 )
1742 pWnd
->strName
.Buffer
= DesktopHeapAlloc(pWnd
->head
.rpdesk
,
1743 WindowName
->Length
+ sizeof(UNICODE_NULL
));
1744 if (pWnd
->strName
.Buffer
== NULL
)
1749 RtlCopyMemory(pWnd
->strName
.Buffer
, WindowName
->Buffer
, WindowName
->Length
);
1750 pWnd
->strName
.Buffer
[WindowName
->Length
/ sizeof(WCHAR
)] = L
'\0';
1751 pWnd
->strName
.Length
= WindowName
->Length
;
1752 pWnd
->strName
.MaximumLength
= WindowName
->Length
+ sizeof(UNICODE_NULL
);
1755 /* Correct the window style. */
1756 if ((pWnd
->style
& (WS_CHILD
| WS_POPUP
)) != WS_CHILD
)
1758 pWnd
->style
|= WS_CLIPSIBLINGS
;
1759 if (!(pWnd
->style
& WS_POPUP
))
1761 pWnd
->style
|= WS_CAPTION
;
1765 /* WS_EX_WINDOWEDGE depends on some other styles */
1766 if (pWnd
->ExStyle
& WS_EX_DLGMODALFRAME
)
1767 pWnd
->ExStyle
|= WS_EX_WINDOWEDGE
;
1768 else if (pWnd
->style
& (WS_DLGFRAME
| WS_THICKFRAME
))
1770 if (!((pWnd
->ExStyle
& WS_EX_STATICEDGE
) &&
1771 (pWnd
->style
& (WS_CHILD
| WS_POPUP
))))
1772 pWnd
->ExStyle
|= WS_EX_WINDOWEDGE
;
1775 pWnd
->ExStyle
&= ~WS_EX_WINDOWEDGE
;
1777 if (!(pWnd
->style
& (WS_CHILD
| WS_POPUP
)))
1778 pWnd
->state
|= WNDS_SENDSIZEMOVEMSGS
;
1780 /* Set the window menu */
1781 if ((Cs
->style
& (WS_CHILD
| WS_POPUP
)) != WS_CHILD
)
1785 IntSetMenu(pWnd
, Cs
->hMenu
, &MenuChanged
);
1787 else if (pWnd
->pcls
->lpszMenuName
) // Take it from the parent.
1789 UNICODE_STRING MenuName
;
1792 if (IS_INTRESOURCE(pWnd
->pcls
->lpszMenuName
))
1794 MenuName
.Length
= 0;
1795 MenuName
.MaximumLength
= 0;
1796 MenuName
.Buffer
= pWnd
->pcls
->lpszMenuName
;
1800 RtlInitUnicodeString( &MenuName
, pWnd
->pcls
->lpszMenuName
);
1802 hMenu
= co_IntCallLoadMenu( pWnd
->pcls
->hModule
, &MenuName
);
1803 if (hMenu
) IntSetMenu(pWnd
, hMenu
, &MenuChanged
);
1807 pWnd
->IDMenu
= (UINT
) Cs
->hMenu
;
1810 if ( ParentWindow
&&
1811 ParentWindow
!= ParentWindow
->head
.rpdesk
->spwndMessage
&&
1812 ParentWindow
!= ParentWindow
->head
.rpdesk
->pDeskInfo
->spwnd
)
1814 PWND Owner
= IntGetNonChildAncestor(ParentWindow
);
1816 if (!IntValidateOwnerDepth(pWnd
, Owner
))
1818 EngSetLastError(ERROR_INVALID_PARAMETER
);
1821 if ( pWnd
->spwndOwner
&&
1822 pWnd
->spwndOwner
->ExStyle
& WS_EX_TOPMOST
)
1824 pWnd
->ExStyle
|= WS_EX_TOPMOST
;
1826 if ( pWnd
->spwndOwner
&&
1827 Class
->atomClassName
!= gpsi
->atomSysClass
[ICLS_IME
] &&
1828 pti
!= pWnd
->spwndOwner
->head
.pti
)
1830 //ERR("CreateWindow Owner in.\n");
1831 UserAttachThreadInput(pti
, pWnd
->spwndOwner
->head
.pti
, TRUE
);
1835 /* Insert the window into the thread's window list. */
1836 InsertTailList (&pti
->WindowListHead
, &pWnd
->ThreadListEntry
);
1838 /* Handle "CS_CLASSDC", it is tested first. */
1839 if ( (pWnd
->pcls
->style
& CS_CLASSDC
) && !(pWnd
->pcls
->pdce
) )
1840 { /* One DCE per class to have CLASS. */
1841 pWnd
->pcls
->pdce
= DceAllocDCE( pWnd
, DCE_CLASS_DC
);
1843 else if ( pWnd
->pcls
->style
& CS_OWNDC
)
1844 { /* Allocate a DCE for this window. */
1845 DceAllocDCE(pWnd
, DCE_WINDOW_DC
);
1851 ERR("IntCreateWindow Allocation Error.\n");
1852 SetLastNtError(STATUS_INSUFFICIENT_RESOURCES
);
1855 UserDereferenceObject(pWnd
);
1863 co_UserCreateWindowEx(CREATESTRUCTW
* Cs
,
1864 PUNICODE_STRING ClassName
,
1865 PLARGE_STRING WindowName
,
1869 PWND Window
= NULL
, ParentWindow
= NULL
, OwnerWindow
;
1870 HWND hWnd
, hWndParent
, hWndOwner
, hwndInsertAfter
;
1871 PWINSTATION_OBJECT WinSta
;
1874 POINT MaxSize
, MaxPos
, MinTrack
, MaxTrack
;
1875 CBT_CREATEWNDW
* pCbtCreate
;
1877 USER_REFERENCE_ENTRY ParentRef
, Ref
;
1879 DWORD dwShowMode
= SW_SHOW
;
1880 CREATESTRUCTW
*pCsw
= NULL
;
1881 PVOID pszClass
= NULL
, pszName
= NULL
;
1884 /* Get the current window station and reference it */
1885 pti
= GetW32ThreadInfo();
1886 if (pti
== NULL
|| pti
->rpdesk
== NULL
)
1888 ERR("Thread is not attached to a desktop! Cannot create window!\n");
1889 return NULL
; // There is nothing to cleanup.
1891 WinSta
= pti
->rpdesk
->rpwinstaParent
;
1892 ObReferenceObjectByPointer(WinSta
, KernelMode
, ExWindowStationObjectType
, 0);
1897 /* Get the class and reference it */
1898 Class
= IntGetAndReferenceClass(ClassName
, Cs
->hInstance
, FALSE
);
1901 ERR("Failed to find class %wZ\n", ClassName
);
1905 /* Now find the parent and the owner window */
1906 hWndParent
= pti
->rpdesk
->pDeskInfo
->spwnd
->head
.h
;
1909 if (Cs
->hwndParent
== HWND_MESSAGE
)
1911 Cs
->hwndParent
= hWndParent
= pti
->rpdesk
->spwndMessage
->head
.h
;
1913 else if (Cs
->hwndParent
)
1915 if ((Cs
->style
& (WS_CHILD
|WS_POPUP
)) != WS_CHILD
)
1916 hWndOwner
= Cs
->hwndParent
;
1918 hWndParent
= Cs
->hwndParent
;
1920 else if ((Cs
->style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
)
1922 ERR("Cannot create a child window without a parrent!\n");
1923 EngSetLastError(ERROR_TLW_WITH_WSCHILD
);
1924 goto cleanup
; /* WS_CHILD needs a parent, but WS_POPUP doesn't */
1927 ParentWindow
= hWndParent
? UserGetWindowObject(hWndParent
): NULL
;
1928 OwnerWindow
= hWndOwner
? UserGetWindowObject(hWndOwner
): NULL
;
1930 /* FIXME: Is this correct? */
1932 OwnerWindow
= UserGetAncestor(OwnerWindow
, GA_ROOT
);
1934 /* Fix the position and the size of the window */
1937 UserRefObjectCo(ParentWindow
, &ParentRef
);
1938 IntFixWindowCoordinates(Cs
, ParentWindow
, &dwShowMode
);
1941 /* Allocate and initialize the new window */
1942 Window
= IntCreateWindow(Cs
,
1951 ERR("IntCreateWindow failed!\n");
1955 hWnd
= UserHMGetHandle(Window
);
1956 hwndInsertAfter
= HWND_TOP
;
1958 UserRefObjectCo(Window
, &Ref
);
1959 UserDereferenceObject(Window
);
1960 ObDereferenceObject(WinSta
);
1962 //// Check for a hook to eliminate overhead. ////
1963 if ( ISITHOOKED(WH_CBT
) || (pti
->rpdesk
->pDeskInfo
->fsHooks
& HOOKID_TO_FLAG(WH_CBT
)) )
1965 // Allocate the calling structures Justin Case this goes Global.
1966 pCsw
= ExAllocatePoolWithTag(NonPagedPool
, sizeof(CREATESTRUCTW
), TAG_HOOK
);
1967 pCbtCreate
= ExAllocatePoolWithTag(NonPagedPool
, sizeof(CBT_CREATEWNDW
), TAG_HOOK
);
1968 if (!pCsw
|| !pCbtCreate
)
1970 ERR("UserHeapAlloc() failed!\n");
1974 /* Fill the new CREATESTRUCTW */
1975 RtlCopyMemory(pCsw
, Cs
, sizeof(CREATESTRUCTW
));
1976 pCsw
->style
= Window
->style
; /* HCBT_CREATEWND needs the real window style */
1978 // Based on the assumption this is from "unicode source" user32, ReactOS, answer is yes.
1979 if (!IS_ATOM(ClassName
->Buffer
))
1981 if (Window
->state
& WNDS_ANSICREATOR
)
1983 ANSI_STRING AnsiString
;
1984 AnsiString
.MaximumLength
= (USHORT
)RtlUnicodeStringToAnsiSize(ClassName
)+sizeof(CHAR
);
1985 pszClass
= UserHeapAlloc(AnsiString
.MaximumLength
);
1988 ERR("UserHeapAlloc() failed!\n");
1991 RtlZeroMemory(pszClass
, AnsiString
.MaximumLength
);
1992 AnsiString
.Buffer
= (PCHAR
)pszClass
;
1993 RtlUnicodeStringToAnsiString(&AnsiString
, ClassName
, FALSE
);
1997 UNICODE_STRING UnicodeString
;
1998 UnicodeString
.MaximumLength
= ClassName
->Length
+ sizeof(UNICODE_NULL
);
1999 pszClass
= UserHeapAlloc(UnicodeString
.MaximumLength
);
2002 ERR("UserHeapAlloc() failed!\n");
2005 RtlZeroMemory(pszClass
, UnicodeString
.MaximumLength
);
2006 UnicodeString
.Buffer
= (PWSTR
)pszClass
;
2007 RtlCopyUnicodeString(&UnicodeString
, ClassName
);
2009 pCsw
->lpszClass
= UserHeapAddressToUser(pszClass
);
2011 if (WindowName
->Length
)
2013 UNICODE_STRING Name
;
2014 Name
.Buffer
= WindowName
->Buffer
;
2015 Name
.Length
= (USHORT
)min(WindowName
->Length
, MAXUSHORT
); // FIXME: LARGE_STRING truncated
2016 Name
.MaximumLength
= (USHORT
)min(WindowName
->MaximumLength
, MAXUSHORT
);
2018 if (Window
->state
& WNDS_ANSICREATOR
)
2020 ANSI_STRING AnsiString
;
2021 AnsiString
.MaximumLength
= (USHORT
)RtlUnicodeStringToAnsiSize(&Name
) + sizeof(CHAR
);
2022 pszName
= UserHeapAlloc(AnsiString
.MaximumLength
);
2025 ERR("UserHeapAlloc() failed!\n");
2028 RtlZeroMemory(pszName
, AnsiString
.MaximumLength
);
2029 AnsiString
.Buffer
= (PCHAR
)pszName
;
2030 RtlUnicodeStringToAnsiString(&AnsiString
, &Name
, FALSE
);
2034 UNICODE_STRING UnicodeString
;
2035 UnicodeString
.MaximumLength
= Name
.Length
+ sizeof(UNICODE_NULL
);
2036 pszName
= UserHeapAlloc(UnicodeString
.MaximumLength
);
2039 ERR("UserHeapAlloc() failed!\n");
2042 RtlZeroMemory(pszName
, UnicodeString
.MaximumLength
);
2043 UnicodeString
.Buffer
= (PWSTR
)pszName
;
2044 RtlCopyUnicodeString(&UnicodeString
, &Name
);
2046 pCsw
->lpszName
= UserHeapAddressToUser(pszName
);
2049 pCbtCreate
->lpcs
= pCsw
;
2050 pCbtCreate
->hwndInsertAfter
= hwndInsertAfter
;
2052 //// Call the WH_CBT hook ////
2053 Result
= co_HOOK_CallHooks(WH_CBT
, HCBT_CREATEWND
, (WPARAM
) hWnd
, (LPARAM
) pCbtCreate
);
2056 ERR("WH_CBT HCBT_CREATEWND hook failed! 0x%x\n", Result
);
2059 // Write back changes.
2064 hwndInsertAfter
= pCbtCreate
->hwndInsertAfter
;
2067 /* NCCREATE and WM_NCCALCSIZE need the original values */
2068 Cs
->lpszName
= (LPCWSTR
) WindowName
;
2069 Cs
->lpszClass
= (LPCWSTR
) ClassName
;
2071 if ((Cs
->style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
)
2073 if (ParentWindow
!= co_GetDesktopWindow(Window
))
2075 Cs
->x
+= ParentWindow
->rcClient
.left
;
2076 Cs
->y
+= ParentWindow
->rcClient
.top
;
2080 /* Send the WM_GETMINMAXINFO message */
2084 if ((Cs
->style
& WS_THICKFRAME
) || !(Cs
->style
& (WS_POPUP
| WS_CHILD
)))
2086 co_WinPosGetMinMaxInfo(Window
, &MaxSize
, &MaxPos
, &MinTrack
, &MaxTrack
);
2087 if (Size
.cx
> MaxTrack
.x
) Size
.cx
= MaxTrack
.x
;
2088 if (Size
.cy
> MaxTrack
.y
) Size
.cy
= MaxTrack
.y
;
2089 if (Size
.cx
< MinTrack
.x
) Size
.cx
= MinTrack
.x
;
2090 if (Size
.cy
< MinTrack
.y
) Size
.cy
= MinTrack
.y
;
2093 Window
->rcWindow
.left
= Cs
->x
;
2094 Window
->rcWindow
.top
= Cs
->y
;
2095 Window
->rcWindow
.right
= Cs
->x
+ Size
.cx
;
2096 Window
->rcWindow
.bottom
= Cs
->y
+ Size
.cy
;
2098 if (0 != (Window->style & WS_CHILD) && ParentWindow)
2100 ERR("co_UserCreateWindowEx(): Offset rcWindow\n");
2101 RECTL_vOffsetRect(&Window->rcWindow,
2102 ParentWindow->rcClient.left,
2103 ParentWindow->rcClient.top);
2106 /* correct child window coordinates if mirroring on parent is enabled */
2107 if (ParentWindow
!= NULL
)
2109 if ( ((Cs
->style
& WS_CHILD
) == WS_CHILD
) &&
2110 ((ParentWindow
->ExStyle
& WS_EX_LAYOUTRTL
) == WS_EX_LAYOUTRTL
))
2112 Window
->rcWindow
.right
= ParentWindow
->rcClient
.right
- (Window
->rcWindow
.left
- ParentWindow
->rcClient
.left
);
2113 Window
->rcWindow
.left
= Window
->rcWindow
.right
- Size
.cx
;
2117 Window
->rcClient
= Window
->rcWindow
;
2119 /* Link the window */
2120 if (NULL
!= ParentWindow
)
2122 /* Link the window into the siblings list */
2123 if ((Cs
->style
& (WS_CHILD
|WS_MAXIMIZE
)) == WS_CHILD
)
2124 IntLinkHwnd(Window
, HWND_BOTTOM
);
2126 IntLinkHwnd(Window
, hwndInsertAfter
);
2129 if (!(Window
->state2
& WNDS2_WIN31COMPAT
))
2131 if (Class
->style
& CS_PARENTDC
&& !(ParentWindow
->style
& WS_CLIPCHILDREN
))
2132 Window
->style
&= ~(WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
);
2135 if ((Window
->style
& (WS_CHILD
| WS_POPUP
)) == WS_CHILD
)
2137 if ( !IntIsTopLevelWindow(Window
) )
2139 if (pti
!= Window
->spwndParent
->head
.pti
)
2141 //ERR("CreateWindow Parent in.\n");
2142 UserAttachThreadInput(pti
, Window
->spwndParent
->head
.pti
, TRUE
);
2147 /* Send the NCCREATE message */
2148 Result
= co_IntSendMessage(UserHMGetHandle(Window
), WM_NCCREATE
, 0, (LPARAM
) Cs
);
2151 ERR("co_UserCreateWindowEx(): NCCREATE message failed\n");
2155 /* Send the WM_NCCALCSIZE message */
2158 MaxPos
.x
= Window
->rcWindow
.left
;
2159 MaxPos
.y
= Window
->rcWindow
.top
;
2161 Result
= co_WinPosGetNonClientSize(Window
, &Window
->rcWindow
, &Window
->rcClient
);
2162 //rc = Window->rcWindow;
2163 //Result = co_IntSendMessageNoWait(Window->head.h, WM_NCCALCSIZE, FALSE, (LPARAM)&rc);
2164 //Window->rcClient = rc;
2166 RECTL_vOffsetRect(&Window
->rcWindow
, MaxPos
.x
- Window
->rcWindow
.left
,
2167 MaxPos
.y
- Window
->rcWindow
.top
);
2170 /* Send the WM_CREATE message. */
2171 Result
= co_IntSendMessage(UserHMGetHandle(Window
), WM_CREATE
, 0, (LPARAM
) Cs
);
2172 if (Result
== (LRESULT
)-1)
2174 ERR("co_UserCreateWindowEx(): WM_CREATE message failed\n");
2178 /* Send the EVENT_OBJECT_CREATE event */
2179 IntNotifyWinEvent(EVENT_OBJECT_CREATE
, Window
, OBJID_WINDOW
, CHILDID_SELF
, 0);
2181 /* By setting the flag below it can be examined to determine if the window
2182 was created successfully and a valid pwnd was passed back to caller since
2183 from here the function has to succeed. */
2184 Window
->state2
|= WNDS2_WMCREATEMSGPROCESSED
;
2186 /* Send the WM_SIZE and WM_MOVE messages. */
2187 if (!(Window
->state
& WNDS_SENDSIZEMOVEMSGS
))
2189 co_WinPosSendSizeMove(Window
);
2192 /* Show or maybe minimize or maximize the window. */
2194 style
= IntSetStyle( Window
, 0, WS_MAXIMIZE
| WS_MINIMIZE
);
2195 if (style
& (WS_MINIMIZE
| WS_MAXIMIZE
))
2198 UINT SwFlag
= (style
& WS_MINIMIZE
) ? SW_MINIMIZE
: SW_MAXIMIZE
;
2200 SwFlag
= co_WinPosMinMaximize(Window
, SwFlag
, &NewPos
);
2201 SwFlag
|= SWP_NOZORDER
|SWP_FRAMECHANGED
; /* Frame always gets changed */
2202 if (!(style
& WS_VISIBLE
) || (style
& WS_CHILD
) || UserGetActiveWindow()) SwFlag
|= SWP_NOACTIVATE
;
2203 co_WinPosSetWindowPos(Window
, 0, NewPos
.left
, NewPos
.top
,
2204 NewPos
.right
, NewPos
.bottom
, SwFlag
);
2207 /* Send the WM_PARENTNOTIFY message */
2208 IntSendParentNotify(Window
, WM_CREATE
);
2210 /* Notify the shell that a new window was created */
2211 if (Window
->spwndParent
== UserGetDesktopWindow() &&
2212 Window
->spwndOwner
== NULL
&&
2213 (Window
->style
& WS_VISIBLE
) &&
2214 (!(Window
->ExStyle
& WS_EX_TOOLWINDOW
) ||
2215 (Window
->ExStyle
& WS_EX_APPWINDOW
)))
2217 co_IntShellHookNotify(HSHELL_WINDOWCREATED
, (WPARAM
)hWnd
, 0);
2220 /* Initialize and show the window's scrollbars */
2221 if (Window
->style
& WS_VSCROLL
)
2223 co_UserShowScrollBar(Window
, SB_VERT
, FALSE
, TRUE
);
2225 if (Window
->style
& WS_HSCROLL
)
2227 co_UserShowScrollBar(Window
, SB_HORZ
, TRUE
, FALSE
);
2230 /* Show the new window */
2231 if (Cs
->style
& WS_VISIBLE
)
2233 if (Window
->style
& WS_MAXIMIZE
)
2234 dwShowMode
= SW_SHOW
;
2235 else if (Window
->style
& WS_MINIMIZE
)
2236 dwShowMode
= SW_SHOWMINIMIZED
;
2238 co_WinPosShowWindow(Window
, dwShowMode
);
2240 if (Window
->ExStyle
& WS_EX_MDICHILD
)
2242 ASSERT(ParentWindow
);
2245 co_IntSendMessage(UserHMGetHandle(ParentWindow
), WM_MDIREFRESHMENU
, 0, 0);
2246 /* ShowWindow won't activate child windows */
2247 co_WinPosSetWindowPos(Window
, HWND_TOP
, 0, 0, 0, 0, SWP_SHOWWINDOW
| SWP_NOMOVE
| SWP_NOSIZE
);
2251 if (Class
->atomClassName
== gaGuiConsoleWndClass
)
2253 /* Count only console windows manually */
2254 co_IntUserManualGuiCheck(TRUE
);
2257 TRACE("co_UserCreateWindowEx(): Created window %p\n", hWnd
);
2263 TRACE("co_UserCreateWindowEx(): Error Created window!\n");
2264 /* If the window was created, the class will be dereferenced by co_UserDestroyWindow */
2266 co_UserDestroyWindow(Window
);
2268 IntDereferenceClass(Class
, pti
->pDeskInfo
, pti
->ppi
);
2271 if (pCsw
) ExFreePoolWithTag(pCsw
, TAG_HOOK
);
2272 if (pCbtCreate
) ExFreePoolWithTag(pCbtCreate
, TAG_HOOK
);
2273 if (pszName
) UserHeapFree(pszName
);
2274 if (pszClass
) UserHeapFree(pszClass
);
2278 UserDerefObjectCo(Window
);
2280 if (ParentWindow
) UserDerefObjectCo(ParentWindow
);
2287 ProbeAndCaptureLargeString(
2288 OUT PLARGE_STRING plstrSafe
,
2289 IN PLARGE_STRING plstrUnsafe
)
2291 LARGE_STRING lstrTemp
;
2292 PVOID pvBuffer
= NULL
;
2296 /* Probe and copy the string */
2297 ProbeForRead(plstrUnsafe
, sizeof(LARGE_STRING
), sizeof(ULONG
));
2298 lstrTemp
= *plstrUnsafe
;
2300 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2303 _SEH2_YIELD(return _SEH2_GetExceptionCode();)
2307 if (lstrTemp
.Length
!= 0)
2309 /* Allocate a buffer from paged pool */
2310 pvBuffer
= ExAllocatePoolWithTag(PagedPool
, lstrTemp
.Length
, TAG_STRING
);
2313 return STATUS_NO_MEMORY
;
2318 /* Probe and copy the buffer */
2319 ProbeForRead(lstrTemp
.Buffer
, lstrTemp
.Length
, sizeof(WCHAR
));
2320 RtlCopyMemory(pvBuffer
, lstrTemp
.Buffer
, lstrTemp
.Length
);
2322 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2324 /* Cleanup and fail */
2325 ExFreePoolWithTag(pvBuffer
, TAG_STRING
);
2326 _SEH2_YIELD(return _SEH2_GetExceptionCode();)
2331 /* Set the output string */
2332 plstrSafe
->Buffer
= pvBuffer
;
2333 plstrSafe
->Length
= lstrTemp
.Length
;
2334 plstrSafe
->MaximumLength
= lstrTemp
.Length
;
2336 return STATUS_SUCCESS
;
2340 * \todo Allow passing plstrClassName as ANSI.
2344 NtUserCreateWindowEx(
2346 PLARGE_STRING plstrClassName
,
2347 PLARGE_STRING plstrClsVersion
,
2348 PLARGE_STRING plstrWindowName
,
2356 HINSTANCE hInstance
,
2362 LARGE_STRING lstrWindowName
;
2363 LARGE_STRING lstrClassName
;
2364 UNICODE_STRING ustrClassName
;
2369 lstrWindowName
.Buffer
= NULL
;
2370 lstrClassName
.Buffer
= NULL
;
2372 ASSERT(plstrWindowName
);
2374 if ( (dwStyle
& (WS_POPUP
|WS_CHILD
)) != WS_CHILD
)
2376 /* check hMenu is valid handle */
2377 if (hMenu
&& !UserGetMenuObject(hMenu
))
2379 ERR("NtUserCreateWindowEx: Got an invalid menu handle!\n");
2380 EngSetLastError(ERROR_INVALID_MENU_HANDLE
);
2385 /* Copy the window name to kernel mode */
2386 Status
= ProbeAndCaptureLargeString(&lstrWindowName
, plstrWindowName
);
2387 if (!NT_SUCCESS(Status
))
2389 ERR("NtUserCreateWindowEx: failed to capture plstrWindowName\n");
2390 SetLastNtError(Status
);
2394 plstrWindowName
= &lstrWindowName
;
2396 /* Check if the class is an atom */
2397 if (IS_ATOM(plstrClassName
))
2399 /* It is, pass the atom in the UNICODE_STRING */
2400 ustrClassName
.Buffer
= (PVOID
)plstrClassName
;
2401 ustrClassName
.Length
= 0;
2402 ustrClassName
.MaximumLength
= 0;
2406 /* It's not, capture the class name */
2407 Status
= ProbeAndCaptureLargeString(&lstrClassName
, plstrClassName
);
2408 if (!NT_SUCCESS(Status
))
2410 ERR("NtUserCreateWindowEx: failed to capture plstrClassName\n");
2411 /* Set last error, cleanup and return */
2412 SetLastNtError(Status
);
2416 /* We pass it on as a UNICODE_STRING */
2417 ustrClassName
.Buffer
= lstrClassName
.Buffer
;
2418 ustrClassName
.Length
= (USHORT
)min(lstrClassName
.Length
, MAXUSHORT
); // FIXME: LARGE_STRING truncated
2419 ustrClassName
.MaximumLength
= (USHORT
)min(lstrClassName
.MaximumLength
, MAXUSHORT
);
2422 /* Fill the CREATESTRUCTW */
2423 /* we will keep here the original parameters */
2425 Cs
.lpCreateParams
= lpParam
;
2426 Cs
.hInstance
= hInstance
;
2428 Cs
.hwndParent
= hWndParent
;
2433 Cs
.lpszName
= (LPCWSTR
) plstrWindowName
->Buffer
;
2434 Cs
.lpszClass
= ustrClassName
.Buffer
;
2435 Cs
.dwExStyle
= dwExStyle
;
2437 UserEnterExclusive();
2439 /* Call the internal function */
2440 pwnd
= co_UserCreateWindowEx(&Cs
, &ustrClassName
, plstrWindowName
, acbiBuffer
);
2444 ERR("co_UserCreateWindowEx failed!\n");
2446 hwnd
= pwnd
? UserHMGetHandle(pwnd
) : NULL
;
2451 if (lstrWindowName
.Buffer
)
2453 ExFreePoolWithTag(lstrWindowName
.Buffer
, TAG_STRING
);
2455 if (lstrClassName
.Buffer
)
2457 ExFreePoolWithTag(lstrClassName
.Buffer
, TAG_STRING
);
2464 BOOLEAN
co_UserDestroyWindow(PVOID Object
)
2470 PWND Window
= Object
;
2472 ASSERT_REFS_CO(Window
); // FIXME: Temp HACK?
2474 hWnd
= Window
->head
.h
;
2475 ti
= PsGetCurrentThreadWin32Thread();
2477 TRACE("co_UserDestroyWindow \n");
2479 /* Check for owner thread */
2480 if ( Window
->head
.pti
!= PsGetCurrentThreadWin32Thread())
2482 /* Check if we are destroying the desktop window */
2483 if (! ((Window
->head
.rpdesk
->dwDTFlags
& DF_DESTROYED
) && Window
== Window
->head
.rpdesk
->pDeskInfo
->spwnd
))
2485 EngSetLastError(ERROR_ACCESS_DENIED
);
2490 /* If window was created successfully and it is hooked */
2491 if ((Window
->state2
& WNDS2_WMCREATEMSGPROCESSED
))
2493 if (co_HOOK_CallHooks(WH_CBT
, HCBT_DESTROYWND
, (WPARAM
) hWnd
, 0))
2495 ERR("Destroy Window WH_CBT Call Hook return!\n");
2500 if (Window
->pcls
->atomClassName
!= gpsi
->atomSysClass
[ICLS_IME
])
2502 if ((Window
->style
& (WS_POPUP
|WS_CHILD
)) != WS_CHILD
)
2504 if (Window
->spwndOwner
)
2506 //ERR("DestroyWindow Owner out.\n");
2507 UserAttachThreadInput(Window
->head
.pti
, Window
->spwndOwner
->head
.pti
, FALSE
);
2512 /* Inform the parent */
2513 if (Window
->style
& WS_CHILD
)
2515 IntSendParentNotify(Window
, WM_DESTROY
);
2518 if (!Window
->spwndOwner
&& !IntGetParent(Window
))
2520 co_IntShellHookNotify(HSHELL_WINDOWDESTROYED
, (WPARAM
) hWnd
, 0);
2523 /* Hide the window */
2524 if (Window
->style
& WS_VISIBLE
)
2526 if (Window
->style
& WS_CHILD
)
2528 /* Only child windows receive WM_SHOWWINDOW in DestroyWindow() */
2529 co_WinPosShowWindow(Window
, SW_HIDE
);
2533 co_WinPosSetWindowPos(Window
, 0, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
2537 // Adjust last active.
2538 if ((pwndTemp
= Window
->spwndOwner
))
2540 while (pwndTemp
->spwndOwner
)
2541 pwndTemp
= pwndTemp
->spwndOwner
;
2543 if (pwndTemp
->spwndLastActive
== Window
)
2544 pwndTemp
->spwndLastActive
= Window
->spwndOwner
;
2547 if (Window
->spwndParent
&& IntIsWindow(UserHMGetHandle(Window
)))
2549 if ((Window
->style
& (WS_POPUP
| WS_CHILD
)) == WS_CHILD
)
2551 if (!IntIsTopLevelWindow(Window
))
2553 //ERR("DestroyWindow Parent out.\n");
2554 UserAttachThreadInput(Window
->head
.pti
, Window
->spwndParent
->head
.pti
, FALSE
);
2559 if (Window
->head
.pti
->MessageQueue
->spwndActive
== Window
)
2560 Window
->head
.pti
->MessageQueue
->spwndActive
= NULL
;
2561 if (Window
->head
.pti
->MessageQueue
->spwndFocus
== Window
)
2562 Window
->head
.pti
->MessageQueue
->spwndFocus
= NULL
;
2563 if (Window
->head
.pti
->MessageQueue
->spwndActivePrev
== Window
)
2564 Window
->head
.pti
->MessageQueue
->spwndActivePrev
= NULL
;
2565 if (Window
->head
.pti
->MessageQueue
->spwndCapture
== Window
)
2566 Window
->head
.pti
->MessageQueue
->spwndCapture
= NULL
;
2569 * Check if this window is the Shell's Desktop Window. If so set hShellWindow to NULL
2572 if ((ti
!= NULL
) && (ti
->pDeskInfo
!= NULL
))
2574 if (ti
->pDeskInfo
->hShellWindow
== hWnd
)
2576 ERR("Destroying the ShellWindow!\n");
2577 ti
->pDeskInfo
->hShellWindow
= NULL
;
2581 IntEngWindowChanged(Window
, WOC_DELETE
);
2583 if (!IntIsWindow(UserHMGetHandle(Window
)))
2588 /* Recursively destroy owned windows */
2590 if (! (Window
->style
& WS_CHILD
))
2594 BOOL GotOne
= FALSE
;
2597 PWND Child
, Desktop
;
2599 Desktop
= IntIsDesktopWindow(Window
) ? Window
:
2600 UserGetWindowObject(IntGetDesktopWindow());
2601 Children
= IntWinListChildren(Desktop
);
2605 for (ChildHandle
= Children
; *ChildHandle
; ++ChildHandle
)
2607 Child
= UserGetWindowObject(*ChildHandle
);
2610 if (Child
->spwndOwner
!= Window
)
2615 if (IntWndBelongsToThread(Child
, PsGetCurrentThreadWin32Thread()))
2617 USER_REFERENCE_ENTRY ChildRef
;
2618 UserRefObjectCo(Child
, &ChildRef
); // Temp HACK?
2619 co_UserDestroyWindow(Child
);
2620 UserDerefObjectCo(Child
); // Temp HACK?
2626 if (Child
->spwndOwner
!= NULL
)
2628 Child
->spwndOwner
= NULL
;
2632 ExFreePoolWithTag(Children
, USERTAG_WINDOWLIST
);
2641 /* Generate mouse move message for the next window */
2642 msg
.message
= WM_MOUSEMOVE
;
2643 msg
.wParam
= UserGetMouseButtonsState();
2644 msg
.lParam
= MAKELPARAM(gpsi
->ptCursor
.x
, gpsi
->ptCursor
.y
);
2645 msg
.pt
= gpsi
->ptCursor
;
2646 co_MsqInsertMouseMessage(&msg
, 0, 0, TRUE
);
2648 IntNotifyWinEvent(EVENT_OBJECT_DESTROY
, Window
, OBJID_WINDOW
, CHILDID_SELF
, 0);
2650 /* Send destroy messages */
2652 IntSendDestroyMsg(UserHMGetHandle(Window
));
2654 if (!IntIsWindow(UserHMGetHandle(Window
)))
2659 /* Destroy the window storage */
2660 co_UserFreeWindow(Window
, PsGetCurrentProcessWin32Process(), PsGetCurrentThreadWin32Thread(), TRUE
);
2670 NtUserDestroyWindow(HWND Wnd
)
2673 DECLARE_RETURN(BOOLEAN
);
2675 USER_REFERENCE_ENTRY Ref
;
2677 TRACE("Enter NtUserDestroyWindow\n");
2678 UserEnterExclusive();
2680 if (!(Window
= UserGetWindowObject(Wnd
)))
2685 UserRefObjectCo(Window
, &Ref
); // FIXME: Dunno if win should be reffed during destroy...
2686 ret
= co_UserDestroyWindow(Window
);
2687 UserDerefObjectCo(Window
); // FIXME: Dunno if win should be reffed during destroy...
2692 TRACE("Leave NtUserDestroyWindow, ret=%u\n", _ret_
);
2698 static HWND FASTCALL
2699 IntFindWindow(PWND Parent
,
2702 PUNICODE_STRING WindowName
)
2704 BOOL CheckWindowName
;
2707 UNICODE_STRING CurrentWindowName
;
2711 CheckWindowName
= WindowName
->Buffer
!= 0;
2713 if((List
= IntWinListChildren(Parent
)))
2718 /* skip handles before and including ChildAfter */
2719 while(*phWnd
&& (*(phWnd
++) != ChildAfter
->head
.h
))
2723 /* search children */
2727 if(!(Child
= UserGetWindowObject(*(phWnd
++))))
2732 /* Do not send WM_GETTEXT messages in the kernel mode version!
2733 The user mode version however calls GetWindowText() which will
2734 send WM_GETTEXT messages to windows belonging to its processes */
2735 if (!ClassAtom
|| Child
->pcls
->atomClassName
== ClassAtom
)
2737 // FIXME: LARGE_STRING truncated
2738 CurrentWindowName
.Buffer
= Child
->strName
.Buffer
;
2739 CurrentWindowName
.Length
= (USHORT
)min(Child
->strName
.Length
, MAXUSHORT
);
2740 CurrentWindowName
.MaximumLength
= (USHORT
)min(Child
->strName
.MaximumLength
, MAXUSHORT
);
2741 if(!CheckWindowName
||
2742 (Child
->strName
.Length
< 0xFFFF &&
2743 !RtlCompareUnicodeString(WindowName
, &CurrentWindowName
, TRUE
)))
2745 Ret
= Child
->head
.h
;
2750 ExFreePoolWithTag(List
, USERTAG_WINDOWLIST
);
2758 * Searches a window's children for a window with the specified
2761 * hwndParent = The window whose childs are to be searched.
2763 * HWND_MESSAGE = message-only windows
2765 * hwndChildAfter = Search starts after this child window.
2766 * NULL = start from beginning
2768 * ucClassName = Class name to search for
2769 * Reguired parameter.
2771 * ucWindowName = Window name
2772 * ->Buffer == NULL = don't care
2775 * The HWND of the window if it was found, otherwise NULL
2781 NtUserFindWindowEx(HWND hwndParent
,
2782 HWND hwndChildAfter
,
2783 PUNICODE_STRING ucClassName
,
2784 PUNICODE_STRING ucWindowName
,
2787 PWND Parent
, ChildAfter
;
2788 UNICODE_STRING ClassName
= {0}, WindowName
= {0};
2789 HWND Desktop
, Ret
= NULL
;
2790 BOOL DoMessageWnd
= FALSE
;
2791 RTL_ATOM ClassAtom
= (RTL_ATOM
)0;
2792 DECLARE_RETURN(HWND
);
2794 TRACE("Enter NtUserFindWindowEx\n");
2797 if (ucClassName
!= NULL
|| ucWindowName
!= NULL
)
2801 if (ucClassName
!= NULL
)
2803 ClassName
= ProbeForReadUnicodeString(ucClassName
);
2804 if (ClassName
.Length
!= 0)
2806 ProbeForRead(ClassName
.Buffer
,
2810 else if (!IS_ATOM(ClassName
.Buffer
))
2812 EngSetLastError(ERROR_INVALID_PARAMETER
);
2816 if (!IntGetAtomFromStringOrAtom(&ClassName
,
2823 if (ucWindowName
!= NULL
)
2825 WindowName
= ProbeForReadUnicodeString(ucWindowName
);
2826 if (WindowName
.Length
!= 0)
2828 ProbeForRead(WindowName
.Buffer
,
2834 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2836 SetLastNtError(_SEH2_GetExceptionCode());
2837 _SEH2_YIELD(RETURN(NULL
));
2841 if (ucClassName
!= NULL
)
2843 if (ClassName
.Length
== 0 && ClassName
.Buffer
!= NULL
&&
2844 !IS_ATOM(ClassName
.Buffer
))
2846 EngSetLastError(ERROR_INVALID_PARAMETER
);
2849 else if (ClassAtom
== (RTL_ATOM
)0)
2851 /* LastError code was set by IntGetAtomFromStringOrAtom */
2857 Desktop
= IntGetCurrentThreadDesktopWindow();
2859 if(hwndParent
== NULL
)
2861 hwndParent
= Desktop
;
2862 DoMessageWnd
= TRUE
;
2864 else if(hwndParent
== HWND_MESSAGE
)
2866 hwndParent
= IntGetMessageWindow();
2869 if(!(Parent
= UserGetWindowObject(hwndParent
)))
2875 if(hwndChildAfter
&& !(ChildAfter
= UserGetWindowObject(hwndChildAfter
)))
2882 if(Parent
->head
.h
== Desktop
)
2885 PWND TopLevelWindow
;
2886 BOOLEAN CheckWindowName
;
2887 BOOLEAN WindowMatches
;
2888 BOOLEAN ClassMatches
;
2890 /* windows searches through all top-level windows if the parent is the desktop
2893 if((List
= IntWinListChildren(Parent
)))
2899 /* skip handles before and including ChildAfter */
2900 while(*phWnd
&& (*(phWnd
++) != ChildAfter
->head
.h
))
2904 CheckWindowName
= WindowName
.Buffer
!= 0;
2906 /* search children */
2909 UNICODE_STRING ustr
;
2911 if(!(TopLevelWindow
= UserGetWindowObject(*(phWnd
++))))
2916 /* Do not send WM_GETTEXT messages in the kernel mode version!
2917 The user mode version however calls GetWindowText() which will
2918 send WM_GETTEXT messages to windows belonging to its processes */
2919 ustr
.Buffer
= TopLevelWindow
->strName
.Buffer
;
2920 ustr
.Length
= (USHORT
)min(TopLevelWindow
->strName
.Length
, MAXUSHORT
); // FIXME:LARGE_STRING truncated
2921 ustr
.MaximumLength
= (USHORT
)min(TopLevelWindow
->strName
.MaximumLength
, MAXUSHORT
);
2922 WindowMatches
= !CheckWindowName
||
2923 (TopLevelWindow
->strName
.Length
< 0xFFFF &&
2924 !RtlCompareUnicodeString(&WindowName
, &ustr
, TRUE
));
2925 ClassMatches
= (ClassAtom
== (RTL_ATOM
)0) ||
2926 ClassAtom
== TopLevelWindow
->pcls
->atomClassName
;
2928 if (WindowMatches
&& ClassMatches
)
2930 Ret
= TopLevelWindow
->head
.h
;
2934 if (IntFindWindow(TopLevelWindow
, NULL
, ClassAtom
, &WindowName
))
2936 /* window returns the handle of the top-level window, in case it found
2938 Ret
= TopLevelWindow
->head
.h
;
2943 ExFreePoolWithTag(List
, USERTAG_WINDOWLIST
);
2948 ERR("FindWindowEx: Not Desktop Parent!\n");
2949 Ret
= IntFindWindow(Parent
, ChildAfter
, ClassAtom
, &WindowName
);
2952 if (Ret
== NULL
&& DoMessageWnd
)
2956 if((MsgWindows
= UserGetWindowObject(IntGetMessageWindow())))
2958 Ret
= IntFindWindow(MsgWindows
, ChildAfter
, ClassAtom
, &WindowName
);
2962 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2964 SetLastNtError(_SEH2_GetExceptionCode());
2972 TRACE("Leave NtUserFindWindowEx, ret %p\n", _ret_
);
2981 PWND FASTCALL
UserGetAncestor(PWND Wnd
, UINT Type
)
2983 PWND WndAncestor
, Parent
;
2985 if (Wnd
->head
.h
== IntGetDesktopWindow())
2994 WndAncestor
= Wnd
->spwndParent
;
3005 if(!(Parent
= WndAncestor
->spwndParent
))
3009 if(IntIsDesktopWindow(Parent
))
3014 WndAncestor
= Parent
;
3025 Parent
= IntGetParent(WndAncestor
);
3032 WndAncestor
= Parent
;
3050 NtUserGetAncestor(HWND hWnd
, UINT Type
)
3052 PWND Window
, Ancestor
;
3053 DECLARE_RETURN(HWND
);
3055 TRACE("Enter NtUserGetAncestor\n");
3056 UserEnterExclusive();
3058 if (!(Window
= UserGetWindowObject(hWnd
)))
3063 Ancestor
= UserGetAncestor(Window
, Type
);
3064 /* faxme: can UserGetAncestor ever return NULL for a valid window? */
3066 RETURN(Ancestor
? Ancestor
->head
.h
: NULL
);
3069 TRACE("Leave NtUserGetAncestor, ret=%p\n", _ret_
);
3075 //// ReactOS work around! Keep it the sames as in Combo.c and Controls.h
3077 /* combo state struct */
3091 INT fixedOwnerDrawHeight
;
3092 INT droppedWidth
; /* last two are not used unless set */
3093 INT editHeight
; /* explicitly */
3095 } HEADCOMBO
,*LPHEADCOMBO
;
3097 // Window Extra data container.
3098 typedef struct _WND2CBOX
3102 } WND2CBOX
, *PWND2CBOX
;
3104 #define CBF_BUTTONDOWN 0x0002
3110 NtUserGetComboBoxInfo(
3116 BOOL NotSameppi
= FALSE
;
3118 DECLARE_RETURN(BOOL
);
3120 TRACE("Enter NtUserGetComboBoxInfo\n");
3123 if (!(Wnd
= UserGetWindowObject(hWnd
)))
3129 ProbeForWrite(pcbi
, sizeof(COMBOBOXINFO
), 1);
3131 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
3133 SetLastNtError(_SEH2_GetExceptionCode());
3134 _SEH2_YIELD(RETURN(FALSE
));
3138 if (pcbi
->cbSize
< sizeof(COMBOBOXINFO
))
3140 EngSetLastError(ERROR_INVALID_PARAMETER
);
3144 // Pass the user pointer, it was already probed.
3145 if ((Wnd
->pcls
->atomClassName
!= gpsi
->atomSysClass
[ICLS_COMBOBOX
]) && Wnd
->fnid
!= FNID_COMBOBOX
)
3147 RETURN( (BOOL
) co_IntSendMessage( Wnd
->head
.h
, CB_GETCOMBOBOXINFO
, 0, (LPARAM
)pcbi
));
3150 ppi
= PsGetCurrentProcessWin32Process();
3151 NotSameppi
= ppi
!= Wnd
->head
.pti
->ppi
;
3154 KeAttachProcess(&Wnd
->head
.pti
->ppi
->peProcess
->Pcb
);
3159 LPHEADCOMBO lphc
= ((PWND2CBOX
)Wnd
)->pCBox
;
3160 pcbi
->rcItem
= lphc
->textRect
;
3161 pcbi
->rcButton
= lphc
->buttonRect
;
3162 pcbi
->stateButton
= 0;
3163 if (lphc
->wState
& CBF_BUTTONDOWN
)
3164 pcbi
->stateButton
|= STATE_SYSTEM_PRESSED
;
3165 if (RECTL_bIsEmptyRect(&lphc
->buttonRect
))
3166 pcbi
->stateButton
|= STATE_SYSTEM_INVISIBLE
;
3167 pcbi
->hwndCombo
= lphc
->self
;
3168 pcbi
->hwndItem
= lphc
->hWndEdit
;
3169 pcbi
->hwndList
= lphc
->hWndLBox
;
3171 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
3174 SetLastNtError(_SEH2_GetExceptionCode());
3181 if (NotSameppi
) KeDetachProcess();
3182 TRACE("Leave NtUserGetComboBoxInfo, ret=%i\n",_ret_
);
3188 //// ReactOS work around! Keep it the sames as in Listbox.c
3190 /* Listbox structure */
3193 HWND self
; /* Our own window handle */
3194 HWND owner
; /* Owner window to send notifications to */
3195 UINT style
; /* Window style */
3196 INT width
; /* Window width */
3197 INT height
; /* Window height */
3198 VOID
*items
; /* Array of items */
3199 INT nb_items
; /* Number of items */
3200 INT top_item
; /* Top visible item */
3201 INT selected_item
; /* Selected item */
3202 INT focus_item
; /* Item that has the focus */
3203 INT anchor_item
; /* Anchor item for extended selection */
3204 INT item_height
; /* Default item height */
3205 INT page_size
; /* Items per listbox page */
3206 INT column_width
; /* Column width for multi-column listboxes */
3209 // Window Extra data container.
3210 typedef struct _WND2LB
3220 NtUserGetListBoxInfo(
3225 BOOL NotSameppi
= FALSE
;
3227 DECLARE_RETURN(DWORD
);
3229 TRACE("Enter NtUserGetListBoxInfo\n");
3232 if (!(Wnd
= UserGetWindowObject(hWnd
)))
3237 if ((Wnd
->pcls
->atomClassName
!= gpsi
->atomSysClass
[ICLS_LISTBOX
]) && Wnd
->fnid
!= FNID_LISTBOX
)
3239 RETURN( (DWORD
) co_IntSendMessage( Wnd
->head
.h
, LB_GETLISTBOXINFO
, 0, 0 ));
3242 // wine lisbox:test_GetListBoxInfo lb_getlistboxinfo = 0, should not send a message!
3243 ppi
= PsGetCurrentProcessWin32Process();
3244 NotSameppi
= ppi
!= Wnd
->head
.pti
->ppi
;
3247 KeAttachProcess(&Wnd
->head
.pti
->ppi
->peProcess
->Pcb
);
3252 LB_DESCR
*descr
= ((PWND2LB
)Wnd
)->pLBiv
;
3253 // See Controls ListBox.c:LB_GETLISTBOXINFO must match...
3254 if (descr
->style
& LBS_MULTICOLUMN
) //// ReactOS
3255 Ret
= descr
->page_size
* descr
->column_width
;
3257 Ret
= descr
->page_size
;
3259 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
3262 SetLastNtError(_SEH2_GetExceptionCode());
3269 if (NotSameppi
) KeDetachProcess();
3270 TRACE("Leave NtUserGetListBoxInfo, ret=%lu\n", _ret_
);
3278 * The NtUserSetParent function changes the parent window of the specified
3282 * The new parent window and the child window must belong to the same
3283 * application. If the window identified by the hWndChild parameter is
3284 * visible, the system performs the appropriate redrawing and repainting.
3285 * For compatibility reasons, NtUserSetParent does not modify the WS_CHILD
3286 * or WS_POPUP window styles of the window whose parent is being changed.
3293 NtUserSetParent(HWND hWndChild
, HWND hWndNewParent
)
3295 DECLARE_RETURN(HWND
);
3297 TRACE("Enter NtUserSetParent\n");
3298 UserEnterExclusive();
3301 Check Parent first from user space, set it here.
3305 hWndNewParent
= IntGetDesktopWindow();
3307 else if (hWndNewParent
== HWND_MESSAGE
)
3309 hWndNewParent
= IntGetMessageWindow();
3312 RETURN( co_UserSetParent(hWndChild
, hWndNewParent
));
3315 TRACE("Leave NtUserSetParent, ret=%p\n", _ret_
);
3321 * UserGetShellWindow
3323 * Returns a handle to shell window that was set by NtUserSetShellWindowEx.
3328 HWND FASTCALL
UserGetShellWindow(VOID
)
3330 PWINSTATION_OBJECT WinStaObject
;
3333 NTSTATUS Status
= IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation
,
3339 if (!NT_SUCCESS(Status
))
3341 SetLastNtError(Status
);
3345 Ret
= (HWND
)WinStaObject
->ShellWindow
;
3347 ObDereferenceObject(WinStaObject
);
3352 * NtUserSetShellWindowEx
3354 * This is undocumented function to set global shell window. The global
3355 * shell window has special handling of window position.
3361 NtUserSetShellWindowEx(HWND hwndShell
, HWND hwndListView
)
3363 PWINSTATION_OBJECT WinStaObject
;
3364 PWND WndShell
, WndListView
;
3365 DECLARE_RETURN(BOOL
);
3366 USER_REFERENCE_ENTRY Ref
;
3370 TRACE("Enter NtUserSetShellWindowEx\n");
3371 UserEnterExclusive();
3373 if (!(WndShell
= UserGetWindowObject(hwndShell
)))
3378 if(!(WndListView
= UserGetWindowObject(hwndListView
)))
3383 Status
= IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation
,
3389 if (!NT_SUCCESS(Status
))
3391 SetLastNtError(Status
);
3396 * Test if we are permitted to change the shell window.
3398 if (WinStaObject
->ShellWindow
)
3400 ObDereferenceObject(WinStaObject
);
3405 * Move shell window into background.
3407 if (hwndListView
&& hwndListView
!= hwndShell
)
3410 * Disabled for now to get Explorer working.
3411 * -- Filip, 01/nov/2003
3414 co_WinPosSetWindowPos(WndListView
, HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
);
3417 if (WndListView
->ExStyle
& WS_EX_TOPMOST
)
3419 ObDereferenceObject(WinStaObject
);
3424 if (WndShell
->ExStyle
& WS_EX_TOPMOST
)
3426 ObDereferenceObject(WinStaObject
);
3430 UserRefObjectCo(WndShell
, &Ref
);
3431 WndShell
->state2
|= WNDS2_BOTTOMMOST
;
3432 co_WinPosSetWindowPos(WndShell
, HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
);
3434 WinStaObject
->ShellWindow
= hwndShell
;
3435 WinStaObject
->ShellListView
= hwndListView
;
3437 ti
= GetW32ThreadInfo();
3440 ti
->pDeskInfo
->hShellWindow
= hwndShell
;
3441 ti
->pDeskInfo
->spwndShell
= WndShell
;
3442 ti
->pDeskInfo
->ppiShellProcess
= ti
->ppi
;
3445 UserRegisterHotKey(WndShell
, SC_TASKLIST
, MOD_CONTROL
, VK_ESCAPE
);
3447 UserDerefObjectCo(WndShell
);
3449 ObDereferenceObject(WinStaObject
);
3453 TRACE("Leave NtUserSetShellWindowEx, ret=%i\n",_ret_
);
3458 // Fixes wine Win test_window_styles and todo tests...
3459 static BOOL FASTCALL
3460 IntCheckFrameEdge(ULONG Style
, ULONG ExStyle
)
3462 if (ExStyle
& WS_EX_DLGMODALFRAME
)
3464 else if (!(ExStyle
& WS_EX_STATICEDGE
) && (Style
& (WS_DLGFRAME
| WS_THICKFRAME
)))
3471 co_IntSetWindowLong(HWND hWnd
, DWORD Index
, LONG NewValue
, BOOL Ansi
, BOOL bAlter
)
3473 PWND Window
, Parent
;
3474 PWINSTATION_OBJECT WindowStation
;
3478 if (!(Window
= UserGetWindowObject(hWnd
)))
3483 if ((INT
)Index
>= 0)
3485 if ((Index
+ sizeof(LONG
)) > Window
->cbwndExtra
)
3487 EngSetLastError(ERROR_INVALID_INDEX
);
3491 OldValue
= *((LONG
*)((PCHAR
)(Window
+ 1) + Index
));
3493 if ( Index == DWLP_DLGPROC && Wnd->state & WNDS_DIALOGWINDOW)
3495 OldValue = (LONG)IntSetWindowProc( Wnd,
3498 if (!OldValue) return 0;
3501 *((LONG
*)((PCHAR
)(Window
+ 1) + Index
)) = NewValue
;
3508 OldValue
= (LONG
) Window
->ExStyle
;
3509 Style
.styleOld
= OldValue
;
3510 Style
.styleNew
= NewValue
;
3512 co_IntSendMessage(hWnd
, WM_STYLECHANGING
, GWL_EXSTYLE
, (LPARAM
) &Style
);
3515 * Remove extended window style bit WS_EX_TOPMOST for shell windows.
3517 WindowStation
= Window
->head
.pti
->rpdesk
->rpwinstaParent
;
3520 if (hWnd
== WindowStation
->ShellWindow
|| hWnd
== WindowStation
->ShellListView
)
3521 Style
.styleNew
&= ~WS_EX_TOPMOST
;
3523 /* WS_EX_WINDOWEDGE depends on some other styles */
3524 if (IntCheckFrameEdge(Window
->style
, NewValue
))
3525 Style
.styleNew
|= WS_EX_WINDOWEDGE
;
3527 Style
.styleNew
&= ~WS_EX_WINDOWEDGE
;
3529 Window
->ExStyle
= (DWORD
)Style
.styleNew
;
3531 co_IntSendMessage(hWnd
, WM_STYLECHANGED
, GWL_EXSTYLE
, (LPARAM
) &Style
);
3535 OldValue
= (LONG
) Window
->style
;
3536 Style
.styleOld
= OldValue
;
3537 Style
.styleNew
= NewValue
;
3540 co_IntSendMessage(hWnd
, WM_STYLECHANGING
, GWL_STYLE
, (LPARAM
) &Style
);
3542 /* WS_CLIPSIBLINGS can't be reset on top-level windows */
3543 if (Window
->spwndParent
== UserGetDesktopWindow()) Style
.styleNew
|= WS_CLIPSIBLINGS
;
3544 /* Fixes wine FIXME: changing WS_DLGFRAME | WS_THICKFRAME is supposed to change WS_EX_WINDOWEDGE too */
3545 if (IntCheckFrameEdge(NewValue
, Window
->ExStyle
))
3546 Window
->ExStyle
|= WS_EX_WINDOWEDGE
;
3548 Window
->ExStyle
&= ~WS_EX_WINDOWEDGE
;
3550 if ((Style
.styleOld
^ Style
.styleNew
) & WS_VISIBLE
)
3552 if (Style
.styleOld
& WS_VISIBLE
) Window
->head
.pti
->cVisWindows
--;
3553 if (Style
.styleNew
& WS_VISIBLE
) Window
->head
.pti
->cVisWindows
++;
3554 DceResetActiveDCEs( Window
);
3556 Window
->style
= (DWORD
)Style
.styleNew
;
3559 co_IntSendMessage(hWnd
, WM_STYLECHANGED
, GWL_STYLE
, (LPARAM
) &Style
);
3564 if ( Window
->head
.pti
->ppi
!= PsGetCurrentProcessWin32Process() ||
3565 Window
->fnid
& FNID_FREED
)
3567 EngSetLastError(ERROR_ACCESS_DENIED
);
3570 OldValue
= (LONG
)IntSetWindowProc(Window
,
3577 OldValue
= (LONG
) Window
->hModule
;
3578 Window
->hModule
= (HINSTANCE
) NewValue
;
3581 case GWL_HWNDPARENT
:
3582 Parent
= Window
->spwndParent
;
3583 if (Parent
&& (Parent
->head
.h
== IntGetDesktopWindow()))
3584 OldValue
= (LONG
) IntSetOwner(Window
->head
.h
, (HWND
) NewValue
);
3586 OldValue
= (LONG
) co_UserSetParent(Window
->head
.h
, (HWND
) NewValue
);
3590 OldValue
= (LONG
) Window
->IDMenu
;
3591 Window
->IDMenu
= (UINT
) NewValue
;
3595 OldValue
= Window
->dwUserData
;
3596 Window
->dwUserData
= NewValue
;
3600 ERR("NtUserSetWindowLong(): Unsupported index %lu\n", Index
);
3601 EngSetLastError(ERROR_INVALID_INDEX
);
3612 co_UserSetWindowLong(HWND hWnd
, DWORD Index
, LONG NewValue
, BOOL Ansi
)
3614 return co_IntSetWindowLong(hWnd
, Index
, NewValue
, Ansi
, FALSE
);
3618 * NtUserSetWindowLong
3620 * The NtUserSetWindowLong function changes an attribute of the specified
3621 * window. The function also sets the 32-bit (long) value at the specified
3622 * offset into the extra window memory.
3629 NtUserSetWindowLong(HWND hWnd
, DWORD Index
, LONG NewValue
, BOOL Ansi
)
3633 UserEnterExclusive();
3635 if (hWnd
== IntGetDesktopWindow())
3637 EngSetLastError(STATUS_ACCESS_DENIED
);
3642 ret
= co_IntSetWindowLong(hWnd
, Index
, NewValue
, Ansi
, FALSE
);
3650 NtUserAlterWindowStyle(HWND hWnd
, DWORD Index
, LONG NewValue
)
3654 UserEnterExclusive();
3656 if (hWnd
== IntGetDesktopWindow())
3658 EngSetLastError(STATUS_ACCESS_DENIED
);
3663 ret
= co_IntSetWindowLong(hWnd
, Index
, NewValue
, FALSE
, TRUE
);
3672 * NtUserSetWindowWord
3674 * Legacy function similar to NtUserSetWindowLong.
3681 NtUserSetWindowWord(HWND hWnd
, INT Index
, WORD NewValue
)
3685 DECLARE_RETURN(WORD
);
3687 TRACE("Enter NtUserSetWindowWord\n");
3688 UserEnterExclusive();
3690 if (hWnd
== IntGetDesktopWindow())
3692 EngSetLastError(STATUS_ACCESS_DENIED
);
3696 if (!(Window
= UserGetWindowObject(hWnd
)))
3705 case GWL_HWNDPARENT
:
3706 RETURN( (WORD
)co_UserSetWindowLong(UserHMGetHandle(Window
), Index
, (UINT
)NewValue
, TRUE
));
3710 EngSetLastError(ERROR_INVALID_INDEX
);
3715 if ((ULONG
)Index
> (Window
->cbwndExtra
- sizeof(WORD
)))
3717 EngSetLastError(ERROR_INVALID_PARAMETER
);
3721 OldValue
= *((WORD
*)((PCHAR
)(Window
+ 1) + Index
));
3722 *((WORD
*)((PCHAR
)(Window
+ 1) + Index
)) = NewValue
;
3727 TRACE("Leave NtUserSetWindowWord, ret=%u\n", _ret_
);
3733 QueryWindow based on KJK::Hyperion and James Tabor.
3735 0 = QWUniqueProcessId
3736 1 = QWUniqueThreadId
3739 4 = QWIsHung Implements IsHungAppWindow found
3742 9 = QWKillWindow When I called this with hWnd ==
3743 DesktopWindow, it shutdown the system
3750 NtUserQueryWindow(HWND hWnd
, DWORD Index
)
3752 /* Console Leader Process CID Window offsets */
3753 #define GWLP_CONSOLE_LEADER_PID 0
3754 #define GWLP_CONSOLE_LEADER_TID 4
3758 DECLARE_RETURN(UINT
);
3760 TRACE("Enter NtUserQueryWindow\n");
3763 if (!(pWnd
= UserGetWindowObject(hWnd
)))
3770 case QUERY_WINDOW_UNIQUE_PROCESS_ID
:
3772 if ( (pWnd
->head
.pti
->TIF_flags
& TIF_CSRSSTHREAD
) &&
3773 (pWnd
->pcls
->atomClassName
== gaGuiConsoleWndClass
) )
3775 // IntGetWindowLong(offset == GWLP_CONSOLE_LEADER_PID)
3776 Result
= (DWORD
)(*((LONG_PTR
*)((PCHAR
)(pWnd
+ 1) + GWLP_CONSOLE_LEADER_PID
)));
3780 Result
= (DWORD
)IntGetWndProcessId(pWnd
);
3785 case QUERY_WINDOW_UNIQUE_THREAD_ID
:
3787 if ( (pWnd
->head
.pti
->TIF_flags
& TIF_CSRSSTHREAD
) &&
3788 (pWnd
->pcls
->atomClassName
== gaGuiConsoleWndClass
) )
3790 // IntGetWindowLong(offset == GWLP_CONSOLE_LEADER_TID)
3791 Result
= (DWORD
)(*((LONG_PTR
*)((PCHAR
)(pWnd
+ 1) + GWLP_CONSOLE_LEADER_TID
)));
3795 Result
= (DWORD
)IntGetWndThreadId(pWnd
);
3800 case QUERY_WINDOW_ACTIVE
:
3801 Result
= (DWORD
)(pWnd
->head
.pti
->MessageQueue
->spwndActive
? UserHMGetHandle(pWnd
->head
.pti
->MessageQueue
->spwndActive
) : 0);
3804 case QUERY_WINDOW_FOCUS
:
3805 Result
= (DWORD
)(pWnd
->head
.pti
->MessageQueue
->spwndFocus
? UserHMGetHandle(pWnd
->head
.pti
->MessageQueue
->spwndFocus
) : 0);
3808 case QUERY_WINDOW_ISHUNG
:
3809 Result
= (DWORD
)MsqIsHung(pWnd
->head
.pti
);
3812 case QUERY_WINDOW_REAL_ID
:
3813 Result
= (DWORD
)pWnd
->head
.pti
->pEThread
->Cid
.UniqueProcess
;
3816 case QUERY_WINDOW_FOREGROUND
:
3817 Result
= (pWnd
->head
.pti
->MessageQueue
== gpqForeground
);
3821 Result
= (DWORD
)NULL
;
3828 TRACE("Leave NtUserQueryWindow, ret=%u\n", _ret_
);
3837 NtUserRegisterWindowMessage(PUNICODE_STRING MessageNameUnsafe
)
3839 UNICODE_STRING SafeMessageName
;
3842 DECLARE_RETURN(UINT
);
3844 TRACE("Enter NtUserRegisterWindowMessage\n");
3845 UserEnterExclusive();
3847 if(MessageNameUnsafe
== NULL
)
3849 EngSetLastError(ERROR_INVALID_PARAMETER
);
3853 Status
= IntSafeCopyUnicodeStringTerminateNULL(&SafeMessageName
, MessageNameUnsafe
);
3854 if(!NT_SUCCESS(Status
))
3856 SetLastNtError(Status
);
3860 Ret
= (UINT
)IntAddAtom(SafeMessageName
.Buffer
);
3861 if (SafeMessageName
.Buffer
)
3862 ExFreePoolWithTag(SafeMessageName
.Buffer
, TAG_STRING
);
3866 TRACE("Leave NtUserRegisterWindowMessage, ret=%u\n", _ret_
);
3875 NtUserSetWindowFNID(HWND hWnd
,
3879 DECLARE_RETURN(BOOL
);
3881 TRACE("Enter NtUserSetWindowFNID\n");
3882 UserEnterExclusive();
3884 if (!(Wnd
= UserGetWindowObject(hWnd
)))
3889 if (Wnd
->head
.pti
->ppi
!= PsGetCurrentProcessWin32Process())
3891 EngSetLastError(ERROR_ACCESS_DENIED
);
3895 // From user land we only set these.
3896 if (fnID
!= FNID_DESTROY
)
3898 /* HACK: The minimum should be FNID_BUTTON, but menu code relies on this */
3899 if (fnID
< FNID_FIRST
|| fnID
> FNID_GHOST
||
3902 EngSetLastError(ERROR_INVALID_PARAMETER
);
3911 TRACE("Leave NtUserSetWindowFNID\n");
3919 * Undocumented function that is called from DefWindowProc to set
3926 NtUserDefSetText(HWND hWnd
, PLARGE_STRING WindowText
)
3929 LARGE_STRING SafeText
;
3930 UNICODE_STRING UnicodeString
;
3933 TRACE("Enter NtUserDefSetText\n");
3935 if (WindowText
!= NULL
)
3939 SafeText
= ProbeForReadLargeString(WindowText
);
3941 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
3944 SetLastNtError(_SEH2_GetExceptionCode());
3954 UserEnterExclusive();
3956 if(!(Wnd
= UserGetWindowObject(hWnd
)))
3962 // ReactOS uses Unicode and not mixed. Up/Down converting will take time.
3963 // Brought to you by: The Wine Project! Dysfunctional Thought Processes!
3964 // Now we know what the bAnsi is for.
3965 RtlInitUnicodeString(&UnicodeString
, NULL
);
3966 if (SafeText
.Buffer
)
3971 ProbeForRead(SafeText
.Buffer
, SafeText
.Length
, sizeof(CHAR
));
3973 ProbeForRead(SafeText
.Buffer
, SafeText
.Length
, sizeof(WCHAR
));
3974 Ret
= RtlLargeStringToUnicodeString(&UnicodeString
, &SafeText
);
3976 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
3979 SetLastNtError(_SEH2_GetExceptionCode());
3982 if (!Ret
) goto Exit
;
3985 if (UnicodeString
.Length
!= 0)
3987 if (Wnd
->strName
.MaximumLength
> 0 &&
3988 UnicodeString
.Length
<= Wnd
->strName
.MaximumLength
- sizeof(UNICODE_NULL
))
3990 ASSERT(Wnd
->strName
.Buffer
!= NULL
);
3992 Wnd
->strName
.Length
= UnicodeString
.Length
;
3993 Wnd
->strName
.Buffer
[UnicodeString
.Length
/ sizeof(WCHAR
)] = L
'\0';
3994 RtlCopyMemory(Wnd
->strName
.Buffer
,
3995 UnicodeString
.Buffer
,
3996 UnicodeString
.Length
);
4001 Wnd
->strName
.MaximumLength
= Wnd
->strName
.Length
= 0;
4002 buf
= Wnd
->strName
.Buffer
;
4003 Wnd
->strName
.Buffer
= NULL
;
4006 DesktopHeapFree(Wnd
->head
.rpdesk
, buf
);
4009 Wnd
->strName
.Buffer
= DesktopHeapAlloc(Wnd
->head
.rpdesk
,
4010 UnicodeString
.Length
+ sizeof(UNICODE_NULL
));
4011 if (Wnd
->strName
.Buffer
!= NULL
)
4013 Wnd
->strName
.Buffer
[UnicodeString
.Length
/ sizeof(WCHAR
)] = L
'\0';
4014 RtlCopyMemory(Wnd
->strName
.Buffer
,
4015 UnicodeString
.Buffer
,
4016 UnicodeString
.Length
);
4017 Wnd
->strName
.MaximumLength
= UnicodeString
.Length
+ sizeof(UNICODE_NULL
);
4018 Wnd
->strName
.Length
= UnicodeString
.Length
;
4022 EngSetLastError(ERROR_NOT_ENOUGH_MEMORY
);
4030 Wnd
->strName
.Length
= 0;
4031 if (Wnd
->strName
.Buffer
!= NULL
)
4032 Wnd
->strName
.Buffer
[0] = L
'\0';
4035 // FIXME: HAX! Windows does not do this in here!
4036 // In User32, these are called after: NotifyWinEvent EVENT_OBJECT_NAMECHANGE than
4037 // RepaintButton, StaticRepaint, NtUserCallHwndLock HWNDLOCK_ROUTINE_REDRAWFRAMEANDHOOK, etc.
4038 /* Send shell notifications */
4039 if (!Wnd
->spwndOwner
&& !IntGetParent(Wnd
))
4041 co_IntShellHookNotify(HSHELL_REDRAW
, (WPARAM
) hWnd
, FALSE
); // FIXME Flashing?
4046 if (UnicodeString
.Buffer
) RtlFreeUnicodeString(&UnicodeString
);
4047 TRACE("Leave NtUserDefSetText, ret=%i\n", Ret
);
4053 * NtUserInternalGetWindowText
4060 NtUserInternalGetWindowText(HWND hWnd
, LPWSTR lpString
, INT nMaxCount
)
4065 DECLARE_RETURN(INT
);
4067 TRACE("Enter NtUserInternalGetWindowText\n");
4070 if(lpString
&& (nMaxCount
<= 1))
4072 EngSetLastError(ERROR_INVALID_PARAMETER
);
4076 if(!(Wnd
= UserGetWindowObject(hWnd
)))
4081 Result
= Wnd
->strName
.Length
/ sizeof(WCHAR
);
4084 const WCHAR Terminator
= L
'\0';
4086 WCHAR
*Buffer
= (WCHAR
*)lpString
;
4088 Copy
= min(nMaxCount
- 1, Result
);
4091 Status
= MmCopyToCaller(Buffer
, Wnd
->strName
.Buffer
, Copy
* sizeof(WCHAR
));
4092 if(!NT_SUCCESS(Status
))
4094 SetLastNtError(Status
);
4100 Status
= MmCopyToCaller(Buffer
, &Terminator
, sizeof(WCHAR
));
4101 if(!NT_SUCCESS(Status
))
4103 SetLastNtError(Status
);
4113 TRACE("Leave NtUserInternalGetWindowText, ret=%i\n",_ret_
);
4123 IntShowOwnedPopups(PWND OwnerWnd
, BOOL fShow
)
4129 // ASSERT(OwnerWnd);
4131 TRACE("Enter ShowOwnedPopups Show: %s\n", (fShow
? "TRUE" : "FALSE"));
4132 win_array
= IntWinListChildren(OwnerWnd
);
4137 while (win_array
[count
])
4139 while (--count
>= 0)
4141 if (!(pWnd
= ValidateHwndNoErr( win_array
[count
] )))
4143 if (pWnd
->spwndOwner
!= OwnerWnd
)
4148 if (pWnd
->state
& WNDS_HIDDENPOPUP
)
4150 /* In Windows, ShowOwnedPopups(TRUE) generates
4151 * WM_SHOWWINDOW messages with SW_PARENTOPENING,
4152 * regardless of the state of the owner
4154 co_IntSendMessage(win_array
[count
], WM_SHOWWINDOW
, SW_SHOWNORMAL
, SW_PARENTOPENING
);
4160 if (pWnd
->style
& WS_VISIBLE
)
4162 /* In Windows, ShowOwnedPopups(FALSE) generates
4163 * WM_SHOWWINDOW messages with SW_PARENTCLOSING,
4164 * regardless of the state of the owner
4166 co_IntSendMessage(win_array
[count
], WM_SHOWWINDOW
, SW_HIDE
, SW_PARENTCLOSING
);
4172 ExFreePoolWithTag(win_array
, USERTAG_WINDOWLIST
);
4173 TRACE("Leave ShowOwnedPopups\n");