[DUG] Is it a bug in latest version of Delphi?

Jolyon Smith jsmith at deltics.co.nz
Tue Feb 16 16:34:24 NZDT 2010


D2006, and *I* get 0, -1, -1... no error


> -----Original Message-----
> From: delphi-bounces at delphi.org.nz [mailto:delphi-
> bounces at delphi.org.nz] On Behalf Of Karl Reynolds
> Sent: Tuesday, 16 February 2010 4:16 p.m.
> To: NZ Borland Developers Group - Delphi List
> Subject: Re: [DUG] Is it a bug in latest version of Delphi?
> 
> On Tue, Feb 16, 2010 at 3:57 PM, Jolyon Smith <jsmith at deltics.co.nz>
> wrote:
> > Good luck with GetLastError().  There's nothing to indicate that
> > LB_GETITEMDATA processing will set a Windows "LastError".
> >
> > And empirically I would have to say that it doesn't:
> 
> Hmm... empirically I would have to say it does.
> 
> type
>   TIPRListBox = class(TListBox);
> 
> procedure TForm1.Button1Click(Sender: TObject);
> 
>   function GetValue(AListBox: TListBox; AIndex: Integer): Integer;
>   begin
>     Result := TIPRListBox(AListBox).GetItemData(AIndex);
>     if GetLastError <> 0 then RaiseLastOSError;
>   end;
> 
> begin
>   ListBox1.Items.AddObject('foo', TObject(0));
>   ListBox1.Items.AddObject('foo', TObject(-1));
>   ShowMessage(IntToStr(GetValue(ListBox1, 0)));
>   ShowMessage(IntToStr(GetValue(ListBox1, 1)));
>   ShowMessage(IntToStr(GetValue(ListBox1, 2)));
> end;
> 
> Tested results: 0, -1, <invalid index error>
> 
> I'm using D2006, and you?
> 
> Cheers,
> Karl
> _______________________________________________
> NZ Borland Developers Group - Delphi mailing list
> Post: delphi at delphi.org.nz
> Admin: http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email to delphi-request at delphi.org.nz with
> Subject: unsubscribe



More information about the Delphi mailing list