#include once "window9.bi"

Function AddTreeViewItem OverLoad(ByVal gadget As Integer, ByVal string_ As String,ByVal IDImage_0 As HBITMAP,ByVal IDImage_Selected As HBITMAP,ByVal pos_ As integer,ByVal parent As Integer) As Integer Export
  dim tvis as TVINSERTSTRUCT
  dim iList as HIMAGELIST = Cast(HIMAGELIST,GetHimageCombo_(gadget))
  Dim As Integer ppoos =ImageList_Add(iList,IDImage_0       ,0)
  Dim As Integer ppoos1=ImageList_Add(iList,IDImage_Selected,0)
  tvis.Item.Mask           = TVIF_TEXT or TVIF_IMAGE or TVIF_SELECTEDIMAGE 
  tvis.item.pszText        = strptr(string_) 
  tvis.item.cchTextMax     = len(string_) 
  tvis.item.iImage         = ppoos
  tvis.item.iSelectedImage = ppoos1 
  tvis.hInsertAfter        = Cast(HTREEITEM,pos_)
  tvis.hParent             = Cast(HTREEITEM,parent) 
  Var  hPrev               = TreeView_InsertItem(GadgetID(gadget), @tvis )
  DeleteObject(Cast(HGDIOBJ,ppoos)):DeleteObject(Cast(HGDIOBJ,ppoos1))
	Return Cast(Integer,hPrev)
End Function

Function AddTreeViewItem(ByVal gadget As Integer, ByVal string_ As String,ByVal IDImage_0 As HICON,ByVal IDImage_Selected As HICON,ByVal pos_ As integer,ByVal parent As Integer) As Integer Export
  dim tvis as TVINSERTSTRUCT
  dim iList as HIMAGELIST = Cast(HIMAGELIST,GetHimageCombo_(gadget))
  Dim As Integer ppoos =ImageList_AddIcon(iList,IDImage_0)
  Dim As Integer ppoos1=ImageList_AddIcon(iList,IDImage_Selected)
  tvis.Item.Mask           = TVIF_TEXT or TVIF_IMAGE or TVIF_SELECTEDIMAGE 
  tvis.item.pszText        = strptr(string_) 
  tvis.item.cchTextMax     = len(string_) 
  tvis.item.iImage         = ppoos
  tvis.item.iSelectedImage = ppoos1 
  tvis.hInsertAfter        = Cast(HTREEITEM,pos_)
  tvis.hParent             = Cast(HTREEITEM,parent) 
  Var  hPrev               = TreeView_InsertItem(GadgetID(gadget), @tvis )
  DeleteObject(Cast(HGDIOBJ,ppoos)):DeleteObject(Cast(HGDIOBJ,ppoos1))
	Return Cast(Integer,hPrev)
End Function