ReactOS  0.4.15-dev-4920-g5fa8403
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)
 
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)
 
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)
 
static 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 3445 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");
1270  co_WinPosSetWindowPos( Wnd,
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 WS_CLIPSIBLINGS
Definition: pedump.c:618
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
DWORD ExStyle
Definition: ntuser.h:683
struct _DESKTOP * rpdesk
Definition: ntuser.h:186
VOID FASTCALL IntUnlinkWindow(PWND Wnd)
Definition: window.c:1341
DWORD ExStyle2
Definition: ntuser.h:724
NTSTATUS FASTCALL UserAttachThreadInput(PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach)
Definition: input.c:480
#define UserIsDesktopWindow(pWnd)
Definition: desktop.h:194
#define WS_EX2_LINKED
Definition: ntuser.h:659
#define TRUE
Definition: types.h:120
#define pt(x, y)
Definition: drawing.c:79
#define SW_HIDE
Definition: winuser.h:762
#define ASSERT_REFS_CO(_obj_)
Definition: userfuncs.h:14
VOID FASTCALL IntNotifyWinEvent(DWORD Event, PWND pWnd, LONG idObject, LONG idChild, DWORD flags)
Definition: event.c:179
BOOLEAN FASTCALL co_WinPosSetWindowPos(PWND Window, HWND WndInsertAfter, INT x, INT y, INT cx, INT cy, UINT flags)
Definition: winpos.c:1721
#define OBJID_WINDOW
Definition: winable.h:15
LONG top
Definition: windef.h:307
#define WS_EX_LAYOUTRTL
Definition: winuser.h:390
#define HWND_TOPMOST
Definition: winuser.h:1198
#define HWND_TOP
Definition: winuser.h:1197
#define WS_CHILD
Definition: pedump.c:617
LONG left
Definition: windef.h:306
#define SWP_NOZORDER
Definition: winuser.h:1237
LONG right
Definition: windef.h:308
VOID FASTCALL IntLinkHwnd(PWND Wnd, HWND hWndPrev)
Definition: window.c:971
#define FALSE
Definition: types.h:117
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CHILDID_SELF
Definition: winable.h:14
struct _WND * spwndOwner
Definition: ntuser.h:694
THRDESKHEAD head
Definition: ntuser.h:674
PWND FASTCALL co_GetDesktopWindow(PWND pWnd)
Definition: desktop.c:1366
#define WEF_SETBYWNDPTI
Definition: ntuser.h:227
BOOLEAN FASTCALL co_WinPosShowWindow(PWND Wnd, INT Cmd)
Definition: winpos.c:2491
#define TRACE(s)
Definition: solgame.cpp:4
#define ASSERT(a)
Definition: mode.c:44
#define SWP_NOACTIVATE
Definition: winuser.h:1232
#define UserIsMessageWindow(pWnd)
Definition: desktop.h:197
VOID FASTCALL DceResetActiveDCEs(PWND Window)
Definition: windc.c:816
#define WS_EX_TOPMOST
Definition: pedump.c:647
BOOL FASTCALL IntScreenToClient(PWND Wnd, LPPOINT lpPoint)
Definition: winpos.c:212
RECT rcWindow
Definition: ntuser.h:695
#define SWP_NOSIZE
Definition: winuser.h:1235
#define ERR(fmt,...)
Definition: debug.h:110
Definition: ntuser.h:672
#define SW_SHOWNORMAL
Definition: winuser.h:764
#define WS_POPUP
Definition: pedump.c:616
#define NULL
Definition: types.h:112
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
struct _WND * spwndParent
Definition: ntuser.h:692
BOOL FASTCALL IntIsChildWindow(PWND Parent, PWND BaseWindow)
Definition: window.c:916
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:28
VOID FASTCALL UserReferenceObject(PVOID obj)
Definition: object.c:731
DWORD style
Definition: ntuser.h:685

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 3810 of file window.c.

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

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 2180 of file window.c.

2185 {
2186  ULONG style;
2187  PWND Window = NULL, ParentWindow = NULL, OwnerWindow;
2188  HWND hWnd, hWndParent, hWndOwner, hwndInsertAfter;
2189  PWINSTATION_OBJECT WinSta;
2190  PCLS Class = NULL;
2191  SIZE Size;
2192  POINT MaxSize, MaxPos, MinTrack, MaxTrack;
2193  CBT_CREATEWNDW * pCbtCreate;
2194  LRESULT Result;
2195  USER_REFERENCE_ENTRY ParentRef, Ref;
2196  PTHREADINFO pti;
2197  DWORD dwShowMode = SW_SHOW;
2198  CREATESTRUCTW *pCsw = NULL;
2199  PVOID pszClass = NULL, pszName = NULL;
2200  PWND ret = NULL;
2201 
2202  /* Get the current window station and reference it */
2203  pti = GetW32ThreadInfo();
2204  if (pti == NULL || pti->rpdesk == NULL)
2205  {
2206  ERR("Thread is not attached to a desktop! Cannot create window!\n");
2207  return NULL; // There is nothing to cleanup.
2208  }
2209  WinSta = pti->rpdesk->rpwinstaParent;
2211 
2212  pCsw = NULL;
2213  pCbtCreate = NULL;
2214 
2215  /* Get the class and reference it */
2216  Class = IntGetAndReferenceClass(ClassName, Cs->hInstance, FALSE);
2217  if(!Class)
2218  {
2220  ERR("Failed to find class %wZ\n", ClassName);
2221  goto cleanup;
2222  }
2223 
2224  /* Now find the parent and the owner window */
2225  hWndParent = pti->rpdesk->pDeskInfo->spwnd->head.h;
2226  hWndOwner = NULL;
2227 
2228  if (Cs->hwndParent == HWND_MESSAGE)
2229  {
2230  Cs->hwndParent = hWndParent = pti->rpdesk->spwndMessage->head.h;
2231  }
2232  else if (Cs->hwndParent)
2233  {
2234  if ((Cs->style & (WS_CHILD|WS_POPUP)) != WS_CHILD)
2235  hWndOwner = Cs->hwndParent;
2236  else
2237  hWndParent = Cs->hwndParent;
2238  }
2239  else if ((Cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
2240  {
2241  ERR("Cannot create a child window without a parent!\n");
2243  goto cleanup; /* WS_CHILD needs a parent, but WS_POPUP doesn't */
2244  }
2246  (IS_INTRESOURCE(Cs->lpszClass) ||
2247  Cs->lpszClass != (LPCWSTR)MAKEINTATOM(gpsi->atomSysClass[ICLS_HWNDMESSAGE]) ||
2248  _wcsicmp(Cs->lpszClass, L"Message") != 0))
2249  {
2250  if (pti->ppi->dwLayout & LAYOUT_RTL)
2251  {
2252  Cs->dwExStyle |= WS_EX_LAYOUTRTL;
2253  }
2254  }
2255 
2256  ParentWindow = hWndParent ? UserGetWindowObject(hWndParent): NULL;
2257  OwnerWindow = hWndOwner ? UserGetWindowObject(hWndOwner): NULL;
2258 
2259  if (hWndParent && !ParentWindow)
2260  {
2261  ERR("Got invalid parent window handle\n");
2262  goto cleanup;
2263  }
2264  else if (hWndOwner && !OwnerWindow)
2265  {
2266  ERR("Got invalid owner window handle\n");
2267  ParentWindow = NULL;
2268  goto cleanup;
2269  }
2270 
2271  if(OwnerWindow)
2272  {
2273  if (IntIsDesktopWindow(OwnerWindow)) OwnerWindow = NULL;
2274  else if (ParentWindow && !IntIsDesktopWindow(ParentWindow))
2275  {
2276  ERR("an owned window must be created as top-level\n");
2278  goto cleanup;
2279  }
2280  else /* owner must be a top-level window */
2281  {
2282  while ((OwnerWindow->style & (WS_POPUP|WS_CHILD)) == WS_CHILD && !IntIsDesktopWindow(OwnerWindow->spwndParent))
2283  OwnerWindow = OwnerWindow->spwndParent;
2284  }
2285  }
2286 
2287  /* Fix the position and the size of the window */
2288  if (ParentWindow)
2289  {
2290  UserRefObjectCo(ParentWindow, &ParentRef);
2291  IntFixWindowCoordinates(Cs, ParentWindow, &dwShowMode);
2292  }
2293 
2294  /* Allocate and initialize the new window */
2295  Window = IntCreateWindow(Cs,
2296  WindowName,
2297  Class,
2298  ParentWindow,
2299  OwnerWindow,
2300  acbiBuffer,
2301  NULL,
2302  dwVer );
2303  if(!Window)
2304  {
2305  ERR("IntCreateWindow failed!\n");
2306  goto cleanup;
2307  }
2308 
2310  hwndInsertAfter = HWND_TOP;
2311 
2312  UserRefObjectCo(Window, &Ref);
2314  ObDereferenceObject(WinSta);
2315 
2316  /* NCCREATE, WM_NCCALCSIZE and Hooks need the original values */
2317  Cs->lpszName = (LPCWSTR) WindowName;
2318  Cs->lpszClass = (LPCWSTR) ClassName;
2319 
2321  if ( ISITHOOKED(WH_CBT) || (pti->rpdesk->pDeskInfo->fsHooks & HOOKID_TO_FLAG(WH_CBT)) )
2322  {
2323  // Allocate the calling structures Justin Case this goes Global.
2326  if (!pCsw || !pCbtCreate)
2327  {
2328  ERR("UserHeapAlloc() failed!\n");
2329  goto cleanup;
2330  }
2331 
2332  if (!IntMsgCreateStructW( Window, pCsw, Cs, &pszClass, &pszName ) )
2333  {
2334  ERR("IntMsgCreateStructW() failed!\n");
2335  goto cleanup;
2336  }
2337 
2338  pCbtCreate->lpcs = pCsw;
2339  pCbtCreate->hwndInsertAfter = hwndInsertAfter;
2340 
2343  if (Result != 0)
2344  {
2345  ERR("WH_CBT HCBT_CREATEWND hook failed! 0x%x\n", Result);
2346  goto cleanup;
2347  }
2348  // Write back changes.
2349  Cs->cx = pCsw->cx;
2350  Cs->cy = pCsw->cy;
2351  Cs->x = pCsw->x;
2352  Cs->y = pCsw->y;
2353  hwndInsertAfter = pCbtCreate->hwndInsertAfter;
2354  }
2355 
2356  if ((Cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
2357  {
2358  if (ParentWindow != co_GetDesktopWindow(Window))
2359  {
2360  Cs->x += ParentWindow->rcClient.left;
2361  Cs->y += ParentWindow->rcClient.top;
2362  }
2363  }
2364 
2365  /* Send the WM_GETMINMAXINFO message */
2366  Size.cx = Cs->cx;
2367  Size.cy = Cs->cy;
2368 
2369  if ((Cs->style & WS_THICKFRAME) || !(Cs->style & (WS_POPUP | WS_CHILD)))
2370  {
2371  co_WinPosGetMinMaxInfo(Window, &MaxSize, &MaxPos, &MinTrack, &MaxTrack);
2372  if (Size.cx > MaxTrack.x) Size.cx = MaxTrack.x;
2373  if (Size.cy > MaxTrack.y) Size.cy = MaxTrack.y;
2374  if (Size.cx < MinTrack.x) Size.cx = MinTrack.x;
2375  if (Size.cy < MinTrack.y) Size.cy = MinTrack.y;
2376  }
2377 
2378  Window->rcWindow.left = Cs->x;
2379  Window->rcWindow.top = Cs->y;
2380  Window->rcWindow.right = Cs->x + Size.cx;
2381  Window->rcWindow.bottom = Cs->y + Size.cy;
2382  /*
2383  if (0 != (Window->style & WS_CHILD) && ParentWindow)
2384  {
2385  ERR("co_UserCreateWindowEx(): Offset rcWindow\n");
2386  RECTL_vOffsetRect(&Window->rcWindow,
2387  ParentWindow->rcClient.left,
2388  ParentWindow->rcClient.top);
2389  }
2390  */
2391  /* correct child window coordinates if mirroring on parent is enabled */
2392  if (ParentWindow != NULL)
2393  {
2394  if ( ((Cs->style & WS_CHILD) == WS_CHILD) &&
2395  ((ParentWindow->ExStyle & WS_EX_LAYOUTRTL) == WS_EX_LAYOUTRTL))
2396  {
2397  Window->rcWindow.right = ParentWindow->rcClient.right - (Window->rcWindow.left - ParentWindow->rcClient.left);
2398  Window->rcWindow.left = Window->rcWindow.right - Size.cx;
2399  }
2400  }
2401 
2402  Window->rcClient = Window->rcWindow;
2403 
2404  if (Window->spwndNext || Window->spwndPrev)
2405  {
2406  ERR("Window 0x%p has been linked too early!\n", Window);
2407  }
2408 
2409  if (!(Window->state2 & WNDS2_WIN31COMPAT))
2410  {
2411  if (Class->style & CS_PARENTDC && !(ParentWindow->style & WS_CLIPCHILDREN))
2412  Window->style &= ~(WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
2413  }
2414 
2415  if ((Window->style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
2416  {
2417  if ( !IntIsTopLevelWindow(Window) )
2418  {
2419  if (pti != ParentWindow->head.pti)
2420  {
2421  //ERR("CreateWindow Parent in.\n");
2422  UserAttachThreadInput(pti, ParentWindow->head.pti, TRUE);
2423  }
2424  }
2425  }
2426 
2427  /* Send the NCCREATE message */
2429  if (!Result)
2430  {
2431  ERR("co_UserCreateWindowEx(): NCCREATE message failed\n");
2432  goto cleanup;
2433  }
2434 
2435  /* Link the window */
2436  if (ParentWindow != NULL)
2437  {
2438  /* Link the window into the siblings list */
2439  if ((Cs->style & (WS_CHILD | WS_MAXIMIZE)) == WS_CHILD)
2441  else
2442  IntLinkHwnd(Window, hwndInsertAfter);
2443  }
2444 
2445  /* Send the WM_NCCALCSIZE message */
2446  {
2447  // RECT rc;
2448  MaxPos.x = Window->rcWindow.left;
2449  MaxPos.y = Window->rcWindow.top;
2450 
2451  Result = co_WinPosGetNonClientSize(Window, &Window->rcWindow, &Window->rcClient);
2452  //rc = Window->rcWindow;
2453  //Result = co_IntSendMessageNoWait(Window->head.h, WM_NCCALCSIZE, FALSE, (LPARAM)&rc);
2454  //Window->rcClient = rc;
2455 
2456  RECTL_vOffsetRect(&Window->rcWindow, MaxPos.x - Window->rcWindow.left,
2457  MaxPos.y - Window->rcWindow.top);
2458  }
2459 
2460  /* Send the WM_CREATE message. */
2462  if (Result == (LRESULT)-1)
2463  {
2464  ERR("co_UserCreateWindowEx(): WM_CREATE message failed\n");
2465  goto cleanup;
2466  }
2467 
2468  /* Send the EVENT_OBJECT_CREATE event */
2469  IntNotifyWinEvent(EVENT_OBJECT_CREATE, Window, OBJID_WINDOW, CHILDID_SELF, 0);
2470 
2471  /* By setting the flag below it can be examined to determine if the window
2472  was created successfully and a valid pwnd was passed back to caller since
2473  from here the function has to succeed. */
2475 
2476  /* Send the WM_SIZE and WM_MOVE messages. */
2477  if (!(Window->state & WNDS_SENDSIZEMOVEMSGS))
2478  {
2480  }
2481 
2482  /* Show or maybe minimize or maximize the window. */
2483 
2485  if (style & (WS_MINIMIZE | WS_MAXIMIZE))
2486  {
2487  RECTL NewPos;
2488  UINT SwFlag = (style & WS_MINIMIZE) ? SW_MINIMIZE : SW_MAXIMIZE;
2489 
2490  SwFlag = co_WinPosMinMaximize(Window, SwFlag, &NewPos);
2491  SwFlag |= SWP_NOZORDER|SWP_FRAMECHANGED; /* Frame always gets changed */
2492  if (!(style & WS_VISIBLE) || (style & WS_CHILD) || UserGetActiveWindow()) SwFlag |= SWP_NOACTIVATE;
2493  co_WinPosSetWindowPos(Window, 0, NewPos.left, NewPos.top,
2494  NewPos.right, NewPos.bottom, SwFlag);
2495  }
2496 
2497  /* Send the WM_PARENTNOTIFY message */
2499 
2500  /* Notify the shell that a new window was created */
2501  if (Window->spwndOwner == NULL ||
2502  !(Window->spwndOwner->style & WS_VISIBLE) ||
2503  (Window->spwndOwner->ExStyle & WS_EX_TOOLWINDOW))
2504  {
2505  if (UserIsDesktopWindow(Window->spwndParent) &&
2506  (Window->style & WS_VISIBLE) &&
2507  (!(Window->ExStyle & WS_EX_TOOLWINDOW) ||
2508  (Window->ExStyle & WS_EX_APPWINDOW)))
2509  {
2511  }
2512  }
2513 
2514  /* Initialize and show the window's scrollbars */
2515  if (Window->style & WS_VSCROLL)
2516  {
2518  }
2519  if (Window->style & WS_HSCROLL)
2520  {
2522  }
2523 
2524  /* Show the new window */
2525  if (Cs->style & WS_VISIBLE)
2526  {
2527  if (Window->style & WS_MAXIMIZE)
2528  dwShowMode = SW_SHOW;
2529  else if (Window->style & WS_MINIMIZE)
2530  dwShowMode = SW_SHOWMINIMIZED;
2531 
2532  co_WinPosShowWindow(Window, dwShowMode);
2533 
2534  if (Window->ExStyle & WS_EX_MDICHILD)
2535  {
2536  ASSERT(ParentWindow);
2537  if(!ParentWindow)
2538  goto cleanup;
2539  co_IntSendMessage(UserHMGetHandle(ParentWindow), WM_MDIREFRESHMENU, 0, 0);
2540  /* ShowWindow won't activate child windows */
2542  }
2543  }
2544 
2545  if (Class->atomClassName == gaGuiConsoleWndClass)
2546  {
2547  /* Count only console windows manually */
2549  }
2550 
2551  TRACE("co_UserCreateWindowEx(): Created window %p\n", hWnd);
2552  ret = Window;
2553 
2554 cleanup:
2555  if (!ret)
2556  {
2557  TRACE("co_UserCreateWindowEx(): Error Created window!\n");
2558  /* If the window was created, the class will be dereferenced by co_UserDestroyWindow */
2559  if (Window)
2561  else if (Class)
2562  IntDereferenceClass(Class, pti->pDeskInfo, pti->ppi);
2563  }
2564 
2565  if (pCsw) ExFreePoolWithTag(pCsw, TAG_HOOK);
2566  if (pCbtCreate) ExFreePoolWithTag(pCbtCreate, TAG_HOOK);
2567  if (pszName) UserHeapFree(pszName);
2568  if (pszClass) UserHeapFree(pszClass);
2569 
2570  if (Window)
2571  {
2573  }
2574  if (ParentWindow) UserDerefObjectCo(ParentWindow);
2575 
2576  // See CORE-13717, not setting error on success.
2577  if (ret)
2579 
2580  return ret;
2581 }
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define WS_THICKFRAME
Definition: pedump.c:630
#define HOOKID_TO_FLAG(HookId)
Definition: hook.h:5
#define HCBT_CREATEWND
Definition: winuser.h:58
POBJECT_TYPE ExWindowStationObjectType
Definition: win32k.c:21
long y
Definition: polytest.cpp:48
#define LAYOUT_RTL
Definition: wingdi.h:1371
#define ERROR_SUCCESS
Definition: deptool.c:10
NTSTATUS FASTCALL UserAttachThreadInput(PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach)
Definition: input.c:480
#define TAG_HOOK
Definition: tags.h:5
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define UserIsDesktopWindow(pWnd)
Definition: desktop.h:194
long x
Definition: polytest.cpp:48
#define SB_VERT
Definition: winuser.h:553
#define TRUE
Definition: types.h:120
HWND FASTCALL UserGetActiveWindow(VOID)
Definition: focus.c:1424
LPCREATESTRUCTW lpcs
Definition: winuser.h:2955
#define SB_HORZ
Definition: winuser.h:552
VOID FASTCALL IntNotifyWinEvent(DWORD Event, PWND pWnd, LONG idObject, LONG idChild, DWORD flags)
Definition: event.c:179
BOOLEAN FASTCALL co_WinPosSetWindowPos(PWND Window, HWND WndInsertAfter, INT x, INT y, INT cx, INT cy, UINT flags)
Definition: winpos.c:1721
PSERVERINFO gpsi
Definition: imm.c:17
#define OBJID_WINDOW
Definition: winable.h:15
HWND hWnd
Definition: settings.c:17
#define ICLS_DESKTOP
Definition: ntuser.h:908
#define WS_EX_LAYOUTRTL
Definition: winuser.h:390
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:27
#define HSHELL_WINDOWCREATED
Definition: winuser.h:1245
long bottom
Definition: polytest.cpp:53
static __inline BOOL UserHeapFree(PVOID lpMem)
Definition: usrheap.h:44
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
DWORD FASTCALL co_UserShowScrollBar(PWND, int, BOOL, BOOL)
Definition: scrollbar.c:933
#define HWND_TOP
Definition: winuser.h:1197
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:644
UINT_PTR WPARAM
Definition: windef.h:207
#define WNDS_SENDSIZEMOVEMSGS
Definition: ntuser.h:592
#define WS_CHILD
Definition: pedump.c:617
#define HWND_MESSAGE
Definition: winuser.h:1200
#define SWP_NOZORDER
Definition: winuser.h:1237
#define SW_SHOWMINIMIZED
Definition: winuser.h:765
#define WS_CLIPCHILDREN
Definition: pedump.c:619
ATOM gaGuiConsoleWndClass
Definition: ntuser.c:27
#define WM_NCCREATE
Definition: winuser.h:1670
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
struct _DESKTOP * rpdesk
Definition: win32.h:93
DWORD dwLayout
Definition: win32.h:275
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:801
PPROCESSINFO ppi
Definition: win32.h:89
HWND hwndInsertAfter
Definition: winuser.h:2956
long right
Definition: polytest.cpp:53
Definition: window.c:28
#define WS_EX_MDICHILD
Definition: winuser.h:394
#define L(x)
Definition: ntvdm.h:50
VOID FASTCALL IntLinkHwnd(PWND Wnd, HWND hWndPrev)
Definition: window.c:971
#define FALSE
Definition: types.h:117
#define WS_MINIMIZE
Definition: pedump.c:622
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:40
long top
Definition: polytest.cpp:53
#define CHILDID_SELF
Definition: winable.h:14
Definition: object.h:3
_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
Definition: ntuser.h:548
LONG_PTR LPARAM
Definition: windef.h:208
PWND FASTCALL co_GetDesktopWindow(PWND pWnd)
Definition: desktop.c:1366
#define WH_CBT
Definition: winuser.h:35
NTSTATUS NTAPI ObReferenceObjectByPointer(IN PVOID Object, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode)
Definition: obref.c:381
#define SW_SHOW
Definition: winuser.h:769
PWND FASTCALL IntCreateWindow(CREATESTRUCTW *Cs, PLARGE_STRING WindowName, PCLS Class, PWND ParentWindow, PWND OwnerWindow, PVOID acbiBuffer, PDESKTOP pdeskCreated, DWORD dwVer)
Definition: window.c:1787
long left
Definition: polytest.cpp:53
VOID FASTCALL co_IntUserManualGuiCheck(BOOL Create)
Definition: guicheck.c:77
UINT FASTCALL co_WinPosGetMinMaxInfo(PWND Window, POINT *MaxSize, POINT *MaxPos, POINT *MinTrack, POINT *MaxTrack)
Definition: winpos.c:932
BOOLEAN FASTCALL co_WinPosShowWindow(PWND Wnd, INT Cmd)
Definition: winpos.c:2491
BOOLEAN co_UserDestroyWindow(PVOID Object)
Definition: window.c:2836
HINSTANCE hInstance
Definition: winuser.h:2936
#define UserHMGetHandle(obj)
Definition: ntuser.h:222
#define ERROR_TLW_WITH_WSCHILD
Definition: winerror.h:887
#define HWND_BOTTOM
Definition: winuser.h:1195
#define TRACE(s)
Definition: solgame.cpp:4
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
#define ASSERT(a)
Definition: mode.c:44
#define SWP_NOACTIVATE
Definition: winuser.h:1232
#define ISITHOOKED(HookId)
Definition: hook.h:6
PCLS IntGetAndReferenceClass(PUNICODE_STRING ClassName, HINSTANCE hInstance, BOOL bDesktopThread)
Definition: class.c:1437
#define ObDereferenceObject
Definition: obfuncs.h:203
void FASTCALL co_WinPosSendSizeMove(PWND Wnd)
Definition: winpos.c:2306
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WNDS2_WMCREATEMSGPROCESSED
Definition: ntuser.h:653
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define SW_MINIMIZE
Definition: winuser.h:770
int Window
Definition: x11stubs.h:26
#define WS_HSCROLL
Definition: pedump.c:628
BOOL FASTCALL IntIsTopLevelWindow(PWND pWnd)
Definition: window.c:354
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
LRESULT APIENTRY co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
Definition: hook.c:1103
int ret
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1446
LPCWSTR lpszName
Definition: winuser.h:2944
#define SWP_FRAMECHANGED
Definition: winuser.h:1230
#define SWP_NOSIZE
Definition: winuser.h:1235
#define ERR(fmt,...)
Definition: debug.h:110
Definition: ntuser.h:672
FORCEINLINE VOID RECTL_vOffsetRect(_Inout_ RECTL *prcl, _In_ INT cx, _In_ INT cy)
Definition: rect.h:31
#define IntIsDesktopWindow(WndObj)
Definition: window.h:24
#define WM_MDIREFRESHMENU
Definition: winuser.h:1813
#define WNDS2_WIN31COMPAT
Definition: ntuser.h:632
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:126
#define WS_POPUP
Definition: pedump.c:616
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define WS_VSCROLL
Definition: pedump.c:627
#define SWP_SHOWWINDOW
Definition: winuser.h:1238
VOID co_IntShellHookNotify(WPARAM Message, WPARAM wParam, LPARAM lParam)
Definition: desktop.c:1692
UINT FASTCALL co_WinPosMinMaximize(PWND Wnd, UINT ShowFlag, RECT *NewPos)
Definition: winpos.c:2340
VOID IntDereferenceClass(IN OUT PCLS Class, IN PDESKTOPINFO Desktop, IN PPROCESSINFO pi)
Definition: class.c:815
#define WM_CREATE
Definition: winuser.h:1595
LPCWSTR lpszClass
Definition: winuser.h:2945
ULONG FASTCALL IntSetStyle(PWND pwnd, ULONG set_bits, ULONG clear_bits)
Definition: window.c:147
unsigned int ULONG
Definition: retypes.h:1
char * cleanup(char *str)
Definition: wpickclick.c:99
#define SWP_NOMOVE
Definition: winuser.h:1234
#define WS_EX_APPWINDOW
Definition: winuser.h:383
LONG_PTR LRESULT
Definition: windef.h:209
struct _DESKTOPINFO * pDeskInfo
Definition: win32.h:94
Arabic default style
Definition: afstyles.h:93
#define WS_VISIBLE
Definition: pedump.c:620
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define SW_MAXIMIZE
Definition: winuser.h:766
BOOL FASTCALL IntMsgCreateStructW(PWND, CREATESTRUCTW *, CREATESTRUCTW *, PVOID *, PVOID *)
Definition: message.c:597
static void IntSendParentNotify(PWND pWindow, UINT msg)
Definition: window.c:1678
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:28
void FASTCALL IntFixWindowCoordinates(CREATESTRUCTW *Cs, PWND ParentWindow, DWORD *dwShowMode)
Definition: window.c:1697
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define CS_PARENTDC
Definition: winuser.h:651
#define MAKEINTATOM(i)
Definition: winbase.h:1448
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1031
LRESULT FASTCALL co_WinPosGetNonClientSize(PWND Window, RECT *WindowRect, RECT *ClientRect)
Definition: winpos.c:2291
#define WS_MAXIMIZE
Definition: pedump.c:623
#define ERROR_CANNOT_FIND_WND_CLASS
Definition: winerror.h:888

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

◆ co_UserDestroyWindow()

BOOLEAN co_UserDestroyWindow ( PVOID  Object)

Definition at line 2836 of file window.c.

2837 {
2838  HWND hWnd;
2839  PWND pwndTemp;
2840  PTHREADINFO ti;
2841  MSG msg;
2842  PWND Window = Object;
2843 
2844  ASSERT_REFS_CO(Window); // FIXME: Temp HACK?
2845 
2846  hWnd = Window->head.h;
2848 
2849  TRACE("co_UserDestroyWindow(Window = 0x%p, hWnd = 0x%p)\n", Window, hWnd);
2850 
2851  /* Check for owner thread */
2852  if (Window->head.pti != ti)
2853  {
2854  /* Check if we are destroying the desktop window */
2855  if (! ((Window->head.rpdesk->dwDTFlags & DF_DESTROYED) && Window == Window->head.rpdesk->pDeskInfo->spwnd))
2856  {
2858  return FALSE;
2859  }
2860  }
2861 
2862  /* If window was created successfully and it is hooked */
2863  if ((Window->state2 & WNDS2_WMCREATEMSGPROCESSED))
2864  {
2866  {
2867  ERR("Destroy Window WH_CBT Call Hook return!\n");
2868  return FALSE;
2869  }
2870  }
2871 
2872  if (Window->pcls->atomClassName != gpsi->atomSysClass[ICLS_IME])
2873  {
2874  if ((Window->style & (WS_POPUP|WS_CHILD)) != WS_CHILD)
2875  {
2876  if (Window->spwndOwner)
2877  {
2878  //ERR("DestroyWindow Owner out.\n");
2879  UserAttachThreadInput(Window->head.pti, Window->spwndOwner->head.pti, FALSE);
2880  }
2881  }
2882  }
2883 
2884  /* Inform the parent */
2885  if (Window->style & WS_CHILD)
2886  {
2888  }
2889 
2890  if (!Window->spwndOwner && !IntGetParent(Window))
2891  {
2893  }
2894 
2895  /* Hide the window */
2896  if (Window->style & WS_VISIBLE)
2897  {
2898  if (Window->style & WS_CHILD)
2899  {
2900  /* Only child windows receive WM_SHOWWINDOW in DestroyWindow() */
2902  }
2903  else
2904  {
2906  }
2907  }
2908 
2909  /* Adjust last active */
2910  if ((pwndTemp = Window->spwndOwner))
2911  {
2912  while (pwndTemp->spwndOwner)
2913  pwndTemp = pwndTemp->spwndOwner;
2914 
2915  if (pwndTemp->spwndLastActive == Window)
2916  pwndTemp->spwndLastActive = Window->spwndOwner;
2917  }
2918 
2919  if (Window->spwndParent && IntIsWindow(UserHMGetHandle(Window)))
2920  {
2921  if ((Window->style & (WS_POPUP | WS_CHILD)) == WS_CHILD)
2922  {
2924  {
2925  //ERR("DestroyWindow Parent out.\n");
2926  UserAttachThreadInput(Window->head.pti, Window->spwndParent->head.pti, FALSE);
2927  }
2928  }
2929  }
2930 
2931  if (Window->head.pti->MessageQueue->spwndActive == Window)
2932  Window->head.pti->MessageQueue->spwndActive = NULL;
2933  if (Window->head.pti->MessageQueue->spwndFocus == Window)
2934  Window->head.pti->MessageQueue->spwndFocus = NULL;
2935  if (Window->head.pti->MessageQueue->spwndActivePrev == Window)
2936  Window->head.pti->MessageQueue->spwndActivePrev = NULL;
2937  if (Window->head.pti->MessageQueue->spwndCapture == Window)
2938  Window->head.pti->MessageQueue->spwndCapture = NULL;
2939 
2940  /*
2941  * Check if this window is the Shell's Desktop Window. If so set hShellWindow to NULL
2942  */
2943 
2944  if ((ti != NULL) && (ti->pDeskInfo != NULL))
2945  {
2946  if (ti->pDeskInfo->hShellWindow == hWnd)
2947  {
2948  ERR("Destroying the ShellWindow!\n");
2949  ti->pDeskInfo->hShellWindow = NULL;
2950  }
2951  }
2952 
2954 
2956  {
2957  return TRUE;
2958  }
2959 
2960  /* Recursively destroy owned windows */
2961  if (!(Window->style & WS_CHILD))
2962  {
2964  }
2965 
2966  /* Generate mouse move message for the next window */
2967  msg.message = WM_MOUSEMOVE;
2968  msg.wParam = UserGetMouseButtonsState();
2969  msg.lParam = MAKELPARAM(gpsi->ptCursor.x, gpsi->ptCursor.y);
2970  msg.pt = gpsi->ptCursor;
2972 
2973  IntNotifyWinEvent(EVENT_OBJECT_DESTROY, Window, OBJID_WINDOW, CHILDID_SELF, 0);
2974 
2975  /* Send destroy messages */
2977 
2978  // Destroy the default IME window if necessary
2979  if (IS_IMM_MODE() && !(ti->TIF_flags & TIF_INCLEANUP) &&
2980  ti->spwndDefaultIme && !IS_WND_IMELIKE(Window) && !(Window->state & WNDS_DESTROYED))
2981  {
2982  if (IS_WND_CHILD(Window))
2983  {
2986  }
2987  else
2988  {
2991  }
2992  }
2993 
2995  {
2996  return TRUE;
2997  }
2998 
2999  /* Destroy the window storage */
3001 
3002  return TRUE;
3003 }
#define IS_WND_CHILD(pWnd)
Definition: window.h:105
VOID FASTCALL co_MsqInsertMouseMessage(MSG *Msg, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook)
Definition: msgqueue.c:580
LRESULT co_UserFreeWindow(PWND Window, PPROCESSINFO ProcessData, PTHREADINFO ThreadData, BOOLEAN SendMessages)
Definition: window.c:569
NTSTATUS FASTCALL UserAttachThreadInput(PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach)
Definition: input.c:480
#define TRUE
Definition: types.h:120
#define SW_HIDE
Definition: winuser.h:762
#define ASSERT_REFS_CO(_obj_)
Definition: userfuncs.h:14
FLONG TIF_flags
Definition: win32.h:96
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
VOID FASTCALL IntNotifyWinEvent(DWORD Event, PWND pWnd, LONG idObject, LONG idChild, DWORD flags)
Definition: event.c:179
#define MAKELPARAM(l, h)
Definition: winuser.h:3988
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
BOOLEAN FASTCALL co_WinPosSetWindowPos(PWND Window, HWND WndInsertAfter, INT x, INT y, INT cx, INT cy, UINT flags)
Definition: winpos.c:1721
PSERVERINFO gpsi
Definition: imm.c:17
#define OBJID_WINDOW
Definition: winable.h:15
HWND hWnd
Definition: settings.c:17
UINT_PTR WPARAM
Definition: windef.h:207
#define WS_CHILD
Definition: pedump.c:617
#define SWP_NOZORDER
Definition: winuser.h:1237
WORD FASTCALL UserGetMouseButtonsState(VOID)
Definition: mouse.c:22
#define SWP_HIDEWINDOW
Definition: winuser.h:1231
Definition: window.c:28
#define FALSE
Definition: types.h:117
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define WOC_DELETE
Definition: winddi.h:1269
#define HCBT_DESTROYWND
Definition: winuser.h:59
#define CHILDID_SELF
Definition: winable.h:14
struct _WND * spwndOwner
Definition: ntuser.h:694
struct _WND * spwndDefaultIme
Definition: win32.h:132
#define WH_CBT
Definition: winuser.h:35
BOOL FASTCALL IntImeCanDestroyDefIME(PWND pImeWnd, PWND pwndTarget)
Definition: ime.c:2047
#define WM_DESTROY
Definition: winuser.h:1596
BOOL FASTCALL IntImeCanDestroyDefIMEforChild(PWND pImeWnd, PWND pwndTarget)
Definition: ime.c:2002
BOOLEAN FASTCALL co_WinPosShowWindow(PWND Wnd, INT Cmd)
Definition: winpos.c:2491
BOOLEAN co_UserDestroyWindow(PVOID Object)
Definition: window.c:2836
#define UserHMGetHandle(obj)
Definition: ntuser.h:222
#define TRACE(s)
Definition: solgame.cpp:4
static void IntSendDestroyMsg(HWND hWnd)
Definition: window.c:456
#define SWP_NOACTIVATE
Definition: winuser.h:1232
#define WNDS2_WMCREATEMSGPROCESSED
Definition: ntuser.h:653
BOOL FASTCALL IntIsWindow(HWND hWnd)
Definition: window.c:180
BOOL FASTCALL IntIsTopLevelWindow(PWND pWnd)
Definition: window.c:354
LRESULT APIENTRY co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
Definition: hook.c:1103
#define ICLS_IME
Definition: ntuser.h:906
#define IS_IMM_MODE()
Definition: precomp.h:117
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
#define HSHELL_WINDOWDESTROYED
Definition: winuser.h:1246
#define SWP_NOSIZE
Definition: winuser.h:1235
#define ERR(fmt,...)
Definition: debug.h:110
Definition: ntuser.h:672
VOID FASTCALL IntDestroyOwnedWindows(PWND Window)
Definition: window.c:2793
struct _WND * spwndLastActive
Definition: ntuser.h:718
#define DF_DESTROYED
Definition: desktop.h:50
PWND FASTCALL IntGetParent(PWND Wnd)
Definition: window.c:208
#define WS_POPUP
Definition: pedump.c:616
#define WM_MOUSEMOVE
Definition: winuser.h:1762
#define NULL
Definition: types.h:112
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
VOID FASTCALL IntEngWindowChanged(_In_ struct _WND *Window, _In_ FLONG flChanged)
VOID co_IntShellHookNotify(WPARAM Message, WPARAM wParam, LPARAM lParam)
Definition: desktop.c:1692
#define msg(x)
Definition: auth_time.c:54
#define IS_WND_IMELIKE(pWnd)
Definition: window.h:111
#define SWP_NOMOVE
Definition: winuser.h:1234
struct _DESKTOPINFO * pDeskInfo
Definition: win32.h:94
#define WS_VISIBLE
Definition: pedump.c:620
#define WNDS_DESTROYED
Definition: ntuser.h:619
static void IntSendParentNotify(PWND pWindow, UINT msg)
Definition: window.c:1678
#define TIF_INCLEANUP
Definition: ntuser.h:254
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:28
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1031

Referenced by co_UserCreateWindowEx(), 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 569 of file window.c.

573 {
574  HWND *Children;
575  HWND *ChildHandle;
576  PWND Child;
577  PMENU Menu;
578  BOOLEAN BelongsToThreadData;
579 
580  ASSERT(Window);
581 
582  if(Window->state2 & WNDS2_INDESTROY)
583  {
584  TRACE("Tried to call co_UserFreeWindow() twice\n");
585  return 0;
586  }
587  Window->state2 |= WNDS2_INDESTROY;
588  Window->style &= ~WS_VISIBLE;
589  Window->head.pti->cVisWindows--;
590 
591 
592  /* remove the window already at this point from the thread window list so we
593  don't get into trouble when destroying the thread windows while we're still
594  in co_UserFreeWindow() */
595  RemoveEntryList(&Window->ThreadListEntry);
596 
597  BelongsToThreadData = IntWndBelongsToThread(Window, ThreadData);
598 
600 
601  /* free child windows */
602  Children = IntWinListChildren(Window);
603  if (Children)
604  {
605  for (ChildHandle = Children; *ChildHandle; ++ChildHandle)
606  {
607  if ((Child = IntGetWindowObject(*ChildHandle)))
608  {
610  {
611  /* send WM_DESTROY messages to windows not belonging to the same thread */
613  }
614  else
615  co_UserFreeWindow(Child, ProcessData, ThreadData, SendMessages);
616 
618  }
619  }
621  }
622 
623  if (SendMessages)
624  {
625  /*
626  * Clear the update region to make sure no WM_PAINT messages will be
627  * generated for this window while processing the WM_NCDESTROY.
628  */
632  if (BelongsToThreadData)
634  }
635 
637 
639 
640  /* Unregister hot keys */
642 
643  /* flush the message queue */
645 
646  /* from now on no messages can be sent to this window anymore */
647  Window->state |= WNDS_DESTROYED;
648  Window->fnid |= FNID_FREED;
649 
650  /* don't remove the WINDOWSTATUS_DESTROYING bit */
651 
652  /* reset shell window handles */
653  if (ThreadData->rpdesk)
654  {
655  if (Window->head.h == ThreadData->rpdesk->rpwinstaParent->ShellWindow)
656  ThreadData->rpdesk->rpwinstaParent->ShellWindow = NULL;
657 
658  if (Window->head.h == ThreadData->rpdesk->rpwinstaParent->ShellListView)
659  ThreadData->rpdesk->rpwinstaParent->ShellListView = NULL;
660  }
661 
662  if (ThreadData->spwndDefaultIme &&
663  ThreadData->spwndDefaultIme->spwndOwner == Window)
664  {
665  ThreadData->spwndDefaultIme->spwndOwner = NULL;
666  }
667 
668  if (IS_IMM_MODE() && Window == ThreadData->spwndDefaultIme)
669  {
670  UserAssignmentUnlock((PVOID*)&(ThreadData->spwndDefaultIme));
671  }
672 
673  /* Fixes dialog test_focus breakage due to r66237. */
674  if (ThreadData->MessageQueue->spwndFocus == Window)
675  ThreadData->MessageQueue->spwndFocus = NULL;
676 
677  if (ThreadData->MessageQueue->spwndActive == Window)
678  ThreadData->MessageQueue->spwndActive = NULL;
679 
680  if (ThreadData->MessageQueue->spwndCapture == Window)
681  {
683  }
684 
686  if ( Window->hrgnUpdate != NULL || Window->state & WNDS_INTERNALPAINT )
687  {
688  MsqDecPaintCountQueue(Window->head.pti);
689  if (Window->hrgnUpdate > HRGN_WINDOW && GreIsHandleValid(Window->hrgnUpdate))
690  {
692  GreDeleteObject(Window->hrgnUpdate);
693  }
694  Window->hrgnUpdate = NULL;
695  Window->state &= ~WNDS_INTERNALPAINT;
696  }
697 
699  {
701  }
702 
703  if ( ((Window->style & (WS_CHILD|WS_POPUP)) != WS_CHILD) &&
704  Window->IDMenu &&
705  (Menu = UserGetMenuObject((HMENU)Window->IDMenu)))
706  {
707  TRACE("UFW: IDMenu %p\n",Window->IDMenu);
708  IntDestroyMenuObject(Menu, TRUE);
709  Window->IDMenu = 0;
710  }
711 
712  if (Window->SystemMenu
713  && (Menu = UserGetMenuObject(Window->SystemMenu)))
714  {
715  IntDestroyMenuObject(Menu, TRUE);
716  Window->SystemMenu = (HMENU)0;
717  }
718 
719  DceFreeWindowDCE(Window); /* Always do this to catch orphaned DCs */
720 
722 
723  if (Window->PropListItems)
724  {
726  TRACE("Window->PropListItems %lu\n",Window->PropListItems);
727  ASSERT(Window->PropListItems==0);
728  }
729 
732 
734 
735  if (Window->pcls->atomClassName == gaGuiConsoleWndClass)
736  {
737  /* Count only console windows manually */
739  }
740 
741  /* dereference the class */
742  NT_ASSERT(Window->head.pti != NULL);
744  Window->head.pti->pDeskInfo,
745  Window->head.pti->ppi);
746  Window->pcls = NULL;
747 
748  if (Window->hrgnClip)
749  {
751  GreDeleteObject(Window->hrgnClip);
752  Window->hrgnClip = NULL;
753  }
754  Window->head.pti->cWindows--;
755 
756 // ASSERT(Window != NULL);
757  UserFreeWindowInfo(Window->head.pti, Window);
758 
761 
762  return 0;
763 }
#define RDW_NOINTERNALPAINT
Definition: winuser.h:1207
#define RDW_NOCHILDREN
Definition: winuser.h:1212
BOOL FASTCALL UserDeleteObject(HANDLE h, HANDLE_TYPE type)
Definition: object.c:717
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1158
LRESULT co_UserFreeWindow(PWND Window, PPROCESSINFO ProcessData, PTHREADINFO ThreadData, BOOLEAN SendMessages)
Definition: window.c:569
BOOL NTAPI GreIsHandleValid(HGDIOBJ hobj)
Definition: gdiobj.c:1146
VOID FASTCALL IntUnlinkWindow(PWND Wnd)
Definition: window.c:1341
BOOL FASTCALL IntReleaseCapture(VOID)
Definition: focus.c:1525
#define IntWndBelongsToThread(WndObj, W32Thread)
Definition: window.h:31
#define TRUE
Definition: types.h:120
#define WNDS_SENDNCPAINT
Definition: ntuser.h:599
BOOL FASTCALL IntDestroyMenuObject(PMENU Menu, BOOL bRecurse)
Definition: menu.c:317
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:644
#define WS_CHILD
Definition: pedump.c:617
ATOM gaGuiConsoleWndClass
Definition: ntuser.c:27
PWND FASTCALL IntGetWindowObject(HWND hWnd)
Definition: window.c:73
FORCEINLINE PMENU UserGetMenuObject(HMENU hMenu)
Definition: userfuncs.h:4
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
BOOL FASTCALL DestroyTimersForWindow(PTHREADINFO pti, PWND Window)
Definition: timer.c:522
Definition: window.c:28
#define FALSE
Definition: types.h:117
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
Definition: wdffdo.h:533
void FASTCALL DceFreeWindowDCE(PWND)
Definition: windc.c:686
unsigned char BOOLEAN
#define HRGN_WINDOW
Definition: ntuser.h:344
VOID FASTCALL UserClipboardFreeWindow(PWND pWindow)
Definition: clipboard.c:414
VOID FASTCALL co_IntUserManualGuiCheck(BOOL Create)
Definition: guicheck.c:77
#define UserHMGetHandle(obj)
Definition: ntuser.h:222
#define TRACE(s)
Definition: solgame.cpp:4
BOOL IntDeRegisterShellHookWindow(HWND hWnd)
Definition: desktop.c:1784
#define ASSERT(a)
Definition: mode.c:44
VOID FASTCALL UserRemoveWindowProps(_In_ PWND Window)
Definition: prop.c:115
BOOL FASTCALL IntGdiSetRegionOwner(HRGN hRgn, DWORD OwnerMask)
Definition: region.c:2478
#define WM_NCDESTROY
Definition: winuser.h:1671
VOID FASTCALL MsqDecPaintCountQueue(PTHREADINFO pti)
Definition: msgqueue.c:508
#define FNID_FREED
Definition: ntuser.h:879
#define RDW_VALIDATE
Definition: winuser.h:1208
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1446
#define IS_IMM_MODE()
Definition: precomp.h:117
#define RDW_NOERASE
Definition: winuser.h:1205
HWND *FASTCALL IntWinListChildren(PWND Window)
Definition: window.c:278
#define GDI_OBJ_HMGR_POWNED
Definition: ntgdihdl.h:117
#define RDW_NOFRAME
Definition: winuser.h:1206
Definition: ntuser.h:672
BOOL FASTCALL co_UserRedrawWindow(PWND Window, const RECTL *UpdateRect, PREGION UpdateRgn, ULONG Flags)
Definition: painting.c:888
BOOL FASTCALL IntDestroyScrollBars(PWND)
Definition: scrollbar.c:880
#define WS_POPUP
Definition: pedump.c:616
#define NULL
Definition: types.h:112
#define WNDS_INTERNALPAINT
Definition: ntuser.h:600
#define WNDS_SENDERASEBACKGROUND
Definition: ntuser.h:597
PVOID FASTCALL UserAssignmentUnlock(PVOID *ppvObj)
Definition: object.c:861
VOID IntDereferenceClass(IN OUT PCLS Class, IN PDESKTOPINFO Desktop, IN PPROCESSINFO pi)
Definition: class.c:815
#define USERTAG_WINDOWLIST
Definition: tags.h:298
#define WS_VISIBLE
Definition: pedump.c:620
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define WNDS_DESTROYED
Definition: ntuser.h:619
VOID APIENTRY MsqRemoveWindowMessagesFromQueue(PWND Window)
Definition: msgqueue.c:798
#define WNDS2_INDESTROY
Definition: ntuser.h:631
VOID FASTCALL UnregisterWindowHotKeys(PWND pWnd)
Definition: hotkey.c:91
static VOID UserFreeWindowInfo(PTHREADINFO ti, PWND Wnd)
Definition: window.c:536
VOID FASTCALL UserReferenceObject(PVOID obj)
Definition: object.c:731
#define NT_ASSERT
Definition: rtlfuncs.h:3310
BOOL FASTCALL UserMarkObjectDestroy(PVOID Object)
Definition: object.c:621

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 
1293  if (hWndChild == IntGetDesktopWindow())
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 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:27
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:644
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:40
Definition: object.h:3
#define IntIsBroadcastHwnd(hWnd)
Definition: window.h:27
#define ERR(fmt,...)
Definition: debug.h:110
Definition: ntuser.h:672
HWND FASTCALL IntGetDesktopWindow(VOID)
Definition: desktop.c:1374
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:126
#define NULL
Definition: types.h:112
PWND FASTCALL co_IntSetParent(PWND Wnd, PWND WndNewParent)
Definition: window.c:1143
HWND hWndChild[NUM_TABS]
Definition: main.h:75
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:28

Referenced by co_IntSetWindowLongPtr(), and NtUserSetParent().

◆ co_UserSetWindowLong()

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

Definition at line 4005 of file window.c.

4006 {
4007  return (LONG)co_IntSetWindowLongPtr(hWnd, Index, NewValue, Ansi, sizeof(LONG), FALSE);
4008 }
HWND hWnd
Definition: settings.c:17
#define FALSE
Definition: types.h:117
static LONG_PTR co_IntSetWindowLongPtr(HWND hWnd, DWORD Index, LONG_PTR NewValue, BOOL Ansi, ULONG Size, BOOL bAlter)
Definition: window.c:3810
long LONG
Definition: pedump.c:60
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by DesktopWindowProc(), and NtUserSetWindowWord().

◆ co_UserSetWindowLongPtr()

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

Definition at line 4011 of file window.c.

4012 {
4013  return co_IntSetWindowLongPtr(hWnd, Index, NewValue, Ansi, sizeof(LONG_PTR), FALSE);
4014 }
HWND hWnd
Definition: settings.c:17
#define FALSE
Definition: types.h:117
static LONG_PTR co_IntSetWindowLongPtr(HWND hWnd, DWORD Index, LONG_PTR NewValue, BOOL Ansi, ULONG Size, BOOL bAlter)
Definition: window.c:3810
_In_ WDFCOLLECTION _In_ ULONG Index
__int3264 LONG_PTR
Definition: mstsclib_h.h:276

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UserWnd  )

◆ DefSetText()

BOOL APIENTRY DefSetText ( PWND  Wnd,
PCWSTR  WindowText 
)

Definition at line 4369 of file window.c.

4370 {
4372  BOOL Ret = FALSE;
4373 
4374  RtlInitUnicodeString(&UnicodeString, WindowText);
4375 
4376  if (UnicodeString.Length != 0)
4377  {
4378  if (Wnd->strName.MaximumLength > 0 &&
4379  UnicodeString.Length <= Wnd->strName.MaximumLength - sizeof(UNICODE_NULL))
4380  {
4381  ASSERT(Wnd->strName.Buffer != NULL);
4382 
4383  Wnd->strName.Length = UnicodeString.Length;
4384  Wnd->strName.Buffer[UnicodeString.Length / sizeof(WCHAR)] = L'\0';
4386  UnicodeString.Buffer,
4387  UnicodeString.Length);
4388  }
4389  else
4390  {
4391  PWCHAR buf;
4392  Wnd->strName.MaximumLength = Wnd->strName.Length = 0;
4393  buf = Wnd->strName.Buffer;
4394  Wnd->strName.Buffer = NULL;
4395  if (buf != NULL)
4396  {
4397  DesktopHeapFree(Wnd->head.rpdesk, buf);
4398  }
4399 
4401  UnicodeString.Length + sizeof(UNICODE_NULL));
4402  if (Wnd->strName.Buffer != NULL)
4403  {
4404  Wnd->strName.Buffer[UnicodeString.Length / sizeof(WCHAR)] = L'\0';
4406  UnicodeString.Buffer,
4407  UnicodeString.Length);
4408  Wnd->strName.MaximumLength = UnicodeString.Length + sizeof(UNICODE_NULL);
4409  Wnd->strName.Length = UnicodeString.Length;
4410  }
4411  else
4412  {
4414  goto Exit;
4415  }
4416  }
4417  }
4418  else
4419  {
4420  Wnd->strName.Length = 0;
4421  if (Wnd->strName.Buffer != NULL)
4422  Wnd->strName.Buffer[0] = L'\0';
4423  }
4424 
4425  // FIXME: HAX! Windows does not do this in here!
4426  // In User32, these are called after: NotifyWinEvent EVENT_OBJECT_NAMECHANGE than
4427  // RepaintButton, StaticRepaint, NtUserCallHwndLock HWNDLOCK_ROUTINE_REDRAWFRAMEANDHOOK, etc.
4428  /* Send shell notifications */
4429  if (!Wnd->spwndOwner && !IntGetParent(Wnd))
4430  {
4431  co_IntShellHookNotify(HSHELL_REDRAW, (WPARAM) UserHMGetHandle(Wnd), FALSE); // FIXME Flashing?
4432  }
4433 
4434  Ret = TRUE;
4435 Exit:
4437  return Ret;
4438 }
struct _DESKTOP * rpdesk
Definition: ntuser.h:186
#define TRUE
Definition: types.h:120
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
UINT_PTR WPARAM
Definition: windef.h:207
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_opt_ PCUNICODE_STRING UnicodeString
Definition: wdfstring.h:64
uint16_t * PWCHAR
Definition: typedefs.h:56
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define L(x)
Definition: ntvdm.h:50
static __inline PVOID DesktopHeapAlloc(IN PDESKTOP Desktop, IN SIZE_T Bytes)
Definition: desktop.h:204
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
unsigned int BOOL
Definition: ntddk_ex.h:94
struct _WND * spwndOwner
Definition: ntuser.h:694
THRDESKHEAD head
Definition: ntuser.h:674
LARGE_UNICODE_STRING strName
Definition: ntuser.h:715
#define UserHMGetHandle(obj)
Definition: ntuser.h:222
#define ASSERT(a)
Definition: mode.c:44
__wchar_t WCHAR
Definition: xmlstorage.h:180
static void Exit(void)
Definition: sock.c:1331
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
PWND FASTCALL IntGetParent(PWND Wnd)
Definition: window.c:208
#define NULL
Definition: types.h:112
VOID co_IntShellHookNotify(WPARAM Message, WPARAM wParam, LPARAM lParam)
Definition: desktop.c:1692
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
static __inline BOOL DesktopHeapFree(IN PDESKTOP Desktop, IN PVOID lpMem)
Definition: desktop.h:215
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:28

◆ 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 }
#define HWND_TERMINATOR
Definition: window.h:82
struct tagWINDOWLIST * pNextList
Definition: window.h:86
HANDLE HWND
Definition: compat.h:19
struct tagWINDOWLIST WINDOWLIST
#define WL_IS_BAD(pwl)
Definition: window.h:96
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:801
HWND * phwndLast
Definition: window.h:87
#define INITIAL_COUNT
PWINDOWLIST gpwlCache
Definition: window.c:17
HWND ahwnd[ANYSIZE_ARRAY]
Definition: window.h:90
unsigned long DWORD
Definition: ntddk_ex.h:95
PWINDOWLIST FASTCALL IntPopulateHwndList(PWINDOWLIST pwl, PWND pwnd, DWORD dwFlags)
Definition: window.c:1380
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
HWND * phwndEnd
Definition: window.h:88
PWINDOWLIST gpwlList
Definition: window.c:16
#define NULL
Definition: types.h:112
#define USERTAG_WINDOWLIST
Definition: tags.h:298
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
PTHREADINFO pti
Definition: window.h:89

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

◆ IntCheckFrameEdge()

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

Definition at line 3799 of file window.c.

3800 {
3802  return TRUE;
3803  else if (!(ExStyle & WS_EX_STATICEDGE) && (Style & (WS_DLGFRAME | WS_THICKFRAME)))
3804  return TRUE;
3805  else
3806  return FALSE;
3807 }
#define WS_THICKFRAME
Definition: pedump.c:630
#define TRUE
Definition: types.h:120
#define WS_DLGFRAME
Definition: pedump.c:626
#define FALSE
Definition: types.h:117
#define WS_EX_DLGMODALFRAME
Definition: pedump.c:645
const DWORD Style
Definition: appswitch.c:71
#define WS_EX_STATICEDGE
Definition: winuser.h:403
const DWORD ExStyle
Definition: appswitch.c:72

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) )
1813  Cs->dwExStyle |= WS_EX_LAYOUTRTL;
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  {
1826  Cs->dwExStyle |= WS_EX_LAYOUTRTL;
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))))
1836  Cs->dwExStyle |= WS_EX_WINDOWEDGE;
1837  else
1838  Cs->dwExStyle &= ~WS_EX_WINDOWEDGE;
1839 
1840  /* Is it a unicode window? */
1841  bUnicodeWindow =!(Cs->dwExStyle & WS_EX_SETANSICREATOR);
1843 
1844  /* Allocate the new window */
1846  pdeskCreated ? pdeskCreated : pti->rpdesk,
1847  pti,
1848  (PHANDLE)&hWnd,
1849  TYPE_WINDOW,
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  pWnd->spwndOwner = 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  {
2037  pWnd->strName.Buffer = DesktopHeapAlloc(pWnd->head.rpdesk,
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  /* Create the IME window for pWnd */
2051  if (IS_IMM_MODE() && !(pti->spwndDefaultIme) && IntWantImeWindow(pWnd))
2052  {
2053  PWND pwndDefaultIme = co_IntCreateDefaultImeWindow(pWnd, pWnd->hModule);
2054  UserAssignmentLock((PVOID*)&(pti->spwndDefaultIme), pwndDefaultIme);
2055 
2056  if (pwndDefaultIme && (pti->pClientInfo->CI_flags & CI_IMMACTIVATE))
2057  {
2059  HKL hKL;
2060 
2061  UserRefObjectCo(pwndDefaultIme, &Ref);
2062 
2063  hKL = pti->KeyboardLayout->hkl;
2065  IMS_ACTIVATELAYOUT, (LPARAM)hKL);
2066  pti->pClientInfo->CI_flags &= ~CI_IMMACTIVATE;
2067 
2068  UserDerefObjectCo(pwndDefaultIme);
2069  }
2070  }
2071 
2072  /* Correct the window style. */
2073  if ((pWnd->style & (WS_CHILD | WS_POPUP)) != WS_CHILD)
2074  {
2075  pWnd->style |= WS_CLIPSIBLINGS;
2076  if (!(pWnd->style & WS_POPUP))
2077  {
2078  pWnd->style |= WS_CAPTION;
2079  }
2080  }
2081 
2082  /* WS_EX_WINDOWEDGE depends on some other styles */
2083  if (pWnd->ExStyle & WS_EX_DLGMODALFRAME)
2084  pWnd->ExStyle |= WS_EX_WINDOWEDGE;
2085  else if (pWnd->style & (WS_DLGFRAME | WS_THICKFRAME))
2086  {
2087  if (!((pWnd->ExStyle & WS_EX_STATICEDGE) &&
2088  (pWnd->style & (WS_CHILD | WS_POPUP))))
2089  pWnd->ExStyle |= WS_EX_WINDOWEDGE;
2090  }
2091  else
2092  pWnd->ExStyle &= ~WS_EX_WINDOWEDGE;
2093 
2094  if (!(pWnd->style & (WS_CHILD | WS_POPUP)))
2095  pWnd->state |= WNDS_SENDSIZEMOVEMSGS;
2096 
2097  /* Set the window menu */
2098  if ((Cs->style & (WS_CHILD | WS_POPUP)) != WS_CHILD)
2099  {
2100  if (Cs->hMenu)
2101  {
2102  IntSetMenu(pWnd, Cs->hMenu, &MenuChanged);
2103  }
2104  else if (pWnd->pcls->lpszMenuName) // Take it from the parent.
2105  {
2106  UNICODE_STRING MenuName;
2107  HMENU hMenu;
2108 
2109  if (IS_INTRESOURCE(pWnd->pcls->lpszMenuName))
2110  {
2111  MenuName.Length = 0;
2112  MenuName.MaximumLength = 0;
2113  MenuName.Buffer = pWnd->pcls->lpszMenuName;
2114  }
2115  else
2116  {
2117  RtlInitUnicodeString( &MenuName, pWnd->pcls->lpszMenuName);
2118  }
2119  hMenu = co_IntCallLoadMenu( pWnd->pcls->hModule, &MenuName);
2120  if (hMenu) IntSetMenu(pWnd, hMenu, &MenuChanged);
2121  }
2122  }
2123  else // Not a child
2124  pWnd->IDMenu = (UINT_PTR)Cs->hMenu;
2125 
2126 
2127  if ( ParentWindow &&
2128  ParentWindow != ParentWindow->head.rpdesk->spwndMessage &&
2129  ParentWindow != ParentWindow->head.rpdesk->pDeskInfo->spwnd )
2130  {
2131  PWND Owner = IntGetNonChildAncestor(ParentWindow);
2132 
2133  if (!IntValidateOwnerDepth(pWnd, Owner))
2134  {
2136  goto Error;
2137  }
2138  if ( pWnd->spwndOwner &&
2139  pWnd->spwndOwner->ExStyle & WS_EX_TOPMOST )
2140  {
2141  pWnd->ExStyle |= WS_EX_TOPMOST;
2142  }
2143  if ( pWnd->spwndOwner &&
2144  Class->atomClassName != gpsi->atomSysClass[ICLS_IME] &&
2145  pti != pWnd->spwndOwner->head.pti)
2146  {
2147  //ERR("CreateWindow Owner in.\n");
2148  UserAttachThreadInput(pti, pWnd->spwndOwner->head.pti, TRUE);
2149  }
2150  }
2151 
2152  /* Insert the window into the thread's window list. */
2154 
2155  /* Handle "CS_CLASSDC", it is tested first. */
2156  if ( (pWnd->pcls->style & CS_CLASSDC) && !(pWnd->pcls->pdce) )
2157  { /* One DCE per class to have CLASS. */
2158  pWnd->pcls->pdce = DceAllocDCE( pWnd, DCE_CLASS_DC );
2159  }
2160  else if ( pWnd->pcls->style & CS_OWNDC)
2161  { /* Allocate a DCE for this window. */
2162  DceAllocDCE(pWnd, DCE_WINDOW_DC);
2163  }
2164 
2165  return pWnd;
2166 
2167 AllocError:
2168  ERR("IntCreateWindow Allocation Error.\n");
2170 Error:
2171  if(pWnd)
2172  UserDereferenceObject(pWnd);
2173  return NULL;
2174 }
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
static const WCHAR Class[]
Definition: cfgmgr.c:42
unsigned __int3264 UINT_PTR
Definition: activex.cpp:275
#define WS_THICKFRAME
Definition: pedump.c:630
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
DWORD ExStyle
Definition: ntuser.h:683
static HICON
Definition: imagelist.c:84
UINT HideFocus
Definition: ntuser.h:737
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define IMAGE_ICON
Definition: winuser.h:212
#define ICLS_MDICLIENT
Definition: ntuser.h:897
LIST_ENTRY ThreadListEntry
Definition: ntuser.h:743
WNDPROC pfnClientPrevious
Definition: ntuser.h:535
struct _DESKTOP * rpdesk
Definition: ntuser.h:186
struct tagIMC * spDefaultImc
Definition: win32.h:133
#define LAYOUT_RTL
Definition: wingdi.h:1371
ULONG PropListItems
Definition: ntuser.h:703
NTSTATUS FASTCALL UserAttachThreadInput(PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach)
Definition: input.c:480
PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon)
Definition: cursoricon.c:200
USHORT MaximumLength
Definition: env_spec_w32.h:370
PVOID FASTCALL UserAssignmentLock(PVOID *ppvObj, PVOID pvNew)
Definition: object.c:840
PVOID Buffer
Definition: ntuser.h:94
#define GETPFNCLIENTW(fnid)
Definition: ntuser.h:885
#define TRUE
Definition: types.h:120
#define CURSORF_FROMRESOURCE
Definition: ntuser.h:1166
LIST_ENTRY WindowListHead
Definition: win32.h:156
HINSTANCE hModule
Definition: ntuser.h:687
static __inline BOOL IsCallProcHandle(IN WNDPROC lpWndProc)
Definition: class.h:13
WNDPROC lpfnWndProc
Definition: ntuser.h:697
BOOL FASTCALL IntValidateOwnerDepth(PWND Wnd, PWND Owner)
Definition: window.c:362
HINSTANCE hModule
Definition: ntuser.h:567
#define WINVER_WIN2K
Definition: window.h:55
#define ICLS_EDIT
Definition: ntuser.h:892
PSERVERINFO gpsi
Definition: imm.c:17
LIST_ENTRY PropListHead
Definition: ntuser.h:702
HWND hWnd
Definition: settings.c:17
#define WS_EX_LAYOUTRTL
Definition: winuser.h:390
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:27
struct _WND WND
#define WS_DLGFRAME
Definition: pedump.c:626
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define SM_CYSMICON
Definition: winuser.h:1007
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:644
#define WNDS_SENDSIZEMOVEMSGS
Definition: ntuser.h:592
#define WS_CHILD
Definition: pedump.c:617
#define CS_OWNDC
Definition: winuser.h:650
HIMC hImc
Definition: ntuser.h:719
#define InsertTailList(ListHead, Entry)
if(dx==0 &&dy==0)
Definition: linetemp.h:174
struct _DESKTOP * rpdesk
Definition: win32.h:93
#define WINVER_WINNT4
Definition: window.h:56
#define ICLS_DIALOG
Definition: ntuser.h:909
PVOID FASTCALL UserCreateObject(PUSER_HANDLE_TABLE ht, PDESKTOP pDesktop, PTHREADINFO pti, HANDLE *h, HANDLE_TYPE type, ULONG size)
Definition: object.c:568
PWND FASTCALL co_IntCreateDefaultImeWindow(PWND pwndTarget, HINSTANCE hInst)
Definition: ime.c:1939
DWORD dwLayout
Definition: win32.h:275
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:801
PPROCESSINFO ppi
Definition: win32.h:89
PCALLPROCDATA CreateCallProc(IN PDESKTOP Desktop, IN WNDPROC WndProc, IN BOOL Unicode, IN PPROCESSINFO pi)
Definition: callproc.c:29
WNDPROC lpfnWndProc
Definition: ntuser.h:564
PTHREADINFO gptiDesktopThread
Definition: desktop.c:37
ULONG cbwndExtra
Definition: ntuser.h:717
#define ICLS_LISTBOX
Definition: ntuser.h:894
DWORD CSF_flags
Definition: ntuser.h:556
#define CSF_CACHEDSMICON
Definition: ntuser.h:545
#define L(x)
Definition: ntvdm.h:50
UINT style
Definition: ntuser.h:563
static __inline PVOID DesktopHeapAlloc(IN PDESKTOP Desktop, IN SIZE_T Bytes)
Definition: desktop.h:204
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
DWORD fnid
Definition: ntuser.h:688
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CURSORF_LRSHARED
Definition: ntuser.h:1168
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:40
HMENU APIENTRY co_IntCallLoadMenu(HINSTANCE hModule, PUNICODE_STRING pMenuName)
Definition: callback.c:903
#define FNID_DIALOG
Definition: ntuser.h:848
struct _WND * spwndOwner
Definition: ntuser.h:694
THRDESKHEAD head
Definition: ntuser.h:674
Definition: object.h:3
BOOL FASTCALL IntWantImeWindow(PWND pwndTarget)
Definition: ime.c:1899
#define WS_EX_DLGMODALFRAME
Definition: pedump.c:645
LONG_PTR LPARAM
Definition: windef.h:208
struct _WND * spwndDefaultIme
Definition: win32.h:132
PVOID pdce
Definition: ntuser.h:555
#define WM_IME_SYSTEM
Definition: undocuser.h:59
LARGE_UNICODE_STRING strName
Definition: ntuser.h:715
#define ICLS_STATIC
Definition: ntuser.h:893
UINT HideAccel
Definition: ntuser.h:738
HANDLE FASTCALL co_IntCopyImage(HANDLE hnd, UINT type, INT desiredx, INT desiredy, UINT flags)
Definition: callback.c:985
LONG NTAPI UserGetSystemMetrics(ULONG Index)
Definition: metric.c:194
HINSTANCE hInstance
Definition: winuser.h:2936
#define UserHMGetHandle(obj)
Definition: ntuser.h:222
#define WS_CAPTION
Definition: pedump.c:624
UINT_PTR IDMenu
Definition: ntuser.h:710
#define TRACE(s)
Definition: solgame.cpp:4
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
__wchar_t WCHAR
Definition: xmlstorage.h:180
ULONG Length
Definition: ntuser.h:91
DWORD fnid
Definition: ntuser.h:553
#define WS_EX_NOINHERITLAYOUT
Definition: winuser.h:396
BOOL Error
Definition: chkdsk.c:66
struct _CLIENTINFO * pClientInfo
Definition: win32.h:95
#define SM_CXSMICON
Definition: winuser.h:1006
#define IMS_ACTIVATELAYOUT
Definition: immdev.h:30
#define CSF_SERVERSIDEPROC
Definition: ntuser.h:539
#define WNDS2_WIN50COMPAT
Definition: ntuser.h:634
#define ICLS_IME
Definition: ntuser.h:906
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1446
#define IS_IMM_MODE()
Definition: precomp.h:117
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:454
#define GETPFNCLIENTA(fnid)
Definition: ntuser.h:883
#define WS_EX_TOPMOST
Definition: pedump.c:647
#define CSF_ANSIPROC
Definition: ntuser.h:540
UINT_PTR HKL
Definition: msctf.idl:101
#define ICLS_COMBOLBOX
Definition: ntuser.h:898
struct tagKL * KeyboardLayout
Definition: win32.h:91
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:37
INT cbwndExtra
Definition: ntuser.h:566
VOID UserAddCallProcToClass(IN OUT PCLS Class, IN PCALLPROCDATA CallProc)
Definition: class.c:423
PWSTR lpszMenuName
Definition: ntuser.h:571
#define CS_CLASSDC
Definition: winuser.h:645
#define WS_EX_SETANSICREATOR
Definition: undocuser.h:28
#define ERR(fmt,...)
Definition: debug.h:110
Definition: ntuser.h:672
#define FNID_GHOST
Definition: ntuser.h:854
#define LR_COPYFROMRESOURCE
Definition: winuser.h:1093
struct _WND * PWND
PVOID UserGetObject(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type)
Definition: object.c:495
struct _WND * spwndLastActive
Definition: ntuser.h:718
#define CI_IMMACTIVATE
Definition: ntuser.h:297
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define WNDS_ANSIWINDOWPROC
Definition: ntuser.h:607
#define FNID_BUTTON
Definition: ntuser.h:845
DWORD state
Definition: ntuser.h:680
#define WNDS2_WIN31COMPAT
Definition: ntuser.h:632
#define WS_POPUP
Definition: pedump.c:616
_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:1583
#define NULL
Definition: types.h:112
#define WINVER_WIN31
Definition: window.h:57
PWND FASTCALL IntGetNonChildAncestor(PWND pWnd)
Definition: window.c:346
struct _WND * spwndParent
Definition: ntuser.h:692
DWORD state2
Definition: ntuser.h:681
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define ICLS_BUTTON
Definition: ntuser.h:891
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
PVOID pActCtx
Definition: ntuser.h:721
struct _WND::@4898 InternalPos
#define WNDS2_WIN40COMPAT
Definition: ntuser.h:633
PDCE FASTCALL DceAllocDCE(PWND Window, DCE_TYPE Type)
Definition: windc.c:86
#define WS_VISIBLE
Definition: pedump.c:620
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
#define WNDS_ANSICREATOR
Definition: ntuser.h:617
BOOL FASTCALL IntSetMenu(PWND Wnd, HMENU Menu, BOOL *Changed)
Definition: menu.c:5457
#define WNDS_SERVERSIDEWINDOWPROC
Definition: ntuser.h:606
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define WS_EX_STATICEDGE
Definition: winuser.h:403
UINT Unicode
Definition: ntuser.h:735
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:28
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1031
PCLS pcls
Definition: ntuser.h:699
DWORD style
Definition: ntuser.h:685
#define ICLS_COMBOBOX
Definition: ntuser.h:896

Referenced by co_UserCreateWindowEx(), and IntCreateDesktop().

◆ IntDestroyOwnedWindows()

VOID FASTCALL IntDestroyOwnedWindows ( PWND  Window)

Definition at line 2793 of file window.c.

2794 {
2795  HWND* List;
2796  HWND* phWnd;
2797  PWND pWnd;
2798  PTHREADINFO pti = Window->head.pti;
2800 
2802  if (!List)
2803  return;
2804 
2805  for (phWnd = List; *phWnd; ++phWnd)
2806  {
2807  pWnd = ValidateHwndNoErr(*phWnd);
2808  if (pWnd == NULL)
2809  continue;
2810  ASSERT(pWnd->spwndOwner == Window);
2811  ASSERT(pWnd != Window);
2812 
2813  if (IS_IMM_MODE() && !(pti->TIF_flags & TIF_INCLEANUP) &&
2814  pWnd == pti->spwndDefaultIme)
2815  {
2816  continue;
2817  }
2818 
2819  pWnd->spwndOwner = NULL;
2821  {
2822  UserRefObjectCo(pWnd, &Ref); // Temp HACK?
2823  co_UserDestroyWindow(pWnd);
2824  UserDerefObjectCo(pWnd); // Temp HACK?
2825  }
2826  else
2827  {
2828  ERR("IntWndBelongsToThread(0x%p) is FALSE, ignoring.\n", pWnd);
2829  }
2830  }
2831 
2833 }
PWND FASTCALL ValidateHwndNoErr(HWND hWnd)
Definition: window.c:118
#define IntWndBelongsToThread(WndObj, W32Thread)
Definition: window.h:31
FLONG TIF_flags
Definition: win32.h:96
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:27
HWND *FASTCALL IntWinListOwnedPopups(PWND Window)
Definition: window.c:310
Definition: window.c:28
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:40
struct _WND * spwndOwner
Definition: ntuser.h:694
Definition: object.h:3
struct _WND * spwndDefaultIme
Definition: win32.h:132
BOOLEAN co_UserDestroyWindow(PVOID Object)
Definition: window.c:2836
#define ASSERT(a)
Definition: mode.c:44
#define IS_IMM_MODE()
Definition: precomp.h:117
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
#define ERR(fmt,...)
Definition: debug.h:110
Definition: ntuser.h:672
#define NULL
Definition: types.h:112
#define USERTAG_WINDOWLIST
Definition: tags.h:298
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define TIF_INCLEANUP
Definition: ntuser.h:254

Referenced by co_UserDestroyWindow().

◆ IntEnableWindow()

BOOL FASTCALL IntEnableWindow ( HWND  hWnd,
BOOL  bEnable 
)

Definition at line 224 of file window.c.

225 {
226  BOOL Update;
227  PWND pWnd;
228  UINT bIsDisabled;
229 
230  if(!(pWnd = UserGetWindowObject(hWnd)))
231  {
232  return FALSE;
233  }
234 
235  /* check if updating is needed */
236  bIsDisabled = !!(pWnd->style & WS_DISABLED);
237  Update = bIsDisabled;
238 
239  if (bEnable)
240  {
241  IntSetStyle( pWnd, 0, WS_DISABLED );
242  }
243  else
244  {
245  Update = !bIsDisabled;
246 
248 
249  /* Remove keyboard focus from that window if it had focus */
250  if (hWnd == IntGetThreadFocusWindow())
251  {
252  TRACE("IntEnableWindow SF NULL\n");
254  }
255  IntSetStyle( pWnd, WS_DISABLED, 0 );
256  }
257 
258  if (Update)
259  {
260  IntNotifyWinEvent(EVENT_OBJECT_STATECHANGE, pWnd, OBJID_WINDOW, CHILDID_SELF, 0);
262  }
263  // Return nonzero if it was disabled, or zero if it wasn't:
264  return bIsDisabled;
265 }
#define WS_DISABLED
Definition: pedump.c:621
HWND FASTCALL IntGetThreadFocusWindow(VOID)
Definition: focus.c:41
HWND FASTCALL co_UserSetFocus(PWND Window)
Definition: focus.c:1309
VOID FASTCALL IntNotifyWinEvent(DWORD Event, PWND pWnd, LONG idObject, LONG idChild, DWORD flags)
Definition: event.c:179
#define OBJID_WINDOW
Definition: winable.h:15
HWND hWnd
Definition: settings.c:17
#define WM_ENABLE
Definition: winuser.h:1602
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CHILDID_SELF
Definition: winable.h:14
LONG_PTR LPARAM
Definition: windef.h:208
#define TRACE(s)
Definition: solgame.cpp:4
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1446
#define WM_CANCELMODE
Definition: winuser.h:1622
Definition: ntuser.h:672
_In_ BOOL bEnable
Definition: winddi.h:3426
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:126
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
ULONG FASTCALL IntSetStyle(PWND pwnd, ULONG set_bits, ULONG clear_bits)
Definition: window.c:147
DWORD style
Definition: ntuser.h:685

Referenced by NtUserCallTwoParam(), and NtUserEnableScrollBar().

◆ IntFindWindow()

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

Definition at line 3039 of file window.c.

3043 {
3044  BOOL CheckWindowName;
3045  HWND *List, *phWnd;
3046  HWND Ret = NULL;
3047  UNICODE_STRING CurrentWindowName;
3048 
3049  ASSERT(Parent);
3050 
3051  CheckWindowName = WindowName->Buffer != 0;
3052 
3053  if((List = IntWinListChildren(Parent)))
3054  {
3055  phWnd = List;
3056  if(ChildAfter)
3057  {
3058  /* skip handles before and including ChildAfter */
3059  while(*phWnd && (*(phWnd++) != ChildAfter->head.h))
3060  ;
3061  }
3062 
3063  /* search children */
3064  while(*phWnd)
3065  {
3066  PWND Child;
3067  if(!(Child = UserGetWindowObject(*(phWnd++))))
3068  {
3069  continue;
3070  }
3071 
3072  /* Do not send WM_GETTEXT messages in the kernel mode version!
3073  The user mode version however calls GetWindowText() which will
3074  send WM_GETTEXT messages to windows belonging to its processes */
3075  if (!ClassAtom || Child->pcls->atomNVClassName == ClassAtom)
3076  {
3077  // FIXME: LARGE_STRING truncated
3078  CurrentWindowName.Buffer = Child->strName.Buffer;
3079  CurrentWindowName.Length = (USHORT)min(Child->strName.Length, MAXUSHORT);
3080  CurrentWindowName.MaximumLength = (USHORT)min(Child->strName.MaximumLength, MAXUSHORT);
3081  if(!CheckWindowName ||
3082  (Child->strName.Length < 0xFFFF &&
3083  !RtlCompareUnicodeString(WindowName, &CurrentWindowName, TRUE)))
3084  {
3085  Ret = Child->head.h;
3086  break;
3087  }
3088  }
3089  }
3091  }
3092 
3093  return Ret;
3094 }
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define TRUE
Definition: types.h:120
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical 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:728
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
Definition: wdffdo.h:533
unsigned int BOOL
Definition: ntddk_ex.h:94
THRDESKHEAD head
Definition: ntuser.h:674
#define ASSERT(a)
Definition: mode.c:44
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
HWND *FASTCALL IntWinListChildren(PWND Window)
Definition: window.c:278
Definition: ntuser.h:672
unsigned short USHORT
Definition: pedump.c:61
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:126
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
#define MAXUSHORT
Definition: typedefs.h:83
#define USERTAG_WINDOWLIST
Definition: tags.h:298
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

Referenced by 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 }
#define SM_CYSIZE
Definition: winuser.h:986
LONG top
Definition: windef.h:307
#define STARTF_USEPOSITION
Definition: winbase.h:490
#define WS_CHILD
Definition: pedump.c:617
LONG left
Definition: windef.h:306
#define SM_CYFRAME
Definition: winuser.h:990
#define SM_CXFRAME
Definition: winuser.h:988
LONG right
Definition: windef.h:308
SHORT cWndStack
Definition: monitor.h:22
RECT rcWork
Definition: monitor.h:19
#define PsGetCurrentProcess
Definition: psfuncs.h:17
LONG NTAPI UserGetSystemMetrics(ULONG Index)
Definition: metric.c:194
#define TRACE(s)
Definition: solgame.cpp:4
#define WS_POPUP
Definition: pedump.c:616
#define NULL
Definition: types.h:112
PMONITOR NTAPI UserGetPrimaryMonitor(VOID)
Definition: monitor.c:102
#define SM_CXSIZE
Definition: winuser.h:985
LONG bottom
Definition: windef.h:309
#define IS_DEFAULT(x)

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 }
struct tagWINDOWLIST * pNextList
Definition: window.h:86
PWINDOWLIST gpwlCache
Definition: window.c:17
#define WL_CAPACITY(pwl)
Definition: window.h:97
PWINDOWLIST gpwlList
Definition: window.c:16
#define USERTAG_WINDOWLIST
Definition: tags.h:298
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

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

◆ IntGetNonChildAncestor()

PWND FASTCALL IntGetNonChildAncestor ( PWND  pWnd)

Definition at line 346 of file window.c.

347 {
348  while(pWnd && (pWnd->style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
349  pWnd = pWnd->spwndParent;
350  return pWnd;
351 }
#define WS_CHILD
Definition: pedump.c:617
#define WS_POPUP
Definition: pedump.c:616
struct _WND * spwndParent
Definition: ntuser.h:692
DWORD style
Definition: ntuser.h:685

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

◆ IntGetParent()

PWND FASTCALL IntGetParent ( PWND  Wnd)

Definition at line 208 of file window.c.

209 {
210  if (Wnd->style & WS_POPUP)
211  {
212  return Wnd->spwndOwner;
213  }
214  else if (Wnd->style & WS_CHILD)
215  {
216  return Wnd->spwndParent;
217  }
218 
219  return NULL;
220 }
#define WS_CHILD
Definition: pedump.c:617
struct _WND * spwndOwner
Definition: ntuser.h:694
#define WS_POPUP
Definition: pedump.c:616
#define NULL
Definition: types.h:112
struct _WND * spwndParent
Definition: ntuser.h:692
DWORD style
Definition: ntuser.h:685

Referenced by co_UserDestroyWindow(), DefSetText(), DefWndDoSizeMove(), DefWndHandleWindowPosChanged(), GetControlBrush(), IntDefWindowProc(), IntGetWindowContextHelpId(), MsqSendParentNotify(), NC_DoNCPaint(), NC_GetSysPopupPos(), NtUserCallHwndLock(), NtUserDefSetText(), and UserGetAncestor().

◆ IntGetWindow()

HWND FASTCALL IntGetWindow ( HWND  hWnd,
UINT  uCmd 
)

Definition at line 376 of file window.c.

378 {
379  PWND Wnd, FoundWnd;
380  HWND Ret = NULL;
381 
382  Wnd = ValidateHwndNoErr(hWnd);
383  if (!Wnd)
384  return NULL;
385 
386  FoundWnd = NULL;
387  switch (uCmd)
388  {
389  case GW_OWNER:
390  if (Wnd->spwndOwner != NULL)
391  FoundWnd = Wnd->spwndOwner;
392  break;
393 
394  case GW_HWNDFIRST:
395  if(Wnd->spwndParent != NULL)
396  {
397  FoundWnd = Wnd->spwndParent;
398  if (FoundWnd->spwndChild != NULL)
399  FoundWnd = FoundWnd->spwndChild;
400  }
401  break;
402  case GW_HWNDNEXT:
403  if (Wnd->spwndNext != NULL)
404  FoundWnd = Wnd->spwndNext;
405  break;
406 
407  case GW_HWNDPREV:
408  if (Wnd->spwndPrev != NULL)
409  FoundWnd = Wnd->spwndPrev;
410  break;
411 
412  case GW_CHILD:
413  if (Wnd->spwndChild != NULL)
414  FoundWnd = Wnd->spwndChild;
415  break;
416 
417  case GW_HWNDLAST:
418  FoundWnd = Wnd;
419  while ( FoundWnd->spwndNext != NULL)
420  FoundWnd = FoundWnd->spwndNext;
421  break;
422 
423  default:
424  Wnd = NULL;
425  break;
426  }
427 
428  if (FoundWnd != NULL)
429  Ret = UserHMGetHandle(FoundWnd);
430  return Ret;
431 }
#define GW_HWNDNEXT
Definition: winuser.h:756
PWND FASTCALL ValidateHwndNoErr(HWND hWnd)
Definition: window.c:118
#define GW_CHILD
Definition: winuser.h:758
HWND hWnd
Definition: settings.c:17
struct _WND * spwndOwner
Definition: ntuser.h:694
struct _WND * spwndNext
Definition: ntuser.h:690
#define UserHMGetHandle(obj)
Definition: ntuser.h:222
#define GW_HWNDLAST
Definition: winuser.h:760
#define GW_HWNDFIRST
Definition: winuser.h:759
Definition: ntuser.h:672
#define NULL
Definition: types.h:112
#define GW_OWNER
Definition: winuser.h:761
struct _WND * spwndParent
Definition: ntuser.h:692
struct _WND * spwndChild
Definition: ntuser.h:693
#define GW_HWNDPREV
Definition: winuser.h:757
struct _WND * spwndPrev
Definition: ntuser.h:691

Referenced by WinPosFixupFlags().

◆ IntGetWindowContextHelpId()

DWORD FASTCALL IntGetWindowContextHelpId ( PWND  pWnd)

Definition at line 433 of file window.c.

434 {
435  DWORD HelpId;
436 
437  do
438  {
440  if (!HelpId) break;
441  pWnd = IntGetParent(pWnd);
442  }
443  while (pWnd && pWnd->fnid != FNID_DESKTOP);
444  return HelpId;
445 }
#define TRUE
Definition: types.h:120
PSERVERINFO gpsi
Definition: imm.c:17
ATOM atomContextHelpIdProp
Definition: ntuser.h:1038
#define DWORD
Definition: nt_native.h:44
DWORD fnid
Definition: ntuser.h:688
#define FNID_DESKTOP
Definition: ntuser.h:841
HANDLE FASTCALL UserGetProp(_In_ PWND Window, _In_ ATOM Atom, _In_ BOOLEAN SystemProp)
Definition: prop.c:46
unsigned long DWORD
Definition: ntddk_ex.h:95
uint32_t DWORD_PTR
Definition: typedefs.h:65
PWND FASTCALL IntGetParent(PWND Wnd)
Definition: window.c:208

Referenced by IntDefWindowProc().

◆ IntGetWindowObject()

PWND FASTCALL IntGetWindowObject ( HWND  hWnd)

Definition at line 73 of file window.c.

74 {
75  PWND Window;
76 
77  if (!hWnd) return NULL;
78 
80  if (Window)
81  Window->head.cLockObj++;
82 
83  return Window;
84 }
HWND hWnd
Definition: settings.c:17
Definition: window.c:28
int Window
Definition: x11stubs.h:26
Definition: ntuser.h:672
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:126
#define NULL
Definition: types.h:112

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

◆ IntGetWindowProc()

WNDPROC FASTCALL IntGetWindowProc ( PWND  pWnd,
BOOL  Ansi 
)

Definition at line 769 of file window.c.

771 {
772  INT i;
773  PCLS Class;
774  WNDPROC gcpd, Ret = 0;
775 
777 
778  Class = pWnd->pcls;
779 
780  if (pWnd->state & WNDS_SERVERSIDEWINDOWPROC)
781  {
782  for ( i = FNID_FIRST; i <= FNID_SWITCH; i++)
783  {
784  if (GETPFNSERVER(i) == pWnd->lpfnWndProc)
785  {
786  if (Ansi)
787  Ret = GETPFNCLIENTA(i);
788  else
789  Ret = GETPFNCLIENTW(i);
790  }
791  }
792  return Ret;
793  }
794 
795  if (Class->fnid == FNID_EDIT)
796  Ret = pWnd->lpfnWndProc;
797  else
798  {
799  Ret = pWnd->lpfnWndProc;
800 
801  if (Class->fnid <= FNID_GHOST && Class->fnid >= FNID_BUTTON)
802  {
803  if (Ansi)
804  {
805  if (GETPFNCLIENTW(Class->fnid) == pWnd->lpfnWndProc)
806  Ret = GETPFNCLIENTA(Class->fnid);
807  }
808  else
809  {
810  if (GETPFNCLIENTA(Class->fnid) == pWnd->lpfnWndProc)
811  Ret = GETPFNCLIENTW(Class->fnid);
812  }
813  }
814  if ( Ret != pWnd->lpfnWndProc)
815  return Ret;
816  }
817  if ( Ansi == !!(pWnd->state & WNDS_ANSIWINDOWPROC) )
818  return Ret;
819 
820  gcpd = (WNDPROC)UserGetCPD(
821  pWnd,
823  (ULONG_PTR)Ret);
824 
825  return (gcpd ? gcpd : Ret);
826 }
static const WCHAR Class[]
Definition: cfgmgr.c:42
#define FNID_EDIT
Definition: ntuser.h:849
#define GETPFNSERVER(fnid)
Definition: ntuser.h:888
#define GETPFNCLIENTW(fnid)
Definition: ntuser.h:885
WNDPROC lpfnWndProc
Definition: ntuser.h:697
ULONG_PTR FASTCALL UserGetCPD(PVOID pvClsWnd, GETCPD Flags, ULONG_PTR ProcIn)
Definition: callproc.c:107
int32_t INT
Definition: typedefs.h:58
Definition: ntuser.h:548
#define FNID_SWITCH
Definition: ntuser.h:844
#define ASSERT(a)
Definition: mode.c:44
#define GETPFNCLIENTA(fnid)
Definition: ntuser.h:883
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2886
#define FNID_GHOST
Definition: ntuser.h:854
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 WNDS_ANSIWINDOWPROC
Definition: ntuser.h:607
#define FNID_BUTTON
Definition: ntuser.h:845
DWORD state
Definition: ntuser.h:680
BOOL FASTCALL UserIsEnteredExclusive(VOID)
Definition: ntuser.c:231
#define ULONG_PTR
Definition: config.h:101
#define WNDS_SERVERSIDEWINDOWPROC
Definition: ntuser.h:606
#define FNID_FIRST
Definition: ntuser.h:837
PCLS pcls
Definition: ntuser.h:699

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 }
#define TRUE
Definition: types.h:120
HANDLE HWND
Definition: compat.h:19
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
HWND * phwndLast
Definition: window.h:87
PVOID FASTCALL IntReAllocatePoolWithTag(POOL_TYPE PoolType, PVOID pOld, SIZE_T cbOld, SIZE_T cbNew, ULONG Tag)
Definition: window.c:22
#define GROW_COUNT
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define USERTAG_WINDOWLIST
Definition: tags.h:298

Referenced by IntPopulateHwndList().

◆ IntIsChildWindow()

BOOL FASTCALL IntIsChildWindow ( PWND  Parent,
PWND  BaseWindow 
)

Definition at line 916 of file window.c.

917 {
919  do
920  {
921  if ( Window == NULL || (Window->style & (WS_POPUP|WS_CHILD)) != WS_CHILD )
922  return FALSE;
923 
924  Window = Window->spwndParent;
925  }
926  while(Parent != Window);
927  return TRUE;
928 }
#define TRUE
Definition: types.h:120
#define WS_CHILD
Definition: pedump.c:617
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical 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:728
Definition: window.c:28
#define FALSE
Definition: types.h:117
Definition: ntuser.h:672
#define WS_POPUP
Definition: pedump.c:616
#define NULL
Definition: types.h:112
struct tagBaseWindow BaseWindow

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

◆ IntIsTopLevelWindow()

BOOL FASTCALL IntIsTopLevelWindow ( PWND  pWnd)

Definition at line 354 of file window.c.

355 {
356  if ( pWnd->spwndParent &&
357  pWnd->spwndParent == co_GetDesktopWindow(pWnd) ) return TRUE;
358  return FALSE;
359 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
PWND FASTCALL co_GetDesktopWindow(PWND pWnd)
Definition: desktop.c:1366
struct _WND * spwndParent
Definition: ntuser.h:692

Referenced by co_UserCreateWindowEx(), and co_UserDestroyWindow().

◆ IntIsWindow()

BOOL FASTCALL IntIsWindow ( HWND  hWnd)

Definition at line 180 of file window.c.

181 {
182  PWND Window;
183 
184  if (!(Window = UserGetWindowObject(hWnd)))
185  {
186  return FALSE;
187  }
188 
189  return TRUE;
190 }
#define TRUE
Definition: types.h:120
HWND hWnd
Definition: settings.c:17
Definition: window.c:28
#define FALSE
Definition: types.h:117
int Window
Definition: x11stubs.h:26
Definition: ntuser.h:672
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:126

Referenced by co_IntPaintWindows(), co_UserDestroyWindow(), co_UserSetFocus(), co_WinPosSetWindowPos(), DefWndDoSizeMove(), IntSendDestroyMsg(), IntTrackPopupMenuEx(), NtUserCallHwnd(), NtUserSetActiveWindow(), and NtUserSetLogonNotifyWindow().

◆ IntIsWindowVisible()

BOOL FASTCALL IntIsWindowVisible ( PWND  Wnd)

Definition at line 193 of file window.c.

194 {
195  PWND Temp = Wnd;
196  for (;;)
197  {
198  if (!Temp) return TRUE;
199  if (!(Temp->style & WS_VISIBLE)) break;
200  if (Temp->style & WS_MINIMIZE && Temp != Wnd) break;
201  if (Temp->fnid == FNID_DESKTOP) return TRUE;
202  Temp = Temp->spwndParent;
203  }
204  return FALSE;
205 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define WS_MINIMIZE
Definition: pedump.c:622
DWORD fnid
Definition: ntuser.h:688
#define FNID_DESKTOP
Definition: ntuser.h:841
Definition: ntuser.h:672
struct _WND * spwndParent
Definition: ntuser.h:692
#define WS_VISIBLE
Definition: pedump.c:620
DWORD style
Definition: ntuser.h:685

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

◆ IntLinkHwnd()

VOID FASTCALL IntLinkHwnd ( PWND  Wnd,
HWND  hWndPrev 
)

Definition at line 971 of file window.c.

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

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

◆ IntLinkWindow()

VOID FASTCALL IntLinkWindow ( PWND  Wnd,
PWND  WndInsertAfter 
)

Definition at line 933 of file window.c.

937 {
938  if (Wnd == WndInsertAfter)
939  {
940  ERR("IntLinkWindow -- Trying to link window 0x%p to itself!!\n", Wnd);
941  return;
942  }
943 
944  Wnd->spwndPrev = WndInsertAfter;
945  if (Wnd->spwndPrev)
946  {
947  /* Link after WndInsertAfter */
948  ASSERT(Wnd != WndInsertAfter->spwndNext);
949  Wnd->spwndNext = WndInsertAfter->spwndNext;
950  if (Wnd->spwndNext)
951  Wnd->spwndNext->spwndPrev = Wnd;
952 
953  ASSERT(Wnd != Wnd->spwndPrev);
954  Wnd->spwndPrev->spwndNext = Wnd;
955  }
956  else
957  {
958  /* Link at the top */
959  ASSERT(Wnd != Wnd->spwndParent->spwndChild);
960  Wnd->spwndNext = Wnd->spwndParent->spwndChild;
961  if (Wnd->spwndNext)
962  Wnd->spwndNext->spwndPrev = Wnd;
963 
964  Wnd->spwndParent->spwndChild = Wnd;
965  }
966 }
struct _WND * spwndNext
Definition: ntuser.h:690
#define ASSERT(a)
Definition: mode.c:44
#define ERR(fmt,...)
Definition: debug.h:110
struct _WND * spwndParent
Definition: ntuser.h:692
struct _WND * spwndPrev
Definition: ntuser.h:691

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 WL_IS_BAD(pwl)
Definition: window.h:96
#define IACE_LIST
Definition: window.h:103
HWND * phwndLast
Definition: window.h:87
#define IACE_CHILDREN
Definition: imm.h:581
THRDESKHEAD head
Definition: ntuser.h:674
struct _WND * spwndNext
Definition: ntuser.h:690
#define UserHMGetHandle(obj)
Definition: ntuser.h:222
#define ASSERT(a)
Definition: mode.c:44
PWINDOWLIST FASTCALL IntPopulateHwndList(PWINDOWLIST pwl, PWND pwnd, DWORD dwFlags)
Definition: window.c:1380
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
BOOL FASTCALL IntGrowHwndList(PWINDOWLIST *ppwl)
Definition: window.c:1359
HWND * phwndEnd
Definition: window.h:88
struct _WND * spwndChild
Definition: ntuser.h:693
PTHREADINFO pti
Definition: window.h:89

Referenced by IntBuildHwndList().

◆ IntProcessOwnerSwap()

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

Definition at line 1064 of file window.c.

1065 {
1066  if (WndOldOwner)
1067  {
1068  if (Wnd->head.pti != WndOldOwner->head.pti)
1069  {
1070  if (!WndNewOwner ||
1071  Wnd->head.pti == WndNewOwner->head.pti ||
1072  WndOldOwner->head.pti != WndNewOwner->head.pti )
1073  {
1074  //ERR("ProcessOwnerSwap Old out.\n");
1075  UserAttachThreadInput(Wnd->head.pti, WndOldOwner->head.pti, FALSE);
1076  }
1077  }
1078  }
1079  if (WndNewOwner)
1080  {
1081  if (Wnd->head.pti != WndNewOwner->head.pti)
1082  {
1083  if (!WndOldOwner ||
1084  WndOldOwner->head.pti != WndNewOwner->head.pti )
1085  {
1086  //ERR("ProcessOwnerSwap New in.\n");
1087  UserAttachThreadInput(Wnd->head.pti, WndNewOwner->head.pti, TRUE);
1088  }
1089  }
1090  }
1091  // FIXME: System Tray checks.
1092 }
NTSTATUS FASTCALL UserAttachThreadInput(PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach)
Definition: input.c:480
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
THRDESKHEAD head
Definition: ntuser.h:674

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 {
29  PVOID pNew = ExAllocatePoolWithTag(PoolType, cbNew, Tag);
30  if (!pNew)
31  return NULL;
32 
33  RtlCopyMemory(pNew, pOld, min(cbOld, cbNew));
34  ExFreePoolWithTag(pOld, Tag);
35  return pNew;
36 }
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4061
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3810
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

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 */
369  pDesk->dwDTFlags &= ~(DF_TME_LEAVE|DF_TME_HOVER);
370  pDesk->spwndTrack = NULL;
371 }
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1346
DWORD htEx
Definition: desktop.h:32
PWND spwndTrack
Definition: desktop.h:31
#define ID_EVENT_SYSTIMER_MOUSEHOVER
Definition: timer.h:27
#define TRUE
Definition: types.h:120
BOOL FASTCALL IntKillTimer(PWND Window, UINT_PTR IDEvent, BOOL SystemTimer)
Definition: timer.c:573
#define DF_TME_LEAVE
Definition: desktop.h:48
DWORD dwDTFlags
Definition: desktop.h:12
#define WM_MOUSELEAVE
Definition: commctrl.h:4975
#define UserHMGetHandle(obj)
Definition: ntuser.h:222
#define DF_TME_HOVER
Definition: desktop.h:47
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define WM_NCMOUSELEAVE
Definition: winuser.h:1829
#define HTCLIENT
Definition: winuser.h:2455

Referenced by IntSendDestroyMsg().

◆ IntSendDestroyMsg()

static void IntSendDestroyMsg ( HWND  hWnd)
static

Definition at line 456 of file window.c.

457 {
458  PTHREADINFO ti;
459  PWND Window;
460 
463 
464  if (Window)
465  {
466  /*
467  * Look whether the focus is within the tree of windows
468  * we will be destroying.
469  */
470  // Rule #1
471  if ( ti->MessageQueue->spwndActive == Window || // Fixes CORE-106 RegSvr32 exit and return focus to CMD.
472  (ti->MessageQueue->spwndActive == NULL && ti->MessageQueue == IntGetFocusMessageQueue()) )
473  {
475  }
476 
477  /* Fixes CMD properties closing and returning focus to CMD */
478  if (ti->MessageQueue->spwndFocus == Window)
479  {
480  if ((Window->style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
481  {
482  co_UserSetFocus(Window->spwndParent);
483  }
484  else
485  {
487  }
488  }
489 
490  if (ti->MessageQueue->CaretInfo.hWnd == UserHMGetHandle(Window))
491  {
492  co_IntDestroyCaret(ti);
493  }
494 
495  /* If the window being destroyed is currently tracked... */
496  if (ti->rpdesk->spwndTrack == Window)
497  {
499  }
500  }
501 
502  /* If the window being destroyed is the current clipboard owner... */
503  if (ti->ppi->prpwinsta != NULL && Window == ti->ppi->prpwinsta->spwndClipOwner)
504  {
505  /* ... make it release the clipboard */
507  }
508 
509  /* Send the WM_DESTROY to the window */
511 
512  /*
513  * This WM_DESTROY message can trigger re-entrant calls to DestroyWindow
514  * make sure that the window still exists when we come back.
515  */
516  if (IntIsWindow(hWnd))
517  {
518  HWND* pWndArray;
519  int i;
520 
521  if (!(pWndArray = IntWinListChildren( Window ))) return;
522 
523  for (i = 0; pWndArray[i]; i++)
524  {
525  if (IntIsWindow( pWndArray[i] )) IntSendDestroyMsg( pWndArray[i] );
526  }
528  }
529  else
530  {
531  TRACE("destroyed itself while in WM_DESTROY!\n");
532  }
533 }
HWND FASTCALL co_UserSetFocus(PWND Window)
Definition: focus.c:1309
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
HWND hWnd
Definition: settings.c:17
VOID FASTCALL UserClipboardRelease(PWND pWindow)
Definition: clipboard.c:374
#define WS_CHILD
Definition: pedump.c:617
struct _WINSTATION_OBJECT * prpwinsta
Definition: win32.h:262
VOID FASTCALL co_WinPosActivateOtherWindow(PWND Wnd)
Definition: winpos.c:395
PUSER_MESSAGE_QUEUE FASTCALL IntGetFocusMessageQueue(VOID)
Definition: desktop.c:130