<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18876"></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=730014520-15022010><FONT color=#0000ff
size=2 face=Arial>I</FONT></SPAN><SPAN class=730014520-15022010><FONT
color=#0000ff size=2 face=Arial>t works as expected (i.e. displays -1) in Win32
D2007 for me in an otherwise empty VCL Forms application.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=730014520-15022010><FONT color=#0000ff
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=730014520-15022010><FONT color=#0000ff
size=2 face=Arial>Are you sure you have reproduced this exact code in a clean
app in D2007?</FONT></SPAN></DIV><BR>
<DIV dir=ltr lang=en-us class=OutlookMessageHeader align=left>
<HR tabIndex=-1>
</DIV>
<DIV dir=ltr lang=en-us class=OutlookMessageHeader align=left><FONT
face=Tahoma><FONT size=2><B>From:</B> delphi-bounces@delphi.org.nz
[mailto:delphi-bounces@delphi.org.nz] <B>On Behalf Of </B>sinu
sudhakaran<BR><SPAN class=730014520-15022010><FONT color=#0000ff
face=Arial> </FONT></SPAN></FONT></FONT></DIV>
<DIV dir=ltr lang=en-us class=OutlookMessageHeader align=left>I came across a
strange bug(???) in latest versions of Delphi.<BR><BR>Have a look at the
following code.<BR><BR>procedure TForm1.Button1Click(Sender:
TObject);<BR>var<BR>i :
integer;<BR>begin<BR>ComboBox1.Clear;<BR>ComboBox1.Items.AddObject('All
Locations', TObject(-1));<BR>ComboBox1.Items.AddObject('Only this Location',
TObject(0));<BR>ComboBox1.Items.AddObject(Test Location', TObject(1));<BR><BR>i
:=
Integer(ComboBox1.Items.Objects[0]);<BR>showmessage(inttostr(i));<BR>end;<BR><BR>When
I tried to run this code in Delphi 6 and Delphi 2007 , I am getting List Index
out of bounds[0] error in Showmessage. When I tried -2, -3, -4… instead of -1
object , I got the proper output without any <BR>List index out of bounds error.
Also I am getting -1 without any error when I tried this code in Delphi 3.
<BR><BR>Is it a bug in latest version of Delphi ? Any help is
appreciated.</DIV></BODY></HTML>