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
Function PBMain() As Long
Dialog New Pixels, 0, "ListView Test",300,300,200,200,%WS_OverlappedWindow, 0 To hDlg
CreateListview
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local LVHT As LVHitTestInfo, LVNT As NMItemActivate Ptr
Select Case Cb.Msg
Case %WM_Notify
Select Case Cb.NmId
Case %IDC_ListView
Select Case Cb.NmCode
Case %NM_Click
' GetCursorPos LVHT.pt
' ScreenToClient hListView, LVHT.pt
' Control Send hDlg, %IDC_ListView, %LVM_SubItemHitTest, 0, VarPtr(LVHT)
' Dialog Set Text hDlg, Str$(LVHT.iItem)
'or
LVNT = Cb.LParam
Dialog Set Text hDlg, Str$(@LVNT.iItem)
End Select
End Select
End Select
End Function
Sub CreateListView
Control Add ListView, hDlg, %IDC_ListView, "", 10,10,175,125, %WS_TabStop Or %WS_Border Or %LVS_Report
Control Handle hDlg, %IDC_ListView To hListView
ListView Insert Column hDlg, %IDC_ListView, 1, "test1", 125, 0
ListView Insert Item hDlg, %IDC_ListView, 1, 0, "000" 'row 1, col1
ListView Insert Item hDlg, %IDC_ListView, 2, 0, "111" 'row 2, col1
ListView Insert Item hDlg, %IDC_ListView, 3, 0, "222" 'row 1, col1
ListView Insert Item hDlg, %IDC_ListView, 4, 0, "333" 'row 2, col1
ListView Set StyleXX hDlg, 100, %LVS_Ex_GridLines Or %LVS_Ex_FullRowSelect
End Sub
'gbs_00789
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm