Page 1 of 1

TreeGadget (lost images) now with better source code

Posted: Wed Jul 02, 2003 3:59 pm
by Inner
This is doing my head in and I can't figure out why, but in one program these functions work, they add the icon to the the aproperate label in the tree, when I copyed them out into another it doesn't add the images anymore and doesn't even add a space next to the label to show one should have been there..

Code: Select all

;
; loads icons in ( wish these could be .ico but never mind )
;
Procedure Load_DisplayEntryIcons()
    htvicons=LoadImage(4000,"bitmaps/treeviewicons.bmp")
    htvmask=LoadImage(4001,"bitmaps/treeviewmask.bmp")
    tvdb_hImgList=ImageList_Create_(16,16,#ILC_COLOR8|#ILC_MASK, 2, 4)
    Debug("ILA-"+Str(ImageList_Add_(tvdb_hImgList,htvicons,htvmask)))
EndProcedure
;
; adds label to treeview.
;
Procedure.l AddFolderItemTree(gadget.l,foldername.s,nLevel.l)
    gadget=GadgetID(gadget)
    tvi.TVITEM
    tvins.TVINSERTSTRUCT
    hPrev=#TVI_FIRST
    If nLevel=0 : ProcedureReturn 0 : EndIf
    tvins\item\mask=#TVIF_TEXT|#TVIF_IMAGE
    tvins\item\pszText = @foldername
    tvins\item\cchTextMax = Len(foldername)
	tvins\item\iImage = 0
    If nLevel=1
        tvins\hParent=#TVI_ROOT
	 	hPrev=SendMessage_(gadget,#TVM_INSERTITEM,0,@tvins)
    Else
        tvins\hParent=hPrevItemArray(nLevel-1)
	 	hPrev=SendMessage_(gadget,#TVM_INSERTITEM,0,@tvins)
    EndIf
	hPrevItemArray(nLevel)=hPrev
    ProcedureReturn hPrev
EndProcedure
Any help would be greatly recived thank you.

Posted: Thu Jul 03, 2003 9:52 am
by Inner
okay well I thought, what I posted would be enough, looking at it I don't think it is anymore, (probably why no replys and that's my fault sorry )..

http://www.inet.net.nz/~tjr/irc/faultimagetree.zip - 3kb

I keep feeling I've missed something, but I can't for the life of me think what, the source can be compiled and ran as is, it includes the bitmaps I am using as well, I'd really like to just use standard .ico.

But anyway, the same result the old code contunes to work just to spite me, and this new one contunes to not add the images to the labels to make me fustrated.

Again thanks, and sorry I didn't post enouch code.

Posted: Fri Jul 04, 2003 5:42 am
by Inner
^ BUMP ^

Posted: Fri Jul 04, 2003 1:20 pm
by freak
You create the Imagelist, but you never associate it with the TreeGadget.
How should it know where to take the images from?

Add the following line right after the TreeGadget() command:

Code: Select all

SendMessage_(GadgetID(#DEGAD_TREE), #TVM_SETIMAGELIST, #TVSIL_NORMAL,tvdb_hImgList)
(of course, "tvdb_hImgList" must also be made global)

... and there you go, Images are back :D

TImo

Posted: Fri Jul 04, 2003 2:52 pm
by Inner
thank you so much, I'm very greatful.. ( I feel like an idiot )