Date: 02-16-2022
Return to Index
created by gbSnippets
'works with keyboard or mouse change
'The use of iResult is because LVN_ItemChanged is fired 3 times
'when a new row is selected - twice before selecting the new row
'(with nothing selected) and then finally when the new row is selected.
'Compilable Example: (Jose Includes)
#Compiler PBWin 10
#Compile Exe
#Dim All
%Unicode=1
#Include "win32api.inc"
%IDC_ListView = 500
Global hDlg As Dword 'main dialog handle
Function PBMain() As Long
Dialog New Pixels, 0, "ListView Test",300,300,200,140,%WS_OverlappedWindow To hDlg
Control Add ListView, hDlg, %IDC_ListView, "", 10,10,180,80
ListView Insert Column hDlg, %IDC_ListView, 1, "test1", 90, 0
ListView Insert Item hDlg, %IDC_ListView, 1, 0, "one" 'row,image
ListView Insert Item hDlg, %IDC_ListView, 2, 0, "two" 'row,image
ListView Insert Item hDlg, %IDC_ListView, 3, 0, "three" 'row,image
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local ChosenLine, iResult As Long
Select Case Cb.Msg
Case %WM_Notify
Select Case Cb.NmId
Case %IDC_ListView
Select Case Cb.NmCode
Case %NM_Click
ListView Get Select hDlg, %IDC_ListView To iResult
If iResult Then ChosenLine = iResult : Dialog Set Text hDlg, Str$(ChosenLine)
End Select
End Select
End Select
End Function
'gbs_01241
'Date: 05-11-2013
http://www.garybeene.com/sw/gbsnippets.htm