There was no change in the “Windows standard”. It’s a simple error in some poorly implemented error handling code added to the VCL at some point (subsequently fixed in combo boxes, but not listboxes – as of D2006).
You needn’t have waded through all the replies to find that the answer was provided. The answer came very quickly… what then followed was a great deal of pointless and diverting/misleading speculation as to other possible explanations that disregarded the fact that the answer was very quickly apparent from an inspection of the VCL source. FYI - Your “multiple by 2” solution worked because it transformed a stored value of “-1” into “-2”, which then avoided the collision between that value (-1) and the Windows “error” code and thus avoided the problem caused by the overly-helpful and incorrectly implemented error handling code in the VCL. From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On Behalf Of Rohit Gupta Sent: Wednesday, 24 February 2010 9:55 a.m. To: NZ Borland Developers Group - Delphi List Subject: Re: [DUG] Is it a bug in latest version of Delphi? - Solution Sinu, I dont know if its been answered satisfactorily. There are too many replies to wade through. I recall that along the way Windows standard changed from 0 being a null pointer to -1. I had to change some of my code in stringlist to work. I think my solution was to just multiply by 2 and then store it. Found my note - it happened in 2003. My conclusion now, is that its a combination of windows version/updates and version of Delphi that causes this issue. Rohit sinu sudhakaran wrote: Hi all, I came across a strange bug(???) in latest versions of Delphi. Have a look at the following code. procedure TForm1.Button1Click(Sender: TObject); var i : integer; begin ComboBox1.Clear; ComboBox1.Items.AddObject('All Locations', TObject(-1)); ComboBox1.Items.AddObject('Only this Location', TObject(0)); ComboBox1.Items.AddObject(Test Location', TObject(1)); i := Integer(ComboBox1.Items.Objects[0]); showmessage(inttostr(i)); end; 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 List index out of bounds error. Also I am getting -1 without any error when I tried this code in Delphi 3. Is it a bug in latest version of Delphi ? Any help is appreciated. Thank you Regards, Sinu <http://sigads.rediff.com/RealMedia/ads/click_nx.ads/www.rediffmail.com/signatureline....@middle?> Image removed by sender. _____ _______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe
<<~WRD000.jpg>>
_______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe