Date: 02-16-2022
Return to Index
created by gbSnippets
'An online TreeView control tutorial may be found at:
'http://www.garybeene.com/power/pb-tutor-controls.htm
'Primary Code:
'Syntax: Control Add TreeView, hDlg, id&, txt$, x, y, xx, yy [, [style&] [, [exstyle&]]] [[,] Call CallBack]
Control Add TreeView, hDlg, 100, "", 10,10,130,125
'Compilable Example: (Jose Includes)
'The following compilable code demonstrates a dialog with a TreeView control.
'A resource file, imagelist, and display of images within the control is used.
'The Dialog CallBack response to selection of a TreeView item is demonstrated.
'Controls can also have a Callback function of their own.
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Resource "gbsnippets.pbr"
Global hDlg As Dword, hLst As Dword, hItem As Dword, hTemp As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "TreeView",200,200,155,150, %WS_SysMenu, 0 To hDlg
'create control
Control Add TreeView, hDlg, 100, "", 10,10,130,125
'create imagelist w,h,depth,size
ImageList New Icon 16,16,32,3 To hLst
ImageList Add Icon hLst, "x"
ImageList Add Icon hLst, "y"
ImageList Add Icon hLst, "z"
ImageList Add Icon hLst, "check"
'attach imagelist
TreeView Set ImageList hDlg, 100, hLst
'add items hdlg,id&,hPrnt,hIAftr,image&,selimage&,txt$ To hItem
TreeView Insert Item hDlg, 100, 0, %TVI_Last, 1,1,"One" To hItem
TreeView Insert Item hDlg, 100, hItem, %TVI_Last, 1,4,"One-1" To hTemp
TreeView Insert Item hDlg, 100, hItem, %TVI_Last, 2,4,"One-2" To hTemp
TreeView Insert Item hDlg, 100, 0, %TVI_Last, 2,2,"Two" To hItem
TreeView Insert Item hDlg, 100, hItem, %TVI_Last, 1,4,"Two-1" To hTemp
TreeView Insert Item hDlg, 100, hItem, %TVI_Last, 2,4,"Two-2" To hTemp
TreeView Insert Item hDlg, 100, 0, %TVI_Last, 3,3,"Three" To hItem
TreeView Insert Item hDlg, 100, hItem, %TVI_Last, 1,4,"Three-1" To hTemp
TreeView Insert Item hDlg, 100, hItem, %TVI_Last, 2,4,"Three-2" To hTemp
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
If CB.Msg = %WM_Notify AND CB.NmID = 100 AND CB.Nmcode = %TVN_SelChanged Then
Static i as Long
If i Then MsgBox "Selected!"
Incr i
End If
End Function
'gbs_00105
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm