The ListView control doesn't expose any property that lets you disable the dragging of its elements. To do so, you must trap the WM_NOTIFY message that the ListView control sends its parent form when the drag operation begins, and "eat" it. Using the MSGHOOK.DLL subclassing library it's easy to accomplish it: |
Click here to copy the following block |
Const WM_NOTIFY = &H4E Const LVN_FIRST = -100& Const LVN_BEGINDRAG = (LVN_FIRST - 9)
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As _ Any, source As Any, ByVal bytes As Long)
Private Type NMHDR hwndFrom As Long idFrom As Long code As Long End Type
Dim WithEvents FormHook As MsgHook
Private Sub Form_Load() Set FormHook = New MsgHook FormHook.StartSubclass Me
End Sub
Private Sub FormHook_BeforeMessage(uMsg As Long, wParam As Long, lParam As Long, _ retValue As Long, Cancel As Boolean) If uMsg = WM_NOTIFY Then Dim nmh As NMHDR CopyMemory nmh, ByVal lParam, Len(nmh)
If nmh.hwndFrom = ListView1.hWnd And nmh.code = LVN_BEGINDRAG Then retValue = 1 Cancel = True End If End If End Sub |
|