From 6491031cc2ebc851bf95ead5a454f89e2b7acc6d Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Fri, 2 Apr 2004 20:51:08 +0000 Subject: [PATCH] implemented GetWindowInfo() svn path=/trunk/; revision=8953 --- reactos/include/win32k/ntuser.h | 1 + reactos/lib/user32/include/user32.h | 3 ++ reactos/lib/user32/windows/window.c | 7 ++-- reactos/subsys/win32k/include/window.h | 17 +++++++++ reactos/subsys/win32k/ntuser/misc.c | 36 ++++++++++++++++- reactos/subsys/win32k/ntuser/window.c | 44 ++++++++++++++++++++- reactos/subsys/win32k/ntuser/winpos.c | 53 ++------------------------ 7 files changed, 105 insertions(+), 56 deletions(-) diff --git a/reactos/include/win32k/ntuser.h b/reactos/include/win32k/ntuser.h index 91019b8720d..7276838bc7d 100644 --- a/reactos/include/win32k/ntuser.h +++ b/reactos/include/win32k/ntuser.h @@ -197,6 +197,7 @@ NtUserCallOneParam( #define TWOPARAM_ROUTINE_SETWNDCONTEXTHLPID 0x58 #define TWOPARAM_ROUTINE_CURSORPOSITION 0x59 #define TWOPARAM_ROUTINE_SETCARETPOS 0x60 +#define TWOPARAM_ROUTINE_GETWINDOWINFO 0x61 DWORD STDCALL NtUserCallTwoParam( diff --git a/reactos/lib/user32/include/user32.h b/reactos/lib/user32/include/user32.h index d44f29edf27..d33fb9010e6 100644 --- a/reactos/lib/user32/include/user32.h +++ b/reactos/lib/user32/include/user32.h @@ -55,6 +55,9 @@ void DrawCaret(HWND hWnd, PTHRDCARETINFO CaretInfo); #define NtUserSetMenuBarHeight(menu, height) \ (BOOL)NtUserCallTwoParam((DWORD)menu, (DWORD)height, TWOPARAM_ROUTINE_SETMENUBARHEIGHT) +#define NtUserGetWindowInfo(hwnd, pwi) \ + (BOOL)NtUserCallTwoParam((DWORD)hwnd, (DWORD)pwi, TWOPARAM_ROUTINE_GETWINDOWINFO) + #define NtUserSetCaretBlinkTime(uMSeconds) \ (BOOL)NtUserCallOneParam((DWORD)uMSeconds, ONEPARAM_ROUTINE_SETCARETBLINKTIME) diff --git a/reactos/lib/user32/windows/window.c b/reactos/lib/user32/windows/window.c index 604ce18487a..9b84f1f1002 100644 --- a/reactos/lib/user32/windows/window.c +++ b/reactos/lib/user32/windows/window.c @@ -1,4 +1,4 @@ -/* $Id: window.c,v 1.102 2004/03/14 11:27:33 gvg Exp $ +/* $Id: window.c,v 1.103 2004/04/02 20:51:07 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -890,14 +890,13 @@ GetTopWindow(HWND hWnd) /* - * @unimplemented + * @implemented */ BOOL STDCALL GetWindowInfo(HWND hwnd, PWINDOWINFO pwi) { - UNIMPLEMENTED; - return FALSE; + return NtUserGetWindowInfo(hwnd, pwi); } diff --git a/reactos/subsys/win32k/include/window.h b/reactos/subsys/win32k/include/window.h index 863f405f80f..5e0ca1b955f 100644 --- a/reactos/subsys/win32k/include/window.h +++ b/reactos/subsys/win32k/include/window.h @@ -108,6 +108,17 @@ typedef struct _WINDOW_OBJECT #define WINDOWSTATUS_DESTROYING (0x1) #define WINDOWSTATUS_DESTROYED (0x2) +#define HAS_DLGFRAME(Style, ExStyle) \ + (((ExStyle) & WS_EX_DLGMODALFRAME) || \ + (((Style) & WS_DLGFRAME) && (!((Style) & WS_THICKFRAME)))) + +#define HAS_THICKFRAME(Style, ExStyle) \ + (((Style) & WS_THICKFRAME) && \ + (!(((Style) & (WS_DLGFRAME | WS_BORDER)) == WS_DLGFRAME))) + +#define HAS_THINFRAME(Style, ExStyle) \ + (((Style) & WS_BORDER) || (!((Style) & (WS_CHILD | WS_POPUP)))) + #define IntIsDesktopWindow(WndObj) \ (WndObj->Parent == NULL) @@ -194,6 +205,12 @@ IntGetWindowRgn(HWND hWnd, HRGN hRgn); INT FASTCALL IntGetWindowRgnBox(HWND hWnd, RECT *Rect); +BOOL FASTCALL +IntGetWindowInfo(PWINDOW_OBJECT WindowObject, PWINDOWINFO pwi); + +VOID FASTCALL +IntGetWindowBorderMeasures(PWINDOW_OBJECT WindowObject, INT *cx, INT *cy); + DWORD IntRemoveWndProcHandle(WNDPROC Handle); DWORD IntRemoveProcessWndProcHandles(HANDLE ProcessID); DWORD IntAddWndProcHandle(WNDPROC WindowProc, BOOL IsUnicode); diff --git a/reactos/subsys/win32k/ntuser/misc.c b/reactos/subsys/win32k/ntuser/misc.c index ab1233850f1..6c37651c88f 100644 --- a/reactos/subsys/win32k/ntuser/misc.c +++ b/reactos/subsys/win32k/ntuser/misc.c @@ -1,4 +1,4 @@ -/* $Id: misc.c,v 1.55 2004/03/23 21:47:37 weiden Exp $ +/* $Id: misc.c,v 1.56 2004/04/02 20:51:08 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -369,6 +369,40 @@ NtUserCallTwoParam( case TWOPARAM_ROUTINE_SETCARETPOS: return (DWORD)IntSetCaretPos((int)Param1, (int)Param2); + + case TWOPARAM_ROUTINE_GETWINDOWINFO: + { + WINDOWINFO wi; + DWORD Ret; + + if(!(WindowObject = IntGetWindowObject((HWND)Param1))) + { + SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); + return FALSE; + } + + Status = MmCopyFromCaller(&wi.cbSize, (PVOID)Param2, sizeof(wi.cbSize)); + if(!NT_SUCCESS(Status)) + { + IntReleaseWindowObject(WindowObject); + SetLastNtError(Status); + return FALSE; + } + + if((Ret = (DWORD)IntGetWindowInfo(WindowObject, &wi))) + { + Status = MmCopyToCaller((PVOID)Param2, &wi, sizeof(WINDOWINFO)); + if(!NT_SUCCESS(Status)) + { + IntReleaseWindowObject(WindowObject); + SetLastNtError(Status); + return FALSE; + } + } + + IntReleaseWindowObject(WindowObject); + return Ret; + } } DPRINT1("Calling invalid routine number 0x%x in NtUserCallTwoParam()\n Param1=0x%x Parm2=0x%x\n", Routine, Param1, Param2); diff --git a/reactos/subsys/win32k/ntuser/window.c b/reactos/subsys/win32k/ntuser/window.c index 7c81158cbce..47a95ba9aa6 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.207 2004/03/31 19:44:34 weiden Exp $ +/* $Id: window.c,v 1.208 2004/04/02 20:51:08 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -430,6 +430,48 @@ static LRESULT IntDestroyWindow(PWINDOW_OBJECT Window, return 0; } +VOID FASTCALL +IntGetWindowBorderMeasures(PWINDOW_OBJECT WindowObject, INT *cx, INT *cy) +{ + if(HAS_DLGFRAME(WindowObject->Style, WindowObject->ExStyle) && !(WindowObject->Style & WS_MINIMIZE)) + { + *cx = NtUserGetSystemMetrics(SM_CXDLGFRAME); + *cy = NtUserGetSystemMetrics(SM_CYDLGFRAME); + } + else + { + if(HAS_THICKFRAME(WindowObject->Style, WindowObject->ExStyle)&& !(WindowObject->Style & WS_MINIMIZE)) + { + *cx = NtUserGetSystemMetrics(SM_CXFRAME); + *cy = NtUserGetSystemMetrics(SM_CYFRAME); + } + else if(HAS_THINFRAME(WindowObject->Style, WindowObject->ExStyle)) + { + *cx = NtUserGetSystemMetrics(SM_CXBORDER); + *cy = NtUserGetSystemMetrics(SM_CYBORDER); + } + else + { + *cx = *cy = 0; + } + } +} + +BOOL FASTCALL +IntGetWindowInfo(PWINDOW_OBJECT WindowObject, PWINDOWINFO pwi) +{ + pwi->cbSize = sizeof(WINDOWINFO); + pwi->rcWindow = WindowObject->WindowRect; + pwi->rcClient = WindowObject->ClientRect; + pwi->dwStyle = WindowObject->Style; + pwi->dwExStyle = WindowObject->ExStyle; + pwi->dwWindowStatus = (NtUserGetForegroundWindow() == WindowObject->Self); /* WS_ACTIVECAPTION */ + IntGetWindowBorderMeasures(WindowObject, &pwi->cxWindowBorders, &pwi->cyWindowBorders); + pwi->atomWindowType = (WindowObject->Class ? WindowObject->Class->Atom : 0); + pwi->wCreatorVersion = 0x400; /* FIXME - return a real version number */ + return TRUE; +} + static BOOL FASTCALL IntSetMenu( PWINDOW_OBJECT WindowObject, diff --git a/reactos/subsys/win32k/ntuser/winpos.c b/reactos/subsys/win32k/ntuser/winpos.c index 36a606d6505..39eacc3f264 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.107 2004/04/01 23:16:21 gvg Exp $ +/* $Id: winpos.c,v 1.108 2004/04/02 20:51:08 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -66,17 +66,6 @@ /* FUNCTIONS *****************************************************************/ -#define HAS_DLGFRAME(Style, ExStyle) \ - (((ExStyle) & WS_EX_DLGMODALFRAME) || \ - (((Style) & WS_DLGFRAME) && (!((Style) & WS_THICKFRAME)))) - -#define HAS_THICKFRAME(Style, ExStyle) \ - (((Style) & WS_THICKFRAME) && \ - (!(((Style) & (WS_DLGFRAME | WS_BORDER)) == WS_DLGFRAME))) - -#define HAS_THINFRAME(Style, ExStyle) \ - (((Style) & WS_BORDER) || (!((Style) & (WS_CHILD | WS_POPUP)))) - BOOL FASTCALL IntGetClientOrigin(HWND hWnd, LPPOINT Point) { @@ -223,25 +212,7 @@ WinPosInitInternalPos(PWINDOW_OBJECT WindowObject, POINT *pt, PRECT RestoreRect) return NULL; } WindowObject->InternalPos->NormalRect = WindowObject->WindowRect; - if (HAS_DLGFRAME(WindowObject->Style, WindowObject->ExStyle) && !(WindowObject->Style & WS_MINIMIZE)) - { - XInc = NtUserGetSystemMetrics(SM_CXDLGFRAME); - YInc = NtUserGetSystemMetrics(SM_CYDLGFRAME); - } - else - { - XInc = YInc = 0; - if (HAS_THICKFRAME(WindowObject->Style, WindowObject->ExStyle)&& !(WindowObject->Style & WS_MINIMIZE)) - { - XInc += NtUserGetSystemMetrics(SM_CXFRAME); - YInc += NtUserGetSystemMetrics(SM_CYFRAME); - } - else if (HAS_THINFRAME(WindowObject->Style, WindowObject->ExStyle)) - { - XInc += NtUserGetSystemMetrics(SM_CXBORDER); - YInc += NtUserGetSystemMetrics(SM_CYBORDER); - } - } + IntGetWindowBorderMeasures(WindowObject, &XInc, &YInc); WindowObject->InternalPos->MaxPos.x = WorkArea.left - XInc; WindowObject->InternalPos->MaxPos.y = WorkArea.top - YInc; WindowObject->InternalPos->IconPos.x = WorkArea.left; @@ -385,25 +356,7 @@ WinPosFillMinMaxInfoStruct(PWINDOW_OBJECT Window, MINMAXINFO *Info) Info->ptMaxTrackSize.x = Info->ptMaxSize.x; Info->ptMaxTrackSize.y = Info->ptMaxSize.y; - if (HAS_DLGFRAME(Window->Style, Window->ExStyle)) - { - XInc = NtUserGetSystemMetrics(SM_CXDLGFRAME); - YInc = NtUserGetSystemMetrics(SM_CYDLGFRAME); - } - else - { - XInc = YInc = 0; - if (HAS_THICKFRAME(Window->Style, Window->ExStyle)) - { - XInc += NtUserGetSystemMetrics(SM_CXFRAME); - YInc += NtUserGetSystemMetrics(SM_CYFRAME); - } - else if (HAS_THINFRAME(Window->Style, Window->ExStyle)) - { - XInc += NtUserGetSystemMetrics(SM_CXBORDER); - YInc += NtUserGetSystemMetrics(SM_CYBORDER); - } - } + IntGetWindowBorderMeasures(Window, &XInc, &YInc); Info->ptMaxSize.x += 2 * XInc; Info->ptMaxSize.y += 2 * YInc;