2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 /* $Id: window.c,v 1.63 2003/07/11 17:08:44 chorns Exp $
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
24 * FILE: subsys/win32k/ntuser/window.c
25 * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
27 * 06-06-2001 CSH Created
29 /* INCLUDES ******************************************************************/
31 #include <ddk/ntddk.h>
32 #include <internal/safe.h>
33 #include <win32k/win32k.h>
34 #include <include/object.h>
35 #include <include/guicheck.h>
36 #include <include/window.h>
37 #include <include/class.h>
38 #include <include/error.h>
39 #include <include/winsta.h>
40 #include <include/winpos.h>
41 #include <include/callback.h>
42 #include <include/msgqueue.h>
43 #include <include/rect.h>
44 #include <include/dce.h>
45 #include <include/paint.h>
46 #include <include/painting.h>
47 #include <include/scroll.h>
50 #include <win32k/debug1.h>
53 #define TAG_WNAM TAG('W', 'N', 'A', 'M')
55 typedef struct _REGISTERED_MESSAGE
59 } REGISTERED_MESSAGE
, *PREGISTERED_MESSAGE
;
61 static LIST_ENTRY RegisteredMessageListHead
;
63 #define REGISTERED_MESSAGE_MIN 0xc000
64 #define REGISTERED_MESSAGE_MAX 0xffff
66 /* FUNCTIONS *****************************************************************/
69 NtUserGetAncestor(HWND hWnd
, UINT Flags
)
71 if (W32kIsDesktopWindow(hWnd
))
75 if (Flags
& GA_PARENT
)
77 PWINDOW_OBJECT Window
;
80 Window
= W32kGetWindowObject(hWnd
);
86 if (Window
->Parent
== NULL
)
88 W32kReleaseWindowObject(Window
);
91 hParent
= Window
->Parent
->Self
;
93 W32kReleaseWindowObject(Window
);
97 else if (Flags
& GA_ROOT
)
99 PWINDOW_OBJECT Window
;
100 PWINDOW_OBJECT pChainEnumerator
;
103 Window
= W32kGetWindowObject(hWnd
);
109 pChainEnumerator
= Window
;
110 while(pChainEnumerator
->Parent
!= NULL
)
112 pChainEnumerator
= pChainEnumerator
->Parent
;
115 hRoot
= pChainEnumerator
->Self
;
116 W32kReleaseWindowObject(Window
);
128 W32kSetFocusWindow(HWND hWnd
)
130 PUSER_MESSAGE_QUEUE OldMessageQueue
;
131 PDESKTOP_OBJECT DesktopObject
;
132 PWINDOW_OBJECT WindowObject
;
135 DPRINT("W32kSetFocusWindow(hWnd 0x%x)\n", hWnd
);
139 WindowObject
= W32kGetWindowObject(hWnd
);
142 DPRINT("Bad window handle 0x%x\n", hWnd
);
143 SetLastWin32Error(ERROR_INVALID_HANDLE
);
152 DesktopObject
= W32kGetActiveDesktop();
155 DPRINT("No active desktop\n");
156 if (WindowObject
!= NULL
)
158 W32kReleaseWindowObject(WindowObject
);
160 SetLastWin32Error(ERROR_INVALID_HANDLE
);
164 hWndOldFocus
= (HWND
)0;
165 OldMessageQueue
= (PUSER_MESSAGE_QUEUE
)DesktopObject
->ActiveMessageQueue
;
166 if (OldMessageQueue
!= NULL
)
168 hWndOldFocus
= OldMessageQueue
->FocusWindow
;
171 if (WindowObject
!= NULL
)
173 WindowObject
->MessageQueue
->FocusWindow
= hWnd
;
174 (PUSER_MESSAGE_QUEUE
)DesktopObject
->ActiveMessageQueue
=
175 WindowObject
->MessageQueue
;
176 W32kReleaseWindowObject(WindowObject
);
180 (PUSER_MESSAGE_QUEUE
)DesktopObject
->ActiveMessageQueue
= NULL
;
183 DPRINT("hWndOldFocus = 0x%x\n", hWndOldFocus
);
189 W32kIsChildWindow(HWND Parent
, HWND Child
)
191 PWINDOW_OBJECT BaseWindow
= W32kGetWindowObject(Child
);
192 PWINDOW_OBJECT Window
= BaseWindow
;
193 while (Window
!= NULL
&& Window
->Style
& WS_CHILD
)
195 if (Window
->Self
== Parent
)
197 W32kReleaseWindowObject(BaseWindow
);
200 Window
= Window
->Parent
;
202 W32kReleaseWindowObject(BaseWindow
);
207 W32kIsWindowVisible(HWND Wnd
)
209 PWINDOW_OBJECT BaseWindow
= W32kGetWindowObject(Wnd
);
210 PWINDOW_OBJECT Window
= BaseWindow
;
211 BOOLEAN Result
= FALSE
;
212 while (Window
!= NULL
&& Window
->Style
& WS_CHILD
)
214 if (!(Window
->Style
& WS_VISIBLE
))
216 W32kReleaseWindowObject(BaseWindow
);
219 Window
= Window
->Parent
;
221 if (Window
!= NULL
&& Window
->Style
& WS_VISIBLE
)
225 W32kReleaseWindowObject(BaseWindow
);
230 W32kIsDesktopWindow(HWND hWnd
)
232 PWINDOW_OBJECT WindowObject
;
234 WindowObject
= W32kGetWindowObject(hWnd
);
235 IsDesktop
= WindowObject
->Parent
== NULL
;
236 W32kReleaseWindowObject(WindowObject
);
240 HWND FASTCALL
W32kGetDesktopWindow(VOID
)
242 return W32kGetActiveDesktop()->DesktopWindow
;
245 HWND FASTCALL
W32kGetParentWindow(HWND hWnd
)
247 return W32kGetWindowObject(hWnd
)->ParentHandle
;
250 PWINDOW_OBJECT FASTCALL
251 W32kGetWindowObject(HWND hWnd
)
253 PWINDOW_OBJECT WindowObject
;
256 ObmReferenceObjectByHandle(PsGetWin32Process()->WindowStation
->
260 (PVOID
*)&WindowObject
);
261 if (!NT_SUCCESS(Status
))
265 return(WindowObject
);
269 W32kReleaseWindowObject(PWINDOW_OBJECT Window
)
271 ObmDereferenceObject(Window
);
276 * Returns client window rectangle relative to the upper-left corner of client area.
278 * \note Does not check the validity of the parameters
281 W32kGetClientRect(PWINDOW_OBJECT WindowObject
, PRECT Rect
)
283 ASSERT( WindowObject
);
286 Rect
->left
= Rect
->top
= 0;
287 Rect
->right
= WindowObject
->ClientRect
.right
- WindowObject
->ClientRect
.left
;
289 WindowObject
->ClientRect
.bottom
- WindowObject
->ClientRect
.top
;
294 * Return the dimension of the window in the screen coordinates.
297 W32kGetWindowRect(HWND hWnd
, LPRECT Rect
)
299 PWINDOW_OBJECT WindowObject
;
303 WindowObject
= W32kGetWindowObject(hWnd
);
304 if (WindowObject
== NULL
)
308 *Rect
= WindowObject
->WindowRect
;
309 if (WindowObject
->Style
& WS_CHILD
)
313 W32kReleaseWindowObject(WindowObject
);
318 * Return the dimension of the window in the screen coordinates.
319 * \param hWnd window handle.
320 * \param Rect pointer to the buffer where the coordinates are returned.
323 NtUserGetWindowRect(HWND hWnd
, LPRECT Rect
)
328 bRet
= W32kGetWindowRect(hWnd
, &SafeRect
);
329 if (! NT_SUCCESS(MmCopyToCaller(Rect
, &SafeRect
, sizeof(RECT
)))){
336 * Returns client window rectangle relative to the upper-left corner of client area.
338 * \param hWnd window handle.
339 * \param Rect pointer to the buffer where the coordinates are returned.
343 NtUserGetClientRect(HWND hWnd
, LPRECT Rect
)
345 PWINDOW_OBJECT WindowObject
;
348 WindowObject
= W32kGetWindowObject(hWnd
);
349 if (WindowObject
== NULL
)
353 W32kGetClientRect(WindowObject
, &SafeRect
);
354 if (! NT_SUCCESS(MmCopyToCaller(Rect
, &SafeRect
, sizeof(RECT
))))
356 W32kReleaseWindowObject(WindowObject
);
360 W32kReleaseWindowObject(WindowObject
);
365 W32kGetActiveWindow(VOID
)
367 PUSER_MESSAGE_QUEUE Queue
;
368 Queue
= (PUSER_MESSAGE_QUEUE
)W32kGetActiveDesktop()->ActiveMessageQueue
;
375 return(Queue
->ActiveWindow
);
380 W32kGetFocusWindow(VOID
)
382 PUSER_MESSAGE_QUEUE Queue
;
383 PDESKTOP_OBJECT pdo
= W32kGetActiveDesktop();
388 Queue
= (PUSER_MESSAGE_QUEUE
)pdo
->ActiveMessageQueue
;
393 return(Queue
->FocusWindow
);
398 W32kGetWindowProc(HWND Wnd
)
400 PWINDOW_OBJECT WindowObject
;
403 WindowObject
= W32kGetWindowObject(Wnd
);
407 WndProc
= WindowObject
->WndProc
;
408 W32kReleaseWindowObject(WindowObject
);
415 InitializeListHead(&RegisteredMessageListHead
);
417 return(STATUS_SUCCESS
);
421 CleanupWindowImpl(VOID
)
423 return(STATUS_SUCCESS
);
428 NtUserAlterWindowStyle(DWORD Unknown0
,
438 NtUserChildWindowFromPointEx(HWND Parent
,
449 W32kCreateDesktopWindow(PWINSTATION_OBJECT WindowStation
,
450 PWNDCLASS_OBJECT DesktopClass
,
451 ULONG Width
, ULONG Height
)
455 PWINDOW_OBJECT WindowObject
;
457 /* Create the window object. */
458 WindowObject
= (PWINDOW_OBJECT
)ObmCreateObject(WindowStation
->HandleTable
,
461 sizeof(WINDOW_OBJECT
));
468 * Fill out the structure describing it.
470 WindowObject
->Class
= DesktopClass
;
471 WindowObject
->ExStyle
= 0;
472 WindowObject
->Style
= WS_VISIBLE
;
475 WindowObject
->Width
= Width
;
476 WindowObject
->Height
= Height
;
477 WindowObject
->ParentHandle
= NULL
;
478 WindowObject
->Parent
= NULL
;
479 WindowObject
->Menu
= NULL
;
480 WindowObject
->Instance
= NULL
;
481 WindowObject
->Parameters
= NULL
;
482 WindowObject
->Self
= Handle
;
483 WindowObject
->MessageQueue
= NULL
;
484 WindowObject
->ExtraData
= NULL
;
485 WindowObject
->ExtraDataSize
= 0;
486 WindowObject
->WindowRect
.left
= 0;
487 WindowObject
->WindowRect
.top
= 0;
488 WindowObject
->WindowRect
.right
= Width
;
489 WindowObject
->WindowRect
.bottom
= Height
;
490 WindowObject
->ClientRect
= WindowObject
->WindowRect
;
491 WindowObject
->UserData
= 0;
492 WindowObject
->WndProc
= DesktopClass
->Class
.lpfnWndProc
;
494 InitializeListHead(&WindowObject
->ChildrenListHead
);
495 ExInitializeFastMutex(&WindowObject
->ChildrenListLock
);
497 WindowName
= ExAllocatePool(NonPagedPool
, sizeof(L
"DESKTOP"));
498 wcscpy(WindowName
, L
"DESKTOP");
499 RtlInitUnicodeString(&WindowObject
->WindowName
, WindowName
);
505 NtUserCreateWindowEx(DWORD dwExStyle
,
506 PUNICODE_STRING lpClassName
,
507 PUNICODE_STRING lpWindowName
,
519 PWINSTATION_OBJECT WinStaObject
;
520 PWNDCLASS_OBJECT ClassObject
;
521 PWINDOW_OBJECT WindowObject
;
522 PWINDOW_OBJECT ParentWindow
;
523 UNICODE_STRING WindowName
;
526 POINT MaxSize
, MaxPos
, MinTrack
, MaxTrack
;
529 DPRINT("NtUserCreateWindowEx\n");
531 /* Initialize gui state if necessary. */
532 W32kGraphicsCheck(TRUE
);
534 if (!RtlCreateUnicodeString(&WindowName
,
535 NULL
== lpWindowName
->Buffer
?
536 L
"" : lpWindowName
->Buffer
))
538 SetLastNtError(STATUS_INSUFFICIENT_RESOURCES
);
542 if (hWndParent
!= NULL
)
544 ParentWindow
= W32kGetWindowObject(hWndParent
);
548 hWndParent
= PsGetWin32Thread()->Desktop
->DesktopWindow
;
549 ParentWindow
= W32kGetWindowObject(hWndParent
);
552 /* Check the class. */
553 Status
= ClassReferenceClassByNameOrAtom(&ClassObject
, lpClassName
->Buffer
);
554 if (!NT_SUCCESS(Status
))
556 RtlFreeUnicodeString(&WindowName
);
557 W32kReleaseWindowObject(ParentWindow
);
561 /* Check the window station. */
562 DPRINT("IoGetCurrentProcess() %X\n", IoGetCurrentProcess());
563 DPRINT("PROCESS_WINDOW_STATION %X\n", PROCESS_WINDOW_STATION());
564 Status
= ValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
568 if (!NT_SUCCESS(Status
))
570 RtlFreeUnicodeString(&WindowName
);
571 ObmDereferenceObject(ClassObject
);
572 W32kReleaseWindowObject(ParentWindow
);
573 DPRINT("Validation of window station handle (0x%X) failed\n",
574 PROCESS_WINDOW_STATION());
578 /* Create the window object. */
579 WindowObject
= (PWINDOW_OBJECT
)
580 ObmCreateObject(PsGetWin32Process()->WindowStation
->HandleTable
, &Handle
,
581 otWindow
, sizeof(WINDOW_OBJECT
));
582 DPRINT("Created object with handle %X\n", Handle
);
585 ObDereferenceObject(WinStaObject
);
586 ObmDereferenceObject(ClassObject
);
587 RtlFreeUnicodeString(&WindowName
);
588 W32kReleaseWindowObject(ParentWindow
);
589 SetLastNtError(STATUS_INSUFFICIENT_RESOURCES
);
592 ObDereferenceObject(WinStaObject
);
595 * Fill out the structure describing it.
597 WindowObject
->Class
= ClassObject
;
598 WindowObject
->ExStyle
= dwExStyle
;
599 WindowObject
->Style
= dwStyle
| WIN_NCACTIVATED
;
602 WindowObject
->Width
= nWidth
;
603 WindowObject
->Height
= nHeight
;
604 WindowObject
->ParentHandle
= hWndParent
;
605 WindowObject
->Menu
= hMenu
;
606 WindowObject
->Instance
= hInstance
;
607 WindowObject
->Parameters
= lpParam
;
608 WindowObject
->Self
= Handle
;
609 WindowObject
->MessageQueue
= PsGetWin32Thread()->MessageQueue
;
610 WindowObject
->Parent
= ParentWindow
;
611 WindowObject
->UserData
= 0;
612 WindowObject
->WndProc
= ClassObject
->Class
.lpfnWndProc
;
614 ExAcquireFastMutexUnsafe(&ParentWindow
->ChildrenListLock
);
615 InsertHeadList(&ParentWindow
->ChildrenListHead
,
616 &WindowObject
->SiblingListEntry
);
617 ExReleaseFastMutexUnsafe(&ParentWindow
->ChildrenListLock
);
619 InitializeListHead(&WindowObject
->ChildrenListHead
);
620 InitializeListHead(&WindowObject
->PropListHead
);
621 ExInitializeFastMutex(&WindowObject
->ChildrenListLock
);
623 RtlInitUnicodeString(&WindowObject
->WindowName
, WindowName
.Buffer
);
624 RtlFreeUnicodeString(&WindowName
);
626 if (ClassObject
->Class
.cbWndExtra
!= 0)
628 WindowObject
->ExtraData
=
629 ExAllocatePool(PagedPool
,
630 ClassObject
->Class
.cbWndExtra
);
631 WindowObject
->ExtraDataSize
= ClassObject
->Class
.cbWndExtra
;
635 WindowObject
->ExtraData
= NULL
;
636 WindowObject
->ExtraDataSize
= 0;
639 /* Correct the window style. */
640 if (!(dwStyle
& WS_CHILD
))
642 WindowObject
->Style
|= WS_CLIPSIBLINGS
;
643 if (!(dwStyle
& WS_POPUP
))
645 WindowObject
->Style
|= WS_CAPTION
;
646 /* FIXME: Note the window needs a size. */
650 /* Insert the window into the process's window list. */
651 ExAcquireFastMutexUnsafe (&PsGetWin32Thread()->WindowListLock
);
652 InsertTailList (&PsGetWin32Thread()->WindowListHead
,
653 &WindowObject
->ThreadListEntry
);
654 ExReleaseFastMutexUnsafe (&PsGetWin32Thread()->WindowListLock
);
657 * Insert the window into the list of windows associated with the thread's
660 InsertTailList(&PsGetWin32Thread()->Desktop
->WindowListHead
,
661 &WindowObject
->DesktopListEntry
);
662 /* Allocate a DCE for this window. */
663 if (dwStyle
& CS_OWNDC
) WindowObject
->Dce
= DceAllocDCE(WindowObject
->Self
,DCE_WINDOW_DC
);
664 /* FIXME: Handle "CS_CLASSDC" */
666 /* Initialize the window dimensions. */
667 WindowObject
->WindowRect
.left
= x
;
668 WindowObject
->WindowRect
.top
= y
;
669 WindowObject
->WindowRect
.right
= x
+ nWidth
;
670 WindowObject
->WindowRect
.bottom
= y
+ nHeight
;
671 WindowObject
->ClientRect
= WindowObject
->WindowRect
;
674 * Get the size and position of the window.
676 if ((dwStyle
& WS_THICKFRAME
) || !(dwStyle
& (WS_POPUP
| WS_CHILD
)))
678 WinPosGetMinMaxInfo(WindowObject
, &MaxSize
, &MaxPos
, &MinTrack
,
680 x
= min(MaxSize
.x
, y
);
681 y
= min(MaxSize
.y
, y
);
682 x
= max(MinTrack
.x
, x
);
683 y
= max(MinTrack
.y
, y
);
686 WindowObject
->WindowRect
.left
= x
;
687 WindowObject
->WindowRect
.top
= y
;
688 WindowObject
->WindowRect
.right
= x
+ nWidth
;
689 WindowObject
->WindowRect
.bottom
= y
+ nHeight
;
690 WindowObject
->ClientRect
= WindowObject
->WindowRect
;
692 /* FIXME: Initialize the window menu. */
694 /* Initialize the window's scrollbars */
695 if (dwStyle
& WS_VSCROLL
)
696 SCROLL_CreateScrollBar(WindowObject
, SB_VERT
);
697 if (dwStyle
& WS_HSCROLL
)
698 SCROLL_CreateScrollBar(WindowObject
, SB_HORZ
);
700 /* Send a NCCREATE message. */
701 Cs
.lpCreateParams
= lpParam
;
702 Cs
.hInstance
= hInstance
;
704 Cs
.hwndParent
= hWndParent
;
710 Cs
.lpszName
= lpWindowName
->Buffer
;
711 Cs
.lpszClass
= lpClassName
->Buffer
;
712 Cs
.dwExStyle
= dwExStyle
;
713 DPRINT("NtUserCreateWindowEx(): About to send NCCREATE message.\n");
714 Result
= W32kSendNCCREATEMessage(WindowObject
->Self
, &Cs
);
717 /* FIXME: Cleanup. */
718 W32kReleaseWindowObject(ParentWindow
);
719 DPRINT("NtUserCreateWindowEx(): NCCREATE message failed.\n");
723 /* Calculate the non-client size. */
724 MaxPos
.x
= WindowObject
->WindowRect
.left
;
725 MaxPos
.y
= WindowObject
->WindowRect
.top
;
726 DPRINT("NtUserCreateWindowEx(): About to get non-client size.\n");
727 Result
= WinPosGetNonClientSize(WindowObject
->Self
,
728 &WindowObject
->WindowRect
,
729 &WindowObject
->ClientRect
);
730 W32kOffsetRect(&WindowObject
->WindowRect
,
731 MaxPos
.x
- WindowObject
->WindowRect
.left
,
732 MaxPos
.y
- WindowObject
->WindowRect
.top
);
734 /* Send the CREATE message. */
735 DPRINT("NtUserCreateWindowEx(): about to send CREATE message.\n");
736 Result
= W32kSendCREATEMessage(WindowObject
->Self
, &Cs
);
737 if (Result
== (LRESULT
)-1)
739 /* FIXME: Cleanup. */
740 W32kReleaseWindowObject(ParentWindow
);
741 DPRINT("NtUserCreateWindowEx(): send CREATE message failed.\n");
745 /* Send move and size messages. */
746 if (!(WindowObject
->Flags
& WINDOWOBJECT_NEED_SIZE
))
751 MAKE_LONG(WindowObject
->ClientRect
.right
-
752 WindowObject
->ClientRect
.left
,
753 WindowObject
->ClientRect
.bottom
-
754 WindowObject
->ClientRect
.top
);
756 DPRINT("NtUserCreateWindow(): About to send WM_SIZE\n");
757 W32kCallWindowProc(NULL
, WindowObject
->Self
, WM_SIZE
, SIZE_RESTORED
,
760 MAKE_LONG(WindowObject
->ClientRect
.left
,
761 WindowObject
->ClientRect
.top
);
762 DPRINT("NtUserCreateWindow(): About to send WM_MOVE\n");
763 W32kCallWindowProc(NULL
, WindowObject
->Self
, WM_MOVE
, 0, lParam
);
766 /* Move from parent-client to screen coordinates */
767 if (0 != (WindowObject
->Style
& WS_CHILD
))
769 W32kOffsetRect(&WindowObject
->WindowRect
,
770 ParentWindow
->ClientRect
.left
,
771 ParentWindow
->ClientRect
.top
);
772 W32kOffsetRect(&WindowObject
->ClientRect
,
773 ParentWindow
->ClientRect
.left
,
774 ParentWindow
->ClientRect
.top
);
777 /* Show or maybe minimize or maximize the window. */
778 if (WindowObject
->Style
& (WS_MINIMIZE
| WS_MAXIMIZE
))
783 SwFlag
= (WindowObject
->Style
& WS_MINIMIZE
) ? SW_MINIMIZE
:
785 WinPosMinMaximize(WindowObject
, SwFlag
, &NewPos
);
787 ((WindowObject
->Style
& WS_CHILD
) || W32kGetActiveWindow()) ?
788 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
:
789 SWP_NOZORDER
| SWP_FRAMECHANGED
;
790 DPRINT("NtUserCreateWindow(): About to minimize/maximize\n");
791 WinPosSetWindowPos(WindowObject
->Self
, 0, NewPos
.left
, NewPos
.top
,
792 NewPos
.right
, NewPos
.bottom
, SwFlag
);
795 /* Notify the parent window of a new child. */
796 if ((WindowObject
->Style
& WS_CHILD
) ||
797 (!(WindowObject
->ExStyle
& WS_EX_NOPARENTNOTIFY
)))
799 DPRINT("NtUserCreateWindow(): About to notify parent\n");
800 W32kCallWindowProc(NULL
, WindowObject
->Parent
->Self
,
802 MAKEWPARAM(WM_CREATE
, WindowObject
->IDMenu
),
803 (LPARAM
)WindowObject
->Self
);
806 if (dwStyle
& WS_VISIBLE
)
808 DPRINT("NtUserCreateWindow(): About to show window\n");
809 WinPosShowWindow(WindowObject
->Self
, dwShowMode
);
812 DPRINT("NtUserCreateWindow(): = %X\n", Handle
);
813 return((HWND
)Handle
);
817 NtUserDeferWindowPos(HDWP WinPosInfo
,
832 /***********************************************************************
835 static void W32kSendDestroyMsg(HWND Wnd
)
840 if (GetGUIThreadInfo(GetCurrentThreadId(), &info
))
842 if (Wnd
== info
.hwndCaret
)
850 * Send the WM_DESTROY to the window.
852 NtUserSendMessage(Wnd
, WM_DESTROY
, 0, 0);
855 * This WM_DESTROY message can trigger re-entrant calls to DestroyWindow
856 * make sure that the window still exists when we come back.
864 if (!(pWndArray
= WIN_ListChildren( hwnd
))) return;
866 /* start from the end (FIXME: is this needed?) */
867 for (i
= 0; pWndArray
[i
]; i
++) ;
871 if (IsWindow( pWndArray
[i
] )) WIN_SendDestroyMsg( pWndArray
[i
] );
873 HeapFree(GetProcessHeap(), 0, pWndArray
);
877 DPRINT("destroyed itself while in WM_DESTROY!\n");
882 static BOOLEAN
W32kWndBelongsToThread(PWINDOW_OBJECT Window
, PW32THREAD ThreadData
)
885 PWINDOW_OBJECT ThreadWindow
;
886 BOOLEAN Belongs
= FALSE
;
888 ExAcquireFastMutexUnsafe(&ThreadData
->WindowListLock
);
889 /* If there's no win32k thread data then this thread hasn't created any windows */
890 if (NULL
!= ThreadData
)
892 Current
= ThreadData
->WindowListHead
.Flink
;
893 while (! Belongs
&& Current
!= &ThreadData
->WindowListHead
)
895 ThreadWindow
= CONTAINING_RECORD(Current
, WINDOW_OBJECT
, ThreadListEntry
);
896 Belongs
= (Window
== ThreadWindow
);
897 Current
= Current
->Flink
;
900 ExReleaseFastMutexUnsafe(&ThreadData
->WindowListLock
);
905 static BOOL
BuildChildWindowArray(PWINDOW_OBJECT Window
, HWND
**Children
, unsigned *NumChildren
)
909 PWINDOW_OBJECT Child
;
913 ExAcquireFastMutexUnsafe(&Window
->ChildrenListLock
);
914 Current
= Window
->ChildrenListHead
.Flink
;
915 while (Current
!= &Window
->ChildrenListHead
)
918 Current
= Current
->Flink
;
920 if (0 != *NumChildren
)
922 *Children
= ExAllocatePoolWithTag(PagedPool
, *NumChildren
* sizeof(HWND
), TAG_WNAM
);
923 if (NULL
!= *Children
)
925 Current
= Window
->ChildrenListHead
.Flink
;
927 while (Current
!= &Window
->ChildrenListHead
)
929 Child
= CONTAINING_RECORD(Current
, WINDOW_OBJECT
, SiblingListEntry
);
930 (*Children
)[Index
] = Child
->Self
;
931 Current
= Current
->Flink
;
934 assert(Index
== *NumChildren
);
938 DPRINT1("Failed to allocate memory for children array\n");
941 ExReleaseFastMutexUnsafe(&Window
->ChildrenListLock
);
943 return 0 == *NumChildren
|| NULL
!= *Children
;
946 /***********************************************************************
949 * Destroy storage associated to a window. "Internals" p.358
951 static LRESULT
W32kDestroyWindow(PWINDOW_OBJECT Window
,
952 PW32PROCESS ProcessData
,
953 PW32THREAD ThreadData
,
954 BOOLEAN SendMessages
)
957 unsigned NumChildren
;
959 PWINDOW_OBJECT Child
;
961 if (! W32kWndBelongsToThread(Window
, ThreadData
))
963 DPRINT1("Window doesn't belong to current thread\n");
967 /* free child windows */
968 if (! BuildChildWindowArray(Window
, &Children
, &NumChildren
))
972 for (Index
= NumChildren
; 0 < Index
; Index
--)
974 Child
= W32kGetWindowObject(Children
[Index
- 1]);
977 if (W32kWndBelongsToThread(Child
, ThreadData
))
979 W32kDestroyWindow(Child
, ProcessData
, ThreadData
, SendMessages
);
984 SendMessageW( list
[i
], WM_WINE_DESTROYWINDOW
, 0, 0 );
989 if (0 != NumChildren
)
991 ExFreePool(Children
);
997 * Clear the update region to make sure no WM_PAINT messages will be
998 * generated for this window while processing the WM_NCDESTROY.
1000 PaintRedrawWindow(Window
->Self
, NULL
, 0,
1001 RDW_VALIDATE
| RDW_NOFRAME
| RDW_NOERASE
| RDW_NOINTERNALPAINT
| RDW_NOCHILDREN
,
1005 * Send the WM_NCDESTROY to the window being destroyed.
1007 NtUserSendMessage(Window
->Self
, WM_NCDESTROY
, 0, 0);
1010 /* FIXME: do we need to fake QS_MOUSEMOVE wakebit? */
1013 WinPosCheckInternalPos(Window
->Self
);
1014 if (Window
->Self
== GetCapture())
1019 /* free resources associated with the window */
1020 TIMER_RemoveWindowTimers(Window
->Self
);
1024 if (0 == (Window
->Style
& WS_CHILD
))
1026 HMENU Menu
= (HMENU
) NtUserSetWindowLongW(Window
->Self
, GWL_ID
, 0);
1032 if (Window
->hSysMenu
)
1034 DestroyMenu(Window
->hSysMenu
);
1035 Window
->hSysMenu
= 0;
1037 DCE_FreeWindowDCE(Window
->Self
); /* Always do this to catch orphaned DCs */
1038 WINPROC_FreeProc(Window
->winproc
, WIN_PROC_WINDOW
);
1039 CLASS_RemoveWindow(Window
->Class
);
1042 ExAcquireFastMutexUnsafe(&Window
->Parent
->ChildrenListLock
);
1043 RemoveEntryList(&Window
->SiblingListEntry
);
1044 ExReleaseFastMutexUnsafe(&Window
->Parent
->ChildrenListLock
);
1046 RemoveEntryList(&Window
->DesktopListEntry
);
1048 ExAcquireFastMutexUnsafe (&ThreadData
->WindowListLock
);
1049 RemoveEntryList(&Window
->ThreadListEntry
);
1050 ExReleaseFastMutexUnsafe (&ThreadData
->WindowListLock
);
1052 Window
->Class
= NULL
;
1053 ObmCloseHandle(ProcessData
->WindowStation
->HandleTable
, Window
->Self
);
1055 W32kGraphicsCheck(FALSE
);
1061 NtUserDestroyWindow(HWND Wnd
)
1063 PWINDOW_OBJECT Window
;
1067 Window
= W32kGetWindowObject(Wnd
);
1073 /* Check for desktop window (has NULL parent) */
1074 if (NULL
== Window
->Parent
)
1076 W32kReleaseWindowObject(Window
);
1077 SetLastWin32Error(ERROR_ACCESS_DENIED
);
1081 /* Look whether the focus is within the tree of windows we will
1084 hWndFocus
= W32kGetFocusWindow();
1085 if (hWndFocus
== Wnd
|| W32kIsChildWindow(Wnd
, hWndFocus
))
1087 HWND Parent
= NtUserGetAncestor(Wnd
, GA_PARENT
);
1088 if (Parent
== W32kGetDesktopWindow())
1092 W32kSetFocusWindow(Parent
);
1097 if (HOOK_CallHooks(WH_CBT
, HCBT_DESTROYWND
, (WPARAM
) hwnd
, 0, TRUE
))
1103 isChild
= (0 != (Window
->Style
& WS_CHILD
));
1108 if (! USER_IsExitingThread(GetCurrentThreadId()))
1110 send_parent_notify(hwnd
, WM_DESTROY
);
1113 else if (NULL
!= GetWindow(Wnd
, GW_OWNER
))
1115 HOOK_CallHooks( WH_SHELL
, HSHELL_WINDOWDESTROYED
, (WPARAM
)hwnd
, 0L, TRUE
);
1116 /* FIXME: clean up palette - see "Internals" p.352 */
1119 if (! IsWindow(Wnd
))
1125 /* Hide the window */
1126 if (! WinPosShowWindow(Wnd
, SW_HIDE
))
1129 if (hwnd
== GetActiveWindow())
1131 WINPOS_ActivateOtherWindow( hwnd
);
1137 if (! IsWindow(Wnd
))
1143 /* Recursively destroy owned windows */
1150 BOOL GotOne
= FALSE
;
1151 HWND
*list
= WIN_ListChildren(GetDesktopWindow());
1154 for (i
= 0; list
[i
]; i
++)
1156 if (GetWindow(list
[i
], GW_OWNER
) != Wnd
)
1160 if (WIN_IsCurrentThread(list
[i
]))
1162 DestroyWindow(list
[i
]);
1166 WIN_SetOwner(list
[i
], NULL
);
1168 HeapFree(GetProcessHeap(), 0, list
);
1178 /* Send destroy messages */
1179 W32kSendDestroyMsg(Wnd
);
1188 /* Unlink now so we won't bother with the children later on */
1190 WIN_UnlinkWindow( hwnd
);
1193 /* Destroy the window storage */
1194 W32kDestroyWindow(Window
, PsGetWin32Process(), PsGetWin32Thread(), TRUE
);
1200 DestroyThreadWindows(struct _ETHREAD
*Thread
)
1202 PLIST_ENTRY LastHead
;
1203 PW32PROCESS Win32Process
;
1204 PW32THREAD Win32Thread
;
1205 PWINDOW_OBJECT Window
;
1207 Win32Thread
= Thread
->Win32Thread
;
1208 Win32Process
= Thread
->ThreadsProcess
->Win32Process
;
1209 ExAcquireFastMutexUnsafe(&Win32Thread
->WindowListLock
);
1211 while (Win32Thread
->WindowListHead
.Flink
!= &(Win32Thread
->WindowListHead
) &&
1212 Win32Thread
->WindowListHead
.Flink
!= LastHead
)
1214 LastHead
= Win32Thread
->WindowListHead
.Flink
;
1215 Window
= CONTAINING_RECORD(Win32Thread
->WindowListHead
.Flink
, WINDOW_OBJECT
, ThreadListEntry
);
1216 ExReleaseFastMutexUnsafe(&Win32Thread
->WindowListLock
);
1217 W32kDestroyWindow(Window
, Win32Process
, Win32Thread
, FALSE
);
1218 ExAcquireFastMutexUnsafe(&Win32Thread
->WindowListLock
);
1220 if (Win32Thread
->WindowListHead
.Flink
== LastHead
)
1222 /* Window at head of list was not removed, should never happen, infinite loop */
1225 ExReleaseFastMutexUnsafe(&Win32Thread
->WindowListLock
);
1229 NtUserEndDeferWindowPosEx(DWORD Unknown0
,
1238 NtUserFillWindow(DWORD Unknown0
,
1250 * Searches a window's children for a window with the specified
1253 * hwndParent = The window whose childs are to be searched.
1256 * hwndChildAfter = Search starts after this child window.
1257 * NULL = start from beginning
1259 * ucClassName = Class name to search for
1260 * Reguired parameter.
1262 * ucWindowName = Window name
1263 * ->Buffer == NULL = don't care
1266 * The HWND of the window if it was found, otherwise NULL
1269 * Should use MmCopyFromCaller, we don't want an access violation in here
1274 NtUserFindWindowEx(HWND hwndParent
,
1275 HWND hwndChildAfter
,
1276 PUNICODE_STRING ucClassName
,
1277 PUNICODE_STRING ucWindowName
)
1281 PWINDOW_OBJECT windowObject
;
1282 PWINDOW_OBJECT ParentWindow
;
1283 PLIST_ENTRY currentEntry
;
1284 PWNDCLASS_OBJECT classObject
;
1286 // Get a pointer to the class
1287 status
= ClassReferenceClassByNameOrAtom(&classObject
, ucClassName
->Buffer
);
1288 if (!NT_SUCCESS(status
))
1293 // If hwndParent==NULL use the desktop window instead
1295 hwndParent
= PsGetWin32Thread()->Desktop
->DesktopWindow
;
1298 ParentWindow
= W32kGetWindowObject(hwndParent
);
1302 ObmDereferenceObject(classObject
);
1306 ExAcquireFastMutexUnsafe (&ParentWindow
->ChildrenListLock
);
1307 currentEntry
= ParentWindow
->ChildrenListHead
.Flink
;
1311 while (currentEntry
!= &ParentWindow
->ChildrenListHead
)
1313 windowObject
= CONTAINING_RECORD (currentEntry
, WINDOW_OBJECT
,
1316 if(windowObject
->Self
== hwndChildAfter
)
1318 /* "The search begins with the _next_ child window in the Z order." */
1319 currentEntry
= currentEntry
->Flink
;
1323 currentEntry
= currentEntry
->Flink
;
1326 /* If the child hwndChildAfter was not found:
1327 currentEntry=&ParentWindow->ChildrenListHead now so the next
1328 block of code will just fall through and the function returns NULL */
1331 while (currentEntry
!= &ParentWindow
->ChildrenListHead
)
1333 windowObject
= CONTAINING_RECORD (currentEntry
, WINDOW_OBJECT
,
1336 if (classObject
== windowObject
->Class
&& (ucWindowName
->Buffer
==NULL
||
1337 RtlCompareUnicodeString (ucWindowName
, &windowObject
->WindowName
, TRUE
) == 0))
1339 windowHandle
= windowObject
->Self
;
1341 ExReleaseFastMutexUnsafe (&ParentWindow
->ChildrenListLock
);
1342 W32kReleaseWindowObject(ParentWindow
);
1343 ObmDereferenceObject (classObject
);
1345 return windowHandle
;
1347 currentEntry
= currentEntry
->Flink
;
1350 ExReleaseFastMutexUnsafe (&ParentWindow
->ChildrenListLock
);
1351 W32kReleaseWindowObject(ParentWindow
);
1352 ObmDereferenceObject (classObject
);
1358 NtUserFlashWindowEx(DWORD Unknown0
)
1366 NtUserGetForegroundWindow(VOID
)
1374 NtUserGetInternalWindowPos(DWORD Unknown0
,
1384 NtUserGetOpenClipboardWindow(VOID
)
1392 NtUserGetWindowDC(HWND hWnd
)
1394 return (DWORD
) NtUserGetDCEx( hWnd
, 0, DCX_USESTYLE
| DCX_WINDOW
);
1398 NtUserGetWindowPlacement(DWORD Unknown0
,
1407 NtUserInternalGetWindowText(DWORD Unknown0
,
1417 NtUserLockWindowUpdate(DWORD Unknown0
)
1433 PWINDOW_OBJECT Window
= W32kGetWindowObject(hWnd
);
1434 ULONG uStyle
, uExStyle
;
1437 if (!Window
) return FALSE
;
1439 uStyle
= Window
->Style
;
1440 uExStyle
= Window
->ExStyle
;
1441 pWinPos
.hwnd
= hWnd
;
1445 if (nWidth
> NtUserGetSystemMetrics(SM_CXMIN
))
1446 pWinPos
.cx
= pWinPos
.x
+ nWidth
;
1448 pWinPos
.cx
= pWinPos
.x
+ NtUserGetSystemMetrics(SM_CXMIN
);
1450 if (nHeight
> NtUserGetSystemMetrics(SM_CYMIN
))
1451 pWinPos
.cy
= pWinPos
.x
+ nHeight
;
1453 pWinPos
.cy
= pWinPos
.y
+ NtUserGetSystemMetrics(SM_CYMIN
);
1454 W32kSendWINDOWPOSCHANGINGMessage(Window
->Self
, &pWinPos
);
1456 Window
->WindowRect
.top
= Window
->ClientRect
.top
= pWinPos
.y
;
1457 Window
->WindowRect
.left
= Window
->ClientRect
.left
= pWinPos
.x
;
1458 Window
->WindowRect
.bottom
= Window
->ClientRect
.bottom
= pWinPos
.cy
;
1459 Window
->WindowRect
.right
= Window
->ClientRect
.right
= pWinPos
.cx
;
1461 if (!(uStyle
& WS_THICKFRAME
))
1463 Window
->ClientRect
.top
+= NtUserGetSystemMetrics(SM_CYFIXEDFRAME
);
1464 Window
->ClientRect
.bottom
-= NtUserGetSystemMetrics(SM_CYFIXEDFRAME
);
1465 Window
->ClientRect
.left
+= NtUserGetSystemMetrics(SM_CXFIXEDFRAME
);
1466 Window
->ClientRect
.right
-= NtUserGetSystemMetrics(SM_CXFIXEDFRAME
);
1470 Window
->ClientRect
.top
+= NtUserGetSystemMetrics(SM_CYSIZEFRAME
);
1471 Window
->ClientRect
.bottom
-= NtUserGetSystemMetrics(SM_CYSIZEFRAME
);
1472 Window
->ClientRect
.left
+= NtUserGetSystemMetrics(SM_CXSIZEFRAME
);
1473 Window
->ClientRect
.right
-= NtUserGetSystemMetrics(SM_CXSIZEFRAME
);
1476 if (uStyle
& WS_CAPTION
)
1477 Window
->ClientRect
.top
+= NtUserGetSystemMetrics(SM_CYCAPTION
) + 1;
1478 if ( Window
->Class
->Class
.lpszMenuName
)
1480 Window
->ClientRect
.top
+= NtUserGetSystemMetrics(SM_CYMENU
);
1483 W32kSendWINDOWPOSCHANGEDMessage(Window
->Self
, &pWinPos
);
1485 NtUserSendMessage(hWnd
, WM_MOVE
, 0, MAKEWORD(Window
->ClientRect
.left
,
1486 Window
->ClientRect
.top
));
1488 NtUserSendMessage(hWnd
, WM_SIZE
, 0, MAKEWORD(Window
->ClientRect
.right
-
1489 Window
->ClientRect
.left
,
1490 Window
->ClientRect
.bottom
-
1491 Window
->ClientRect
.top
));
1493 /* FIXME: Send WM_NCCALCSIZE */
1494 W32kReleaseWindowObject(Window
);
1495 if (bRepaint
) NtUserSendMessage(hWnd
, WM_PAINT
, 0, 0);
1500 QueryWindow based on KJK::Hyperion and James Tabor.
1502 0 = QWUniqueProcessId
1503 1 = QWUniqueThreadId
1504 4 = QWIsHung Implements IsHungAppWindow found
1507 9 = QWKillWindow When I called this with hWnd ==
1508 DesktopWindow, it shutdown the system
1512 NtUserQueryWindow(HWND hWnd
, DWORD Index
)
1515 W32kGetWndObj uses PsGetWin32Process() which came from
1516 PsGetCurrentProcess() made from PsGetCurrentThread().
1517 What would happen if hWnd was under a different EThread
1520 PWINDOW_OBJECT Window
= W32kGetWindowObject(hWnd
);
1522 if(Window
== NULL
) return((DWORD
)NULL
);
1524 W32kReleaseWindowObject(Window
);
1529 return((DWORD
)PsGetCurrentProcessId());
1532 return((DWORD
)PsGetCurrentThreadId());
1535 return((DWORD
)NULL
);
1541 NtUserRealChildWindowFromPoint(DWORD Unknown0
,
1555 CONST RECT
*lprcUpdate
,
1560 RECT SafeUpdateRect
;
1563 if(NULL
!= lprcUpdate
)
1565 Status
= MmCopyFromCaller(&SafeUpdateRect
, (PRECT
)lprcUpdate
, sizeof(RECT
));
1567 if(!NT_SUCCESS(Status
))
1569 /* FIXME: set last error */
1574 Status
= PaintRedrawWindow
1577 NULL
== lprcUpdate
? NULL
: &SafeUpdateRect
,
1583 if(!NT_SUCCESS(Status
))
1585 /* FIXME: set last error */
1593 NtUserRegisterWindowMessage(PUNICODE_STRING MessageNameUnsafe
)
1595 PLIST_ENTRY Current
;
1596 PREGISTERED_MESSAGE NewMsg
, RegMsg
;
1597 UINT Msg
= REGISTERED_MESSAGE_MIN
;
1598 UNICODE_STRING MessageName
;
1601 Status
= MmCopyFromCaller(&MessageName
, MessageNameUnsafe
, sizeof(UNICODE_STRING
));
1602 if (! NT_SUCCESS(Status
))
1604 SetLastNtError(Status
);
1608 NewMsg
= ExAllocatePoolWithTag(PagedPool
,
1609 sizeof(REGISTERED_MESSAGE
) +
1614 SetLastNtError(STATUS_NO_MEMORY
);
1618 Status
= MmCopyFromCaller(NewMsg
->MessageName
, MessageName
.Buffer
, MessageName
.Length
);
1619 if (! NT_SUCCESS(Status
))
1622 SetLastNtError(Status
);
1625 NewMsg
->MessageName
[MessageName
.Length
/ sizeof(WCHAR
)] = L
'\0';
1626 if (wcslen(NewMsg
->MessageName
) != MessageName
.Length
/ sizeof(WCHAR
))
1629 SetLastNtError(STATUS_INVALID_PARAMETER
);
1633 Current
= RegisteredMessageListHead
.Flink
;
1634 while (Current
!= &RegisteredMessageListHead
)
1636 RegMsg
= CONTAINING_RECORD(Current
, REGISTERED_MESSAGE
, ListEntry
);
1637 if (0 == wcscmp(NewMsg
->MessageName
, RegMsg
->MessageName
))
1643 Current
= Current
->Flink
;
1646 if (REGISTERED_MESSAGE_MAX
< Msg
)
1649 SetLastNtError(STATUS_INSUFFICIENT_RESOURCES
);
1653 InsertTailList(&RegisteredMessageListHead
, &(NewMsg
->ListEntry
));
1659 NtUserScrollWindowEx(DWORD Unknown0
,
1674 NtUserSetActiveWindow(DWORD Unknown0
)
1682 NtUserSetImeOwnerWindow(DWORD Unknown0
,
1691 NtUserSetInternalWindowPos(DWORD Unknown0
,
1703 NtUserSetLayeredWindowAttributes(DWORD Unknown0
,
1714 NtUserSetLogonNotifyWindow(DWORD Unknown0
)
1722 NtUserSetShellWindowEx(DWORD Unknown0
,
1731 NtUserSetWindowFNID(DWORD Unknown0
,
1740 NtUserGetWindowLong(HWND hWnd
, DWORD Index
)
1742 PWINDOW_OBJECT WindowObject
;
1747 ObmReferenceObjectByHandle(PsGetWin32Process()->WindowStation
->HandleTable
,
1750 (PVOID
*)&WindowObject
);
1751 if (!NT_SUCCESS(Status
))
1753 SetLastWin32Error(ERROR_INVALID_HANDLE
);
1757 if (0 <= (int) Index
)
1759 if (WindowObject
->ExtraDataSize
- sizeof(LONG
) < Index
||
1760 0 != Index
% sizeof(LONG
))
1762 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
1765 Result
= WindowObject
->ExtraData
[Index
/ sizeof(LONG
)];
1772 Result
= WindowObject
->ExStyle
;
1776 Result
= WindowObject
->Style
;
1780 Result
= (LONG
) WindowObject
->WndProc
;
1784 Result
= (LONG
) WindowObject
->Instance
;
1787 case GWL_HWNDPARENT
:
1788 Result
= (LONG
) WindowObject
->ParentHandle
;
1792 Result
= (LONG
) WindowObject
->IDMenu
;
1796 Result
= WindowObject
->UserData
;
1800 DPRINT1("NtUserGetWindowLong(): Unsupported index %d\n", Index
);
1801 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
1807 ObmDereferenceObject(WindowObject
);
1813 NtUserSetWindowLong(HWND hWnd
, DWORD Index
, LONG NewValue
, BOOL Ansi
)
1815 PWINDOW_OBJECT WindowObject
;
1821 ObmReferenceObjectByHandle(PsGetWin32Process()->WindowStation
->HandleTable
,
1824 (PVOID
*)&WindowObject
);
1825 if (!NT_SUCCESS(Status
))
1827 SetLastWin32Error(ERROR_INVALID_HANDLE
);
1831 if (0 <= (int) Index
)
1833 if (WindowObject
->ExtraDataSize
- sizeof(LONG
) < Index
||
1834 0 != Index
% sizeof(LONG
))
1836 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
1839 OldValue
= WindowObject
->ExtraData
[Index
/ sizeof(LONG
)];
1840 WindowObject
->ExtraData
[Index
/ sizeof(LONG
)] = NewValue
;
1847 OldValue
= (LONG
) WindowObject
->ExStyle
;
1848 Style
.styleOld
= OldValue
;
1849 Style
.styleNew
= NewValue
;
1850 W32kSendSTYLECHANGINGMessage(hWnd
, GWL_EXSTYLE
, &Style
);
1851 WindowObject
->ExStyle
= (DWORD
)Style
.styleNew
;
1852 W32kSendSTYLECHANGEDMessage(hWnd
, GWL_EXSTYLE
, &Style
);
1856 OldValue
= (LONG
) WindowObject
->Style
;
1857 Style
.styleOld
= OldValue
;
1858 Style
.styleNew
= NewValue
;
1859 W32kSendSTYLECHANGINGMessage(hWnd
, GWL_STYLE
, &Style
);
1860 WindowObject
->Style
= (DWORD
)Style
.styleNew
;
1861 W32kSendSTYLECHANGEDMessage(hWnd
, GWL_STYLE
, &Style
);
1865 /* FIXME: should check if window belongs to current process */
1866 OldValue
= (LONG
) WindowObject
->WndProc
;
1867 WindowObject
->WndProc
= (WNDPROC
) NewValue
;
1871 OldValue
= (LONG
) WindowObject
->Instance
;
1872 WindowObject
->Instance
= (HINSTANCE
) NewValue
;
1875 case GWL_HWNDPARENT
:
1876 OldValue
= (LONG
) WindowObject
->ParentHandle
;
1877 WindowObject
->ParentHandle
= (HWND
) NewValue
;
1878 /* FIXME: Need to update window lists of old and new parent */
1883 OldValue
= (LONG
) WindowObject
->IDMenu
;
1884 WindowObject
->IDMenu
= (UINT
) NewValue
;
1888 OldValue
= WindowObject
->UserData
;
1889 WindowObject
->UserData
= NewValue
;
1893 DPRINT1("NtUserSetWindowLong(): Unsupported index %d\n", Index
);
1894 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
1900 ObmDereferenceObject(WindowObject
);
1905 NtUserSetWindowPlacement(DWORD Unknown0
,
1914 STDCALL
NtUserSetWindowPos(
1916 HWND hWndInsertAfter
,
1923 return WinPosSetWindowPos(hWnd
, hWndInsertAfter
, X
, Y
, cx
, cy
, uFlags
);
1927 NtUserSetWindowRgn(DWORD Unknown0
,
1937 NtUserSetWindowWord(DWORD Unknown0
,
1947 NtUserShowWindow(HWND hWnd
,
1950 return(WinPosShowWindow(hWnd
, nCmdShow
));
1954 NtUserShowWindowAsync(DWORD Unknown0
,
1962 BOOL STDCALL
NtUserUpdateWindow( HWND hWnd
)
1964 PWINDOW_OBJECT pWindow
= W32kGetWindowObject( hWnd
);
1968 if (pWindow
->UpdateRegion
)
1969 NtUserSendMessage( hWnd
, WM_PAINT
,0,0);
1970 W32kReleaseWindowObject(pWindow
);
1975 NtUserUpdateLayeredWindow(DWORD Unknown0
,
1991 NtUserWindowFromPoint(DWORD Unknown0
,
2000 NtUserGetDesktopWindow()
2002 return W32kGetDesktopWindow();