Solved

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

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

Accepted Solution

by:
Sinisa Vuk earned 500 total points
Comment Utility
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
Comment Utility
Thank you very much Sinisa!

Shawn
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now