From 05bd5fcc78efcb25d92f7466f602bb0cfa77e03d Mon Sep 17 00:00:00 2001 From: Andrew Greenwood Date: Wed, 20 Aug 2003 03:07:33 +0000 Subject: [PATCH] * Made a start on a few user32 stubs * Various other small changes svn path=/trunk/; revision=5691 --- reactos/lib/user32/misc/stubs.c | 38 ++++- reactos/lib/user32/windows/class.c | 18 ++- reactos/lib/user32/windows/defwnd.c | 17 ++- reactos/lib/user32/windows/draw.c | 8 +- reactos/lib/user32/windows/input.c | 4 +- reactos/lib/user32/windows/window.c | 226 ++++++++++++++-------------- 6 files changed, 174 insertions(+), 137 deletions(-) diff --git a/reactos/lib/user32/misc/stubs.c b/reactos/lib/user32/misc/stubs.c index f6d8a8930c4..72e17874417 100644 --- a/reactos/lib/user32/misc/stubs.c +++ b/reactos/lib/user32/misc/stubs.c @@ -1,4 +1,4 @@ -/* $Id: stubs.c,v 1.33 2003/08/19 01:31:15 weiden Exp $ +/* $Id: stubs.c,v 1.34 2003/08/20 03:07:33 silverblade Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -11,6 +11,10 @@ */ #include #include +#include +typedef UINT *LPUINT; +#include + /* * @unimplemented @@ -246,15 +250,26 @@ LockWorkStation(VOID) /* - * @unimplemented + * @implemented */ WINBOOL STDCALL MessageBeep( UINT uType) { - UNIMPLEMENTED; - return FALSE; + CHAR EventName[64]; + + switch(uType) + { + case 0xFFFFFFFF : return Beep(500, 100); // Beep through speaker + case MB_ICONASTERISK : strcpy(EventName, "SystemAsterisk"); break; + case MB_ICONEXCLAMATION : strcpy(EventName, "SystemExclamation"); break; + case MB_ICONHAND : strcpy(EventName, "SystemHand"); break; + case MB_ICONQUESTION : strcpy(EventName, "SystemQuestion"); break; + case MB_OK : strcpy(EventName, "SystemDefault"); break; + } +// return PlaySoundA((LPCSTR) &EventName, NULL, SND_ALIAS | SND_NOWAIT | SND_NOSTOP | SND_ASYNC); + return FALSE; } @@ -640,7 +655,7 @@ RegisterShellHookWindow(HWND hWnd) } /* - * @unimplemented + * @implemented */ WINBOOL STDCALL @@ -649,8 +664,17 @@ EndTask( WINBOOL fShutDown, WINBOOL fForce) { - UNIMPLEMENTED; - return FALSE; + SendMessageW(hWnd, WM_CLOSE, 0, 0); + + if (IsWindow(hWnd)) + { + if (fForce) + return DestroyWindow(hWnd); + else + return FALSE; + } + + return TRUE; } /* diff --git a/reactos/lib/user32/windows/class.c b/reactos/lib/user32/windows/class.c index 84bac25e5bc..3dc36d75280 100644 --- a/reactos/lib/user32/windows/class.c +++ b/reactos/lib/user32/windows/class.c @@ -1,4 +1,4 @@ -/* $Id: class.c,v 1.37 2003/08/20 01:05:10 silverblade Exp $ +/* $Id: class.c,v 1.38 2003/08/20 03:07:33 silverblade Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -372,7 +372,7 @@ GetClassNameW( /* - * @unimplemented + * @implemented */ WORD STDCALL @@ -383,8 +383,10 @@ GetClassWord( * NOTE: Obsoleted in 32-bit windows */ { - UNIMPLEMENTED; - return 0; + if ((nIndex < 0) && (nIndex != GCW_ATOM)) + return 0; + + return (WORD) NtUserGetClassLong ( hWnd, nIndex, TRUE ); } @@ -695,7 +697,7 @@ SetClassLongW( /* - * @unimplemented + * @implemented */ WORD STDCALL @@ -707,8 +709,10 @@ SetClassWord( * NOTE: Obsoleted in 32-bit windows */ { - UNIMPLEMENTED; - return 0; + if ((nIndex < 0) && (nIndex != GCW_ATOM)) + return 0; + + return (WORD) NtUserSetClassLong ( hWnd, nIndex, wNewWord, TRUE ); } diff --git a/reactos/lib/user32/windows/defwnd.c b/reactos/lib/user32/windows/defwnd.c index c3edc4126ba..55a5e8125ba 100644 --- a/reactos/lib/user32/windows/defwnd.c +++ b/reactos/lib/user32/windows/defwnd.c @@ -1,4 +1,4 @@ -/* $Id: defwnd.c,v 1.71 2003/08/20 01:41:01 silverblade Exp $ +/* $Id: defwnd.c,v 1.72 2003/08/20 03:07:33 silverblade Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -451,7 +451,10 @@ DrawCaption( #endif // If DC_GRADIENT is specified, a Win 98/2000 style caption gradient should - // be painted. For now, that flag is ignored. + // be painted. For now, that flag is ignored: + // Windows 98/Me, Windows 2000/XP: When this flag is set, the function uses + // COLOR_GRADIENTACTIVECAPTION (if the DC_ACTIVE flag was set) or + // COLOR_GRADIENTINACTIVECAPTION for the title-bar color. // Draw the caption background if (uFlags & DC_INBUTTON) @@ -489,7 +492,11 @@ DrawCaption( if ((uFlags & DC_TEXT) && (GetWindowTextW( hWnd, buffer, sizeof(buffer)/sizeof(buffer[0]) ))) { - r.left += GetSystemMetrics(SM_CXSIZE) + Padding; + // Duplicate odd behaviour from Windows: + if ((! uFlags & DC_SMALLCAP) || (uFlags & DC_ICON) || (uFlags & DC_INBUTTON) || + (! uFlags & DC_ACTIVE)) + r.left += GetSystemMetrics(SM_CXSIZE) + Padding; + r.right = (lprc->right - lprc->left); nclm.cbSize = sizeof(nclm); @@ -501,8 +508,8 @@ DrawCaption( SetTextColor(MemDC, SysColours[ uFlags & DC_ACTIVE ? COLOR_CAPTIONTEXT : COLOR_INACTIVECAPTIONTEXT]); SetBkMode( MemDC, TRANSPARENT ); -// if (GetWindowLongW(hWnd, GWL_STYLE) & WS_EX_TOOLWINDOW) - if (uFlags & DC_SMALLCAP) + if (GetWindowLongW(hWnd, GWL_STYLE) & WS_EX_TOOLWINDOW) +// if (uFlags & DC_SMALLCAP) // incorrect hFont = CreateFontIndirectW(&nclm.lfSmCaptionFont); else hFont = CreateFontIndirectW(&nclm.lfCaptionFont); diff --git a/reactos/lib/user32/windows/draw.c b/reactos/lib/user32/windows/draw.c index d4393dba244..9301e94388f 100644 --- a/reactos/lib/user32/windows/draw.c +++ b/reactos/lib/user32/windows/draw.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: draw.c,v 1.25 2003/08/20 00:41:04 silverblade Exp $ +/* $Id: draw.c,v 1.26 2003/08/20 03:07:33 silverblade Exp $ * * PROJECT: ReactOS user32.dll * FILE: lib/user32/windows/input.c @@ -1684,7 +1684,7 @@ DrawAnimatedRects( /* - * @unimplemented + * @implemented */ WINBOOL STDCALL @@ -2009,7 +2009,7 @@ WINBOOL INTERNAL_DrawState( /* - * @unimplemented + * @implemented */ WINBOOL STDCALL @@ -2030,7 +2030,7 @@ DrawStateA( /* - * @unimplemented + * @implemented */ WINBOOL STDCALL diff --git a/reactos/lib/user32/windows/input.c b/reactos/lib/user32/windows/input.c index 0093c88a2f3..e5092564a18 100644 --- a/reactos/lib/user32/windows/input.c +++ b/reactos/lib/user32/windows/input.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: input.c,v 1.13 2003/08/17 22:45:40 silverblade Exp $ +/* $Id: input.c,v 1.14 2003/08/20 03:07:33 silverblade Exp $ * * PROJECT: ReactOS user32.dll * FILE: lib/user32/windows/input.c @@ -36,7 +36,7 @@ /* - * @unimplemented + * @implemented */ WINBOOL STDCALL diff --git a/reactos/lib/user32/windows/window.c b/reactos/lib/user32/windows/window.c index 5ae2e79341e..5053c94c316 100644 --- a/reactos/lib/user32/windows/window.c +++ b/reactos/lib/user32/windows/window.c @@ -1,4 +1,4 @@ -/* $Id: window.c,v 1.68 2003/08/19 01:31:15 weiden Exp $ +/* $Id: window.c,v 1.69 2003/08/20 03:07:33 silverblade Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -46,7 +46,7 @@ User32SendNCCALCSIZEMessageForKernel(PVOID Arguments, ULONG ArgumentLength) DPRINT("Wrong length.\n"); return(STATUS_INFO_LENGTH_MISMATCH); } - Proc = (WNDPROC)GetWindowLongW(CallbackArgs->Wnd, GWL_WNDPROC); + Proc = (WNDPROC)NtUserGetWindowLong(CallbackArgs->Wnd, GWL_WNDPROC, FALSE); DPRINT("Proc %X\n", Proc); /* Call the window procedure; notice kernel messages are always unicode. */ if (CallbackArgs->Validate) @@ -81,7 +81,7 @@ User32SendGETMINMAXINFOMessageForKernel(PVOID Arguments, ULONG ArgumentLength) DPRINT("Wrong length.\n"); return(STATUS_INFO_LENGTH_MISMATCH); } - Proc = (WNDPROC)GetWindowLongW(CallbackArgs->Wnd, GWL_WNDPROC); + Proc = (WNDPROC)NtUserGetWindowLong(CallbackArgs->Wnd, GWL_WNDPROC, FALSE); DPRINT("Proc %X\n", Proc); /* Call the window procedure; notice kernel messages are always unicode. */ Result.Result = CallWindowProcW(Proc, CallbackArgs->Wnd, WM_GETMINMAXINFO, @@ -106,7 +106,7 @@ User32SendCREATEMessageForKernel(PVOID Arguments, ULONG ArgumentLength) DPRINT("Wrong length.\n"); return(STATUS_INFO_LENGTH_MISMATCH); } - Proc = (WNDPROC)GetWindowLongW(CallbackArgs->Wnd, GWL_WNDPROC); + Proc = (WNDPROC)NtUserGetWindowLong(CallbackArgs->Wnd, GWL_WNDPROC, FALSE); DPRINT("Proc %X\n", Proc); /* Call the window procedure; notice kernel messages are always unicode. */ Result = CallWindowProcW(Proc, CallbackArgs->Wnd, WM_CREATE, 0, @@ -130,7 +130,7 @@ User32SendNCCREATEMessageForKernel(PVOID Arguments, ULONG ArgumentLength) DPRINT("Wrong length.\n"); return(STATUS_INFO_LENGTH_MISMATCH); } - Proc = (WNDPROC)GetWindowLongW(CallbackArgs->Wnd, GWL_WNDPROC); + Proc = (WNDPROC)NtUserGetWindowLong(CallbackArgs->Wnd, GWL_WNDPROC, FALSE); DPRINT("Proc %X\n", Proc); /* Call the window procedure; notice kernel messages are always unicode. */ Result = CallWindowProcW(Proc, CallbackArgs->Wnd, WM_NCCREATE, 0, @@ -154,7 +154,7 @@ User32SendWINDOWPOSCHANGINGMessageForKernel(PVOID Arguments, ULONG ArgumentLengt DPRINT("Wrong length.\n"); return(STATUS_INFO_LENGTH_MISMATCH); } - Proc = (WNDPROC)GetWindowLongW(CallbackArgs->Wnd, GWL_WNDPROC); + Proc = (WNDPROC)NtUserGetWindowLong(CallbackArgs->Wnd, GWL_WNDPROC, FALSE); DPRINT("Proc %X\n", Proc); /* Call the window procedure; notice kernel messages are always unicode. */ Result = CallWindowProcW(Proc, CallbackArgs->Wnd, WM_WINDOWPOSCHANGING, 0, @@ -178,7 +178,7 @@ User32SendWINDOWPOSCHANGEDMessageForKernel(PVOID Arguments, ULONG ArgumentLength DPRINT("Wrong length.\n"); return(STATUS_INFO_LENGTH_MISMATCH); } - Proc = (WNDPROC)GetWindowLongW(CallbackArgs->Wnd, GWL_WNDPROC); + Proc = (WNDPROC)NtUserGetWindowLong(CallbackArgs->Wnd, GWL_WNDPROC, FALSE); DPRINT("Proc %X\n", Proc); /* Call the window procedure; notice kernel messages are always unicode. */ Result = CallWindowProcW(Proc, CallbackArgs->Wnd, WM_WINDOWPOSCHANGED, 0, @@ -202,7 +202,7 @@ User32SendSTYLECHANGINGMessageForKernel(PVOID Arguments, ULONG ArgumentLength) DPRINT("Wrong length.\n"); return(STATUS_INFO_LENGTH_MISMATCH); } - Proc = (WNDPROC)GetWindowLongW(CallbackArgs->Wnd, GWL_WNDPROC); + Proc = (WNDPROC)NtUserGetWindowLong(CallbackArgs->Wnd, GWL_WNDPROC, FALSE); DPRINT("Proc %X\n", Proc); /* Call the window procedure; notice kernel messages are always unicode. */ Result = CallWindowProcW(Proc, CallbackArgs->Wnd, WM_STYLECHANGING, CallbackArgs->WhichStyle, @@ -226,7 +226,7 @@ User32SendSTYLECHANGEDMessageForKernel(PVOID Arguments, ULONG ArgumentLength) DPRINT("Wrong length.\n"); return(STATUS_INFO_LENGTH_MISMATCH); } - Proc = (WNDPROC)GetWindowLongW(CallbackArgs->Wnd, GWL_WNDPROC); + Proc = (WNDPROC)NtUserGetWindowLong(CallbackArgs->Wnd, GWL_WNDPROC, FALSE); DPRINT("Proc %X\n", Proc); /* Call the window procedure; notice kernel messages are always unicode. */ Result = CallWindowProcW(Proc, CallbackArgs->Wnd, WM_STYLECHANGED, CallbackArgs->WhichStyle, @@ -266,7 +266,7 @@ User32CallWindowProcFromKernel(PVOID Arguments, ULONG ArgumentLength) } if (CallbackArgs->Proc == NULL) { - CallbackArgs->Proc = (WNDPROC)GetWindowLongW(CallbackArgs->Wnd, GWL_WNDPROC); + CallbackArgs->Proc = (WNDPROC)NtUserGetWindowLong(CallbackArgs->Wnd, GWL_WNDPROC, FALSE); } Result = CallWindowProcW(CallbackArgs->Proc, CallbackArgs->Wnd, CallbackArgs->Msg, CallbackArgs->wParam, @@ -330,18 +330,6 @@ NC_AdjustRectInner95 (LPRECT rect, DWORD style, DWORD exStyle) } -/* - * @implemented - */ -WINBOOL STDCALL -AdjustWindowRect(LPRECT lpRect, - DWORD dwStyle, - WINBOOL bMenu) -{ - return(AdjustWindowRectEx(lpRect, dwStyle, bMenu, 0)); -} - - /* * @implemented */ @@ -364,6 +352,18 @@ AdjustWindowRectEx(LPRECT lpRect, } +/* + * @implemented + */ +WINBOOL STDCALL +AdjustWindowRect(LPRECT lpRect, + DWORD dwStyle, + WINBOOL bMenu) +{ + return(AdjustWindowRectEx(lpRect, dwStyle, bMenu, 0)); +} + + /* * @unimplemented */ @@ -375,36 +375,6 @@ AllowSetForegroundWindow(DWORD dwProcessId) } -/* - * @implemented - */ -WINBOOL STDCALL -AnimateWindow(HWND hwnd, - DWORD dwTime, - DWORD dwFlags) -{ - /* FIXME Add animation code */ - - /* If trying to show/hide and it's already * - * shown/hidden or invalid window, fail with * - * invalid parameter */ - - BOOL visible; - visible = IsWindowVisible(hwnd); - if(!IsWindow(hwnd) || - (visible && !(dwFlags & AW_HIDE)) || - (!visible && (dwFlags & AW_HIDE))) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - ShowWindow(hwnd, (dwFlags & AW_HIDE) ? SW_HIDE : ((dwFlags & AW_ACTIVATE) ? SW_SHOW : SW_SHOWNA)); - - return TRUE; -} - - /* * @unimplemented */ @@ -788,6 +758,27 @@ EndDeferWindowPos(HDWP hWinPosInfo) } +/* + * @implemented + */ +HWND STDCALL +GetDesktopWindow(VOID) +{ + return NtUserGetDesktopWindow(); +} + + +/* + * @unimplemented + */ +HWND STDCALL +GetForegroundWindow(VOID) +{ + UNIMPLEMENTED; + return (HWND)0; +} + + WINBOOL STATIC User32EnumWindows ( @@ -913,18 +904,6 @@ EnumDesktopWindows( } -/* - * @implemented - */ -HWND STDCALL -FindWindowA(LPCSTR lpClassName, LPCSTR lpWindowName) -{ - //FIXME: FindWindow does not search children, but FindWindowEx does. - // what should we do about this? - return FindWindowExA (NULL, NULL, lpClassName, lpWindowName); -} - - /* * @unimplemented */ @@ -939,27 +918,6 @@ FindWindowExA(HWND hwndParent, } -/* - * @implemented - */ -HWND STDCALL -FindWindowW(LPCWSTR lpClassName, LPCWSTR lpWindowName) -{ - /* - - There was a FIXME here earlier, but I think it is just a documentation unclarity. - - FindWindow only searches top level windows. What they mean is that child - windows of other windows than the desktop can be searched. - FindWindowExW never does a recursive search. - - / Joakim - */ - - return FindWindowExW (NULL, NULL, lpClassName, lpWindowName); -} - - /* * @implemented */ @@ -991,6 +949,41 @@ FindWindowExW(HWND hwndParent, return NtUserFindWindowEx(hwndParent, hwndChildAfter, &ucClassName, &ucWindowName); } + +/* + * @implemented + */ +HWND STDCALL +FindWindowA(LPCSTR lpClassName, LPCSTR lpWindowName) +{ + //FIXME: FindWindow does not search children, but FindWindowEx does. + // what should we do about this? + return FindWindowExA (NULL, NULL, lpClassName, lpWindowName); +} + + +/* + * @implemented + */ +HWND STDCALL +FindWindowW(LPCWSTR lpClassName, LPCWSTR lpWindowName) +{ + /* + + There was a FIXME here earlier, but I think it is just a documentation unclarity. + + FindWindow only searches top level windows. What they mean is that child + windows of other windows than the desktop can be searched. + FindWindowExW never does a recursive search. + + / Joakim + */ + + return FindWindowExW (NULL, NULL, lpClassName, lpWindowName); +} + + + /* * @unimplemented */ @@ -1041,27 +1034,6 @@ GetClientRect(HWND hWnd, LPRECT lpRect) } -/* - * @implemented - */ -HWND STDCALL -GetDesktopWindow(VOID) -{ - return NtUserGetDesktopWindow(); -} - - -/* - * @unimplemented - */ -HWND STDCALL -GetForegroundWindow(VOID) -{ - UNIMPLEMENTED; - return (HWND)0; -} - - /* * @unimplemented */ @@ -1121,10 +1093,10 @@ GetTitleBarInfo(HWND hwnd, * @implemented */ HWND STDCALL -GetTopWindow(HWND hWnd) +GetWindow(HWND hWnd, + UINT uCmd) { - if (!hWnd) hWnd = GetDesktopWindow(); - return GetWindow( hWnd, GW_CHILD ); + return NtUserGetWindow(hWnd, uCmd); } @@ -1132,10 +1104,10 @@ GetTopWindow(HWND hWnd) * @implemented */ HWND STDCALL -GetWindow(HWND hWnd, - UINT uCmd) +GetTopWindow(HWND hWnd) { - return NtUserGetWindow(hWnd, uCmd); + if (!hWnd) hWnd = GetDesktopWindow(); + return GetWindow( hWnd, GW_CHILD ); } @@ -1376,6 +1348,36 @@ MoveWindow(HWND hWnd, } +/* + * @implemented + */ +WINBOOL STDCALL +AnimateWindow(HWND hwnd, + DWORD dwTime, + DWORD dwFlags) +{ + /* FIXME Add animation code */ + + /* If trying to show/hide and it's already * + * shown/hidden or invalid window, fail with * + * invalid parameter */ + + BOOL visible; + visible = IsWindowVisible(hwnd); +// if(!IsWindow(hwnd) || +// (visible && !(dwFlags & AW_HIDE)) || +// (!visible && (dwFlags & AW_HIDE))) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + +// ShowWindow(hwnd, (dwFlags & AW_HIDE) ? SW_HIDE : ((dwFlags & AW_ACTIVATE) ? SW_SHOW : SW_SHOWNA)); + + return TRUE; +} + + /* * @unimplemented */