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"
%IDC_ListView = 500
Global hDlg,hConsole As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "ListView Test",300,300,350,150,%WS_SysMenu, 0 To hDlg
Control Add ListView, hDlg, %IDC_ListView, "", 10,10,175,125,, %WS_Ex_ClientEdge '225
ListView Set StyleXX hDlg, %IDC_ListView, %LVS_Ex_CheckBoxes Or %LVS_Ex_GridLines Or %LVS_Ex_FullRowSelect
ListView Insert Column hDlg, %IDC_ListView, 1, "test1", 175, 0
ListView Insert Item hDlg, %IDC_ListView, 1, 0, "one" 'row 1, col1
ListView Insert Item hDlg, %IDC_ListView, 2, 0, "two" 'row 2, col1
ListView Insert Item hDlg, %IDC_ListView, 3, 0, "three" 'row 3, col1
ListView Insert Item hDlg, %IDC_ListView, 4, 0, "four" 'row 4, col1
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Static OldRow, NewRow, iResult As Long, pNMLV As NMLISTVIEW Ptr
Select Case Cb.Msg
Case %WM_InitDialog
OldRow = 1
ListView Select hDlg, %IDC_ListView, OldRow
Case %WM_Notify
Select Case Cb.NmId
Case %IDC_ListView
Select Case Cb.NmCode
Case %LVN_ItemChanged
pNMLV = Cb.LParam
ListView Get Select hDlg, %IDC_ListView To NewRow
If NewRow Then 'item_changed fires 3 times before row is selected
If NewRow = OldRow Then
Dialog Set Text hDlg, "Checkbox changed in row " + Str$(@p
}{Item+1) + " " + Time$
Else
Dialog Set Text hDlg, "No checkbox change occurred!"
End If
End If
OldRow = NewRow
End Select
End Select
End Select
End Function
'ListView Select hDlg, %IDC_ListView, LastSel
'ListView_SetItemState hListView, LastSel-1, %LVIS_Focused, %LVIS_Focused '<--- keyboard synchronizing code
'gbs_01239
'Date: 05-11-2013
http://www.garybeene.com/sw/gbsnippets.htm