Solved

THittest when double-clicking item in TListView not working right...

Posted on 2014-07-17
2
237 Views
Last Modified: 2014-07-20
Hi Experts, I'm trying to detect what item is double-clicked on in my TListView. Googling around, I found code from Mr. Zarko Gajic explaining exactly how to do that:

http://delphi.about.com/od/vclusing/a/lv_item_click.htm

First off, it wouldn't compile correctly on this line:

for ht in hts do

... saying "For loop control variable must be simple local variable". So I just got rid of that section of code, seeing as how it's just a "debug" section anyhow.
   The problem lies in the statement:

if hts <= [htOnIcon, htOnItem, htOnLabel, htOnStateIcon] then

... it never seems to get satisfied - no matter where I double-click in my TListView items. Variable "hts" *always* seems to have the value :

[htAbove, htOnStateIcon,,htToLeft]

... and therefore never satisfies the IF statement. Backtracking a bit in the code, I assume hts is getting bad values because of what it gets fed by ListViewCursosPos.X and ListViewCursosPos.Y. ListViewCursosPos.X seems to have a value of -38 (minus 38) and ListViewCursosPos.Y has a value of -335. That can't be right. Backtracking further from that, the ListView1.ScreenToClient procedure must be feeding it bad values. Anyone have any idea what's going on?

Thanks!
    Shawn
0
Comment
Question by:shawn857
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 27

Accepted Solution

by:
Sinisa Vuk earned 500 total points
ID: 40203963
in yours another question ... I use simple:
var
  itm: TListItem;
begin
  itm := ListView1.Selected;
  if Assigned(itm) then
    ExchangeItems(ListView1, itm.Index);

Open in new window



...add: rowselect is set to True.
0
 

Author Closing Comment

by:shawn857
ID: 40207558
Thank you very much Sinisa!

Shawn
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question