#include once "window9.bi"

Sub ReplaceImageItemTreeView OverLoad(ByVal gadget As Integer, _
									ByVal item As Integer, _
									ByVal image As Hbitmap, _
									ByVal Selectimage As Hbitmap) Export
	Dim TV_ITEM_ As TV_ITEM
	TV_ITEM_.hItem=Cast(HTREEITEM,item)
	If image<>0 And Selectimage<>0 Then
		TV_ITEM_.mask=TVIF_IMAGE Or TVIF_SELECTEDIMAGE
		SendMessage(GadgetID(gadget),TVM_GETITEM,0,Cast(lparam,@TV_ITEM_))
		ImageList_Replace(Cast(HIMAGELIST,GetHimageCombo_(gadget)),TV_ITEM_.iImage,Image,0)
		ImageList_Replace(Cast(HIMAGELIST,GetHimageCombo_(gadget)),TV_ITEM_.iSelectedImage,Selectimage,0)
	ElseIf image<>0 Then
		TV_ITEM_.mask=TVIF_IMAGE
		SendMessage(GadgetID(gadget),TVM_GETITEM,0,Cast(lparam,@TV_ITEM_))
		ImageList_Replace(Cast(HIMAGELIST,GetHimageCombo_(gadget)),TV_ITEM_.iImage,Image,0)
	ElseIf Selectimage<>0 Then
		TV_ITEM_.mask=TVIF_SELECTEDIMAGE
		SendMessage(GadgetID(gadget),TVM_GETITEM,0,Cast(lparam,@TV_ITEM_))
		ImageList_Replace(Cast(HIMAGELIST,GetHimageCombo_(gadget)),TV_ITEM_.iSelectedImage,Selectimage,0)
	EndIf
	for i as Long = 0 to 3
	    InvalidateRect(GadgetID(gadget),0,1)
	Next
End Sub

Sub ReplaceImageItemTreeView(ByVal gadget As Integer, _
							ByVal item As Integer, _
							ByVal image As HICON, _
							ByVal Selectimage As HICON) Export
	Dim TV_ITEM_ As TV_ITEM
	TV_ITEM_.hItem=Cast(HTREEITEM,item)
	If image<>0 And Selectimage<>0 Then
		TV_ITEM_.mask=TVIF_IMAGE Or TVIF_SELECTEDIMAGE
		SendMessage(GadgetID(gadget),TVM_GETITEM,0,Cast(lparam,@TV_ITEM_))
		ImageList_ReplaceIcon(Cast(HIMAGELIST,GetHimageCombo_(gadget)),TV_ITEM_.iImage,Image)
		ImageList_ReplaceIcon(Cast(HIMAGELIST,GetHimageCombo_(gadget)),TV_ITEM_.iSelectedImage,Selectimage)
	ElseIf image<>0 Then
		TV_ITEM_.mask=TVIF_IMAGE
		SendMessage(GadgetID(gadget),TVM_GETITEM,0,Cast(lparam,@TV_ITEM_))
		ImageList_ReplaceIcon(Cast(HIMAGELIST,GetHimageCombo_(gadget)),TV_ITEM_.iImage,Image)
	ElseIf Selectimage<>0 Then
		TV_ITEM_.mask=TVIF_SELECTEDIMAGE
		SendMessage(GadgetID(gadget),TVM_GETITEM,0,Cast(lparam,@TV_ITEM_))
		ImageList_ReplaceIcon(Cast(HIMAGELIST,GetHimageCombo_(gadget)),TV_ITEM_.iSelectedImage,Selectimage)
	EndIf
	for i as Long = 0 to 3
	    InvalidateRect(GadgetID(gadget),0,1)
	Next
End Sub