Window = UserGetWindowObject(hWnd);
if (Window)
{
- ASSERT(USER_BODY_TO_HEADER(Window)->RefCount >= 0);
+ ASSERT(Window->head.cLockObj >= 0);
- USER_BODY_TO_HEADER(Window)->RefCount++;
+ Window->head.cLockObj++;
}
return Window;
}
/* temp hack */
PWINDOW_OBJECT FASTCALL UserGetWindowObject(HWND hWnd)
{
- PW32THREADINFO ti;
+ PTHREADINFO ti;
PWINDOW_OBJECT Window;
if (PsGetCurrentProcess() != PsInitialSystemProcess)
}
Window = (PWINDOW_OBJECT)UserGetObject(gHandleTable, hWnd, otWindow);
- if (!Window || 0 != (Window->Status & WINDOWSTATUS_DESTROYED))
+ if (!Window || 0 != (Window->state & WINDOWSTATUS_DESTROYED))
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
return NULL;
}
- ASSERT(USER_BODY_TO_HEADER(Window)->RefCount >= 0);
+ ASSERT(Window->head.cLockObj >= 0);
return Window;
}
}
else if (Wnd->Wnd->style & WS_CHILD)
{
- return Wnd->Parent;
+ return Wnd->spwndParent;
}
return NULL;
if (!Window) return NULL;
- for (Child = Window->FirstChild; Child; Child = Child->NextSibling)
+ for (Child = Window->spwndChild; Child; Child = Child->spwndNext)
++NumChildren;
List = ExAllocatePoolWithTag(PagedPool, (NumChildren + 1) * sizeof(HWND), TAG_WINLIST);
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return NULL;
}
- for (Child = Window->FirstChild, Index = 0;
+ for (Child = Window->spwndChild, Index = 0;
Child != NULL;
- Child = Child->NextSibling, ++Index)
+ Child = Child->spwndNext, ++Index)
List[Index] = Child->hSelf;
List[Index] = NULL;
}
static VOID
-UserFreeWindowInfo(PW32THREADINFO ti, PWINDOW_OBJECT WindowObject)
+UserFreeWindowInfo(PTHREADINFO ti, PWINDOW_OBJECT WindowObject)
{
PCLIENTINFO ClientInfo = GetWin32ClientInfo();
PWND Wnd = WindowObject->Wnd;
+ if (!Wnd) return;
+
if (ClientInfo->CallbackWnd.pvWnd == DesktopHeapAddressToUser(WindowObject->Wnd))
{
ClientInfo->CallbackWnd.hWnd = NULL;
{
Wnd->strName.Length = 0;
Wnd->strName.MaximumLength = 0;
- DesktopHeapFree(Wnd->rpdesk,
+ DesktopHeapFree(Wnd->head.rpdesk,
Wnd->strName.Buffer);
Wnd->strName.Buffer = NULL;
}
- DesktopHeapFree(Wnd->rpdesk, Wnd);
+ DesktopHeapFree(Wnd->head.rpdesk, Wnd);
WindowObject->Wnd = NULL;
}
*/
static LRESULT co_UserFreeWindow(PWINDOW_OBJECT Window,
- PW32PROCESS ProcessData,
+ PPROCESSINFO ProcessData,
PTHREADINFO ThreadData,
BOOLEAN SendMessages)
{
Wnd = Window->Wnd;
- if(Window->Status & WINDOWSTATUS_DESTROYING)
+ if(Window->state & WINDOWSTATUS_DESTROYING)
{
DPRINT("Tried to call IntDestroyWindow() twice\n");
return 0;
}
- Window->Status |= WINDOWSTATUS_DESTROYING;
+ Window->state |= WINDOWSTATUS_DESTROYING;
Wnd->style &= ~WS_VISIBLE;
+
+ IntNotifyWinEvent(EVENT_OBJECT_DESTROY, Wnd, OBJID_WINDOW, 0);
+
/* remove the window already at this point from the thread window list so we
don't get into trouble when destroying the thread windows while we're still
in IntDestroyWindow() */
IntDeRegisterShellHookWindow(Window->hSelf);
- IntNotifyWinEvent(EVENT_OBJECT_DESTROY, Window->hSelf, OBJID_WINDOW, 0);
-
if(SendMessages)
{
/* Send destroy messages */
co_IntSendMessage(Window->hSelf, WM_NCDESTROY, 0, 0);
}
MsqRemoveTimersWindow(ThreadData->MessageQueue, Window->hSelf);
+ HOOK_DestroyThreadHooks(ThreadData->pEThread); // This is needed here too!
/* flush the message queue */
MsqRemoveWindowMessagesFromQueue(Window);
/* from now on no messages can be sent to this window anymore */
- Window->Status |= WINDOWSTATUS_DESTROYED;
+ Window->state |= WINDOWSTATUS_DESTROYED;
+ Wnd->state |= WNDS_DESTROYED;
+ Wnd->fnid |= FNID_FREED;
+
/* don't remove the WINDOWSTATUS_DESTROYING bit */
/* reset shell window handles */
- if(ThreadData->Desktop)
+ if(ThreadData->rpdesk)
{
- if (Window->hSelf == ThreadData->Desktop->WindowStation->ShellWindow)
- ThreadData->Desktop->WindowStation->ShellWindow = NULL;
+ if (Window->hSelf == ThreadData->rpdesk->rpwinstaParent->ShellWindow)
+ ThreadData->rpdesk->rpwinstaParent->ShellWindow = NULL;
- if (Window->hSelf == ThreadData->Desktop->WindowStation->ShellListView)
- ThreadData->Desktop->WindowStation->ShellListView = NULL;
+ if (Window->hSelf == ThreadData->rpdesk->rpwinstaParent->ShellListView)
+ ThreadData->rpdesk->rpwinstaParent->ShellListView = NULL;
}
/* Unregister hot keys */
/* dereference the class */
IntDereferenceClass(Wnd->pcls,
- Window->ti->pDeskInfo,
- Window->ti->ppi);
+ Window->pti->pDeskInfo,
+ Window->pti->ppi);
Wnd->pcls = NULL;
- if(Window->WindowRegion)
+ if(Window->hrgnClip)
{
- GreDeleteObject(Window->WindowRegion);
+ GreDeleteObject(Window->hrgnClip);
}
ASSERT(Window->Wnd != NULL);
- UserFreeWindowInfo(Window->ti, Window);
+ UserFreeWindowInfo(Window->pti, Window);
UserDereferenceObject(Window);
}
}
-static WNDPROC
-IntGetWindowProc(IN PWINDOW_OBJECT Window,
- IN BOOL Ansi)
+//
+// Same as User32:IntGetWndProc.
+//
+WNDPROC FASTCALL
+IntGetWindowProc(PWND pWnd,
+ BOOL Ansi)
{
- PWND Wnd = Window->Wnd;
+ INT i;
+ PCLS Class;
+ WNDPROC gcpd, Ret = 0;
- ASSERT(UserIsEnteredExclusive() == TRUE);
+ ASSERT(UserIsEnteredExclusive() == TRUE);
- if (Wnd->IsSystem)
- {
- return (Ansi ? Wnd->WndProcExtra : Wnd->lpfnWndProc);
- }
- else
- {
- if (!Ansi == Wnd->Unicode)
- {
- return Wnd->lpfnWndProc;
- }
- else
- {
- if (Wnd->CallProc != NULL)
- {
- return GetCallProcHandle(Wnd->CallProc);
- }
- /* BUGBOY Comments: Maybe theres something Im not undestanding here, but why would a CallProc be created
- on a function that I thought is only suppose to return the current Windows Proc? */
+ Class = pWnd->pcls;
+
+ if (pWnd->state & WNDS_SERVERSIDEWINDOWPROC)
+ {
+ for ( i = FNID_FIRST; i <= FNID_SWITCH; i++)
+ {
+ if (GETPFNSERVER(i) == pWnd->lpfnWndProc)
+ {
+ if (Ansi)
+ Ret = GETPFNCLIENTA(i);
else
- {
- PCALLPROCDATA NewCallProc, CallProc;
+ Ret = GETPFNCLIENTW(i);
+ }
+ }
+ return Ret;
+ }
- NewCallProc = UserFindCallProc(Wnd->pcls,
- Wnd->lpfnWndProc,
- Wnd->Unicode);
- if (NewCallProc == NULL)
- {
- NewCallProc = CreateCallProc(Wnd->pti->pDeskInfo,
- Wnd->lpfnWndProc,
- Wnd->Unicode,
- Wnd->pti->ppi);
- if (NewCallProc == NULL)
- {
- SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
- return NULL;
- }
-
- UserAddCallProcToClass(Wnd->pcls,
- NewCallProc);
- }
+ if (Class->fnid == FNID_EDIT)
+ Ret = pWnd->lpfnWndProc;
+ else
+ {
+ Ret = pWnd->lpfnWndProc;
- CallProc = Wnd->CallProc;
- Wnd->CallProc = NewCallProc;
+ if (Class->fnid <= FNID_GHOST && Class->fnid >= FNID_BUTTON)
+ {
+ if (Ansi)
+ {
+ if (GETPFNCLIENTW(Class->fnid) == pWnd->lpfnWndProc)
+ Ret = GETPFNCLIENTA(Class->fnid);
+ }
+ else
+ {
+ if (GETPFNCLIENTA(Class->fnid) == pWnd->lpfnWndProc)
+ Ret = GETPFNCLIENTW(Class->fnid);
+ }
+ }
+ if ( Ret != pWnd->lpfnWndProc)
+ return Ret;
+ }
+ if ( Ansi == !!(pWnd->state & WNDS_ANSIWINDOWPROC) )
+ return Ret;
- return GetCallProcHandle((CallProc == NULL ? NewCallProc : CallProc));
- }
- }
- }
+ gcpd = (WNDPROC)UserGetCPD(
+ pWnd,
+ (Ansi ? UserGetCPDA2U : UserGetCPDU2A )|UserGetCPDWindow,
+ (ULONG_PTR)Ret);
+
+ return (gcpd ? gcpd : Ret);
+}
+
+static WNDPROC
+IntSetWindowProc(PWND pWnd,
+ WNDPROC NewWndProc,
+ BOOL Ansi)
+{
+ INT i;
+ PCALLPROCDATA CallProc;
+ PCLS Class;
+ WNDPROC Ret, chWndProc = NULL;
+
+ // Retrieve previous window proc.
+ Ret = IntGetWindowProc(pWnd, Ansi);
+
+ Class = pWnd->pcls;
+
+ if (IsCallProcHandle(NewWndProc))
+ {
+ CallProc = UserGetObject(gHandleTable, NewWndProc, otCallProc);
+ if (CallProc)
+ { // Reset new WndProc.
+ NewWndProc = CallProc->pfnClientPrevious;
+ // Reset Ansi from CallProc handle. This is expected with wine "deftest".
+ Ansi = !!(CallProc->wType & UserGetCPDU2A);
+ }
+ }
+ // Switch from Client Side call to Server Side call if match. Ref: "deftest".
+ for ( i = FNID_FIRST; i <= FNID_SWITCH; i++)
+ {
+ if (GETPFNCLIENTW(i) == NewWndProc)
+ {
+ chWndProc = GETPFNSERVER(i);
+ break;
+ }
+ if (GETPFNCLIENTA(i) == NewWndProc)
+ {
+ chWndProc = GETPFNSERVER(i);
+ break;
+ }
+ }
+ // If match, set/reset to Server Side and clear ansi.
+ if (chWndProc)
+ {
+ pWnd->lpfnWndProc = chWndProc;
+ pWnd->Unicode = TRUE;
+ pWnd->state &= ~WNDS_ANSIWINDOWPROC;
+ pWnd->state |= WNDS_SERVERSIDEWINDOWPROC;
+ }
+ else
+ {
+ pWnd->Unicode = !Ansi;
+ // Handle the state change in here.
+ if (Ansi)
+ pWnd->state |= WNDS_ANSIWINDOWPROC;
+ else
+ pWnd->state &= ~WNDS_ANSIWINDOWPROC;
+
+ if (pWnd->state & WNDS_SERVERSIDEWINDOWPROC)
+ pWnd->state &= ~WNDS_SERVERSIDEWINDOWPROC;
+
+ if (!NewWndProc) NewWndProc = pWnd->lpfnWndProc;
+
+ if (Class->fnid <= FNID_GHOST && Class->fnid >= FNID_BUTTON)
+ {
+ if (Ansi)
+ {
+ if (GETPFNCLIENTW(Class->fnid) == NewWndProc)
+ chWndProc = GETPFNCLIENTA(Class->fnid);
+ }
+ else
+ {
+ if (GETPFNCLIENTA(Class->fnid) == NewWndProc)
+ chWndProc = GETPFNCLIENTW(Class->fnid);
+ }
+ }
+ // Now set the new window proc.
+ pWnd->lpfnWndProc = (chWndProc ? chWndProc : NewWndProc);
+ }
+ return Ret;
}
+// Move this to user space!
BOOL FASTCALL
IntGetWindowInfo(PWINDOW_OBJECT Window, PWINDOWINFO pwi)
{
{
W32Thread = PsGetCurrentThreadWin32Thread();
- if(!W32Thread->Desktop)
+ if(!W32Thread->rpdesk)
return NULL;
if(Window->SystemMenu)
}
}
- if(W32Thread->Desktop->WindowStation->SystemMenuTemplate)
+ if(W32Thread->rpdesk->rpwinstaParent->SystemMenuTemplate)
{
/* clone system menu */
- Menu = UserGetMenuObject(W32Thread->Desktop->WindowStation->SystemMenuTemplate);
+ Menu = UserGetMenuObject(W32Thread->rpdesk->rpwinstaParent->SystemMenuTemplate);
if(!Menu)
return NULL;
break;
}
- Window = Window->Parent;
+ Window = Window->spwndParent;
}
return(FALSE);
return FALSE;
}
- Window = Window->Parent;
+ Window = Window->spwndParent;
}
if(Window && Wnd->style & WS_VISIBLE)
return FALSE;
}
+VOID FASTCALL
+IntLinkWnd(
+ PWND Wnd,
+ PWND WndParent,
+ PWND WndPrevSibling) /* set to NULL if top sibling */
+{
+ Wnd->spwndParent = WndParent;
+ if ((Wnd->spwndPrev = WndPrevSibling))
+ {
+ /* link after WndPrevSibling */
+ if ((Wnd->spwndNext = WndPrevSibling->spwndNext))
+ Wnd->spwndNext->spwndPrev = Wnd;
+
+ Wnd->spwndPrev->spwndNext = Wnd;
+ }
+ else
+ {
+ /* link at top */
+ if ((Wnd->spwndNext = WndParent->spwndChild))
+ Wnd->spwndNext->spwndPrev = Wnd;
+
+ WndParent->spwndChild = Wnd;
+ }
+
+}
/* link the window into siblings and parent. children are kept in place. */
VOID FASTCALL
{
PWINDOW_OBJECT Parent;
- Wnd->Parent = WndParent;
- Wnd->Wnd->spwndParent = WndParent ? WndParent->Wnd : NULL;
- if ((Wnd->PrevSibling = WndPrevSibling))
+ IntLinkWnd(Wnd->Wnd,
+ WndParent->Wnd,
+ WndPrevSibling ? WndPrevSibling->Wnd : NULL);
+
+ Wnd->spwndParent = WndParent;
+ if ((Wnd->spwndPrev = WndPrevSibling))
{
/* link after WndPrevSibling */
- if ((Wnd->NextSibling = WndPrevSibling->NextSibling))
- Wnd->NextSibling->PrevSibling = Wnd;
- else if ((Parent = Wnd->Parent))
- {
- if(Parent->LastChild == WndPrevSibling)
- Parent->LastChild = Wnd;
- }
- Wnd->PrevSibling->NextSibling = Wnd;
+ if ((Wnd->spwndNext = WndPrevSibling->spwndNext))
+ Wnd->spwndNext->spwndPrev = Wnd;
+ Wnd->spwndPrev->spwndNext = Wnd;
}
else
{
/* link at top */
- Parent = Wnd->Parent;
- if ((Wnd->NextSibling = WndParent->FirstChild))
- Wnd->NextSibling->PrevSibling = Wnd;
+ Parent = Wnd->spwndParent;
+ if ((Wnd->spwndNext = WndParent->spwndChild))
+ Wnd->spwndNext->spwndPrev = Wnd;
else if (Parent)
{
- Parent->LastChild = Wnd;
- Parent->FirstChild = Wnd;
+ Parent->spwndChild = Wnd;
return;
}
if(Parent)
{
- Parent->FirstChild = Wnd;
+ Parent->spwndChild = Wnd;
}
}
// hWnd = Wnd->hSelf;
// hWndNewParent = WndNewParent->hSelf;
+ /* Some applications try to set a child as a parent */
+ if (IntIsChildWindow(Wnd, WndNewParent))
+ {
+ SetLastWin32Error( ERROR_INVALID_PARAMETER );
+ return NULL;
+ }
+
/*
* Windows hides the window first, then shows it again
* including the WM_SHOWWINDOW messages and all
// return NULL;
/* Window must belong to current process */
- if (Wnd->OwnerThread->ThreadsProcess != PsGetCurrentProcess())
+ if (Wnd->pti->pEThread->ThreadsProcess != PsGetCurrentProcess())
return NULL;
- WndOldParent = Wnd->Parent;
+ WndOldParent = Wnd->spwndParent;
if (WndOldParent) UserReferenceObject(WndOldParent); /* caller must deref */
if (0 == (Wnd->Wnd->ExStyle & WS_EX_TOPMOST))
{
/* Not a TOPMOST window, put after TOPMOSTs of new parent */
- Sibling = WndNewParent->FirstChild;
+ Sibling = WndNewParent->spwndChild;
while (NULL != Sibling && 0 != (Sibling->Wnd->ExStyle & WS_EX_TOPMOST))
{
InsertAfter = Sibling;
- Sibling = Sibling->NextSibling;
+ Sibling = Sibling->spwndNext;
}
}
if (NULL == InsertAfter)
return TRUE;
}
+/* unlink the window from siblings and parent. children are kept in place. */
+VOID FASTCALL
+IntUnlinkWnd(PWND Wnd)
+{
+ if (Wnd->spwndNext)
+ Wnd->spwndNext->spwndPrev = Wnd->spwndPrev;
+
+ if (Wnd->spwndPrev)
+ Wnd->spwndPrev->spwndNext = Wnd->spwndNext;
+
+ if (Wnd->spwndParent && Wnd->spwndParent->spwndChild == Wnd)
+ Wnd->spwndParent->spwndChild = Wnd->spwndNext;
+
+ Wnd->spwndPrev = Wnd->spwndNext = Wnd->spwndParent = NULL;
+}
+
/* unlink the window from siblings and parent. children are kept in place. */
VOID FASTCALL
IntUnlinkWindow(PWINDOW_OBJECT Wnd)
{
- PWINDOW_OBJECT WndParent = Wnd->Parent;
+ PWINDOW_OBJECT WndParent = Wnd->spwndParent;
+
+ IntUnlinkWnd(Wnd->Wnd);
- if (Wnd->NextSibling)
- Wnd->NextSibling->PrevSibling = Wnd->PrevSibling;
- else if (WndParent && WndParent->LastChild == Wnd)
- WndParent->LastChild = Wnd->PrevSibling;
+ if (Wnd->spwndNext)
+ Wnd->spwndNext->spwndPrev = Wnd->spwndPrev;
- if (Wnd->PrevSibling)
- Wnd->PrevSibling->NextSibling = Wnd->NextSibling;
- else if (WndParent && WndParent->FirstChild == Wnd)
- WndParent->FirstChild = Wnd->NextSibling;
+ if (Wnd->spwndPrev)
+ Wnd->spwndPrev->spwndNext = Wnd->spwndNext;
+ else if (WndParent && WndParent->spwndChild == Wnd)
+ WndParent->spwndChild = Wnd->spwndNext;
- Wnd->PrevSibling = Wnd->NextSibling = Wnd->Parent = NULL;
- if (Wnd->Wnd)
- Wnd->Wnd->spwndParent = NULL;
+ Wnd->spwndPrev = Wnd->spwndNext = Wnd->spwndParent = NULL;
}
BOOL FASTCALL
return FALSE;
}
- for(Child = Window->FirstChild; Child; Child = Child->NextSibling)
+ for(Child = Window->spwndChild; Child; Child = Child->spwndNext)
{
if(Child->hOwner && Child->Wnd->style & WS_VISIBLE)
{
BOOL FASTCALL
IntIsWindowInDestroy(PWINDOW_OBJECT Window)
{
- return ((Window->Status & WINDOWSTATUS_DESTROYING) == WINDOWSTATUS_DESTROYING);
+ return ((Window->state & WINDOWSTATUS_DESTROYING) == WINDOWSTATUS_DESTROYING);
}
{
lpwndpl->showCmd = SW_HIDE;
}
- else if (0 != (Window->Flags & WINDOWOBJECT_RESTOREMAX) ||
+ else if (0 != (Window->state & WINDOWOBJECT_RESTOREMAX) ||
0 != (Wnd->style & WS_MAXIMIZE))
{
lpwndpl->showCmd = SW_MAXIMIZE;
}
if((Parent = UserGetWindowObject(hwndParent)) &&
- (Window = Parent->FirstChild))
+ (Window = Parent->spwndChild))
{
BOOL bGoDown = TRUE;
break;
}
}
- if (Window->FirstChild && bChildren)
+ if (Window->spwndChild && bChildren)
{
- Window = Window->FirstChild;
+ Window = Window->spwndChild;
continue;
}
bGoDown = FALSE;
}
- if (Window->NextSibling)
+ if (Window->spwndNext)
{
- Window = Window->NextSibling;
+ Window = Window->spwndNext;
bGoDown = TRUE;
continue;
}
- Window = Window->Parent;
+ Window = Window->spwndParent;
if (Window == Parent)
{
break;
* calculates the default position of a window
*/
BOOL FASTCALL
-IntCalcDefPosSize(PWINDOW_OBJECT Parent, PWINDOW_OBJECT Window, RECTL *rc, BOOL IncPos)
+IntCalcDefPosSize(PWINDOW_OBJECT Parent, RECTL *rc, BOOL IncPos)
{
SIZE Sz;
+ PMONITOR pMonitor;
POINT Pos = {0, 0};
+
+ pMonitor = IntGetPrimaryMonitor();
if(Parent != NULL)
{
- RECTL_bIntersectRect(rc, rc, &Parent->Wnd->rcClient);
+ RECTL_bIntersectRect(rc, rc, &pMonitor->rcMonitor);
if(IncPos)
{
- Pos.x = Parent->TiledCounter * (UserGetSystemMetrics(SM_CXSIZE) + UserGetSystemMetrics(SM_CXFRAME));
- Pos.y = Parent->TiledCounter * (UserGetSystemMetrics(SM_CYSIZE) + UserGetSystemMetrics(SM_CYFRAME));
- if(Pos.x > ((rc->right - rc->left) / 4) ||
- Pos.y > ((rc->bottom - rc->top) / 4))
+ Pos.x = pMonitor->cWndStack * (UserGetSystemMetrics(SM_CXSIZE) + UserGetSystemMetrics(SM_CXFRAME));
+ Pos.y = pMonitor->cWndStack * (UserGetSystemMetrics(SM_CYSIZE) + UserGetSystemMetrics(SM_CYFRAME));
+ if (Pos.x > ((rc->right - rc->left) / 4) ||
+ Pos.y > ((rc->bottom - rc->top) / 4))
{
/* reset counter and position */
Pos.x = 0;
Pos.y = 0;
- Parent->TiledCounter = 0;
+ pMonitor->cWndStack = 0;
}
- Parent->TiledCounter++;
+ pMonitor->cWndStack++;
}
Pos.x += rc->left;
Pos.y += rc->top;
HWND hWnd;
POINT Pos;
SIZE Size;
- PW32THREADINFO ti = NULL;
+ PTHREADINFO ti = NULL;
#if 0
POINT MaxSize, MaxPos, MinTrack, MaxTrack;
pti = PsGetCurrentThreadWin32Thread();
- if (pti->Desktop)
+ if (pti->rpdesk)
{
- ParentWindowHandle = pti->Desktop->DesktopWindow;
+ ParentWindowHandle = pti->rpdesk->DesktopWindow;
}
+
+ if ( !(pti->ppi->W32PF_flags & W32PF_CLASSESREGISTERED ))
+ {
+ UserRegisterSystemClasses();
+ }
+
OwnerWindowHandle = NULL;
+ DPRINT("co_IntCreateWindowEx %wZ\n", ClassName);
+
if (hWndParent == HWND_MESSAGE)
{
/*
/* Check the window station. */
ti = GetW32ThreadInfo();
- if (ti == NULL || pti->Desktop == NULL)
+ if (ti == NULL || pti->rpdesk == NULL)
{
DPRINT1("Thread is not attached to a desktop! Cannot create window!\n");
RETURN( (PWND)0);
/* Check the class. */
+ DPRINT("Class %wZ\n", ClassName);
+
ClassAtom = IntGetClassAtom(ClassName,
hInstance,
ti->ppi,
SetLastWin32Error(ERROR_CANNOT_FIND_WND_CLASS);
RETURN((PWND)0);
}
-
+ DPRINT("ClassAtom %x\n", ClassAtom);
Class = IntReferenceClass(Class,
ClassLink,
- pti->Desktop);
+ pti->rpdesk);
if (Class == NULL)
{
DPRINT1("Failed to reference window class!\n");
RETURN(NULL);
}
- WinSta = pti->Desktop->WindowStation;
+ WinSta = pti->rpdesk->rpwinstaParent;
//FIXME: Reference thread/desktop instead
ObReferenceObjectByPointer(WinSta, KernelMode, ExWindowStationObjectType, 0);
/* Create the window object. */
Window = (PWINDOW_OBJECT) UserCreateObject( gHandleTable,
+ pti->rpdesk,
(PHANDLE)&hWnd,
otWindow,
sizeof(WINDOW_OBJECT));
if (Window)
{
- Window->Wnd = DesktopHeapAlloc(pti->Desktop,
+ Window->Wnd = DesktopHeapAlloc(pti->rpdesk,
sizeof(WND) + Class->cbwndExtra);
if (!Window->Wnd)
goto AllocErr;
RtlZeroMemory(Window->Wnd,
sizeof(WND) + Class->cbwndExtra);
- Window->Wnd->hdr.Handle = hWnd; /* FIXME: Remove hack , are you sure?*/
+ Window->Wnd->head.h = hWnd;
Wnd = Window->Wnd;
+ Wnd->fnid = 0;
- Wnd->pti = ti;
- Wnd->pi = ti->ppi;
- Wnd->rpdesk = pti->Desktop;
+ Wnd->head.pti = ti;
+ Wnd->head.rpdesk = pti->rpdesk;
Wnd->hWndLastActive = hWnd;
+ Wnd->state2 |= WNDS2_WIN40COMPAT;
}
DPRINT("Created object with handle %X\n", hWnd);
ObDereferenceObject(WinSta);
- if (NULL == pti->Desktop->DesktopWindow)
+ if (NULL == pti->rpdesk->DesktopWindow)
{
/* If there is no desktop window yet, we must be creating it */
- pti->Desktop->DesktopWindow = hWnd;
- pti->Desktop->DesktopInfo->Wnd = Wnd;
+ pti->rpdesk->DesktopWindow = hWnd;
+ pti->rpdesk->pDeskInfo->spwnd = Wnd;
}
/*
* Fill out the structure describing it.
*/
- Window->ti = ti;
+ Window->pti = ti;
Wnd->pcls = Class;
Class = NULL;
Wnd->hModule = hInstance;
Window->hSelf = hWnd;
- Window->MessageQueue = pti->MessageQueue;
- IntReferenceMessageQueue(Window->MessageQueue);
- Window->Parent = ParentWindow;
+ IntReferenceMessageQueue(Window->pti->MessageQueue);
+ Window->spwndParent = ParentWindow;
Wnd->spwndParent = ParentWindow ? ParentWindow->Wnd : NULL;
if (Wnd->spwndParent != NULL && hWndParent != 0)
{
Wnd->dwUserData = 0;
- Wnd->IsSystem = Wnd->pcls->System;
+ if (Wnd->pcls->CSF_flags & CSF_SERVERSIDEPROC)
+ Wnd->state |= WNDS_SERVERSIDEWINDOWPROC;
+
+ /* BugBoy Comments: Comment below say that System classes are always created
+ as UNICODE. In windows, creating a window with the ANSI version of CreateWindow
+ sets the window to ansi as verified by testing with IsUnicodeWindow API.
+
+ No where can I see in code or through testing does the window change back
+ to ANSI after being created as UNICODE in ROS. I didnt do more testing to
+ see what problems this would cause.*/
+
+ // Set WndProc from Class.
+ Wnd->lpfnWndProc = Wnd->pcls->lpfnWndProc;
+
+ // GetWindowProc, test for non server side default classes and set WndProc.
+ if ( Wnd->pcls->fnid <= FNID_GHOST && Wnd->pcls->fnid >= FNID_BUTTON )
+ {
+ if (bUnicodeWindow)
+ {
+ if (GETPFNCLIENTA(Wnd->pcls->fnid) == Wnd->lpfnWndProc)
+ Wnd->lpfnWndProc = GETPFNCLIENTW(Wnd->pcls->fnid);
+ }
+ else
+ {
+ if (GETPFNCLIENTW(Wnd->pcls->fnid) == Wnd->lpfnWndProc)
+ Wnd->lpfnWndProc = GETPFNCLIENTA(Wnd->pcls->fnid);
+ }
+ }
- /* BugBoy Comments: Comment below say that System classes are always created as UNICODE.
- In windows, creating a window with the ANSI version of CreateWindow sets the window
- to ansi as verified by testing with IsUnicodeWindow API.
+ // If not an Unicode caller, set Ansi creator bit.
+ if (!bUnicodeWindow) Wnd->state |= WNDS_ANSICREATOR;
- No where can I see in code or through testing does the window change back to ANSI
- after being created as UNICODE in ROS. I didnt do more testing to see what problems this would cause.*/
- // See NtUserDefSetText! We convert to Unicode all the time and never use Mix. (jt)
- if (Wnd->pcls->System)
+ // Clone Class Ansi/Unicode proc type.
+ if (Wnd->pcls->CSF_flags & CSF_ANSIPROC)
{
- /* NOTE: Always create a unicode window for system classes! */
- Wnd->Unicode = TRUE;
- Wnd->lpfnWndProc = Wnd->pcls->lpfnWndProc;
- Wnd->WndProcExtra = Wnd->pcls->WndProcExtra;
+ Wnd->state |= WNDS_ANSIWINDOWPROC;
+ Wnd->Unicode = FALSE;
}
else
- {
- Wnd->Unicode = Wnd->pcls->Unicode;
- Wnd->lpfnWndProc = Wnd->pcls->lpfnWndProc;
- Wnd->CallProc = NULL;
+ { /*
+ It seems there can be both an Ansi creator and Unicode Class Window
+ WndProc, unless the following overriding conditions occur:
+ */
+ if ( !bUnicodeWindow &&
+ ( ClassAtom == gpsi->atomSysClass[ICLS_BUTTON] ||
+ ClassAtom == gpsi->atomSysClass[ICLS_COMBOBOX] ||
+ ClassAtom == gpsi->atomSysClass[ICLS_COMBOLBOX] ||
+ ClassAtom == gpsi->atomSysClass[ICLS_DIALOG] ||
+ ClassAtom == gpsi->atomSysClass[ICLS_EDIT] ||
+ ClassAtom == gpsi->atomSysClass[ICLS_IME] ||
+ ClassAtom == gpsi->atomSysClass[ICLS_LISTBOX] ||
+ ClassAtom == gpsi->atomSysClass[ICLS_MDICLIENT] ||
+ ClassAtom == gpsi->atomSysClass[ICLS_STATIC] ) )
+ { // Override Class and set the window Ansi WndProc.
+ Wnd->state |= WNDS_ANSIWINDOWPROC;
+ Wnd->Unicode = FALSE;
+ }
+ else
+ { // Set the window Unicode WndProc.
+ Wnd->state &= ~WNDS_ANSIWINDOWPROC;
+ Wnd->Unicode = TRUE;
+ }
}
- Window->OwnerThread = PsGetCurrentThread();
- Window->FirstChild = NULL;
- Window->LastChild = NULL;
- Window->PrevSibling = NULL;
- Window->NextSibling = NULL;
+ Window->spwndChild = NULL;
+ Window->spwndPrev = NULL;
+ Window->spwndNext = NULL;
+
+ Wnd->spwndNext = NULL;
+ Wnd->spwndPrev = NULL;
+ Wnd->spwndChild = NULL;
+
Wnd->cbwndExtra = Wnd->pcls->cbwndExtra;
InitializeListHead(&Wnd->PropListHead);
- InitializeListHead(&Window->WndObjListHead);
if ( NULL != WindowName->Buffer && WindowName->Length > 0 )
{
- Wnd->strName.Buffer = DesktopHeapAlloc(Wnd->rpdesk,
+ Wnd->strName.Buffer = DesktopHeapAlloc(Wnd->head.rpdesk,
WindowName->Length + sizeof(UNICODE_NULL));
if (Wnd->strName.Buffer == NULL)
{
if (!(dwStyle & WS_POPUP))
{
dwStyle |= WS_CAPTION;
- Window->Flags |= WINDOWOBJECT_NEED_SIZE;
+ Window->state |= WINDOWOBJECT_NEED_SIZE;
DPRINT("4: Style is now %lx\n", dwStyle);
}
}
{
if (hMenu)
IntSetMenu(Window, hMenu, &MenuChanged);
- else // Take it from the parent.
+ else if (Wnd->pcls->lpszMenuName) // Take it from the parent.
{
UNICODE_STRING MenuName;
-
- RtlInitUnicodeString( &MenuName, Wnd->pcls->lpszMenuName);
-
+ if (IS_INTRESOURCE(Wnd->pcls->lpszMenuName))
+ {
+ MenuName.Length = 0;
+ MenuName.MaximumLength = 0;
+ MenuName.Buffer = Wnd->pcls->lpszMenuName;
+ }
+ else
+ {
+ RtlInitUnicodeString( &MenuName, Wnd->pcls->lpszMenuName);
+ }
hMenu = co_IntCallLoadMenu( Wnd->pcls->hModule, &MenuName);
if (hMenu) IntSetMenu(Window, hMenu, &MenuChanged);
}
InsertTailList (&pti->WindowListHead, &Window->ThreadListEntry);
/* Handle "CS_CLASSDC", it is tested first. */
- if ((Wnd->pcls->style & CS_CLASSDC) && !(Wnd->pcls->pdce)) // One DCE per class to have CLASS.
- Wnd->pcls->pdce = DceAllocDCE(Window, DCE_CLASS_DC);
- /* Allocate a DCE for this window. */
+ if ( (Wnd->pcls->style & CS_CLASSDC) && !(Wnd->pcls->pdce) )
+ { /* One DCE per class to have CLASS. */
+ Wnd->pcls->pdce = DceAllocDCE( Window, DCE_CLASS_DC );
+ }
else if ( Wnd->pcls->style & CS_OWNDC)
- Window->Dce = DceAllocDCE(Window, DCE_WINDOW_DC);
+ { /* Allocate a DCE for this window. */
+ DceAllocDCE(Window, DCE_WINDOW_DC);
+ }
Pos.x = x;
Pos.y = y;
PRTL_USER_PROCESS_PARAMETERS ProcessParams;
BOOL CalculatedDefPosSize = FALSE;
- IntGetDesktopWorkArea(((PTHREADINFO)Window->OwnerThread->Tcb.Win32Thread)->Desktop, &WorkArea);
+ IntGetDesktopWorkArea(Window->pti->rpdesk, &WorkArea);
rc = WorkArea;
ProcessParams = PsGetCurrentProcess()->Peb->ProcessParameters;
if(x == CW_USEDEFAULT || x == CW_USEDEFAULT16)
{
- CalculatedDefPosSize = IntCalcDefPosSize(ParentWindow, Window, &rc, TRUE);
+ CalculatedDefPosSize = IntCalcDefPosSize(ParentWindow, &rc, TRUE);
if(ProcessParams->WindowFlags & STARTF_USEPOSITION)
{
{
if(!CalculatedDefPosSize)
{
- IntCalcDefPosSize(ParentWindow, Window, &rc, FALSE);
+ IntCalcDefPosSize(ParentWindow, &rc, FALSE);
}
if(ProcessParams->WindowFlags & STARTF_USESIZE)
{
{
PWINDOW_OBJECT PrevSibling;
- PrevSibling = ParentWindow->LastChild;
+ PrevSibling = ParentWindow->spwndChild;
+
+ if(PrevSibling)
+ {
+ while (PrevSibling->spwndNext)
+ PrevSibling = PrevSibling->spwndNext;
+ }
/* link window as bottom sibling */
IntLinkWindow(Window, ParentWindow, PrevSibling /*prev sibling*/);
if (!(dwExStyle & WS_EX_TOPMOST))
{
InsertAfter = NULL;
- Sibling = ParentWindow->FirstChild;
+ Sibling = ParentWindow->spwndChild;
while (Sibling && (Sibling->Wnd->ExStyle & WS_EX_TOPMOST))
{
InsertAfter = Sibling;
- Sibling = Sibling->NextSibling;
+ Sibling = Sibling->spwndNext;
}
}
else
}
IntLinkWindow(Window, ParentWindow, InsertAfter /* prev sibling */);
-
}
}
RETURN((PWND)0);
}
- IntNotifyWinEvent(EVENT_OBJECT_CREATE, Window->hSelf, OBJID_WINDOW, 0);
+ IntNotifyWinEvent(EVENT_OBJECT_CREATE, Window->Wnd, OBJID_WINDOW, 0);
/* Send move and size messages. */
- if (!(Window->Flags & WINDOWOBJECT_NEED_SIZE))
+ if (!(Window->state & WINDOWOBJECT_NEED_SIZE))
{
LONG lParam;
{
PCALLPROCDATA CallProc;
//CallProc = CreateCallProc(NULL, Wnd->lpfnWndProc, bUnicodeWindow, Wnd->ti->ppi);
- CallProc = CreateCallProc(NULL, Wnd->lpfnWndProc, Wnd->Unicode , Wnd->pti->ppi);
+ CallProc = CreateCallProc(NULL, Wnd->lpfnWndProc, Wnd->Unicode , Wnd->head.pti->ppi);
if (!CallProc)
{
else
{
UserAddCallProcToClass(Wnd->pcls, CallProc);
- Wnd->CallProc = CallProc;
- Wnd->IsSystem = FALSE;
}
}
CLEANUP:
if (!_ret_ && Window && Window->Wnd && ti)
- UserFreeWindowInfo(ti, Window);
+ co_UserDestroyWindow(Window);
+// UserFreeWindowInfo(ti, Window);
if (Window)
{
UserDerefObjectCo(Window);
dwShowMode,
bUnicodeWindow);
- if (pNewWindow) NewWindow = pNewWindow->hdr.Handle;
+ if (pNewWindow) NewWindow = UserHMGetHandle(pNewWindow);
if (WindowName.Buffer)
{
if (!Wnd) return TRUE; // FIXME: Need to finish object rewrite or lock the thread when killing the window!
+ DPRINT("co_UserDestroyWindow \n");
+
/* Check for owner thread */
- if ((Window->OwnerThread != PsGetCurrentThread()))
+ if ( (Window->pti->pEThread != PsGetCurrentThread()) ||
+ Wnd->head.pti != PsGetCurrentThreadWin32Thread() )
{
SetLastWin32Error(ERROR_ACCESS_DENIED);
return FALSE;
}
}
- if (Window->MessageQueue->ActiveWindow == Window->hSelf)
- Window->MessageQueue->ActiveWindow = NULL;
- if (Window->MessageQueue->FocusWindow == Window->hSelf)
- Window->MessageQueue->FocusWindow = NULL;
- if (Window->MessageQueue->CaptureWindow == Window->hSelf)
- Window->MessageQueue->CaptureWindow = NULL;
+ if (Window->pti->MessageQueue->ActiveWindow == Window->hSelf)
+ Window->pti->MessageQueue->ActiveWindow = NULL;
+ if (Window->pti->MessageQueue->FocusWindow == Window->hSelf)
+ Window->pti->MessageQueue->FocusWindow = NULL;
+ if (Window->pti->MessageQueue->CaptureWindow == Window->hSelf)
+ Window->pti->MessageQueue->CaptureWindow = NULL;
- IntDereferenceMessageQueue(Window->MessageQueue);
+ IntDereferenceMessageQueue(Window->pti->MessageQueue);
IntEngWindowChanged(Window, WOC_DELETE);
isChild = (0 != (Wnd->style & WS_CHILD));
}
-
-
/*
* @implemented
*/
{
case GA_PARENT:
{
- WndAncestor = Wnd->Parent;
+ WndAncestor = Wnd->spwndParent;
break;
}
for(;;)
{
- if(!(Parent = WndAncestor->Parent))
+ if(!(Parent = WndAncestor->spwndParent))
{
break;
}
return WndAncestor;
}
-
-
/*
* @implemented
*/
return( hWndOldParent);
}
-
-
/*
* NtUserSetParent
*
END_CLEANUP;
}
-
-
/*
* UserGetShellWindow
*
* Status
* @implemented
*/
-HWND FASTCALL UserGetShellWindow()
+HWND FASTCALL UserGetShellWindow(VOID)
{
PWINSTATION_OBJECT WinStaObject;
HWND Ret;
DECLARE_RETURN(BOOL);
USER_REFERENCE_ENTRY Ref;
NTSTATUS Status;
- PW32THREADINFO ti;
+ PTHREADINFO ti;
DPRINT("Enter NtUserSetShellWindowEx\n");
UserEnterExclusive();
END_CLEANUP;
}
-
-
-
HWND FASTCALL
UserGetWindow(HWND hWnd, UINT Relationship)
{
switch (Relationship)
{
case GW_HWNDFIRST:
- if((Parent = Window->Parent))
+ if((Parent = Window->spwndParent))
{
- if (Parent->FirstChild)
- hWndResult = Parent->FirstChild->hSelf;
+ if (Parent->spwndChild)
+ hWndResult = Parent->spwndChild->hSelf;
}
break;
case GW_HWNDLAST:
- if((Parent = Window->Parent))
+ if((Parent = Window->spwndParent))
{
- if (Parent->LastChild)
- hWndResult = Parent->LastChild->hSelf;
+ if (Parent->spwndChild)
+ {
+ Window = Parent->spwndChild;
+ if(Window)
+ {
+ while(Window->spwndNext)
+ Window = Window->spwndNext;
+ }
+ hWndResult = Window->hSelf;
+ }
}
break;
case GW_HWNDNEXT:
- if (Window->NextSibling)
- hWndResult = Window->NextSibling->hSelf;
+ if (Window->spwndNext)
+ hWndResult = Window->spwndNext->hSelf;
break;
case GW_HWNDPREV:
- if (Window->PrevSibling)
- hWndResult = Window->PrevSibling->hSelf;
+ if (Window->spwndPrev)
+ hWndResult = Window->spwndPrev->hSelf;
break;
case GW_OWNER:
}
break;
case GW_CHILD:
- if (Window->FirstChild)
- hWndResult = Window->FirstChild->hSelf;
+ if (Window->spwndChild)
+ hWndResult = Window->spwndChild->hSelf;
break;
}
return hWndResult;
}
-
-
-/*
- * NtUserGetWindow
- *
- * The NtUserGetWindow function retrieves a handle to a window that has the
- * specified relationship (Z order or owner) to the specified window.
- *
- * Status
- * @implemented
- */
-
-HWND APIENTRY
-NtUserGetWindow(HWND hWnd, UINT Relationship)
-{
- DECLARE_RETURN(HWND);
-
- DPRINT("Enter NtUserGetWindow\n");
- UserEnterShared();
-
- RETURN(UserGetWindow(hWnd, Relationship));
-
-CLEANUP:
- DPRINT("Leave NtUserGetWindow, ret=%i\n",_ret_);
- UserLeave();
- END_CLEANUP;
-}
-
-
-
-
/*
* NtUserGetWindowLong
*
* WndProc is only available to the owner process
*/
if (GWL_WNDPROC == Index
- && Window->OwnerThread->ThreadsProcess != PsGetCurrentProcess())
+ && Window->pti->pEThread->ThreadsProcess != PsGetCurrentProcess())
{
SetLastWin32Error(ERROR_ACCESS_DENIED);
return 0;
break;
case GWL_WNDPROC:
- Result = (LONG)IntGetWindowProc(Window,
- Ansi);
+ Result = (LONG)IntGetWindowProc(Wnd, Ansi);
break;
case GWL_HINSTANCE:
break;
case GWL_HWNDPARENT:
- Parent = Window->Parent;
+ Parent = Window->spwndParent;
if(Parent)
{
if (Parent && Parent->hSelf == IntGetDesktopWindow())
return Result;
}
-
-
-
-/*
- * NtUserGetWindowLong
- *
- * The NtUserGetWindowLong function retrieves information about the specified
- * window. The function also retrieves the 32-bit (long) value at the
- * specified offset into the extra window memory.
- *
- * Status
- * @implemented
- */
-
-LONG APIENTRY
-NtUserGetWindowLong(HWND hWnd, DWORD Index, BOOL Ansi)
-{
- DECLARE_RETURN(LONG);
-
- DPRINT("Enter NtUserGetWindowLong(%x,%d,%d)\n", hWnd, (INT)Index, Ansi);
- UserEnterExclusive();
-
- RETURN(UserGetWindowLong(hWnd, Index, Ansi));
-
-CLEANUP:
- DPRINT("Leave NtUserGetWindowLong, ret=%i\n",_ret_);
- UserLeave();
- END_CLEANUP;
-}
-
-static WNDPROC
-IntSetWindowProc(PWINDOW_OBJECT Window,
- WNDPROC NewWndProc,
- BOOL Ansi)
-{
- WNDPROC Ret;
- PCALLPROCDATA CallProc;
- PWND Wnd = Window->Wnd;
-
- /* resolve any callproc handle if possible */
- if (IsCallProcHandle(NewWndProc))
- {
- WNDPROC_INFO wpInfo;
-
- if (UserGetCallProcInfo((HANDLE)NewWndProc,
- &wpInfo))
- {
- NewWndProc = wpInfo.WindowProc;
- /* FIXME - what if wpInfo.IsUnicode doesn't match Ansi? */
- }
- }
-
- /* attempt to get the previous window proc */
- if (Wnd->IsSystem)
- {
- Ret = (Ansi ? Wnd->WndProcExtra : Wnd->lpfnWndProc);
- }
- else
- {
- if (!Ansi == Wnd->Unicode)
- {
- Ret = Wnd->lpfnWndProc;
- }
- else
- {
- CallProc = UserFindCallProc(Wnd->pcls,
- Wnd->lpfnWndProc,
- Wnd->Unicode);
- if (CallProc == NULL)
- {
- CallProc = CreateCallProc(NULL,
- Wnd->lpfnWndProc,
- Wnd->Unicode,
- Wnd->pti->ppi);
- if (CallProc == NULL)
- {
- SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
- return NULL;
- }
-
- UserAddCallProcToClass(Wnd->pcls,
- CallProc);
- }
- /* BugBoy Comments: Added this if else, see below comments */
- if (!Wnd->CallProc)
- {
- Ret = Wnd->lpfnWndProc;
- }
- else
- {
- Ret = GetCallProcHandle(Wnd->CallProc);
- }
-
- Wnd->CallProc = CallProc;
-
- /* BugBoy Comments: Above sets the current CallProc for the
- window and below we set the Ret value to it.
- SetWindowLong for WNDPROC should return the previous proc
- Ret = GetCallProcHandle(Wnd->CallProc); */
- }
- }
-
- if (Wnd->pcls->System)
- {
- /* check if the new procedure matches with the one in the
- window class. If so, we need to restore both procedures! */
- Wnd->IsSystem = (NewWndProc == Wnd->pcls->lpfnWndProc ||
- NewWndProc == Wnd->pcls->WndProcExtra);
-
- if (Wnd->IsSystem)
- {
- Wnd->lpfnWndProc = Wnd->pcls->lpfnWndProc;
- Wnd->WndProcExtra = Wnd->pcls->WndProcExtra;
- Wnd->Unicode = !Ansi;
- return Ret;
- }
- }
-
- ASSERT(!Wnd->IsSystem);
-
- /* update the window procedure */
- Wnd->lpfnWndProc = NewWndProc;
- Wnd->Unicode = !Ansi;
-
- return Ret;
-}
-
-
LONG FASTCALL
co_UserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi)
{
{
if ((Index + sizeof(LONG)) > Wnd->cbwndExtra)
{
- SetLastWin32Error(ERROR_INVALID_PARAMETER);
+ SetLastWin32Error(ERROR_INVALID_INDEX);
return( 0);
}
+
OldValue = *((LONG *)((PCHAR)(Wnd + 1) + Index));
+/*
+ if ( Index == DWLP_DLGPROC && Wnd->state & WNDS_DIALOGWINDOW)
+ {
+ OldValue = (LONG)IntSetWindowProc( Wnd,
+ (WNDPROC)NewValue,
+ Ansi);
+ if (!OldValue) return 0;
+ }
+*/
*((LONG *)((PCHAR)(Wnd + 1) + Index)) = NewValue;
}
else
/*
* Remove extended window style bit WS_EX_TOPMOST for shell windows.
*/
- WindowStation = ((PTHREADINFO)Window->OwnerThread->Tcb.Win32Thread)->Desktop->WindowStation;
+ WindowStation = Window->pti->rpdesk->rpwinstaParent;
if(WindowStation)
{
if (hWnd == WindowStation->ShellWindow || hWnd == WindowStation->ShellListView)
case GWL_WNDPROC:
{
- /* FIXME: should check if window belongs to current process */
- OldValue = (LONG)IntSetWindowProc(Window,
+ if ( Wnd->head.pti->ppi != PsGetCurrentProcessWin32Process() ||
+ Wnd->fnid & FNID_FREED)
+ {
+ SetLastWin32Error(ERROR_ACCESS_DENIED);
+ return( 0);
+ }
+ OldValue = (LONG)IntSetWindowProc(Wnd,
(WNDPROC)NewValue,
Ansi);
break;
break;
case GWL_HWNDPARENT:
- Parent = Window->Parent;
+ Parent = Window->spwndParent;
if (Parent && (Parent->hSelf == IntGetDesktopWindow()))
OldValue = (LONG) IntSetOwner(Window->hSelf, (HWND) NewValue);
else
default:
DPRINT1("NtUserSetWindowLong(): Unsupported index %d\n", Index);
- SetLastWin32Error(ERROR_INVALID_PARAMETER);
+ SetLastWin32Error(ERROR_INVALID_INDEX);
OldValue = 0;
break;
}
return( OldValue);
}
-
-
/*
* NtUserSetWindowLong
*
{
Safepl.showCmd = SW_HIDE;
}
- else if ((0 != (Window->Flags & WINDOWOBJECT_RESTOREMAX) ||
+ else if ((0 != (Window->state & WINDOWOBJECT_RESTOREMAX) ||
0 != (Wnd->style & WS_MAXIMIZE)) &&
0 == (Wnd->style & WS_MINIMIZE))
{
NtUserQueryWindow(HWND hWnd, DWORD Index)
{
PWINDOW_OBJECT Window;
+ PWND pWnd;
DWORD Result;
DECLARE_RETURN(UINT);
DPRINT("Enter NtUserQueryWindow\n");
UserEnterShared();
- if (!(Window = UserGetWindowObject(hWnd)))
+ if (!(Window = UserGetWindowObject(hWnd)) || !Window->Wnd)
{
RETURN( 0);
}
+ pWnd = Window->Wnd;
+
switch(Index)
{
case QUERY_WINDOW_UNIQUE_PROCESS_ID:
break;
case QUERY_WINDOW_ISHUNG:
- Result = (DWORD)MsqIsHung(Window->MessageQueue);
+ Result = (DWORD)MsqIsHung(Window->pti->MessageQueue);
break;
+ case QUERY_WINDOW_REAL_ID:
+ Result = (DWORD)pWnd->head.pti->pEThread->Cid.UniqueProcess;
+
default:
Result = (DWORD)NULL;
break;
Wnd = Window->Wnd;
/* Create a new window region using the window rectangle */
- VisRgn = UnsafeIntCreateRectRgnIndirect(&Window->Wnd->rcWindow);
+ VisRgn = IntSysCreateRectRgnIndirect(&Window->Wnd->rcWindow);
NtGdiOffsetRgn(VisRgn, -Window->Wnd->rcWindow.left, -Window->Wnd->rcWindow.top);
/* if there's a region assigned to the window, combine them both */
- if(Window->WindowRegion && !(Wnd->style & WS_MINIMIZE))
- NtGdiCombineRgn(VisRgn, VisRgn, Window->WindowRegion, RGN_AND);
+ if(Window->hrgnClip && !(Wnd->style & WS_MINIMIZE))
+ NtGdiCombineRgn(VisRgn, VisRgn, Window->hrgnClip, RGN_AND);
/* Copy the region into hRgn */
NtGdiCombineRgn(hRgn, VisRgn, NULL, RGN_COPY);
- if((pRgn = REGION_LockRgn(hRgn)))
+ if((pRgn = RGNOBJAPI_Lock(hRgn, NULL)))
{
Ret = pRgn->rdh.iType;
- REGION_UnlockRgn(pRgn);
+ RGNOBJAPI_Unlock(pRgn);
}
else
Ret = ERROR;
- GreDeleteObject(VisRgn);
+ REGION_FreeRgnByHandle(VisRgn);
return Ret;
}
Wnd = Window->Wnd;
/* Create a new window region using the window rectangle */
- VisRgn = UnsafeIntCreateRectRgnIndirect(&Window->Wnd->rcWindow);
+ VisRgn = IntSysCreateRectRgnIndirect(&Window->Wnd->rcWindow);
NtGdiOffsetRgn(VisRgn, -Window->Wnd->rcWindow.left, -Window->Wnd->rcWindow.top);
/* if there's a region assigned to the window, combine them both */
- if(Window->WindowRegion && !(Wnd->style & WS_MINIMIZE))
- NtGdiCombineRgn(VisRgn, VisRgn, Window->WindowRegion, RGN_AND);
+ if(Window->hrgnClip && !(Wnd->style & WS_MINIMIZE))
+ NtGdiCombineRgn(VisRgn, VisRgn, Window->hrgnClip, RGN_AND);
- if((pRgn = REGION_LockRgn(VisRgn)))
+ if((pRgn = RGNOBJAPI_Lock(VisRgn, NULL)))
{
Ret = pRgn->rdh.iType;
*Rect = pRgn->rdh.rcBound;
- REGION_UnlockRgn(pRgn);
+ RGNOBJAPI_Unlock(pRgn);
}
else
Ret = ERROR;
- GreDeleteObject(VisRgn);
+ REGION_FreeRgnByHandle(VisRgn);
return Ret;
}
HRGN hRgn,
BOOL bRedraw)
{
+ HRGN hrgnCopy;
PWINDOW_OBJECT Window;
DECLARE_RETURN(INT);
RETURN( 0);
}
- /* FIXME - Verify if hRgn is a valid handle!!!!
- Propably make this operation thread-safe, but maybe it's not necessary */
+ if (hRgn) // The region will be deleted in user32.
+ {
+ if (GDIOBJ_ValidateHandle(hRgn, GDI_OBJECT_TYPE_REGION))
+ {
+ hrgnCopy = IntSysCreateRectRgn(0, 0, 0, 0);
+ NtGdiCombineRgn(hrgnCopy, hRgn, 0, RGN_COPY);
+ }
+ else
+ RETURN( 0);
+ }
+ else
+ hrgnCopy = (HRGN) 1;
- if(Window->WindowRegion)
+ if (Window->hrgnClip)
{
/* Delete no longer needed region handle */
- GreDeleteObject(Window->WindowRegion);
+ GreDeleteObject(Window->hrgnClip);
}
- Window->WindowRegion = hRgn;
+ Window->hrgnClip = hrgnCopy;
/* FIXME - send WM_WINDOWPOSCHANGING and WM_WINDOWPOSCHANGED messages to the window */
Wnd->strName.Buffer = NULL;
if (buf != NULL)
{
- DesktopHeapFree(Wnd->rpdesk, buf);
+ DesktopHeapFree(Wnd->head.rpdesk, buf);
}
- Wnd->strName.Buffer = DesktopHeapAlloc(Wnd->rpdesk,
+ Wnd->strName.Buffer = DesktopHeapAlloc(Wnd->head.rpdesk,
UnicodeString.Length + sizeof(UNICODE_NULL));
if (Wnd->strName.Buffer != NULL)
{
if (fShow)
{
- if (pWnd->Flags & WIN_NEEDS_SHOW_OWNEDPOPUP)
+ if (pWnd->Wnd->state & WNDS_HIDDENPOPUP)
{
/* In Windows, ShowOwnedPopups(TRUE) generates
* WM_SHOWWINDOW messages with SW_PARENTOPENING,
}
case otMonitor:
{
- PMONITOR_OBJECT Monitor;
+ PMONITOR Monitor;
if ((Monitor = UserGetMonitorObject((HMONITOR) handle))) return TRUE;
return FALSE;
}