Module: wine Branch: master Commit: 7fc61f6fea27d207706f896dbf47285516ebe760 URL: http://source.winehq.org/git/wine.git/?a=commit;h=7fc61f6fea27d207706f896dbf...
Author: Alexandre Julliard julliard@winehq.org Date: Wed Nov 14 16:29:39 2012 +0100
user32: Add some error checking in ScreenToClient and ClientToScreen.
---
dlls/user32/winpos.c | 62 +++++++++++++++++++++++++++++++++---------------- 1 files changed, 42 insertions(+), 20 deletions(-)
diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c index c620df9..0ce3ddd 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.@) */