ReactOS 0.4.15-dev-5875-g7c755d9
window.c File Reference
#include <win32k.h>
#include <ddk/immdev.h>
Include dependency graph for window.c:

Go to the source code of this file.

Classes

struct  HEADCOMBO
 
struct  _WND2CBOX
 
struct  LB_DESCR
 
struct  _WND2LB
 

Macros

#define GROW_COUNT   8
 
#define INITIAL_COUNT   32
 
#define IS_DEFAULT(x)   ((x) == CW_USEDEFAULT || (x) == (SHORT)0x8000)
 
#define CBF_BUTTONDOWN   0x0002
 
#define GWLP_CONSOLE_LEADER_PID   0
 
#define GWLP_CONSOLE_LEADER_TID   4
 

Typedefs

typedef struct HEADCOMBOLPHEADCOMBO
 
typedef struct _WND2CBOX WND2CBOX
 
typedef struct _WND2CBOXPWND2CBOX
 
typedef struct _WND2LB WND2LB
 
typedef struct _WND2LBPWND2LB
 

Functions

 DBG_DEFAULT_CHANNEL (UserWnd)
 
PVOID FASTCALL IntReAllocatePoolWithTag (POOL_TYPE PoolType, PVOID pOld, SIZE_T cbOld, SIZE_T cbNew, ULONG Tag)
 
BOOL FASTCALL UserUpdateUiState (PWND Wnd, WPARAM wParam)
 
PWND FASTCALL IntGetWindowObject (HWND hWnd)
 
PWND FASTCALL VerifyWnd (PWND pWnd)
 
PWND FASTCALL ValidateHwndNoErr (HWND hWnd)
 
PWND FASTCALL UserGetWindowObject (HWND hWnd)
 
ULONG FASTCALL IntSetStyle (PWND pwnd, ULONG set_bits, ULONG clear_bits)
 
BOOL FASTCALL IntIsWindow (HWND hWnd)
 
BOOL FASTCALL IntIsWindowVisible (PWND Wnd)
 
PWND FASTCALL IntGetParent (PWND Wnd)
 
BOOL FASTCALL IntEnableWindow (HWND hWnd, BOOL bEnable)
 
HWND *FASTCALL IntWinListChildren (PWND Window)
 
static BOOL IntWndIsDefaultIme (_In_ PWND Window)
 
HWND *FASTCALL IntWinListOwnedPopups (PWND Window)
 
PWND FASTCALL IntGetNonChildAncestor (PWND pWnd)
 
BOOL FASTCALL IntIsTopLevelWindow (PWND pWnd)
 
BOOL FASTCALL IntValidateOwnerDepth (PWND Wnd, PWND Owner)
 
HWND FASTCALL IntGetWindow (HWND hWnd, UINT uCmd)
 
DWORD FASTCALL IntGetWindowContextHelpId (PWND pWnd)
 
VOID FASTCALL IntRemoveTrackMouseEvent (PDESKTOP pDesk)
 
static void IntSendDestroyMsg (HWND hWnd)
 
static VOID UserFreeWindowInfo (PTHREADINFO ti, PWND Wnd)
 
LRESULT co_UserFreeWindow (PWND Window, PPROCESSINFO ProcessData, PTHREADINFO ThreadData, BOOLEAN SendMessages)
 
WNDPROC FASTCALL IntGetWindowProc (PWND pWnd, BOOL Ansi)
 
static WNDPROC IntSetWindowProc (PWND pWnd, WNDPROC NewWndProc, BOOL Ansi)
 
BOOL FASTCALL IntIsChildWindow (PWND Parent, PWND BaseWindow)
 
VOID FASTCALL IntLinkWindow (PWND Wnd, PWND WndInsertAfter)
 
VOID FASTCALL IntLinkHwnd (PWND Wnd, HWND hWndPrev)
 
VOID FASTCALL IntProcessOwnerSwap (PWND Wnd, PWND WndNewOwner, PWND WndOldOwner)
 
static HWND FASTCALL IntSetOwner (HWND hWnd, HWND hWndNewOwner)
 
PWND FASTCALL co_IntSetParent (PWND Wnd, PWND WndNewParent)
 
HWND FASTCALL co_UserSetParent (HWND hWndChild, HWND hWndNewParent)
 
VOID FASTCALL IntUnlinkWindow (PWND Wnd)
 
BOOL FASTCALL IntGrowHwndList (PWINDOWLIST *ppwl)
 
PWINDOWLIST FASTCALL IntPopulateHwndList (PWINDOWLIST pwl, PWND pwnd, DWORD dwFlags)
 
PWINDOWLIST FASTCALL IntBuildHwndList (PWND pwnd, DWORD dwFlags, PTHREADINFO pti)
 
VOID FASTCALL IntFreeHwndList (PWINDOWLIST pwlTarget)
 
NTSTATUS NTAPI NtUserBuildHwndList (HDESK hDesktop, HWND hwndParent, BOOLEAN bChildren, ULONG dwThreadId, ULONG cHwnd, HWND *phwndList, ULONG *pcHwndNeeded)
 
static void IntSendParentNotify (PWND pWindow, UINT msg)
 
void FASTCALL IntFixWindowCoordinates (CREATESTRUCTW *Cs, PWND ParentWindow, DWORD *dwShowMode)
 
PWND FASTCALL IntCreateWindow (CREATESTRUCTW *Cs, PLARGE_STRING WindowName, PCLS Class, PWND ParentWindow, PWND OwnerWindow, PVOID acbiBuffer, PDESKTOP pdeskCreated, DWORD dwVer)
 
PWND FASTCALL co_UserCreateWindowEx (CREATESTRUCTW *Cs, PUNICODE_STRING ClassName, PLARGE_STRING WindowName, PVOID acbiBuffer, DWORD dwVer)
 
NTSTATUS NTAPI ProbeAndCaptureLargeString (OUT PLARGE_STRING plstrSafe, IN PLARGE_STRING plstrUnsafe)
 
HWND NTAPI NtUserCreateWindowEx (DWORD dwExStyle, PLARGE_STRING plstrClassName, PLARGE_STRING plstrClsVersion, PLARGE_STRING plstrWindowName, DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam, DWORD dwFlags, PVOID acbiBuffer)
 
VOID FASTCALL IntDestroyOwnedWindows (PWND Window)
 
BOOLEAN co_UserDestroyWindow (PVOID Object)
 
BOOLEAN APIENTRY NtUserDestroyWindow (HWND Wnd)
 
HWND FASTCALL IntFindWindow (PWND Parent, PWND ChildAfter, RTL_ATOM ClassAtom, PUNICODE_STRING WindowName)
 
HWND APIENTRY NtUserFindWindowEx (HWND hwndParent, HWND hwndChildAfter, PUNICODE_STRING ucClassName, PUNICODE_STRING ucWindowName, DWORD dwUnknown)
 
PWND FASTCALL UserGetAncestor (PWND Wnd, UINT Type)
 
HWND APIENTRY NtUserGetAncestor (HWND hWnd, UINT Type)
 
BOOL APIENTRY NtUserGetComboBoxInfo (HWND hWnd, PCOMBOBOXINFO pcbi)
 
DWORD APIENTRY NtUserGetListBoxInfo (HWND hWnd)
 
HWND APIENTRY NtUserSetParent (HWND hWndChild, HWND hWndNewParent)
 
HWND FASTCALL UserGetShellWindow (VOID)
 
BOOL APIENTRY NtUserSetShellWindowEx (HWND hwndShell, HWND hwndListView)
 
static BOOL FASTCALL IntCheckFrameEdge (ULONG Style, ULONG ExStyle)
 
static LONG_PTR co_IntSetWindowLongPtr (HWND hWnd, DWORD Index, LONG_PTR NewValue, BOOL Ansi, ULONG Size, BOOL bAlter)
 
LONG FASTCALL co_UserSetWindowLong (HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi)
 
LONG_PTR FASTCALL co_UserSetWindowLongPtr (HWND hWnd, DWORD Index, LONG_PTR NewValue, BOOL Ansi)
 
LONG APIENTRY NtUserSetWindowLong (HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi)
 
DWORD APIENTRY NtUserAlterWindowStyle (HWND hWnd, DWORD Index, LONG NewValue)
 
WORD APIENTRY NtUserSetWindowWord (HWND hWnd, INT Index, WORD NewValue)
 
DWORD_PTR APIENTRY NtUserQueryWindow (HWND hWnd, DWORD Index)
 
UINT APIENTRY NtUserRegisterWindowMessage (PUNICODE_STRING MessageNameUnsafe)
 
BOOL APIENTRY NtUserSetWindowFNID (HWND hWnd, WORD fnID)
 
BOOL APIENTRY DefSetText (PWND Wnd, PCWSTR WindowText)
 
BOOL APIENTRY NtUserDefSetText (HWND hWnd, PLARGE_STRING WindowText)
 
INT APIENTRY NtUserInternalGetWindowText (HWND hWnd, LPWSTR lpString, INT nMaxCount)
 
BOOL FASTCALL IntShowOwnedPopups (PWND OwnerWnd, BOOL fShow)
 

Variables

INT gNestedWindowLimit = 50
 
PWINDOWLIST gpwlList = NULL
 
PWINDOWLIST gpwlCache = NULL
 

Macro Definition Documentation

◆ CBF_BUTTONDOWN

#define CBF_BUTTONDOWN   0x0002

Definition at line 3448 of file window.c.

◆ GROW_COUNT

#define GROW_COUNT   8

◆ GWLP_CONSOLE_LEADER_PID

#define GWLP_CONSOLE_LEADER_PID   0

◆ GWLP_CONSOLE_LEADER_TID

#define GWLP_CONSOLE_LEADER_TID   4

◆ INITIAL_COUNT

#define INITIAL_COUNT   32

◆ IS_DEFAULT

#define IS_DEFAULT (   x)    ((x) == CW_USEDEFAULT || (x) == (SHORT)0x8000)

Typedef Documentation

◆ LPHEADCOMBO

◆ PWND2CBOX

◆ PWND2LB

typedef struct _WND2LB * PWND2LB

◆ WND2CBOX

◆ WND2LB

Function Documentation

◆ co_IntSetParent()

PWND FASTCALL co_IntSetParent ( PWND  Wnd,
PWND  WndNewParent 
)

Definition at line 1143 of file window.c.

1144{
1145 PWND WndOldParent, pWndExam;
1146 BOOL WasVisible;
1147 POINT pt;
1148 int swFlags = SWP_NOSIZE|SWP_NOZORDER;
1149
1150 ASSERT(Wnd);
1151 ASSERT(WndNewParent);
1152 ASSERT_REFS_CO(Wnd);
1153 ASSERT_REFS_CO(WndNewParent);
1154
1155 if (Wnd == Wnd->head.rpdesk->spwndMessage)
1156 {
1158 return( NULL);
1159 }
1160
1161 /* Some applications try to set a child as a parent */
1162 if (IntIsChildWindow(Wnd, WndNewParent))
1163 {
1164 TRACE("IntSetParent try to set a child as a parent.\n");
1166 return NULL;
1167 }
1168
1169 pWndExam = WndNewParent; // Load parent Window to examine.
1170 // Now test for set parent to parent hit.
1171 while (pWndExam)
1172 {
1173 if (Wnd == pWndExam)
1174 {
1175 TRACE("IntSetParent Failed Test for set parent to parent!\n");
1177 return NULL;
1178 }
1179 pWndExam = pWndExam->spwndParent;
1180 }
1181
1182 /*
1183 * Windows hides the window first, then shows it again
1184 * including the WM_SHOWWINDOW messages and all
1185 */
1186 WasVisible = co_WinPosShowWindow(Wnd, SW_HIDE);
1187
1188 /* Window must belong to current process */
1189 if (Wnd->head.pti->ppi != PsGetCurrentProcessWin32Process())
1190 {
1191 ERR("IntSetParent Window must belong to current process!\n");
1192 return NULL;
1193 }
1194
1195 WndOldParent = Wnd->spwndParent;
1196
1197 if ( WndOldParent &&
1198 WndOldParent->ExStyle & WS_EX_LAYOUTRTL)
1199 pt.x = Wnd->rcWindow.right;
1200 else
1201 pt.x = Wnd->rcWindow.left;
1202 pt.y = Wnd->rcWindow.top;
1203
1204 IntScreenToClient(WndOldParent, &pt);
1205
1206 if (WndOldParent) UserReferenceObject(WndOldParent); /* Caller must deref */
1207
1208 if (WndNewParent != WndOldParent)
1209 {
1210 /* Unlink the window from the siblings list */
1211 IntUnlinkWindow(Wnd);
1212 Wnd->ExStyle2 &= ~WS_EX2_LINKED;
1213
1214 /* Set the new parent */
1215 Wnd->spwndParent = WndNewParent;
1216
1217 if ( Wnd->style & WS_CHILD &&
1218 Wnd->spwndOwner &&
1219 Wnd->spwndOwner->ExStyle & WS_EX_TOPMOST )
1220 {
1221 ERR("SetParent Top Most from Pop up!\n");
1222 Wnd->ExStyle |= WS_EX_TOPMOST;
1223 }
1224
1225 /* Link the window with its new siblings */
1226 IntLinkHwnd( Wnd,
1227 ((0 == (Wnd->ExStyle & WS_EX_TOPMOST) &&
1228 UserIsDesktopWindow(WndNewParent) ) ? HWND_TOP : HWND_TOPMOST ) );
1229 }
1230
1231 if ( WndNewParent == co_GetDesktopWindow(Wnd) &&
1232 !(Wnd->style & WS_CLIPSIBLINGS) )
1233 {
1234 Wnd->style |= WS_CLIPSIBLINGS;
1235 DceResetActiveDCEs(Wnd);
1236 }
1237
1238 /* if parent belongs to a different thread and the window isn't */
1239 /* top-level, attach the two threads */
1240 if ((Wnd->style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
1241 {
1242 if ( Wnd->spwndParent != co_GetDesktopWindow(Wnd))
1243 {
1244 if (WndOldParent && (Wnd->head.pti != WndOldParent->head.pti))
1245 {
1246 //ERR("SetParent Old out.\n");
1247 UserAttachThreadInput(Wnd->head.pti, WndOldParent->head.pti, FALSE);
1248 }
1249 }
1250 if ( WndNewParent != co_GetDesktopWindow(Wnd))
1251 {
1252 if (Wnd->head.pti != WndNewParent->head.pti)
1253 {
1254 //ERR("SetParent New in.\n");
1255 UserAttachThreadInput(Wnd->head.pti, WndNewParent->head.pti, TRUE);
1256 }
1257 }
1258 }
1259
1260 if (UserIsMessageWindow(WndOldParent) || UserIsMessageWindow(WndNewParent))
1261 swFlags |= SWP_NOACTIVATE;
1262
1263 IntNotifyWinEvent(EVENT_OBJECT_PARENTCHANGE, Wnd ,OBJID_WINDOW, CHILDID_SELF, WEF_SETBYWNDPTI);
1264 /*
1265 * SetParent additionally needs to make hwnd the top window
1266 * in the z-order and send the expected WM_WINDOWPOSCHANGING and
1267 * WM_WINDOWPOSCHANGED notification messages.
1268 */
1269 //ERR("IntSetParent SetWindowPos 1\n");
1271 (0 == (Wnd->ExStyle & WS_EX_TOPMOST) ? HWND_TOP : HWND_TOPMOST),
1272 pt.x, pt.y, 0, 0, swFlags);
1273 //ERR("IntSetParent SetWindowPos 2 X %d Y %d\n",pt.x, pt.y);
1274 if (WasVisible) co_WinPosShowWindow(Wnd, SW_SHOWNORMAL);
1275
1276 return WndOldParent;
1277}
#define ERR(fmt,...)
Definition: debug.h:110
VOID FASTCALL DceResetActiveDCEs(PWND Window)
Definition: windc.c:816
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define pt(x, y)
Definition: drawing.c:79
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WEF_SETBYWNDPTI
Definition: ntuser.h:235
#define ASSERT(a)
Definition: mode.c:44
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
BOOLEAN FASTCALL co_WinPosSetWindowPos(PWND Window, HWND WndInsertAfter, INT x, INT y, INT cx, INT cy, UINT flags)
Definition: winpos.c:1787
BOOL FASTCALL IntScreenToClient(PWND Wnd, LPPOINT lpPoint)
Definition: winpos.c:214
BOOLEAN FASTCALL co_WinPosShowWindow(PWND Wnd, INT Cmd)
Definition: winpos.c:2567
#define WS_CHILD
Definition: pedump.c:617
#define WS_POPUP
Definition: pedump.c:616
#define WS_EX_TOPMOST
Definition: pedump.c:647
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define TRACE(s)
Definition: solgame.cpp:4
struct _DESKTOP * rpdesk
Definition: ntuser.h:194
Definition: ntuser.h:689
DWORD ExStyle
Definition: ntuser.h:699
DWORD ExStyle2
Definition: ntuser.h:740
struct _WND * spwndOwner
Definition: ntuser.h:710
THRDESKHEAD head
Definition: ntuser.h:690
DWORD style
Definition: ntuser.h:701
RECT rcWindow
Definition: ntuser.h:711
struct _WND * spwndParent
Definition: ntuser.h:708
LONG right
Definition: windef.h:308
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define ASSERT_REFS_CO(_obj_)
Definition: userfuncs.h:14
PWND FASTCALL co_GetDesktopWindow(PWND pWnd)
Definition: desktop.c:1366
#define UserIsMessageWindow(pWnd)
Definition: desktop.h:197
#define UserIsDesktopWindow(pWnd)
Definition: desktop.h:194
VOID FASTCALL IntNotifyWinEvent(DWORD Event, PWND pWnd, LONG idObject, LONG idChild, DWORD flags)
Definition: event.c:179
NTSTATUS FASTCALL UserAttachThreadInput(PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach)
Definition: input.c:480
VOID FASTCALL UserReferenceObject(PVOID obj)
Definition: object.c:731
VOID FASTCALL IntUnlinkWindow(PWND Wnd)
Definition: window.c:1341
BOOL FASTCALL IntIsChildWindow(PWND Parent, PWND BaseWindow)
Definition: window.c:922
VOID FASTCALL IntLinkHwnd(PWND Wnd, HWND hWndPrev)
Definition: window.c:977
#define OBJID_WINDOW
Definition: winable.h:15
#define CHILDID_SELF
Definition: winable.h:14
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:28
#define SW_SHOWNORMAL
Definition: winuser.h:764
#define WS_EX_LAYOUTRTL
Definition: winuser.h:390
#define SW_HIDE
Definition: winuser.h:762
#define SWP_NOACTIVATE
Definition: winuser.h:1232
#define HWND_TOPMOST
Definition: winuser.h:1198
#define SWP_NOSIZE
Definition: winuser.h:1235
#define HWND_TOP
Definition: winuser.h:1197
#define SWP_NOZORDER
Definition: winuser.h:1237

Referenced by co_UserSetParent().

◆ co_IntSetWindowLongPtr()

static LONG_PTR co_IntSetWindowLongPtr ( HWND  hWnd,
DWORD  Index,
LONG_PTR  NewValue,
BOOL  Ansi,
ULONG  Size,
BOOL  bAlter 
)
static

Definition at line 3813 of file window.c.

3814{
3816 PWINSTATION_OBJECT WindowStation;
3817 LONG_PTR OldValue;
3819
3821 {
3822 return( 0);
3823 }
3824
3825 if ((INT)Index >= 0)
3826 {
3827 if ((Index + Size) > Window->cbwndExtra)
3828 {
3830 return( 0);
3831 }
3832
3833#ifdef _WIN64
3834 if (Size == sizeof(LONG))
3835 {
3836 OldValue = *((LONG *)((PCHAR)(Window + 1) + Index));
3837 *((LONG*)((PCHAR)(Window + 1) + Index)) = (LONG)NewValue;
3838 }
3839 else
3840#endif
3841 {
3842 OldValue = *((LONG_PTR *)((PCHAR)(Window + 1) + Index));
3843 /*
3844 if ( Index == DWLP_DLGPROC && Wnd->state & WNDS_DIALOGWINDOW)
3845 {
3846 OldValue = (LONG_PTR)IntSetWindowProc( Wnd, (WNDPROC)NewValue, Ansi);
3847 if (!OldValue) return 0;
3848 }
3849 */
3850 *((LONG_PTR*)((PCHAR)(Window + 1) + Index)) = NewValue;
3851 }
3852
3853 }
3854 else
3855 {
3856#ifdef _WIN64
3857 if (Size == sizeof(LONG))
3858 {
3859 if ((Index != GWL_STYLE) &&
3860 (Index != GWL_EXSTYLE) &&
3861 (Index != GWL_ID) &&
3862 (Index != GWL_USERDATA))
3863 {
3864 ERR("NtUserSetWindowLong(): Index requires pointer size: %lu\n", Index);
3866 return 0;
3867 }
3868 }
3869#endif
3870
3871 switch (Index)
3872 {
3873 case GWL_EXSTYLE: // LONG
3874 OldValue = (LONG) Window->ExStyle;
3875 Style.styleOld = OldValue;
3876 Style.styleNew = NewValue;
3877
3878 co_IntSendMessage(hWnd, WM_STYLECHANGING, GWL_EXSTYLE, (LPARAM) &Style);
3879
3880 /*
3881 * Remove extended window style bit WS_EX_TOPMOST for shell windows.
3882 */
3883 WindowStation = Window->head.pti->rpdesk->rpwinstaParent;
3884 if(WindowStation)
3885 {
3886 if (hWnd == WindowStation->ShellWindow || hWnd == WindowStation->ShellListView)
3887 Style.styleNew &= ~WS_EX_TOPMOST;
3888 }
3889 /* WS_EX_WINDOWEDGE depends on some other styles */
3890 if (IntCheckFrameEdge(Window->style, NewValue))
3891 Style.styleNew |= WS_EX_WINDOWEDGE;
3892 else
3893 Style.styleNew &= ~WS_EX_WINDOWEDGE;
3894
3895 if (!(Window->ExStyle & WS_EX_LAYERED))
3896 {
3898 }
3899
3900 Window->ExStyle = (DWORD)Style.styleNew;
3901
3902 co_IntSendMessage(hWnd, WM_STYLECHANGED, GWL_EXSTYLE, (LPARAM) &Style);
3903 break;
3904
3905 case GWL_STYLE: // LONG
3906 OldValue = (LONG) Window->style;
3907 Style.styleOld = OldValue;
3908 Style.styleNew = NewValue;
3909
3910 if (!bAlter)
3911 co_IntSendMessage(hWnd, WM_STYLECHANGING, GWL_STYLE, (LPARAM) &Style);
3912
3913 /* WS_CLIPSIBLINGS can't be reset on top-level windows */
3914 if (UserIsDesktopWindow(Window->spwndParent)) Style.styleNew |= WS_CLIPSIBLINGS;
3915 /* WS_MINIMIZE can't be reset */
3916 if (OldValue & WS_MINIMIZE) Style.styleNew |= WS_MINIMIZE;
3917 /* Fixes wine FIXME: changing WS_DLGFRAME | WS_THICKFRAME is supposed to change WS_EX_WINDOWEDGE too */
3918 if (IntCheckFrameEdge(NewValue, Window->ExStyle))
3919 Window->ExStyle |= WS_EX_WINDOWEDGE;
3920 else
3921 Window->ExStyle &= ~WS_EX_WINDOWEDGE;
3922
3923 if ((OldValue & (WS_CHILD | WS_POPUP)) == WS_CHILD)
3924 {
3925 if ((NewValue & (WS_CHILD | WS_POPUP)) != WS_CHILD)
3926 {
3928 ERR("IDMenu going null! %d\n",Window->IDMenu);
3929 Window->IDMenu = 0; // Window->spmenu = 0;
3930 }
3931 }
3932 else
3933 {
3934 if ((NewValue & (WS_CHILD | WS_POPUP)) == WS_CHILD)
3935 {
3936 PMENU pMenu = UserGetMenuObject(UlongToHandle(Window->IDMenu));
3937 Window->state &= ~WNDS_HASMENU;
3938 if (pMenu)
3939 {
3940 ERR("IDMenu released 0x%p\n",pMenu);
3941 // ROS may not hold a lock after setting menu to window. But it should!
3942 //IntReleaseMenuObject(pMenu);
3943 }
3944 }
3945 }
3946
3947 if ((Style.styleOld ^ Style.styleNew) & WS_VISIBLE)
3948 {
3949 if (Style.styleOld & WS_VISIBLE) Window->head.pti->cVisWindows--;
3950 if (Style.styleNew & WS_VISIBLE) Window->head.pti->cVisWindows++;
3952 }
3953 Window->style = (DWORD)Style.styleNew;
3954
3955 if (!bAlter)
3956 co_IntSendMessage(hWnd, WM_STYLECHANGED, GWL_STYLE, (LPARAM) &Style);
3957 break;
3958
3959 case GWLP_WNDPROC: // LONG_PTR
3960 {
3961 if ( Window->head.pti->ppi != PsGetCurrentProcessWin32Process() ||
3962 Window->fnid & FNID_FREED)
3963 {
3965 return( 0);
3966 }
3967 OldValue = (LONG_PTR)IntSetWindowProc(Window,
3968 (WNDPROC)NewValue,
3969 Ansi);
3970 break;
3971 }
3972
3973 case GWLP_HINSTANCE: // LONG_PTR
3974 OldValue = (LONG_PTR) Window->hModule;
3975 Window->hModule = (HINSTANCE) NewValue;
3976 break;
3977
3978 case GWLP_HWNDPARENT: // LONG_PTR
3979 Parent = Window->spwndParent;
3980 if (Parent && (Parent->head.h == IntGetDesktopWindow()))
3981 OldValue = (LONG_PTR) IntSetOwner(Window->head.h, (HWND) NewValue);
3982 else
3983 OldValue = (LONG_PTR) co_UserSetParent(Window->head.h, (HWND) NewValue);
3984 break;
3985
3986 case GWLP_ID: // LONG
3987 OldValue = (LONG) Window->IDMenu;
3988 Window->IDMenu = (UINT) NewValue;
3989 break;
3990
3991 case GWLP_USERDATA: // LONG or LONG_PTR
3992 OldValue = Window->dwUserData;
3993 Window->dwUserData = NewValue;
3994 break;
3995
3996 default:
3997 ERR("NtUserSetWindowLong(): Unsupported index %lu\n", Index);
3999 OldValue = 0;
4000 break;
4001 }
4002 }
4003
4004 return( OldValue);
4005}
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:732
const DWORD Style
Definition: appswitch.c:71
HWND hWnd
Definition: settings.c:17
#define UlongToHandle(ul)
Definition: basetsd.h:97
#define FNID_FREED
Definition: ntuser.h:895
BOOL FASTCALL SetLayeredStatus(PWND pWnd, BYTE set)
Definition: layered.c:34
if(dx< 0)
Definition: linetemp.h:194
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define DWORD
Definition: nt_native.h:44
#define WS_MINIMIZE
Definition: pedump.c:622
#define WS_VISIBLE
Definition: pedump.c:620
long LONG
Definition: pedump.c:60
Definition: window.c:28
HANDLE ShellListView
Definition: winsta.h:44
HANDLE ShellWindow
Definition: winsta.h:43
#define LONG_PTR
Definition: treelist.c:79
#define GWLP_WNDPROC
Definition: treelist.c:66
#define GWLP_USERDATA
Definition: treelist.c:63
int32_t INT
Definition: typedefs.h:58
char * PCHAR
Definition: typedefs.h:51
FORCEINLINE PMENU UserGetMenuObject(HMENU hMenu)
Definition: userfuncs.h:4
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
HWND FASTCALL IntGetDesktopWindow(VOID)
Definition: desktop.c:1374
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1446
HWND FASTCALL co_UserSetParent(HWND hWndChild, HWND hWndNewParent)
Definition: window.c:1281
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:122
static BOOL FASTCALL IntCheckFrameEdge(ULONG Style, ULONG ExStyle)
Definition: window.c:3802
static WNDPROC IntSetWindowProc(PWND pWnd, WNDPROC NewWndProc, BOOL Ansi)
Definition: window.c:835
static HWND FASTCALL IntSetOwner(HWND hWnd, HWND hWndNewOwner)
Definition: window.c:1102
LONG_PTR LPARAM
Definition: windef.h:208
#define ERROR_INVALID_INDEX
Definition: winerror.h:894
#define GWL_USERDATA
Definition: winuser.h:855
#define GWL_ID
Definition: winuser.h:853
#define GWLP_HINSTANCE
Definition: winuser.h:850
#define GWLP_HWNDPARENT
Definition: winuser.h:852
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
#define WS_EX_LAYERED
Definition: winuser.h:389
#define GWLP_ID
Definition: winuser.h:854
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2896
#define GWL_STYLE
Definition: winuser.h:846
#define GWL_EXSTYLE
Definition: winuser.h:845

Referenced by co_UserSetWindowLong(), co_UserSetWindowLongPtr(), NtUserAlterWindowStyle(), and NtUserSetWindowLong().

◆ co_UserCreateWindowEx()

PWND FASTCALL co_UserCreateWindowEx ( CREATESTRUCTW Cs,
PUNICODE_STRING  ClassName,
PLARGE_STRING  WindowName,
PVOID  acbiBuffer,
DWORD  dwVer 
)

Definition at line 2158 of file window.c.

2163{
2164 ULONG style;
2165 PWND Window = NULL, ParentWindow = NULL, OwnerWindow;
2166 HWND hWnd, hWndParent, hWndOwner, hwndInsertAfter;
2167 PWINSTATION_OBJECT WinSta;
2168 PCLS Class = NULL;
2169 SIZE Size;
2170 POINT MaxSize, MaxPos, MinTrack, MaxTrack;
2171 CBT_CREATEWNDW * pCbtCreate;
2173 USER_REFERENCE_ENTRY ParentRef, Ref;
2174 PTHREADINFO pti;
2175 DWORD dwShowMode = SW_SHOW;
2176 CREATESTRUCTW *pCsw = NULL;
2177 PVOID pszClass = NULL, pszName = NULL;
2178 PWND ret = NULL;
2179
2180 /* Get the current window station and reference it */
2181 pti = GetW32ThreadInfo();
2182 if (pti == NULL || pti->rpdesk == NULL)
2183 {
2184 ERR("Thread is not attached to a desktop! Cannot create window!\n");
2185 return NULL; // There is nothing to cleanup.
2186 }
2187 WinSta = pti->rpdesk->rpwinstaParent;
2189
2190 pCsw = NULL;
2191 pCbtCreate = NULL;
2192
2193 /* Get the class and reference it */
2194 Class = IntGetAndReferenceClass(ClassName, Cs->hInstance, FALSE);
2195 if(!Class)
2196 {
2198 ERR("Failed to find class %wZ\n", ClassName);
2199 goto cleanup;
2200 }
2201
2202 /* Now find the parent and the owner window */
2203 hWndParent = pti->rpdesk->pDeskInfo->spwnd->head.h;
2204 hWndOwner = NULL;
2205
2206 if (Cs->hwndParent == HWND_MESSAGE)
2207 {
2208 Cs->hwndParent = hWndParent = pti->rpdesk->spwndMessage->head.h;
2209 }
2210 else if (Cs->hwndParent)
2211 {
2212 if ((Cs->style & (WS_CHILD|WS_POPUP)) != WS_CHILD)
2213 hWndOwner = Cs->hwndParent;
2214 else
2215 hWndParent = Cs->hwndParent;
2216 }
2217 else if ((Cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
2218 {
2219 ERR("Cannot create a child window without a parent!\n");
2221 goto cleanup; /* WS_CHILD needs a parent, but WS_POPUP doesn't */
2222 }
2224 (IS_INTRESOURCE(Cs->lpszClass) ||
2225 Cs->lpszClass != (LPCWSTR)MAKEINTATOM(gpsi->atomSysClass[ICLS_HWNDMESSAGE]) ||
2226 _wcsicmp(Cs->lpszClass, L"Message") != 0))
2227 {
2228 if (pti->ppi->dwLayout & LAYOUT_RTL)
2229 {
2231 }
2232 }
2233
2234 ParentWindow = hWndParent ? UserGetWindowObject(hWndParent): NULL;
2235 OwnerWindow = hWndOwner ? UserGetWindowObject(hWndOwner): NULL;
2236
2237 if (hWndParent && !ParentWindow)
2238 {
2239 ERR("Got invalid parent window handle\n");
2240 goto cleanup;
2241 }
2242 else if (hWndOwner && !OwnerWindow)
2243 {
2244 ERR("Got invalid owner window handle\n");
2245 ParentWindow = NULL;
2246 goto cleanup;
2247 }
2248
2249 if(OwnerWindow)
2250 {
2251 if (IntIsDesktopWindow(OwnerWindow)) OwnerWindow = NULL;
2252 else if (ParentWindow && !IntIsDesktopWindow(ParentWindow))
2253 {
2254 ERR("an owned window must be created as top-level\n");
2256 goto cleanup;
2257 }
2258 else /* owner must be a top-level window */
2259 {
2260 while ((OwnerWindow->style & (WS_POPUP|WS_CHILD)) == WS_CHILD && !IntIsDesktopWindow(OwnerWindow->spwndParent))
2261 OwnerWindow = OwnerWindow->spwndParent;
2262 }
2263 }
2264
2265 /* Fix the position and the size of the window */
2266 if (ParentWindow)
2267 {
2268 UserRefObjectCo(ParentWindow, &ParentRef);
2269 IntFixWindowCoordinates(Cs, ParentWindow, &dwShowMode);
2270 }
2271
2272 /* Allocate and initialize the new window */
2274 WindowName,
2275 Class,
2276 ParentWindow,
2277 OwnerWindow,
2278 acbiBuffer,
2279 NULL,
2280 dwVer );
2281 if(!Window)
2282 {
2283 ERR("IntCreateWindow failed!\n");
2284 goto cleanup;
2285 }
2286
2288 hwndInsertAfter = HWND_TOP;
2289
2290 UserRefObjectCo(Window, &Ref);
2292 ObDereferenceObject(WinSta);
2293
2294 /* NCCREATE, WM_NCCALCSIZE and Hooks need the original values */
2295 Cs->lpszName = (LPCWSTR) WindowName;
2296 Cs->lpszClass = (LPCWSTR) ClassName;
2297
2299 if ( ISITHOOKED(WH_CBT) || (pti->rpdesk->pDeskInfo->fsHooks & HOOKID_TO_FLAG(WH_CBT)) )
2300 {
2301 // Allocate the calling structures Justin Case this goes Global.
2304 if (!pCsw || !pCbtCreate)
2305 {
2306 ERR("UserHeapAlloc() failed!\n");
2307 goto cleanup;
2308 }
2309
2310 if (!IntMsgCreateStructW( Window, pCsw, Cs, &pszClass, &pszName ) )
2311 {
2312 ERR("IntMsgCreateStructW() failed!\n");
2313 goto cleanup;
2314 }
2315
2316 pCbtCreate->lpcs = pCsw;
2317 pCbtCreate->hwndInsertAfter = hwndInsertAfter;
2318
2321 if (Result != 0)
2322 {
2323 ERR("WH_CBT HCBT_CREATEWND hook failed! 0x%x\n", Result);
2324 goto cleanup;
2325 }
2326 // Write back changes.
2327 Cs->cx = pCsw->cx;
2328 Cs->cy = pCsw->cy;
2329 Cs->x = pCsw->x;
2330 Cs->y = pCsw->y;
2331 hwndInsertAfter = pCbtCreate->hwndInsertAfter;
2332 }
2333
2334 if ((Cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
2335 {
2336 if (ParentWindow != co_GetDesktopWindow(Window))
2337 {
2338 Cs->x += ParentWindow->rcClient.left;
2339 Cs->y += ParentWindow->rcClient.top;
2340 }
2341 }
2342
2343 /* Send the WM_GETMINMAXINFO message */
2344 Size.cx = Cs->cx;
2345 Size.cy = Cs->cy;
2346
2347 if ((Cs->style & WS_THICKFRAME) || !(Cs->style & (WS_POPUP | WS_CHILD)))
2348 {
2349 co_WinPosGetMinMaxInfo(Window, &MaxSize, &MaxPos, &MinTrack, &MaxTrack);
2350 if (Size.cx > MaxTrack.x) Size.cx = MaxTrack.x;
2351 if (Size.cy > MaxTrack.y) Size.cy = MaxTrack.y;
2352 if (Size.cx < MinTrack.x) Size.cx = MinTrack.x;
2353 if (Size.cy < MinTrack.y) Size.cy = MinTrack.y;
2354 }
2355
2356 Window->rcWindow.left = Cs->x;
2357 Window->rcWindow.top = Cs->y;
2358 Window->rcWindow.right = Cs->x + Size.cx;
2359 Window->rcWindow.bottom = Cs->y + Size.cy;
2360 /*
2361 if (0 != (Window->style & WS_CHILD) && ParentWindow)
2362 {
2363 ERR("co_UserCreateWindowEx(): Offset rcWindow\n");
2364 RECTL_vOffsetRect(&Window->rcWindow,
2365 ParentWindow->rcClient.left,
2366 ParentWindow->rcClient.top);
2367 }
2368 */
2369 /* correct child window coordinates if mirroring on parent is enabled */
2370 if (ParentWindow != NULL)
2371 {
2372 if ( ((Cs->style & WS_CHILD) == WS_CHILD) &&
2373 ((ParentWindow->ExStyle & WS_EX_LAYOUTRTL) == WS_EX_LAYOUTRTL))
2374 {
2375 Window->rcWindow.right = ParentWindow->rcClient.right - (Window->rcWindow.left - ParentWindow->rcClient.left);
2376 Window->rcWindow.left = Window->rcWindow.right - Size.cx;
2377 }
2378 }
2379
2380 Window->rcClient = Window->rcWindow;
2381
2382 if (Window->spwndNext || Window->spwndPrev)
2383 {
2384 ERR("Window 0x%p has been linked too early!\n", Window);
2385 }
2386
2387 if (!(Window->state2 & WNDS2_WIN31COMPAT))
2388 {
2389 if (Class->style & CS_PARENTDC && !(ParentWindow->style & WS_CLIPCHILDREN))
2390 Window->style &= ~(WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
2391 }
2392
2393 if ((Window->style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
2394 {
2396 {
2397 if (pti != ParentWindow->head.pti)
2398 {
2399 //ERR("CreateWindow Parent in.\n");
2400 UserAttachThreadInput(pti, ParentWindow->head.pti, TRUE);
2401 }
2402 }
2403 }
2404
2405 /* Send the NCCREATE message */
2407 if (!Result)
2408 {
2409 ERR("co_UserCreateWindowEx(): NCCREATE message failed\n");
2410 goto cleanup;
2411 }
2412
2413 /* Link the window */
2414 if (ParentWindow != NULL)
2415 {
2416 /* Link the window into the siblings list */
2417 if ((Cs->style & (WS_CHILD | WS_MAXIMIZE)) == WS_CHILD)
2419 else
2420 IntLinkHwnd(Window, hwndInsertAfter);
2421 }
2422
2423 /* Create the IME window for pWnd */
2425 {
2426 PWND pwndDefaultIme = co_IntCreateDefaultImeWindow(Window, Window->hModule);
2427 UserAssignmentLock((PVOID*)&pti->spwndDefaultIme, pwndDefaultIme);
2428
2429 if (pwndDefaultIme)
2430 {
2431 HWND hImeWnd;
2433 UserRefObjectCo(pwndDefaultIme, &Ref);
2434
2435 hImeWnd = UserHMGetHandle(pwndDefaultIme);
2436
2438
2439 if (pti->pClientInfo->CI_flags & CI_IMMACTIVATE)
2440 {
2441 HKL hKL = pti->KeyboardLayout->hkl;
2443 pti->pClientInfo->CI_flags &= ~CI_IMMACTIVATE;
2444 }
2445
2446 UserDerefObjectCo(pwndDefaultIme);
2447 }
2448 }
2449
2450 /* Send the WM_NCCALCSIZE message */
2451 {
2452 // RECT rc;
2453 MaxPos.x = Window->rcWindow.left;
2454 MaxPos.y = Window->rcWindow.top;
2455
2456 Result = co_WinPosGetNonClientSize(Window, &Window->rcWindow, &Window->rcClient);
2457 //rc = Window->rcWindow;
2458 //Result = co_IntSendMessageNoWait(Window->head.h, WM_NCCALCSIZE, FALSE, (LPARAM)&rc);
2459 //Window->rcClient = rc;
2460
2461 RECTL_vOffsetRect(&Window->rcWindow, MaxPos.x - Window->rcWindow.left,
2462 MaxPos.y - Window->rcWindow.top);
2463 }
2464
2465 /* Send the WM_CREATE message. */
2467 if (Result == (LRESULT)-1)
2468 {
2469 ERR("co_UserCreateWindowEx(): WM_CREATE message failed\n");
2470 goto cleanup;
2471 }
2472
2473 /* Send the EVENT_OBJECT_CREATE event */
2474 IntNotifyWinEvent(EVENT_OBJECT_CREATE, Window, OBJID_WINDOW, CHILDID_SELF, 0);
2475
2476 /* By setting the flag below it can be examined to determine if the window
2477 was created successfully and a valid pwnd was passed back to caller since
2478 from here the function has to succeed. */
2480
2481 /* Send the WM_SIZE and WM_MOVE messages. */
2482 if (!(Window->state & WNDS_SENDSIZEMOVEMSGS))
2483 {
2485 }
2486
2487 /* Show or maybe minimize or maximize the window. */
2488
2490 if (style & (WS_MINIMIZE | WS_MAXIMIZE))
2491 {
2492 RECTL NewPos;
2493 UINT SwFlag = (style & WS_MINIMIZE) ? SW_MINIMIZE : SW_MAXIMIZE;
2494
2495 SwFlag = co_WinPosMinMaximize(Window, SwFlag, &NewPos);
2496 SwFlag |= SWP_NOZORDER|SWP_FRAMECHANGED; /* Frame always gets changed */
2497 if (!(style & WS_VISIBLE) || (style & WS_CHILD) || UserGetActiveWindow() ||
2498 (Window->ExStyle & WS_EX_NOACTIVATE))
2499 {
2500 SwFlag |= SWP_NOACTIVATE;
2501 }
2502 co_WinPosSetWindowPos(Window, 0, NewPos.left, NewPos.top,
2503 NewPos.right, NewPos.bottom, SwFlag);
2504 }
2505
2506 /* Send the WM_PARENTNOTIFY message */
2508
2509 /* Notify the shell that a new window was created */
2510 if (Window->spwndOwner == NULL ||
2511 !(Window->spwndOwner->style & WS_VISIBLE) ||
2512 (Window->spwndOwner->ExStyle & WS_EX_TOOLWINDOW))
2513 {
2514 if (UserIsDesktopWindow(Window->spwndParent) &&
2515 (Window->style & WS_VISIBLE) &&
2516 (!(Window->ExStyle & WS_EX_TOOLWINDOW) ||
2517 (Window->ExStyle & WS_EX_APPWINDOW)))
2518 {
2520 }
2521 }
2522
2523 /* Initialize and show the window's scrollbars */
2524 if (Window->style & WS_VSCROLL)
2525 {
2527 }
2528 if (Window->style & WS_HSCROLL)
2529 {
2531 }
2532
2533 /* Show the new window */
2534 if (Cs->style & WS_VISIBLE)
2535 {
2536 if (Window->style & WS_MAXIMIZE)
2537 dwShowMode = SW_SHOW;
2538 else if (Window->style & WS_MINIMIZE)
2539 dwShowMode = SW_SHOWMINIMIZED;
2540
2541 co_WinPosShowWindow(Window, dwShowMode);
2542
2543 if (Window->ExStyle & WS_EX_MDICHILD)
2544 {
2545 ASSERT(ParentWindow);
2546 if(!ParentWindow)
2547 goto cleanup;
2549 /* ShowWindow won't activate child windows */
2551 }
2552 }
2553
2554 if (Class->atomClassName == gaGuiConsoleWndClass)
2555 {
2556 /* Count only console windows manually */
2558 }
2559
2560 TRACE("co_UserCreateWindowEx(): Created window %p\n", hWnd);
2561 ret = Window;
2562
2563cleanup:
2564 if (!ret)
2565 {
2566 TRACE("co_UserCreateWindowEx(): Error Created window!\n");
2567 /* If the window was created, the class will be dereferenced by co_UserDestroyWindow */
2568 if (Window)
2570 else if (Class)
2572 }
2573
2574 if (pCsw) ExFreePoolWithTag(pCsw, TAG_HOOK);
2575 if (pCbtCreate) ExFreePoolWithTag(pCbtCreate, TAG_HOOK);
2576 if (pszName) UserHeapFree(pszName);
2577 if (pszClass) UserHeapFree(pszClass);
2578
2579 if (Window)
2580 {
2582 }
2583 if (ParentWindow) UserDerefObjectCo(ParentWindow);
2584
2585 // See CORE-13717, not setting error on success.
2586 if (ret)
2588
2589 return ret;
2590}
Arabic default style
Definition: afstyles.h:94
#define ERROR_SUCCESS
Definition: deptool.c:10
PSERVERINFO gpsi
Definition: imm.c:18
static void cleanup(void)
Definition: main.c:1335
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define NonPagedPool
Definition: env_spec_w32.h:307
unsigned long DWORD
Definition: ntddk_ex.h:95
HWND FASTCALL UserGetActiveWindow(VOID)
Definition: focus.c:1429
VOID FASTCALL co_IntUserManualGuiCheck(BOOL Create)
Definition: guicheck.c:77
#define ISITHOOKED(HookId)
Definition: hook.h:6
#define HOOKID_TO_FLAG(HookId)
Definition: hook.h:5
#define IMS_LOADTHREADLAYOUT
Definition: immdev.h:45
#define IMS_ACTIVATELAYOUT
Definition: immdev.h:40
#define WNDS2_WIN31COMPAT
Definition: ntuser.h:644
#define UserHMGetHandle(obj)
Definition: ntuser.h:230
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:801
#define CI_IMMACTIVATE
Definition: ntuser.h:305
#define WNDS2_WMCREATEMSGPROCESSED
Definition: ntuser.h:665
#define IS_IMM_MODE()
Definition: ntuser.h:1232
#define ICLS_DESKTOP
Definition: ntuser.h:924
#define WNDS_SENDSIZEMOVEMSGS
Definition: ntuser.h:604
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
UINT_PTR HKL
Definition: msctf.idl:104
#define KernelMode
Definition: asm.h:34
LRESULT APIENTRY co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
Definition: hook.c:1103
UINT FASTCALL co_WinPosMinMaximize(PWND Wnd, UINT ShowFlag, RECT *NewPos)
Definition: winpos.c:2416
LRESULT FASTCALL co_WinPosGetNonClientSize(PWND Window, RECT *WindowRect, RECT *ClientRect)
Definition: winpos.c:2367
UINT FASTCALL co_WinPosGetMinMaxInfo(PWND Window, POINT *MaxSize, POINT *MaxPos, POINT *MinTrack, POINT *MaxTrack)
Definition: winpos.c:935
void FASTCALL co_WinPosSendSizeMove(PWND Wnd)
Definition: winpos.c:2382
ATOM gaGuiConsoleWndClass
Definition: ntuser.c:27
#define L(x)
Definition: ntvdm.h:50
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:40
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:27
NTSTATUS NTAPI ObReferenceObjectByPointer(IN PVOID Object, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode)
Definition: obref.c:381
#define WS_MAXIMIZE
Definition: pedump.c:623
#define WS_VSCROLL
Definition: pedump.c:627
#define WS_HSCROLL
Definition: pedump.c:628
#define WS_CLIPCHILDREN
Definition: pedump.c:619
#define WS_THICKFRAME
Definition: pedump.c:630
DWORD FASTCALL co_UserShowScrollBar(PWND, int, BOOL, BOOL)
Definition: scrollbar.c:852
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
long bottom
Definition: polytest.cpp:53
long right
Definition: polytest.cpp:53
long top
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53
Definition: ntuser.h:561
DWORD dwLayout
Definition: win32.h:279
PPROCESSINFO ppi
Definition: win32.h:88
struct _DESKTOPINFO * pDeskInfo
Definition: win32.h:93
struct _CLIENTINFO * pClientInfo
Definition: win32.h:94
struct tagKL * KeyboardLayout
Definition: win32.h:90
struct _DESKTOP * rpdesk
Definition: win32.h:92
struct _WND * spwndDefaultIme
Definition: win32.h:131
Definition: object.h:4
LPCREATESTRUCTW lpcs
Definition: winuser.h:2965
HWND hwndInsertAfter
Definition: winuser.h:2966
LPCWSTR lpszClass
Definition: winuser.h:2955
LPCWSTR lpszName
Definition: winuser.h:2954
HINSTANCE hInstance
Definition: winuser.h:2946
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1055
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define WM_IME_SYSTEM
Definition: undocuser.h:60
static __inline BOOL UserHeapFree(PVOID lpMem)
Definition: usrheap.h:44
int ret
POBJECT_TYPE ExWindowStationObjectType
Definition: win32k.c:21
FORCEINLINE VOID RECTL_vOffsetRect(_Inout_ RECTL *prcl, _In_ INT cx, _In_ INT cy)
Definition: rect.h:31
BOOL FASTCALL IntMsgCreateStructW(PWND, CREATESTRUCTW *, CREATESTRUCTW *, PVOID *, PVOID *)
Definition: message.c:597
VOID IntDereferenceClass(IN OUT PCLS Class, IN PDESKTOPINFO Desktop, IN PPROCESSINFO pi)
Definition: class.c:815
PCLS IntGetAndReferenceClass(PUNICODE_STRING ClassName, HINSTANCE hInstance, BOOL bDesktopThread)
Definition: class.c:1437
VOID co_IntShellHookNotify(WPARAM Message, WPARAM wParam, LPARAM lParam)
Definition: desktop.c:1692
PWND FASTCALL co_IntCreateDefaultImeWindow(PWND pwndTarget, HINSTANCE hInst)
Definition: ime.c:1972
BOOL FASTCALL IntWantImeWindow(PWND pwndTarget)
Definition: ime.c:1932
PVOID FASTCALL UserAssignmentLock(PVOID *ppvObj, PVOID pvNew)
Definition: object.c:840
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:644
#define TAG_HOOK
Definition: tags.h:5
ULONG FASTCALL IntSetStyle(PWND pwnd, ULONG set_bits, ULONG clear_bits)
Definition: window.c:143
PWND FASTCALL IntCreateWindow(CREATESTRUCTW *Cs, PLARGE_STRING WindowName, PCLS Class, PWND ParentWindow, PWND OwnerWindow, PVOID acbiBuffer, PDESKTOP pdeskCreated, DWORD dwVer)
Definition: window.c:1787
void FASTCALL IntFixWindowCoordinates(CREATESTRUCTW *Cs, PWND ParentWindow, DWORD *dwShowMode)
Definition: window.c:1697
BOOL FASTCALL IntIsTopLevelWindow(PWND pWnd)
Definition: window.c:359
BOOLEAN co_UserDestroyWindow(PVOID Object)
Definition: window.c:2838
static void IntSendParentNotify(PWND pWindow, UINT msg)
Definition: window.c:1678
#define IntIsDesktopWindow(WndObj)
Definition: window.h:25
#define MAKEINTATOM(i)
Definition: winbase.h:1451
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define ERROR_TLW_WITH_WSCHILD
Definition: winerror.h:887
#define ERROR_CANNOT_FIND_WND_CLASS
Definition: winerror.h:888
#define LAYOUT_RTL
Definition: wingdi.h:1371
#define HWND_MESSAGE
Definition: winuser.h:1200
#define SWP_FRAMECHANGED
Definition: winuser.h:1230
#define WM_CREATE
Definition: winuser.h:1598
#define WS_EX_APPWINDOW
Definition: winuser.h:383
#define SW_MINIMIZE
Definition: winuser.h:770
#define HSHELL_WINDOWCREATED
Definition: winuser.h:1245
#define SB_VERT
Definition: winuser.h:553
#define SWP_NOMOVE
Definition: winuser.h:1234
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
#define WS_EX_NOACTIVATE
Definition: winuser.h:395
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
#define WH_CBT
Definition: winuser.h:35
#define HCBT_CREATEWND
Definition: winuser.h:58
#define WM_NCCREATE
Definition: winuser.h:1673
#define WM_MDIREFRESHMENU
Definition: winuser.h:1816
#define SW_SHOWMINIMIZED
Definition: winuser.h:765
#define WS_EX_MDICHILD
Definition: winuser.h:394
#define SWP_SHOWWINDOW
Definition: winuser.h:1238
#define SW_SHOW
Definition: winuser.h:769
#define SW_MAXIMIZE
Definition: winuser.h:766
#define CS_PARENTDC
Definition: winuser.h:651
#define HWND_BOTTOM
Definition: winuser.h:1195
#define SB_HORZ
Definition: winuser.h:552
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
#define ObDereferenceObject
Definition: obfuncs.h:203
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by co_IntCreateDefaultImeWindow(), MENU_InitPopup(), and NtUserCreateWindowEx().

◆ co_UserDestroyWindow()

BOOLEAN co_UserDestroyWindow ( PVOID  Object)

Definition at line 2838 of file window.c.

2839{
2840 HWND hWnd;
2841 PWND pwndTemp;
2842 PTHREADINFO ti;
2843 MSG msg;
2844 PWND Window = Object;
2845
2846 ASSERT_REFS_CO(Window); // FIXME: Temp HACK?
2847
2848 hWnd = Window->head.h;
2850
2851 TRACE("co_UserDestroyWindow(Window = 0x%p, hWnd = 0x%p)\n", Window, hWnd);
2852
2853 /* Check for owner thread */
2854 if (Window->head.pti != ti)
2855 {
2856 /* Check if we are destroying the desktop window */
2857 if (! ((Window->head.rpdesk->dwDTFlags & DF_DESTROYED) && Window == Window->head.rpdesk->pDeskInfo->spwnd))
2858 {
2860 return FALSE;
2861 }
2862 }
2863
2864 /* If window was created successfully and it is hooked */
2865 if ((Window->state2 & WNDS2_WMCREATEMSGPROCESSED))
2866 {
2868 {
2869 ERR("Destroy Window WH_CBT Call Hook return!\n");
2870 return FALSE;
2871 }
2872 }
2873
2874 if (Window->pcls->atomClassName != gpsi->atomSysClass[ICLS_IME])
2875 {
2876 if ((Window->style & (WS_POPUP|WS_CHILD)) != WS_CHILD)
2877 {
2878 if (Window->spwndOwner)
2879 {
2880 //ERR("DestroyWindow Owner out.\n");
2881 UserAttachThreadInput(Window->head.pti, Window->spwndOwner->head.pti, FALSE);
2882 }
2883 }
2884 }
2885
2886 /* Inform the parent */
2887 if (Window->style & WS_CHILD)
2888 {
2890 }
2891
2892 if (!Window->spwndOwner && !IntGetParent(Window))
2893 {
2895 }
2896
2897 /* Hide the window */
2898 if (Window->style & WS_VISIBLE)
2899 {
2900 if (Window->style & WS_CHILD)
2901 {
2902 /* Only child windows receive WM_SHOWWINDOW in DestroyWindow() */
2904 }
2905 else
2906 {
2908 }
2909 }
2910
2911 /* Adjust last active */
2912 if ((pwndTemp = Window->spwndOwner))
2913 {
2914 while (pwndTemp->spwndOwner)
2915 pwndTemp = pwndTemp->spwndOwner;
2916
2917 if (pwndTemp->spwndLastActive == Window)
2918 pwndTemp->spwndLastActive = Window->spwndOwner;
2919 }
2920
2921 if (Window->spwndParent && IntIsWindow(UserHMGetHandle(Window)))
2922 {
2923 if ((Window->style & (WS_POPUP | WS_CHILD)) == WS_CHILD)
2924 {
2926 {
2927 //ERR("DestroyWindow Parent out.\n");
2928 UserAttachThreadInput(Window->head.pti, Window->spwndParent->head.pti, FALSE);
2929 }
2930 }
2931 }
2932
2933 if (Window->head.pti->MessageQueue->spwndActive == Window)
2934 Window->head.pti->MessageQueue->spwndActive = NULL;
2935 if (Window->head.pti->MessageQueue->spwndFocus == Window)
2936 Window->head.pti->MessageQueue->spwndFocus = NULL;
2937 if (Window->head.pti->MessageQueue->spwndActivePrev == Window)
2938 Window->head.pti->MessageQueue->spwndActivePrev = NULL;
2939 if (Window->head.pti->MessageQueue->spwndCapture == Window)
2940 Window->head.pti->MessageQueue->spwndCapture = NULL;
2941
2942 /*
2943 * Check if this window is the Shell's Desktop Window. If so set hShellWindow to NULL
2944 */
2945
2946 if (ti->pDeskInfo != NULL)
2947 {
2948 if (ti->pDeskInfo->hShellWindow == hWnd)
2949 {
2950 ERR("Destroying the ShellWindow!\n");
2951 ti->pDeskInfo->hShellWindow = NULL;
2952 }
2953 }
2954
2956
2958 {
2959 return TRUE;
2960 }
2961
2962 /* Recursively destroy owned windows */
2963 if (!(Window->style & WS_CHILD))
2964 {
2966 }
2967
2968 /* Generate mouse move message for the next window */
2969 msg.message = WM_MOUSEMOVE;
2970 msg.wParam = UserGetMouseButtonsState();
2971 msg.lParam = MAKELPARAM(gpsi->ptCursor.x, gpsi->ptCursor.y);
2972 msg.pt = gpsi->ptCursor;
2974
2975 IntNotifyWinEvent(EVENT_OBJECT_DESTROY, Window, OBJID_WINDOW, CHILDID_SELF, 0);
2976
2977 /* Send destroy messages */
2979
2980 /* Destroy the default IME window if necessary */
2981 if (IS_IMM_MODE() && !(ti->TIF_flags & TIF_INCLEANUP) &&
2982 ti->spwndDefaultIme && (ti->spwndDefaultIme != Window) &&
2983 !(Window->state & WNDS_DESTROYED) && !IS_WND_IMELIKE(Window))
2984 {
2985 if (IS_WND_CHILD(Window))
2986 {
2989 }
2990 else
2991 {
2994 }
2995 }
2996
2998 {
2999 return TRUE;
3000 }
3001
3002 /* Destroy the window storage */
3004
3005 return TRUE;
3006}
#define msg(x)
Definition: auth_time.c:54
VOID FASTCALL IntEngWindowChanged(_In_ struct _WND *Window, _In_ FLONG flChanged)
#define ICLS_IME
Definition: ntuser.h:922
#define TIF_INCLEANUP
Definition: ntuser.h:262
#define WNDS_DESTROYED
Definition: ntuser.h:631
VOID FASTCALL co_MsqInsertMouseMessage(MSG *Msg, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook)
Definition: msgqueue.c:580
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
FLONG TIF_flags
Definition: win32.h:95
struct _WND * spwndLastActive
Definition: ntuser.h:734
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
#define DF_DESTROYED
Definition: desktop.h:50
BOOL FASTCALL IntImeCanDestroyDefIME(PWND pImeWnd, PWND pwndTarget)
Definition: ime.c:2080
BOOL FASTCALL IntImeCanDestroyDefIMEforChild(PWND pImeWnd, PWND pwndTarget)
Definition: ime.c:2035
WORD FASTCALL UserGetMouseButtonsState(VOID)
Definition: mouse.c:22
PWND FASTCALL IntGetParent(PWND Wnd)
Definition: window.c:204
LRESULT co_UserFreeWindow(PWND Window, PPROCESSINFO ProcessData, PTHREADINFO ThreadData, BOOLEAN SendMessages)
Definition: window.c:574
static void IntSendDestroyMsg(HWND hWnd)
Definition: window.c:461
BOOL FASTCALL IntIsWindow(HWND hWnd)
Definition: window.c:176
VOID FASTCALL IntDestroyOwnedWindows(PWND Window)
Definition: window.c:2802
#define IS_WND_IMELIKE(pWnd)
Definition: window.h:114
#define IS_WND_CHILD(pWnd)
Definition: window.h:108
#define WOC_DELETE
Definition: winddi.h:1269
#define MAKELPARAM(l, h)
Definition: winuser.h:3998
#define HSHELL_WINDOWDESTROYED
Definition: winuser.h:1246
#define HCBT_DESTROYWND
Definition: winuser.h:59
#define WM_MOUSEMOVE
Definition: winuser.h:1765
#define SWP_HIDEWINDOW
Definition: winuser.h:1231
#define WM_DESTROY
Definition: winuser.h:1599

Referenced by co_UserCreateWindowEx(), co_UserDestroyWindow(), handle_internal_message(), IntDefWindowProc(), IntDesktopObjectDelete(), IntDestroyOwnedWindows(), IntTrackPopupMenuEx(), MENU_HideSubPopups(), MENU_TrackMenu(), NtUserDestroyWindow(), and NtUserDisableThreadIme().

◆ co_UserFreeWindow()

LRESULT co_UserFreeWindow ( PWND  Window,
PPROCESSINFO  ProcessData,
PTHREADINFO  ThreadData,
BOOLEAN  SendMessages 
)

Definition at line 574 of file window.c.

578{
579 HWND *Children;
580 HWND *ChildHandle;
581 PWND Child;
582 PMENU Menu;
583 BOOLEAN BelongsToThreadData;
584
585 ASSERT(Window);
586
587 if(Window->state2 & WNDS2_INDESTROY)
588 {
589 TRACE("Tried to call co_UserFreeWindow() twice\n");
590 return 0;
591 }
592 Window->state2 |= WNDS2_INDESTROY;
593 Window->style &= ~WS_VISIBLE;
594 Window->head.pti->cVisWindows--;
595
597
598 /* remove the window already at this point from the thread window list so we
599 don't get into trouble when destroying the thread windows while we're still
600 in co_UserFreeWindow() */
601 RemoveEntryList(&Window->ThreadListEntry);
602
603 BelongsToThreadData = IntWndBelongsToThread(Window, ThreadData);
604
606
607 /* free child windows */
608 Children = IntWinListChildren(Window);
609 if (Children)
610 {
611 for (ChildHandle = Children; *ChildHandle; ++ChildHandle)
612 {
613 if ((Child = IntGetWindowObject(*ChildHandle)))
614 {
616 {
617 /* send WM_DESTROY messages to windows not belonging to the same thread */
619 }
620 else
621 co_UserFreeWindow(Child, ProcessData, ThreadData, SendMessages);
622
624 }
625 }
627 }
628
629 if (SendMessages)
630 {
631 /*
632 * Clear the update region to make sure no WM_PAINT messages will be
633 * generated for this window while processing the WM_NCDESTROY.
634 */
638 if (BelongsToThreadData)
640 }
641
643
645
646 /* Unregister hot keys */
648
649 /* flush the message queue */
651
652 /* from now on no messages can be sent to this window anymore */
653 Window->state |= WNDS_DESTROYED;
654 Window->fnid |= FNID_FREED;
655
656 /* don't remove the WINDOWSTATUS_DESTROYING bit */
657
658 /* reset shell window handles */
659 if (ThreadData->rpdesk)
660 {
661 if (Window->head.h == ThreadData->rpdesk->rpwinstaParent->ShellWindow)
662 ThreadData->rpdesk->rpwinstaParent->ShellWindow = NULL;
663
664 if (Window->head.h == ThreadData->rpdesk->rpwinstaParent->ShellListView)
665 ThreadData->rpdesk->rpwinstaParent->ShellListView = NULL;
666 }
667
668 if (ThreadData->spwndDefaultIme &&
669 ThreadData->spwndDefaultIme->spwndOwner == Window)
670 {
671 WndSetOwner(ThreadData->spwndDefaultIme, NULL);
672 }
673
674 if (IS_IMM_MODE() && Window == ThreadData->spwndDefaultIme)
675 {
676 UserAssignmentUnlock((PVOID*)&(ThreadData->spwndDefaultIme));
677 }
678
679 /* Fixes dialog test_focus breakage due to r66237. */
680 if (ThreadData->MessageQueue->spwndFocus == Window)
681 ThreadData->MessageQueue->spwndFocus = NULL;
682
683 if (ThreadData->MessageQueue->spwndActive == Window)
684 ThreadData->MessageQueue->spwndActive = NULL;
685
686 if (ThreadData->MessageQueue->spwndCapture == Window)
687 {
689 }
690
692 if ( Window->hrgnUpdate != NULL || Window->state & WNDS_INTERNALPAINT )
693 {
694 MsqDecPaintCountQueue(Window->head.pti);
695 if (Window->hrgnUpdate > HRGN_WINDOW && GreIsHandleValid(Window->hrgnUpdate))
696 {
698 GreDeleteObject(Window->hrgnUpdate);
699 }
700 Window->hrgnUpdate = NULL;
701 Window->state &= ~WNDS_INTERNALPAINT;
702 }
703
705 {
707 }
708
709 if ( ((Window->style & (WS_CHILD|WS_POPUP)) != WS_CHILD) &&
710 Window->IDMenu &&
711 (Menu = UserGetMenuObject((HMENU)Window->IDMenu)))
712 {
713 TRACE("UFW: IDMenu %p\n",Window->IDMenu);
715 Window->IDMenu = 0;
716 }
717
718 if (Window->SystemMenu
719 && (Menu = UserGetMenuObject(Window->SystemMenu)))
720 {
722 Window->SystemMenu = (HMENU)0;
723 }
724
725 DceFreeWindowDCE(Window); /* Always do this to catch orphaned DCs */
726
728
729 if (Window->PropListItems)
730 {
732 TRACE("Window->PropListItems %lu\n",Window->PropListItems);
733 ASSERT(Window->PropListItems==0);
734 }
735
738
740
741 if (Window->pcls->atomClassName == gaGuiConsoleWndClass)
742 {
743 /* Count only console windows manually */
745 }
746
747 /* dereference the class */
748 NT_ASSERT(Window->head.pti != NULL);
750 Window->head.pti->pDeskInfo,
751 Window->head.pti->ppi);
752 Window->pcls = NULL;
753
754 if (Window->hrgnClip)
755 {
757 GreDeleteObject(Window->hrgnClip);
758 Window->hrgnClip = NULL;
759 }
760 Window->head.pti->cWindows--;
761
762// ASSERT(Window != NULL);
763 UserFreeWindowInfo(Window->head.pti, Window);
764
767
768 return 0;
769}
unsigned char BOOLEAN
void FASTCALL DceFreeWindowDCE(PWND)
Definition: windc.c:686
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
BOOL FASTCALL IntReleaseCapture(VOID)
Definition: focus.c:1530
#define WNDS_SENDNCPAINT
Definition: ntuser.h:611
#define WNDS_INTERNALPAINT
Definition: ntuser.h:612
@ TYPE_WINDOW
Definition: ntuser.h:41
#define WNDS2_INDESTROY
Definition: ntuser.h:643
#define HRGN_WINDOW
Definition: ntuser.h:356
#define WNDS_SENDERASEBACKGROUND
Definition: ntuser.h:609
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
VOID APIENTRY MsqRemoveWindowMessagesFromQueue(PWND Window)
Definition: msgqueue.c:798
VOID FASTCALL MsqDecPaintCountQueue(PTHREADINFO pti)
Definition: msgqueue.c:508
@ WM_ASYNC_DESTROYWINDOW
Definition: msgqueue.h:120
#define GDI_OBJ_HMGR_POWNED
Definition: ntgdihdl.h:117
BOOL FASTCALL IntDestroyScrollBars(PWND)
Definition: scrollbar.c:799
BOOL FASTCALL co_UserRedrawWindow(PWND Window, const RECTL *UpdateRect, PREGION UpdateRgn, ULONG Flags)
Definition: painting.c:888
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
Definition: wdffdo.h:536
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1158
BOOL NTAPI GreIsHandleValid(HGDIOBJ hobj)
Definition: gdiobj.c:1146
BOOL FASTCALL IntGdiSetRegionOwner(HRGN hRgn, DWORD OwnerMask)
Definition: region.c:2475
VOID FASTCALL UserClipboardFreeWindow(PWND pWindow)
Definition: clipboard.c:414
BOOL IntDeRegisterShellHookWindow(HWND hWnd)
Definition: desktop.c:1784
VOID FASTCALL UnregisterWindowHotKeys(PWND pWnd)
Definition: hotkey.c:91
BOOL FASTCALL IntDestroyMenuObject(PMENU Menu, BOOL bRecurse)
Definition: menu.c:319
BOOL FASTCALL UserMarkObjectDestroy(PVOID Object)
Definition: object.c:621
BOOL FASTCALL UserDeleteObject(HANDLE h, HANDLE_TYPE type)
Definition: object.c:717
PVOID FASTCALL UserAssignmentUnlock(PVOID *ppvObj)
Definition: object.c:861
VOID FASTCALL UserRemoveWindowProps(_In_ PWND Window)
Definition: prop.c:115
#define USERTAG_WINDOWLIST
Definition: tags.h:298
BOOL FASTCALL DestroyTimersForWindow(PTHREADINFO pti, PWND Window)
Definition: timer.c:522
HWND *FASTCALL IntWinListChildren(PWND Window)
Definition: window.c:274
static VOID UserFreeWindowInfo(PTHREADINFO ti, PWND Wnd)
Definition: window.c:541
PWND FASTCALL IntGetWindowObject(HWND hWnd)
Definition: window.c:73
static VOID WndSetOwner(_Inout_ PWND pwnd, _In_opt_ PWND pwndOwner)
Definition: window.h:130
#define IntWndBelongsToThread(WndObj, W32Thread)
Definition: window.h:32
#define RDW_NOINTERNALPAINT
Definition: winuser.h:1207
#define RDW_NOCHILDREN
Definition: winuser.h:1212
#define WM_NCDESTROY
Definition: winuser.h:1674
#define RDW_NOFRAME
Definition: winuser.h:1206
#define RDW_NOERASE
Definition: winuser.h:1205
#define RDW_VALIDATE
Definition: winuser.h:1208
#define NT_ASSERT
Definition: rtlfuncs.h:3310

Referenced by co_UserDestroyWindow(), co_UserFreeWindow(), and handle_internal_message().

◆ co_UserSetParent()

HWND FASTCALL co_UserSetParent ( HWND  hWndChild,
HWND  hWndNewParent 
)

Definition at line 1281 of file window.c.

1282{
1283 PWND Wnd = NULL, WndParent = NULL, WndOldParent;
1284 HWND hWndOldParent = NULL;
1285 USER_REFERENCE_ENTRY Ref, ParentRef;
1286
1287 if (IntIsBroadcastHwnd(hWndChild) || IntIsBroadcastHwnd(hWndNewParent))
1288 {
1290 return( NULL);
1291 }
1292
1294 {
1295 ERR("UserSetParent Access Denied!\n");
1297 return( NULL);
1298 }
1299
1300 if (hWndNewParent)
1301 {
1302 if (!(WndParent = UserGetWindowObject(hWndNewParent)))
1303 {
1304 ERR("UserSetParent Bad New Parent!\n");
1305 return( NULL);
1306 }
1307 }
1308 else
1309 {
1310 if (!(WndParent = UserGetWindowObject(IntGetDesktopWindow())))
1311 {
1312 return( NULL);
1313 }
1314 }
1315
1316 if (!(Wnd = UserGetWindowObject(hWndChild)))
1317 {
1318 ERR("UserSetParent Bad Child!\n");
1319 return( NULL);
1320 }
1321
1322 UserRefObjectCo(Wnd, &Ref);
1323 UserRefObjectCo(WndParent, &ParentRef);
1324 //ERR("Enter co_IntSetParent\n");
1325 WndOldParent = co_IntSetParent(Wnd, WndParent);
1326 //ERR("Leave co_IntSetParent\n");
1327 UserDerefObjectCo(WndParent);
1328 UserDerefObjectCo(Wnd);
1329
1330 if (WndOldParent)
1331 {
1332 hWndOldParent = WndOldParent->head.h;
1333 UserDereferenceObject(WndOldParent);
1334 }
1335
1336 return( hWndOldParent);
1337}
HWND hWndChild[NUM_TABS]
Definition: main.h:75
PWND FASTCALL co_IntSetParent(PWND Wnd, PWND WndNewParent)
Definition: window.c:1143
#define IntIsBroadcastHwnd(hWnd)
Definition: window.h:28

Referenced by co_IntSetWindowLongPtr(), and NtUserSetParent().

◆ co_UserSetWindowLong()

LONG FASTCALL co_UserSetWindowLong ( HWND  hWnd,
DWORD  Index,
LONG  NewValue,
BOOL  Ansi 
)

Definition at line 4008 of file window.c.

4009{
4010 return (LONG)co_IntSetWindowLongPtr(hWnd, Index, NewValue, Ansi, sizeof(LONG), FALSE);
4011}
static LONG_PTR co_IntSetWindowLongPtr(HWND hWnd, DWORD Index, LONG_PTR NewValue, BOOL Ansi, ULONG Size, BOOL bAlter)
Definition: window.c:3813

Referenced by DesktopWindowProc(), and NtUserSetWindowWord().

◆ co_UserSetWindowLongPtr()

LONG_PTR FASTCALL co_UserSetWindowLongPtr ( HWND  hWnd,
DWORD  Index,
LONG_PTR  NewValue,
BOOL  Ansi 
)

Definition at line 4014 of file window.c.

4015{
4016 return co_IntSetWindowLongPtr(hWnd, Index, NewValue, Ansi, sizeof(LONG_PTR), FALSE);
4017}

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UserWnd  )

◆ DefSetText()

BOOL APIENTRY DefSetText ( PWND  Wnd,
PCWSTR  WindowText 
)

Definition at line 4372 of file window.c.

4373{
4375 BOOL Ret = FALSE;
4376
4377 RtlInitUnicodeString(&UnicodeString, WindowText);
4378
4379 if (UnicodeString.Length != 0)
4380 {
4381 if (Wnd->strName.MaximumLength > 0 &&
4382 UnicodeString.Length <= Wnd->strName.MaximumLength - sizeof(UNICODE_NULL))
4383 {
4384 ASSERT(Wnd->strName.Buffer != NULL);
4385
4386 Wnd->strName.Length = UnicodeString.Length;
4387 Wnd->strName.Buffer[UnicodeString.Length / sizeof(WCHAR)] = L'\0';
4389 UnicodeString.Buffer,
4390 UnicodeString.Length);
4391 }
4392 else
4393 {
4394 PWCHAR buf;
4395 Wnd->strName.MaximumLength = Wnd->strName.Length = 0;
4396 buf = Wnd->strName.Buffer;
4397 Wnd->strName.Buffer = NULL;
4398 if (buf != NULL)
4399 {
4401 }
4402
4404 UnicodeString.Length + sizeof(UNICODE_NULL));
4405 if (Wnd->strName.Buffer != NULL)
4406 {
4407 Wnd->strName.Buffer[UnicodeString.Length / sizeof(WCHAR)] = L'\0';
4409 UnicodeString.Buffer,
4410 UnicodeString.Length);
4411 Wnd->strName.MaximumLength = UnicodeString.Length + sizeof(UNICODE_NULL);
4412 Wnd->strName.Length = UnicodeString.Length;
4413 }
4414 else
4415 {
4417 goto Exit;
4418 }
4419 }
4420 }
4421 else
4422 {
4423 Wnd->strName.Length = 0;
4424 if (Wnd->strName.Buffer != NULL)
4425 Wnd->strName.Buffer[0] = L'\0';
4426 }
4427
4428 // FIXME: HAX! Windows does not do this in here!
4429 // In User32, these are called after: NotifyWinEvent EVENT_OBJECT_NAMECHANGE than
4430 // RepaintButton, StaticRepaint, NtUserCallHwndLock HWNDLOCK_ROUTINE_REDRAWFRAMEANDHOOK, etc.
4431 /* Send shell notifications */
4432 if (!Wnd->spwndOwner && !IntGetParent(Wnd))
4433 {
4434 co_IntShellHookNotify(HSHELL_REDRAW, (WPARAM) UserHMGetHandle(Wnd), FALSE); // FIXME Flashing?
4435 }
4436
4437 Ret = TRUE;
4438Exit:
4440 return Ret;
4441}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define UNICODE_NULL
static void Exit(void)
Definition: sock.c:1330
LARGE_UNICODE_STRING strName
Definition: ntuser.h:731
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint16_t * PWCHAR
Definition: typedefs.h:56
static __inline PVOID DesktopHeapAlloc(IN PDESKTOP Desktop, IN SIZE_T Bytes)
Definition: desktop.h:204
static __inline BOOL DesktopHeapFree(IN PDESKTOP Desktop, IN PVOID lpMem)
Definition: desktop.h:215
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by IntDefWindowProc(), RealDefWindowProcA(), and RealDefWindowProcW().

◆ IntBuildHwndList()

PWINDOWLIST FASTCALL IntBuildHwndList ( PWND  pwnd,
DWORD  dwFlags,
PTHREADINFO  pti 
)

Definition at line 1410 of file window.c.

1411{
1412 PWINDOWLIST pwl;
1413 DWORD cbWL;
1414
1415 if (gpwlCache)
1416 {
1417 pwl = gpwlCache;
1418 gpwlCache = NULL;
1419 }
1420 else
1421 {
1422#define INITIAL_COUNT 32
1423 cbWL = sizeof(WINDOWLIST) + (INITIAL_COUNT - 1) * sizeof(HWND);
1425 if (!pwl)
1426 return NULL;
1427
1428 pwl->phwndEnd = &pwl->ahwnd[INITIAL_COUNT];
1429#undef INITIAL_COUNT
1430 }
1431
1432 pwl->pti = pti;
1433 pwl->phwndLast = pwl->ahwnd;
1434 pwl = IntPopulateHwndList(pwl, pwnd, dwFlags);
1435 if (WL_IS_BAD(pwl))
1436 {
1438 return NULL;
1439 }
1440
1441 *(pwl->phwndLast) = HWND_TERMINATOR;
1442
1443 if (dwFlags & 0x8)
1444 {
1445 // TODO:
1446 }
1447
1448 pwl->pti = GetW32ThreadInfo();
1449 pwl->pNextList = gpwlList;
1450 gpwlList = pwl;
1451
1452 return pwl;
1453}
HANDLE HWND
Definition: compat.h:19
#define PagedPool
Definition: env_spec_w32.h:308
HWND * phwndLast
Definition: window.h:88
HWND ahwnd[ANYSIZE_ARRAY]
Definition: window.h:91
struct tagWINDOWLIST * pNextList
Definition: window.h:87
PTHREADINFO pti
Definition: window.h:90
HWND * phwndEnd
Definition: window.h:89
PWINDOWLIST gpwlCache
Definition: window.c:17
PWINDOWLIST FASTCALL IntPopulateHwndList(PWINDOWLIST pwl, PWND pwnd, DWORD dwFlags)
Definition: window.c:1380
#define INITIAL_COUNT
PWINDOWLIST gpwlList
Definition: window.c:16
#define WL_IS_BAD(pwl)
Definition: window.h:97
#define HWND_TERMINATOR
Definition: window.h:83
struct tagWINDOWLIST WINDOWLIST
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

Referenced by IntAssociateInputContextEx(), IntCheckImeShowStatus(), IntDestroyInputContext(), and IntImeWindowPosChanged().

◆ IntCheckFrameEdge()

static BOOL FASTCALL IntCheckFrameEdge ( ULONG  Style,
ULONG  ExStyle 
)
static

Definition at line 3802 of file window.c.

3803{
3805 return TRUE;
3806 else if (!(ExStyle & WS_EX_STATICEDGE) && (Style & (WS_DLGFRAME | WS_THICKFRAME)))
3807 return TRUE;
3808 else
3809 return FALSE;
3810}
const DWORD ExStyle
Definition: appswitch.c:72
#define WS_EX_DLGMODALFRAME
Definition: pedump.c:645
#define WS_DLGFRAME
Definition: pedump.c:626
#define WS_EX_STATICEDGE
Definition: winuser.h:403

Referenced by co_IntSetWindowLongPtr().

◆ IntCreateWindow()

PWND FASTCALL IntCreateWindow ( CREATESTRUCTW Cs,
PLARGE_STRING  WindowName,
PCLS  Class,
PWND  ParentWindow,
PWND  OwnerWindow,
PVOID  acbiBuffer,
PDESKTOP  pdeskCreated,
DWORD  dwVer 
)

Definition at line 1787 of file window.c.

1795{
1796 PWND pWnd = NULL;
1797 HWND hWnd;
1798 PTHREADINFO pti;
1799 BOOL MenuChanged;
1800 BOOL bUnicodeWindow;
1801 PCALLPROCDATA pcpd;
1802
1803 pti = pdeskCreated ? gptiDesktopThread : GetW32ThreadInfo();
1804
1805 if (!(Cs->dwExStyle & WS_EX_LAYOUTRTL))
1806 { // Need both here for wine win.c test_CreateWindow.
1807 //if (Cs->hwndParent && ParentWindow)
1808 if (ParentWindow) // It breaks more tests..... WIP.
1809 {
1810 if ( (Cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD &&
1811 ParentWindow->ExStyle & WS_EX_LAYOUTRTL &&
1812 !(ParentWindow->ExStyle & WS_EX_NOINHERITLAYOUT) )
1814 }
1815 else
1816 { /*
1817 * Note from MSDN <http://msdn.microsoft.com/en-us/library/aa913269.aspx>:
1818 *
1819 * Dialog boxes and message boxes do not inherit layout, so you must
1820 * set the layout explicitly.
1821 */
1822 if ( Class->fnid != FNID_DIALOG )
1823 {
1824 if (pti->ppi->dwLayout & LAYOUT_RTL)
1825 {
1827 }
1828 }
1829 }
1830 }
1831
1832 /* Automatically add WS_EX_WINDOWEDGE */
1833 if ((Cs->dwExStyle & WS_EX_DLGMODALFRAME) ||
1834 ((!(Cs->dwExStyle & WS_EX_STATICEDGE)) &&
1835 (Cs->style & (WS_DLGFRAME | WS_THICKFRAME))))
1837 else
1838 Cs->dwExStyle &= ~WS_EX_WINDOWEDGE;
1839
1840 /* Is it a unicode window? */
1841 bUnicodeWindow =!(Cs->dwExStyle & WS_EX_SETANSICREATOR);
1842 Cs->dwExStyle &= ~WS_EX_SETANSICREATOR;
1843
1844 /* Allocate the new window */
1846 pdeskCreated ? pdeskCreated : pti->rpdesk,
1847 pti,
1848 (PHANDLE)&hWnd,
1850 sizeof(WND) + Class->cbwndExtra);
1851
1852 if (!pWnd)
1853 {
1854 goto AllocError;
1855 }
1856
1857 TRACE("Created window object with handle %p\n", hWnd);
1858
1859 if (pdeskCreated && pdeskCreated->DesktopWindow == NULL )
1860 { /* HACK: Helper for win32csr/desktopbg.c */
1861 /* If there is no desktop window yet, we must be creating it */
1862 TRACE("CreateWindow setting desktop.\n");
1863 pdeskCreated->DesktopWindow = hWnd;
1864 pdeskCreated->pDeskInfo->spwnd = pWnd;
1865 }
1866
1867 /*
1868 * Fill out the structure describing it.
1869 */
1870 /* Remember, pWnd->head is setup in object.c ... */
1871 pWnd->spwndParent = ParentWindow;
1872 WndSetOwner(pWnd, OwnerWindow);
1873 pWnd->fnid = 0;
1874 pWnd->spwndLastActive = pWnd;
1875 // Ramp up compatible version sets.
1876 if ( dwVer >= WINVER_WIN31 )
1877 {
1878 pWnd->state2 |= WNDS2_WIN31COMPAT;
1879 if ( dwVer >= WINVER_WINNT4 )
1880 {
1881 pWnd->state2 |= WNDS2_WIN40COMPAT;
1882 if ( dwVer >= WINVER_WIN2K )
1883 {
1884 pWnd->state2 |= WNDS2_WIN50COMPAT;
1885 }
1886 }
1887 }
1888 pWnd->pcls = Class;
1889 pWnd->hModule = Cs->hInstance;
1890 pWnd->style = Cs->style & ~WS_VISIBLE;
1891 pWnd->ExStyle = Cs->dwExStyle;
1892 pWnd->cbwndExtra = pWnd->pcls->cbwndExtra;
1893 pWnd->pActCtx = acbiBuffer;
1894
1895 if (pti->spDefaultImc && Class->atomClassName != gpsi->atomSysClass[ICLS_BUTTON])
1896 pWnd->hImc = UserHMGetHandle(pti->spDefaultImc);
1897
1898 pWnd->InternalPos.MaxPos.x = pWnd->InternalPos.MaxPos.y = -1;
1899 pWnd->InternalPos.IconPos.x = pWnd->InternalPos.IconPos.y = -1;
1900
1901 if (pWnd->spwndParent != NULL && Cs->hwndParent != 0)
1902 {
1903 pWnd->HideFocus = pWnd->spwndParent->HideFocus;
1904 pWnd->HideAccel = pWnd->spwndParent->HideAccel;
1905 }
1906
1907 pWnd->head.pti->cWindows++;
1908
1909 if (Class->spicn && !Class->spicnSm)
1910 {
1911 HICON IconSmHandle = NULL;
1912 if((Class->spicn->CURSORF_flags & (CURSORF_LRSHARED | CURSORF_FROMRESOURCE))
1914 {
1915 IconSmHandle = co_IntCopyImage(
1916 UserHMGetHandle(Class->spicn),
1917 IMAGE_ICON,
1921 }
1922 if (!IconSmHandle)
1923 {
1924 /* Retry without copying from resource */
1925 IconSmHandle = co_IntCopyImage(
1926 UserHMGetHandle(Class->spicn),
1927 IMAGE_ICON,
1930 0);
1931 }
1932
1933 if (IconSmHandle)
1934 {
1935 Class->spicnSm = UserGetCurIconObject(IconSmHandle);
1936 Class->CSF_flags |= CSF_CACHEDSMICON;
1937 }
1938 }
1939
1940 if (pWnd->pcls->CSF_flags & CSF_SERVERSIDEPROC)
1942
1943 /* BugBoy Comments: Comment below say that System classes are always created
1944 as UNICODE. In windows, creating a window with the ANSI version of CreateWindow
1945 sets the window to ansi as verified by testing with IsUnicodeWindow API.
1946
1947 No where can I see in code or through testing does the window change back
1948 to ANSI after being created as UNICODE in ROS. I didnt do more testing to
1949 see what problems this would cause. */
1950
1951 // Set WndProc from Class.
1952 if (IsCallProcHandle(pWnd->pcls->lpfnWndProc))
1953 {
1955 if (pcpd)
1956 pWnd->lpfnWndProc = pcpd->pfnClientPrevious;
1957 }
1958 else
1959 {
1960 pWnd->lpfnWndProc = pWnd->pcls->lpfnWndProc;
1961 }
1962
1963 // GetWindowProc, test for non server side default classes and set WndProc.
1964 if ( pWnd->pcls->fnid <= FNID_GHOST && pWnd->pcls->fnid >= FNID_BUTTON )
1965 {
1966 if (bUnicodeWindow)
1967 {
1968 if (GETPFNCLIENTA(pWnd->pcls->fnid) == pWnd->lpfnWndProc)
1969 pWnd->lpfnWndProc = GETPFNCLIENTW(pWnd->pcls->fnid);
1970 }
1971 else
1972 {
1973 if (GETPFNCLIENTW(pWnd->pcls->fnid) == pWnd->lpfnWndProc)
1974 pWnd->lpfnWndProc = GETPFNCLIENTA(pWnd->pcls->fnid);
1975 }
1976 }
1977
1978 // If not an Unicode caller, set Ansi creator bit.
1979 if (!bUnicodeWindow) pWnd->state |= WNDS_ANSICREATOR;
1980
1981 // Clone Class Ansi/Unicode proc type.
1982 if (pWnd->pcls->CSF_flags & CSF_ANSIPROC)
1983 {
1984 pWnd->state |= WNDS_ANSIWINDOWPROC;
1985 pWnd->Unicode = FALSE;
1986 }
1987 else
1988 { /*
1989 * It seems there can be both an Ansi creator and Unicode Class Window
1990 * WndProc, unless the following overriding conditions occur:
1991 */
1992 if ( !bUnicodeWindow &&
1993 ( Class->atomClassName == gpsi->atomSysClass[ICLS_BUTTON] ||
1994 Class->atomClassName == gpsi->atomSysClass[ICLS_COMBOBOX] ||
1995 Class->atomClassName == gpsi->atomSysClass[ICLS_COMBOLBOX] ||
1996 Class->atomClassName == gpsi->atomSysClass[ICLS_DIALOG] ||
1997 Class->atomClassName == gpsi->atomSysClass[ICLS_EDIT] ||
1998 Class->atomClassName == gpsi->atomSysClass[ICLS_IME] ||
1999 Class->atomClassName == gpsi->atomSysClass[ICLS_LISTBOX] ||
2000 Class->atomClassName == gpsi->atomSysClass[ICLS_MDICLIENT] ||
2001 Class->atomClassName == gpsi->atomSysClass[ICLS_STATIC] ) )
2002 { // Override Class and set the window Ansi WndProc.
2003 pWnd->state |= WNDS_ANSIWINDOWPROC;
2004 pWnd->Unicode = FALSE;
2005 }
2006 else
2007 { // Set the window Unicode WndProc.
2008 pWnd->state &= ~WNDS_ANSIWINDOWPROC;
2009 pWnd->Unicode = TRUE;
2010 }
2011 }
2012
2013 /* BugBoy Comments: if the window being created is a edit control, ATOM 0xCxxx,
2014 then my testing shows that windows (2k and XP) creates a CallProc for it immediately
2015 Dont understand why it does this. */
2016 if (Class->atomClassName == gpsi->atomSysClass[ICLS_EDIT])
2017 {
2018 PCALLPROCDATA CallProc;
2019 CallProc = CreateCallProc(pWnd->head.rpdesk, pWnd->lpfnWndProc, pWnd->Unicode , pWnd->head.pti->ppi);
2020
2021 if (!CallProc)
2022 {
2024 ERR("Warning: Unable to create CallProc for edit control. Control may not operate correctly! hwnd %p\n", hWnd);
2025 }
2026 else
2027 {
2028 UserAddCallProcToClass(pWnd->pcls, CallProc);
2029 }
2030 }
2031
2033 pWnd->PropListItems = 0;
2034
2035 if ( WindowName->Buffer != NULL && WindowName->Length > 0 )
2036 {
2038 WindowName->Length + sizeof(UNICODE_NULL));
2039 if (pWnd->strName.Buffer == NULL)
2040 {
2041 goto AllocError;
2042 }
2043
2044 RtlCopyMemory(pWnd->strName.Buffer, WindowName->Buffer, WindowName->Length);
2045 pWnd->strName.Buffer[WindowName->Length / sizeof(WCHAR)] = L'\0';
2046 pWnd->strName.Length = WindowName->Length;
2047 pWnd->strName.MaximumLength = WindowName->Length + sizeof(UNICODE_NULL);
2048 }
2049
2050 /* Correct the window style. */
2051 if ((pWnd->style & (WS_CHILD | WS_POPUP)) != WS_CHILD)
2052 {
2053 pWnd->style |= WS_CLIPSIBLINGS;
2054 if (!(pWnd->style & WS_POPUP))
2055 {
2056 pWnd->style |= WS_CAPTION;
2057 }
2058 }
2059
2060 /* WS_EX_WINDOWEDGE depends on some other styles */
2061 if (pWnd->ExStyle & WS_EX_DLGMODALFRAME)
2062 pWnd->ExStyle |= WS_EX_WINDOWEDGE;
2063 else if (pWnd->style & (WS_DLGFRAME | WS_THICKFRAME))
2064 {
2065 if (!((pWnd->ExStyle & WS_EX_STATICEDGE) &&
2066 (pWnd->style & (WS_CHILD | WS_POPUP))))
2067 pWnd->ExStyle |= WS_EX_WINDOWEDGE;
2068 }
2069 else
2070 pWnd->ExStyle &= ~WS_EX_WINDOWEDGE;
2071
2072 if (!(pWnd->style & (WS_CHILD | WS_POPUP)))
2074
2075 /* Set the window menu */
2076 if ((Cs->style & (WS_CHILD | WS_POPUP)) != WS_CHILD)
2077 {
2078 if (Cs->hMenu)
2079 {
2080 IntSetMenu(pWnd, Cs->hMenu, &MenuChanged);
2081 }
2082 else if (pWnd->pcls->lpszMenuName) // Take it from the parent.
2083 {
2084 UNICODE_STRING MenuName;
2085 HMENU hMenu;
2086
2087 if (IS_INTRESOURCE(pWnd->pcls->lpszMenuName))
2088 {
2089 MenuName.Length = 0;
2090 MenuName.MaximumLength = 0;
2091 MenuName.Buffer = pWnd->pcls->lpszMenuName;
2092 }
2093 else
2094 {
2095 RtlInitUnicodeString( &MenuName, pWnd->pcls->lpszMenuName);
2096 }
2097 hMenu = co_IntCallLoadMenu( pWnd->pcls->hModule, &MenuName);
2098 if (hMenu) IntSetMenu(pWnd, hMenu, &MenuChanged);
2099 }
2100 }
2101 else // Not a child
2102 pWnd->IDMenu = (UINT_PTR)Cs->hMenu;
2103
2104
2105 if ( ParentWindow &&
2106 ParentWindow != ParentWindow->head.rpdesk->spwndMessage &&
2107 ParentWindow != ParentWindow->head.rpdesk->pDeskInfo->spwnd )
2108 {
2109 PWND Owner = IntGetNonChildAncestor(ParentWindow);
2110
2111 if (!IntValidateOwnerDepth(pWnd, Owner))
2112 {
2114 goto Error;
2115 }
2116 if ( pWnd->spwndOwner &&
2117 pWnd->spwndOwner->ExStyle & WS_EX_TOPMOST )
2118 {
2119 pWnd->ExStyle |= WS_EX_TOPMOST;
2120 }
2121 if ( pWnd->spwndOwner &&
2122 Class->atomClassName != gpsi->atomSysClass[ICLS_IME] &&
2123 pti != pWnd->spwndOwner->head.pti)
2124 {
2125 //ERR("CreateWindow Owner in.\n");
2126 UserAttachThreadInput(pti, pWnd->spwndOwner->head.pti, TRUE);
2127 }
2128 }
2129
2130 /* Insert the window into the thread's window list. */
2132
2133 /* Handle "CS_CLASSDC", it is tested first. */
2134 if ( (pWnd->pcls->style & CS_CLASSDC) && !(pWnd->pcls->pdce) )
2135 { /* One DCE per class to have CLASS. */
2136 pWnd->pcls->pdce = DceAllocDCE( pWnd, DCE_CLASS_DC );
2137 }
2138 else if ( pWnd->pcls->style & CS_OWNDC)
2139 { /* Allocate a DCE for this window. */
2141 }
2142
2143 return pWnd;
2144
2145AllocError:
2146 ERR("IntCreateWindow Allocation Error.\n");
2148Error:
2149 if(pWnd)
2151 return NULL;
2152}
BOOL Error
Definition: chkdsk.c:66
PCALLPROCDATA CreateCallProc(IN PDESKTOP Desktop, IN WNDPROC WndProc, IN BOOL Unicode, IN PPROCESSINFO pi)
Definition: callproc.c:29
static __inline BOOL IsCallProcHandle(IN WNDPROC lpWndProc)
Definition: class.h:13
PDCE FASTCALL DceAllocDCE(PWND Window, DCE_TYPE Type)
Definition: windc.c:86
@ DCE_CLASS_DC
Definition: dce.h:13
@ DCE_WINDOW_DC
Definition: dce.h:14
#define InsertTailList(ListHead, Entry)
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define ICLS_DIALOG
Definition: ntuser.h:925
#define ICLS_LISTBOX
Definition: ntuser.h:910
#define WNDS2_WIN40COMPAT
Definition: ntuser.h:645
#define ICLS_EDIT
Definition: ntuser.h:908
#define CURSORF_LRSHARED
Definition: ntuser.h:1196
#define ICLS_COMBOBOX
Definition: ntuser.h:912
#define ICLS_STATIC
Definition: ntuser.h:909
#define GETPFNCLIENTW(fnid)
Definition: ntuser.h:901
#define GETPFNCLIENTA(fnid)
Definition: ntuser.h:899
#define CSF_ANSIPROC
Definition: ntuser.h:552
#define WNDS_SERVERSIDEWINDOWPROC
Definition: ntuser.h:618
#define FNID_BUTTON
Definition: ntuser.h:861
#define CSF_CACHEDSMICON
Definition: ntuser.h:557
struct _WND * PWND
#define FNID_DIALOG
Definition: ntuser.h:864
#define ICLS_COMBOLBOX
Definition: ntuser.h:914
#define ICLS_BUTTON
Definition: ntuser.h:907
struct _WND WND
@ TYPE_CALLPROC
Definition: ntuser.h:47
#define CURSORF_FROMRESOURCE
Definition: ntuser.h:1194
#define CSF_SERVERSIDEPROC
Definition: ntuser.h:551
#define WNDS_ANSICREATOR
Definition: ntuser.h:629
#define FNID_GHOST
Definition: ntuser.h:870
#define ICLS_MDICLIENT
Definition: ntuser.h:913
#define WNDS2_WIN50COMPAT
Definition: ntuser.h:646
#define WNDS_ANSIWINDOWPROC
Definition: ntuser.h:619
static HICON
Definition: imagelist.c:84
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL _Inout_ PULONG _Out_writes_bytes_to_opt_ SaclSize PACL _Inout_ PULONG _Out_writes_bytes_to_opt_ OwnerSize PSID Owner
Definition: rtlfuncs.h:1597
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
#define WS_CAPTION
Definition: pedump.c:624
WNDPROC pfnClientPrevious
Definition: ntuser.h:547
PWSTR lpszMenuName
Definition: ntuser.h:583
WNDPROC lpfnWndProc
Definition: ntuser.h:576
INT cbwndExtra
Definition: ntuser.h:578
DWORD CSF_flags
Definition: ntuser.h:568
UINT style
Definition: ntuser.h:575
HINSTANCE hModule
Definition: ntuser.h:579
DWORD fnid
Definition: ntuser.h:565
PVOID pdce
Definition: ntuser.h:567
ULONG Length
Definition: ntuser.h:91
PVOID Buffer
Definition: ntuser.h:94
struct tagIMC * spDefaultImc
Definition: win32.h:132
LIST_ENTRY WindowListHead
Definition: win32.h:155
USHORT MaximumLength
Definition: env_spec_w32.h:370
LIST_ENTRY ThreadListEntry
Definition: ntuser.h:759
PCLS pcls
Definition: ntuser.h:715
UINT Unicode
Definition: ntuser.h:751
ULONG PropListItems
Definition: ntuser.h:719
DWORD state2
Definition: ntuser.h:697
PVOID pActCtx
Definition: ntuser.h:737
DWORD fnid
Definition: ntuser.h:704
UINT HideFocus
Definition: ntuser.h:753
UINT HideAccel
Definition: ntuser.h:754
LIST_ENTRY PropListHead
Definition: ntuser.h:718
HIMC hImc
Definition: ntuser.h:735
DWORD state
Definition: ntuser.h:696
UINT_PTR IDMenu
Definition: ntuser.h:726
WNDPROC lpfnWndProc
Definition: ntuser.h:713
HINSTANCE hModule
Definition: ntuser.h:703
ULONG cbwndExtra
Definition: ntuser.h:733
struct _WND::@4895 InternalPos
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define WS_EX_SETANSICREATOR
Definition: undocuser.h:28
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:37
HMENU APIENTRY co_IntCallLoadMenu(HINSTANCE hModule, PUNICODE_STRING pMenuName)
Definition: callback.c:903
HANDLE FASTCALL co_IntCopyImage(HANDLE hnd, UINT type, INT desiredx, INT desiredy, UINT flags)
Definition: callback.c:985
VOID UserAddCallProcToClass(IN OUT PCLS Class, IN PCALLPROCDATA CallProc)
Definition: class.c:423
PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon)
Definition: cursoricon.c:200
PTHREADINFO gptiDesktopThread
Definition: desktop.c:37
BOOL FASTCALL IntSetMenu(PWND Wnd, HMENU Menu, BOOL *Changed)
Definition: menu.c:5459
LONG NTAPI UserGetSystemMetrics(ULONG Index)
Definition: metric.c:208
PVOID UserGetObject(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type)
Definition: object.c:495
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
PVOID FASTCALL UserCreateObject(PUSER_HANDLE_TABLE ht, PDESKTOP pDesktop, PTHREADINFO pti, HANDLE *h, HANDLE_TYPE type, ULONG size)
Definition: object.c:568
BOOL FASTCALL IntValidateOwnerDepth(PWND Wnd, PWND Owner)
Definition: window.c:367
PWND FASTCALL IntGetNonChildAncestor(PWND pWnd)
Definition: window.c:351
#define WINVER_WIN2K
Definition: window.h:56
#define WINVER_WINNT4
Definition: window.h:57
#define WINVER_WIN31
Definition: window.h:58
#define IMAGE_ICON
Definition: winuser.h:212
#define LR_COPYFROMRESOURCE
Definition: winuser.h:1093
#define SM_CYSMICON
Definition: winuser.h:1007
#define SM_CXSMICON
Definition: winuser.h:1006
#define CS_OWNDC
Definition: winuser.h:650
#define CS_CLASSDC
Definition: winuser.h:645
#define WS_EX_NOINHERITLAYOUT
Definition: winuser.h:396

Referenced by co_UserCreateWindowEx(), and IntCreateDesktop().

◆ IntDestroyOwnedWindows()

VOID FASTCALL IntDestroyOwnedWindows ( PWND  Window)

Definition at line 2802 of file window.c.

2803{
2804 HWND* List;
2805 HWND* phWnd;
2806 PWND pWnd;
2808
2810 if (!List)
2811 return;
2812
2813 for (phWnd = List; *phWnd; ++phWnd)
2814 {
2815 pWnd = ValidateHwndNoErr(*phWnd);
2816 if (pWnd == NULL)
2817 continue;
2818 ASSERT(pWnd->spwndOwner == Window);
2819 ASSERT(pWnd != Window);
2820
2821 WndSetOwner(pWnd, NULL);
2823 {
2824 UserRefObjectCo(pWnd, &Ref); // Temp HACK?
2826 UserDerefObjectCo(pWnd); // Temp HACK?
2827 }
2828 else
2829 {
2830 ERR("IntWndBelongsToThread(0x%p) is FALSE, ignoring.\n", pWnd);
2831 }
2832 }
2833
2835}
#define ValidateHwndNoErr(hwnd)
Definition: precomp.h:84
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
HWND *FASTCALL IntWinListOwnedPopups(PWND Window)
Definition: window.c:315

Referenced by co_UserDestroyWindow().

◆ IntEnableWindow()

BOOL FASTCALL IntEnableWindow ( HWND  hWnd,
BOOL  bEnable 
)

Definition at line 220 of file window.c.

221{
222 BOOL Update;
223 PWND pWnd;
224 UINT bIsDisabled;
225
226 if(!(pWnd = UserGetWindowObject(hWnd)))
227 {
228 return FALSE;
229 }
230
231 /* check if updating is needed */
232 bIsDisabled = !!(pWnd->style & WS_DISABLED);
233 Update = bIsDisabled;
234
235 if (bEnable)
236 {
237 IntSetStyle( pWnd, 0, WS_DISABLED );
238 }
239 else
240 {
241 Update = !bIsDisabled;
242
244
245 /* Remove keyboard focus from that window if it had focus */
247 {
248 TRACE("IntEnableWindow SF NULL\n");
250 }
251 IntSetStyle( pWnd, WS_DISABLED, 0 );
252 }
253
254 if (Update)
255 {
256 IntNotifyWinEvent(EVENT_OBJECT_STATECHANGE, pWnd, OBJID_WINDOW, CHILDID_SELF, 0);
258 }
259 // Return nonzero if it was disabled, or zero if it wasn't:
260 return bIsDisabled;
261}
@ Update
Definition: registry.c:565
HWND FASTCALL IntGetThreadFocusWindow(VOID)
Definition: focus.c:41
HWND FASTCALL co_UserSetFocus(PWND Window)
Definition: focus.c:1314
#define WS_DISABLED
Definition: pedump.c:621
_In_ BOOL bEnable
Definition: winddi.h:3426
#define WM_ENABLE
Definition: winuser.h:1605
#define WM_CANCELMODE
Definition: winuser.h:1625

Referenced by NtUserCallTwoParam(), and NtUserEnableScrollBar().

◆ IntFindWindow()

HWND FASTCALL IntFindWindow ( PWND  Parent,
PWND  ChildAfter,
RTL_ATOM  ClassAtom,
PUNICODE_STRING  WindowName 
)

Definition at line 3042 of file window.c.

3046{
3047 BOOL CheckWindowName;
3048 HWND *List, *phWnd;
3049 HWND Ret = NULL;
3050 UNICODE_STRING CurrentWindowName;
3051
3052 ASSERT(Parent);
3053
3054 CheckWindowName = WindowName->Buffer != 0;
3055
3057 {
3058 phWnd = List;
3059 if(ChildAfter)
3060 {
3061 /* skip handles before and including ChildAfter */
3062 while(*phWnd && (*(phWnd++) != ChildAfter->head.h))
3063 ;
3064 }
3065
3066 /* search children */
3067 while(*phWnd)
3068 {
3069 PWND Child;
3070 if(!(Child = UserGetWindowObject(*(phWnd++))))
3071 {
3072 continue;
3073 }
3074
3075 /* Do not send WM_GETTEXT messages in the kernel mode version!
3076 The user mode version however calls GetWindowText() which will
3077 send WM_GETTEXT messages to windows belonging to its processes */
3078 if (!ClassAtom || Child->pcls->atomNVClassName == ClassAtom)
3079 {
3080 // FIXME: LARGE_STRING truncated
3081 CurrentWindowName.Buffer = Child->strName.Buffer;
3082 CurrentWindowName.Length = (USHORT)min(Child->strName.Length, MAXUSHORT);
3083 CurrentWindowName.MaximumLength = (USHORT)min(Child->strName.MaximumLength, MAXUSHORT);
3084 if(!CheckWindowName ||
3085 (Child->strName.Length < 0xFFFF &&
3086 !RtlCompareUnicodeString(WindowName, &CurrentWindowName, TRUE)))
3087 {
3088 Ret = Child->head.h;
3089 break;
3090 }
3091 }
3092 }
3094 }
3095
3096 return Ret;
3097}
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
#define min(a, b)
Definition: monoChain.cc:55
unsigned short USHORT
Definition: pedump.c:61
#define MAXUSHORT
Definition: typedefs.h:83

Referenced by IntDefWindowProc(), and NtUserFindWindowEx().

◆ IntFixWindowCoordinates()

void FASTCALL IntFixWindowCoordinates ( CREATESTRUCTW Cs,
PWND  ParentWindow,
DWORD dwShowMode 
)

Definition at line 1697 of file window.c.

1698{
1699#define IS_DEFAULT(x) ((x) == CW_USEDEFAULT || (x) == (SHORT)0x8000)
1700
1701 /* default positioning for overlapped windows */
1702 if(!(Cs->style & (WS_POPUP | WS_CHILD)))
1703 {
1704 PMONITOR pMonitor;
1705 PRTL_USER_PROCESS_PARAMETERS ProcessParams;
1706
1707 pMonitor = UserGetPrimaryMonitor();
1708
1709 /* Check if we don't have a monitor attached yet */
1710 if(pMonitor == NULL)
1711 {
1712 Cs->x = Cs->y = 0;
1713 Cs->cx = 800;
1714 Cs->cy = 600;
1715 return;
1716 }
1717
1718 ProcessParams = PsGetCurrentProcess()->Peb->ProcessParameters;
1719
1720 if (IS_DEFAULT(Cs->x))
1721 {
1722 if (!IS_DEFAULT(Cs->y)) *dwShowMode = Cs->y;
1723
1724 if(ProcessParams->WindowFlags & STARTF_USEPOSITION)
1725 {
1726 Cs->x = ProcessParams->StartingX;
1727 Cs->y = ProcessParams->StartingY;
1728 }
1729 else
1730 {
1733 if (Cs->x > ((pMonitor->rcWork.right - pMonitor->rcWork.left) / 4) ||
1734 Cs->y > ((pMonitor->rcWork.bottom - pMonitor->rcWork.top) / 4))
1735 {
1736 /* reset counter and position */
1737 Cs->x = 0;
1738 Cs->y = 0;
1739 pMonitor->cWndStack = 0;
1740 }
1741 pMonitor->cWndStack++;
1742 }
1743 }
1744
1745 if (IS_DEFAULT(Cs->cx))
1746 {
1747 if (ProcessParams->WindowFlags & STARTF_USEPOSITION)
1748 {
1749 Cs->cx = ProcessParams->CountX;
1750 Cs->cy = ProcessParams->CountY;
1751 }
1752 else
1753 {
1754 Cs->cx = (pMonitor->rcWork.right - pMonitor->rcWork.left) * 3 / 4;
1755 Cs->cy = (pMonitor->rcWork.bottom - pMonitor->rcWork.top) * 3 / 4;
1756 }
1757 }
1758 /* neither x nor cx are default. Check the y values .
1759 * In the trace we see Outlook and Outlook Express using
1760 * cy set to CW_USEDEFAULT when opening the address book.
1761 */
1762 else if (IS_DEFAULT(Cs->cy))
1763 {
1764 TRACE("Strange use of CW_USEDEFAULT in nHeight\n");
1765 Cs->cy = (pMonitor->rcWork.bottom - pMonitor->rcWork.top) * 3 / 4;
1766 }
1767 }
1768 else
1769 {
1770 /* if CW_USEDEFAULT is set for non-overlapped windows, both values are set to zero */
1771 if(IS_DEFAULT(Cs->x))
1772 {
1773 Cs->x = 0;
1774 Cs->y = 0;
1775 }
1776 if(IS_DEFAULT(Cs->cx))
1777 {
1778 Cs->cx = 0;
1779 Cs->cy = 0;
1780 }
1781 }
1782
1783#undef IS_DEFAULT
1784}
SHORT cWndStack
Definition: monitor.h:22
RECT rcWork
Definition: monitor.h:19
LONG bottom
Definition: windef.h:309
PMONITOR NTAPI UserGetPrimaryMonitor(VOID)
Definition: monitor.c:102
#define IS_DEFAULT(x)
#define STARTF_USEPOSITION
Definition: winbase.h:493
#define SM_CYSIZE
Definition: winuser.h:986
#define SM_CXFRAME
Definition: winuser.h:988
#define SM_CXSIZE
Definition: winuser.h:985
#define SM_CYFRAME
Definition: winuser.h:990
#define PsGetCurrentProcess
Definition: psfuncs.h:17

Referenced by co_UserCreateWindowEx().

◆ IntFreeHwndList()

VOID FASTCALL IntFreeHwndList ( PWINDOWLIST  pwlTarget)

Definition at line 1456 of file window.c.

1457{
1458 PWINDOWLIST pwl, *ppwl;
1459
1460 for (ppwl = &gpwlList; *ppwl; ppwl = &(*ppwl)->pNextList)
1461 {
1462 if (*ppwl != pwlTarget)
1463 continue;
1464
1465 *ppwl = pwlTarget->pNextList;
1466
1467 if (gpwlCache)
1468 {
1469 if (WL_CAPACITY(pwlTarget) > WL_CAPACITY(gpwlCache))
1470 {
1471 pwl = gpwlCache;
1472 gpwlCache = pwlTarget;
1474 }
1475 else
1476 {
1478 }
1479 }
1480 else
1481 {
1482 gpwlCache = pwlTarget;
1483 }
1484
1485 break;
1486 }
1487}
#define WL_CAPACITY(pwl)
Definition: window.h:98

Referenced by ExitThreadCallback(), IntAssociateInputContextEx(), IntCheckImeShowStatus(), IntDestroyInputContext(), and IntImeWindowPosChanged().

◆ IntGetNonChildAncestor()

PWND FASTCALL IntGetNonChildAncestor ( PWND  pWnd)

Definition at line 351 of file window.c.

352{
353 while(pWnd && (pWnd->style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
354 pWnd = pWnd->spwndParent;
355 return pWnd;
356}

Referenced by co_IntProcessMouseMessage(), co_IntSetActiveWindow(), and IntCreateWindow().

◆ IntGetParent()

PWND FASTCALL IntGetParent ( PWND  Wnd)

◆ IntGetWindow()

HWND FASTCALL IntGetWindow ( HWND  hWnd,
UINT  uCmd 
)

Definition at line 381 of file window.c.

383{
384 PWND Wnd, FoundWnd;
385 HWND Ret = NULL;
386
387 Wnd = ValidateHwndNoErr(hWnd);
388 if (!Wnd)
389 return NULL;
390
391 FoundWnd = NULL;
392 switch (uCmd)
393 {
394 case GW_OWNER:
395 if (Wnd->spwndOwner != NULL)
396 FoundWnd = Wnd->spwndOwner;
397 break;
398
399 case GW_HWNDFIRST:
400 if(Wnd->spwndParent != NULL)
401 {
402 FoundWnd = Wnd->spwndParent;
403 if (FoundWnd->spwndChild != NULL)
404 FoundWnd = FoundWnd->spwndChild;
405 }
406 break;
407 case GW_HWNDNEXT:
408 if (Wnd->spwndNext != NULL)
409 FoundWnd = Wnd->spwndNext;
410 break;
411
412 case GW_HWNDPREV:
413 if (Wnd->spwndPrev != NULL)
414 FoundWnd = Wnd->spwndPrev;
415 break;
416
417 case GW_CHILD:
418 if (Wnd->spwndChild != NULL)
419 FoundWnd = Wnd->spwndChild;
420 break;
421
422 case GW_HWNDLAST:
423 FoundWnd = Wnd;
424 while ( FoundWnd->spwndNext != NULL)
425 FoundWnd = FoundWnd->spwndNext;
426 break;
427
428 default:
429 Wnd = NULL;
430 break;
431 }
432
433 if (FoundWnd != NULL)
434 Ret = UserHMGetHandle(FoundWnd);
435 return Ret;
436}
struct _WND * spwndPrev
Definition: ntuser.h:707
struct _WND * spwndChild
Definition: ntuser.h:709
struct _WND * spwndNext
Definition: ntuser.h:706
#define GW_OWNER
Definition: winuser.h:761
#define GW_HWNDFIRST
Definition: winuser.h:759
#define GW_HWNDLAST
Definition: winuser.h:760
#define GW_HWNDNEXT
Definition: winuser.h:756
#define GW_HWNDPREV
Definition: winuser.h:757
#define GW_CHILD
Definition: winuser.h:758

Referenced by WinPosFixupFlags().

◆ IntGetWindowContextHelpId()

DWORD FASTCALL IntGetWindowContextHelpId ( PWND  pWnd)

Definition at line 438 of file window.c.

439{
440 DWORD HelpId;
441
442 do
443 {
445 if (!HelpId) break;
446 pWnd = IntGetParent(pWnd);
447 }
448 while (pWnd && pWnd->fnid != FNID_DESKTOP);
449 return HelpId;
450}
#define FNID_DESKTOP
Definition: ntuser.h:857
ATOM atomContextHelpIdProp
Definition: ntuser.h:1062
uint32_t DWORD_PTR
Definition: typedefs.h:65
HANDLE FASTCALL UserGetProp(_In_ PWND Window, _In_ ATOM Atom, _In_ BOOLEAN SystemProp)
Definition: prop.c:46

Referenced by IntDefWindowProc().

◆ IntGetWindowObject()

PWND FASTCALL IntGetWindowObject ( HWND  hWnd)

Definition at line 73 of file window.c.

74{
76
77 if (!hWnd) return NULL;
78
80 if (Window)
81 Window->head.cLockObj++;
82
83 return Window;
84}

Referenced by co_UserFreeWindow(), IntHideDesktop(), and IntSetOwner().

◆ IntGetWindowProc()

WNDPROC FASTCALL IntGetWindowProc ( PWND  pWnd,
BOOL  Ansi 
)

Definition at line 775 of file window.c.

777{
778 INT i;
779 PCLS Class;
780 WNDPROC gcpd, Ret = 0;
781
783
784 Class = pWnd->pcls;
785
787 {
788 for ( i = FNID_FIRST; i <= FNID_SWITCH; i++)
789 {
790 if (GETPFNSERVER(i) == pWnd->lpfnWndProc)
791 {
792 if (Ansi)
793 Ret = GETPFNCLIENTA(i);
794 else
795 Ret = GETPFNCLIENTW(i);
796 }
797 }
798 return Ret;
799 }
800
801 if (Class->fnid == FNID_EDIT)
802 Ret = pWnd->lpfnWndProc;
803 else
804 {
805 Ret = pWnd->lpfnWndProc;
806
807 if (Class->fnid <= FNID_GHOST && Class->fnid >= FNID_BUTTON)
808 {
809 if (Ansi)
810 {
811 if (GETPFNCLIENTW(Class->fnid) == pWnd->lpfnWndProc)
812 Ret = GETPFNCLIENTA(Class->fnid);
813 }
814 else
815 {
816 if (GETPFNCLIENTA(Class->fnid) == pWnd->lpfnWndProc)
817 Ret = GETPFNCLIENTW(Class->fnid);
818 }
819 }
820 if ( Ret != pWnd->lpfnWndProc)
821 return Ret;
822 }
823 if ( Ansi == !!(pWnd->state & WNDS_ANSIWINDOWPROC) )
824 return Ret;
825
826 gcpd = (WNDPROC)UserGetCPD(
827 pWnd,
829 (ULONG_PTR)Ret);
830
831 return (gcpd ? gcpd : Ret);
832}
ULONG_PTR FASTCALL UserGetCPD(PVOID pvClsWnd, GETCPD Flags, ULONG_PTR ProcIn)
Definition: callproc.c:107
#define ULONG_PTR
Definition: config.h:101
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FNID_SWITCH
Definition: ntuser.h:860
#define FNID_FIRST
Definition: ntuser.h:853
@ UserGetCPDU2A
Definition: ntuser.h:536
@ UserGetCPDWindow
Definition: ntuser.h:538
@ UserGetCPDA2U
Definition: ntuser.h:535
#define GETPFNSERVER(fnid)
Definition: ntuser.h:904
#define FNID_EDIT
Definition: ntuser.h:865
BOOL FASTCALL UserIsEnteredExclusive(VOID)
Definition: ntuser.c:227

Referenced by IntSetWindowProc().

◆ IntGrowHwndList()

BOOL FASTCALL IntGrowHwndList ( PWINDOWLIST ppwl)

Definition at line 1359 of file window.c.

1360{
1361 PWINDOWLIST pwlOld, pwlNew;
1362 SIZE_T ibOld, ibNew;
1363
1364#define GROW_COUNT 8
1365 pwlOld = *ppwl;
1366 ibOld = (LPBYTE)pwlOld->phwndLast - (LPBYTE)pwlOld;
1367 ibNew = ibOld + GROW_COUNT * sizeof(HWND);
1368#undef GROW_COUNT
1369 pwlNew = IntReAllocatePoolWithTag(PagedPool, pwlOld, ibOld, ibNew, USERTAG_WINDOWLIST);
1370 if (!pwlNew)
1371 return FALSE;
1372
1373 pwlNew->phwndLast = (HWND *)((LPBYTE)pwlNew + ibOld);
1374 pwlNew->phwndEnd = (HWND *)((LPBYTE)pwlNew + ibNew);
1375 *ppwl = pwlNew;
1376 return TRUE;
1377}
unsigned char * LPBYTE
Definition: typedefs.h:53
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define GROW_COUNT
PVOID FASTCALL IntReAllocatePoolWithTag(POOL_TYPE PoolType, PVOID pOld, SIZE_T cbOld, SIZE_T cbNew, ULONG Tag)
Definition: window.c:22

Referenced by IntPopulateHwndList().

◆ IntIsChildWindow()

BOOL FASTCALL IntIsChildWindow ( PWND  Parent,
PWND  BaseWindow 
)

Definition at line 922 of file window.c.

923{
925 do
926 {
927 if ( Window == NULL || (Window->style & (WS_POPUP|WS_CHILD)) != WS_CHILD )
928 return FALSE;
929
930 Window = Window->spwndParent;
931 }
932 while(Parent != Window);
933 return TRUE;
934}
struct tagBaseWindow BaseWindow

Referenced by co_IntFixCaret(), co_IntSetParent(), DceResetActiveDCEs(), IntGetPaintMessage(), and NC_DoNCPaint().

◆ IntIsTopLevelWindow()

BOOL FASTCALL IntIsTopLevelWindow ( PWND  pWnd)

Definition at line 359 of file window.c.

360{
361 if ( pWnd->spwndParent &&
362 pWnd->spwndParent == co_GetDesktopWindow(pWnd) ) return TRUE;
363 return FALSE;
364}

Referenced by co_UserCreateWindowEx(), and co_UserDestroyWindow().

◆ IntIsWindow()

◆ IntIsWindowVisible()

BOOL FASTCALL IntIsWindowVisible ( PWND  Wnd)

Definition at line 189 of file window.c.

190{
191 PWND Temp = Wnd;
192 for (;;)
193 {
194 if (!Temp) return TRUE;
195 if (!(Temp->style & WS_VISIBLE)) break;
196 if (Temp->style & WS_MINIMIZE && Temp != Wnd) break;
197 if (Temp->fnid == FNID_DESKTOP) return TRUE;
198 Temp = Temp->spwndParent;
199 }
200 return FALSE;
201}

Referenced by co_IntSendActivateMessages(), DefWndDoSizeMove(), DefWndPrint(), NC_DoNCPaint(), UserDrawCaptionBar(), and WinPosFixupFlags().

◆ IntLinkHwnd()

VOID FASTCALL IntLinkHwnd ( PWND  Wnd,
HWND  hWndPrev 
)

Definition at line 977 of file window.c.

978{
979 if (hWndPrev == HWND_NOTOPMOST)
980 {
981 if (!(Wnd->ExStyle & WS_EX_TOPMOST) && (Wnd->ExStyle2 & WS_EX2_LINKED))
982 return; /* nothing to do */
983 Wnd->ExStyle &= ~WS_EX_TOPMOST;
984 hWndPrev = HWND_TOP; /* fallback to the HWND_TOP case */
985 }
986
987 IntUnlinkWindow(Wnd); /* unlink it from the previous location */
988
989 if (hWndPrev == HWND_BOTTOM)
990 {
991 /* Link in the bottom of the list */
992 PWND WndInsertAfter;
993
994 WndInsertAfter = Wnd->spwndParent->spwndChild;
995 while (WndInsertAfter && WndInsertAfter->spwndNext)
996 {
997 WndInsertAfter = WndInsertAfter->spwndNext;
998 }
999
1000 IntLinkWindow(Wnd, WndInsertAfter);
1001 Wnd->ExStyle &= ~WS_EX_TOPMOST;
1002 }
1003 else if (hWndPrev == HWND_TOPMOST)
1004 {
1005 /* Link in the top of the list */
1006 IntLinkWindow(Wnd, NULL);
1007 Wnd->ExStyle |= WS_EX_TOPMOST;
1008 }
1009 else if (hWndPrev == HWND_TOP)
1010 {
1011 /* Link it after the last topmost window */
1012 PWND WndInsertBefore;
1013
1014 WndInsertBefore = Wnd->spwndParent->spwndChild;
1015
1016 if (!(Wnd->ExStyle & WS_EX_TOPMOST)) /* put it above the first non-topmost window */
1017 {
1018 while (WndInsertBefore != NULL && WndInsertBefore->spwndNext != NULL)
1019 {
1020 if (!(WndInsertBefore->ExStyle & WS_EX_TOPMOST))
1021 break;
1022
1023 if (WndInsertBefore == Wnd->spwndOwner) /* keep it above owner */
1024 {
1025 Wnd->ExStyle |= WS_EX_TOPMOST;
1026 break;
1027 }
1028 WndInsertBefore = WndInsertBefore->spwndNext;
1029 }
1030 }
1031
1032 IntLinkWindow(Wnd, WndInsertBefore ? WndInsertBefore->spwndPrev : NULL);
1033 }
1034 else
1035 {
1036 /* Link it after hWndPrev */
1037 PWND WndInsertAfter;
1038
1039 WndInsertAfter = UserGetWindowObject(hWndPrev);
1040 /* Are we called with an erroneous handle */
1041 if (WndInsertAfter == NULL)
1042 {
1043 /* Link in a default position */
1044 IntLinkHwnd(Wnd, HWND_TOP);
1045 return;
1046 }
1047
1048 if (Wnd == WndInsertAfter)
1049 ERR("IntLinkHwnd -- Trying to link window 0x%p to itself!!\n", Wnd);
1050 IntLinkWindow(Wnd, WndInsertAfter);
1051
1052 /* Fix the WS_EX_TOPMOST flag */
1053 if (!(WndInsertAfter->ExStyle & WS_EX_TOPMOST))
1054 {
1055 Wnd->ExStyle &= ~WS_EX_TOPMOST;
1056 }
1057 else
1058 {
1059 if (WndInsertAfter->spwndNext &&
1060 (WndInsertAfter->spwndNext->ExStyle & WS_EX_TOPMOST))
1061 {
1062 Wnd->ExStyle |= WS_EX_TOPMOST;
1063 }
1064 }
1065 }
1066 Wnd->ExStyle2 |= WS_EX2_LINKED;
1067}
#define WS_EX2_LINKED
Definition: ntuser.h:671
VOID FASTCALL IntLinkWindow(PWND Wnd, PWND WndInsertAfter)
Definition: window.c:939
#define HWND_NOTOPMOST
Definition: winuser.h:1196

Referenced by co_IntSetParent(), co_UserCreateWindowEx(), co_WinPosSetWindowPos(), IntImeSetTopMost(), and IntLinkHwnd().

◆ IntLinkWindow()

VOID FASTCALL IntLinkWindow ( PWND  Wnd,
PWND  WndInsertAfter 
)

Definition at line 939 of file window.c.

943{
944 if (Wnd == WndInsertAfter)
945 {
946 ERR("IntLinkWindow -- Trying to link window 0x%p to itself!!\n", Wnd);
947 return;
948 }
949
950 Wnd->spwndPrev = WndInsertAfter;
951 if (Wnd->spwndPrev)
952 {
953 /* Link after WndInsertAfter */
954 ASSERT(Wnd != WndInsertAfter->spwndNext);
955 Wnd->spwndNext = WndInsertAfter->spwndNext;
956 if (Wnd->spwndNext)
957 Wnd->spwndNext->spwndPrev = Wnd;
958
959 ASSERT(Wnd != Wnd->spwndPrev);
960 Wnd->spwndPrev->spwndNext = Wnd;
961 }
962 else
963 {
964 /* Link at the top */
965 ASSERT(Wnd != Wnd->spwndParent->spwndChild);
966 Wnd->spwndNext = Wnd->spwndParent->spwndChild;
967 if (Wnd->spwndNext)
968 Wnd->spwndNext->spwndPrev = Wnd;
969
970 Wnd->spwndParent->spwndChild = Wnd;
971 }
972}

Referenced by IntLinkHwnd().

◆ IntPopulateHwndList()

PWINDOWLIST FASTCALL IntPopulateHwndList ( PWINDOWLIST  pwl,
PWND  pwnd,
DWORD  dwFlags 
)

Definition at line 1380 of file window.c.

1381{
1382 ASSERT(!WL_IS_BAD(pwl));
1383
1384 for (; pwnd; pwnd = pwnd->spwndNext)
1385 {
1386 if (!pwl->pti || pwl->pti == pwnd->head.pti)
1387 {
1388 *(pwl->phwndLast) = UserHMGetHandle(pwnd);
1389 ++(pwl->phwndLast);
1390
1391 if (pwl->phwndLast == pwl->phwndEnd && !IntGrowHwndList(&pwl))
1392 break;
1393 }
1394
1395 if ((dwFlags & IACE_CHILDREN) && pwnd->spwndChild)
1396 {
1398 if (WL_IS_BAD(pwl))
1399 break;
1400 }
1401
1402 if (!(dwFlags & IACE_LIST))
1403 break;
1404 }
1405
1406 return pwl;
1407}
#define IACE_CHILDREN
Definition: imm.h:581
BOOL FASTCALL IntGrowHwndList(PWINDOWLIST *ppwl)
Definition: window.c:1359
#define IACE_LIST
Definition: window.h:106

Referenced by IntBuildHwndList(), and IntPopulateHwndList().

◆ IntProcessOwnerSwap()

VOID FASTCALL IntProcessOwnerSwap ( PWND  Wnd,
PWND  WndNewOwner,
PWND  WndOldOwner 
)

Definition at line 1070 of file window.c.

1071{
1072 if (WndOldOwner)
1073 {
1074 if (Wnd->head.pti != WndOldOwner->head.pti)
1075 {
1076 if (!WndNewOwner ||
1077 Wnd->head.pti == WndNewOwner->head.pti ||
1078 WndOldOwner->head.pti != WndNewOwner->head.pti )
1079 {
1080 //ERR("ProcessOwnerSwap Old out.\n");
1081 UserAttachThreadInput(Wnd->head.pti, WndOldOwner->head.pti, FALSE);
1082 }
1083 }
1084 }
1085 if (WndNewOwner)
1086 {
1087 if (Wnd->head.pti != WndNewOwner->head.pti)
1088 {
1089 if (!WndOldOwner ||
1090 WndOldOwner->head.pti != WndNewOwner->head.pti )
1091 {
1092 //ERR("ProcessOwnerSwap New in.\n");
1093 UserAttachThreadInput(Wnd->head.pti, WndNewOwner->head.pti, TRUE);
1094 }
1095 }
1096 }
1097 // FIXME: System Tray checks.
1098}

Referenced by IntSetOwner().

◆ IntReAllocatePoolWithTag()

PVOID FASTCALL IntReAllocatePoolWithTag ( POOL_TYPE  PoolType,
PVOID  pOld,
SIZE_T  cbOld,
SIZE_T  cbNew,
ULONG  Tag 
)

Definition at line 22 of file window.c.

28{
30 if (!pNew)
31 return NULL;
32
33 RtlCopyMemory(pNew, pOld, min(cbOld, cbNew));
35 return pNew;
36}
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3815

Referenced by IntGrowHwndList().

◆ IntRemoveTrackMouseEvent()

VOID FASTCALL IntRemoveTrackMouseEvent ( PDESKTOP  pDesk)

Definition at line 355 of file mouse.c.

357{
358 /* Generate a leave message */
359 if (pDesk->dwDTFlags & DF_TME_LEAVE)
360 {
361 UINT uMsg = (pDesk->htEx != HTCLIENT) ? WM_NCMOUSELEAVE : WM_MOUSELEAVE;
362 UserPostMessage(UserHMGetHandle(pDesk->spwndTrack), uMsg, 0, 0);
363 }
364 /* Kill the timer */
365 if (pDesk->dwDTFlags & DF_TME_HOVER)
367
368 /* Reset state */
370 pDesk->spwndTrack = NULL;
371}
#define WM_MOUSELEAVE
Definition: commctrl.h:4975
PWND spwndTrack
Definition: desktop.h:31
DWORD htEx
Definition: desktop.h:32
DWORD dwDTFlags
Definition: desktop.h:12
#define DF_TME_LEAVE
Definition: desktop.h:48
#define DF_TME_HOVER
Definition: desktop.h:47
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1346
BOOL FASTCALL IntKillTimer(PWND Window, UINT_PTR IDEvent, BOOL SystemTimer)
Definition: timer.c:573
#define ID_EVENT_SYSTIMER_MOUSEHOVER
Definition: timer.h:27
#define HTCLIENT
Definition: winuser.h:2465
#define WM_NCMOUSELEAVE
Definition: winuser.h:1832

Referenced by IntSendDestroyMsg().

◆ IntSendDestroyMsg()

static void IntSendDestroyMsg ( HWND  hWnd)
static

Definition at line 461 of file window.c.

462{
463 PTHREADINFO ti;
464 PWND Window;
465
468
469 if (Window)
470 {
471 /*
472 * Look whether the focus is within the tree of windows
473 * we will be destroying.
474 */
475 // Rule #1
476 if ( ti->MessageQueue->spwndActive == Window || // Fixes CORE-106 RegSvr32 exit and return focus to CMD.
477 (ti->MessageQueue->spwndActive == NULL && ti->MessageQueue == IntGetFocusMessageQueue()) )
478 {
480 }
481
482 /* Fixes CMD properties closing and returning focus to CMD */
483 if (ti->MessageQueue->spwndFocus == Window)
484 {
485 if ((Window->style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
486 {
487 co_UserSetFocus(Window->spwndParent);
488 }
489 else
490 {
492 }
493 }
494
495 if (ti->MessageQueue->CaretInfo.hWnd == UserHMGetHandle(Window))
496 {
498 }
499
500 /* If the window being destroyed is currently tracked... */
501 if (ti->rpdesk && ti->rpdesk->spwndTrack == Window)
502 {
504 }
505 }
506
507 /* If the window being destroyed is the current clipboard owner... */
508 if (ti->ppi->prpwinsta != NULL && Window == ti->ppi->prpwinsta->spwndClipOwner)
509 {
510 /* ... make it release the clipboard */
512 }
513
514 /* Send the WM_DESTROY to the window */
516
517 /*
518 * This WM_DESTROY message can trigger re-entrant calls to DestroyWindow
519 * make sure that the window still exists when we come back.
520 */
521 if (IntIsWindow(hWnd))
522 {
523 HWND* pWndArray;
524 int i;
525
526 if (!(pWndArray = IntWinListChildren( Window ))) return;
527
528 for (i = 0; pWndArray[i]; i++)
529 {
530 if (IntIsWindow( pWndArray[i] )) IntSendDestroyMsg( pWndArray[i] );
531 }
533 }
534 else
535 {
536 TRACE("destroyed itself while in WM_DESTROY!\n");
537 }
538}
VOID FASTCALL co_WinPosActivateOtherWindow(PWND Wnd)
Definition: winpos.c:398
struct _WINSTATION_OBJECT * prpwinsta
Definition: win32.h:266
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:89
BOOL FASTCALL co_IntDestroyCaret(PTHREADINFO Win32Thread)
Definition: caret.c:159
VOID FASTCALL UserClipboardRelease(PWND pWindow)
Definition: clipboard.c:374
PUSER_MESSAGE_QUEUE FASTCALL IntGetFocusMessageQueue(VOID)
Definition: desktop.c:1307
VOID FASTCALL IntRemoveTrackMouseEvent(PDESKTOP pDesk)
Definition: mouse.c:355

Referenced by co_UserDestroyWindow(), and IntSendDestroyMsg().

◆ IntSendParentNotify()

static void IntSendParentNotify ( PWND  pWindow,
UINT  msg 
)
static

Definition at line 1678 of file window.c.

1679{
1680 if ( (pWindow->style & (WS_CHILD | WS_POPUP)) == WS_CHILD &&
1681 !(pWindow->ExStyle & WS_EX_NOPARENTNOTIFY))
1682 {
1683 if (VerifyWnd(pWindow->spwndParent) && !UserIsDesktopWindow(pWindow->spwndParent))
1684 {
1686 UserRefObjectCo(pWindow->spwndParent, &Ref);
1687 co_IntSendMessage( pWindow->spwndParent->head.h,
1689 MAKEWPARAM( msg, pWindow->IDMenu),
1690 (LPARAM)pWindow->head.h );
1692 }
1693 }
1694}
#define WS_EX_NOPARENTNOTIFY
Definition: pedump.c:646
PWND FASTCALL VerifyWnd(PWND pWnd)
Definition: window.c:86
#define MAKEWPARAM(l, h)
Definition: winuser.h:3999
#define WM_PARENTNOTIFY
Definition: winuser.h:1793

Referenced by co_UserCreateWindowEx(), and co_UserDestroyWindow().

◆ IntSetOwner()

static HWND FASTCALL IntSetOwner ( HWND  hWnd,
HWND  hWndNewOwner 
)
static

Definition at line 1102 of file window.c.

1103{
1104 PWND Wnd, WndOldOwner, WndNewOwner;
1105 HWND ret;
1106
1107 Wnd = IntGetWindowObject(hWnd);
1108 if(!Wnd)
1109 return NULL;
1110
1111 WndOldOwner = Wnd->spwndOwner;
1112
1113 ret = WndOldOwner ? UserHMGetHandle(WndOldOwner) : 0;
1114 WndNewOwner = UserGetWindowObject(hWndNewOwner);
1115
1116 if (!WndNewOwner && hWndNewOwner)
1117 {
1119 ret = NULL;
1120 goto Error;
1121 }
1122
1123 /* if parent belongs to a different thread and the window isn't */
1124 /* top-level, attach the two threads */
1125 IntProcessOwnerSwap(Wnd, WndNewOwner, WndOldOwner);
1126
1127 if (IntValidateOwnerDepth(Wnd, WndNewOwner))
1128 {
1129 WndSetOwner(Wnd, WndNewOwner);
1130 }
1131 else
1132 {
1133 IntProcessOwnerSwap(Wnd, WndOldOwner, WndNewOwner);
1135 ret = NULL;
1136 }
1137Error:
1139 return ret;
1140}
VOID FASTCALL IntProcessOwnerSwap(PWND Wnd, PWND WndNewOwner, PWND WndOldOwner)
Definition: window.c:1070

Referenced by co_IntSetWindowLongPtr().

◆ IntSetStyle()

ULONG FASTCALL IntSetStyle ( PWND  pwnd,
ULONG  set_bits,
ULONG  clear_bits 
)

Definition at line 143 of file window.c.

144{
145 ULONG styleOld, styleNew;
146 styleOld = pwnd->style;
147 styleNew = (pwnd->style | set_bits) & ~clear_bits;
148 if (styleNew == styleOld) return styleNew;
149 pwnd->style = styleNew;
150 if ((styleOld ^ styleNew) & WS_VISIBLE) // State Change.
151 {
152 if (styleOld & WS_VISIBLE) pwnd->head.pti->cVisWindows--;
153 if (styleNew & WS_VISIBLE) pwnd->head.pti->cVisWindows++;
154 DceResetActiveDCEs( pwnd );
155 }
156 return styleOld;
157}

Referenced by co_UserCreateWindowEx(), co_UserShowScrollBar(), co_WinPosMinMaximize(), co_WinPosShowWindow(), IntDefWindowProc(), and IntEnableWindow().

◆ IntSetWindowProc()

static WNDPROC IntSetWindowProc ( PWND  pWnd,
WNDPROC  NewWndProc,
BOOL  Ansi 
)
static

Definition at line 835 of file window.c.

838{
839 INT i;
840 PCALLPROCDATA CallProc;
841 PCLS Class;
842 WNDPROC Ret, chWndProc = NULL;
843
844 // Retrieve previous window proc.
845 Ret = IntGetWindowProc(pWnd, Ansi);
846
847 Class = pWnd->pcls;
848
849 if (IsCallProcHandle(NewWndProc))
850 {
851 CallProc = UserGetObject(gHandleTable, NewWndProc, TYPE_CALLPROC);
852 if (CallProc)
853 { // Reset new WndProc.
854 NewWndProc = CallProc->pfnClientPrevious;
855 // Reset Ansi from CallProc handle. This is expected with wine "deftest".
856 Ansi = !!(CallProc->wType & UserGetCPDU2A);
857 }
858 }
859 // Switch from Client Side call to Server Side call if match. Ref: "deftest".
860 for ( i = FNID_FIRST; i <= FNID_SWITCH; i++)
861 {
862 if (GETPFNCLIENTW(i) == NewWndProc)
863 {
864 chWndProc = GETPFNSERVER(i);
865 break;
866 }
867 if (GETPFNCLIENTA(i) == NewWndProc)
868 {
869 chWndProc = GETPFNSERVER(i);
870 break;
871 }
872 }
873 // If match, set/reset to Server Side and clear ansi.
874 if (chWndProc)
875 {
876 pWnd->lpfnWndProc = chWndProc;
877 pWnd->Unicode = TRUE;
878 pWnd->state &= ~WNDS_ANSIWINDOWPROC;
880 }
881 else
882 {
883 pWnd->Unicode = !Ansi;
884 // Handle the state change in here.
885 if (Ansi)
886 pWnd->state |= WNDS_ANSIWINDOWPROC;
887 else
888 pWnd->state &= ~WNDS_ANSIWINDOWPROC;
889
891 pWnd->state &= ~WNDS_SERVERSIDEWINDOWPROC;
892
893 if (!NewWndProc) NewWndProc = pWnd->lpfnWndProc;
894
895 if (Class->fnid <= FNID_GHOST && Class->fnid >= FNID_BUTTON)
896 {
897 if (Ansi)
898 {
899 if (GETPFNCLIENTW(Class->fnid) == NewWndProc)
900 chWndProc = GETPFNCLIENTA(Class->fnid);
901 }
902 else
903 {
904 if (GETPFNCLIENTA(Class->fnid) == NewWndProc)
905 chWndProc = GETPFNCLIENTW(Class->fnid);
906 }
907 }
908 // Now set the new window proc.
909 pWnd->lpfnWndProc = (chWndProc ? chWndProc : NewWndProc);
910 }
911 return Ret;
912}
GETCPD wType
Definition: ntuser.h:548
WNDPROC FASTCALL IntGetWindowProc(PWND pWnd, BOOL Ansi)
Definition: window.c:775

Referenced by co_IntSetWindowLongPtr().

◆ IntShowOwnedPopups()

BOOL FASTCALL IntShowOwnedPopups ( PWND  OwnerWnd,
BOOL  fShow 
)

Definition at line 4650 of file window.c.

4651{
4652 int count = 0;
4653 PWND pWnd;
4654 HWND *win_array;
4655
4656// ASSERT(OwnerWnd);
4657
4658 TRACE("Enter ShowOwnedPopups Show: %s\n", (fShow ? "TRUE" : "FALSE"));
4659
4660 /* NOTE: Popups are not children */
4661 win_array = IntWinListOwnedPopups(OwnerWnd);
4662
4663 if (!win_array)
4664 return TRUE;
4665
4666 while (win_array[count])
4667 count++;
4668 while (--count >= 0)
4669 {
4670 if (!(pWnd = ValidateHwndNoErr( win_array[count] )))
4671 continue;
4672 ASSERT(pWnd->spwndOwner == OwnerWnd);
4673
4674 if (fShow)
4675 {
4676 if (pWnd->state & WNDS_HIDDENPOPUP)
4677 {
4678 /* In Windows, ShowOwnedPopups(TRUE) generates
4679 * WM_SHOWWINDOW messages with SW_PARENTOPENING,
4680 * regardless of the state of the owner
4681 */
4683 pWnd->state &= ~WNDS_HIDDENPOPUP;
4684 continue;
4685 }
4686 }
4687 else
4688 {
4689 if (pWnd->style & WS_VISIBLE)
4690 {
4691 /* In Windows, ShowOwnedPopups(FALSE) generates
4692 * WM_SHOWWINDOW messages with SW_PARENTCLOSING,
4693 * regardless of the state of the owner
4694 */
4696 pWnd->state |= WNDS_HIDDENPOPUP;
4697 continue;
4698 }
4699 }
4700 }
4702 TRACE("Leave ShowOwnedPopups\n");
4703 return TRUE;
4704}
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define WNDS_HIDDENPOPUP
Definition: ntuser.h:614
#define WM_SHOWWINDOW
Definition: winuser.h:1618
#define SW_PARENTCLOSING
Definition: winuser.h:2432
#define SW_PARENTOPENING
Definition: winuser.h:2434

Referenced by co_WinPosMinMaximize(), co_WinPosShowWindow(), DefWndHandleSysCommand(), and NtUserCallTwoParam().

◆ IntUnlinkWindow()

VOID FASTCALL IntUnlinkWindow ( PWND  Wnd)

Definition at line 1341 of file window.c.

1342{
1343 ASSERT(Wnd != Wnd->spwndNext);
1344 ASSERT(Wnd != Wnd->spwndPrev);
1345
1346 if (Wnd->spwndNext)
1347 Wnd->spwndNext->spwndPrev = Wnd->spwndPrev;
1348
1349 if (Wnd->spwndPrev)
1350 Wnd->spwndPrev->spwndNext = Wnd->spwndNext;
1351
1352 if (Wnd->spwndParent && Wnd->spwndParent->spwndChild == Wnd)
1353 Wnd->spwndParent->spwndChild = Wnd->spwndNext;
1354
1355 Wnd->spwndPrev = Wnd->spwndNext = NULL;
1356}

Referenced by co_IntSetParent(), co_UserFreeWindow(), IntImeSetTopMost(), and IntLinkHwnd().

◆ IntValidateOwnerDepth()

BOOL FASTCALL IntValidateOwnerDepth ( PWND  Wnd,
PWND  Owner 
)

Definition at line 367 of file window.c.

368{
369 INT Depth = 1;
370 for (;;)
371 {
372 if ( !Owner ) return gNestedWindowLimit >= Depth;
373 if (Owner == Wnd) break;
374 Owner = Owner->spwndOwner;
375 Depth++;
376 }
377 return FALSE;
378}
INT gNestedWindowLimit
Definition: window.c:14
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION _In_ ULONG _In_ SIZE_T _In_ ULONG _In_ USHORT Depth
Definition: exfuncs.h:819

Referenced by IntCreateWindow(), and IntSetOwner().

◆ IntWinListChildren()

HWND *FASTCALL IntWinListChildren ( PWND  Window)

Definition at line 274 of file window.c.

275{
276 PWND Child;
277 HWND *List;
278 UINT Index, NumChildren = 0;
279
280 if (!Window) return NULL;
281
282 for (Child = Window->spwndChild; Child; Child = Child->spwndNext)
283 {
284 ++NumChildren;
285 }
286
287 List = ExAllocatePoolWithTag(PagedPool, (NumChildren + 1) * sizeof(HWND), USERTAG_WINDOWLIST);
288 if(!List)
289 {
290 ERR("Failed to allocate memory for children array\n");
292 return NULL;
293 }
294
295 Index = 0;
296 for (Child = Window->spwndChild; Child; Child = Child->spwndNext)
297 {
298 List[Index++] = Child->head.h;
299 }
300 List[Index] = NULL;
301
302 return List;
303}

Referenced by co_IntPaintWindows(), co_IntSendActivateMessages(), co_IntSendMessageTimeout(), co_UserFreeWindow(), co_WinPosSearchChildren(), IntChildWindowFromPointEx(), IntClientShutdown(), IntDeactivateWindow(), IntFindWindow(), IntRealChildWindowFromPoint(), IntSendDestroyMsg(), NtUserBuildHwndList(), NtUserFindWindowEx(), NtUserMessageCall(), SpiNotifyNCMetricsChanged(), UserPostMessage(), UserRegisterUserApiHook(), UserSendNotifyMessage(), and WinPosDoOwnedPopups().

◆ IntWinListOwnedPopups()

HWND *FASTCALL IntWinListOwnedPopups ( PWND  Window)

Definition at line 315 of file window.c.

316{
318 HWND *List;
319 UINT Index, NumOwned = 0;
320
322 if (!Desktop)
323 return NULL;
324
325 for (Child = Desktop->spwndChild; Child; Child = Child->spwndNext)
326 {
327 if (Child->spwndOwner == Window && !IntWndIsDefaultIme(Child))
328 ++NumOwned;
329 }
330
331 List = ExAllocatePoolWithTag(PagedPool, (NumOwned + 1) * sizeof(HWND), USERTAG_WINDOWLIST);
332 if (!List)
333 {
334 ERR("Failed to allocate memory for children array\n");
336 return NULL;
337 }
338
339 Index = 0;
340 for (Child = Desktop->spwndChild; Child; Child = Child->spwndNext)
341 {
342 if (Child->spwndOwner == Window && !IntWndIsDefaultIme(Child))
343 List[Index++] = Child->head.h;
344 }
345 List[Index] = NULL;
346
347 return List;
348}
static BOOL IntWndIsDefaultIme(_In_ PWND Window)
Definition: window.c:306

Referenced by IntDestroyOwnedWindows(), and IntShowOwnedPopups().

◆ IntWndIsDefaultIme()

static BOOL IntWndIsDefaultIme ( _In_ PWND  Window)
static

Definition at line 306 of file window.c.

307{
308 PTHREADINFO pti = Window->head.pti;
309
310 return (IS_IMM_MODE() && !(pti->TIF_flags & TIF_INCLEANUP) &&
311 Window == pti->spwndDefaultIme);
312}

Referenced by IntWinListOwnedPopups().

◆ NtUserAlterWindowStyle()

DWORD APIENTRY NtUserAlterWindowStyle ( HWND  hWnd,
DWORD  Index,
LONG  NewValue 
)

Definition at line 4075 of file window.c.

4076{
4077 LONG ret;
4078
4080
4081 if (hWnd == IntGetDesktopWindow())
4082 {
4084 UserLeave();
4085 return 0;
4086 }
4087
4088 ret = co_IntSetWindowLongPtr(hWnd, Index, NewValue, FALSE, sizeof(LONG), TRUE);
4089
4090 UserLeave();
4091
4092 return ret;
4093}
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:254
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:245

Referenced by ButtonWndProc_common().

◆ NtUserBuildHwndList()

NTSTATUS NTAPI NtUserBuildHwndList ( HDESK  hDesktop,
HWND  hwndParent,
BOOLEAN  bChildren,
ULONG  dwThreadId,
ULONG  cHwnd,
HWND phwndList,
ULONG pcHwndNeeded 
)

Definition at line 1504 of file window.c.

1512{
1514 ULONG dwCount = 0;
1515
1516 if (pcHwndNeeded == NULL)
1518
1520
1521 if (hwndParent || !dwThreadId)
1522 {
1525
1526 if(!hwndParent)
1527 {
1528 if(hDesktop == NULL && !(Desktop = IntGetActiveDesktop()))
1529 {
1531 goto Quit;
1532 }
1533
1534 if(hDesktop)
1535 {
1537 UserMode,
1538 0,
1539 &Desktop);
1540 if(!NT_SUCCESS(Status))
1541 {
1543 goto Quit;
1544 }
1545 }
1546 hwndParent = Desktop->DesktopWindow;
1547 }
1548 else
1549 {
1550 hDesktop = 0;
1551 }
1552
1554 (Window = Parent->spwndChild))
1555 {
1556 BOOL bGoDown = TRUE;
1557
1559 while(TRUE)
1560 {
1561 if (bGoDown)
1562 {
1563 if (dwCount++ < cHwnd && phwndList)
1564 {
1565 _SEH2_TRY
1566 {
1567 ProbeForWrite(phwndList, sizeof(HWND), 1);
1568 *phwndList = Window->head.h;
1569 phwndList++;
1570 }
1572 {
1574 }
1575 _SEH2_END
1576 if(!NT_SUCCESS(Status))
1577 {
1578 break;
1579 }
1580 }
1581 if (Window->spwndChild && bChildren)
1582 {
1583 Window = Window->spwndChild;
1584 continue;
1585 }
1586 bGoDown = FALSE;
1587 }
1588 if (Window->spwndNext)
1589 {
1590 Window = Window->spwndNext;
1591 bGoDown = TRUE;
1592 continue;
1593 }
1594 Window = Window->spwndParent;
1595 if (Window == Parent)
1596 {
1597 break;
1598 }
1599 }
1600 }
1601
1602 if(hDesktop)
1603 {
1605 }
1606 }
1607 else // Build EnumThreadWindows list!
1608 {
1610 PTHREADINFO W32Thread;
1611 PWND Window;
1612 HWND *List = NULL;
1613
1615 if (!NT_SUCCESS(Status))
1616 {
1617 ERR("Thread Id is not valid!\n");
1619 goto Quit;
1620 }
1621 if (!(W32Thread = (PTHREADINFO)Thread->Tcb.Win32Thread))
1622 {
1624 TRACE("Tried to enumerate windows of a non gui thread\n");
1626 goto Quit;
1627 }
1628
1629 // Do not use Thread link list due to co_UserFreeWindow!!!
1630 // Current = W32Thread->WindowListHead.Flink;
1631 // Fixes Api:CreateWindowEx tests!!!
1633 if (List)
1634 {
1635 int i;
1636 for (i = 0; List[i]; i++)
1637 {
1639 if (Window && Window->head.pti == W32Thread)
1640 {
1641 if (dwCount < cHwnd && phwndList)
1642 {
1643 _SEH2_TRY
1644 {
1645 ProbeForWrite(phwndList, sizeof(HWND), 1);
1646 *phwndList = Window->head.h;
1647 phwndList++;
1648 }
1650 {
1652 }
1653 _SEH2_END
1654 if (!NT_SUCCESS(Status))
1655 {
1656 ERR("Failure to build window list!\n");
1657 break;
1658 }
1659 }
1660 dwCount++;
1661 }
1662 }
1664 }
1665
1667 }
1668
1669 *pcHwndNeeded = dwCount;
1671
1672Quit:
1674 UserLeave();
1675 return Status;
1676}
LONG NTSTATUS
Definition: precomp.h:26
static HWND hwndParent
Definition: cryptui.c:300
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
DWORD dwThreadId
Definition: fdebug.c:31
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
Status
Definition: gdiplustypes.h:25
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define UserMode
Definition: asm.h:35
NTSTATUS NTAPI PsLookupThreadByThreadId(IN HANDLE ThreadId, OUT PETHREAD *Thread)
Definition: thread.c:643
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:245
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:159
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
#define STATUS_SUCCESS
Definition: shellext.h:65
KTHREAD Tcb
Definition: pstypes.h:1103
PVOID Win32Thread
Definition: ketypes.h:1806
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PDESKTOP FASTCALL IntGetActiveDesktop(VOID)
Definition: desktop.c:1262
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1386
NTSTATUS FASTCALL IntValidateDesktopHandle(HDESK Desktop, KPROCESSOR_MODE AccessMode, ACCESS_MASK DesiredAccess, PDESKTOP *Object)
Definition: desktop.c:1237

Referenced by User32EnumWindows(), and WIN_ListChildren().

◆ NtUserCreateWindowEx()

HWND NTAPI NtUserCreateWindowEx ( DWORD  dwExStyle,
PLARGE_STRING  plstrClassName,
PLARGE_STRING  plstrClsVersion,
PLARGE_STRING  plstrWindowName,
DWORD  dwStyle,
int  x,
int  y,
int  nWidth,
int  nHeight,
HWND  hWndParent,
HMENU  hMenu,
HINSTANCE  hInstance,
LPVOID  lpParam,
DWORD  dwFlags,
PVOID  acbiBuffer 
)
Todo:
Allow passing plstrClassName as ANSI.

Definition at line 2651 of file window.c.

2667{
2669 LARGE_STRING lstrWindowName;
2670 LARGE_STRING lstrClassName;
2671 LARGE_STRING lstrClsVersion;
2672 UNICODE_STRING ustrClassName;
2673 UNICODE_STRING ustrClsVersion;
2674 CREATESTRUCTW Cs;
2675 HWND hwnd = NULL;
2676 PWND pwnd;
2677
2678 lstrWindowName.Buffer = NULL;
2679 lstrClassName.Buffer = NULL;
2680 lstrClsVersion.Buffer = NULL;
2681
2682 if ( (dwStyle & (WS_POPUP|WS_CHILD)) != WS_CHILD)
2683 {
2684 /* check hMenu is valid handle */
2685 if (hMenu && !UserGetMenuObject(hMenu))
2686 {
2687 ERR("NtUserCreateWindowEx: Got an invalid menu handle!\n");
2689 return NULL;
2690 }
2691 }
2692
2693 /* Copy the window name to kernel mode */
2694 Status = ProbeAndCaptureLargeString(&lstrWindowName, plstrWindowName);
2695 if (!NT_SUCCESS(Status))
2696 {
2697 ERR("NtUserCreateWindowEx: failed to capture plstrWindowName\n");
2699 return NULL;
2700 }
2701
2702 plstrWindowName = &lstrWindowName;
2703
2704 /* Check if the class is an atom */
2705 if (IS_ATOM(plstrClassName))
2706 {
2707 /* It is, pass the atom in the UNICODE_STRING */
2708 ustrClassName.Buffer = (PVOID)plstrClassName;
2709 ustrClassName.Length = 0;
2710 ustrClassName.MaximumLength = 0;
2711 }
2712 else
2713 {
2714 /* It's not, capture the class name */
2715 Status = ProbeAndCaptureLargeString(&lstrClassName, plstrClassName);
2716 if (!NT_SUCCESS(Status))
2717 {
2718 ERR("NtUserCreateWindowEx: failed to capture plstrClassName\n");
2719 /* Set last error, cleanup and return */
2721 goto cleanup;
2722 }
2723
2724 /* We pass it on as a UNICODE_STRING */
2725 ustrClassName.Buffer = lstrClassName.Buffer;
2726 ustrClassName.Length = (USHORT)min(lstrClassName.Length, MAXUSHORT); // FIXME: LARGE_STRING truncated
2727 ustrClassName.MaximumLength = (USHORT)min(lstrClassName.MaximumLength, MAXUSHORT);
2728 }
2729
2730 /* Check if the class version is an atom */
2731 if (IS_ATOM(plstrClsVersion))
2732 {
2733 /* It is, pass the atom in the UNICODE_STRING */
2734 ustrClsVersion.Buffer = (PVOID)plstrClsVersion;
2735 ustrClsVersion.Length = 0;
2736 ustrClsVersion.MaximumLength = 0;
2737 }
2738 else
2739 {
2740 /* It's not, capture the class name */
2741 Status = ProbeAndCaptureLargeString(&lstrClsVersion, plstrClsVersion);
2742 if (!NT_SUCCESS(Status))
2743 {
2744 ERR("NtUserCreateWindowEx: failed to capture plstrClsVersion\n");
2745 /* Set last error, cleanup and return */
2747 goto cleanup;
2748 }
2749
2750 /* We pass it on as a UNICODE_STRING */
2751 ustrClsVersion.Buffer = lstrClsVersion.Buffer;
2752 ustrClsVersion.Length = (USHORT)min(lstrClsVersion.Length, MAXUSHORT); // FIXME: LARGE_STRING truncated
2753 ustrClsVersion.MaximumLength = (USHORT)min(lstrClsVersion.MaximumLength, MAXUSHORT);
2754 }
2755
2756 /* Fill the CREATESTRUCTW */
2757 /* we will keep here the original parameters */
2758 Cs.style = dwStyle;
2759 Cs.lpCreateParams = lpParam;
2760 Cs.hInstance = hInstance;
2761 Cs.hMenu = hMenu;
2763 Cs.cx = nWidth;
2764 Cs.cy = nHeight;
2765 Cs.x = x;
2766 Cs.y = y;
2767 Cs.lpszName = (LPCWSTR) plstrWindowName->Buffer;
2768 Cs.lpszClass = ustrClassName.Buffer;
2769 Cs.dwExStyle = dwExStyle;
2770
2772
2773 /* Call the internal function */
2774 pwnd = co_UserCreateWindowEx(&Cs, &ustrClsVersion, plstrWindowName, acbiBuffer, dwFlags);
2775
2776 if(!pwnd)
2777 {
2778 ERR("co_UserCreateWindowEx failed!\n");
2779 }
2780 hwnd = pwnd ? UserHMGetHandle(pwnd) : NULL;
2781
2782 UserLeave();
2783
2784cleanup:
2785 if (lstrWindowName.Buffer)
2786 {
2787 ExFreePoolWithTag(lstrWindowName.Buffer, TAG_STRING);
2788 }
2789 if (lstrClassName.Buffer)
2790 {
2791 ExFreePoolWithTag(lstrClassName.Buffer, TAG_STRING);
2792 }
2793 if (lstrClsVersion.Buffer)
2794 {
2795 ExFreePoolWithTag(lstrClsVersion.Buffer, TAG_STRING);
2796 }
2797
2798 return hwnd;
2799}
HINSTANCE hInstance
Definition: charmap.c:19
#define IS_ATOM(x)
Definition: class.h:3
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define TAG_STRING
Definition: oslist.h:22
ULONG MaximumLength
Definition: ntuser.h:92
LPVOID lpCreateParams
Definition: winuser.h:2945
void * PVOID
Definition: typedefs.h:50
PWND FASTCALL co_UserCreateWindowEx(CREATESTRUCTW *Cs, PUNICODE_STRING ClassName, PLARGE_STRING WindowName, PVOID acbiBuffer, DWORD dwVer)
Definition: window.c:2158
NTSTATUS NTAPI ProbeAndCaptureLargeString(OUT PLARGE_STRING plstrSafe, IN PLARGE_STRING plstrUnsafe)
Definition: window.c:2594
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define ERROR_INVALID_MENU_HANDLE
Definition: winerror.h:882

Referenced by CreateWnd(), and User32CreateWindowEx().

◆ NtUserDefSetText()

BOOL APIENTRY NtUserDefSetText ( HWND  hWnd,
PLARGE_STRING  WindowText 
)

Definition at line 4453 of file window.c.

4454{
4455 PWND Wnd;
4456 LARGE_STRING SafeText;
4458 BOOL Ret = TRUE;
4459
4460 TRACE("Enter NtUserDefSetText\n");
4461
4462 if (WindowText != NULL)
4463 {
4464 _SEH2_TRY
4465 {
4466 SafeText = ProbeForReadLargeString(WindowText);
4467 }
4469 {
4470 Ret = FALSE;
4472 }
4473 _SEH2_END;
4474
4475 if (!Ret)
4476 return FALSE;
4477 }
4478 else
4479 return TRUE;
4480
4482
4483 if(!(Wnd = UserGetWindowObject(hWnd)))
4484 {
4485 UserLeave();
4486 return FALSE;
4487 }
4488
4489 // ReactOS uses Unicode and not mixed. Up/Down converting will take time.
4490 // Brought to you by: The Wine Project! Dysfunctional Thought Processes!
4491 // Now we know what the bAnsi is for.
4493 if (SafeText.Buffer)
4494 {
4495 _SEH2_TRY
4496 {
4497 if (SafeText.bAnsi)
4498 ProbeForRead(SafeText.Buffer, SafeText.Length, sizeof(CHAR));
4499 else
4500 ProbeForRead(SafeText.Buffer, SafeText.Length, sizeof(WCHAR));
4502 }
4504 {
4505 Ret = FALSE;
4507 }
4508 _SEH2_END;
4509 if (!Ret) goto Exit;
4510 }
4511
4512 if (UnicodeString.Length != 0)
4513 {
4514 if (Wnd->strName.MaximumLength > 0 &&
4515 UnicodeString.Length <= Wnd->strName.MaximumLength - sizeof(UNICODE_NULL))
4516 {
4517 ASSERT(Wnd->strName.Buffer != NULL);
4518
4519 Wnd->strName.Length = UnicodeString.Length;
4520 Wnd->strName.Buffer[UnicodeString.Length / sizeof(WCHAR)] = L'\0';
4522 UnicodeString.Buffer,
4523 UnicodeString.Length);
4524 }
4525 else
4526 {
4527 PWCHAR buf;
4528 Wnd->strName.MaximumLength = Wnd->strName.Length = 0;
4529 buf = Wnd->strName.Buffer;
4530 Wnd->strName.Buffer = NULL;
4531 if (buf != NULL)
4532 {
4534 }
4535
4537 UnicodeString.Length + sizeof(UNICODE_NULL));
4538 if (Wnd->strName.Buffer != NULL)
4539 {
4540 Wnd->strName.Buffer[UnicodeString.Length / sizeof(WCHAR)] = L'\0';
4542 UnicodeString.Buffer,
4543 UnicodeString.Length);
4544 Wnd->strName.MaximumLength = UnicodeString.Length + sizeof(UNICODE_NULL);
4545 Wnd->strName.Length = UnicodeString.Length;
4546 }
4547 else
4548 {
4550 Ret = FALSE;
4551 goto Exit;
4552 }
4553 }
4554 }
4555 else
4556 {
4557 Wnd->strName.Length = 0;
4558 if (Wnd->strName.Buffer != NULL)
4559 Wnd->strName.Buffer[0] = L'\0';
4560 }
4561
4562 // FIXME: HAX! Windows does not do this in here!
4563 // In User32, these are called after: NotifyWinEvent EVENT_OBJECT_NAMECHANGE than
4564 // RepaintButton, StaticRepaint, NtUserCallHwndLock HWNDLOCK_ROUTINE_REDRAWFRAMEANDHOOK, etc.
4565 /* Send shell notifications */
4566 if (!Wnd->spwndOwner && !IntGetParent(Wnd))
4567 {
4568 co_IntShellHookNotify(HSHELL_REDRAW, (WPARAM) hWnd, FALSE); // FIXME Flashing?
4569 }
4570
4571 Ret = TRUE;
4572Exit:
4574 TRACE("Leave NtUserDefSetText, ret=%i\n", Ret);
4575 UserLeave();
4576 return Ret;
4577}
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
BOOL NTAPI RtlLargeStringToUnicodeString(PUNICODE_STRING, PLARGE_STRING)
Definition: rtlstr.c:67
ULONG bAnsi
Definition: ntuser.h:93
char CHAR
Definition: xmlstorage.h:175

Referenced by DefSetText().

◆ NtUserDestroyWindow()

BOOLEAN APIENTRY NtUserDestroyWindow ( HWND  Wnd)

Definition at line 3013 of file window.c.

3014{
3015 PWND Window;
3017 BOOLEAN ret;
3019
3020 TR