Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "win32api.inc"
#Include "commctrl.inc"
%IDC_ListView = 500
Global hDlg, hListView As Dword, D() As String 'will put ListView data in D()
Function PBMain() As Long
Local i,j As Long
ReDim D(1000,10)
For i = 0 To 1000 : For j = 0 To 10 : D(i,j) = "Col" + Str$(j) + " - Row" + Str$(i) : Next j : Next i 'sample data
Dialog New Pixels, 0, "Virtual ListView", , , 450,220, %WS_SysMenu,, To hDlg
Control Add ListView, hDlg, %IDC_ListView, "", 0, 0, 450,220, %WS_Child Or %WS_TabStop Or %WS_Visible Or %LVS_ShowSelAlways Or %LVS_Report Or %LVS_OwnerData
Control Handle hDlg, %IDC_ListView To hListView 'handle to ListView
For i = 1 To 11
ListView Insert Column hDlg, %IDC_Listview, i, "Col" + Str$(i), 115,0 'set headers
Next i
ListView_SetItemCountEx(hListView, 1000, %LVSICF_noInvalidateAll) 'max rows
Dialog Show Modal hDlg, Call CBProc
End Function
CallBack Function CBProc
Local col, row As Long, pLVDI As LV_DISPINFO Ptr, lplvcd As NMLVCUSTOMDRAW Ptr
Select Case Cb.Msg
Case %WM_Notify
Select Case Cb.NmId
Case %IDC_ListView
Select Case Cb.NmCode
Case %NM_CustomDraw
lplvcd = Cb.LParam
Select Case @lplvcd.nmcd.dwDrawStage
Case %CDDS_PrePaint
Function = %CDRF_NOTIFYITEMDRAW : Exit Function
Case %CDDS_ItemPrePaint
Select Case @lplvcd.nmcd.dwItemSpec Mod 6
Case 3,4,5
@lplvcd.clrTextBk = %rgb_PaleTurquoise 'item BG color
@lplvcd.clrText = %Red
End Select
Function = %CDRF_NEWFONT : Exit Function 'change item/subitem BG colors
End Select
Case %LVN_GetDispInfo 'notification to ask for data
pLVDI = Cb.LParam 'pointer to LVDISPINFO structure for requested subitem
row = @pLVDI.item.iItem 'row being asked for
col = @pLVDI.item.iSubItem 'sub item being asked for (columns)
@pLVDI.item.pszText = StrPtr(D(row,col)) 'text sent to ListView
End Select
End Select
End Select
End Function
'gbs_01039
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm