Using Hittest with more than one Listview Control

AlexanderBB

Well-known Member
Joined
Jul 1, 2009
Messages
2,092
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
VBA Code:
Private Type POINTAPI
    x As Long
    y As Long
End Type

Private Type LVHITTESTINFO
    pt As POINTAPI
    flags As Long
    iItem As Long
    iSubItem  As Long
End Type

Private Const LVM_SUBITEMHITTEST As Long = &H1039
Private Const LVHT_ONITEM        As Long = &HE

Private Declare Function SendMessage Lib "user32" Alias "SendMessageW" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Are there any considerations with using listviews together? Different names and Mouse down events but all using

VBA Code:
  Dim hitTest As LVHITTESTINFO
    With hitTest
        .flags = LVHT_ONITEM
        .pt.x = (x) ' \ Screen.TwipsPerPixelX)
        .pt.y = (y) ' \ Screen.TwipsPerPixelY)
    End With

    SendMessage NAME.hWnd, LVM_SUBITEMHITTEST, 0, hitTest
Under some circumstances I haven't fully tracked down yet, Hitest.iItem can incorrectly be -1 or >listitems.count
It is happening when moving items from one list into another. Perhaps on 2nd or Next time.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,224,505
Messages
6,179,153
Members
452,891
Latest member
JUSTOUTOFMYREACH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top