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, "gbSearch v1.0",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 LVData As NM_ListView
Select Case Cb.Msg
Case %WM_Notify
Select Case Cb.NmId
Case %IDC_ListView
Select Case Cb.NmCode
Case %LVN_ColumnClick
Type Set LVData = Cb.NmHdr$(SizeOf(LVData))
SortDirection = SortDirection Xor 1
If SortDirection Then
If LVData.iSubItem = 0 Then ListView Sort hDlg, %IDC_ListView, 1, Ascend
If LVData.iSubItem = 1 Then ListView Sort hDlg, %IDC_ListView, 2, Ascend
Else
If LVData.iSubItem = 0 Then ListView Sort hDlg, %IDC_ListView, 1, Descend
If LVData.iSubItem = 1 Then ListView Sort hDlg, %IDC_ListView, 2, Descend
End If
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_00987
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm