Solved

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

Posted on 2014-07-17
2
227 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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

772 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