From 5c5255881794af76d35a4300b1f6aadb631c08db Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 22 Dec 2003 11:37:32 +0000 Subject: [PATCH] - Enabled CS_PARENTDC style for edit control. - Minor corrections in [Get/Set]WindowPlacement. - Fixed handling of MDI client info structure. - Bug fixes. svn path=/trunk/; revision=7174 --- reactos/lib/user32/controls/edit.c | 2 +- reactos/lib/user32/windows/mdi.c | 22 +++++++-- reactos/lib/user32/windows/window.c | 4 +- reactos/subsys/win32k/ntuser/painting.c | 8 +--- reactos/subsys/win32k/ntuser/window.c | 42 +++++++++++++---- reactos/subsys/win32k/ntuser/winpos.c | 62 ++++++++++++++++++++++++- 6 files changed, 114 insertions(+), 26 deletions(-) diff --git a/reactos/lib/user32/controls/edit.c b/reactos/lib/user32/controls/edit.c index d7ef6df4173..bf7bf0a447b 100644 --- a/reactos/lib/user32/controls/edit.c +++ b/reactos/lib/user32/controls/edit.c @@ -294,7 +294,7 @@ const struct builtin_class_descr EDIT_builtin_class = #ifdef __REACTOS__ L"Edit", /* name */ /* FIXME: Add CS_PARENTDC when the handling of WM_ERASEBKGND will be fixed! */ - CS_GLOBALCLASS | CS_DBLCLKS, /* style */ + CS_GLOBALCLASS | CS_DBLCLKS | CS_PARENTDC, /* style */ (WNDPROC)EditWndProcW, /* procW */ (WNDPROC)EditWndProcA, /* procA */ sizeof(EDITSTATE *), /* extra */ diff --git a/reactos/lib/user32/windows/mdi.c b/reactos/lib/user32/windows/mdi.c index ceae74ea75b..bb8a30772d2 100644 --- a/reactos/lib/user32/windows/mdi.c +++ b/reactos/lib/user32/windows/mdi.c @@ -219,11 +219,11 @@ const struct builtin_class_descr MDICLIENT_builtin_class = { #ifdef __REACTOS__ L"MDIClient", /* name */ - CS_GLOBALCLASS, /* style */ - MDIClientWndProcW, /* procW */ - MDIClientWndProcA, /* procA */ - sizeof(MDICLIENTINFO), /* extra */ - IDC_ARROW, /* cursor */ + CS_GLOBALCLASS, /* style */ + MDIClientWndProcW, /* procW */ + MDIClientWndProcA, /* procA */ + sizeof(MDICLIENTINFO *), /* extra */ + IDC_ARROW, /* cursor */ (HBRUSH)(COLOR_APPWORKSPACE+1) /* brush */ #else "MDIClient", /* name */ @@ -1340,6 +1340,14 @@ static LRESULT MDIClientWndProc_common( HWND hwnd, UINT message, switch (message) { +#ifdef __REACTOS__ + case WM_NCCREATE: + if (!(ci = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ci)))) + return FALSE; + SetWindowLongPtrW( hwnd, 0, (LONG_PTR)ci ); + return TRUE; +#endif + case WM_CREATE: { RECT rect; @@ -1413,6 +1421,10 @@ static LRESULT MDIClientWndProc_common( HWND hwnd, UINT message, DeleteMenu(ci->hWindowMenu,MF_BYPOSITION,ci->idFirstChild--); } if (ci->frameTitle) HeapFree( GetProcessHeap(), 0, ci->frameTitle ); +#ifdef __REACTOS__ + HeapFree( GetProcessHeap(), 0, ci ); + SetWindowLongPtrW( hwnd, 0, 0 ); +#endif return 0; } diff --git a/reactos/lib/user32/windows/window.c b/reactos/lib/user32/windows/window.c index 063a67269e7..95f97334486 100644 --- a/reactos/lib/user32/windows/window.c +++ b/reactos/lib/user32/windows/window.c @@ -1,4 +1,4 @@ -/* $Id: window.c,v 1.91 2003/12/19 23:20:05 weiden Exp $ +/* $Id: window.c,v 1.92 2003/12/22 11:37:32 navaraf Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -1267,7 +1267,7 @@ IsWindowEnabled( // AG: I don't know if child windows are affected if the parent is // disabled. I think they stop processing messages but stay appearing // as enabled. - + return (! (NtUserGetWindowLong(hWnd, GWL_STYLE, FALSE) & WS_DISABLED)); } diff --git a/reactos/subsys/win32k/ntuser/painting.c b/reactos/subsys/win32k/ntuser/painting.c index 397798400f9..36cebd50c98 100644 --- a/reactos/subsys/win32k/ntuser/painting.c +++ b/reactos/subsys/win32k/ntuser/painting.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: painting.c,v 1.49 2003/12/18 21:56:44 weiden Exp $ + * $Id: painting.c,v 1.50 2003/12/22 11:37:32 navaraf Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -747,12 +747,6 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* lPs) NtUserHideCaret(hWnd); DcxFlags = DCX_INTERSECTUPDATE | DCX_WINDOWPAINT | DCX_USESTYLE; - if (IntGetClassLong(Window, GCL_STYLE, FALSE) & CS_PARENTDC) - { - /* FIXME: Is this correct? */ - /* Don't clip the output to the update region for CS_PARENTDC window */ - DcxFlags &= ~DCX_INTERSECTUPDATE; - } lPs->hdc = NtUserGetDCEx(hWnd, 0, DcxFlags); diff --git a/reactos/subsys/win32k/ntuser/window.c b/reactos/subsys/win32k/ntuser/window.c index 646d3cf2aa4..66ef5d18b5a 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.169 2003/12/19 23:20:06 weiden Exp $ +/* $Id: window.c,v 1.170 2003/12/22 11:37:32 navaraf Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -1280,18 +1280,20 @@ NtUserCreateWindowEx(DWORD dwExStyle, /* * Get the size and position of the window. */ -#if 0 if ((dwStyle & WS_THICKFRAME) || !(dwStyle & (WS_POPUP | WS_CHILD))) { + POINT MaxSize, MaxPos, MinTrack, MaxTrack; + /* WinPosGetMinMaxInfo sends the WM_GETMINMAXINFO message */ WinPosGetMinMaxInfo(WindowObject, &MaxSize, &MaxPos, &MinTrack, &MaxTrack); - x = min(MaxSize.x, y); - y = min(MaxSize.y, y); - x = max(MinTrack.x, x); - y = max(MinTrack.y, y); + if (MaxSize.x < nWidth) nWidth = MaxSize.x; + if (MaxSize.y < nHeight) nHeight = MaxSize.y; + if (nWidth < MinTrack.x ) nWidth = MinTrack.x; + if (nHeight < MinTrack.y ) nHeight = MinTrack.y; + if (nWidth < 0) nWidth = 0; + if (nHeight < 0) nHeight = 0; } -#endif WindowObject->WindowRect.left = x; WindowObject->WindowRect.top = y; @@ -2662,6 +2664,12 @@ NtUserGetWindowPlacement(HWND hWnd, /* FIXME - fill structure */ Safepl.flags = 0; Safepl.showCmd = ((WindowObject->Style & WINDOWOBJECT_RESTOREMAX) ? SW_MAXIMIZE : SW_SHOWNORMAL); + if (WindowObject->InternalPos) + { + Safepl.rcNormalPosition = WindowObject->InternalPos->NormalRect; + Safepl.ptMinPosition = WindowObject->InternalPos->IconPos; + Safepl.ptMaxPosition = WindowObject->InternalPos->MaxPos; + } Status = MmCopyToCaller(lpwndpl, &Safepl, sizeof(WINDOWPLACEMENT)); if(!NT_SUCCESS(Status)) @@ -3043,14 +3051,13 @@ NtUserSetWindowPlacement(HWND hWnd, 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)) { @@ -3064,9 +3071,24 @@ NtUserSetWindowPlacement(HWND hWnd, return FALSE; } + if ((WindowObject->Style & (WS_MAXIMIZE | WS_MINIMIZE)) == 0) + { + WinPosSetWindowPos(WindowObject->Self, NULL, + Safepl.rcNormalPosition.left, Safepl.rcNormalPosition.top, + Safepl.rcNormalPosition.right - Safepl.rcNormalPosition.left, + Safepl.rcNormalPosition.bottom - Safepl.rcNormalPosition.top, + SWP_NOZORDER | SWP_NOACTIVATE); + } + /* FIXME - change window status */ WinPosShowWindow(WindowObject->Self, Safepl.showCmd); - + + if (WindowObject->InternalPos == NULL) + WindowObject->InternalPos = ExAllocatePool(PagedPool, sizeof(INTERNALPOS)); + WindowObject->InternalPos->NormalRect = Safepl.rcNormalPosition; + WindowObject->InternalPos->IconPos = Safepl.ptMinPosition; + WindowObject->InternalPos->MaxPos = Safepl.ptMaxPosition; + IntReleaseWindowObject(WindowObject); return TRUE; } diff --git a/reactos/subsys/win32k/ntuser/winpos.c b/reactos/subsys/win32k/ntuser/winpos.c index a12585abae5..4a76ba4444c 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.59 2003/12/21 22:38:38 weiden Exp $ +/* $Id: winpos.c,v 1.60 2003/12/22 11:37:32 navaraf Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -530,7 +530,67 @@ WinPosDoWinPosChanging(PWINDOW_OBJECT WindowObject, HWND FASTCALL WinPosDoOwnedPopups(HWND hWnd, HWND hWndInsertAfter) { +#if 0 /* FIXME */ + return hWndInsertAfter; +#endif + HWND *List = NULL; + HWND Owner = NtUserGetWindow(hWnd, GW_OWNER); + LONG Style = NtUserGetWindowLong(hWnd, GWL_STYLE, FALSE); + PWINDOW_OBJECT DesktopWindow; + int i; + + if ((Style & WS_POPUP) && Owner) + { + /* Make sure this popup stays above the owner */ + HWND hWndLocalPrev = HWND_TOP; + + if (hWndInsertAfter != HWND_TOP) + { + DesktopWindow = IntGetWindowObject(IntGetDesktopWindow()); + List = IntWinListChildren(DesktopWindow); + IntReleaseWindowObject(DesktopWindow); + if (List != NULL) + { + for (i = 0; List[i]; i++) + { + if (List[i] == Owner) break; + if (List[i] != hWnd) hWndLocalPrev = List[i]; + if (hWndLocalPrev == hWndInsertAfter) break; + } + hWndInsertAfter = hWndLocalPrev; + } + } + } + else if (Style & WS_CHILD) + { + return hWndInsertAfter; + } + + if (!List) + { + DesktopWindow = IntGetWindowObject(IntGetDesktopWindow()); + List = IntWinListChildren(DesktopWindow); + IntReleaseWindowObject(DesktopWindow); + } + if (List != NULL) + { + for (i = 0; List[i]; i++) + { + DPRINT1("%x\n", List[i]); + if (List[i] == hWnd) + break; + if ((NtUserGetWindowLong(List[i], GWL_STYLE, FALSE) & WS_POPUP) && + NtUserGetWindow(List[i], GW_OWNER) == hWnd) + { + WinPosSetWindowPos(List[i], hWndInsertAfter, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING); + hWndInsertAfter = List[i]; + } + } + ExFreePool(List); + } + return hWndInsertAfter; }