ReactOS  0.4.15-dev-5461-g062a8f2
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)
 
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 3454 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:699
struct _DESKTOP * rpdesk
Definition: ntuser.h:194
VOID FASTCALL IntUnlinkWindow(PWND Wnd)
Definition: window.c:1341
DWORD ExStyle2
Definition: ntuser.h:740
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:671
#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:1748
#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:710
THRDESKHEAD head
Definition: ntuser.h:690
PWND FASTCALL co_GetDesktopWindow(PWND pWnd)
Definition: desktop.c:1366
#define WEF_SETBYWNDPTI
Definition: ntuser.h:235
BOOLEAN FASTCALL co_WinPosShowWindow(PWND Wnd, INT Cmd)
Definition: winpos.c:2518
#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:711
#define SWP_NOSIZE
Definition: winuser.h:1235
#define ERR(fmt,...)
Definition: debug.h:110
Definition: ntuser.h:688
#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:708
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:701

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

3820 {
3821  PWND Window, Parent;
3822  PWINSTATION_OBJECT WindowStation;
3823  LONG_PTR OldValue;
3825 
3826  if (!(Window = UserGetWindowObject(hWnd)))
3827  {
3828  return( 0);
3829  }
3830 
3831  if ((INT)Index >= 0)
3832  {
3833  if ((Index + Size) > Window->cbwndExtra)
3834  {
3836  return( 0);
3837  }
3838 
3839 #ifdef _WIN64
3840  if (Size == sizeof(LONG))
3841  {
3842  OldValue = *((LONG *)((PCHAR)(Window + 1) + Index));
3843  *((LONG*)((PCHAR)(Window + 1) + Index)) = (LONG)NewValue;
3844  }
3845  else
3846 #endif
3847  {
3848  OldValue = *((LONG_PTR *)((PCHAR)(Window + 1) + Index));
3849  /*
3850  if ( Index == DWLP_DLGPROC && Wnd->state & WNDS_DIALOGWINDOW)
3851  {
3852  OldValue = (LONG_PTR)IntSetWindowProc( Wnd, (WNDPROC)NewValue, Ansi);
3853  if (!OldValue) return 0;
3854  }
3855  */
3856  *((LONG_PTR*)((PCHAR)(Window + 1) + Index)) = NewValue;
3857  }
3858 
3859  }
3860  else
3861  {
3862 #ifdef _WIN64
3863  if (Size == sizeof(LONG))
3864  {
3865  if ((Index != GWL_STYLE) &&
3866  (Index != GWL_EXSTYLE) &&
3867  (Index != GWL_ID) &&
3868  (Index != GWL_USERDATA))
3869  {
3870  ERR("NtUserSetWindowLong(): Index requires pointer size: %lu\n", Index);
3872  return 0;
3873  }
3874  }
3875 #endif
3876 
3877  switch (Index)
3878  {
3879  case GWL_EXSTYLE: // LONG
3880  OldValue = (LONG) Window->ExStyle;
3881  Style.styleOld = OldValue;
3882  Style.styleNew = NewValue;
3883 
3884  co_IntSendMessage(hWnd, WM_STYLECHANGING, GWL_EXSTYLE, (LPARAM) &Style);
3885 
3886  /*
3887  * Remove extended window style bit WS_EX_TOPMOST for shell windows.
3888  */
3889  WindowStation = Window->head.pti->rpdesk->rpwinstaParent;
3890  if(WindowStation)
3891  {
3892  if (hWnd == WindowStation->ShellWindow || hWnd == WindowStation->ShellListView)
3893  Style.styleNew &= ~WS_EX_TOPMOST;
3894  }
3895  /* WS_EX_WINDOWEDGE depends on some other styles */
3896  if (IntCheckFrameEdge(Window->style, NewValue))
3897  Style.styleNew |= WS_EX_WINDOWEDGE;
3898  else
3899  Style.styleNew &= ~WS_EX_WINDOWEDGE;
3900 
3901  if (!(Window->ExStyle & WS_EX_LAYERED))
3902  {
3904  }
3905 
3906  Window->ExStyle = (DWORD)Style.styleNew;
3907 
3908  co_IntSendMessage(hWnd, WM_STYLECHANGED, GWL_EXSTYLE, (LPARAM) &Style);
3909  break;
3910 
3911  case GWL_STYLE: // LONG
3912  OldValue = (LONG) Window->style;
3913  Style.styleOld = OldValue;
3914  Style.styleNew = NewValue;
3915 
3916  if (!bAlter)
3917  co_IntSendMessage(hWnd, WM_STYLECHANGING, GWL_STYLE, (LPARAM) &Style);
3918 
3919  /* WS_CLIPSIBLINGS can't be reset on top-level windows */
3920  if (UserIsDesktopWindow(Window->spwndParent)) Style.styleNew |= WS_CLIPSIBLINGS;
3921  /* WS_MINIMIZE can't be reset */
3922  if (OldValue & WS_MINIMIZE) Style.styleNew |= WS_MINIMIZE;
3923  /* Fixes wine FIXME: changing WS_DLGFRAME | WS_THICKFRAME is supposed to change WS_EX_WINDOWEDGE too */
3924  if (IntCheckFrameEdge(NewValue, Window->ExStyle))
3925  Window->ExStyle |= WS_EX_WINDOWEDGE;
3926  else
3927  Window->ExStyle &= ~WS_EX_WINDOWEDGE;
3928 
3929  if ((OldValue & (WS_CHILD | WS_POPUP)) == WS_CHILD)
3930  {
3931  if ((NewValue & (WS_CHILD | WS_POPUP)) != WS_CHILD)
3932  {
3934  ERR("IDMenu going null! %d\n",Window->IDMenu);
3935  Window->IDMenu = 0; // Window->spmenu = 0;
3936  }
3937  }
3938  else
3939  {
3940  if ((NewValue & (WS_CHILD | WS_POPUP)) == WS_CHILD)
3941  {
3942  PMENU pMenu = UserGetMenuObject(UlongToHandle(Window->IDMenu));
3943  Window->state &= ~WNDS_HASMENU;
3944  if (pMenu)
3945  {
3946  ERR("IDMenu released 0x%p\n",pMenu);
3947  // ROS may not hold a lock after setting menu to window. But it should!
3948  //IntReleaseMenuObject(pMenu);
3949  }
3950  }
3951  }
3952 
3953  if ((Style.styleOld ^ Style.styleNew) & WS_VISIBLE)
3954  {
3955  if (Style.styleOld & WS_VISIBLE) Window->head.pti->cVisWindows--;
3956  if (Style.styleNew & WS_VISIBLE) Window->head.pti->cVisWindows++;
3958  }
3959  Window->style = (DWORD)Style.styleNew;
3960 
3961  if (!bAlter)
3962  co_IntSendMessage(hWnd, WM_STYLECHANGED, GWL_STYLE, (LPARAM) &Style);
3963  break;
3964 
3965  case GWLP_WNDPROC: // LONG_PTR
3966  {
3967  if ( Window->head.pti->ppi != PsGetCurrentProcessWin32Process() ||
3968  Window->fnid & FNID_FREED)
3969  {
3971  return( 0);
3972  }
3973  OldValue = (LONG_PTR)IntSetWindowProc(Window,
3974  (WNDPROC)NewValue,
3975  Ansi);
3976  break;
3977  }
3978 
3979  case GWLP_HINSTANCE: // LONG_PTR
3980  OldValue = (LONG_PTR) Window->hModule;
3981  Window->hModule = (HINSTANCE) NewValue;
3982  break;
3983 
3984  case GWLP_HWNDPARENT: // LONG_PTR
3985  Parent = Window->spwndParent;
3986  if (Parent && (Parent->head.h == IntGetDesktopWindow()))
3987  OldValue = (LONG_PTR) IntSetOwner(Window->head.h, (HWND) NewValue);
3988  else
3989  OldValue = (LONG_PTR) co_UserSetParent(Window->head.h, (HWND) NewValue);
3990  break;
3991 
3992  case GWLP_ID: // LONG
3993  OldValue = (LONG) Window->IDMenu;
3994  Window->IDMenu = (UINT) NewValue;
3995  break;
3996 
3997  case GWLP_USERDATA: // LONG or LONG_PTR
3998  OldValue = Window->dwUserData;
3999  Window->dwUserData = NewValue;
4000  break;
4001 
4002  default:
4003  ERR("NtUserSetWindowLong(): Unsupported index %lu\n", Index);
4005  OldValue = 0;
4006  break;
4007  }
4008  }
4009 
4010  return( OldValue);
4011 }
#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
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:895
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:2896
#define ERR(fmt,...)
Definition: debug.h:110
#define GWL_STYLE
Definition: winuser.h:846
Definition: ntuser.h:688
HWND FASTCALL IntGetDesktopWindow(VOID)
Definition: desktop.c:1374
static BOOL FASTCALL IntCheckFrameEdge(ULONG Style, ULONG ExStyle)
Definition: window.c:3808
__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
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:732
#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:600
#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 2185 of file window.c.

2190 {
2191  ULONG style;
2192  PWND Window = NULL, ParentWindow = NULL, OwnerWindow;
2193  HWND hWnd, hWndParent, hWndOwner, hwndInsertAfter;
2194  PWINSTATION_OBJECT WinSta;
2195  PCLS Class = NULL;
2196  SIZE Size;
2197  POINT MaxSize, MaxPos, MinTrack, MaxTrack;
2198  CBT_CREATEWNDW * pCbtCreate;
2199  LRESULT Result;
2200  USER_REFERENCE_ENTRY ParentRef, Ref;
2201  PTHREADINFO pti;
2202  DWORD dwShowMode = SW_SHOW;
2203  CREATESTRUCTW *pCsw = NULL;
2204  PVOID pszClass = NULL, pszName = NULL;
2205  PWND ret = NULL;
2206 
2207  /* Get the current window station and reference it */
2208  pti = GetW32ThreadInfo();
2209  if (pti == NULL || pti->rpdesk == NULL)
2210  {
2211  ERR("Thread is not attached to a desktop! Cannot create window!\n");
2212  return NULL; // There is nothing to cleanup.
2213  }
2214  WinSta = pti->rpdesk->rpwinstaParent;
2216 
2217  pCsw = NULL;
2218  pCbtCreate = NULL;
2219 
2220  /* Get the class and reference it */
2221  Class = IntGetAndReferenceClass(ClassName, Cs->hInstance, FALSE);
2222  if(!Class)
2223  {
2225  ERR("Failed to find class %wZ\n", ClassName);
2226  goto cleanup;
2227  }
2228 
2229  /* Now find the parent and the owner window */
2230  hWndParent = pti->rpdesk->pDeskInfo->spwnd->head.h;
2231  hWndOwner = NULL;
2232 
2233  if (Cs->hwndParent == HWND_MESSAGE)
2234  {
2235  Cs->hwndParent = hWndParent = pti->rpdesk->spwndMessage->head.h;
2236  }
2237  else if (Cs->hwndParent)
2238  {
2239  if ((Cs->style & (WS_CHILD|WS_POPUP)) != WS_CHILD)
2240  hWndOwner = Cs->hwndParent;
2241  else
2242  hWndParent = Cs->hwndParent;
2243  }
2244  else if ((Cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
2245  {
2246  ERR("Cannot create a child window without a parent!\n");
2248  goto cleanup; /* WS_CHILD needs a parent, but WS_POPUP doesn't */
2249  }
2251  (IS_INTRESOURCE(Cs->lpszClass) ||
2252  Cs->lpszClass != (LPCWSTR)MAKEINTATOM(gpsi->atomSysClass[ICLS_HWNDMESSAGE]) ||
2253  _wcsicmp(Cs->lpszClass, L"Message") != 0))
2254  {
2255  if (pti->ppi->dwLayout & LAYOUT_RTL)
2256  {
2257  Cs->dwExStyle |= WS_EX_LAYOUTRTL;
2258  }
2259  }
2260 
2261  ParentWindow = hWndParent ? UserGetWindowObject(hWndParent): NULL;
2262  OwnerWindow = hWndOwner ? UserGetWindowObject(hWndOwner): NULL;
2263 
2264  if (hWndParent && !ParentWindow)
2265  {
2266  ERR("Got invalid parent window handle\n");
2267  goto cleanup;
2268  }
2269  else if (hWndOwner && !OwnerWindow)
2270  {
2271  ERR("Got invalid owner window handle\n");
2272  ParentWindow = NULL;
2273  goto cleanup;
2274  }
2275 
2276  if(OwnerWindow)
2277  {
2278  if (IntIsDesktopWindow(OwnerWindow)) OwnerWindow = NULL;
2279  else if (ParentWindow && !IntIsDesktopWindow(ParentWindow))
2280  {
2281  ERR("an owned window must be created as top-level\n");
2283  goto cleanup;
2284  }
2285  else /* owner must be a top-level window */
2286  {
2287  while ((OwnerWindow->style & (WS_POPUP|WS_CHILD)) == WS_CHILD && !IntIsDesktopWindow(OwnerWindow->spwndParent))
2288  OwnerWindow = OwnerWindow->spwndParent;
2289  }
2290  }
2291 
2292  /* Fix the position and the size of the window */
2293  if (ParentWindow)
2294  {
2295  UserRefObjectCo(ParentWindow, &ParentRef);
2296  IntFixWindowCoordinates(Cs, ParentWindow, &dwShowMode);
2297  }
2298 
2299  /* Allocate and initialize the new window */
2300  Window = IntCreateWindow(Cs,
2301  WindowName,
2302  Class,
2303  ParentWindow,
2304  OwnerWindow,
2305  acbiBuffer,
2306  NULL,
2307  dwVer );
2308  if(!Window)
2309  {
2310  ERR("IntCreateWindow failed!\n");
2311  goto cleanup;
2312  }
2313 
2315  hwndInsertAfter = HWND_TOP;
2316 
2317  UserRefObjectCo(Window, &Ref);
2319  ObDereferenceObject(WinSta);
2320 
2321  /* NCCREATE, WM_NCCALCSIZE and Hooks need the original values */
2322  Cs->lpszName = (LPCWSTR) WindowName;
2323  Cs->lpszClass = (LPCWSTR) ClassName;
2324 
2326  if ( ISITHOOKED(WH_CBT) || (pti->rpdesk->pDeskInfo->fsHooks & HOOKID_TO_FLAG(WH_CBT)) )
2327  {
2328  // Allocate the calling structures Justin Case this goes Global.
2331  if (!pCsw || !pCbtCreate)
2332  {
2333  ERR("UserHeapAlloc() failed!\n");
2334  goto cleanup;
2335  }
2336 
2337  if (!IntMsgCreateStructW( Window, pCsw, Cs, &pszClass, &pszName ) )
2338  {
2339  ERR("IntMsgCreateStructW() failed!\n");
2340  goto cleanup;
2341  }
2342 
2343  pCbtCreate->lpcs = pCsw;
2344  pCbtCreate->hwndInsertAfter = hwndInsertAfter;
2345 
2348  if (Result != 0)
2349  {
2350  ERR("WH_CBT HCBT_CREATEWND hook failed! 0x%x\n", Result);
2351  goto cleanup;
2352  }
2353  // Write back changes.
2354  Cs->cx = pCsw->cx;
2355  Cs->cy = pCsw->cy;
2356  Cs->x = pCsw->x;
2357  Cs->y = pCsw->y;
2358  hwndInsertAfter = pCbtCreate->hwndInsertAfter;
2359  }
2360 
2361  if ((Cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
2362  {
2363  if (ParentWindow != co_GetDesktopWindow(Window))
2364  {
2365  Cs->x += ParentWindow->rcClient.left;
2366  Cs->y += ParentWindow->rcClient.top;
2367  }
2368  }
2369 
2370  /* Send the WM_GETMINMAXINFO message */
2371  Size.cx = Cs->cx;
2372  Size.cy = Cs->cy;
2373 
2374  if ((Cs->style & WS_THICKFRAME) || !(Cs->style & (WS_POPUP | WS_CHILD)))
2375  {
2376  co_WinPosGetMinMaxInfo(Window, &MaxSize, &MaxPos, &MinTrack, &MaxTrack);
2377  if (Size.cx > MaxTrack.x) Size.cx = MaxTrack.x;
2378  if (Size.cy > MaxTrack.y) Size.cy = MaxTrack.y;
2379  if (Size.cx < MinTrack.x) Size.cx = MinTrack.x;
2380  if (Size.cy < MinTrack.y) Size.cy = MinTrack.y;
2381  }
2382 
2383  Window->rcWindow.left = Cs->x;
2384  Window->rcWindow.top = Cs->y;
2385  Window->rcWindow.right = Cs->x + Size.cx;
2386  Window->rcWindow.bottom = Cs->y + Size.cy;
2387  /*
2388  if (0 != (Window->style & WS_CHILD) && ParentWindow)
2389  {
2390  ERR("co_UserCreateWindowEx(): Offset rcWindow\n");
2391  RECTL_vOffsetRect(&Window->rcWindow,
2392  ParentWindow->rcClient.left,
2393  ParentWindow->rcClient.top);
2394  }
2395  */
2396  /* correct child window coordinates if mirroring on parent is enabled */
2397  if (ParentWindow != NULL)
2398  {
2399  if ( ((Cs->style & WS_CHILD) == WS_CHILD) &&
2400  ((ParentWindow->ExStyle & WS_EX_LAYOUTRTL) == WS_EX_LAYOUTRTL))
2401  {
2402  Window->rcWindow.right = ParentWindow->rcClient.right - (Window->rcWindow.left - ParentWindow->rcClient.left);
2403  Window->rcWindow.left = Window->rcWindow.right - Size.cx;
2404  }
2405  }
2406 
2407  Window->rcClient = Window->rcWindow;
2408 
2409  if (Window->spwndNext || Window->spwndPrev)
2410  {
2411  ERR("Window 0x%p has been linked too early!\n", Window);
2412  }
2413 
2414  if (!(Window->state2 & WNDS2_WIN31COMPAT))
2415  {
2416  if (Class->style & CS_PARENTDC && !(ParentWindow->style & WS_CLIPCHILDREN))
2417  Window->style &= ~(WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
2418  }
2419 
2420  if ((Window->style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
2421  {
2422  if ( !IntIsTopLevelWindow(Window) )
2423  {
2424  if (pti != ParentWindow->head.pti)
2425  {
2426  //ERR("CreateWindow Parent in.\n");
2427  UserAttachThreadInput(pti, ParentWindow->head.pti, TRUE);
2428  }
2429  }
2430  }
2431 
2432  /* Send the NCCREATE message */
2434  if (!Result)
2435  {
2436  ERR("co_UserCreateWindowEx(): NCCREATE message failed\n");
2437  goto cleanup;
2438  }
2439 
2440  /* Link the window */
2441  if (ParentWindow != NULL)
2442  {
2443  /* Link the window into the siblings list */
2444  if ((Cs->style & (WS_CHILD | WS_MAXIMIZE)) == WS_CHILD)
2446  else
2447  IntLinkHwnd(Window, hwndInsertAfter);
2448  }
2449 
2450  /* Send the WM_NCCALCSIZE message */
2451  {
2452  // RECT rc;
2453  MaxPos.x = Window->rcWindow.left;
2454  MaxPos.y = Window->rcWindow.top;
2455 
2456  Result = co_WinPosGetNonClientSize(Window, &Window->rcWindow, &Window->rcClient);
2457  //rc = Window->rcWindow;
2458  //Result = co_IntSendMessageNoWait(Window->head.h, WM_NCCALCSIZE, FALSE, (LPARAM)&rc);
2459  //Window->rcClient = rc;
2460 
2461  RECTL_vOffsetRect(&Window->rcWindow, MaxPos.x - Window->rcWindow.left,
2462  MaxPos.y - Window->rcWindow.top);
2463  }
2464 
2465  /* Send the WM_CREATE message. */
2467  if (Result == (LRESULT)-1)
2468  {
2469  ERR("co_UserCreateWindowEx(): WM_CREATE message failed\n");
2470  goto cleanup;
2471  }
2472 
2473  /* Send the EVENT_OBJECT_CREATE event */
2474  IntNotifyWinEvent(EVENT_OBJECT_CREATE, Window, OBJID_WINDOW, CHILDID_SELF, 0);
2475 
2476  /* By setting the flag below it can be examined to determine if the window
2477  was created successfully and a valid pwnd was passed back to caller since
2478  from here the function has to succeed. */
2480 
2481  /* Send the WM_SIZE and WM_MOVE messages. */
2482  if (!(Window->state & WNDS_SENDSIZEMOVEMSGS))
2483  {
2485  }
2486 
2487  /* Show or maybe minimize or maximize the window. */
2488 
2490  if (style & (WS_MINIMIZE | WS_MAXIMIZE))
2491  {
2492  RECTL NewPos;
2493  UINT SwFlag = (style & WS_MINIMIZE) ? SW_MINIMIZE : SW_MAXIMIZE;
2494 
2495  SwFlag = co_WinPosMinMaximize(Window, SwFlag, &NewPos);
2496  SwFlag |= SWP_NOZORDER|SWP_FRAMECHANGED; /* Frame always gets changed */
2497  if (!(style & WS_VISIBLE) || (style & WS_CHILD) || UserGetActiveWindow() ||
2498  (Window->ExStyle & WS_EX_NOACTIVATE))
2499  {
2500  SwFlag |= SWP_NOACTIVATE;
2501  }
2502  co_WinPosSetWindowPos(Window, 0, NewPos.left, NewPos.top,
2503  NewPos.right, NewPos.bottom, SwFlag);
2504  }
2505 
2506  /* Send the WM_PARENTNOTIFY message */
2508 
2509  /* Notify the shell that a new window was created */
2510  if (Window->spwndOwner == NULL ||
2511  !(Window->spwndOwner->style & WS_VISIBLE) ||
2512  (Window->spwndOwner->ExStyle & WS_EX_TOOLWINDOW))
2513  {
2514  if (UserIsDesktopWindow(Window->spwndParent) &&
2515  (Window->style & WS_VISIBLE) &&
2516  (!(Window->ExStyle & WS_EX_TOOLWINDOW) ||
2517  (Window->ExStyle & WS_EX_APPWINDOW)))
2518  {
2520  }
2521  }
2522 
2523  /* Initialize and show the window's scrollbars */
2524  if (Window->style & WS_VSCROLL)
2525  {
2527  }
2528  if (Window->style & WS_HSCROLL)
2529  {
2531  }
2532 
2533  /* Show the new window */
2534  if (Cs->style & WS_VISIBLE)
2535  {
2536  if (Window->style & WS_MAXIMIZE)
2537  dwShowMode = SW_SHOW;
2538  else if (Window->style & WS_MINIMIZE)
2539  dwShowMode = SW_SHOWMINIMIZED;
2540 
2541  co_WinPosShowWindow(Window, dwShowMode);
2542 
2543  if (Window->ExStyle & WS_EX_MDICHILD)
2544  {
2545  ASSERT(ParentWindow);
2546  if(!ParentWindow)
2547  goto cleanup;
2548  co_IntSendMessage(UserHMGetHandle(ParentWindow), WM_MDIREFRESHMENU, 0, 0);
2549  /* ShowWindow won't activate child windows */
2551  }
2552  }
2553 
2554  if (Class->atomClassName == gaGuiConsoleWndClass)
2555  {
2556  /* Count only console windows manually */
2558  }
2559 
2560  TRACE("co_UserCreateWindowEx(): Created window %p\n", hWnd);
2561  ret = Window;
2562 
2563 cleanup:
2564  if (!ret)
2565  {
2566  TRACE("co_UserCreateWindowEx(): Error Created window!\n");
2567  /* If the window was created, the class will be dereferenced by co_UserDestroyWindow */
2568  if (Window)
2570  else if (Class)
2571  IntDereferenceClass(Class, pti->pDeskInfo, pti->ppi);
2572  }
2573 
2574  if (pCsw) ExFreePoolWithTag(pCsw, TAG_HOOK);
2575  if (pCbtCreate) ExFreePoolWithTag(pCbtCreate, TAG_HOOK);
2576  if (pszName) UserHeapFree(pszName);
2577  if (pszClass) UserHeapFree(pszClass);
2578 
2579  if (Window)
2580  {
2582  }
2583  if (ParentWindow) UserDerefObjectCo(ParentWindow);
2584 
2585  // See CORE-13717, not setting error on success.
2586  if (ret)
2588 
2589  return ret;
2590 }
#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:1429
LPCREATESTRUCTW lpcs
Definition: winuser.h:2965
#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:1748
PSERVERINFO gpsi
Definition: imm.c:18
#define OBJID_WINDOW
Definition: winable.h:15
HWND hWnd
Definition: settings.c:17
#define ICLS_DESKTOP
Definition: ntuser.h:924
#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:951
#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:604
#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:1673
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
struct _DESKTOP * rpdesk
Definition: win32.h:92
DWORD dwLayout
Definition: win32.h:279
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:801
PPROCESSINFO ppi
Definition: win32.h:88
HWND hwndInsertAfter
Definition: winuser.h:2966
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:560
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 WS_EX_NOACTIVATE
Definition: winuser.h:395
#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:933
BOOLEAN FASTCALL co_WinPosShowWindow(PWND Wnd, INT Cmd)
Definition: winpos.c:2518
BOOLEAN co_UserDestroyWindow(PVOID Object)
Definition: window.c:2845
HINSTANCE hInstance
Definition: winuser.h:2946
#define UserHMGetHandle(obj)
Definition: ntuser.h:230
#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:2333
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WNDS2_WMCREATEMSGPROCESSED
Definition: ntuser.h:665
#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:2954
#define SWP_FRAMECHANGED
Definition: winuser.h:1230
#define SWP_NOSIZE
Definition: winuser.h:1235
#define ERR(fmt,...)
Definition: debug.h:110
Definition: ntuser.h:688
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:1816
#define WNDS2_WIN31COMPAT
Definition: ntuser.h:644
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:2367
VOID IntDereferenceClass(IN OUT PCLS Class, IN PDESKTOPINFO Desktop, IN PPROCESSINFO pi)
Definition: class.c:815
#define WM_CREATE
Definition: winuser.h:1598
LPCWSTR lpszClass
Definition: winuser.h:2955
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:93
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:1451
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1055
LRESULT FASTCALL co_WinPosGetNonClientSize(PWND Window, RECT *WindowRect, RECT *ClientRect)
Definition: winpos.c:2318
#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 2845 of file window.c.

2846 {
2847  HWND hWnd;
2848  PWND pwndTemp;
2849  PTHREADINFO ti;
2850  MSG msg;
2851  PWND Window = Object;
2852 
2853  ASSERT_REFS_CO(Window); // FIXME: Temp HACK?
2854 
2855  hWnd = Window->head.h;
2857 
2858  TRACE("co_UserDestroyWindow(Window = 0x%p, hWnd = 0x%p)\n", Window, hWnd);
2859 
2860  /* Check for owner thread */
2861  if (Window->head.pti != ti)
2862  {
2863  /* Check if we are destroying the desktop window */
2864  if (! ((Window->head.rpdesk->dwDTFlags & DF_DESTROYED) && Window == Window->head.rpdesk->pDeskInfo->spwnd))
2865  {
2867  return FALSE;
2868  }
2869  }
2870 
2871  /* If window was created successfully and it is hooked */
2872  if ((Window->state2 & WNDS2_WMCREATEMSGPROCESSED))
2873  {
2875  {
2876  ERR("Destroy Window WH_CBT Call Hook return!\n");
2877  return FALSE;
2878  }
2879  }
2880 
2881  if (Window->pcls->atomClassName != gpsi->atomSysClass[ICLS_IME])
2882  {
2883  if ((Window->style & (WS_POPUP|WS_CHILD)) != WS_CHILD)
2884  {
2885  if (Window->spwndOwner)
2886  {
2887  //ERR("DestroyWindow Owner out.\n");
2888  UserAttachThreadInput(Window->head.pti, Window->spwndOwner->head.pti, FALSE);
2889  }
2890  }
2891  }
2892 
2893  /* Inform the parent */
2894  if (Window->style & WS_CHILD)
2895  {
2897  }
2898 
2899  if (!Window->spwndOwner && !IntGetParent(Window))
2900  {
2902  }
2903 
2904  /* Hide the window */
2905  if (Window->style & WS_VISIBLE)
2906  {
2907  if (Window->style & WS_CHILD)
2908  {
2909  /* Only child windows receive WM_SHOWWINDOW in DestroyWindow() */
2911  }
2912  else
2913  {
2915  }
2916  }
2917 
2918  /* Adjust last active */
2919  if ((pwndTemp = Window->spwndOwner))
2920  {
2921  while (pwndTemp->spwndOwner)
2922  pwndTemp = pwndTemp->spwndOwner;
2923 
2924  if (pwndTemp->spwndLastActive == Window)
2925  pwndTemp->spwndLastActive = Window->spwndOwner;
2926  }
2927 
2928  if (Window->spwndParent && IntIsWindow(UserHMGetHandle(Window)))
2929  {
2930  if ((Window->style & (WS_POPUP | WS_CHILD)) == WS_CHILD)
2931  {
2933  {
2934  //ERR("DestroyWindow Parent out.\n");
2935  UserAttachThreadInput(Window->head.pti, Window->spwndParent->head.pti, FALSE);
2936  }
2937  }
2938  }
2939 
2940  if (Window->head.pti->MessageQueue->spwndActive == Window)
2941  Window->head.pti->MessageQueue->spwndActive = NULL;
2942  if (Window->head.pti->MessageQueue->spwndFocus == Window)
2943  Window->head.pti->MessageQueue->spwndFocus = NULL;
2944  if (Window->head.pti->MessageQueue->spwndActivePrev == Window)
2945  Window->head.pti->MessageQueue->spwndActivePrev = NULL;
2946  if (Window->head.pti->MessageQueue->spwndCapture == Window)
2947  Window->head.pti->MessageQueue->spwndCapture = NULL;
2948 
2949  /*
2950  * Check if this window is the Shell's Desktop Window. If so set hShellWindow to NULL
2951  */
2952 
2953  if ((ti != NULL) && (ti->pDeskInfo != NULL))
2954  {
2955  if (ti->pDeskInfo->hShellWindow == hWnd)
2956  {
2957  ERR("Destroying the ShellWindow!\n");
2958  ti->pDeskInfo->hShellWindow = NULL;
2959  }
2960  }
2961 
2963 
2965  {
2966  return TRUE;
2967  }
2968 
2969  /* Recursively destroy owned windows */
2970  if (!(Window->style & WS_CHILD))
2971  {
2973  }
2974 
2975  /* Generate mouse move message for the next window */
2976  msg.message = WM_MOUSEMOVE;
2977  msg.wParam = UserGetMouseButtonsState();
2978  msg.lParam = MAKELPARAM(gpsi->ptCursor.x, gpsi->ptCursor.y);
2979  msg.pt = gpsi->ptCursor;
2981 
2982  IntNotifyWinEvent(EVENT_OBJECT_DESTROY, Window, OBJID_WINDOW, CHILDID_SELF, 0);
2983 
2984  /* Send destroy messages */
2986 
2987  // Destroy the default IME window if necessary
2988  if (IS_IMM_MODE() && !(ti->TIF_flags & TIF_INCLEANUP) &&
2989  ti->spwndDefaultIme && !IS_WND_IMELIKE(Window) && !(Window->state & WNDS_DESTROYED))
2990  {
2991  if (IS_WND_CHILD(Window))
2992  {
2995  }
2996  else
2997  {
3000  }
3001  }
3002 
3004  {
3005  return TRUE;
3006  }
3007 
3008  /* Destroy the window storage */
3010 
3011  return TRUE;
3012 }
#define IS_WND_CHILD(pWnd)
Definition: window.h:107
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 IS_IMM_MODE()
Definition: ntuser.h:1232
#define ASSERT_REFS_CO(_obj_)
Definition: userfuncs.h:14
FLONG TIF_flags
Definition: win32.h:95
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:3998
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:1748
PSERVERINFO gpsi
Definition: imm.c:18
#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:710
struct _WND * spwndDefaultIme
Definition: win32.h:131
#define WH_CBT
Definition: winuser.h:35
BOOL FASTCALL IntImeCanDestroyDefIME(PWND pImeWnd, PWND pwndTarget)
Definition: ime.c:2072
#define WM_DESTROY
Definition: winuser.h:1599
BOOL FASTCALL IntImeCanDestroyDefIMEforChild(PWND pImeWnd, PWND pwndTarget)
Definition: ime.c:2027
BOOLEAN FASTCALL co_WinPosShowWindow(PWND Wnd, INT Cmd)
Definition: winpos.c:2518
BOOLEAN co_UserDestroyWindow(PVOID Object)
Definition: window.c:2845
#define UserHMGetHandle(obj)
Definition: ntuser.h:230
#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:665
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:922
_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:688
VOID FASTCALL IntDestroyOwnedWindows(PWND Window)
Definition: window.c:2802
struct _WND * spwndLastActive
Definition: ntuser.h:734
#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:1765
#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:113
#define SWP_NOMOVE
Definition: winuser.h:1234
struct _DESKTOPINFO * pDeskInfo
Definition: win32.h:93
#define WS_VISIBLE
Definition: pedump.c:620
#define WNDS_DESTROYED
Definition: ntuser.h:631
static void IntSendParentNotify(PWND pWindow, UINT msg)
Definition: window.c:1678
#define TIF_INCLEANUP
Definition: ntuser.h:262
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:28
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1055

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:1530
#define IntWndBelongsToThread(WndObj, W32Thread)
Definition: window.h:31
#define TRUE
Definition: types.h:120
#define IS_IMM_MODE()
Definition: ntuser.h:1232
#define WNDS_SENDNCPAINT
Definition: ntuser.h:611
BOOL FASTCALL IntDestroyMenuObject(PMENU Menu, BOOL bRecurse)
Definition: menu.c:319
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:356
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:230
#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:1674
VOID FASTCALL MsqDecPaintCountQueue(PTHREADINFO pti)
Definition: msgqueue.c:508
#define FNID_FREED
Definition: ntuser.h:895
#define RDW_VALIDATE
Definition: winuser.h:1208
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1446
#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:688
BOOL FASTCALL co_UserRedrawWindow(PWND Window, const RECTL *UpdateRect, PREGION UpdateRgn, ULONG Flags)
Definition: painting.c:888
BOOL FASTCALL IntDestroyScrollBars(PWND)
Definition: scrollbar.c:898
#define WS_POPUP
Definition: pedump.c:616
#define NULL
Definition: types.h:112
#define WNDS_INTERNALPAINT
Definition: ntuser.h:612
#define WNDS_SENDERASEBACKGROUND
Definition: ntuser.h:609
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:631
VOID APIENTRY MsqRemoveWindowMessagesFromQueue(PWND Window)
Definition: msgqueue.c:798
#define WNDS2_INDESTROY
Definition: ntuser.h:643
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:688
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 4014 of file window.c.

4015 {
4016  return (LONG)co_IntSetWindowLongPtr(hWnd, Index, NewValue, Ansi, sizeof(LONG), FALSE);
4017 }
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:3819
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 4020 of file window.c.

4021 {
4022  return co_IntSetWindowLongPtr(hWnd, Index, NewValue, Ansi, sizeof(LONG_PTR), FALSE);
4023 }
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:3819
_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 4378 of file window.c.

4379 {
4381  BOOL Ret = FALSE;
4382 
4383  RtlInitUnicodeString(&UnicodeString, WindowText);
4384 
4385  if (UnicodeString.Length != 0)
4386  {
4387  if (Wnd->strName.MaximumLength > 0 &&
4388  UnicodeString.Length <= Wnd->strName.MaximumLength - sizeof(UNICODE_NULL))
4389  {
4390  ASSERT(Wnd->strName.Buffer != NULL);
4391 
4392  Wnd->strName.Length = UnicodeString.Length;
4393  Wnd->strName.Buffer[UnicodeString.Length / sizeof(WCHAR)] = L'\0';
4395  UnicodeString.Buffer,
4396  UnicodeString.Length);
4397  }
4398  else
4399  {
4400  PWCHAR buf;
4401  Wnd->strName.MaximumLength = Wnd->strName.Length = 0;
4402  buf = Wnd->strName.Buffer;
4403  Wnd->strName.Buffer = NULL;
4404  if (buf != NULL)
4405  {
4406  DesktopHeapFree(Wnd->head.rpdesk, buf);
4407  }
4408 
4410  UnicodeString.Length + sizeof(UNICODE_NULL));
4411  if (Wnd->strName.Buffer != NULL)
4412  {
4413  Wnd->strName.Buffer[UnicodeString.Length / sizeof(WCHAR)] = L'\0';
4415  UnicodeString.Buffer,
4416  UnicodeString.Length);
4417  Wnd->strName.MaximumLength = UnicodeString.Length + sizeof(UNICODE_NULL);
4418  Wnd->strName.Length = UnicodeString.Length;
4419  }
4420  else
4421  {
4423  goto Exit;
4424  }
4425  }
4426  }
4427  else
4428  {
4429  Wnd->strName.Length = 0;
4430  if (Wnd->strName.Buffer != NULL)
4431  Wnd->strName.Buffer[0] = L'\0';
4432  }
4433 
4434  // FIXME: HAX! Windows does not do this in here!
4435  // In User32, these are called after: NotifyWinEvent EVENT_OBJECT_NAMECHANGE than
4436  // RepaintButton, StaticRepaint, NtUserCallHwndLock HWNDLOCK_ROUTINE_REDRAWFRAMEANDHOOK, etc.
4437  /* Send shell notifications */
4438  if (!Wnd->spwndOwner && !IntGetParent(Wnd))
4439  {
4440  co_IntShellHookNotify(HSHELL_REDRAW, (WPARAM) UserHMGetHandle(Wnd), FALSE); // FIXME Flashing?
4441  }
4442 
4443  Ret = TRUE;
4444 Exit:
4446  return Ret;
4447 }
struct _DESKTOP * rpdesk
Definition: ntuser.h:194
#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:710
THRDESKHEAD head
Definition: ntuser.h:690
LARGE_UNICODE_STRING strName
Definition: ntuser.h:731
#define UserHMGetHandle(obj)
Definition: ntuser.h:230
#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 3808 of file window.c.

3809 {
3811  return TRUE;
3812  else if (!(ExStyle & WS_EX_STATICEDGE) && (Style & (WS_DLGFRAME | WS_THICKFRAME)))
3813  return TRUE;
3814  else
3815  return FALSE;
3816 }
#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)
2057  {
2058  HWND hImeWnd;
2060  UserRefObjectCo(pwndDefaultIme, &Ref);
2061 
2062  hImeWnd = UserHMGetHandle(pwndDefaultIme);
2063 
2065 
2066  if (pti->pClientInfo->CI_flags & CI_IMMACTIVATE)
2067  {
2068  HKL hKL = pti->KeyboardLayout->hkl;
2070  pti->pClientInfo->CI_flags &= ~CI_IMMACTIVATE;
2071  }
2072 
2073  UserDerefObjectCo(pwndDefaultIme);
2074  }
2075  }
2076 
2077  /* Correct the window style. */
2078  if ((pWnd->style & (WS_CHILD | WS_POPUP)) != WS_CHILD)
2079  {
2080  pWnd->style |= WS_CLIPSIBLINGS;
2081  if (!(pWnd->style & WS_POPUP))
2082  {
2083  pWnd->style |= WS_CAPTION;
2084  }
2085  }
2086 
2087  /* WS_EX_WINDOWEDGE depends on some other styles */
2088  if (pWnd->ExStyle & WS_EX_DLGMODALFRAME)
2089  pWnd->ExStyle |= WS_EX_WINDOWEDGE;
2090  else if (pWnd->style & (WS_DLGFRAME | WS_THICKFRAME))
2091  {
2092  if (!((pWnd->ExStyle & WS_EX_STATICEDGE) &&
2093  (pWnd->style & (WS_CHILD | WS_POPUP))))
2094  pWnd->ExStyle |= WS_EX_WINDOWEDGE;
2095  }
2096  else
2097  pWnd->ExStyle &= ~WS_EX_WINDOWEDGE;
2098 
2099  if (!(pWnd->style & (WS_CHILD | WS_POPUP)))
2100  pWnd->state |= WNDS_SENDSIZEMOVEMSGS;
2101 
2102  /* Set the window menu */
2103  if ((Cs->style & (WS_CHILD | WS_POPUP)) != WS_CHILD)
2104  {
2105  if (Cs->hMenu)
2106  {
2107  IntSetMenu(pWnd, Cs->hMenu, &MenuChanged);
2108  }
2109  else if (pWnd->pcls->lpszMenuName) // Take it from the parent.
2110  {
2111  UNICODE_STRING MenuName;
2112  HMENU hMenu;
2113 
2114  if (IS_INTRESOURCE(pWnd->pcls->lpszMenuName))
2115  {
2116  MenuName.Length = 0;
2117  MenuName.MaximumLength = 0;
2118  MenuName.Buffer = pWnd->pcls->lpszMenuName;
2119  }
2120  else
2121  {
2122  RtlInitUnicodeString( &MenuName, pWnd->pcls->lpszMenuName);
2123  }
2124  hMenu = co_IntCallLoadMenu( pWnd->pcls->hModule, &MenuName);
2125  if (hMenu) IntSetMenu(pWnd, hMenu, &MenuChanged);
2126  }
2127  }
2128  else // Not a child
2129  pWnd->IDMenu = (UINT_PTR)Cs->hMenu;
2130 
2131 
2132  if ( ParentWindow &&
2133  ParentWindow != ParentWindow->head.rpdesk->spwndMessage &&
2134  ParentWindow != ParentWindow->head.rpdesk->pDeskInfo->spwnd )
2135  {
2136  PWND Owner = IntGetNonChildAncestor(ParentWindow);
2137 
2138  if (!IntValidateOwnerDepth(pWnd, Owner))
2139  {
2141  goto Error;
2142  }
2143  if ( pWnd->spwndOwner &&
2144  pWnd->spwndOwner->ExStyle & WS_EX_TOPMOST )
2145  {
2146  pWnd->ExStyle |= WS_EX_TOPMOST;
2147  }
2148  if ( pWnd->spwndOwner &&
2149  Class->atomClassName != gpsi->atomSysClass[ICLS_IME] &&
2150  pti != pWnd->spwndOwner->head.pti)
2151  {
2152  //ERR("CreateWindow Owner in.\n");
2153  UserAttachThreadInput(pti, pWnd->spwndOwner->head.pti, TRUE);
2154  }
2155  }
2156 
2157  /* Insert the window into the thread's window list. */
2159 
2160  /* Handle "CS_CLASSDC", it is tested first. */
2161  if ( (pWnd->pcls->style & CS_CLASSDC) && !(pWnd->pcls->pdce) )
2162  { /* One DCE per class to have CLASS. */
2163  pWnd->pcls->pdce = DceAllocDCE( pWnd, DCE_CLASS_DC );
2164  }
2165  else if ( pWnd->pcls->style & CS_OWNDC)
2166  { /* Allocate a DCE for this window. */
2167  DceAllocDCE(pWnd, DCE_WINDOW_DC);
2168  }
2169 
2170  return pWnd;
2171 
2172 AllocError:
2173  ERR("IntCreateWindow Allocation Error.\n");
2175 Error:
2176  if(pWnd)
2177  UserDereferenceObject(pWnd);
2178  return NULL;
2179 }
#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:699
static HICON
Definition: imagelist.c:84
UINT HideFocus
Definition: ntuser.h:753
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define IMAGE_ICON
Definition: winuser.h:212
#define ICLS_MDICLIENT
Definition: ntuser.h:913
LIST_ENTRY ThreadListEntry
Definition: ntuser.h:759
WNDPROC pfnClientPrevious
Definition: ntuser.h:547
struct _DESKTOP * rpdesk
Definition: ntuser.h:194
struct tagIMC * spDefaultImc
Definition: win32.h:132
#define LAYOUT_RTL
Definition: wingdi.h:1371
ULONG PropListItems
Definition: ntuser.h:719
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:901
#define TRUE
Definition: types.h:120
#define CURSORF_FROMRESOURCE
Definition: ntuser.h:1194
LIST_ENTRY WindowListHead
Definition: win32.h:155
HINSTANCE hModule
Definition: ntuser.h:703
#define IS_IMM_MODE()
Definition: ntuser.h:1232
static __inline BOOL IsCallProcHandle(IN WNDPROC lpWndProc)
Definition: class.h:13
WNDPROC lpfnWndProc
Definition: ntuser.h:713
BOOL FASTCALL IntValidateOwnerDepth(PWND Wnd, PWND Owner)
Definition: window.c:362
HINSTANCE hModule
Definition: ntuser.h:579
#define WINVER_WIN2K
Definition: window.h:55
#define ICLS_EDIT
Definition: ntuser.h:908
PSERVERINFO gpsi
Definition: imm.c:18
LIST_ENTRY PropListHead
Definition: ntuser.h:718
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:604
#define WS_CHILD
Definition: pedump.c:617
#define CS_OWNDC
Definition: winuser.h:650
HIMC hImc
Definition: ntuser.h:735
#define InsertTailList(ListHead, Entry)
if(dx==0 &&dy==0)
Definition: linetemp.h:174
struct _DESKTOP * rpdesk
Definition: win32.h:92
#define WINVER_WINNT4
Definition: window.h:56
#define ICLS_DIALOG
Definition: ntuser.h:925
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:1964
DWORD dwLayout
Definition: win32.h:279
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:801
PPROCESSINFO ppi
Definition: win32.h:88
PCALLPROCDATA CreateCallProc(IN PDESKTOP Desktop, IN WNDPROC WndProc, IN BOOL Unicode, IN PPROCESSINFO pi)
Definition: callproc.c:29
WNDPROC lpfnWndProc
Definition: ntuser.h:576
PTHREADINFO gptiDesktopThread
Definition: desktop.c:37
ULONG cbwndExtra
Definition: ntuser.h:733
#define ICLS_LISTBOX
Definition: ntuser.h:910
DWORD CSF_flags
Definition: ntuser.h:568
#define CSF_CACHEDSMICON
Definition: ntuser.h:557
#define L(x)
Definition: ntvdm.h:50
UINT style
Definition: ntuser.h:575
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:704
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CURSORF_LRSHARED
Definition: ntuser.h:1196
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:864
struct _WND::@4896 InternalPos
struct _WND * spwndOwner
Definition: ntuser.h:710
THRDESKHEAD head
Definition: ntuser.h:690
Definition: object.h:3
BOOL FASTCALL IntWantImeWindow(PWND pwndTarget)
Definition: ime.c:1924
#define WS_EX_DLGMODALFRAME
Definition: pedump.c:645
LONG_PTR LPARAM
Definition: windef.h:208
struct _WND * spwndDefaultIme
Definition: win32.h:131
PVOID pdce
Definition: ntuser.h:567
#define WM_IME_SYSTEM
Definition: undocuser.h:60
LARGE_UNICODE_STRING strName
Definition: ntuser.h:731
#define ICLS_STATIC
Definition: ntuser.h:909
UINT HideAccel
Definition: ntuser.h:754
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:208
HINSTANCE hInstance
Definition: winuser.h:2946
#define UserHMGetHandle(obj)
Definition: ntuser.h:230
#define WS_CAPTION
Definition: pedump.c:624
UINT_PTR IDMenu
Definition: ntuser.h:726
#define TRACE(s)
Definition: solgame.cpp:4
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
#define IMS_LOADTHREADLAYOUT
Definition: immdev.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
ULONG Length
Definition: ntuser.h:91
DWORD fnid
Definition: ntuser.h:565
#define WS_EX_NOINHERITLAYOUT
Definition: winuser.h:396
BOOL Error
Definition: chkdsk.c:66
struct _CLIENTINFO * pClientInfo
Definition: win32.h:94
#define SM_CXSMICON
Definition: winuser.h:1006
#define IMS_ACTIVATELAYOUT
Definition: immdev.h:40
#define CSF_SERVERSIDEPROC
Definition: ntuser.h:551
#define WNDS2_WIN50COMPAT
Definition: ntuser.h:646
#define ICLS_IME
Definition: ntuser.h:922
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1446
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:454
#define GETPFNCLIENTA(fnid)
Definition: ntuser.h:899
#define WS_EX_TOPMOST
Definition: pedump.c:647
#define CSF_ANSIPROC
Definition: ntuser.h:552
UINT_PTR HKL
Definition: msctf.idl:101
#define ICLS_COMBOLBOX
Definition: ntuser.h:914
struct tagKL * KeyboardLayout
Definition: win32.h:90
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:37
INT cbwndExtra
Definition: ntuser.h:578
VOID UserAddCallProcToClass(IN OUT PCLS Class, IN PCALLPROCDATA CallProc)
Definition: class.c:423
PWSTR lpszMenuName
Definition: ntuser.h:583
#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:688
#define FNID_GHOST
Definition: ntuser.h:870
#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:734
#define CI_IMMACTIVATE
Definition: ntuser.h:305
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define WNDS_ANSIWINDOWPROC
Definition: ntuser.h:619
#define FNID_BUTTON
Definition: ntuser.h:861
DWORD state
Definition: ntuser.h:696
#define WNDS2_WIN31COMPAT
Definition: ntuser.h:644
#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:1597
#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:708
DWORD state2
Definition: ntuser.h:697
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define ICLS_BUTTON
Definition: ntuser.h:907
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
PVOID pActCtx
Definition: ntuser.h:737
#define WNDS2_WIN40COMPAT
Definition: ntuser.h:645
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:629
BOOL FASTCALL IntSetMenu(PWND Wnd, HMENU Menu, BOOL *Changed)
Definition: menu.c:5459
#define WNDS_SERVERSIDEWINDOWPROC
Definition: ntuser.h:618
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:751
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:28
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1055
PCLS pcls
Definition: ntuser.h:715
DWORD style
Definition: ntuser.h:701
#define ICLS_COMBOBOX
Definition: ntuser.h:912

Referenced by co_UserCreateWindowEx(), and IntCreateDesktop().

◆ IntDestroyOwnedWindows()

VOID FASTCALL IntDestroyOwnedWindows ( PWND  Window)

Definition at line 2802 of file window.c.

2803 {
2804  HWND* List;
2805  HWND* phWnd;
2806  PWND pWnd;
2807  PTHREADINFO pti = Window->head.pti;
2809 
2811  if (!List)
2812  return;
2813 
2814  for (phWnd = List; *phWnd; ++phWnd)
2815  {
2816  pWnd = ValidateHwndNoErr(*phWnd);
2817  if (pWnd == NULL)
2818  continue;
2819  ASSERT(pWnd->spwndOwner == Window);
2820  ASSERT(pWnd != Window);
2821 
2822  if (IS_IMM_MODE() && !(pti->TIF_flags & TIF_INCLEANUP) &&
2823  pWnd == pti->spwndDefaultIme)
2824  {
2825  continue;
2826  }
2827 
2828  pWnd->spwndOwner = NULL;
2830  {
2831  UserRefObjectCo(pWnd, &Ref); // Temp HACK?
2832  co_UserDestroyWindow(pWnd);
2833  UserDerefObjectCo(pWnd); // Temp HACK?
2834  }
2835  else
2836  {
2837  ERR("IntWndBelongsToThread(0x%p) is FALSE, ignoring.\n", pWnd);
2838  }
2839  }
2840 
2842 }
PWND FASTCALL ValidateHwndNoErr(HWND hWnd)
Definition: window.c:118
#define IntWndBelongsToThread(WndObj, W32Thread)
Definition: window.h:31
#define IS_IMM_MODE()
Definition: ntuser.h:1232
FLONG TIF_flags
Definition: win32.h:95
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:710
Definition: object.h:3
struct _WND * spwndDefaultIme
Definition: win32.h:131
BOOLEAN co_UserDestroyWindow(PVOID Object)
Definition: window.c:2845
#define ASSERT(a)
Definition: mode.c:44
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
#define ERR(fmt,...)
Definition: debug.h:110
Definition: ntuser.h:688
#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:262

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:1314
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:1605
#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:1625
Definition: ntuser.h:688
_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:701

Referenced by NtUserCallTwoParam(), and NtUserEnableScrollBar().

◆ IntFindWindow()

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

Definition at line 3048 of file window.c.

3052 {
3053  BOOL CheckWindowName;
3054  HWND *List, *phWnd;
3055  HWND Ret = NULL;
3056  UNICODE_STRING CurrentWindowName;
3057 
3058  ASSERT(Parent);
3059 
3060  CheckWindowName = WindowName->Buffer != 0;
3061 
3062  if((List = IntWinListChildren(Parent)))
3063  {
3064  phWnd = List;
3065  if(ChildAfter)
3066  {
3067  /* skip handles before and including ChildAfter */
3068  while(*phWnd && (*(phWnd++) != ChildAfter->head.h))
3069  ;
3070  }
3071 
3072  /* search children */
3073  while(*phWnd)
3074  {
3075  PWND Child;
3076  if(!(Child = UserGetWindowObject(*(phWnd++))))
3077  {
3078  continue;
3079  }
3080 
3081  /* Do not send WM_GETTEXT messages in the kernel mode version!
3082  The user mode version however calls GetWindowText() which will
3083  send WM_GETTEXT messages to windows belonging to its processes */
3084  if (!ClassAtom || Child->pcls->atomNVClassName == ClassAtom)
3085  {
3086  // FIXME: LARGE_STRING truncated
3087  CurrentWindowName.Buffer = Child->strName.Buffer;
3088  CurrentWindowName.Length = (USHORT)min(Child->strName.Length, MAXUSHORT);
3089  CurrentWindowName.MaximumLength = (USHORT)min(Child->strName.MaximumLength, MAXUSHORT);
3090  if(!CheckWindowName ||
3091  (Child->strName.Length < 0xFFFF &&
3092  !RtlCompareUnicodeString(WindowName, &CurrentWindowName, TRUE)))
3093  {
3094  Ret = Child->head.h;
3095  break;
3096  }
3097  }
3098  }
3100  }
3101 
3102  return Ret;
3103 }
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define TRUE
Definition: types.h:120
_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:690
#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:688
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
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:732
#define USERTAG_WINDOWLIST
Definition: tags.h:298
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

Referenced by IntDefWindowProc(), and NtUserFindWindowEx().

◆ IntFixWindowCoordinates()

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

Definition at line 1697 of file window.c.

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

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:710
#define WS_POPUP
Definition: pedump.c:616
#define NULL
Definition: types.h:112
struct _WND * spwndParent
Definition: ntuser.h:708
DWORD style
Definition: ntuser.h:701

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:710
struct _WND * spwndNext
Definition: ntuser.h:706
#define UserHMGetHandle(obj)
Definition: ntuser.h:230
#define GW_HWNDLAST
Definition: winuser.h:760
#define GW_HWNDFIRST
Definition: winuser.h:759
Definition: ntuser.h:688
#define NULL
Definition: types.h:112
#define GW_OWNER
Definition: winuser.h:761
struct _WND * spwndParent
Definition: ntuser.h:708
struct _WND * spwndChild
Definition: ntuser.h:709
#define GW_HWNDPREV
Definition: winuser.h:757
struct _WND * spwndPrev
Definition: ntuser.h:707

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:18
ATOM atomContextHelpIdProp
Definition: ntuser.h:1062
#define DWORD
Definition: nt_native.h:44
DWORD fnid
Definition: ntuser.h:704
#define FNID_DESKTOP
Definition: ntuser.h:857
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:688
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:865
#define GETPFNSERVER(fnid)
Definition: ntuser.h:904
#define GETPFNCLIENTW(fnid)
Definition: ntuser.h:901
WNDPROC lpfnWndProc
Definition: ntuser.h:713
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:560
#define FNID_SWITCH
Definition: ntuser.h:860
#define ASSERT(a)
Definition: mode.c:44
#define GETPFNCLIENTA(fnid)
Definition: ntuser.h:899
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2896
#define FNID_GHOST
Definition: ntuser.h:870
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:619
#define FNID_BUTTON
Definition: ntuser.h:861
DWORD state
Definition: ntuser.h:696
BOOL FASTCALL UserIsEnteredExclusive(VOID)
Definition: ntuser.c:227
#define ULONG_PTR
Definition: config.h:101
#define WNDS_SERVERSIDEWINDOWPROC
Definition: ntuser.h:618
#define FNID_FIRST
Definition: ntuser.h:853
PCLS pcls
Definition: ntuser.h:715

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
Definition: window.c:28
#define FALSE
Definition: types.h:117
Definition: ntuser.h:688
#define WS_POPUP
Definition: pedump.c:616
#define NULL
Definition: types.h:112
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:732
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:708

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:688
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:126

Referenced by co_IntPaintWindows(), co_UserDestroyWindow(), co_UserSetFocus(), co_WinPosSetWindowPos(), DefWndDoSizeMove(), IntSendDestroyMsg(), IntTrackPopupMenuEx(), NtUserCallHwnd(), 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:704
#define FNID_DESKTOP
Definition: ntuser.h:857
Definition: ntuser.h:688
struct _WND * spwndParent
Definition: ntuser.h:708
#define WS_VISIBLE
Definition: pedump.c:620
DWORD style
Definition: ntuser.h:701

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:699
VOID FASTCALL IntUnlinkWindow(PWND Wnd)
Definition: window.c:1341
DWORD ExStyle2
Definition: ntuser.h:740
#define WS_EX2_LINKED
Definition: ntuser.h:671
#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:710
struct _WND * spwndNext
Definition: ntuser.h:706
#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:688
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:708
#define HWND_NOTOPMOST
Definition: winuser.h:1196
struct _WND * spwndPrev
Definition: ntuser.h:707

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:706
#define ASSERT(a)
Definition: mode.c:44
#define ERR(fmt,...)
Definition: debug.h:110
struct _WND * spwndParent
Definition: ntuser.h:708
struct _WND * spwndPrev
Definition: ntuser.h:707

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:105
HWND * phwndLast
Definition: window.h:87
#define IACE_CHILDREN
Definition: imm.h:581
THRDESKHEAD head
Definition: ntuser.h:690
struct _WND * spwndNext
Definition: ntuser.h:706
#define UserHMGetHandle(obj)
Definition: ntuser.h:230
#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:709
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:690

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:230
#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:1832
#define HTCLIENT
Definition: winuser.h:2465

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:1314
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
HWND hWnd
Definition: settings.c:17