fix bug 838 (Sol.exe is missing it's menubar)
[reactos.git] / reactos / subsys / win32k / ntuser / window.c
index b99e0a8..d0f24bd 100644 (file)
@@ -571,7 +571,7 @@ co_DestroyThreadWindows(struct _ETHREAD *Thread)
    PLIST_ENTRY Current;
    PWINDOW_OBJECT Wnd;
    USER_REFERENCE_ENTRY Ref;
-   WThread = Thread->Tcb.Win32Thread;
+   WThread = (PW32THREAD)Thread->Tcb.Win32Thread;
    
    while (!IsListEmpty(&WThread->WindowListHead))
    {
@@ -1121,7 +1121,7 @@ NtUserBuildHwndList(
          SetLastWin32Error(ERROR_INVALID_PARAMETER);
          return 0;
       }
-      if(!(W32Thread = Thread->Tcb.Win32Thread))
+      if(!(W32Thread = (PW32THREAD)Thread->Tcb.Win32Thread))
       {
          ObDereferenceObject(Thread);
          DPRINT("Thread is not a GUI Thread!\n");
@@ -1462,6 +1462,10 @@ co_IntCreateWindowEx(DWORD dwExStyle,
    Window->IDMenu = 0;
    Window->Instance = hInstance;
    Window->hSelf = hWnd;
+
+   if (!hMenu)
+       hMenu = Class->hMenu;
+
    if (0 != (dwStyle & WS_CHILD))
    {
       Window->IDMenu = (UINT) hMenu;
@@ -1622,7 +1626,7 @@ co_IntCreateWindowEx(DWORD dwExStyle,
       PRTL_USER_PROCESS_PARAMETERS ProcessParams;
       BOOL CalculatedDefPosSize = FALSE;
 
-      IntGetDesktopWorkArea(Window->OwnerThread->Tcb.Win32Thread->Desktop, &WorkArea);
+      IntGetDesktopWorkArea(((PW32THREAD)Window->OwnerThread->Tcb.Win32Thread)->Desktop, &WorkArea);
 
       rc = WorkArea;
       ProcessParams = PsGetCurrentProcess()->Peb->ProcessParameters;
@@ -2034,8 +2038,8 @@ BOOLEAN FASTCALL co_UserDestroyWindow(PWINDOW_OBJECT Window)
 
    ASSERT_REFS_CO(Window); //fixme: temp hack?
 
-   /* Check for owner thread and desktop window */
-   if ((Window->OwnerThread != PsGetCurrentThread()) || IntIsDesktopWindow(Window))
+   /* Check for owner thread */
+   if ((Window->OwnerThread != PsGetCurrentThread()))
    {
       SetLastWin32Error(ERROR_ACCESS_DENIED);
       return FALSE;
@@ -2103,7 +2107,8 @@ BOOLEAN FASTCALL co_UserDestroyWindow(PWINDOW_OBJECT Window)
          HWND *ChildHandle;
          PWINDOW_OBJECT Child, Desktop;
 
-         Desktop = UserGetWindowObject(IntGetDesktopWindow());
+         Desktop = IntIsDesktopWindow(Window) ? Window :
+                   UserGetWindowObject(IntGetDesktopWindow());
          Children = IntWinListChildren(Desktop);
 
          if (Children)
@@ -2273,7 +2278,7 @@ IntFindWindow(PWINDOW_OBJECT Parent,
          /* Do not send WM_GETTEXT messages in the kernel mode version!
             The user mode version however calls GetWindowText() which will
             send WM_GETTEXT messages to windows belonging to its processes */
-         if((!CheckWindowName || !RtlCompareUnicodeString(WindowName, &(Child->WindowName), FALSE)) &&
+         if((!CheckWindowName || !RtlCompareUnicodeString(WindowName, &(Child->WindowName), TRUE)) &&
                (!ClassAtom || Child->Class->Atom == ClassAtom))
          {
             Ret = Child->hSelf;
@@ -2452,7 +2457,7 @@ NtUserFindWindowEx(HWND hwndParent,
                The user mode version however calls GetWindowText() which will
                send WM_GETTEXT messages to windows belonging to its processes */
             WindowMatches = !CheckWindowName || !RtlCompareUnicodeString(
-                               &WindowName, &TopLevelWindow->WindowName, FALSE);
+                               &WindowName, &TopLevelWindow->WindowName, TRUE);
             ClassMatches = !CheckClassName ||
                            ClassAtom == TopLevelWindow->Class->Atom;
 
@@ -3362,7 +3367,7 @@ co_UserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi)
             /*
              * Remove extended window style bit WS_EX_TOPMOST for shell windows.
              */
-            WindowStation = Window->OwnerThread->Tcb.Win32Thread->Desktop->WindowStation;
+            WindowStation = ((PW32THREAD)Window->OwnerThread->Tcb.Win32Thread)->Desktop->WindowStation;
             if(WindowStation)
             {
                if (hWnd == WindowStation->ShellWindow || hWnd == WindowStation->ShellListView)
@@ -3553,7 +3558,23 @@ NtUserGetWindowPlacement(HWND hWnd,
    }
 
    Safepl.flags = 0;
-   Safepl.showCmd = ((Window->Flags & WINDOWOBJECT_RESTOREMAX) ? SW_MAXIMIZE : SW_SHOWNORMAL);
+   if (0 == (Window->Style & WS_VISIBLE))
+   {
+      Safepl.showCmd = SW_HIDE;
+   }
+   else if (0 != (Window->Flags & WINDOWOBJECT_RESTOREMAX) ||
+            0 != (Window->Style & WS_MAXIMIZE))
+   {
+      Safepl.showCmd = SW_MAXIMIZE;
+   }
+   else if (0 != (Window->Style & WS_MINIMIZE))
+   {
+      Safepl.showCmd = SW_MINIMIZE;
+   }
+   else if (0 != (Window->Style & WS_MINIMIZE))
+   {
+      Safepl.showCmd = SW_SHOWNORMAL;
+   }
 
    Size.x = Window->WindowRect.left;
    Size.y = Window->WindowRect.top;