Date: 02-16-2022
Return to Index
created by gbSnippets
'This sample TreeView code shows how to change some of the style
'values at run time.
'Primary Code:
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
#Include "commctrl.inc"
%IDC_TreeView = 100 : %IDC_ButtonA = 200 : %IDC_ButtonB = 300
Global hDlg, hTree As DWord
Function PBMain() As Long
Local hItem As DWord, hTemp As DWord, hTemp2 As DWord, hTemp3 As DWord
Dialog New Pixels, 0, "TreeView",200,200,155,290, %WS_SysMenu, 0 To hDlg
Control Add TreeView, hDlg, %IDC_TreeView, "", 10,10,130,200
Control Handle hDlg, %IDC_TreeView To hTree
Control Add Button, hDlg, %IDC_ButtonA,"Add Styles", 25,220,95,20
Control Add Button, hDlg, %IDC_ButtonB,"Remove Styles", 25,250,95,20
TreeView Insert Item hDlg, %IDC_TreeView, 0, %TVI_Last, 0,0,"Root" To hItem
TreeView Insert Item hDlg, %IDC_TreeView, hItem, %TVI_Last, 0,0,"Mother" To hTemp
TreeView Insert Item hDlg, %IDC_TreeView, hTemp, %TVI_Last, 0,0,"Dan" To hTemp2
TreeView Insert Item hDlg, %IDC_TreeView, hTemp, %TVI_Last, 0,0,"Bob" To hTemp3
TreeView Set Expanded hDlg, %IDC_TreeView, hTemp, %True
TreeView Insert Item hDlg, %IDC_TreeView, hTemp3, %TVI_Last, 0,0,"Foot" To hTemp2
TreeView Insert Item hDlg, %IDC_TreeView, hTemp3, %TVI_Last, 0,0,"Arm" To hTemp2
TreeView Set Expanded hDlg, %IDC_TreeView, hTemp3, %True
TreeView Insert Item hDlg, %IDC_TreeView, hItem, %TVI_Last, 0,0,"Father" To hTemp
TreeView Insert Item hDlg, %IDC_TreeView, hTemp, %TVI_Last, 0,0,"Helen" To hTemp2
TreeView Insert Item hDlg, %IDC_TreeView, hTemp, %TVI_Last, 0,0,"Any" To hTemp3
TreeView Set Expanded hDlg, %IDC_TreeView, hTemp, %True
TreeView Insert Item hDlg, %IDC_TreeView, hTemp3, %TVI_Last, 0,0,"Leg" To hTemp2
TreeView Insert Item hDlg, %IDC_TreeView, hTemp3, %TVI_Last, 0,0,"Finger" To hTemp2
TreeView Set Expanded hDlg, %IDC_TreeView, hTemp3, %True
TreeView Set Expanded hDlg, %IDC_TreeView, hItem, %True
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local hNode As DWord, Style&
If CB.Msg = %WM_Command AND CB.Ctl = %IDC_ButtonA Then
Style&=GetWindowLong(hTree, %GWL_STYLE)
Style&=Style& Or %TVS_TrackSelect
SetWindowLong hTree, %GWL_STYLE, Style&
End If
If CB.Msg = %WM_Command AND CB.Ctl = %IDC_ButtonB Then
Style&=GetWindowLong(hTree, %GWL_STYLE)
Style&=Style& AND (Not %TVS_TrackSelect)
SetWindowLong hTree, %GWL_STYLE, Style&
End If
End Function
'gbs_00687
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm