ReactOS  0.4.12-dev-934-g9a4676f
window.c File Reference
#include <win32k.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 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)
 
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)
 
NTSTATUS APIENTRY NtUserBuildHwndList (HDESK hDesktop, HWND hwndParent, BOOLEAN bChildren, ULONG dwThreadId, ULONG lParam, HWND *pWnd, ULONG *pBufSize)
 
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)
 
PWND FASTCALL co_UserCreateWindowEx (CREATESTRUCTW *Cs, PUNICODE_STRING ClassName, PLARGE_STRING WindowName, PVOID acbiBuffer)
 
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)
 
BOOLEAN co_UserDestroyWindow (PVOID Object)
 
BOOLEAN APIENTRY NtUserDestroyWindow (HWND Wnd)
 
static HWND FASTCALL IntFindWindow (PWND Parent, PWND ChildAfter, RTL_ATOM ClassAtom, PUNICODE_STRING WindowName)
 
HWND APIENTRY NtUserFindWindowEx (HWND hwndParent, HWND hwndChildAfter, PUNICODE_STRING ucClassName, PUNICODE_STRING ucWindowName, DWORD dwUnknown)
 
PWND FASTCALL UserGetAncestor (PWND Wnd, UINT Type)
 
HWND APIENTRY NtUserGetAncestor (HWND hWnd, UINT Type)
 
BOOL APIENTRY NtUserGetComboBoxInfo (HWND hWnd, PCOMBOBOXINFO pcbi)
 
DWORD APIENTRY NtUserGetListBoxInfo (HWND hWnd)
 
HWND APIENTRY NtUserSetParent (HWND hWndChild, HWND hWndNewParent)
 
HWND FASTCALL UserGetShellWindow (VOID)
 
BOOL APIENTRY NtUserSetShellWindowEx (HWND hwndShell, HWND hwndListView)
 
static BOOL FASTCALL IntCheckFrameEdge (ULONG Style, ULONG ExStyle)
 
static LONG_PTR co_IntSetWindowLongPtr (HWND hWnd, DWORD Index, LONG_PTR NewValue, BOOL Ansi, ULONG Size, BOOL bAlter)
 
LONG FASTCALL co_UserSetWindowLong (HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi)
 
LONG_PTR FASTCALL co_UserSetWindowLongPtr (HWND hWnd, DWORD Index, LONG_PTR NewValue, BOOL Ansi)
 
LONG APIENTRY NtUserSetWindowLong (HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi)
 
DWORD APIENTRY NtUserAlterWindowStyle (HWND hWnd, DWORD Index, LONG NewValue)
 
WORD APIENTRY NtUserSetWindowWord (HWND hWnd, INT Index, WORD NewValue)
 
DWORD_PTR APIENTRY NtUserQueryWindow (HWND hWnd, DWORD Index)
 
UINT APIENTRY NtUserRegisterWindowMessage (PUNICODE_STRING MessageNameUnsafe)
 
BOOL APIENTRY NtUserSetWindowFNID (HWND hWnd, WORD fnID)
 
BOOL APIENTRY DefSetText (PWND Wnd, PCWSTR WindowText)
 
BOOL APIENTRY NtUserDefSetText (HWND hWnd, PLARGE_STRING WindowText)
 
INT APIENTRY NtUserInternalGetWindowText (HWND hWnd, LPWSTR lpString, INT nMaxCount)
 
BOOL FASTCALL IntShowOwnedPopups (PWND OwnerWnd, BOOL fShow)
 

Variables

INT gNestedWindowLimit = 50
 

Macro Definition Documentation

◆ CBF_BUTTONDOWN

#define CBF_BUTTONDOWN   0x0002

Definition at line 3252 of file window.c.

◆ GWLP_CONSOLE_LEADER_PID

#define GWLP_CONSOLE_LEADER_PID   0

◆ GWLP_CONSOLE_LEADER_TID

#define GWLP_CONSOLE_LEADER_TID   4

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

1110 {
1111  PWND WndOldParent, pWndExam;
1112  BOOL WasVisible;
1113  POINT pt;
1114  int swFlags = SWP_NOSIZE|SWP_NOZORDER;
1115 
1116  ASSERT(Wnd);
1117  ASSERT(WndNewParent);
1118  ASSERT_REFS_CO(Wnd);
1119  ASSERT_REFS_CO(WndNewParent);
1120 
1121  if (Wnd == Wnd->head.rpdesk->spwndMessage)
1122  {
1124  return( NULL);
1125  }
1126 
1127  /* Some applications try to set a child as a parent */
1128  if (IntIsChildWindow(Wnd, WndNewParent))
1129  {
1130  TRACE("IntSetParent try to set a child as a parent.\n");
1132  return NULL;
1133  }
1134 
1135  pWndExam = WndNewParent; // Load parent Window to examine.
1136  // Now test for set parent to parent hit.
1137  while (pWndExam)
1138  {
1139  if (Wnd == pWndExam)
1140  {
1141  TRACE("IntSetParent Failed Test for set parent to parent!\n");
1143  return NULL;
1144  }
1145  pWndExam = pWndExam->spwndParent;
1146  }
1147 
1148  /*
1149  * Windows hides the window first, then shows it again
1150  * including the WM_SHOWWINDOW messages and all
1151  */
1152  WasVisible = co_WinPosShowWindow(Wnd, SW_HIDE);
1153 
1154  /* Window must belong to current process */
1155  if (Wnd->head.pti->ppi != PsGetCurrentProcessWin32Process())
1156  {
1157  ERR("IntSetParent Window must belong to current process!\n");
1158  return NULL;
1159  }
1160 
1161  WndOldParent = Wnd->spwndParent;
1162 
1163  if ( WndOldParent &&
1164  WndOldParent->ExStyle & WS_EX_LAYOUTRTL)
1165  pt.x = Wnd->rcWindow.right;
1166  else
1167  pt.x = Wnd->rcWindow.left;
1168  pt.y = Wnd->rcWindow.top;
1169 
1170  IntScreenToClient(WndOldParent, &pt);
1171 
1172  if (WndOldParent) UserReferenceObject(WndOldParent); /* Caller must deref */
1173 
1174  if (WndNewParent != WndOldParent)
1175  {
1176  /* Unlink the window from the siblings list */
1177  IntUnlinkWindow(Wnd);
1178  Wnd->ExStyle2 &= ~WS_EX2_LINKED;
1179 
1180  /* Set the new parent */
1181  Wnd->spwndParent = WndNewParent;
1182 
1183  if ( Wnd->style & WS_CHILD &&
1184  Wnd->spwndOwner &&
1185  Wnd->spwndOwner->ExStyle & WS_EX_TOPMOST )
1186  {
1187  ERR("SetParent Top Most from Pop up!\n");
1188  Wnd->ExStyle |= WS_EX_TOPMOST;
1189  }
1190 
1191  /* Link the window with its new siblings */
1192  IntLinkHwnd( Wnd,
1193  ((0 == (Wnd->ExStyle & WS_EX_TOPMOST) &&
1194  UserIsDesktopWindow(WndNewParent) ) ? HWND_TOP : HWND_TOPMOST ) );
1195  }
1196 
1197  if ( WndNewParent == co_GetDesktopWindow(Wnd) &&
1198  !(Wnd->style & WS_CLIPSIBLINGS) )
1199  {
1200  Wnd->style |= WS_CLIPSIBLINGS;
1201  DceResetActiveDCEs(Wnd);
1202  }
1203 
1204  /* if parent belongs to a different thread and the window isn't */
1205  /* top-level, attach the two threads */
1206  if ((Wnd->style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
1207  {
1208  if ( Wnd->spwndParent != co_GetDesktopWindow(Wnd))
1209  {
1210  if (WndOldParent && (Wnd->head.pti != WndOldParent->head.pti))
1211  {
1212  //ERR("SetParent Old out.\n");
1213  UserAttachThreadInput(Wnd->head.pti, WndOldParent->head.pti, FALSE);
1214  }
1215  }
1216  if ( WndNewParent != co_GetDesktopWindow(Wnd))
1217  {
1218  if (Wnd->head.pti != WndNewParent->head.pti)
1219  {
1220  //ERR("SetParent New in.\n");
1221  UserAttachThreadInput(Wnd->head.pti, WndNewParent->head.pti, TRUE);
1222  }
1223  }
1224  }
1225 
1226  if (UserIsMessageWindow(WndOldParent) || UserIsMessageWindow(WndNewParent))
1227  swFlags |= SWP_NOACTIVATE;
1228 
1229  IntNotifyWinEvent(EVENT_OBJECT_PARENTCHANGE, Wnd ,OBJID_WINDOW, CHILDID_SELF, WEF_SETBYWNDPTI);
1230  /*
1231  * SetParent additionally needs to make hwnd the top window
1232  * in the z-order and send the expected WM_WINDOWPOSCHANGING and
1233  * WM_WINDOWPOSCHANGED notification messages.
1234  */
1235  //ERR("IntSetParent SetWindowPos 1\n");
1236  co_WinPosSetWindowPos( Wnd,
1237  (0 == (Wnd->ExStyle & WS_EX_TOPMOST) ? HWND_TOP : HWND_TOPMOST),
1238  pt.x, pt.y, 0, 0, swFlags);
1239  //ERR("IntSetParent SetWindowPos 2 X %d Y %d\n",pt.x, pt.y);
1240  if (WasVisible) co_WinPosShowWindow(Wnd, SW_SHOWNORMAL);
1241 
1242  return WndOldParent;
1243 }
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
DWORD ExStyle
Definition: ntuser.h:668
#define TRUE
Definition: types.h:120
struct _DESKTOP * rpdesk
Definition: ntuser.h:189
VOID FASTCALL IntUnlinkWindow(PWND Wnd)
Definition: window.c:1306
DWORD ExStyle2
Definition: ntuser.h:709
NTSTATUS FASTCALL UserAttachThreadInput(PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach)
Definition: input.c:483
#define UserIsDesktopWindow(pWnd)
Definition: desktop.h:220
#define WS_EX2_LINKED
Definition: ntuser.h:644
#define pt(x, y)
Definition: drawing.c:79
#define SW_HIDE
Definition: winuser.h:762
#define ASSERT_REFS_CO(_obj_)
Definition: userfuncs.h:13
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:1651
#define OBJID_WINDOW
Definition: winable.h:15
LONG top
Definition: windef.h:292
#define WS_EX_LAYOUTRTL
Definition: winuser.h:390
#define HWND_TOPMOST
Definition: winuser.h:1194
#define HWND_TOP
Definition: winuser.h:1193
#define WS_CHILD
Definition: pedump.c:617
LONG left
Definition: windef.h:291
#define SWP_NOZORDER
Definition: winuser.h:1232
LONG right
Definition: windef.h:293
VOID FASTCALL IntLinkHwnd(PWND Wnd, HWND hWndPrev)
Definition: window.c:937
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CHILDID_SELF
Definition: winable.h:14
struct _WND * spwndOwner
Definition: ntuser.h:679
THRDESKHEAD head
Definition: ntuser.h:659
smooth NULL
Definition: ftsmooth.c:416
PWND FASTCALL co_GetDesktopWindow(PWND pWnd)
Definition: desktop.c:1330
#define WEF_SETBYWNDPTI
Definition: ntuser.h:213
BOOLEAN FASTCALL co_WinPosShowWindow(PWND Wnd, INT Cmd)
Definition: winpos.c:2393
#define TRACE(s)
Definition: solgame.cpp:4
#define SWP_NOACTIVATE
Definition: winuser.h:1227
#define UserIsMessageWindow(pWnd)
Definition: desktop.h:223
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
VOID FASTCALL DceResetActiveDCEs(PWND Window)
Definition: windc.c:815
#define WS_EX_TOPMOST
Definition: pedump.c:647
BOOL FASTCALL IntScreenToClient(PWND Wnd, LPPOINT lpPoint)
Definition: winpos.c:212
RECT rcWindow
Definition: ntuser.h:680
#define SWP_NOSIZE
Definition: winuser.h:1230
#define ERR(fmt,...)
Definition: debug.h:109
Definition: ntuser.h:657
#define SW_SHOWNORMAL
Definition: winuser.h:764
#define WS_POPUP
Definition: pedump.c:616
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
struct _WND * spwndParent
Definition: ntuser.h:677
BOOL FASTCALL IntIsChildWindow(PWND Parent, PWND BaseWindow)
Definition: window.c:882
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
VOID FASTCALL UserReferenceObject(PVOID obj)
Definition: object.c:697
DWORD style
Definition: ntuser.h:670

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

3621 {
3622  PWND Window, Parent;
3623  PWINSTATION_OBJECT WindowStation;
3624  LONG_PTR OldValue;
3626 
3627  if (!(Window = UserGetWindowObject(hWnd)))
3628  {
3629  return( 0);
3630  }
3631 
3632  if ((INT)Index >= 0)
3633  {
3634  if ((Index + Size) > Window->cbwndExtra)
3635  {
3637  return( 0);
3638  }
3639 
3640 #ifdef _WIN64
3641  if (Size == sizeof(LONG))
3642  {
3643  OldValue = *((LONG *)((PCHAR)(Window + 1) + Index));
3644  *((LONG*)((PCHAR)(Window + 1) + Index)) = (LONG)NewValue;
3645  }
3646  else
3647 #endif
3648  {
3649  OldValue = *((LONG_PTR *)((PCHAR)(Window + 1) + Index));
3650  /*
3651  if ( Index == DWLP_DLGPROC && Wnd->state & WNDS_DIALOGWINDOW)
3652  {
3653  OldValue = (LONG_PTR)IntSetWindowProc( Wnd, (WNDPROC)NewValue, Ansi);
3654  if (!OldValue) return 0;
3655  }
3656  */
3657  *((LONG_PTR*)((PCHAR)(Window + 1) + Index)) = NewValue;
3658  }
3659 
3660  }
3661  else
3662  {
3663 #ifdef _WIN64
3664  if (Size == sizeof(LONG))
3665  {
3666  if ((Index != GWL_STYLE) &&
3667  (Index != GWL_EXSTYLE) &&
3668  (Index != GWL_ID) &&
3669  (Index != GWL_USERDATA))
3670  {
3671  ERR("NtUserSetWindowLong(): Index requires pointer size: %lu\n", Index);
3673  return 0;
3674  }
3675  }
3676 #endif
3677 
3678  switch (Index)
3679  {
3680  case GWL_EXSTYLE: // LONG
3681  OldValue = (LONG) Window->ExStyle;
3682  Style.styleOld = OldValue;
3683  Style.styleNew = NewValue;
3684 
3685  co_IntSendMessage(hWnd, WM_STYLECHANGING, GWL_EXSTYLE, (LPARAM) &Style);
3686 
3687  /*
3688  * Remove extended window style bit WS_EX_TOPMOST for shell windows.
3689  */
3690  WindowStation = Window->head.pti->rpdesk->rpwinstaParent;
3691  if(WindowStation)
3692  {
3693  if (hWnd == WindowStation->ShellWindow || hWnd == WindowStation->ShellListView)
3694  Style.styleNew &= ~WS_EX_TOPMOST;
3695  }
3696  /* WS_EX_WINDOWEDGE depends on some other styles */
3697  if (IntCheckFrameEdge(Window->style, NewValue))
3698  Style.styleNew |= WS_EX_WINDOWEDGE;
3699  else
3700  Style.styleNew &= ~WS_EX_WINDOWEDGE;
3701 
3702  if (!(Window->ExStyle & WS_EX_LAYERED))
3703  {
3705  }
3706 
3707  Window->ExStyle = (DWORD)Style.styleNew;
3708 
3709  co_IntSendMessage(hWnd, WM_STYLECHANGED, GWL_EXSTYLE, (LPARAM) &Style);
3710  break;
3711 
3712  case GWL_STYLE: // LONG
3713  OldValue = (LONG) Window->style;
3714  Style.styleOld = OldValue;
3715  Style.styleNew = NewValue;
3716 
3717  if (!bAlter)
3718  co_IntSendMessage(hWnd, WM_STYLECHANGING, GWL_STYLE, (LPARAM) &Style);
3719 
3720  /* WS_CLIPSIBLINGS can't be reset on top-level windows */
3721  if (UserIsDesktopWindow(Window->spwndParent)) Style.styleNew |= WS_CLIPSIBLINGS;
3722  /* WS_MINIMIZE can't be reset */
3723  if (OldValue & WS_MINIMIZE) Style.styleNew |= WS_MINIMIZE;
3724  /* Fixes wine FIXME: changing WS_DLGFRAME | WS_THICKFRAME is supposed to change WS_EX_WINDOWEDGE too */
3725  if (IntCheckFrameEdge(NewValue, Window->ExStyle))
3726  Window->ExStyle |= WS_EX_WINDOWEDGE;
3727  else
3728  Window->ExStyle &= ~WS_EX_WINDOWEDGE;
3729 
3730  if ((OldValue & (WS_CHILD | WS_POPUP)) == WS_CHILD)
3731  {
3732  if ((NewValue & (WS_CHILD | WS_POPUP)) != WS_CHILD)
3733  {
3735  ERR("IDMenu going null! %d\n",Window->IDMenu);
3736  Window->IDMenu = 0; // Window->spmenu = 0;
3737  }
3738  }
3739  else
3740  {
3741  if ((NewValue & (WS_CHILD | WS_POPUP)) == WS_CHILD)
3742  {
3743  PMENU pMenu = UserGetMenuObject(UlongToHandle(Window->IDMenu));
3744  Window->state &= ~WNDS_HASMENU;
3745  if (pMenu)
3746  {
3747  ERR("IDMenu released 0x%p\n",pMenu);
3748  // ROS may not hold a lock after setting menu to window. But it should!
3749  //IntReleaseMenuObject(pMenu);
3750  }
3751  }
3752  }
3753 
3754  if ((Style.styleOld ^ Style.styleNew) & WS_VISIBLE)
3755  {
3756  if (Style.styleOld & WS_VISIBLE) Window->head.pti->cVisWindows--;
3757  if (Style.styleNew & WS_VISIBLE) Window->head.pti->cVisWindows++;
3759  }
3760  Window->style = (DWORD)Style.styleNew;
3761 
3762  if (!bAlter)
3763  co_IntSendMessage(hWnd, WM_STYLECHANGED, GWL_STYLE, (LPARAM) &Style);
3764  break;
3765 
3766  case GWLP_WNDPROC: // LONG_PTR
3767  {
3768  if ( Window->head.pti->ppi != PsGetCurrentProcessWin32Process() ||
3769  Window->fnid & FNID_FREED)
3770  {
3772  return( 0);
3773  }
3774  OldValue = (LONG_PTR)IntSetWindowProc(Window,
3775  (WNDPROC)NewValue,
3776  Ansi);
3777  break;
3778  }
3779 
3780  case GWLP_HINSTANCE: // LONG_PTR
3781  OldValue = (LONG_PTR) Window->hModule;
3782  Window->hModule = (HINSTANCE) NewValue;
3783  break;
3784 
3785  case GWLP_HWNDPARENT: // LONG_PTR
3786  Parent = Window->spwndParent;
3787  if (Parent && (Parent->head.h == IntGetDesktopWindow()))
3788  OldValue = (LONG_PTR) IntSetOwner(Window->head.h, (HWND) NewValue);
3789  else
3790  OldValue = (LONG_PTR) co_UserSetParent(Window->head.h, (HWND) NewValue);
3791  break;
3792 
3793  case GWLP_ID: // LONG
3794  OldValue = (LONG) Window->IDMenu;
3795  Window->IDMenu = (UINT) NewValue;
3796  break;
3797 
3798  case GWLP_USERDATA: // LONG or LONG_PTR
3799  OldValue = Window->dwUserData;
3800  Window->dwUserData = NewValue;
3801  break;
3802 
3803  default:
3804  ERR("NtUserSetWindowLong(): Unsupported index %lu\n", Index);
3806  OldValue = 0;
3807  break;
3808  }
3809  }
3810 
3811  return( OldValue);
3812 }
#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:220
#define GWL_ID
Definition: winuser.h:853
HWND hWnd
Definition: settings.c:17
#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:795
#define WS_CHILD
Definition: pedump.c:617
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:716
HWND FASTCALL IntSetOwner(HWND hWnd, HWND hWndNewOwner)
Definition: window.c:1061
#define DWORD
Definition: nt_native.h:44
int32_t INT
Definition: typedefs.h:56
HWND FASTCALL co_UserSetParent(HWND hWndChild, HWND hWndNewParent)
Definition: window.c:1246
FORCEINLINE PMENU UserGetMenuObject(HMENU hMenu)
Definition: userfuncs.h:3
Definition: window.c:29
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
#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
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define UlongToHandle(ul)
Definition: basetsd.h:97
#define WS_EX_LAYERED
Definition: winuser.h:389
static const UCHAR Index[8]
Definition: usbohci.c:18
int Window
Definition: x11stubs.h:26
#define FNID_FREED
Definition: ntuser.h:861
VOID FASTCALL DceResetActiveDCEs(PWND Window)
Definition: windc.c:815
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1291
#define WS_EX_TOPMOST
Definition: pedump.c:647
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define GWLP_WNDPROC
Definition: treelist.c:66
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2859
#define ERR(fmt,...)
Definition: debug.h:109
#define GWL_STYLE
Definition: winuser.h:846
Definition: ntuser.h:657
HWND FASTCALL IntGetDesktopWindow(VOID)
Definition: desktop.c:1338
static BOOL FASTCALL IntCheckFrameEdge(ULONG Style, ULONG ExStyle)
Definition: window.c:3609
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
#define WS_POPUP
Definition: pedump.c:616
unsigned int UINT
Definition: ndis.h:50
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
#define ERROR_INVALID_INDEX
Definition: winerror.h:894
#define GWLP_HINSTANCE
Definition: winuser.h:850
BOOL FASTCALL SetLayeredStatus(PWND pWnd, BYTE set)
Definition: layered.c:34
#define WNDS_HASMENU
Definition: ntuser.h:573
#define WS_VISIBLE
Definition: pedump.c:620
HANDLE ShellListView
Definition: winsta.h:21
#define GWLP_ID
Definition: winuser.h:854
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
HANDLE ShellWindow
Definition: winsta.h:20
#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 
)

Definition at line 1956 of file window.c.

1960 {
1961  ULONG style;
1962  PWND Window = NULL, ParentWindow = NULL, OwnerWindow;
1963  HWND hWnd, hWndParent, hWndOwner, hwndInsertAfter;
1964  PWINSTATION_OBJECT WinSta;
1965  PCLS Class = NULL;
1966  SIZE Size;
1967  POINT MaxSize, MaxPos, MinTrack, MaxTrack;
1968  CBT_CREATEWNDW * pCbtCreate;
1969  LRESULT Result;
1970  USER_REFERENCE_ENTRY ParentRef, Ref;
1971  PTHREADINFO pti;
1972  DWORD dwShowMode = SW_SHOW;
1973  CREATESTRUCTW *pCsw = NULL;
1974  PVOID pszClass = NULL, pszName = NULL;
1975  PWND ret = NULL;
1976 
1977  /* Get the current window station and reference it */
1978  pti = GetW32ThreadInfo();
1979  if (pti == NULL || pti->rpdesk == NULL)
1980  {
1981  ERR("Thread is not attached to a desktop! Cannot create window!\n");
1982  return NULL; // There is nothing to cleanup.
1983  }
1984  WinSta = pti->rpdesk->rpwinstaParent;
1986 
1987  pCsw = NULL;
1988  pCbtCreate = NULL;
1989 
1990  /* Get the class and reference it */
1991  Class = IntGetAndReferenceClass(ClassName, Cs->hInstance, FALSE);
1992  if(!Class)
1993  {
1995  ERR("Failed to find class %wZ\n", ClassName);
1996  goto cleanup;
1997  }
1998 
1999  /* Now find the parent and the owner window */
2000  hWndParent = pti->rpdesk->pDeskInfo->spwnd->head.h;
2001  hWndOwner = NULL;
2002 
2003  if (Cs->hwndParent == HWND_MESSAGE)
2004  {
2005  Cs->hwndParent = hWndParent = pti->rpdesk->spwndMessage->head.h;
2006  }
2007  else if (Cs->hwndParent)
2008  {
2009  if ((Cs->style & (WS_CHILD|WS_POPUP)) != WS_CHILD)
2010  hWndOwner = Cs->hwndParent;
2011  else
2012  hWndParent = Cs->hwndParent;
2013  }
2014  else if ((Cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
2015  {
2016  ERR("Cannot create a child window without a parent!\n");
2018  goto cleanup; /* WS_CHILD needs a parent, but WS_POPUP doesn't */
2019  }
2021  (IS_INTRESOURCE(Cs->lpszClass) ||
2022  Cs->lpszClass != (LPCWSTR)MAKEINTATOM(gpsi->atomSysClass[ICLS_HWNDMESSAGE]) ||
2023  _wcsicmp(Cs->lpszClass, L"Message") != 0))
2024  {
2025  if (pti->ppi->dwLayout & LAYOUT_RTL)
2026  {
2027  Cs->dwExStyle |= WS_EX_LAYOUTRTL;
2028  }
2029  }
2030 
2031  ParentWindow = hWndParent ? UserGetWindowObject(hWndParent): NULL;
2032  OwnerWindow = hWndOwner ? UserGetWindowObject(hWndOwner): NULL;
2033 
2034  if (hWndParent && !ParentWindow)
2035  {
2036  ERR("Got invalid parent window handle\n");
2037  goto cleanup;
2038  }
2039  else if (hWndOwner && !OwnerWindow)
2040  {
2041  ERR("Got invalid owner window handle\n");
2042  ParentWindow = NULL;
2043  goto cleanup;
2044  }
2045 
2046  if(OwnerWindow)
2047  {
2048  if (IntIsDesktopWindow(OwnerWindow)) OwnerWindow = NULL;
2049  else if (ParentWindow && !IntIsDesktopWindow(ParentWindow))
2050  {
2051  ERR("an owned window must be created as top-level\n");
2053  goto cleanup;
2054  }
2055  else /* owner must be a top-level window */
2056  {
2057  while ((OwnerWindow->style & (WS_POPUP|WS_CHILD)) == WS_CHILD && !IntIsDesktopWindow(OwnerWindow->spwndParent))
2058  OwnerWindow = OwnerWindow->spwndParent;
2059  }
2060  }
2061 
2062  /* Fix the position and the size of the window */
2063  if (ParentWindow)
2064  {
2065  UserRefObjectCo(ParentWindow, &ParentRef);
2066  IntFixWindowCoordinates(Cs, ParentWindow, &dwShowMode);
2067  }
2068 
2069  /* Allocate and initialize the new window */
2070  Window = IntCreateWindow(Cs,
2071  WindowName,
2072  Class,
2073  ParentWindow,
2074  OwnerWindow,
2075  acbiBuffer,
2076  NULL);
2077  if(!Window)
2078  {
2079  ERR("IntCreateWindow failed!\n");
2080  goto cleanup;
2081  }
2082 
2084  hwndInsertAfter = HWND_TOP;
2085 
2086  UserRefObjectCo(Window, &Ref);
2088  ObDereferenceObject(WinSta);
2089 
2091  if ( ISITHOOKED(WH_CBT) || (pti->rpdesk->pDeskInfo->fsHooks & HOOKID_TO_FLAG(WH_CBT)) )
2092  {
2093  // Allocate the calling structures Justin Case this goes Global.
2096  if (!pCsw || !pCbtCreate)
2097  {
2098  ERR("UserHeapAlloc() failed!\n");
2099  goto cleanup;
2100  }
2101 
2102  /* Fill the new CREATESTRUCTW */
2103  RtlCopyMemory(pCsw, Cs, sizeof(CREATESTRUCTW));
2104  pCsw->style = Window->style; /* HCBT_CREATEWND needs the real window style */
2105 
2106  // Based on the assumption this is from "unicode source" user32, ReactOS, answer is yes.
2107  if (!IS_ATOM(ClassName->Buffer))
2108  {
2109  if (Window->state & WNDS_ANSICREATOR)
2110  {
2112  AnsiString.MaximumLength = (USHORT)RtlUnicodeStringToAnsiSize(ClassName)+sizeof(CHAR);
2113  pszClass = UserHeapAlloc(AnsiString.MaximumLength);
2114  if (!pszClass)
2115  {
2116  ERR("UserHeapAlloc() failed!\n");
2117  goto cleanup;
2118  }
2119  RtlZeroMemory(pszClass, AnsiString.MaximumLength);
2120  AnsiString.Buffer = (PCHAR)pszClass;
2122  }
2123  else
2124  {
2126  UnicodeString.MaximumLength = ClassName->Length + sizeof(UNICODE_NULL);
2127  pszClass = UserHeapAlloc(UnicodeString.MaximumLength);
2128  if (!pszClass)
2129  {
2130  ERR("UserHeapAlloc() failed!\n");
2131  goto cleanup;
2132  }
2133  RtlZeroMemory(pszClass, UnicodeString.MaximumLength);
2134  UnicodeString.Buffer = (PWSTR)pszClass;
2135  RtlCopyUnicodeString(&UnicodeString, ClassName);
2136  }
2137  pCsw->lpszClass = UserHeapAddressToUser(pszClass);
2138  }
2139  if (WindowName->Length)
2140  {
2142  Name.Buffer = WindowName->Buffer;
2143  Name.Length = (USHORT)min(WindowName->Length, MAXUSHORT); // FIXME: LARGE_STRING truncated
2144  Name.MaximumLength = (USHORT)min(WindowName->MaximumLength, MAXUSHORT);
2145 
2146  if (Window->state & WNDS_ANSICREATOR)
2147  {
2149  AnsiString.MaximumLength = (USHORT)RtlUnicodeStringToAnsiSize(&Name) + sizeof(CHAR);
2150  pszName = UserHeapAlloc(AnsiString.MaximumLength);
2151  if (!pszName)
2152  {
2153  ERR("UserHeapAlloc() failed!\n");
2154  goto cleanup;
2155  }
2156  RtlZeroMemory(pszName, AnsiString.MaximumLength);
2157  AnsiString.Buffer = (PCHAR)pszName;
2159  }
2160  else
2161  {
2163  UnicodeString.MaximumLength = Name.Length + sizeof(UNICODE_NULL);
2164  pszName = UserHeapAlloc(UnicodeString.MaximumLength);
2165  if (!pszName)
2166  {
2167  ERR("UserHeapAlloc() failed!\n");
2168  goto cleanup;
2169  }
2170  RtlZeroMemory(pszName, UnicodeString.MaximumLength);
2171  UnicodeString.Buffer = (PWSTR)pszName;
2173  }
2174  pCsw->lpszName = UserHeapAddressToUser(pszName);
2175  }
2176 
2177  pCbtCreate->lpcs = pCsw;
2178  pCbtCreate->hwndInsertAfter = hwndInsertAfter;
2179 
2182  if (Result != 0)
2183  {
2184  ERR("WH_CBT HCBT_CREATEWND hook failed! 0x%x\n", Result);
2185  goto cleanup;
2186  }
2187  // Write back changes.
2188  Cs->cx = pCsw->cx;
2189  Cs->cy = pCsw->cy;
2190  Cs->x = pCsw->x;
2191  Cs->y = pCsw->y;
2192  hwndInsertAfter = pCbtCreate->hwndInsertAfter;
2193  }
2194 
2195  /* NCCREATE and WM_NCCALCSIZE need the original values */
2196  Cs->lpszName = (LPCWSTR) WindowName;
2197  Cs->lpszClass = (LPCWSTR) ClassName;
2198 
2199  if ((Cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
2200  {
2201  if (ParentWindow != co_GetDesktopWindow(Window))
2202  {
2203  Cs->x += ParentWindow->rcClient.left;
2204  Cs->y += ParentWindow->rcClient.top;
2205  }
2206  }
2207 
2208  /* Send the WM_GETMINMAXINFO message */
2209  Size.cx = Cs->cx;
2210  Size.cy = Cs->cy;
2211 
2212  if ((Cs->style & WS_THICKFRAME) || !(Cs->style & (WS_POPUP | WS_CHILD)))
2213  {
2214  co_WinPosGetMinMaxInfo(Window, &MaxSize, &MaxPos, &MinTrack, &MaxTrack);
2215  if (Size.cx > MaxTrack.x) Size.cx = MaxTrack.x;
2216  if (Size.cy > MaxTrack.y) Size.cy = MaxTrack.y;
2217  if (Size.cx < MinTrack.x) Size.cx = MinTrack.x;
2218  if (Size.cy < MinTrack.y) Size.cy = MinTrack.y;
2219  }
2220 
2221  Window->rcWindow.left = Cs->x;
2222  Window->rcWindow.top = Cs->y;
2223  Window->rcWindow.right = Cs->x + Size.cx;
2224  Window->rcWindow.bottom = Cs->y + Size.cy;
2225  /*
2226  if (0 != (Window->style & WS_CHILD) && ParentWindow)
2227  {
2228  ERR("co_UserCreateWindowEx(): Offset rcWindow\n");
2229  RECTL_vOffsetRect(&Window->rcWindow,
2230  ParentWindow->rcClient.left,
2231  ParentWindow->rcClient.top);
2232  }
2233  */
2234  /* correct child window coordinates if mirroring on parent is enabled */
2235  if (ParentWindow != NULL)
2236  {
2237  if ( ((Cs->style & WS_CHILD) == WS_CHILD) &&
2238  ((ParentWindow->ExStyle & WS_EX_LAYOUTRTL) == WS_EX_LAYOUTRTL))
2239  {
2240  Window->rcWindow.right = ParentWindow->rcClient.right - (Window->rcWindow.left - ParentWindow->rcClient.left);
2241  Window->rcWindow.left = Window->rcWindow.right - Size.cx;
2242  }
2243  }
2244 
2245  Window->rcClient = Window->rcWindow;
2246 
2247  /* Link the window */
2248  if (NULL != ParentWindow)
2249  {
2250  /* Link the window into the siblings list */
2251  if ((Cs->style & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD)
2253  else
2254  IntLinkHwnd(Window, hwndInsertAfter);
2255  }
2256 
2257  if (!(Window->state2 & WNDS2_WIN31COMPAT))
2258  {
2259  if (Class->style & CS_PARENTDC && !(ParentWindow->style & WS_CLIPCHILDREN))
2260  Window->style &= ~(WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
2261  }
2262 
2263  if ((Window->style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
2264  {
2265  if ( !IntIsTopLevelWindow(Window) )
2266  {
2267  if (pti != Window->spwndParent->head.pti)
2268  {
2269  //ERR("CreateWindow Parent in.\n");
2270  UserAttachThreadInput(pti, Window->spwndParent->head.pti, TRUE);
2271  }
2272  }
2273  }
2274 
2275  /* Send the NCCREATE message */
2277  if (!Result)
2278  {
2279  ERR("co_UserCreateWindowEx(): NCCREATE message failed\n");
2280  goto cleanup;
2281  }
2282 
2283  /* Send the WM_NCCALCSIZE message */
2284  {
2285  // RECT rc;
2286  MaxPos.x = Window->rcWindow.left;
2287  MaxPos.y = Window->rcWindow.top;
2288 
2289  Result = co_WinPosGetNonClientSize(Window, &Window->rcWindow, &Window->rcClient);
2290  //rc = Window->rcWindow;
2291  //Result = co_IntSendMessageNoWait(Window->head.h, WM_NCCALCSIZE, FALSE, (LPARAM)&rc);
2292  //Window->rcClient = rc;
2293 
2294  RECTL_vOffsetRect(&Window->rcWindow, MaxPos.x - Window->rcWindow.left,
2295  MaxPos.y - Window->rcWindow.top);
2296  }
2297 
2298  /* Send the WM_CREATE message. */
2300  if (Result == (LRESULT)-1)
2301  {
2302  ERR("co_UserCreateWindowEx(): WM_CREATE message failed\n");
2303  goto cleanup;
2304  }
2305 
2306  /* Send the EVENT_OBJECT_CREATE event */
2307  IntNotifyWinEvent(EVENT_OBJECT_CREATE, Window, OBJID_WINDOW, CHILDID_SELF, 0);
2308 
2309  /* By setting the flag below it can be examined to determine if the window
2310  was created successfully and a valid pwnd was passed back to caller since
2311  from here the function has to succeed. */
2313 
2314  /* Send the WM_SIZE and WM_MOVE messages. */
2315  if (!(Window->state & WNDS_SENDSIZEMOVEMSGS))
2316  {
2318  }
2319 
2320  /* Show or maybe minimize or maximize the window. */
2321 
2323  if (style & (WS_MINIMIZE | WS_MAXIMIZE))
2324  {
2325  RECTL NewPos;
2326  UINT SwFlag = (style & WS_MINIMIZE) ? SW_MINIMIZE : SW_MAXIMIZE;
2327 
2328  SwFlag = co_WinPosMinMaximize(Window, SwFlag, &NewPos);
2329  SwFlag |= SWP_NOZORDER|SWP_FRAMECHANGED; /* Frame always gets changed */
2330  if (!(style & WS_VISIBLE) || (style & WS_CHILD) || UserGetActiveWindow()) SwFlag |= SWP_NOACTIVATE;
2331  co_WinPosSetWindowPos(Window, 0, NewPos.left, NewPos.top,
2332  NewPos.right, NewPos.bottom, SwFlag);
2333  }
2334 
2335  /* Send the WM_PARENTNOTIFY message */
2337 
2338  /* Notify the shell that a new window was created */
2339  if (UserIsDesktopWindow(Window->spwndParent) &&
2340  Window->spwndOwner == NULL &&
2341  (Window->style & WS_VISIBLE) &&
2342  (!(Window->ExStyle & WS_EX_TOOLWINDOW) ||
2343  (Window->ExStyle & WS_EX_APPWINDOW)))
2344  {
2346  }
2347 
2348  /* Initialize and show the window's scrollbars */
2349  if (Window->style & WS_VSCROLL)
2350  {
2352  }
2353  if (Window->style & WS_HSCROLL)
2354  {
2356  }
2357 
2358  /* Show the new window */
2359  if (Cs->style & WS_VISIBLE)
2360  {
2361  if (Window->style & WS_MAXIMIZE)
2362  dwShowMode = SW_SHOW;
2363  else if (Window->style & WS_MINIMIZE)
2364  dwShowMode = SW_SHOWMINIMIZED;
2365 
2366  co_WinPosShowWindow(Window, dwShowMode);
2367 
2368  if (Window->ExStyle & WS_EX_MDICHILD)
2369  {
2370  ASSERT(ParentWindow);
2371  if(!ParentWindow)
2372  goto cleanup;
2373  co_IntSendMessage(UserHMGetHandle(ParentWindow), WM_MDIREFRESHMENU, 0, 0);
2374  /* ShowWindow won't activate child windows */
2376  }
2377  }
2378 
2379  if (Class->atomClassName == gaGuiConsoleWndClass)
2380  {
2381  /* Count only console windows manually */
2383  }
2384 
2385  TRACE("co_UserCreateWindowEx(): Created window %p\n", hWnd);
2386  ret = Window;
2387 
2388 cleanup:
2389  if (!ret)
2390  {
2391  TRACE("co_UserCreateWindowEx(): Error Created window!\n");
2392  /* If the window was created, the class will be dereferenced by co_UserDestroyWindow */
2393  if (Window)
2395  else if (Class)
2396  IntDereferenceClass(Class, pti->pDeskInfo, pti->ppi);
2397  }
2398 
2399  if (pCsw) ExFreePoolWithTag(pCsw, TAG_HOOK);
2400  if (pCbtCreate) ExFreePoolWithTag(pCbtCreate, TAG_HOOK);
2401  if (pszName) UserHeapFree(pszName);
2402  if (pszClass) UserHeapFree(pszClass);
2403 
2404  if (Window)
2405  {
2407  }
2408  if (ParentWindow) UserDerefObjectCo(ParentWindow);
2409 
2410  // See CORE-13717, not setting error on success.
2411  if (ret)
2413 
2414  return ret;
2415 }
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define WS_THICKFRAME
Definition: pedump.c:630
#define HOOKID_TO_FLAG(HookId)
Definition: hook.h:5
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
NTSYSAPI DWORD WINAPI RtlUnicodeStringToAnsiSize(const UNICODE_STRING *)
#define HCBT_CREATEWND
Definition: winuser.h:58
POBJECT_TYPE ExWindowStationObjectType
Definition: win32k.c:25
*BytesInUnicodeString PWCH UnicodeString
Definition: rtlfuncs.h:1980
long y
Definition: polytest.cpp:48
#define LAYOUT_RTL
Definition: wingdi.h:1353
#define ERROR_SUCCESS
Definition: deptool.c:10
NTSTATUS FASTCALL UserAttachThreadInput(PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach)
Definition: input.c:483
#define TAG_HOOK
Definition: tags.h:5
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define UserIsDesktopWindow(pWnd)
Definition: desktop.h:220
long x
Definition: polytest.cpp:48
PVOID Buffer
Definition: ntuser.h:97
#define SB_VERT
Definition: winuser.h:553
HWND FASTCALL UserGetActiveWindow(VOID)
Definition: focus.c:1311
uint16_t * PWSTR
Definition: typedefs.h:54
LPCREATESTRUCTW lpcs
Definition: winuser.h:2928
#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:1651
#define OBJID_WINDOW
Definition: winable.h:15
HWND hWnd
Definition: settings.c:17
#define ICLS_DESKTOP
Definition: ntuser.h:890
#define WS_EX_LAYOUTRTL
Definition: winuser.h:390
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:25
#define HSHELL_WINDOWCREATED
Definition: winuser.h:1240
long bottom
Definition: polytest.cpp:53
static __inline BOOL UserHeapFree(PVOID lpMem)
Definition: usrheap.h:42
DWORD FASTCALL co_UserShowScrollBar(PWND, int, BOOL, BOOL)
Definition: scrollbar.c:859
#define HWND_TOP
Definition: winuser.h:1193
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:610
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
UINT_PTR WPARAM
Definition: windef.h:207
#define WNDS_SENDSIZEMOVEMSGS
Definition: ntuser.h:577
#define WS_CHILD
Definition: pedump.c:617
#define HWND_MESSAGE
Definition: winuser.h:1196
#define SWP_NOZORDER
Definition: winuser.h:1232
static __inline PVOID UserHeapAlloc(SIZE_T Bytes)
Definition: usrheap.h:34
#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:1665
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
struct _DESKTOP * rpdesk
Definition: win32.h:91
PSERVERINFO gpsi
Definition: main.c:27
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
DWORD dwLayout
Definition: win32.h:270
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:783
PPROCESSINFO ppi
Definition: win32.h:87
HWND hwndInsertAfter
Definition: winuser.h:2929
long right
Definition: polytest.cpp:53
Definition: window.c:29
#define WS_EX_MDICHILD
Definition: winuser.h:394
VOID FASTCALL IntLinkHwnd(PWND Wnd, HWND hWndPrev)
Definition: window.c:937
#define UNICODE_NULL
#define WS_MINIMIZE
Definition: pedump.c:622
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:38
long top
Definition: polytest.cpp:53
struct NameRec_ * Name
Definition: cdprocs.h:464
#define CHILDID_SELF
Definition: winable.h:14
Definition: object.h:3
smooth NULL
Definition: ftsmooth.c:416
_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:533
LONG_PTR LPARAM
Definition: windef.h:208
PWND FASTCALL co_GetDesktopWindow(PWND pWnd)
Definition: desktop.c:1330
#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:383
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
#define SW_SHOW
Definition: winuser.h:769
long left
Definition: polytest.cpp:53
VOID FASTCALL co_IntUserManualGuiCheck(BOOL Create)
Definition: guicheck.c:77
#define PCHAR
Definition: match.c:90
UINT FASTCALL co_WinPosGetMinMaxInfo(PWND Window, POINT *MaxSize, POINT *MaxPos, POINT *MinTrack, POINT *MaxTrack)
Definition: winpos.c:936
BOOLEAN FASTCALL co_WinPosShowWindow(PWND Wnd, INT Cmd)
Definition: winpos.c:2393
BOOLEAN co_UserDestroyWindow(PVOID Object)
Definition: window.c:2629
HINSTANCE hInstance
Definition: winuser.h:2909
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
PWND FASTCALL IntCreateWindow(CREATESTRUCTW *Cs, PLARGE_STRING WindowName, PCLS Class, PWND ParentWindow, PWND OwnerWindow, PVOID acbiBuffer, PDESKTOP pdeskCreated)
Definition: window.c:1612
#define ERROR_TLW_WITH_WSCHILD
Definition: winerror.h:887
#define HWND_BOTTOM
Definition: winuser.h:1191
#define TRACE(s)
Definition: solgame.cpp:4
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
ULONG Length
Definition: ntuser.h:94
#define SWP_NOACTIVATE
Definition: winuser.h:1227
#define ISITHOOKED(HookId)
Definition: hook.h:6
PCLS IntGetAndReferenceClass(PUNICODE_STRING ClassName, HINSTANCE hInstance, BOOL bDesktopThread)
Definition: class.c:1407
void FASTCALL co_WinPosSendSizeMove(PWND Wnd)
Definition: winpos.c:2209
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WNDS2_WMCREATEMSGPROCESSED
Definition: ntuser.h:638
#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:331
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#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:1089
int ret
static const WCHAR L[]
Definition: oid.c:1250
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1291
LPCWSTR lpszName
Definition: winuser.h:2917
#define SWP_FRAMECHANGED
Definition: winuser.h:1225
static __inline PVOID UserHeapAddressToUser(PVOID lpMem)
Definition: usrheap.h:92
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define SWP_NOSIZE
Definition: winuser.h:1230
#define ERR(fmt,...)
Definition: debug.h:109
Definition: ntuser.h:657
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:1802
unsigned short USHORT
Definition: pedump.c:61
#define WNDS2_WIN31COMPAT
Definition: ntuser.h:617
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
#define min(a, b)
Definition: monoChain.cc:55
#define WS_POPUP
Definition: pedump.c:616
unsigned int UINT
Definition: ndis.h:50
#define WS_VSCROLL
Definition: pedump.c:627
#define SWP_SHOWWINDOW
Definition: winuser.h:1233
VOID co_IntShellHookNotify(WPARAM Message, WPARAM wParam, LPARAM lParam)
Definition: desktop.c:1656
#define MAXUSHORT
Definition: typedefs.h:81
UINT FASTCALL co_WinPosMinMaximize(PWND Wnd, UINT ShowFlag, RECT *NewPos)
Definition: winpos.c:2243
VOID IntDereferenceClass(IN OUT PCLS Class, IN PDESKTOPINFO Desktop, IN PPROCESSINFO pi)
Definition: class.c:792
#define WM_CREATE
Definition: winuser.h:1590
LPCWSTR lpszClass
Definition: winuser.h:2918
ULONG FASTCALL IntSetStyle(PWND pwnd, ULONG set_bits, ULONG clear_bits)
Definition: window.c:124
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
char * cleanup(char *str)
Definition: wpickclick.c:99
#define SWP_NOMOVE
Definition: winuser.h:1229
#define IS_ATOM(x)
Definition: class.h:3
#define WS_EX_APPWINDOW
Definition: winuser.h:383
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
LONG_PTR LRESULT
Definition: windef.h:209
struct _DESKTOPINFO * pDeskInfo
Definition: win32.h:92
Arabic default style
Definition: afstyles.h:93
#define WS_VISIBLE
Definition: pedump.c:620
#define WNDS_ANSICREATOR
Definition: ntuser.h:602
#define SW_MAXIMIZE
Definition: winuser.h:766
#define CHAR(Char)
static void IntSendParentNotify(PWND pWindow, UINT msg)
Definition: window.c:1503
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
void FASTCALL IntFixWindowCoordinates(CREATESTRUCTW *Cs, PWND ParentWindow, DWORD *dwShowMode)
Definition: window.c:1522
_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:1416
ULONG MaximumLength
Definition: ntuser.h:95
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1013
LRESULT FASTCALL co_WinPosGetNonClientSize(PWND Window, RECT *WindowRect, RECT *ClientRect)
Definition: winpos.c:2194
#define WS_MAXIMIZE
Definition: pedump.c:623
#define ERROR_CANNOT_FIND_WND_CLASS
Definition: winerror.h:888

Referenced by MENU_InitPopup(), and NtUserCreateWindowEx().

◆ co_UserDestroyWindow()

BOOLEAN co_UserDestroyWindow ( PVOID  Object)

Definition at line 2629 of file window.c.

2630 {
2631  HWND hWnd;
2632  PWND pwndTemp;
2633  PTHREADINFO ti;
2634  MSG msg;
2635  PWND Window = Object;
2636 
2637  ASSERT_REFS_CO(Window); // FIXME: Temp HACK?
2638 
2639  hWnd = Window->head.h;
2641 
2642  TRACE("co_UserDestroyWindow(Window = 0x%p, hWnd = 0x%p)\n", Window, hWnd);
2643 
2644  /* Check for owner thread */
2645  if ( Window->head.pti != PsGetCurrentThreadWin32Thread())
2646  {
2647  /* Check if we are destroying the desktop window */
2648  if (! ((Window->head.rpdesk->dwDTFlags & DF_DESTROYED) && Window == Window->head.rpdesk->pDeskInfo->spwnd))
2649  {
2651  return FALSE;
2652  }
2653  }
2654 
2655  /* If window was created successfully and it is hooked */
2656  if ((Window->state2 & WNDS2_WMCREATEMSGPROCESSED))
2657  {
2659  {
2660  ERR("Destroy Window WH_CBT Call Hook return!\n");
2661  return FALSE;
2662  }
2663  }
2664 
2665  if (Window->pcls->atomClassName != gpsi->atomSysClass[ICLS_IME])
2666  {
2667  if ((Window->style & (WS_POPUP|WS_CHILD)) != WS_CHILD)
2668  {
2669  if (Window->spwndOwner)
2670  {
2671  //ERR("DestroyWindow Owner out.\n");
2672  UserAttachThreadInput(Window->head.pti, Window->spwndOwner->head.pti, FALSE);
2673  }
2674  }
2675  }
2676 
2677  /* Inform the parent */
2678  if (Window->style & WS_CHILD)
2679  {
2681  }
2682 
2683  if (!Window->spwndOwner && !IntGetParent(Window))
2684  {
2686  }
2687 
2688  /* Hide the window */
2689  if (Window->style & WS_VISIBLE)
2690  {
2691  if (Window->style & WS_CHILD)
2692  {
2693  /* Only child windows receive WM_SHOWWINDOW in DestroyWindow() */
2695  }
2696  else
2697  {
2699  }
2700  }
2701 
2702  /* Adjust last active */
2703  if ((pwndTemp = Window->spwndOwner))
2704  {
2705  while (pwndTemp->spwndOwner)
2706  pwndTemp = pwndTemp->spwndOwner;
2707 
2708  if (pwndTemp->spwndLastActive == Window)
2709  pwndTemp->spwndLastActive = Window->spwndOwner;
2710  }
2711 
2712  if (Window->spwndParent && IntIsWindow(UserHMGetHandle(Window)))
2713  {
2714  if ((Window->style & (WS_POPUP | WS_CHILD)) == WS_CHILD)
2715  {
2717  {
2718  //ERR("DestroyWindow Parent out.\n");
2719  UserAttachThreadInput(Window->head.pti, Window->spwndParent->head.pti, FALSE);
2720  }
2721  }
2722  }
2723 
2724  if (Window->head.pti->MessageQueue->spwndActive == Window)
2725  Window->head.pti->MessageQueue->spwndActive = NULL;
2726  if (Window->head.pti->MessageQueue->spwndFocus == Window)
2727  Window->head.pti->MessageQueue->spwndFocus = NULL;
2728  if (Window->head.pti->MessageQueue->spwndActivePrev == Window)
2729  Window->head.pti->MessageQueue->spwndActivePrev = NULL;
2730  if (Window->head.pti->MessageQueue->spwndCapture == Window)
2731  Window->head.pti->MessageQueue->spwndCapture = NULL;
2732 
2733  /*
2734  * Check if this window is the Shell's Desktop Window. If so set hShellWindow to NULL
2735  */
2736 
2737  if ((ti != NULL) && (ti->pDeskInfo != NULL))
2738  {
2739  if (ti->pDeskInfo->hShellWindow == hWnd)
2740  {
2741  ERR("Destroying the ShellWindow!\n");
2742  ti->pDeskInfo->hShellWindow = NULL;
2743  }
2744  }
2745 
2747 
2749  {
2750  return TRUE;
2751  }
2752 
2753  /* Recursively destroy owned windows */
2754  if (!(Window->style & WS_CHILD))
2755  {
2756  HWND* List;
2757  HWND* phWnd;
2758  PWND pWnd;
2759 
2761  if (List)
2762  {
2763  for (phWnd = List; *phWnd; ++phWnd)
2764  {
2765  pWnd = ValidateHwndNoErr(*phWnd);
2766  if (pWnd == NULL)
2767  continue;
2768  ASSERT(pWnd->spwndOwner == Window);
2769  ASSERT(pWnd != Window);
2770 
2771  pWnd->spwndOwner = NULL;
2773  {
2775  UserRefObjectCo(pWnd, &Ref); // Temp HACK?
2776  co_UserDestroyWindow(pWnd);
2777  UserDerefObjectCo(pWnd); // Temp HACK?
2778  }
2779  else
2780  {
2781  ERR("IntWndBelongsToThread(0x%p) is FALSE, ignoring.\n", pWnd);
2782  }
2783  }
2784 
2786  }
2787  }
2788 
2789  /* Generate mouse move message for the next window */
2790  msg.message = WM_MOUSEMOVE;
2791  msg.wParam = UserGetMouseButtonsState();
2792  msg.lParam = MAKELPARAM(gpsi->ptCursor.x, gpsi->ptCursor.y);
2793  msg.pt = gpsi->ptCursor;
2795 
2796  IntNotifyWinEvent(EVENT_OBJECT_DESTROY, Window, OBJID_WINDOW, CHILDID_SELF, 0);
2797 
2798  /* Send destroy messages */
2800 
2802  {
2803  return TRUE;
2804  }
2805 
2806  /* Destroy the window storage */
2808 
2809  return TRUE;
2810 }
#define TRUE
Definition: types.h:120
VOID FASTCALL co_MsqInsertMouseMessage(MSG *Msg, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook)
Definition: msgqueue.c:582
LRESULT co_UserFreeWindow(PWND Window, PPROCESSINFO ProcessData, PTHREADINFO ThreadData, BOOLEAN SendMessages)
Definition: window.c:546
PWND FASTCALL ValidateHwndNoErr(HWND hWnd)
Definition: window.c:96
NTSTATUS FASTCALL UserAttachThreadInput(PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach)
Definition: input.c:483
#define IntWndBelongsToThread(WndObj, W32Thread)
Definition: window.h:31
#define SW_HIDE
Definition: winuser.h:762
#define ASSERT_REFS_CO(_obj_)
Definition: userfuncs.h:13
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:3915
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:1651
#define OBJID_WINDOW
Definition: winable.h:15
HWND hWnd
Definition: settings.c:17
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:25
HWND *FASTCALL IntWinListOwnedPopups(PWND Window)
Definition: window.c:287
UINT_PTR WPARAM
Definition: windef.h:207
#define WS_CHILD
Definition: pedump.c:617
#define SWP_NOZORDER
Definition: winuser.h:1232
PSERVERINFO gpsi
Definition: main.c:27
WORD FASTCALL UserGetMouseButtonsState(VOID)
Definition: mouse.c:22
#define SWP_HIDEWINDOW
Definition: winuser.h:1226
Definition: window.c:29
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
#define WOC_DELETE
Definition: winddi.h:1269
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:38
#define HCBT_DESTROYWND
Definition: winuser.h:59
#define CHILDID_SELF
Definition: winable.h:14
struct _WND * spwndOwner
Definition: ntuser.h:679
Definition: object.h:3
smooth NULL
Definition: ftsmooth.c:416
#define WH_CBT
Definition: winuser.h:35
#define WM_DESTROY
Definition: winuser.h:1591
BOOLEAN FASTCALL co_WinPosShowWindow(PWND Wnd, INT Cmd)
Definition: winpos.c:2393
BOOLEAN co_UserDestroyWindow(PVOID Object)
Definition: window.c:2629
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
#define TRACE(s)
Definition: solgame.cpp:4
static void IntSendDestroyMsg(HWND hWnd)
Definition: window.c:433
LIST_ENTRY List
Definition: psmgr.c:57
#define SWP_NOACTIVATE
Definition: winuser.h:1227
#define WNDS2_WMCREATEMSGPROCESSED
Definition: ntuser.h:638
BOOL FASTCALL IntIsWindow(HWND hWnd)
Definition: window.c:157
static IUnknown Object
Definition: main.c:512
BOOL FASTCALL IntIsTopLevelWindow(PWND pWnd)
Definition: window.c:331
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
LRESULT APIENTRY co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
Definition: hook.c:1089
#define ICLS_IME
Definition: ntuser.h:888
#define HSHELL_WINDOWDESTROYED
Definition: winuser.h:1241
#define SWP_NOSIZE
Definition: winuser.h:1230
#define ERR(fmt,...)
Definition: debug.h:109
Definition: ntuser.h:657
struct _WND * spwndLastActive
Definition: ntuser.h:703
#define DF_DESTROYED
Definition: desktop.h:50
PWND FASTCALL IntGetParent(PWND Wnd)
Definition: window.c:185
#define WS_POPUP
Definition: pedump.c:616
#define WM_MOUSEMOVE
Definition: winuser.h:1751
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:1656
#define msg(x)
Definition: auth_time.c:54
#define SWP_NOMOVE
Definition: winuser.h:1229
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define USERTAG_WINDOWLIST
Definition: tags.h:297
struct _DESKTOPINFO * pDeskInfo
Definition: win32.h:92
#define WS_VISIBLE
Definition: pedump.c:620
static void IntSendParentNotify(PWND pWindow, UINT msg)
Definition: window.c:1503
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1013

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

◆ co_UserFreeWindow()

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

Definition at line 546 of file window.c.

550 {
551  HWND *Children;
552  HWND *ChildHandle;
553  PWND Child;
554  PMENU Menu;
555  BOOLEAN BelongsToThreadData;
556 
557  ASSERT(Window);
558 
559  if(Window->state2 & WNDS2_INDESTROY)
560  {
561  TRACE("Tried to call co_UserFreeWindow() twice\n");
562  return 0;
563  }
564  Window->state2 |= WNDS2_INDESTROY;
565  Window->style &= ~WS_VISIBLE;
566  Window->head.pti->cVisWindows--;
567 
568 
569  /* remove the window already at this point from the thread window list so we
570  don't get into trouble when destroying the thread windows while we're still
571  in co_UserFreeWindow() */
572  RemoveEntryList(&Window->ThreadListEntry);
573 
574  BelongsToThreadData = IntWndBelongsToThread(Window, ThreadData);
575 
577 
578  /* free child windows */
579  Children = IntWinListChildren(Window);
580  if (Children)
581  {
582  for (ChildHandle = Children; *ChildHandle; ++ChildHandle)
583  {
584  if ((Child = IntGetWindowObject(*ChildHandle)))
585  {
587  {
588  /* send WM_DESTROY messages to windows not belonging to the same thread */
590  }
591  else
592  co_UserFreeWindow(Child, ProcessData, ThreadData, SendMessages);
593 
595  }
596  }
598  }
599 
600  if (SendMessages)
601  {
602  /*
603  * Clear the update region to make sure no WM_PAINT messages will be
604  * generated for this window while processing the WM_NCDESTROY.
605  */
609  if (BelongsToThreadData)
611  }
612 
614 
616 
617  /* Unregister hot keys */
619 
620  /* flush the message queue */
622 
623  /* from now on no messages can be sent to this window anymore */
624  Window->state |= WNDS_DESTROYED;
625  Window->fnid |= FNID_FREED;
626 
627  /* don't remove the WINDOWSTATUS_DESTROYING bit */
628 
629  /* reset shell window handles */
630  if (ThreadData->rpdesk)
631  {
632  if (Window->head.h == ThreadData->rpdesk->rpwinstaParent->ShellWindow)
633  ThreadData->rpdesk->rpwinstaParent->ShellWindow = NULL;
634 
635  if (Window->head.h == ThreadData->rpdesk->rpwinstaParent->ShellListView)
636  ThreadData->rpdesk->rpwinstaParent->ShellListView = NULL;
637  }
638 
639  /* Fixes dialog test_focus breakage due to r66237. */
640  if (ThreadData->MessageQueue->spwndFocus == Window)
641  ThreadData->MessageQueue->spwndFocus = NULL;
642 
643  if (ThreadData->MessageQueue->spwndActive == Window)
644  ThreadData->MessageQueue->spwndActive = NULL;
645 
646  if (ThreadData->MessageQueue->spwndCapture == Window)
647  {
649  }
650 
652  if ( Window->hrgnUpdate != NULL || Window->state & WNDS_INTERNALPAINT )
653  {
654  MsqDecPaintCountQueue(Window->head.pti);
655  if (Window->hrgnUpdate > HRGN_WINDOW && GreIsHandleValid(Window->hrgnUpdate))
656  {
658  GreDeleteObject(Window->hrgnUpdate);
659  }
660  Window->hrgnUpdate = NULL;
661  Window->state &= ~WNDS_INTERNALPAINT;
662  }
663 
665  {
667  }
668 
669  if ( ((Window->style & (WS_CHILD|WS_POPUP)) != WS_CHILD) &&
670  Window->IDMenu &&
671  (Menu = UserGetMenuObject((HMENU)Window->IDMenu)))
672  {
673  TRACE("UFW: IDMenu %p\n",Window->IDMenu);
674  IntDestroyMenuObject(Menu, TRUE);
675  Window->IDMenu = 0;
676  }
677 
678  if (Window->SystemMenu
679  && (Menu = UserGetMenuObject(Window->SystemMenu)))
680  {
681  IntDestroyMenuObject(Menu, TRUE);
682  Window->SystemMenu = (HMENU)0;
683  }
684 
685  DceFreeWindowDCE(Window); /* Always do this to catch orphaned DCs */
686 
688 
689  if (Window->PropListItems)
690  {
692  TRACE("Window->PropListItems %lu\n",Window->PropListItems);
693  ASSERT(Window->PropListItems==0);
694  }
695 
698 
700 
701  if (Window->pcls->atomClassName == gaGuiConsoleWndClass)
702  {
703  /* Count only console windows manually */
705  }
706 
707  /* dereference the class */
708  NT_ASSERT(Window->head.pti != NULL);
710  Window->head.pti->pDeskInfo,
711  Window->head.pti->ppi);
712  Window->pcls = NULL;
713 
714  if (Window->hrgnClip)
715  {
717  GreDeleteObject(Window->hrgnClip);
718  Window->hrgnClip = NULL;
719  }
720  Window->head.pti->cWindows--;
721 
722 // ASSERT(Window != NULL);
723  UserFreeWindowInfo(Window->head.pti, Window);
724 
727 
728  return 0;
729 }
#define RDW_NOINTERNALPAINT
Definition: winuser.h:1203
#define RDW_NOCHILDREN
Definition: winuser.h:1208
BOOL FASTCALL UserDeleteObject(HANDLE h, HANDLE_TYPE type)
Definition: object.c:683
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1153
#define TRUE
Definition: types.h:120
LRESULT co_UserFreeWindow(PWND Window, PPROCESSINFO ProcessData, PTHREADINFO ThreadData, BOOLEAN SendMessages)
Definition: window.c:546
BOOL NTAPI GreIsHandleValid(HGDIOBJ hobj)
Definition: gdiobj.c:1141
VOID FASTCALL IntUnlinkWindow(PWND Wnd)
Definition: window.c:1306
BOOL FASTCALL IntReleaseCapture(VOID)
Definition: focus.c:1412
#define IntWndBelongsToThread(WndObj, W32Thread)
Definition: window.h:31
#define WNDS_SENDNCPAINT
Definition: ntuser.h:584
BOOL FASTCALL IntDestroyMenuObject(PMENU Menu, BOOL bRecurse)
Definition: menu.c:321
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:610
#define WS_CHILD
Definition: pedump.c:617
ATOM gaGuiConsoleWndClass
Definition: ntuser.c:27
PWND FASTCALL IntGetWindowObject(HWND hWnd)
Definition: window.c:51
FORCEINLINE PMENU UserGetMenuObject(HMENU hMenu)
Definition: userfuncs.h:3
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
BOOL FASTCALL DestroyTimersForWindow(PTHREADINFO pti, PWND Window)
Definition: timer.c:526
Definition: window.c:29
void FASTCALL DceFreeWindowDCE(PWND)
Definition: windc.c:685
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define HRGN_WINDOW
Definition: ntuser.h:329
VOID FASTCALL UserClipboardFreeWindow(PWND pWindow)
Definition: clipboard.c:396
VOID FASTCALL co_IntUserManualGuiCheck(BOOL Create)
Definition: guicheck.c:77
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
#define TRACE(s)
Definition: solgame.cpp:4
BOOL IntDeRegisterShellHookWindow(HWND hWnd)
Definition: desktop.c:1748
VOID FASTCALL UserRemoveWindowProps(_In_ PWND Window)
Definition: prop.c:115
BOOL FASTCALL IntGdiSetRegionOwner(HRGN hRgn, DWORD OwnerMask)
Definition: region.c:2438
#define WM_NCDESTROY
Definition: winuser.h:1666
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
VOID FASTCALL MsqDecPaintCountQueue(PTHREADINFO pti)
Definition: msgqueue.c:508
#define FNID_FREED
Definition: ntuser.h:861
#define RDW_VALIDATE
Definition: winuser.h:1204
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1291
#define RDW_NOERASE
Definition: winuser.h:1201
HWND *FASTCALL IntWinListChildren(PWND Window)
Definition: window.c:255
#define GDI_OBJ_HMGR_POWNED
Definition: ntgdihdl.h:117
#define RDW_NOFRAME
Definition: winuser.h:1202
Definition: ntuser.h:657
BOOL FASTCALL co_UserRedrawWindow(PWND Window, const RECTL *UpdateRect, PREGION UpdateRgn, ULONG Flags)
Definition: painting.c:876
BOOL FASTCALL IntDestroyScrollBars(PWND)
Definition: scrollbar.c:806
#define WS_POPUP
Definition: pedump.c:616
#define WNDS_INTERNALPAINT
Definition: ntuser.h:585
#define WNDS_SENDERASEBACKGROUND
Definition: ntuser.h:582
VOID IntDereferenceClass(IN OUT PCLS Class, IN PDESKTOPINFO Desktop, IN PPROCESSINFO pi)
Definition: class.c:792
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE ACPI_HANDLE Child
Definition: acpixf.h:716
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define USERTAG_WINDOWLIST
Definition: tags.h:297
#define WS_VISIBLE
Definition: pedump.c:620
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:604
VOID APIENTRY MsqRemoveWindowMessagesFromQueue(PWND Window)
Definition: msgqueue.c:802
#define WNDS2_INDESTROY
Definition: ntuser.h:616
VOID FASTCALL UnregisterWindowHotKeys(PWND pWnd)
Definition: hotkey.c:91
static VOID UserFreeWindowInfo(PTHREADINFO ti, PWND Wnd)
Definition: window.c:513
VOID FASTCALL UserReferenceObject(PVOID obj)
Definition: object.c:697
#define NT_ASSERT
Definition: rtlfuncs.h:3312
BOOL FASTCALL UserMarkObjectDestroy(PVOID Object)
Definition: object.c:587

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

◆ co_UserSetParent()

HWND FASTCALL co_UserSetParent ( HWND  hWndChild,
HWND  hWndNewParent 
)

Definition at line 1246 of file window.c.

1247 {
1248  PWND Wnd = NULL, WndParent = NULL, WndOldParent;
1249  HWND hWndOldParent = NULL;
1250  USER_REFERENCE_ENTRY Ref, ParentRef;
1251 
1252  if (IntIsBroadcastHwnd(hWndChild) || IntIsBroadcastHwnd(hWndNewParent))
1253  {
1255  return( NULL);
1256  }
1257 
1258  if (hWndChild == IntGetDesktopWindow())
1259  {
1260  ERR("UserSetParent Access Denied!\n");
1262  return( NULL);
1263  }
1264 
1265  if (hWndNewParent)
1266  {
1267  if (!(WndParent = UserGetWindowObject(hWndNewParent)))
1268  {
1269  ERR("UserSetParent Bad New Parent!\n");
1270  return( NULL);
1271  }
1272  }
1273  else
1274  {
1275  if (!(WndParent = UserGetWindowObject(IntGetDesktopWindow())))
1276  {
1277  return( NULL);
1278  }
1279  }
1280 
1281  if (!(Wnd = UserGetWindowObject(hWndChild)))
1282  {
1283  ERR("UserSetParent Bad Child!\n");
1284  return( NULL);
1285  }
1286 
1287  UserRefObjectCo(Wnd, &Ref);
1288  UserRefObjectCo(WndParent, &ParentRef);
1289  //ERR("Enter co_IntSetParent\n");
1290  WndOldParent = co_IntSetParent(Wnd, WndParent);
1291  //ERR("Leave co_IntSetParent\n");
1292  UserDerefObjectCo(WndParent);
1293  UserDerefObjectCo(Wnd);
1294 
1295  if (WndOldParent)
1296  {
1297  hWndOldParent = WndOldParent->head.h;
1298  UserDereferenceObject(WndOldParent);
1299  }
1300 
1301  return( hWndOldParent);
1302 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:25
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:610
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:38
Definition: object.h:3
smooth NULL
Definition: ftsmooth.c:416
#define IntIsBroadcastHwnd(hWnd)
Definition: window.h:27
#define ERR(fmt,...)
Definition: debug.h:109
Definition: ntuser.h:657
HWND FASTCALL IntGetDesktopWindow(VOID)
Definition: desktop.c:1338
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
PWND FASTCALL co_IntSetParent(PWND Wnd, PWND WndNewParent)
Definition: window.c:1109
HWND hWndChild[NUM_TABS]
Definition: main.h:75
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by co_IntSetWindowLongPtr(), and NtUserSetParent().

◆ co_UserSetWindowLong()

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

Definition at line 3815 of file window.c.

3816 {
3817  return (LONG)co_IntSetWindowLongPtr(hWnd, Index, NewValue, Ansi, sizeof(LONG), FALSE);
3818 }
HWND hWnd
Definition: settings.c:17
static LONG_PTR co_IntSetWindowLongPtr(HWND hWnd, DWORD Index, LONG_PTR NewValue, BOOL Ansi, ULONG Size, BOOL bAlter)
Definition: window.c:3620
long LONG
Definition: pedump.c:60
static const UCHAR Index[8]
Definition: usbohci.c:18

Referenced by DesktopWindowProc(), and NtUserSetWindowWord().

◆ co_UserSetWindowLongPtr()

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

Definition at line 3821 of file window.c.

3822 {
3823  return co_IntSetWindowLongPtr(hWnd, Index, NewValue, Ansi, sizeof(LONG_PTR), FALSE);
3824 }
HWND hWnd
Definition: settings.c:17
static LONG_PTR co_IntSetWindowLongPtr(HWND hWnd, DWORD Index, LONG_PTR NewValue, BOOL Ansi, ULONG Size, BOOL bAlter)
Definition: window.c:3620
static const UCHAR Index[8]
Definition: usbohci.c:18
__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 4149 of file window.c.

4150 {
4152  BOOL Ret = FALSE;
4153 
4154  RtlInitUnicodeString(&UnicodeString, WindowText);
4155 
4156  if (UnicodeString.Length != 0)
4157  {
4158  if (Wnd->strName.MaximumLength > 0 &&
4159  UnicodeString.Length <= Wnd->strName.MaximumLength - sizeof(UNICODE_NULL))
4160  {
4161  ASSERT(Wnd->strName.Buffer != NULL);
4162 
4163  Wnd->strName.Length = UnicodeString.Length;
4164  Wnd->strName.Buffer[UnicodeString.Length / sizeof(WCHAR)] = L'\0';
4166  UnicodeString.Buffer,
4167  UnicodeString.Length);
4168  }
4169  else
4170  {
4171  PWCHAR buf;
4172  Wnd->strName.MaximumLength = Wnd->strName.Length = 0;
4173  buf = Wnd->strName.Buffer;
4174  Wnd->strName.Buffer = NULL;
4175  if (buf != NULL)
4176  {
4177  DesktopHeapFree(Wnd->head.rpdesk, buf);
4178  }
4179 
4181  UnicodeString.Length + sizeof(UNICODE_NULL));
4182  if (Wnd->strName.Buffer != NULL)
4183  {
4184  Wnd->strName.Buffer[UnicodeString.Length / sizeof(WCHAR)] = L'\0';
4186  UnicodeString.Buffer,
4187  UnicodeString.Length);
4188  Wnd->strName.MaximumLength = UnicodeString.Length + sizeof(UNICODE_NULL);
4189  Wnd->strName.Length = UnicodeString.Length;
4190  }
4191  else
4192  {
4194  goto Exit;
4195  }
4196  }
4197  }
4198  else
4199  {
4200  Wnd->strName.Length = 0;
4201  if (Wnd->strName.Buffer != NULL)
4202  Wnd->strName.Buffer[0] = L'\0';
4203  }
4204 
4205  // FIXME: HAX! Windows does not do this in here!
4206  // In User32, these are called after: NotifyWinEvent EVENT_OBJECT_NAMECHANGE than
4207  // RepaintButton, StaticRepaint, NtUserCallHwndLock HWNDLOCK_ROUTINE_REDRAWFRAMEANDHOOK, etc.
4208  /* Send shell notifications */
4209  if (!Wnd->spwndOwner && !IntGetParent(Wnd))
4210  {
4211  co_IntShellHookNotify(HSHELL_REDRAW, (WPARAM) UserHMGetHandle(Wnd), FALSE); // FIXME Flashing?
4212  }
4213 
4214  Ret = TRUE;
4215 Exit:
4217  return Ret;
4218 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
*BytesInUnicodeString PWCH UnicodeString
Definition: rtlfuncs.h:1980
struct _DESKTOP * rpdesk
Definition: ntuser.h:189
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
UINT_PTR WPARAM
Definition: windef.h:207
uint16_t * PWCHAR
Definition: typedefs.h:54
static __inline PVOID DesktopHeapAlloc(IN PDESKTOP Desktop, IN SIZE_T Bytes)
Definition: desktop.h:230
#define UNICODE_NULL
unsigned int BOOL
Definition: ntddk_ex.h:94
struct _WND * spwndOwner
Definition: ntuser.h:679
THRDESKHEAD head
Definition: ntuser.h:659
smooth NULL
Definition: ftsmooth.c:416
LARGE_UNICODE_STRING strName
Definition: ntuser.h:700
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
__wchar_t WCHAR
Definition: xmlstorage.h:180
static void Exit(void)
Definition: sock.c:1331
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR L[]
Definition: oid.c:1250
PWND FASTCALL IntGetParent(PWND Wnd)
Definition: window.c:185
VOID co_IntShellHookNotify(WPARAM Message, WPARAM wParam, LPARAM lParam)
Definition: desktop.c:1656
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
static __inline BOOL DesktopHeapFree(IN PDESKTOP Desktop, IN PVOID lpMem)
Definition: desktop.h:239
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

◆ IntCheckFrameEdge()

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

Definition at line 3609 of file window.c.

3610 {
3612  return TRUE;
3613  else if (!(ExStyle & WS_EX_STATICEDGE) && (Style & (WS_DLGFRAME | WS_THICKFRAME)))
3614  return TRUE;
3615  else
3616  return FALSE;
3617 }
#define WS_THICKFRAME
Definition: pedump.c:630
#define TRUE
Definition: types.h:120
#define WS_DLGFRAME
Definition: pedump.c:626
#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 
)

Definition at line 1612 of file window.c.

1619 {
1620  PWND pWnd = NULL;
1621  HWND hWnd;
1622  PTHREADINFO pti = NULL;
1623  BOOL MenuChanged;
1624  BOOL bUnicodeWindow;
1625 
1626  pti = pdeskCreated ? gptiDesktopThread : GetW32ThreadInfo();
1627 
1628  if (!(Cs->dwExStyle & WS_EX_LAYOUTRTL))
1629  { // Need both here for wine win.c test_CreateWindow.
1630  //if (Cs->hwndParent && ParentWindow)
1631  if (ParentWindow) // It breaks more tests..... WIP.
1632  {
1633  if ( (Cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD &&
1634  ParentWindow->ExStyle & WS_EX_LAYOUTRTL &&
1635  !(ParentWindow->ExStyle & WS_EX_NOINHERITLAYOUT) )
1636  Cs->dwExStyle |= WS_EX_LAYOUTRTL;
1637  }
1638  else
1639  { /*
1640  * Note from MSDN <http://msdn.microsoft.com/en-us/library/aa913269.aspx>:
1641  *
1642  * Dialog boxes and message boxes do not inherit layout, so you must
1643  * set the layout explicitly.
1644  */
1645  if ( Class->fnid != FNID_DIALOG )
1646  {
1647  if (pti->ppi->dwLayout & LAYOUT_RTL)
1648  {
1649  Cs->dwExStyle |= WS_EX_LAYOUTRTL;
1650  }
1651  }
1652  }
1653  }
1654 
1655  /* Automatically add WS_EX_WINDOWEDGE */
1656  if ((Cs->dwExStyle & WS_EX_DLGMODALFRAME) ||
1657  ((!(Cs->dwExStyle & WS_EX_STATICEDGE)) &&
1658  (Cs->style & (WS_DLGFRAME | WS_THICKFRAME))))
1659  Cs->dwExStyle |= WS_EX_WINDOWEDGE;
1660  else
1661  Cs->dwExStyle &= ~WS_EX_WINDOWEDGE;
1662 
1663  /* Is it a unicode window? */
1664  bUnicodeWindow =!(Cs->dwExStyle & WS_EX_SETANSICREATOR);
1666 
1667  /* Allocate the new window */
1669  pdeskCreated ? pdeskCreated : pti->rpdesk,
1670  pti,
1671  (PHANDLE)&hWnd,
1672  TYPE_WINDOW,
1673  sizeof(WND) + Class->cbwndExtra);
1674 
1675  if (!pWnd)
1676  {
1677  goto AllocError;
1678  }
1679 
1680  TRACE("Created window object with handle %p\n", hWnd);
1681 
1682  if (pdeskCreated && pdeskCreated->DesktopWindow == NULL )
1683  { /* HACK: Helper for win32csr/desktopbg.c */
1684  /* If there is no desktop window yet, we must be creating it */
1685  TRACE("CreateWindow setting desktop.\n");
1686  pdeskCreated->DesktopWindow = hWnd;
1687  pdeskCreated->pDeskInfo->spwnd = pWnd;
1688  }
1689 
1690  /*
1691  * Fill out the structure describing it.
1692  */
1693  /* Remember, pWnd->head is setup in object.c ... */
1694  pWnd->spwndParent = ParentWindow;
1695  pWnd->spwndOwner = OwnerWindow;
1696  pWnd->fnid = 0;
1697  pWnd->spwndLastActive = pWnd;
1698  pWnd->state2 |= WNDS2_WIN40COMPAT; // FIXME!!!
1699  pWnd->pcls = Class;
1700  pWnd->hModule = Cs->hInstance;
1701  pWnd->style = Cs->style & ~WS_VISIBLE;
1702  pWnd->ExStyle = Cs->dwExStyle;
1703  pWnd->cbwndExtra = pWnd->pcls->cbwndExtra;
1704  pWnd->pActCtx = acbiBuffer;
1705  pWnd->InternalPos.MaxPos.x = pWnd->InternalPos.MaxPos.y = -1;
1706  pWnd->InternalPos.IconPos.x = pWnd->InternalPos.IconPos.y = -1;
1707 
1708  if (pWnd->spwndParent != NULL && Cs->hwndParent != 0)
1709  {
1710  pWnd->HideFocus = pWnd->spwndParent->HideFocus;
1711  pWnd->HideAccel = pWnd->spwndParent->HideAccel;
1712  }
1713 
1714  pWnd->head.pti->cWindows++;
1715 
1716  if (Class->spicn && !Class->spicnSm)
1717  {
1718  HICON IconSmHandle = NULL;
1719  if((Class->spicn->CURSORF_flags & (CURSORF_LRSHARED | CURSORF_FROMRESOURCE))
1721  {
1722  IconSmHandle = co_IntCopyImage(
1723  UserHMGetHandle(Class->spicn),
1724  IMAGE_ICON,
1728  }
1729  if (!IconSmHandle)
1730  {
1731  /* Retry without copying from resource */
1732  IconSmHandle = co_IntCopyImage(
1733  UserHMGetHandle(Class->spicn),
1734  IMAGE_ICON,
1737  0);
1738  }
1739 
1740  if (IconSmHandle)
1741  {
1742  Class->spicnSm = UserGetCurIconObject(IconSmHandle);
1743  Class->CSF_flags |= CSF_CACHEDSMICON;
1744  }
1745  }
1746 
1747  if (pWnd->pcls->CSF_flags & CSF_SERVERSIDEPROC)
1749 
1750  /* BugBoy Comments: Comment below say that System classes are always created
1751  as UNICODE. In windows, creating a window with the ANSI version of CreateWindow
1752  sets the window to ansi as verified by testing with IsUnicodeWindow API.
1753 
1754  No where can I see in code or through testing does the window change back
1755  to ANSI after being created as UNICODE in ROS. I didnt do more testing to
1756  see what problems this would cause. */
1757 
1758  // Set WndProc from Class.
1759  pWnd->lpfnWndProc = pWnd->pcls->lpfnWndProc;
1760 
1761  // GetWindowProc, test for non server side default classes and set WndProc.
1762  if ( pWnd->pcls->fnid <= FNID_GHOST && pWnd->pcls->fnid >= FNID_BUTTON )
1763  {
1764  if (bUnicodeWindow)
1765  {
1766  if (GETPFNCLIENTA(pWnd->pcls->fnid) == pWnd->lpfnWndProc)
1767  pWnd->lpfnWndProc = GETPFNCLIENTW(pWnd->pcls->fnid);
1768  }
1769  else
1770  {
1771  if (GETPFNCLIENTW(pWnd->pcls->fnid) == pWnd->lpfnWndProc)
1772  pWnd->lpfnWndProc = GETPFNCLIENTA(pWnd->pcls->fnid);
1773  }
1774  }
1775 
1776  // If not an Unicode caller, set Ansi creator bit.
1777  if (!bUnicodeWindow) pWnd->state |= WNDS_ANSICREATOR;
1778 
1779  // Clone Class Ansi/Unicode proc type.
1780  if (pWnd->pcls->CSF_flags & CSF_ANSIPROC)
1781  {
1782  pWnd->state |= WNDS_ANSIWINDOWPROC;
1783  pWnd->Unicode = FALSE;
1784  }
1785  else
1786  { /*
1787  * It seems there can be both an Ansi creator and Unicode Class Window
1788  * WndProc, unless the following overriding conditions occur:
1789  */
1790  if ( !bUnicodeWindow &&
1791  ( Class->atomClassName == gpsi->atomSysClass[ICLS_BUTTON] ||
1792  Class->atomClassName == gpsi->atomSysClass[ICLS_COMBOBOX] ||
1793  Class->atomClassName == gpsi->atomSysClass[ICLS_COMBOLBOX] ||
1794  Class->atomClassName == gpsi->atomSysClass[ICLS_DIALOG] ||
1795  Class->atomClassName == gpsi->atomSysClass[ICLS_EDIT] ||
1796  Class->atomClassName == gpsi->atomSysClass[ICLS_IME] ||
1797  Class->atomClassName == gpsi->atomSysClass[ICLS_LISTBOX] ||
1798  Class->atomClassName == gpsi->atomSysClass[ICLS_MDICLIENT] ||
1799  Class->atomClassName == gpsi->atomSysClass[ICLS_STATIC] ) )
1800  { // Override Class and set the window Ansi WndProc.
1801  pWnd->state |= WNDS_ANSIWINDOWPROC;
1802  pWnd->Unicode = FALSE;
1803  }
1804  else
1805  { // Set the window Unicode WndProc.
1806  pWnd->state &= ~WNDS_ANSIWINDOWPROC;
1807  pWnd->Unicode = TRUE;
1808  }
1809  }
1810 
1811  /* BugBoy Comments: if the window being created is a edit control, ATOM 0xCxxx,
1812  then my testing shows that windows (2k and XP) creates a CallProc for it immediately
1813  Dont understand why it does this. */
1814  if (Class->atomClassName == gpsi->atomSysClass[ICLS_EDIT])
1815  {
1816  PCALLPROCDATA CallProc;
1817  CallProc = CreateCallProc(pWnd->head.rpdesk, pWnd->lpfnWndProc, pWnd->Unicode , pWnd->head.pti->ppi);
1818 
1819  if (!CallProc)
1820  {
1822  ERR("Warning: Unable to create CallProc for edit control. Control may not operate correctly! hwnd %p\n", hWnd);
1823  }
1824  else
1825  {
1826  UserAddCallProcToClass(pWnd->pcls, CallProc);
1827  }
1828  }
1829 
1831  pWnd->PropListItems = 0;
1832 
1833  if ( WindowName->Buffer != NULL && WindowName->Length > 0 )
1834  {
1835  pWnd->strName.Buffer = DesktopHeapAlloc(pWnd->head.rpdesk,
1836  WindowName->Length + sizeof(UNICODE_NULL));
1837  if (pWnd->strName.Buffer == NULL)
1838  {
1839  goto AllocError;
1840  }
1841 
1842  RtlCopyMemory(pWnd->strName.Buffer, WindowName->Buffer, WindowName->Length);
1843  pWnd->strName.Buffer[WindowName->Length / sizeof(WCHAR)] = L'\0';
1844  pWnd->strName.Length = WindowName->Length;
1845  pWnd->strName.MaximumLength = WindowName->Length + sizeof(UNICODE_NULL);
1846  }
1847 
1848  /* Correct the window style. */
1849  if ((pWnd->style & (WS_CHILD | WS_POPUP)) != WS_CHILD)
1850  {
1851  pWnd->style |= WS_CLIPSIBLINGS;
1852  if (!(pWnd->style & WS_POPUP))
1853  {
1854  pWnd->style |= WS_CAPTION;
1855  }
1856  }
1857 
1858  /* WS_EX_WINDOWEDGE depends on some other styles */
1859  if (pWnd->ExStyle & WS_EX_DLGMODALFRAME)
1860  pWnd->ExStyle |= WS_EX_WINDOWEDGE;
1861  else if (pWnd->style & (WS_DLGFRAME | WS_THICKFRAME))
1862  {
1863  if (!((pWnd->ExStyle & WS_EX_STATICEDGE) &&
1864  (pWnd->style & (WS_CHILD | WS_POPUP))))
1865  pWnd->ExStyle |= WS_EX_WINDOWEDGE;
1866  }
1867  else
1868  pWnd->ExStyle &= ~WS_EX_WINDOWEDGE;
1869 
1870  if (!(pWnd->style & (WS_CHILD | WS_POPUP)))
1871  pWnd->state |= WNDS_SENDSIZEMOVEMSGS;
1872 
1873  /* Set the window menu */
1874  if ((Cs->style & (WS_CHILD | WS_POPUP)) != WS_CHILD)
1875  {
1876  if (Cs->hMenu)
1877  {
1878  IntSetMenu(pWnd, Cs->hMenu, &MenuChanged);
1879  }
1880  else if (pWnd->pcls->lpszMenuName) // Take it from the parent.
1881  {
1882  UNICODE_STRING MenuName;
1883  HMENU hMenu;
1884 
1885  if (IS_INTRESOURCE(pWnd->pcls->lpszMenuName))
1886  {
1887  MenuName.Length = 0;
1888  MenuName.MaximumLength = 0;
1889  MenuName.Buffer = pWnd->pcls->lpszMenuName;
1890  }
1891  else
1892  {
1893  RtlInitUnicodeString( &MenuName, pWnd->pcls->lpszMenuName);
1894  }
1895  hMenu = co_IntCallLoadMenu( pWnd->pcls->hModule, &MenuName);
1896  if (hMenu) IntSetMenu(pWnd, hMenu, &MenuChanged);
1897  }
1898  }
1899  else // Not a child
1900  pWnd->IDMenu = (UINT_PTR)Cs->hMenu;
1901 
1902 
1903  if ( ParentWindow &&
1904  ParentWindow != ParentWindow->head.rpdesk->spwndMessage &&
1905  ParentWindow != ParentWindow->head.rpdesk->pDeskInfo->spwnd )
1906  {
1907  PWND Owner = IntGetNonChildAncestor(ParentWindow);
1908 
1909  if (!IntValidateOwnerDepth(pWnd, Owner))
1910  {
1912  goto Error;
1913  }
1914  if ( pWnd->spwndOwner &&
1915  pWnd->spwndOwner->ExStyle & WS_EX_TOPMOST )
1916  {
1917  pWnd->ExStyle |= WS_EX_TOPMOST;
1918  }
1919  if ( pWnd->spwndOwner &&
1920  Class->atomClassName != gpsi->atomSysClass[ICLS_IME] &&
1921  pti != pWnd->spwndOwner->head.pti)
1922  {
1923  //ERR("CreateWindow Owner in.\n");
1924  UserAttachThreadInput(pti, pWnd->spwndOwner->head.pti, TRUE);
1925  }
1926  }
1927 
1928  /* Insert the window into the thread's window list. */
1930 
1931  /* Handle "CS_CLASSDC", it is tested first. */
1932  if ( (pWnd->pcls->style & CS_CLASSDC) && !(pWnd->pcls->pdce) )
1933  { /* One DCE per class to have CLASS. */
1934  pWnd->pcls->pdce = DceAllocDCE( pWnd, DCE_CLASS_DC );
1935  }
1936  else if ( pWnd->pcls->style & CS_OWNDC)
1937  { /* Allocate a DCE for this window. */
1938  DceAllocDCE(pWnd, DCE_WINDOW_DC);
1939  }
1940 
1941  return pWnd;
1942 
1943 AllocError:
1944  ERR("IntCreateWindow Allocation Error.\n");
1946 Error:
1947  if(pWnd)
1948  UserDereferenceObject(pWnd);
1949  return NULL;
1950 }
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
static const WCHAR Class[]
Definition: cfgmgr.c:31
unsigned __int3264 UINT_PTR
Definition: activex.cpp:275
struct _WND::@4105 InternalPos
#define WS_THICKFRAME
Definition: pedump.c:630
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
DWORD ExStyle
Definition: ntuser.h:668
static HICON
Definition: imagelist.c:84
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
UINT HideFocus
Definition: ntuser.h:722
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define IMAGE_ICON
Definition: winuser.h:212
#define ICLS_MDICLIENT
Definition: ntuser.h:879
LIST_ENTRY ThreadListEntry
Definition: ntuser.h:728
struct _DESKTOP * rpdesk
Definition: ntuser.h:189
#define LAYOUT_RTL
Definition: wingdi.h:1353
ULONG PropListItems
Definition: ntuser.h:688
NTSTATUS FASTCALL UserAttachThreadInput(PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach)
Definition: input.c:483
PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon)
Definition: cursoricon.c:200
USHORT MaximumLength
Definition: env_spec_w32.h:370
PVOID Buffer
Definition: ntuser.h:97
#define GETPFNCLIENTW(fnid)
Definition: ntuser.h:867
#define CURSORF_FROMRESOURCE
Definition: ntuser.h:1148
LIST_ENTRY WindowListHead
Definition: win32.h:149
HINSTANCE hModule
Definition: ntuser.h:672
WNDPROC lpfnWndProc
Definition: ntuser.h:682
BOOL FASTCALL IntValidateOwnerDepth(PWND Wnd, PWND Owner)
Definition: window.c:339
HINSTANCE hModule
Definition: ntuser.h:552
#define ICLS_EDIT
Definition: ntuser.h:874
LIST_ENTRY PropListHead
Definition: ntuser.h:687
HWND hWnd
Definition: settings.c:17
#define WS_EX_LAYOUTRTL
Definition: winuser.h:390
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:1003
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:610
#define WNDS_SENDSIZEMOVEMSGS
Definition: ntuser.h:577
#define WS_CHILD
Definition: pedump.c:617
#define CS_OWNDC
Definition: winuser.h:650
#define InsertTailList(ListHead, Entry)
struct _DESKTOP * rpdesk
Definition: win32.h:91
PSERVERINFO gpsi
Definition: main.c:27
#define ICLS_DIALOG
Definition: ntuser.h:891
PVOID FASTCALL UserCreateObject(PUSER_HANDLE_TABLE ht, PDESKTOP pDesktop, PTHREADINFO pti, HANDLE *h, HANDLE_TYPE type, ULONG size)
Definition: object.c:535
DWORD dwLayout
Definition: win32.h:270
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:783
PPROCESSINFO ppi
Definition: win32.h:87
PCALLPROCDATA CreateCallProc(IN PDESKTOP Desktop, IN WNDPROC WndProc, IN BOOL Unicode, IN PPROCESSINFO pi)
Definition: callproc.c:29
WNDPROC lpfnWndProc
Definition: ntuser.h:549
PTHREADINFO gptiDesktopThread
Definition: desktop.c:37
ULONG cbwndExtra
Definition: ntuser.h:702
#define ICLS_LISTBOX
Definition: ntuser.h:876
DWORD CSF_flags
Definition: ntuser.h:541
#define CSF_CACHEDSMICON
Definition: ntuser.h:530
UINT style
Definition: ntuser.h:548
static __inline PVOID DesktopHeapAlloc(IN PDESKTOP Desktop, IN SIZE_T Bytes)
Definition: desktop.h:230
#define UNICODE_NULL
DWORD fnid
Definition: ntuser.h:673
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CURSORF_LRSHARED
Definition: ntuser.h:1150
HMENU APIENTRY co_IntCallLoadMenu(HINSTANCE hModule, PUNICODE_STRING pMenuName)
Definition: callback.c:889
#define FNID_DIALOG
Definition: ntuser.h:831
struct _WND * spwndOwner
Definition: ntuser.h:679
THRDESKHEAD head
Definition: ntuser.h:659
smooth NULL
Definition: ftsmooth.c:416
#define WS_EX_DLGMODALFRAME
Definition: pedump.c:645
PVOID pdce
Definition: ntuser.h:540
LARGE_UNICODE_STRING strName
Definition: ntuser.h:700
#define ICLS_STATIC
Definition: ntuser.h:875
UINT HideAccel
Definition: ntuser.h:723
HANDLE FASTCALL co_IntCopyImage(HANDLE hnd, UINT type, INT desiredx, INT desiredy, UINT flags)
Definition: callback.c:974
LONG NTAPI UserGetSystemMetrics(ULONG Index)
Definition: metric.c:180
HINSTANCE hInstance
Definition: winuser.h:2909
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
#define WS_CAPTION
Definition: pedump.c:624
UINT_PTR IDMenu
Definition: ntuser.h:695
#define TRACE(s)
Definition: solgame.cpp:4
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
if(!(yy_init))
Definition: macro.lex.yy.c:714
__wchar_t WCHAR
Definition: xmlstorage.h:180
ULONG Length
Definition: ntuser.h:94
DWORD fnid
Definition: ntuser.h:538
#define WS_EX_NOINHERITLAYOUT
Definition: winuser.h:396
BOOL Error
Definition: chkdsk.c:66
#define SM_CXSMICON
Definition: winuser.h:1002
#define CSF_SERVERSIDEPROC
Definition: ntuser.h:524
static const WCHAR L[]
Definition: oid.c:1250
#define ICLS_IME
Definition: ntuser.h:888
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:414
#define GETPFNCLIENTA(fnid)
Definition: ntuser.h:865
#define WS_EX_TOPMOST
Definition: pedump.c:647
#define CSF_ANSIPROC
Definition: ntuser.h:525
#define ICLS_COMBOLBOX
Definition: ntuser.h:880
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
INT cbwndExtra
Definition: ntuser.h:551
VOID UserAddCallProcToClass(IN OUT PCLS Class, IN PCALLPROCDATA CallProc)
Definition: class.c:400
PWSTR lpszMenuName
Definition: ntuser.h:556
#define CS_CLASSDC
Definition: winuser.h:645
#define WS_EX_SETANSICREATOR
Definition: undocuser.h:28
#define ERR(fmt,...)
Definition: debug.h:109
Definition: ntuser.h:657
#define FNID_GHOST
Definition: ntuser.h:837
#define LR_COPYFROMRESOURCE
Definition: winuser.h:1089
struct _WND * PWND
struct _WND * spwndLastActive
Definition: ntuser.h:703
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define WNDS_ANSIWINDOWPROC
Definition: ntuser.h:592
#define FNID_BUTTON
Definition: ntuser.h:828
DWORD state
Definition: ntuser.h:665
#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:1557
PWND FASTCALL IntGetNonChildAncestor(PWND pWnd)
Definition: window.c:323
struct _WND * spwndParent
Definition: ntuser.h:677
DWORD state2
Definition: ntuser.h:666
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define ICLS_BUTTON
Definition: ntuser.h:873
PVOID pActCtx
Definition: ntuser.h:706
#define WNDS2_WIN40COMPAT
Definition: ntuser.h:618
PDCE FASTCALL DceAllocDCE(PWND Window, DCE_TYPE Type)
Definition: windc.c:85
#define WS_VISIBLE
Definition: pedump.c:620
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
#define WNDS_ANSICREATOR
Definition: ntuser.h:602
BOOL FASTCALL IntSetMenu(PWND Wnd, HMENU Menu, BOOL *Changed)
Definition: menu.c:5314
#define WNDS_SERVERSIDEWINDOWPROC
Definition: ntuser.h:591
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:720
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1013
PCLS pcls
Definition: ntuser.h:684
DWORD style
Definition: ntuser.h:670
#define ICLS_COMBOBOX
Definition: ntuser.h:878

Referenced by co_UserCreateWindowEx(), and IntCreateDesktop().

◆ IntEnableWindow()

BOOL FASTCALL IntEnableWindow ( HWND  hWnd,
BOOL  bEnable 
)

Definition at line 201 of file window.c.

202 {
203  BOOL Update;
204  PWND pWnd;
205  UINT bIsDisabled;
206 
207  if(!(pWnd = UserGetWindowObject(hWnd)))
208  {
209  return FALSE;
210  }
211 
212  /* check if updating is needed */
213  bIsDisabled = !!(pWnd->style & WS_DISABLED);
214  Update = bIsDisabled;
215 
216  if (bEnable)
217  {
218  IntSetStyle( pWnd, 0, WS_DISABLED );
219  }
220  else
221  {
222  Update = !bIsDisabled;
223 
225 
226  /* Remove keyboard focus from that window if it had focus */
227  if (hWnd == IntGetThreadFocusWindow())
228  {
229  TRACE("IntEnableWindow SF NULL\n");
231  }
232  IntSetStyle( pWnd, WS_DISABLED, 0 );
233  }
234 
235  if (Update)
236  {
237  IntNotifyWinEvent(EVENT_OBJECT_STATECHANGE, pWnd, OBJID_WINDOW, CHILDID_SELF, 0);
239  }
240  // Return nonzero if it was disabled, or zero if it wasn't:
241  return bIsDisabled;
242 }
#define WS_DISABLED
Definition: pedump.c:621
HWND FASTCALL IntGetThreadFocusWindow(VOID)
Definition: focus.c:39
HWND FASTCALL co_UserSetFocus(PWND Window)
Definition: focus.c:1196
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:1597
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CHILDID_SELF
Definition: winable.h:14
smooth NULL
Definition: ftsmooth.c:416
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:1291
#define WM_CANCELMODE
Definition: winuser.h:1617
Definition: ntuser.h:657
_In_ BOOL bEnable
Definition: winddi.h:3426
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
unsigned int UINT
Definition: ndis.h:50
ULONG FASTCALL IntSetStyle(PWND pwnd, ULONG set_bits, ULONG clear_bits)
Definition: window.c:124
DWORD style
Definition: ntuser.h:670

Referenced by NtUserCallTwoParam(), and NtUserEnableScrollBar().

◆ IntFindWindow()

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

Definition at line 2846 of file window.c.

2850 {
2851  BOOL CheckWindowName;
2852  HWND *List, *phWnd;
2853  HWND Ret = NULL;
2854  UNICODE_STRING CurrentWindowName;
2855 
2856  ASSERT(Parent);
2857 
2858  CheckWindowName = WindowName->Buffer != 0;
2859 
2860  if((List = IntWinListChildren(Parent)))
2861  {
2862  phWnd = List;
2863  if(ChildAfter)
2864  {
2865  /* skip handles before and including ChildAfter */
2866  while(*phWnd && (*(phWnd++) != ChildAfter->head.h))
2867  ;
2868  }
2869 
2870  /* search children */
2871  while(*phWnd)
2872  {
2873  PWND Child;
2874  if(!(Child = UserGetWindowObject(*(phWnd++))))
2875  {
2876  continue;
2877  }
2878 
2879  /* Do not send WM_GETTEXT messages in the kernel mode version!
2880  The user mode version however calls GetWindowText() which will
2881  send WM_GETTEXT messages to windows belonging to its processes */
2882  if (!ClassAtom || Child->pcls->atomNVClassName == ClassAtom)
2883  {
2884  // FIXME: LARGE_STRING truncated
2885  CurrentWindowName.Buffer = Child->strName.Buffer;
2886  CurrentWindowName.Length = (USHORT)min(Child->strName.Length, MAXUSHORT);
2887  CurrentWindowName.MaximumLength = (USHORT)min(Child->strName.MaximumLength, MAXUSHORT);
2888  if(!CheckWindowName ||
2889  (Child->strName.Length < 0xFFFF &&
2890  !RtlCompareUnicodeString(WindowName, &CurrentWindowName, TRUE)))
2891  {
2892  Ret = Child->head.h;
2893  break;
2894  }
2895  }
2896  }
2898  }
2899 
2900  return Ret;
2901 }
#define TRUE
Definition: types.h:120
USHORT MaximumLength
Definition: env_spec_w32.h:370
UINT32 Length
Definition: actbl.h:109
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:716
unsigned int BOOL
Definition: ntddk_ex.h:94
THRDESKHEAD head
Definition: ntuser.h:659
smooth NULL
Definition: ftsmooth.c:416
LIST_ENTRY List
Definition: psmgr.c:57
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
HWND *FASTCALL IntWinListChildren(PWND Window)
Definition: window.c:255
Definition: ntuser.h:657
unsigned short USHORT
Definition: pedump.c:61
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
#define min(a, b)
Definition: monoChain.cc:55
#define MAXUSHORT
Definition: typedefs.h:81
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE ACPI_HANDLE Child
Definition: acpixf.h:716
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define USERTAG_WINDOWLIST
Definition: tags.h:297

Referenced by NtUserFindWindowEx().

◆ IntFixWindowCoordinates()

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

Definition at line 1522 of file window.c.

1523 {
1524 #define IS_DEFAULT(x) ((x) == CW_USEDEFAULT || (x) == (SHORT)0x8000)
1525 
1526  /* default positioning for overlapped windows */
1527  if(!(Cs->style & (WS_POPUP | WS_CHILD)))
1528  {
1529  PMONITOR pMonitor;
1530  PRTL_USER_PROCESS_PARAMETERS ProcessParams;
1531 
1532  pMonitor = UserGetPrimaryMonitor();
1533 
1534  /* Check if we don't have a monitor attached yet */
1535  if(pMonitor == NULL)
1536  {
1537  Cs->x = Cs->y = 0;
1538  Cs->cx = 800;
1539  Cs->cy = 600;
1540  return;
1541  }
1542 
1543  ProcessParams = PsGetCurrentProcess()->Peb->ProcessParameters;
1544 
1545  if (IS_DEFAULT(Cs->x))
1546  {
1547  if (!IS_DEFAULT(Cs->y)) *dwShowMode = Cs->y;
1548 
1549  if(ProcessParams->WindowFlags & STARTF_USEPOSITION)
1550  {
1551  Cs->x = ProcessParams->StartingX;
1552  Cs->y = ProcessParams->StartingY;
1553  }
1554  else
1555  {
1558  if (Cs->x > ((pMonitor->rcWork.right - pMonitor->rcWork.left) / 4) ||
1559  Cs->y > ((pMonitor->rcWork.bottom - pMonitor->rcWork.top) / 4))
1560  {
1561  /* reset counter and position */
1562  Cs->x = 0;
1563  Cs->y = 0;
1564  pMonitor->cWndStack = 0;
1565  }
1566  pMonitor->cWndStack++;
1567  }
1568  }
1569 
1570  if (IS_DEFAULT(Cs->cx))
1571  {
1572  if (ProcessParams->WindowFlags & STARTF_USEPOSITION)
1573  {
1574  Cs->cx = ProcessParams->CountX;
1575  Cs->cy = ProcessParams->CountY;
1576  }
1577  else
1578  {
1579  Cs->cx = (pMonitor->rcWork.right - pMonitor->rcWork.left) * 3 / 4;
1580  Cs->cy = (pMonitor->rcWork.bottom - pMonitor->rcWork.top) * 3 / 4;
1581  }
1582  }
1583  /* neither x nor cx are default. Check the y values .
1584  * In the trace we see Outlook and Outlook Express using
1585  * cy set to CW_USEDEFAULT when opening the address book.
1586  */
1587  else if (IS_DEFAULT(Cs->cy))
1588  {
1589  TRACE("Strange use of CW_USEDEFAULT in nHeight\n");
1590  Cs->cy = (pMonitor->rcWork.bottom - pMonitor->rcWork.top) * 3 / 4;
1591  }
1592  }
1593  else
1594  {
1595  /* if CW_USEDEFAULT is set for non-overlapped windows, both values are set to zero */
1596  if(IS_DEFAULT(Cs->x))
1597  {
1598  Cs->x = 0;
1599  Cs->y = 0;
1600  }
1601  if(IS_DEFAULT(Cs->cx))
1602  {
1603  Cs->cx = 0;
1604  Cs->cy = 0;
1605  }
1606  }
1607 
1608 #undef IS_DEFAULT
1609 }
#define SM_CYSIZE
Definition: winuser.h:982
LONG top
Definition: windef.h:292
#define STARTF_USEPOSITION
Definition: winbase.h:474
#define WS_CHILD
Definition: pedump.c:617
LONG left
Definition: windef.h:291
#define SM_CYFRAME
Definition: winuser.h:986
#define SM_CXFRAME
Definition: winuser.h:984
LONG right
Definition: windef.h:293
SHORT cWndStack
Definition: monitor.h:22
RECT rcWork
Definition: monitor.h:19
#define PsGetCurrentProcess
Definition: psfuncs.h:17
smooth NULL
Definition: ftsmooth.c:416
LONG NTAPI UserGetSystemMetrics(ULONG Index)
Definition: metric.c:180
#define TRACE(s)
Definition: solgame.cpp:4
#define WS_POPUP
Definition: pedump.c:616
PMONITOR NTAPI UserGetPrimaryMonitor(VOID)
Definition: monitor.c:102
#define SM_CXSIZE
Definition: winuser.h:981
LONG bottom
Definition: windef.h:294
#define IS_DEFAULT(x)

Referenced by co_UserCreateWindowEx().

◆ IntGetNonChildAncestor()

PWND FASTCALL IntGetNonChildAncestor ( PWND  pWnd)

Definition at line 323 of file window.c.

324 {
325  while(pWnd && (pWnd->style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
326  pWnd = pWnd->spwndParent;
327  return pWnd;
328 }
#define WS_CHILD
Definition: pedump.c:617
#define WS_POPUP
Definition: pedump.c:616
struct _WND * spwndParent
Definition: ntuser.h:677
DWORD style
Definition: ntuser.h:670

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

◆ IntGetParent()

PWND FASTCALL IntGetParent ( PWND  Wnd)

Definition at line 185 of file window.c.

186 {
187  if (Wnd->style & WS_POPUP)
188  {
189  return Wnd->spwndOwner;
190  }
191  else if (Wnd->style & WS_CHILD)
192  {
193  return Wnd->spwndParent;
194  }
195 
196  return NULL;
197 }
#define WS_CHILD
Definition: pedump.c:617
struct _WND * spwndOwner
Definition: ntuser.h:679
smooth NULL
Definition: ftsmooth.c:416
#define WS_POPUP
Definition: pedump.c:616
struct _WND * spwndParent
Definition: ntuser.h:677
DWORD style
Definition: ntuser.h:670

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

355 {
356  PWND Wnd, FoundWnd;
357  HWND Ret = NULL;
358 
359  Wnd = ValidateHwndNoErr(hWnd);
360  if (!Wnd)
361  return NULL;
362 
363  FoundWnd = NULL;
364  switch (uCmd)
365  {
366  case GW_OWNER:
367  if (Wnd->spwndOwner != NULL)
368  FoundWnd = Wnd->spwndOwner;
369  break;
370 
371  case GW_HWNDFIRST:
372  if(Wnd->spwndParent != NULL)
373  {
374  FoundWnd = Wnd->spwndParent;
375  if (FoundWnd->spwndChild != NULL)
376  FoundWnd = FoundWnd->spwndChild;
377  }
378  break;
379  case GW_HWNDNEXT:
380  if (Wnd->spwndNext != NULL)
381  FoundWnd = Wnd->spwndNext;
382  break;
383 
384  case GW_HWNDPREV:
385  if (Wnd->spwndPrev != NULL)
386  FoundWnd = Wnd->spwndPrev;
387  break;
388 
389  case GW_CHILD:
390  if (Wnd->spwndChild != NULL)
391  FoundWnd = Wnd->spwndChild;
392  break;
393 
394  case GW_HWNDLAST:
395  FoundWnd = Wnd;
396  while ( FoundWnd->spwndNext != NULL)
397  FoundWnd = FoundWnd->spwndNext;
398  break;
399 
400  default:
401  Wnd = NULL;
402  break;
403  }
404 
405  if (FoundWnd != NULL)
406  Ret = UserHMGetHandle(FoundWnd);
407  return Ret;
408 }
#define GW_HWNDNEXT
Definition: winuser.h:756
PWND FASTCALL ValidateHwndNoErr(HWND hWnd)
Definition: window.c:96
#define GW_CHILD
Definition: winuser.h:758
HWND hWnd
Definition: settings.c:17
struct _WND * spwndOwner
Definition: ntuser.h:679
smooth NULL
Definition: ftsmooth.c:416
struct _WND * spwndNext
Definition: ntuser.h:675
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
#define GW_HWNDLAST
Definition: winuser.h:760
#define GW_HWNDFIRST
Definition: winuser.h:759
Definition: ntuser.h:657
#define GW_OWNER
Definition: winuser.h:761
struct _WND * spwndParent
Definition: ntuser.h:677
struct _WND * spwndChild
Definition: ntuser.h:678
#define GW_HWNDPREV
Definition: winuser.h:757
struct _WND * spwndPrev
Definition: ntuser.h:676

Referenced by WinPosFixupFlags().

◆ IntGetWindowContextHelpId()

DWORD FASTCALL IntGetWindowContextHelpId ( PWND  pWnd)

Definition at line 410 of file window.c.

411 {
412  DWORD HelpId;
413 
414  do
415  {
417  if (!HelpId) break;
418  pWnd = IntGetParent(pWnd);
419  }
420  while (pWnd && pWnd->fnid != FNID_DESKTOP);
421  return HelpId;
422 }
#define TRUE
Definition: types.h:120
ATOM atomContextHelpIdProp
Definition: ntuser.h:1020
#define DWORD
Definition: nt_native.h:44
PSERVERINFO gpsi
Definition: main.c:27
DWORD fnid
Definition: ntuser.h:673
#define FNID_DESKTOP
Definition: ntuser.h:824
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:63
PWND FASTCALL IntGetParent(PWND Wnd)
Definition: window.c:185

Referenced by IntDefWindowProc().

◆ IntGetWindowObject()

PWND FASTCALL IntGetWindowObject ( HWND  hWnd)

Definition at line 51 of file window.c.

52 {
53  PWND Window;
54 
55  if (!hWnd) return NULL;
56 
58  if (Window)
59  Window->head.cLockObj++;
60 
61  return Window;
62 }
HWND hWnd
Definition: settings.c:17
Definition: window.c:29
smooth NULL
Definition: ftsmooth.c:416
int Window
Definition: x11stubs.h:26
Definition: ntuser.h:657
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103

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

◆ IntGetWindowProc()

WNDPROC FASTCALL IntGetWindowProc ( PWND  pWnd,
BOOL  Ansi 
)

Definition at line 735 of file window.c.

737 {
738  INT i;
739  PCLS Class;
740  WNDPROC gcpd, Ret = 0;
741 
743 
744  Class = pWnd->pcls;
745 
746  if (pWnd->state & WNDS_SERVERSIDEWINDOWPROC)
747  {
748  for ( i = FNID_FIRST; i <= FNID_SWITCH; i++)
749  {
750  if (GETPFNSERVER(i) == pWnd->lpfnWndProc)
751  {
752  if (Ansi)
753  Ret = GETPFNCLIENTA(i);
754  else
755  Ret = GETPFNCLIENTW(i);
756  }
757  }
758  return Ret;
759  }
760 
761  if (Class->fnid == FNID_EDIT)
762  Ret = pWnd->lpfnWndProc;
763  else
764  {
765  Ret = pWnd->lpfnWndProc;
766 
767  if (Class->fnid <= FNID_GHOST && Class->fnid >= FNID_BUTTON)
768  {
769  if (Ansi)
770  {
771  if (GETPFNCLIENTW(Class->fnid) == pWnd->lpfnWndProc)
772  Ret = GETPFNCLIENTA(Class->fnid);
773  }
774  else
775  {
776  if (GETPFNCLIENTA(Class->fnid) == pWnd->lpfnWndProc)
777  Ret = GETPFNCLIENTW(Class->fnid);
778  }
779  }
780  if ( Ret != pWnd->lpfnWndProc)
781  return Ret;
782  }
783  if ( Ansi == !!(pWnd->state & WNDS_ANSIWINDOWPROC) )
784  return Ret;
785 
786  gcpd = (WNDPROC)UserGetCPD(
787  pWnd,
789  (ULONG_PTR)Ret);
790 
791  return (gcpd ? gcpd : Ret);
792 }
static const WCHAR Class[]
Definition: cfgmgr.c:31
#define FNID_EDIT
Definition: ntuser.h:832
#define TRUE
Definition: types.h:120
#define GETPFNSERVER(fnid)
Definition: ntuser.h:870
#define GETPFNCLIENTW(fnid)
Definition: ntuser.h:867
WNDPROC lpfnWndProc
Definition: ntuser.h:682
ULONG_PTR FASTCALL UserGetCPD(PVOID pvClsWnd, GETCPD Flags, ULONG_PTR ProcIn)
Definition: callproc.c:107
int32_t INT
Definition: typedefs.h:56
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
Definition: ntuser.h:533
#define FNID_SWITCH
Definition: ntuser.h:827
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define GETPFNCLIENTA(fnid)
Definition: ntuser.h:865
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2859
#define FNID_GHOST
Definition: ntuser.h:837
#define WNDS_ANSIWINDOWPROC
Definition: ntuser.h:592
#define FNID_BUTTON
Definition: ntuser.h:828
DWORD state
Definition: ntuser.h:665
BOOL FASTCALL UserIsEnteredExclusive(VOID)
Definition: ntuser.c:231
#define ULONG_PTR
Definition: config.h:101
#define WNDS_SERVERSIDEWINDOWPROC
Definition: ntuser.h:591
#define FNID_FIRST
Definition: ntuser.h:820
PCLS pcls
Definition: ntuser.h:684

Referenced by IntSetWindowProc().

◆ IntIsChildWindow()

BOOL FASTCALL IntIsChildWindow ( PWND  Parent,
PWND  BaseWindow 
)

Definition at line 882 of file window.c.

883 {
885  do
886  {
887  if ( Window == NULL || (Window->style & (WS_POPUP|WS_CHILD)) != WS_CHILD )
888  return FALSE;
889 
890  Window = Window->spwndParent;
891  }
892  while(Parent != Window);
893  return TRUE;
894 }
#define TRUE
Definition: types.h:120
#define WS_CHILD
Definition: pedump.c:617
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:716
Definition: window.c:29
smooth NULL
Definition: ftsmooth.c:416
Definition: ntuser.h:657
#define WS_POPUP
Definition: pedump.c:616
struct tagBaseWindow BaseWindow

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

◆ IntIsTopLevelWindow()

BOOL FASTCALL IntIsTopLevelWindow ( PWND  pWnd)

Definition at line 331 of file window.c.

332 {
333  if ( pWnd->spwndParent &&
334  pWnd->spwndParent == co_GetDesktopWindow(pWnd) ) return TRUE;
335  return FALSE;
336 }
#define TRUE
Definition: types.h:120
PWND FASTCALL co_GetDesktopWindow(PWND pWnd)
Definition: desktop.c:1330
struct _WND * spwndParent
Definition: ntuser.h:677

Referenced by co_UserCreateWindowEx(), and co_UserDestroyWindow().

◆ IntIsWindow()

BOOL FASTCALL IntIsWindow ( HWND  hWnd)

Definition at line 157 of file window.c.

158 {
159  PWND Window;
160 
161  if (!(Window = UserGetWindowObject(hWnd)))
162  {
163  return FALSE;
164  }
165 
166  return TRUE;
167 }
#define TRUE
Definition: types.h:120
HWND hWnd
Definition: settings.c:17
Definition: window.c:29
int Window
Definition: x11stubs.h:26
Definition: ntuser.h:657
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103

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

◆ IntIsWindowVisible()

BOOL FASTCALL IntIsWindowVisible ( PWND  Wnd)

Definition at line 170 of file window.c.

171 {
172  PWND Temp = Wnd;
173  for (;;)
174  {
175  if (!Temp) return TRUE;
176  if (!(Temp->style & WS_VISIBLE)) break;
177  if (Temp->style & WS_MINIMIZE && Temp != Wnd) break;
178  if (Temp->fnid == FNID_DESKTOP) return TRUE;
179  Temp = Temp->spwndParent;
180  }
181  return FALSE;
182 }
#define TRUE
Definition: types.h:120
#define WS_MINIMIZE
Definition: pedump.c:622
DWORD fnid
Definition: ntuser.h:673
#define FNID_DESKTOP
Definition: ntuser.h:824
Definition: ntuser.h:657
struct _WND * spwndParent
Definition: ntuser.h:677
#define WS_VISIBLE
Definition: pedump.c:620
DWORD style
Definition: ntuser.h:670

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

◆ IntLinkHwnd()

VOID FASTCALL IntLinkHwnd ( PWND  Wnd,
HWND  hWndPrev 
)

Definition at line 937 of file window.c.

938 {
939  if (hWndPrev == HWND_NOTOPMOST)
940  {
941  if (!(Wnd->ExStyle & WS_EX_TOPMOST) && (Wnd->ExStyle2 & WS_EX2_LINKED))
942  return; /* nothing to do */
943  Wnd->ExStyle &= ~WS_EX_TOPMOST;
944  hWndPrev = HWND_TOP; /* fallback to the HWND_TOP case */
945  }
946 
947  IntUnlinkWindow(Wnd); /* unlink it from the previous location */
948 
949  if (hWndPrev == HWND_BOTTOM)
950  {
951  /* Link in the bottom of the list */
952  PWND WndInsertAfter;
953 
954  WndInsertAfter = Wnd->spwndParent->spwndChild;
955  while (WndInsertAfter && WndInsertAfter->spwndNext)
956  {
957  WndInsertAfter = WndInsertAfter->spwndNext;
958  }
959 
960  IntLinkWindow(Wnd, WndInsertAfter);
961  Wnd->ExStyle &= ~WS_EX_TOPMOST;
962  }
963  else if (hWndPrev == HWND_TOPMOST)
964  {
965  /* Link in the top of the list */
966  IntLinkWindow(Wnd, NULL);
967  Wnd->ExStyle |= WS_EX_TOPMOST;
968  }
969  else if (hWndPrev == HWND_TOP)
970  {
971  /* Link it after the last topmost window */
972  PWND WndInsertBefore;
973 
974  WndInsertBefore = Wnd->spwndParent->spwndChild;
975 
976  if (!(Wnd->ExStyle & WS_EX_TOPMOST)) /* put it above the first non-topmost window */
977  {
978  while (WndInsertBefore != NULL && WndInsertBefore->spwndNext != NULL)
979  {
980  if (!(WndInsertBefore->ExStyle & WS_EX_TOPMOST))
981  break;
982 
983  if (WndInsertBefore == Wnd->spwndOwner) /* keep it above owner */
984  {
985  Wnd->ExStyle |= WS_EX_TOPMOST;
986  break;
987  }
988  WndInsertBefore = WndInsertBefore->spwndNext;
989  }
990  }
991 
992  IntLinkWindow(Wnd, WndInsertBefore ? WndInsertBefore->spwndPrev : NULL);
993  }
994  else
995  {
996  /* Link it after hWndPrev */
997  PWND WndInsertAfter;
998 
999  WndInsertAfter = UserGetWindowObject(hWndPrev);
1000  /* Are we called with an erroneous handle */
1001  if (WndInsertAfter == NULL)
1002  {
1003  /* Link in a default position */
1004  IntLinkHwnd(Wnd, HWND_TOP);
1005  return;
1006  }
1007 
1008  if (Wnd == WndInsertAfter)
1009  ERR("IntLinkHwnd -- Trying to link window 0x%p to itself!!\n", Wnd);
1010  IntLinkWindow(Wnd, WndInsertAfter);
1011 
1012  /* Fix the WS_EX_TOPMOST flag */
1013  if (!(WndInsertAfter->ExStyle & WS_EX_TOPMOST))
1014  {
1015  Wnd->ExStyle &= ~WS_EX_TOPMOST;
1016  }
1017  else
1018  {
1019  if (WndInsertAfter->spwndNext &&
1020  (WndInsertAfter->spwndNext->ExStyle & WS_EX_TOPMOST))
1021  {
1022  Wnd->ExStyle |= WS_EX_TOPMOST;
1023  }
1024  }
1025  }
1026  Wnd->ExStyle2 |= WS_EX2_LINKED;
1027 }
DWORD ExStyle
Definition: ntuser.h:668
VOID FASTCALL IntUnlinkWindow(PWND Wnd)
Definition: window.c:1306
DWORD ExStyle2
Definition: ntuser.h:709
#define WS_EX2_LINKED
Definition: ntuser.h:644
#define HWND_TOPMOST
Definition: winuser.h:1194
#define HWND_TOP
Definition: winuser.h:1193
VOID FASTCALL IntLinkHwnd(PWND Wnd, HWND hWndPrev)
Definition: window.c:937
struct _WND * spwndOwner
Definition: ntuser.h:679
smooth NULL
Definition: ftsmooth.c:416
struct _WND * spwndNext
Definition: ntuser.h:675
#define HWND_BOTTOM
Definition: winuser.h:1191
#define WS_EX_TOPMOST
Definition: pedump.c:647
#define ERR(fmt,...)
Definition: debug.h:109
Definition: ntuser.h:657
VOID FASTCALL IntLinkWindow(PWND Wnd, PWND WndInsertAfter)
Definition: window.c:899
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
struct _WND * spwndParent
Definition: ntuser.h:677
#define HWND_NOTOPMOST
Definition: winuser.h:1192
struct _WND * spwndPrev
Definition: ntuser.h:676

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

◆ IntLinkWindow()

VOID FASTCALL IntLinkWindow ( PWND  Wnd,
PWND  WndInsertAfter 
)

Definition at line 899 of file window.c.

903 {
904  if (Wnd == WndInsertAfter)
905  {
906  ERR("IntLinkWindow -- Trying to link window 0x%p to itself!!\n", Wnd);
907  return;
908  }
909 
910  Wnd->spwndPrev = WndInsertAfter;
911  if (Wnd->spwndPrev)
912  {
913  /* Link after WndInsertAfter */
914  ASSERT(Wnd != WndInsertAfter->spwndNext);
915  Wnd->spwndNext = WndInsertAfter->spwndNext;
916  if (Wnd->spwndNext)
917  Wnd->spwndNext->spwndPrev = Wnd;
918 
919  ASSERT(Wnd != Wnd->spwndPrev);
920  Wnd->spwndPrev->spwndNext = Wnd;
921  }
922  else
923  {
924  /* Link at the top */
925  ASSERT(Wnd != Wnd->spwndParent->spwndChild);
926  Wnd->spwndNext = Wnd->spwndParent->spwndChild;
927  if (Wnd->spwndNext)
928  Wnd->spwndNext->spwndPrev = Wnd;
929 
930  Wnd->spwndParent->spwndChild = Wnd;
931  }
932 }
struct _WND * spwndNext
Definition: ntuser.h:675
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ERR(fmt,...)
Definition: debug.h:109
struct _WND * spwndParent
Definition: ntuser.h:677
struct _WND * spwndPrev
Definition: ntuser.h:676

Referenced by IntLinkHwnd().

◆ IntProcessOwnerSwap()

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

Definition at line 1030 of file window.c.

1031 {
1032  if (WndOldOwner)
1033  {
1034  if (Wnd->head.pti != WndOldOwner->head.pti)
1035  {
1036  if (!WndNewOwner ||
1037  Wnd->head.pti == WndNewOwner->head.pti ||
1038  WndOldOwner->head.pti != WndNewOwner->head.pti )
1039  {
1040  //ERR("ProcessOwnerSwap Old out.\n");
1041  UserAttachThreadInput(Wnd->head.pti, WndOldOwner->head.pti, FALSE);
1042  }
1043  }
1044  }
1045  if (WndNewOwner)
1046  {
1047  if (Wnd->head.pti != WndNewOwner->head.pti)
1048  {
1049  if (!WndOldOwner ||
1050  WndOldOwner->head.pti != WndNewOwner->head.pti )
1051  {
1052  //ERR("ProcessOwnerSwap New in.\n");
1053  UserAttachThreadInput(Wnd->head.pti, WndNewOwner->head.pti, TRUE);
1054  }
1055  }
1056  }
1057  // FIXME: System Tray checks.
1058 }
#define TRUE
Definition: types.h:120
NTSTATUS FASTCALL UserAttachThreadInput(PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach)
Definition: input.c:483
THRDESKHEAD head
Definition: ntuser.h:659

Referenced by IntSetOwner().

◆ IntRemoveTrackMouseEvent()

VOID FASTCALL IntRemoveTrackMouseEvent ( PDESKTOP  pDesk)

Definition at line 347 of file mouse.c.

349 {
350  /* Generate a leave message */
351  if (pDesk->dwDTFlags & DF_TME_LEAVE)
352  {
353  UINT uMsg = (pDesk->htEx != HTCLIENT) ? WM_NCMOUSELEAVE : WM_MOUSELEAVE;
354  UserPostMessage(UserHMGetHandle(pDesk->spwndTrack), uMsg, 0, 0);
355  }
356  /* Kill the timer */
357  if (pDesk->dwDTFlags & DF_TME_HOVER)
359 
360  /* Reset state */
361  pDesk->dwDTFlags &= ~(DF_TME_LEAVE|DF_TME_HOVER);
362  pDesk->spwndTrack = NULL;
363 }
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1189
DWORD htEx
Definition: desktop.h:32
#define TRUE
Definition: types.h:120
PWND spwndTrack
Definition: desktop.h:31
#define ID_EVENT_SYSTIMER_MOUSEHOVER
Definition: timer.h:27
BOOL FASTCALL IntKillTimer(PWND Window, UINT_PTR IDEvent, BOOL SystemTimer)
Definition: timer.c:577
#define DF_TME_LEAVE
Definition: desktop.h:48
DWORD dwDTFlags
Definition: desktop.h:12
#define WM_MOUSELEAVE
Definition: commctrl.h:4946
smooth NULL
Definition: ftsmooth.c:416
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
#define DF_TME_HOVER
Definition: desktop.h:47
unsigned int UINT
Definition: ndis.h:50
#define WM_NCMOUSELEAVE
Definition: winuser.h:1818
#define HTCLIENT
Definition: winuser.h:2429

Referenced by IntSendDestroyMsg().

◆ IntSendDestroyMsg()

static void IntSendDestroyMsg ( HWND  hWnd)
static

Definition at line 433 of file window.c.

434 {
435  PTHREADINFO ti;
436  PWND Window;
437 
440 
441  if (Window)
442  {
443  /*
444  * Look whether the focus is within the tree of windows
445  * we will be destroying.
446  */
447  // Rule #1
448  if ( ti->MessageQueue->spwndActive == Window || // Fixes CORE-106 RegSvr32 exit and return focus to CMD.
449  (ti->MessageQueue->spwndActive == NULL && ti->MessageQueue == IntGetFocusMessageQueue()) )
450  {
452  }
453 
454  /* Fixes CMD properties closing and returning focus to CMD */
455  if (ti->MessageQueue->spwndFocus == Window)
456  {
457  if ((Window->style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
458  {
459  co_UserSetFocus(Window->spwndParent);
460  }
461  else
462  {
464  }
465  }
466 
467  if (ti->MessageQueue->CaretInfo.hWnd == UserHMGetHandle(Window))
468  {
469  co_IntDestroyCaret(ti);
470  }
471 
472  /* If the window being destroyed is currently tracked... */
473  if (ti->rpdesk->spwndTrack == Window)
474  {
476  }
477  }
478 
479  /* If the window being destroyed is the current clipboard owner... */
480  if (ti->ppi->prpwinsta != NULL && Window == ti->ppi->prpwinsta->spwndClipOwner)
481  {
482  /* ... make it release the clipboard */
484  }
485 
486  /* Send the WM_DESTROY to the window */
488 
489  /*
490  * This WM_DESTROY message can trigger re-entrant calls to DestroyWindow
491  * make sure that the window still exists when we come back.
492  */
493  if (IntIsWindow(hWnd))
494  {
495  HWND* pWndArray;
496  int i;
497 
498  if (!(pWndArray = IntWinListChildren( Window ))) return;
499 
500  for (i = 0; pWndArray[i]; i++)
501  {
502  if (IntIsWindow( pWndArray[i] )) IntSendDestroyMsg( pWndArray[i] );
503  }
505  }
506  else
507  {
508  TRACE("destroyed itself while in WM_DESTROY!\n");
509  }
510 }
HWND FASTCALL co_UserSetFocus(PWND Window)
Definition: focus.c:1196
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
HWND hWnd
Definition: settings.c:17
VOID FASTCALL UserClipboardRelease(PWND pWindow)
Definition: clipboard.c:359
#define WS_CHILD
Definition: pedump.c:617
struct _WINSTATION_OBJECT * prpwinsta
Definition: win32.h:257
VOID FASTCALL co_WinPosActivateOtherWindow(PWND Wnd)
Definition: winpos.c:395
PUSER_MESSAGE_QUEUE FASTCALL IntGetFocusMessageQueue(VOID)
Definition: desktop.c:1271
struct _DESKTOP * rpdesk
Definition: win32.h:91
PPROCESSINFO ppi
Definition: win32.h:87
Definition: window.c:29
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
BOOL FASTCALL co_IntDestroyCaret(PTHREADINFO Win32Thread)
Definition: caret.c:164
smooth NULL
Definition: ftsmooth.c:416
#define WM_DESTROY
Definition: winuser.h:1591
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
#define TRACE(s)
Definition: solgame.cpp:4
static void IntSendDestroyMsg(HWND hWnd)
Definition: window.c:433
BOOL FASTCALL IntIsWindow(HWND hWnd)
Definition: window.c:157
int Window
Definition: x11stubs.h:26
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1291
HWND *FASTCALL IntWinListChildren(PWND Window)
Definition: window.c:255
Definition: ntuser.h:657
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:88
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
#define WS_POPUP
Definition: pedump.c:616
VOID FASTCALL IntRemoveTrackMouseEvent(PDESKTOP pDesk)
Definition: mouse.c:347
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define USERTAG_WINDOWLIST
Definition: tags.h:297

Referenced by co_UserDestroyWindow().

◆ IntSendParentNotify()

static void IntSendParentNotify ( PWND  pWindow,
UINT  msg 
)
static

Definition at line 1503 of file window.c.

1504 {
1505  if ( (pWindow->style & (WS_CHILD | WS_POPUP)) == WS_CHILD &&
1506  !(pWindow->ExStyle & WS_EX_NOPARENTNOTIFY))
1507  {
1508  if (VerifyWnd(pWindow->spwndParent) && !UserIsDesktopWindow(pWindow->spwndParent))
1509  {
1511  UserRefObjectCo(pWindow->spwndParent, &Ref);
1512  co_IntSendMessage( pWindow->spwndParent->head.h,
1514  MAKEWPARAM( msg, pWindow->IDMenu),
1515  (LPARAM)pWindow->head.h );
1516  UserDerefObjectCo(pWindow->spwndParent);
1517  }
1518  }
1519 }
DWORD ExStyle
Definition: ntuser.h:668
#define MAKEWPARAM(l, h)
Definition: winuser.h:3916
#define UserIsDesktopWindow(pWnd)
Definition: desktop.h:220
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:25
#define WS_CHILD
Definition: pedump.c:617
#define WM_PARENTNOTIFY
Definition: winuser.h:1779
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:38
THRDESKHEAD head
Definition: ntuser.h:659
Definition: object.h:3
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR IDMenu
Definition: ntuser.h:695
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1291
#define WS_EX_NOPARENTNOTIFY
Definition: pedump.c:646
#define WS_POPUP
Definition: pedump.c:616
#define msg(x)
Definition: auth_time.c:54
struct _WND * spwndParent
Definition: ntuser.h:677
PWND FASTCALL VerifyWnd(PWND pWnd)
Definition: window.c:64
DWORD style
Definition: ntuser.h:670

Referenced by co_UserCreateWindowEx(), and co_UserDestroyWindow().

◆ IntSetOwner()

HWND FASTCALL IntSetOwner ( HWND  hWnd,
HWND  hWndNewOwner 
)

Definition at line 1061 of file window.c.

1062 {
1063  PWND Wnd, WndOldOwner, WndNewOwner;
1064  HWND ret;
1065 
1066  Wnd = IntGetWindowObject(hWnd);
1067  if(!Wnd)
1068  return NULL;
1069 
1070  WndOldOwner = Wnd->spwndOwner;
1071 
1072  ret = WndOldOwner ? UserHMGetHandle(WndOldOwner) : 0;
1073  WndNewOwner = UserGetWindowObject(hWndNewOwner);
1074 
1075  if (!WndNewOwner && hWndNewOwner)
1076  {
1078  ret = NULL;
1079  goto Error;
1080  }
1081 
1082  /* if parent belongs to a different thread and the window isn't */
1083  /* top-level, attach the two threads */
1084  IntProcessOwnerSwap(Wnd, WndNewOwner, WndOldOwner);
1085 
1086  if (IntValidateOwnerDepth(Wnd, WndNewOwner))
1087  {
1088  if (WndNewOwner)
1089  {
1090  Wnd->spwndOwner= WndNewOwner;
1091  }
1092  else
1093  {
1094  Wnd->spwndOwner = NULL;
1095  }
1096  }
1097  else
1098  {
1099  IntProcessOwnerSwap(Wnd, WndOldOwner, WndNewOwner);
1101  ret = NULL;
1102  }
1103 Error:
1104  UserDereferenceObject(Wnd);
1105  return ret;
1106 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
BOOL FASTCALL IntValidateOwnerDepth(PWND Wnd, PWND Owner)
Definition: window.c:339
HWND hWnd
Definition: settings.c:17
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:610
PWND FASTCALL IntGetWindowObject(HWND hWnd)
Definition: window.c:51
struct _WND * spwndOwner
Definition: ntuser.h:679
smooth NULL
Definition: ftsmooth.c:416
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
BOOL Error
Definition: chkdsk.c:66
int ret
Definition: ntuser.h:657
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
VOID FASTCALL IntProcessOwnerSwap(PWND Wnd, PWND WndNewOwner, PWND WndOldOwner)
Definition: window.c:1030

Referenced by co_IntSetWindowLongPtr().

◆ IntSetStyle()

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

Definition at line 124 of file window.c.

125 {
126  ULONG styleOld, styleNew;
127  styleOld = pwnd->style;
128  styleNew = (pwnd->style | set_bits) & ~clear_bits;
129  if (styleNew == styleOld) return styleNew;
130  pwnd->style = styleNew;
131  if ((styleOld ^ styleNew) & WS_VISIBLE) // State Change.
132  {
133  if (styleOld & WS_VISIBLE) pwnd->head.pti->cVisWindows--;
134  if (styleNew & WS_VISIBLE) pwnd->head.pti->cVisWindows++;
135  DceResetActiveDCEs( pwnd );
136  }
137  return styleOld;
138 }
THRDESKHEAD head
Definition: ntuser.h:659
VOID FASTCALL DceResetActiveDCEs(PWND Window)
Definition: windc.c:815
unsigned int ULONG
Definition: retypes.h:1
#define WS_VISIBLE
Definition: pedump.c:620
DWORD style
Definition: ntuser.h:670

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

◆ IntSetWindowProc()

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

Definition at line 795 of file window.c.

798 {
799  INT i;
800  PCALLPROCDATA CallProc;
801  PCLS Class;
802  WNDPROC Ret, chWndProc = NULL;
803 
804  // Retrieve previous window proc.
805  Ret = IntGetWindowProc(pWnd, Ansi);
806 
807  Class = pWnd->pcls;
808 
809  if (IsCallProcHandle(NewWndProc))
810  {
811  CallProc = UserGetObject(gHandleTable, NewWndProc, TYPE_CALLPROC);
812  if (CallProc)
813  { // Reset new WndProc.
814  NewWndProc = CallProc->pfnClientPrevious;
815  // Reset Ansi from CallProc handle. This is expected with wine "deftest".
816  Ansi = !!(CallProc->wType & UserGetCPDU2A);
817  }
818  }
819  // Switch from Client Side call to Server Side call if match. Ref: "deftest".
820  for ( i = FNID_FIRST; i <= FNID_SWITCH; i++)
821  {
822  if (GETPFNCLIENTW(i) == NewWndProc)
823  {
824  chWndProc = GETPFNSERVER(i);
825  break;
826  }
827  if (GETPFNCLIENTA(i) == NewWndProc)
828  {
829  chWndProc = GETPFNSERVER(i);
830  break;
831  }
832  }
833  // If match, set/reset to Server Side and clear ansi.
834  if (chWndProc)
835  {
836  pWnd->lpfnWndProc = chWndProc;
837  pWnd->Unicode = TRUE;
838  pWnd->state &= ~WNDS_ANSIWINDOWPROC;
840  }
841  else
842  {
843  pWnd->Unicode = !Ansi;
844  // Handle the state change in here.
845  if (Ansi)
846  pWnd->state |= WNDS_ANSIWINDOWPROC;
847  else
848  pWnd->state &= ~WNDS_ANSIWINDOWPROC;
849 
850  if (pWnd->state & WNDS_SERVERSIDEWINDOWPROC)
852 
853  if (!NewWndProc) NewWndProc = pWnd->lpfnWndProc;
854 
855  if (Class->fnid <= FNID_GHOST && Class->fnid >= FNID_BUTTON)
856  {
857  if (Ansi)
858  {
859  if (GETPFNCLIENTW(Class->fnid) == NewWndProc)
860  chWndProc = GETPFNCLIENTA(Class->fnid);
861  }
862  else
863  {
864  if (GETPFNCLIENTA(Class->fnid) == NewWndProc)
865  chWndProc = GETPFNCLIENTW(Class->fnid);
866  }
867  }
868  // Now set the new window proc.
869  pWnd->lpfnWndProc = (chWndProc ? chWndProc : NewWndProc);
870  }
871  return Ret;
872 }
static const WCHAR Class[]
Definition: cfgmgr.c:31
#define TRUE
Definition: types.h:120
#define GETPFNSERVER(fnid)
Definition: ntuser.h:870
WNDPROC pfnClientPrevious
Definition: ntuser.h:520
#define GETPFNCLIENTW(fnid)
Definition: ntuser.h:867
WNDPROC lpfnWndProc
Definition: ntuser.h:682
int32_t INT
Definition: typedefs.h:56
GETCPD wType
Definition: ntuser.h:521
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
smooth NULL
Definition: ftsmooth.c:416
Definition: ntuser.h:533
#define FNID_SWITCH
Definition: ntuser.h:827
WNDPROC FASTCALL IntGetWindowProc(PWND pWnd, BOOL Ansi)
Definition: window.c:735
#define GETPFNCLIENTA(fnid)
Definition: ntuser.h:865
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2859
#define FNID_GHOST
Definition: ntuser.h:837
PVOID UserGetObject(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type)
Definition: object.c:462
#define WNDS_ANSIWINDOWPROC
Definition: ntuser.h:592
#define FNID_BUTTON
Definition: ntuser.h:828
DWORD state
Definition: ntuser.h:665
static __inline BOOL IsCallProcHandle(IN WNDPROC lpWndProc)
Definition: class.h:13
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
#define WNDS_SERVERSIDEWINDOWPROC
Definition: ntuser.h:591
#define FNID_FIRST
Definition: ntuser.h:820
UINT Unicode
Definition: ntuser.h:720
PCLS pcls
Definition: ntuser.h:684

Referenced by co_IntSetWindowLongPtr().

◆ IntShowOwnedPopups()

BOOL FASTCALL IntShowOwnedPopups ( PWND  OwnerWnd,
BOOL  fShow 
)

Definition at line 4427 of file window.c.

4428 {
4429  int count = 0;
4430  PWND pWnd;
4431  HWND *win_array;
4432 
4433 // ASSERT(OwnerWnd);
4434 
4435  TRACE("Enter ShowOwnedPopups Show: %s\n", (fShow ? "TRUE" : "FALSE"));
4436 
4437  /* NOTE: Popups are not children */
4438  win_array = IntWinListOwnedPopups(OwnerWnd);
4439 
4440  if (!win_array)
4441  return TRUE;
4442 
4443  while (win_array[count])
4444  count++;
4445  while (--count >= 0)
4446  {
4447  if (!(pWnd = ValidateHwndNoErr( win_array[count] )))
4448  continue;
4449  if (pWnd->spwndOwner != OwnerWnd)
4450  continue;
4451 
4452  if (fShow)
4453  {
4454  if (pWnd->state & WNDS_HIDDENPOPUP)
4455  {
4456  /* In Windows, ShowOwnedPopups(TRUE) generates
4457  * WM_SHOWWINDOW messages with SW_PARENTOPENING,
4458  * regardless of the state of the owner
4459  */
4461  pWnd->state &= ~WNDS_HIDDENPOPUP;
4462  continue;
4463  }
4464  }
4465  else
4466  {
4467  if (pWnd->style & WS_VISIBLE)
4468  {
4469  /* In Windows, ShowOwnedPopups(FALSE) generates
4470  * WM_SHOWWINDOW messages with SW_PARENTCLOSING,
4471  * regardless of the state of the owner
4472  */
4474  pWnd->state |= WNDS_HIDDENPOPUP;
4475  continue;
4476  }
4477  }
4478  }
4479  ExFreePoolWithTag(win_array,