<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 10/24/2012 11:33, Christian Costa
wrote:<br>
</div>
<blockquote
cite="mid:CAMo6X8Z-zoP+gJKqiqJ8FUEqqV=4ipaRkoPQ68uzt+Ga1bU6Rg@mail.gmail.com"
type="cite"><br>
<br>
<div class="gmail_quote">2012/10/24 Dmitry Timoshkov <span
dir="ltr"><<a moz-do-not-send="true"
href="mailto:dmitry@baikal.ru" target="_blank">dmitry@baikal.ru</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">Christian Costa <<a moz-do-not-send="true"
href="mailto:titan.costa@gmail.com">titan.costa@gmail.com</a>>
wrote:<br>
<br>
> BOOL WINAPI ClientToScreen( HWND hwnd, LPPOINT lppnt )<br>
> {<br>
> + DWORD error = GetLastError();<br>
> +<br>
> + if (!hwnd)<br>
> + {<br>
> + SetLastError( ERROR_INVALID_WINDOW_HANDLE );<br>
> + return FALSE;<br>
> + }<br>
> +<br>
> + SetLastError( 0xdeadbeef );<br>
> MapWindowPoints( hwnd, 0, lppnt, 1 );<br>
> +<br>
> + if (GetLastError() != 0xdeadbeef)<br>
> + return FALSE;<br>
> +<br>
> + SetLastError(error);<br>
> return TRUE;<br>
> }<br>
<br>
</div>
As been said before these games with saving/restoring last
error value<br>
are broken.<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
</font></span></blockquote>
<div>Last time you said wrong so what do you mean by wrong or
broken?</div>
<div>The only way to know if MapWindowPoints fails is to set
last error first and check it</div>
<div>after. If I don't restore the previous value, the tests
will not pass. Of course I can</div>
<div>arrange the tests but hey. And I can check windows handle
here as Alexandre said.</div>
</div>
</blockquote>
If error reporting from MapWindowPoints is not sufficient to use it
somewhere else you can always move its guts to<br>
a separate function and report failure as you want. By the way, it
only fails on invalid window handles I guess, is that right?<br>
If you need this behaviour you have a failing WIN_GetPtr() in this
case. Messing with last error is not a solution obviously,<br>
and I don't see where MapWindowPoints even sets it.<br>
</body>
</html>