Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1449

[VB6, Win7+] Undocumented ListView Feature: Multiselect in first column like Explorer

$
0
0
Name:  exsel.jpg
Views: 15
Size:  35.6 KB

Undocumented ListView Features : Part 5 - Explorer-style selection
See Also: Part 1 - Footer Items | Part 2 - Subsetted Groups | Part 3 - Groups With Virtual Mode | Part 4 - Column Backcolor

In Windows Explorer, when you're in Details View, you can start a selection marquee in the first column. However in a ListView, even set to Explorer Style, dragging anywhere in the column starts a dragdrop operation (or does nothing if DD is disabled). It's possible to enable the multiselection marquee when dragging in the first column whitespace like Explorer using the undocumented IListView interface's SetSelectionFlags call. There's no LVM_ message, so the only downside is a TLB is required.

Requirements
Windows 7 or newer - While Vista does have an IListView interface available under a different GUID, this call seems not to work.
oleexp.tlb v4.42 or higher (Recommended) or the deprecated lvundoc.tlb
oleexp Add-on mIID.bas (included in oleexp download) - If you want to use the old lvundoc.tlb, you can supply your own definition of IID_IListView.


First of all, obviously this is only applicable to Details View with Multiselect enabled, and this only applies to a ListView with Explorer Style enabled,
Code:

SetWindowTheme hWnd, StrPtr("explorer"), 0&
Once your ListView is set up, here's what you need:

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 Sub LVSetExplSel(hwndLV As Long, bOn As Boolean)
Dim pILV As oleexp.IListView

SendMessage hwndLV, LVM_QUERYINTERFACE, VarPtr(IID_IListView), pILV
If (pILV Is Nothing) = False Then
    pILV.SetSelectionFlags 1&, iif(bOn, 1&, 0&)
Else
    Debug.Print "LVSetExplSel::Failed to get IListView"
End If

End Sub

It can be toggled on and off, use bOn = True to turn it on.
Attached Images
 

Viewing all articles
Browse latest Browse all 1449

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>