diff --git a/reactos/subsystems/win32/win32k/include/desktop.h b/reactos/subsystems/win32/win32k/include/desktop.h index c7d28e6a1c6..4fc68234e4a 100644 --- a/reactos/subsystems/win32/win32k/include/desktop.h +++ b/reactos/subsystems/win32/win32k/include/desktop.h @@ -28,7 +28,7 @@ typedef struct _DESKTOP PWIN32HEAP pheapDesktop; PSECTION_OBJECT DesktopHeapSection; PDESKTOPINFO DesktopInfo; - HWND spwndMessage; + PWINDOW spwndMessage; } DESKTOP, *PDESKTOP; extern PDESKTOP InputDesktop; diff --git a/reactos/subsystems/win32/win32k/include/window.h b/reactos/subsystems/win32/win32k/include/window.h index 5745825150c..9c9a97a02e5 100644 --- a/reactos/subsystems/win32/win32k/include/window.h +++ b/reactos/subsystems/win32/win32k/include/window.h @@ -171,7 +171,7 @@ IntDefWindowProc( PWINDOW_OBJECT Window, UINT Msg, WPARAM wParam, LPARAM lParam, VOID FASTCALL IntNotifyWinEvent(DWORD, HWND, LONG, LONG); -HWND APIENTRY co_IntCreateWindowEx(DWORD,PUNICODE_STRING,PUNICODE_STRING,DWORD,LONG,LONG,LONG,LONG,HWND,HMENU,HINSTANCE,LPVOID,DWORD,BOOL); +PWINDOW APIENTRY co_IntCreateWindowEx(DWORD,PUNICODE_STRING,PUNICODE_STRING,DWORD,LONG,LONG,LONG,LONG,HWND,HMENU,HINSTANCE,LPVOID,DWORD,BOOL); #endif /* _WIN32K_WINDOW_H */ /* EOF */ diff --git a/reactos/subsystems/win32/win32k/ntuser/desktop.c b/reactos/subsystems/win32/win32k/ntuser/desktop.c index b5cffedc20d..ebfdf6163d0 100644 --- a/reactos/subsystems/win32/win32k/ntuser/desktop.c +++ b/reactos/subsystems/win32/win32k/ntuser/desktop.c @@ -566,7 +566,7 @@ HWND FASTCALL IntGetMessageWindow(VOID) DPRINT("No active desktop\n"); return NULL; } - return pdo->spwndMessage; + return pdo->spwndMessage->hdr.Handle; } HWND FASTCALL IntGetCurrentThreadDesktopWindow(VOID) @@ -898,7 +898,6 @@ NtUserCreateDesktop( { OBJECT_ATTRIBUTES ObjectAttributes; PTHREADINFO W32Thread; - HWND hwndMessage; PWINSTATION_OBJECT WinStaObject; PDESKTOP DesktopObject; UNICODE_STRING DesktopName; @@ -916,6 +915,7 @@ NtUserCreateDesktop( PPROCESSINFO pi = GetW32ProcessInfo(); WNDCLASSEXW wc; PWINDOWCLASS Class; + PWINDOW pWnd; DECLARE_RETURN(HDESK); DPRINT("Enter NtUserCreateDesktop: %wZ\n", lpszDesktopName); @@ -1149,27 +1149,27 @@ NtUserCreateDesktop( DPRINT1("!!! Registering Message system class failed!\n"); } - hwndMessage = co_IntCreateWindowEx( 0, - &ClassName, - &WindowName, - (WS_POPUP|WS_CLIPCHILDREN), - 0, - 0, - 100, - 100, - NULL, - NULL, - pi->hModUser, // hModClient; - NULL, - 0, - TRUE); - if (!hwndMessage) + pWnd = co_IntCreateWindowEx( 0, + &ClassName, + &WindowName, + (WS_POPUP|WS_CLIPCHILDREN), + 0, + 0, + 100, + 100, + NULL, + NULL, + pi->hModUser, // hModClient; + NULL, + 0, + TRUE); + if (!pWnd) { DPRINT1("Failed to create Message window handle\n"); } else { - DesktopObject->spwndMessage = hwndMessage; + DesktopObject->spwndMessage = pWnd; } RETURN( Desktop); diff --git a/reactos/subsystems/win32/win32k/ntuser/window.c b/reactos/subsystems/win32/win32k/ntuser/window.c index 875b44df6cc..d003672c5bb 100644 --- a/reactos/subsystems/win32/win32k/ntuser/window.c +++ b/reactos/subsystems/win32/win32k/ntuser/window.c @@ -1518,7 +1518,7 @@ IntCalcDefPosSize(PWINDOW_OBJECT Parent, PWINDOW_OBJECT Window, RECTL *rc, BOOL /* * @implemented */ -HWND APIENTRY +PWINDOW APIENTRY co_IntCreateWindowEx(DWORD dwExStyle, PUNICODE_STRING ClassName, PUNICODE_STRING WindowName, @@ -1558,7 +1558,7 @@ co_IntCreateWindowEx(DWORD dwExStyle, CBT_CREATEWNDW CbtCreate; LRESULT Result; BOOL MenuChanged; - DECLARE_RETURN(HWND); + DECLARE_RETURN(PWINDOW); BOOL HasOwner; USER_REFERENCE_ENTRY ParentRef, Ref; PTHREADINFO pti; @@ -1595,7 +1595,7 @@ co_IntCreateWindowEx(DWORD dwExStyle, else if ((dwStyle & (WS_CHILD | WS_POPUP)) == WS_CHILD) { SetLastWin32Error(ERROR_TLW_WITH_WSCHILD); - RETURN( (HWND)0); /* WS_CHILD needs a parent, but WS_POPUP doesn't */ + RETURN( (PWINDOW)0); /* WS_CHILD needs a parent, but WS_POPUP doesn't */ } if (ParentWindowHandle) @@ -1616,7 +1616,7 @@ co_IntCreateWindowEx(DWORD dwExStyle, if (ti == NULL || pti->Desktop == NULL) { DPRINT1("Thread is not attached to a desktop! Cannot create window!\n"); - RETURN( (HWND)0); + RETURN( (PWINDOW)0); } /* Check the class. */ @@ -1639,7 +1639,7 @@ co_IntCreateWindowEx(DWORD dwExStyle, } SetLastWin32Error(ERROR_CANNOT_FIND_WND_CLASS); - RETURN((HWND)0); + RETURN((PWINDOW)0); } Class = IntReferenceClass(Class, @@ -1657,9 +1657,10 @@ co_IntCreateWindowEx(DWORD dwExStyle, ObReferenceObjectByPointer(WinSta, KernelMode, ExWindowStationObjectType, 0); /* Create the window object. */ - Window = (PWINDOW_OBJECT) - UserCreateObject(gHandleTable, (PHANDLE)&hWnd, - otWindow, sizeof(WINDOW_OBJECT)); + Window = (PWINDOW_OBJECT) UserCreateObject( gHandleTable, + (PHANDLE)&hWnd, + otWindow, + sizeof(WINDOW_OBJECT)); if (Window) { Window->Wnd = DesktopHeapAlloc(pti->Desktop, @@ -1668,7 +1669,7 @@ co_IntCreateWindowEx(DWORD dwExStyle, goto AllocErr; RtlZeroMemory(Window->Wnd, sizeof(WINDOW) + Class->WndExtra); - Window->Wnd->hdr.Handle = hWnd; /* FIXME: Remove hack */ + Window->Wnd->hdr.Handle = hWnd; /* FIXME: Remove hack , are you sure?*/ Wnd = Window->Wnd; Wnd->ti = ti; @@ -1683,7 +1684,7 @@ co_IntCreateWindowEx(DWORD dwExStyle, AllocErr: ObDereferenceObject(WinSta); SetLastNtError(STATUS_INSUFFICIENT_RESOURCES); - RETURN( (HWND)0); + RETURN( (PWINDOW)0); } UserRefObjectCo(Window, &Ref); @@ -1775,7 +1776,7 @@ AllocErr: if (Wnd->WindowName.Buffer == NULL) { SetLastNtError(STATUS_INSUFFICIENT_RESOURCES); - RETURN( (HWND)0); + RETURN( (PWINDOW)0); } Wnd->WindowName.Buffer[WindowName->Length / sizeof(WCHAR)] = L'\0'; @@ -1885,7 +1886,7 @@ AllocErr: /* FIXME - Delete window object and remove it from the thread windows list */ /* FIXME - delete allocated DCE */ DPRINT1("CBT-hook returned !0\n"); - RETURN( (HWND) NULL); + RETURN( (PWINDOW) NULL); } } x = Cs.x; @@ -2052,7 +2053,7 @@ AllocErr: { /* FIXME: Cleanup. */ DPRINT1("IntCreateWindowEx(): NCCREATE message failed. No cleanup performed!\n"); - RETURN((HWND)0); + RETURN((PWINDOW)0); } /* Calculate the non-client size. */ @@ -2116,7 +2117,7 @@ AllocErr: /* FIXME: Cleanup. */ DPRINT1("IntCreateWindowEx(): send CREATE message failed. No cleanup performed!\n"); IntUnlinkWindow(Window); - RETURN((HWND)0); + RETURN((PWINDOW)0); } IntNotifyWinEvent(EVENT_OBJECT_CREATE, Window->hSelf, OBJID_WINDOW, 0); @@ -2254,7 +2255,7 @@ AllocErr: DPRINT("IntCreateWindow(): = %X\n", hWnd); DPRINT("WindowObject->SystemMenu = 0x%x\n", Window->SystemMenu); - RETURN(hWnd); + RETURN( Wnd); CLEANUP: if (!_ret_ && Window && Window->Wnd && ti) @@ -2297,7 +2298,8 @@ NtUserCreateWindowEx(DWORD dwExStyle, NTSTATUS Status; UNICODE_STRING WindowName; UNICODE_STRING ClassName; - HWND NewWindow; + HWND NewWindow = NULL; + PWINDOW pNewWindow; DECLARE_RETURN(HWND); DPRINT("Enter NtUserCreateWindowEx(): (%d,%d-%d,%d)\n", x, y, nWidth, nHeight); @@ -2344,8 +2346,22 @@ NtUserCreateWindowEx(DWORD dwExStyle, RtlInitUnicodeString(&WindowName, NULL); } - NewWindow = co_IntCreateWindowEx(dwExStyle, &ClassName, &WindowName, dwStyle, x, y, nWidth, nHeight, - hWndParent, hMenu, hInstance, lpParam, dwShowMode, bUnicodeWindow); + pNewWindow = co_IntCreateWindowEx( dwExStyle, + &ClassName, + &WindowName, + dwStyle, + x, + y, + nWidth, + nHeight, + hWndParent, + hMenu, + hInstance, + lpParam, + dwShowMode, + bUnicodeWindow); + + if (pNewWindow) NewWindow = pNewWindow->hdr.Handle; if (WindowName.Buffer) {