Solved

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

Posted on 2014-07-17
2
228 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
2 Comments
 
LVL 26

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

856 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