On Tue, Feb 16, 2010 at 11:55 AM, Jolyon Smith <[email protected]> wrote:
> function ListBoxGetObject(const aListBox: TListBox; const aIndex: Integer):
> TObject;
> begin
>  if (aIndex < 0) or (aIndex >= aListBox.Items.Count) then
>    TStringsHelper(aListBox.Items).Error(SListIndexError, aIndex);
>
>  result := TObject(TListBoxHelper(aListBox).GetItemData(aIndex));
> end;

You should still allow for other funky errors occurring, like out of
memory. So I would throw an extra line at the end:

  if GetLastError <> 0 then RaiseLastOSError;

And then if you do that, I could argue that it's excessive to check
for the bounds explicitly beforehand, since windows does that
internally anyway. It really comes down to whether you like the OS
error message or not.

Cheers,
Karl
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: [email protected]
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to [email protected] with Subject: 
unsubscribe

Reply via email to