Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 10
#Compile Exe
#Dim All
%Unicode=1
#Include "win32api.inc"
#Resource Icon xbookmark "icons\bookmark.ico"
#Resource Icon xstop "icons\stop.ico"
Enum Equates Singular
IDC_ListView = 500
End Enum
Global hDlg, hListView, hImageListA, hImageListB As Dword, D() As String, z As WStringZ * 100
Function PBMain() As Long
Dialog New Pixels, 0, "Virtual ListView", , , 270,300, %WS_OverlappedWindow,, To hDlg
CreateListView
Dialog Show Modal hDlg, Call DlgProc
End Function
CallBack Function DlgProc
Local iRow As Long, pLVDI As LV_DISPINFOW Ptr, tempZ As WStringZ * %Max_Path
Select Case Cb.Msg
Case %WM_InitDialog
ReDim D(100)
For iRow = 0 To 100 : D(iRow) = "Line" + Str$(iRow) : Next iRow
ListView_SetItemCountEx(hListView, UBound(D)+1, %LVSICF_noInvalidateAll) 'max rows
Case %WM_Notify
Select Case Cb.NmId
Case %IDC_ListView
Select Case Cb.NmCode
Case %LVN_GetDispInfo
pLVDI = Cb.LParam
iRow = @pLVDI.item.iItem
Z = D(iRow)
If IsTrue (@plvdi.item.mask And %LVIF_Text) Then @pLVDI.item.pszText = VarPtr(Z)
If IsTrue (@plvdi.item.mask And %LVIF_Text) Then @pLVDI.item.pszText = VarPtr(Z)
If IsTrue (@plvdi.item.mask And %LVIF_Image) Then @pLVDI.item.iImage = 0 'main image
If IsTrue (@plvdi.item.mask And %LVIF_State) Then
@pLVDI.item.statemask =%LVIS_STATEIMAGEMASK
@pLVDI.item.state = IndextoStateImageMask(1)
End If
End Select
End Select
End Select
End Function
Sub CreateListView
Control Add ListView, hDlg, %IDC_ListView,"", 10,40,250,250, %WS_Child Or %LVS_Report Or %LVS_ShowSelAlways Or %WS_TabStop Or %LVS_SingleSel Or %LVS_OwnerData, %WS_Ex_ClientEdge
Control Handle hDlg, %IDC_ListView To hListView
ListView Insert Column hDlg, %IDC_Listview, 1, "ColA", 200,0 'set headers
ImageList New Icon 16,16,24,6 To hImageListA
ImageList Add Icon hImageListA, "xstop"
ImageList New Icon 16,16,24,6 To hImageListB
ImageList Add Icon hImageListB, "xbookmark"
ListView Set ImageList hDlg, %IDC_ListView, hImageListA, %lvsil_small
ListView Set ImageList hDlg, %IDC_ListView, hImageListB, %lvsil_state
End Sub
'gbs_01397
'Date: 10-17-2014
http://www.garybeene.com/sw/gbsnippets.htm