Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
With Me.ListView1
.DragIcon = LoadPicture("C:\Lavori_Vb6\HOTEL\IMG\" & "DRAGMOVE.CUR")
.Drag vbBeginDrag
End With
End If
End Sub
how to get the number of row index clicked on the listview?
Public Declare Function GetDesktopWindow Lib "user32" () As Long
Public Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
Public Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Const LOGPIXELSX = 88
Const LOGPIXELSY = 90
Public Function TwipsPerPixelX() As Integer
Dim MyDesktopWindowHandle As Long, MyDesktopWindowDeviceContext As Long
Dim MyWidthOfScreen As Long, MyUsedToReleaseDeviceContext As Long
'Get the handle of the desktop window
MyDesktopWindowHandle = GetDesktopWindow()
'Get the desktop window's device context
MyDesktopWindowDeviceContext = GetDC(MyDesktopWindowHandle)
'Get the width of the screen
MyWidthOfScreen = GetDeviceCaps(MyDesktopWindowDeviceContext, LOGPIXELSX)
'Release the device context
MyUsedToReleaseDeviceContext = ReleaseDC(MyDesktopWindowHandle, MyDesktopWindowDeviceContext)
TwipsPerPixelX = 1440 / MyWidthOfScreen '1 inch is always 1440 twips
End Function
Public Function TwipsPerPixelY() As Integer
Dim MyDesktopWindowHandle As Long, MyDesktopWindowDeviceContext As Long
Dim MyHeightOfScreen As Long, MyUsedToReleaseDeviceContext As Long
'Get the handle of the desktop window
MyDesktopWindowHandle = GetDesktopWindow()
'Get the desktop window's device context
MyDesktopWindowDeviceContext = GetDC(MyDesktopWindowHandle)
'Get the width of the screen
MyHeightOfScreen = GetDeviceCaps(MyDesktopWindowDeviceContext, LOGPIXELSY)
'Release the device context
MyUsedToReleaseDeviceContext = ReleaseDC(MyDesktopWindowHandle, MyDesktopWindowDeviceContext)
TwipsPerPixelY = 1440 / MyHeightOfScreen '1 inch is always 1440 twips
End Function
Private Sub ListView1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As stdole.OLE_XPOS_PIXELS, ByVal y As stdole.OLE_YPOS_PIXELS)
Dim itm As ListItem
If Button = vbLeftButton Then
With Me.ListView1
' Get the item the user clicked in
Set itm = .HitTest(x * TwipsPerPixelX, y * TwipsPerPixelY)
' Its row number is itm.Index
.DragIcon = LoadPicture("C:\Lavori_Vb6\HOTEL\IMG\" & "DRAGMOVE.CUR")
.Drag vbBeginDrag
End With
End If
End Sub
Public Declare Function GetDesktopWindow Lib "user32" () As Long
Public Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
Public Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Const LOGPIXELSX = 88
Const LOGPIXELSY = 90
Public Function TwipsPerPixelX() As Integer
Dim MyDesktopWindowHandle As Long, MyDesktopWindowDeviceContext As Long
Dim MyWidthOfScreen As Long, MyUsedToReleaseDeviceContext As Long
'Get the handle of the desktop window
MyDesktopWindowHandle = GetDesktopWindow()
'Get the desktop window's device context
MyDesktopWindowDeviceContext = GetDC(MyDesktopWindowHandle)
'Get the width of the screen
MyWidthOfScreen = GetDeviceCaps(MyDesktopWindowDeviceContext, LOGPIXELSX)
'Release the device context
MyUsedToReleaseDeviceContext = ReleaseDC(MyDesktopWindowHandle, MyDesktopWindowDeviceContext)
TwipsPerPixelX = 1440 / MyWidthOfScreen '1 inch is always 1440 twips
End Function
Public Function TwipsPerPixelY() As Integer
Dim MyDesktopWindowHandle As Long, MyDesktopWindowDeviceContext As Long
Dim MyHeightOfScreen As Long, MyUsedToReleaseDeviceContext As Long
'Get the handle of the desktop window
MyDesktopWindowHandle = GetDesktopWindow()
'Get the desktop window's device context
MyDesktopWindowDeviceContext = GetDC(MyDesktopWindowHandle)
'Get the width of the screen
MyHeightOfScreen = GetDeviceCaps(MyDesktopWindowDeviceContext, LOGPIXELSY)
'Release the device context
MyUsedToReleaseDeviceContext = ReleaseDC(MyDesktopWindowHandle, MyDesktopWindowDeviceContext)
TwipsPerPixelY = 1440 / MyHeightOfScreen '1 inch is always 1440 twips
End Function
Private Sub ListView1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As stdole.OLE_XPOS_PIXELS, ByVal y As stdole.OLE_YPOS_PIXELS)
Dim itm As ListItem
If Button = vbLeftButton Then
With Me.ListView1
' Get the item the user clicked in
Set itm = .HitTest(x * TwipsPerPixelX, y * TwipsPerPixelY)
' Its row number is itm.Index
.DragIcon = LoadPicture("C:\Lavori_Vb6\HOTEL\IMG\" & "DRAGMOVE.CUR")
.Drag vbBeginDrag
End With
End If
End Sub
With Me.ListView1
Set ITMX = .HitTest(x, y)
If Not ITMX Is Nothing Then
RM = ITMX.Index
.DragIcon = LoadPicture("C:\Lavori_Vb6\HOTEL\IMG\" & "DRAGMOVE.CUR")
.Drag vbBeginDrag
End If
End With
You do not have the required permissions to view the files attached to this post.
Bit late I know, but why are you trying to use an MS Forms declaration for the ListView MouseDown event rather than the VB6 declaration? The former will NOT work in VB6 - and is the cause of the compile-time error you are seeing.