<br><br><div class="gmail_quote">2012/10/24 Nikolay Sivov <span dir="ltr"><<a href="mailto:bunglehead@gmail.com" target="_blank">bunglehead@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"><div><div class="h5">
<div>On 10/24/2012 11:33, Christian Costa
wrote:<br>
</div>
<blockquote type="cite"><br>
<br>
<div class="gmail_quote">2012/10/24 Dmitry Timoshkov <span dir="ltr"><<a 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>Christian Costa <<a href="mailto:titan.costa@gmail.com" target="_blank">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><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></div></div>
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>
</div>
<br>
<br></blockquote></div>Sounds good. I'll do that. Basically WINPOS_GetWinOffset get most part the job in our case and I already modified it to return an error.<div>Yes it fails only for invalid handles. WIN_GetPtr is not enough because it just return WND_OTHER_PROCESS to call the server to ask</div>
<div>if it exists on another process. It's what IsWindow does (and�WINPOS_GetWinOffset).</div><div>MapWindowPoints can fail (see test). MSDN says to call SetLastError first before calling it and read the value.</div><div>
I will send a patch using�WINPOS_GetWinOffset. Thanks.</div>