Article View: borland.public.cppbuilder.nativeapi
Article #16300Re: Prevent a user from checking a TListItem
From: Remy Lebeau (TeamB)
Date: Tue, 20 May 2003 20:42
Date: Tue, 20 May 2003 20:42
27 lines
2061 bytes
2061 bytes
"StarCinema - Rodolfo Frino" <starcinema@stargate.com> wrote in message
news:3eca8cff@newsgroups.borland.com...
> for (int i=0; i< ListView1->Items->Count; i++)
> ListView1->Items->Item[i]->Checked = false;
Rather than looping, which will be quite inefficient if there are a lot of
items in the list, you could just pass the X and Y values to
TListView::GetItemAt() to get the actual item being clicked on. You could
also hit-test the item first to determine whether the user is actually
clicking on the checkbox in the first place or just selecting the item in
general:
void __fastcall TForm1::ListView1MouseDown(TObject *Sender, TMouseButton
Button, TShiftState Shift, int X, int Y)
{
THitTests ht = ListView1->GetHitTestInfoAt(X, Y);
if( ht.Contains(htOnStateIcon) )
{
TListItem *Item = ListView1->GetItemAt(X, Y);
if( Item ) Item->Checked = false;
}
}
Gambit
Technical Details
Message-ID:
<3eca928b$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!64.152.100.70.MISMATCH!sjc70.webusenet.com!news.webusenet.com!cyclone.bc.net!news-hog.berkeley.edu!ucberkeley!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3eca8580@newsgroups.borland.com> <3eca8cff@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,a81cc7d506c46104 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-05-20 14:18:16 PST From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3eca8580@newsgroups.borland.com> <3eca8cff@newsgroups.borland.com> Subject: Re: Prevent a user from checking a TListItem Date: Tue, 20 May 2003 13:42:02 -0700 Lines: 29 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 207.175.226.26 Message-ID: <3eca928b$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1053463179 207.175.226.26 (20 May 2003 13:39:39 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!64.152.100.70.MISMATCH!sjc70.webusenet.com!news.webusenet.com!cyclone.bc.net!news-hog.berkeley.edu!ucberkeley!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail