Date: 02-16-2022
Return to Index
created by gbSnippets
'Credit: Dave Biggs
'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_Label = 200
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",,,155,220, %WS_SysMenu, 0 To hDlg
Control Add Label, hDlg, %IDC_Label, "", 10,10,130,200
Control Add Treeview, hDlg, %IDC_TreeView, "", 10,40,130,200, %TVS_EditLabels
Control Handle hDlg, %IDC_TreeView To hTree
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, hItem, %TVI_Last, 0,0,"Father" To hTemp
Treeview Insert Item hDlg, %IDC_TreeView, hItem, %TVI_Last, 0,0,"Hothead" To hTemp
Treeview Insert Item hDlg, %IDC_TreeView, hItem, %TVI_Last, 0,0,"Cow" To hTemp
Treeview Insert Item hDlg, %IDC_TreeView, hItem, %TVI_Last, 0,0,"Sister" To hTemp
Treeview Insert Item hDlg, %IDC_TreeView, hItem, %TVI_Last, 0,0,"Hotel" To hTemp
Treeview Insert Item hDlg, %IDC_TreeView, hItem, %TVI_Last, 0,0,"Coward" To hTemp
Treeview Set Expanded hDlg, %IDC_TreeView, hItem, %True
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local SearchTerm As AsciiZ * 256, iResult As Long, pNMTVK As NMTVKEYDOWN Ptr
Select Case Cb.Msg
Case %WM_User + 1000
iResult = TreeView_GetISearchString(hTree, SearchTerm)
'highlight only the matching letters
Control Set Text hDlg, %IDC_Label, SearchTerm
Control ReDraw hDlg, %IDC_TreeView
Case %WM_Notify
Select Case Cb.NmId
Case %IDC_TreeView
Select Case Cb.NmCode
Case %TVN_KeyDown
pNMTVK = Cb.LParam
PostMessage Cb.Hndl, %WM_User + 1000, 0, @pNMTVK.wVKey
End Select
End Select
End Select
End Function
'gbs_01167
'Date: 03-25-2
http://www.garybeene.com/sw/gbsnippets.htm