Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 10
#Compile Exe
#Dim All
#Include "win32api.inc"
%IDC_ListView = 400
Global hDlg, hListView As Dword, hCID, 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, %LVS_Report
Control Handle hDlg, %IDC_ListView To hListView
ListView Set StyleXX hDlg, %IDC_ListView, %LVS_Ex_GridLines Or %LVS_Ex_FullRowSelect
ListView Insert Column hDlg, %IDC_ListView, 1, "Col-A", 100, 0
ListView Insert Column hDlg, %IDC_ListView, 2, "Col-B", 250, 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
Local pHdr As NMHEADER Ptr, pHdi As HDITEM Ptr, pTf As HD_TEXTFILTER Ptr
Local hHeader As Dword
Local HdrStyle As Dword
Select Case Cb.Msg
Case %WM_InitDialog
' / enable filterbar
hHeader = ListView_GetHeader(GetDlgItem(CbHndl, %IDC_LISTVIEW))
hCID = GetDlgCtrlID(hHeader)
HdrStyle = GetWindowLong(hHeader, %GWL_STYLE)
SetWindowLong(hHeader, %GWL_STYLE, HdrStyle Or %HDS_FILTERBAR)
'SendMessage(hHeader, %HDM_SETFILTERCHANGETIMEOUT, 0, 500)
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 2
Case 0
@lplvcd.clrTextBk = &HE0FFFF 'item BG color
@lplvcd.clrText = %Red
End Select
Function = %CDRF_NEWFONT : Exit Function
End Select
End Select
Case hCID
Select Case Cb.NmCode
Case %HDN_BEGINFILTEREDIT : ? "1"
Case %HDN_ENDFILTEREDIT : ? "2"
Case %hdn_FilterBtnClick : ? "3"
Case %hdn_FilterChange : ? "4"
End Select
End Select
End Select
End Function
Sub LoadListViewData
Local i As Long
For i = 1 To 20
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_01457
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm