The TreeView control which ships with ODE doesn't have a FullRowSelect
property like it's VB6 cousin. The FullRowSelect property allows you to specify if
the entire row of the selected item is highlighted and clicking anywhere on an item's row
causes it to be selected.
By using SetWindowLong API function, we can specify an additional
style for the TreeView control, namely TVS_FULLROWSELECT, which gives us the same
functionality as FullRowSelect.
Here are two functions to set and clear this style for a TreeView
control.
Private Const TVS_FULLROWSELECT = &H1000
Private Const GWL_STYLE = (-16)
Private Declare Function apiGetWindowLong Lib "user32" _
Alias "GetWindowLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long) _
As Long
Private Declare Function apiSetWindowLong Lib "user32" _
Alias "SetWindowLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) _
As Long
Function fTvwFullRowSelect(tvw As Control) As Boolean
Dim lngStyle As Long
lngStyle = apiGetWindowLong(tvw.hWnd, GWL_STYLE)
lngStyle = lngStyle Or TVS_FULLROWSELECT
fTvwFullRowSelect = (Not apiSetWindowLong(tvw.hWnd, _
GWL_STYLE, lngStyle) = 0)
End Function
Function fResetTvwFullRowSelect(tvw As Control) As Boolean
Dim lngStyle As Long
lngStyle = apiGetWindowLong(tvw.hWnd, GWL_STYLE)
lngStyle = lngStyle And Not TVS_FULLROWSELECT
fResetTvwFullRowSelect = (Not apiSetWindowLong(tvw.hWnd, _
GWL_STYLE, lngStyle) = 0)
End Function
|