From 7fc61f6fea27d207706f896dbf47285516ebe760 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 14 Nov 2012 16:29:39 +0100 Subject: [PATCH] user32: Add some error checking in ScreenToClient and ClientToScreen. --- dlls/user32/winpos.c | 62 ++++++++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c index c620df91385..0ce3ddded71 100644 --- a/dlls/user32/winpos.c +++ b/dlls/user32/winpos.c @@ -235,26 +235,6 @@ BOOL WINAPI GetClientRect( HWND hwnd, LPRECT rect ) } -/******************************************************************* - * ClientToScreen (USER32.@) - */ -BOOL WINAPI ClientToScreen( HWND hwnd, LPPOINT lppnt ) -{ - MapWindowPoints( hwnd, 0, lppnt, 1 ); - return TRUE; -} - - -/******************************************************************* - * ScreenToClient (USER32.@) - */ -BOOL WINAPI ScreenToClient( HWND hwnd, LPPOINT lppnt ) -{ - MapWindowPoints( 0, hwnd, lppnt, 1 ); - return TRUE; -} - - /*********************************************************************** * list_children_from_point * @@ -588,6 +568,48 @@ INT WINAPI MapWindowPoints( HWND hwndFrom, HWND hwndTo, LPPOINT lppt, UINT count } +/******************************************************************* + * ClientToScreen (USER32.@) + */ +BOOL WINAPI ClientToScreen( HWND hwnd, LPPOINT lppnt ) +{ + POINT offset; + BOOL mirrored; + + if (!hwnd) + { + SetLastError( ERROR_INVALID_WINDOW_HANDLE ); + return FALSE; + } + if (!WINPOS_GetWinOffset( hwnd, 0, &mirrored, &offset )) return FALSE; + lppnt->x += offset.x; + lppnt->y += offset.y; + if (mirrored) lppnt->x = -lppnt->x; + return TRUE; +} + + +/******************************************************************* + * ScreenToClient (USER32.@) + */ +BOOL WINAPI ScreenToClient( HWND hwnd, LPPOINT lppnt ) +{ + POINT offset; + BOOL mirrored; + + if (!hwnd) + { + SetLastError( ERROR_INVALID_WINDOW_HANDLE ); + return FALSE; + } + if (!WINPOS_GetWinOffset( 0, hwnd, &mirrored, &offset )) return FALSE; + lppnt->x += offset.x; + lppnt->y += offset.y; + if (mirrored) lppnt->x = -lppnt->x; + return TRUE; +} + + /*********************************************************************** * IsIconic (USER32.@) */