
Setting FullRowSelect on a ListView Control
Does anyone have any ideas on how to set the full row highlight for a
ListView Control ? According to MSDN the following code should work, but
I've had no luck.
Private Const LVM_FIRST = &H1000
Private Const LVM_GETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 55
Private Const LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 54
'
Private Const LVS_EX_GRIDLINES = &H1
Private Const LVS_EX_SUBITEMIMAGES = &H2
Private Const LVS_EX_CHECKBOXES = &H4
Private Const LVS_EX_TRACKSELECT = &H8
Private Const LVS_EX_HEADERDRAGDROP = &H10
Private Const LVS_EX_FULLROWSELECT = &H20 ' Applies to report mode only
Private Const LVS_EX_ONECLICKACTIVATE = &H40
Private Const LVS_EX_TWOCLICKACTIVATE = &H80
'
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hWnd As Long, wMsg As Long, wParam As Long, lParam As Long) As Long
'
Public Sub SetFullRowHighlight(ByRef oListView As ListView, Optional ByVal
FullRowOn As Variant)
If Not oListView.View = lvwReport Then Exit Sub
'
Dim dwExStyle As Long
'
If IsMissing(FullRowOn) Then FullRowOn = True
'
' Get the current style settings for the control
dwExStyle = SendMessage(oListView.hwnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0,
0)
'
' Reset the style settings so that fullrowselect style is modified
If FullRowOn = True Then
Call SendMessage(oListView.hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0,
dwExStyle Or LVS_EX_FULLROWSELECT)
Else
Call SendMessage(oListView.hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0,
dwExStyle Or Not LVS_EX_FULLROWSELECT)
End If
End Sub
If it is down to the version of the ComCtl32.dll or OCX these are what I
have got;
ComCtl32.dll Date : Saturday, 12 July, 1997
Version : 4.71.1008.3
ComCtl32.ocx Date : Saturday, 19 July, 1997 5:00:28 pm
Version : 5.01.4319