From e437baff4582ba1f6fb394b070f3134ca5e8e335 Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Fri, 19 Dec 2003 23:20:06 +0000 Subject: [PATCH] implemented maximize/restore and minimize buttons for windows, minimize and restore need to be fixed, they don't work properly svn path=/trunk/; revision=7129 --- reactos/include/win32k/ntuser.h | 12 ++-- reactos/lib/user32/windows/defwnd.c | 28 +++++++- reactos/lib/user32/windows/nonclient.c | 2 +- reactos/lib/user32/windows/window.c | 10 ++- reactos/subsys/win32k/include/window.h | 1 + reactos/subsys/win32k/ntuser/window.c | 91 +++++++++++++++++++++----- reactos/subsys/win32k/ntuser/winpos.c | 15 +++-- 7 files changed, 124 insertions(+), 35 deletions(-) diff --git a/reactos/include/win32k/ntuser.h b/reactos/include/win32k/ntuser.h index 99db99086ac..2519189d370 100644 --- a/reactos/include/win32k/ntuser.h +++ b/reactos/include/win32k/ntuser.h @@ -887,11 +887,11 @@ STDCALL NtUserGetWindowDC( HWND hWnd); -DWORD +BOOL STDCALL NtUserGetWindowPlacement( - DWORD Unknown0, - DWORD Unknown1); + HWND hWnd, + WINDOWPLACEMENT *lpwndpl); DWORD STDCALL @@ -1546,11 +1546,11 @@ NtUserSetWindowLong( LONG NewValue, BOOL Ansi); -DWORD +BOOL STDCALL NtUserSetWindowPlacement( - DWORD Unknown0, - DWORD Unknown1); + HWND hWnd, + WINDOWPLACEMENT *lpwndpl); BOOL STDCALL NtUserSetWindowPos( diff --git a/reactos/lib/user32/windows/defwnd.c b/reactos/lib/user32/windows/defwnd.c index 70025edc00c..e5982b3a937 100644 --- a/reactos/lib/user32/windows/defwnd.c +++ b/reactos/lib/user32/windows/defwnd.c @@ -1,4 +1,4 @@ -/* $Id: defwnd.c,v 1.110 2003/12/11 16:24:06 gvg Exp $ +/* $Id: defwnd.c,v 1.111 2003/12/19 23:20:05 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -752,12 +752,38 @@ DefWndDoSizeMove(HWND hwnd, WORD wParam) LRESULT DefWndHandleSysCommand(HWND hWnd, WPARAM wParam, POINT Pt) { + WINDOWPLACEMENT wp; + switch (wParam & 0xfff0) { case SC_MOVE: case SC_SIZE: DefWndDoSizeMove(hWnd, wParam); break; + case SC_MINIMIZE: + wp.length = sizeof(WINDOWPLACEMENT); + if(GetWindowPlacement(hWnd, &wp)) + { + wp.showCmd = SW_MINIMIZE; + SetWindowPlacement(hWnd, &wp); + } + break; + case SC_MAXIMIZE: + wp.length = sizeof(WINDOWPLACEMENT); + if(GetWindowPlacement(hWnd, &wp)) + { + wp.showCmd = SW_MAXIMIZE; + SetWindowPlacement(hWnd, &wp); + } + break; + case SC_RESTORE: + wp.length = sizeof(WINDOWPLACEMENT); + if(GetWindowPlacement(hWnd, &wp)) + { + wp.showCmd = SW_RESTORE; + SetWindowPlacement(hWnd, &wp); + } + break; case SC_CLOSE: SendMessageA(hWnd, WM_CLOSE, 0, 0); break; diff --git a/reactos/lib/user32/windows/nonclient.c b/reactos/lib/user32/windows/nonclient.c index 7a0c6f5c460..fe5c7ff7450 100644 --- a/reactos/lib/user32/windows/nonclient.c +++ b/reactos/lib/user32/windows/nonclient.c @@ -807,7 +807,7 @@ DefWndDoButton(HWND hWnd, WPARAM wParam) break; case HTMAXBUTTON: Btn = DFCS_CAPTIONMAX; - SCMsg = SC_MAXIMIZE; + SCMsg = ((Style & WS_MAXIMIZE) ? SC_RESTORE : SC_MAXIMIZE); HasBtn = (Style & WS_MAXIMIZEBOX); break; default: diff --git a/reactos/lib/user32/windows/window.c b/reactos/lib/user32/windows/window.c index 6e242c5d356..063a67269e7 100644 --- a/reactos/lib/user32/windows/window.c +++ b/reactos/lib/user32/windows/window.c @@ -1,4 +1,4 @@ -/* $Id: window.c,v 1.90 2003/12/18 16:47:27 navaraf Exp $ +/* $Id: window.c,v 1.91 2003/12/19 23:20:05 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -1124,14 +1124,13 @@ GetWindowModuleFileNameW(HWND hwnd, /* - * @unimplemented + * @implemented */ WINBOOL STDCALL GetWindowPlacement(HWND hWnd, WINDOWPLACEMENT *lpwndpl) { - UNIMPLEMENTED; - return FALSE; + return (WINBOOL)NtUserGetWindowPlacement(hWnd, lpwndpl); } @@ -1419,8 +1418,7 @@ WINBOOL STDCALL SetWindowPlacement(HWND hWnd, CONST WINDOWPLACEMENT *lpwndpl) { - UNIMPLEMENTED; - return FALSE; + return (WINBOOL)NtUserSetWindowPlacement(hWnd, (WINDOWPLACEMENT *)lpwndpl); } diff --git a/reactos/subsys/win32k/include/window.h b/reactos/subsys/win32k/include/window.h index 17b32fbe3c8..ec016a8b9bc 100644 --- a/reactos/subsys/win32k/include/window.h +++ b/reactos/subsys/win32k/include/window.h @@ -81,6 +81,7 @@ typedef struct _WINDOW_OBJECT WNDPROC WndProcW; PETHREAD OwnerThread; HWND hWndLastPopup; /* handle to last active popup window (wine doesn't use pointer, for unk. reason)*/ + RECT NormalRect; } WINDOW_OBJECT; /* PWINDOW_OBJECT already declared at top of file */ /* Window flags. */ diff --git a/reactos/subsys/win32k/ntuser/window.c b/reactos/subsys/win32k/ntuser/window.c index de39d18aec3..646d3cf2aa4 100644 --- a/reactos/subsys/win32k/ntuser/window.c +++ b/reactos/subsys/win32k/ntuser/window.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: window.c,v 1.168 2003/12/18 13:00:56 gvg Exp $ +/* $Id: window.c,v 1.169 2003/12/19 23:20:06 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -2629,15 +2629,50 @@ NtUserSetWindowWord(HWND hWnd, INT Index, WORD NewValue) } /* - * @unimplemented + * @implemented */ -DWORD STDCALL -NtUserGetWindowPlacement(DWORD Unknown0, - DWORD Unknown1) +BOOL STDCALL +NtUserGetWindowPlacement(HWND hWnd, + WINDOWPLACEMENT *lpwndpl) { - UNIMPLEMENTED - - return 0; + PWINDOW_OBJECT WindowObject; + WINDOWPLACEMENT Safepl; + NTSTATUS Status; + + WindowObject = IntGetWindowObject(hWnd); + if (WindowObject == NULL) + { + SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); + return FALSE; + } + + Status = MmCopyFromCaller(&Safepl, lpwndpl, sizeof(WINDOWPLACEMENT)); + if(!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + IntReleaseWindowObject(WindowObject); + return FALSE; + } + if(Safepl.length != sizeof(WINDOWPLACEMENT)) + { + IntReleaseWindowObject(WindowObject); + return FALSE; + } + + /* FIXME - fill structure */ + Safepl.flags = 0; + Safepl.showCmd = ((WindowObject->Style & WINDOWOBJECT_RESTOREMAX) ? SW_MAXIMIZE : SW_SHOWNORMAL); + + Status = MmCopyToCaller(lpwndpl, &Safepl, sizeof(WINDOWPLACEMENT)); + if(!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + IntReleaseWindowObject(WindowObject); + return FALSE; + } + + IntReleaseWindowObject(WindowObject); + return TRUE; } @@ -2999,15 +3034,41 @@ NtUserSetWindowFNID(DWORD Unknown0, /* - * @unimplemented + * @implemented */ -DWORD STDCALL -NtUserSetWindowPlacement(DWORD Unknown0, - DWORD Unknown1) +BOOL STDCALL +NtUserSetWindowPlacement(HWND hWnd, + WINDOWPLACEMENT *lpwndpl) { - UNIMPLEMENTED - - return 0; + PWINDOW_OBJECT WindowObject; + WINDOWPLACEMENT Safepl; + NTSTATUS Status; + + WindowObject = IntGetWindowObject(hWnd); + if (WindowObject == NULL) + { + SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); + return FALSE; + } + + Status = MmCopyFromCaller(&Safepl, lpwndpl, sizeof(WINDOWPLACEMENT)); + if(!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + IntReleaseWindowObject(WindowObject); + return FALSE; + } + if(Safepl.length != sizeof(WINDOWPLACEMENT)) + { + IntReleaseWindowObject(WindowObject); + return FALSE; + } + + /* FIXME - change window status */ + WinPosShowWindow(WindowObject->Self, Safepl.showCmd); + + IntReleaseWindowObject(WindowObject); + return TRUE; } diff --git a/reactos/subsys/win32k/ntuser/winpos.c b/reactos/subsys/win32k/ntuser/winpos.c index 560357a12c0..86b8a6a5d08 100644 --- a/reactos/subsys/win32k/ntuser/winpos.c +++ b/reactos/subsys/win32k/ntuser/winpos.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: winpos.c,v 1.56 2003/12/15 21:51:10 weiden Exp $ +/* $Id: winpos.c,v 1.57 2003/12/19 23:20:06 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -184,6 +184,11 @@ WinPosInitInternalPos(PWINDOW_OBJECT WindowObject, POINT pt, PRECT RestoreRect) { InternalPos = ExAllocatePool(NonPagedPool, sizeof(INTERNALPOS)); + if(!InternalPos) + { + DPRINT1("Failed to allocate INTERNALPOS structure for window 0x%x\n", WindowObject->Self); + return NULL; + } IntSetProp(WindowObject, AtomInternalPos, InternalPos); InternalPos->IconTitle = 0; InternalPos->NormalRect = WindowObject->WindowRect; @@ -259,7 +264,7 @@ WinPosMinMaximize(PWINDOW_OBJECT WindowObject, UINT ShowFlag, RECT* NewPos) WinPosShowIconTitle(WindowObject, FALSE); WindowObject->Style &= ~WS_MINIMIZE; } - WindowObject->Style |= WS_MINIMIZE; + WindowObject->Style |= WS_MAXIMIZE; NtGdiSetRect(NewPos, InternalPos->MaxPos.x, InternalPos->MaxPos.y, Size.x, Size.y); break; @@ -287,13 +292,11 @@ WinPosMinMaximize(PWINDOW_OBJECT WindowObject, UINT ShowFlag, RECT* NewPos) { return(-1); } - else - { - WindowObject->Style &= ~WS_MAXIMIZE; - } + WindowObject->Style &= ~WS_MAXIMIZE; *NewPos = InternalPos->NormalRect; NewPos->right -= NewPos->left; NewPos->bottom -= NewPos->top; + DPRINT1("Restoring window to %d, %d, %d, %d\n", NewPos->left, NewPos->top, NewPos->right, NewPos->bottom); break; } }