Results 1 to 4 of 4

Thread: GET ROW AND COLUMN INDEX in listview

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,580

    GET ROW AND COLUMN INDEX in listview

    Dubt...
    but this function really get row and column index from listview?
    Code:
    Private Declare Function SendMessage Lib _
    	"user32" Alias "SendMessageA" (ByVal hWnd As _
    	Long, ByVal wMsg As Long, ByVal wParam As _
    	Long, lParam As Any) As Long
    
    Private Const LVM_SUBITEMHITTEST As Long = 4153
    
    Private Type POINTAPI
    	X As Long
    	Y As Long
    End Type
    
    Private Type LVHITTESTINFO
    	pt As POINTAPI
    	lngFlags As Long
    	lngItem As Long
    	lngSubItem As Long
    End Type
    
    Private Sub ListView1_MouseMove(Button As Integer, _
    	Shift As Integer, X As Single, Y As Single)
    	Dim hti As LVHITTESTINFO
    	Dim lngRet As Long
    	hti.pt.X = X / Screen.TwipsPerPixelX
    	hti.pt.Y = Y / Screen.TwipsPerPixelY
    	lngRet = SendMessage(ListView1.hWnd, _
    		LVM_SUBITEMHITTEST, 0&, hti)
    	Debug.Print "Row=" & hti.lngItem,
    	Debug.Print "Col=" & hti.lngSubItem
    End Sub
    other way are welcome!
    Tks

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: GET ROW AND COLUMN INDEX in listview

    Use the MSHFlexgrid instead. I know many of the pirated copies of VB6 out there lack many of the best controls, but that's no excuse.

  3. #3
    Addicted Member
    Join Date
    Feb 2022
    Posts
    167

    Re: GET ROW AND COLUMN INDEX in listview

    Quote Originally Posted by dilettante View Post
    Use the MSHFlexgrid instead. I know many of the pirated copies of VB6 out there lack many of the best controls, but that's no excuse.
    The biggest problem with this approach is that it is not precise. You cannot determine exact column and rows with these x and y coordinates.

    However MSHFlexgrid is ugly. It's not a palatable UI. It produces ugly little Cro-Magnon dashes around the selected object. Use SendMessage to remove the grotesque lines? Why bother?

    The Listview is your UI friend. Love it, Learn it, Do it.

    Use Krool's Listview and be happy with Unicode support.

    If you decide to you must use MSHFlexgrid, use this one instead.

    Otherwise, use Excel and VBA to build your UI. It's obviously built for accountants, not everyday users.

    My .03 cents. Cheers Dil

  4. #4
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,652

    Re: GET ROW AND COLUMN INDEX in listview

    Quote Originally Posted by dilettante View Post
    Use the MSHFlexgrid instead. I know many of the pirated copies of VB6 out there lack many of the best controls, but that's no excuse.
    Recommending switching to an entirely different control with entirely different abilities, pros, and cons, just to avoid figuring out how to do a listview hit test right, something there's numerous examples of, is ridiculous.

    What if you want a simple view with standard Visual Styles? Now MSHFlexGrid made your life 1000x more difficult. It's overkill for the kinds of things people usually use a ListView for. Like telling someone who can't get something in their house to build a new house instead of turn the thing sideways.
    Last edited by fafalone; Aug 31st, 2023 at 11:37 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width