Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 10
#Compile Exe
#Dim All
%Unicode=1
#Include "win32api.inc"
#Resource Manifest, 1, "xptheme.xml"
#Resource Icon, xtop "top.ico"
#Resource Icon, xmid "mid.ico"
#Resource Icon, xbottom "bottom.ico"
#Resource Icon, xempty "empty.ico"
%IDC_Checks = 500
%IDC_Drawings = 501
%IDC_ListView = 502
Global hDlg,hListView,hImgListFull,hImgListEmpty As Dword
Global CheckBoxes, Drawings As Long
Function PBMain() As Long
Dialog New Pixels, 0, "ListView Test",300,300,200,130,%WS_OverlappedWindow To hDlg
Control Add CheckBox, hDlg, %IDC_Checks, "CheckBoxes", 10,10,75,20
Control Set Check hDlg, %IDC_Checks, %True
Control Add CheckBox, hDlg, %IDC_Drawings, "Line Drawings", 95,10,100,20
Control Set Check hDlg, %IDC_Drawings, %True
CreateListView
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Select Case Cb.Msg
Case %WM_Command
Select Case Cb.Ctl
Case %IDC_Checks
Control Get Check hDlg, %IDC_Checks To CheckBoxes
ListView Set StyleXX hDlg, %IDC_ListView, IIf(CheckBoxes, %LVS_Ex_CheckBoxes, 0)
Case %IDC_Drawings
Control Get Check hDlg, %IDC_Drawings To Drawings
'line drawing
If Drawings Then
ListView Set ImageList hDlg, %IDC_ListView, hImgListFull, %lvsil_small
Else
ListView Set ImageList hDlg, %IDC_ListView, hImgListEmpty, %lvsil_small
End If
End Select
End Select
End Function
Sub CreateListView
Control Add ListView, hDlg, %IDC_ListView, "", 10,40,180,135
Control Handle hDlg, %IDC_ListView To hListView
ListView Set StyleXX hDlg, %IDC_ListView, %LVS_Ex_GridLines Or %LVS_Ex_CheckBoxes
ImageList New Icon 1,16,24,3 To hImgListEmpty
ImageList New Icon 16,16,24,3 To hImgListFull
ImageList Add Icon hImgListFull, "xtop" '<--- 16x16 icons
ImageList Add Icon hImgListFull, "xmid"
ImageList Add Icon hImgListFull, "xbottom"
ListView Insert Column hDlg, %IDC_ListView, 1, "Data", 180, 0
ListView Insert Item hDlg, %IDC_ListView, 1, 1, "Group 1 - Line 1"
ListView Insert Item hDlg, %IDC_ListView, 2, 2, "Group 1 - Line 2"
ListView Insert Item hDlg, %IDC_ListView, 3, 3, "Group 1 - Line 3"
ListView Set ImageList hDlg, %IDC_ListView, hImgListFull, %lvsil_small
ListView Set Image hDlg, %IDC_ListView, 1, 1
ListView Set Image hDlg, %IDC_ListView, 2, 2
ListView Set Image hDlg, %IDC_ListView, 3, 3
End Sub
'gbs_01250
'Date: 05-11-2013
http://www.garybeene.com/sw/gbsnippets.htm