I cant get my (albeit simple) test app to fail. ItemIndex does work too as you suggest.
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of John Sent: Wednesday, 23 July 2003 9:47 a.m. To: Multiple recipients of list delphi Subject: RE: [DUG]: TListbox Hi James, This looks great, however, I tried it and it fails at run time on line: ListBox1.Selected[i] := True; The error message is: "List index out of bounds [3]" This line needs to read: ListBox1.itemIndex := i; Thanks a lot anyway. John. > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Behalf Of James(Jim) Sugrue > Sent: Wednesday, 23 July 2003 08:25 > To: Multiple recipients of list delphi > Subject: RE: [DUG]: TListbox > > > Try this > > procedure TForm1.ListBox1MouseDown(Sender: TObject; Button: > TMouseButton; > Shift: TShiftState; X, Y: Integer); > var > i : Integer; > APoint : TPoint; > begin > APoint.X := X; > APoint.Y := Y; > if Button= mbRight then > begin > i := ListBox1.ItemAtPos(APoint, True); > if i > -1 then > begin > ListBox1.Selected[i] := True; > PopupMenu1.Popup(Mouse.CursorPos.X, Mouse.CursorPos.y); > end; { i > -1 } > end; { Button = mbRight } > end; > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On > Behalf Of John > Sent: Wednesday, 23 July 2003 8:03 a.m. > To: Multiple recipients of list delphi > Subject: [DUG]: TListbox > > Hi all, > > Does anybody know how to select an item from a TListbox with a > right-click, > at the same time as activating the popUpMenu? > > TIA, > > John > > ------------------------------------------------------------------------ > --- > New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] > Website: http://www.delphi.org.nz > To UnSub, send email to: [EMAIL PROTECTED] > with body of "unsubscribe delphi" > Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/ > > --- > Incoming mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.502 / Virus Database: 300 - Release Date: 18/07/2003 > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.502 / Virus Database: 300 - Release Date: 18/07/2003 > > > ------------------------------------------------------------------ > --------- > New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] > Website: http://www.delphi.org.nz > To UnSub, send email to: [EMAIL PROTECTED] > with body of "unsubscribe delphi" > Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/ > ------------------------------------------------------------------------ --- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz To UnSub, send email to: [EMAIL PROTECTED] with body of "unsubscribe delphi" Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/ --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.502 / Virus Database: 300 - Release Date: 18/07/2003 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.502 / Virus Database: 300 - Release Date: 18/07/2003 --------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz To UnSub, send email to: [EMAIL PROTECTED] with body of "unsubscribe delphi" Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
