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 "richedit.inc"
#Include "CommCtrl.inc"
%IDC_ListView = 400
Global hDlg, hListView As Dword, SortDirection As Long
Function PBMain() As Long
Dialog New Pixels, 0, "ListView Line Color Test (NOT %LVS_OwnerData)",300,300,400,220, %WS_OverlappedWindow To hDlg
Control Add ListView, hDlg, %IDC_ListView,"", 10,10,380,200
Control Handle hDlg, %IDC_ListView To hListView
ListView Set StyleXX hDlg, %IDC_ListView, %LVS_Ex_CheckBoxes Or %LVS_Ex_GridLines Or %LVS_Ex_FullRowSelect
ListView Insert Column hDlg, %IDC_ListView, 1, "File Name", 100, 0
ListView Insert Column hDlg, %IDC_ListView, 2, "File Path", 400, 0
LoadListViewData
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
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
End Select
End Select
End Select
End Function
Sub LoadListViewData
Local i As Long
For i = 1 To 10
ListView Insert Item hDlg, %IDC_ListView, 10,0, "Row " + Chr$(64+i)
ListView Set Text hDlg, %IDC_ListView, i, 2, "Col2 " + "Row " + Format$(i,"00")
Next i
End Sub
'gbs_00993
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm