i tested getlasterror also and it does not fail when an invalid index is returned. <div><br></div><div>As i mentioned earlier.. index[99] will not fail.. you just get -1 :D</div><div><br></div><div>pre-testing the range is the only bypass. or.. just store your data in a structure thats kinder to -1 :)<br>
<br><div class="gmail_quote">On Tue, Feb 16, 2010 at 3:57 PM, Jolyon Smith <span dir="ltr"><<a href="mailto:jsmith@deltics.co.nz">jsmith@deltics.co.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Good luck with GetLastError(). There's nothing to indicate that<br>
LB_GETITEMDATA processing will set a Windows "LastError".<br>
<br>
And empirically I would have to say that it doesn't:<br>
<br>
// On an empty Listbox1 ..<br>
<br>
r := SendMessage(Listbox1.Handle, LB_GETITEMDATA, 100, 0);<br>
<div class="im"> if GetLastError <> 0 then<br>
RaiseLastOSError;<br>
<br>
</div> if r = -1 then<br>
ShowMessage('oops');<br>
<br>
<br>
Will yield only the "oops" message, no OS error.<br>
<br>
I am speculating (in this case I don't have the source for SendMessage() or<br>
the LISTBOX wndproc) that SendMessage() isn't setting an error condition<br>
(after all it is successfully sending a message and returning the result)<br>
and that the LISTBOX wndproc doesn't SetLastError() when processing<br>
LB_GETITEMDATA, at least not for an invalid item index.<br>
<div class="im"><br>
<br>
<br>
> -----Original Message-----<br>
> From: <a href="mailto:delphi-bounces@delphi.org.nz">delphi-bounces@delphi.org.nz</a> [mailto:<a href="mailto:delphi-">delphi-</a><br>
</div><div class="im">> <a href="mailto:bounces@delphi.org.nz">bounces@delphi.org.nz</a>] On Behalf Of Karl Reynolds<br>
> Sent: Tuesday, 16 February 2010 3:29 p.m.<br>
> To: NZ Borland Developers Group - Delphi List<br>
> Subject: Re: [DUG] Is it a bug in latest version of Delphi?<br>
><br>
</div><div><div></div><div class="h5">> On Tue, Feb 16, 2010 at 3:06 PM, Jolyon Smith <<a href="mailto:jsmith@deltics.co.nz">jsmith@deltics.co.nz</a>><br>
> wrote:<br>
> > Win API returns -1 to indicate “an error”. Any error. Not a<br>
> specific<br>
> > error. Certainly not specifically a list index error.<br>
><br>
> Pardon me for being pedantic, but while I agree with everything else<br>
> you said, I feel the need to reiterate that -1 isn't actually returned<br>
> to *indicate* an error (and you mentioned the conflict between an<br>
> error result and a valid result yourself at one point). It's just the<br>
> value returned when an error has occured. And yes, that means the VCL<br>
> code is wrong.<br>
><br>
> GetLastError... I won't say it again, promise. ;)<br>
><br>
> Cheers,<br>
> Karl<br>
><br>
> _______________________________________________<br>
> NZ Borland Developers Group - Delphi mailing list<br>
> Post: <a href="mailto:delphi@delphi.org.nz">delphi@delphi.org.nz</a><br>
> Admin: <a href="http://delphi.org.nz/mailman/listinfo/delphi" target="_blank">http://delphi.org.nz/mailman/listinfo/delphi</a><br>
> Unsubscribe: send an email to <a href="mailto:delphi-request@delphi.org.nz">delphi-request@delphi.org.nz</a> with<br>
> Subject: unsubscribe<br>
<br>
<br>
_______________________________________________<br>
NZ Borland Developers Group - Delphi mailing list<br>
Post: <a href="mailto:delphi@delphi.org.nz">delphi@delphi.org.nz</a><br>
Admin: <a href="http://delphi.org.nz/mailman/listinfo/delphi" target="_blank">http://delphi.org.nz/mailman/listinfo/delphi</a><br>
Unsubscribe: send an email to <a href="mailto:delphi-request@delphi.org.nz">delphi-request@delphi.org.nz</a> with Subject: unsubscribe<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Kyley Harris<br>Harris Software<br>+64-21-671-821<br>
</div>