Hi all,
I hope I don't feel like an idiot after this question.
I am trying to learn how to use tree view control. I have code which creates the window nicely. After that I try to insert just the root item using following two procedures, but I only manage to produce GPF.
Can somebody just by looking at this code give any hints where the problem might be? I don't like posting the original code because it is quite extensive.
Variables not declared in these produres are globals.
TIA
Lasse Rantanen
[email protected]
I hope I don't feel like an idiot after this question.

I am trying to learn how to use tree view control. I have code which creates the window nicely. After that I try to insert just the root item using following two procedures, but I only manage to produce GPF.
Can somebody just by looking at this code give any hints where the problem might be? I don't like posting the original code because it is quite extensive.
Variables not declared in these produres are globals.
TIA
Lasse Rantanen
[email protected]
Code:
SUB TV_InitTreeView (hInst AS LONG, hWndTree AS LONG) LOCAL szText AS ASCIIZ*%MAX_CATEGORY CALL LoadString(hInst, %IDS_NETWORK, szText, %MAX_CATEGORY) hTPrev = %TVI_ROOT iImage = idxNetwork hTParent = %NULL iSelect = idxNetwork hTRoot = TV_AddOneItem(BYVAL VARPTR(szText),BYVAL hwndTree, -1) hTParent = hTRoot hTPrev = %TVI_FIRST iImage = idxNic iSelect = idxSelect END SUB FUNCTION TV_AddOneItem( lpszText AS ASCIIZ PTR , hwndTree AS LONG, index AS INTEGER) AS LONG LOCAL hItem AS LONG LOCAL tvI AS TV_ITEM_UNION LOCAL tvIns AS TV_INSERTSTRUCT tvI.item.mask = %TVIF_TEXT OR %TVIF_IMAGE OR %TVIF_SELECTEDIMAGE OR %TVIF_PARAM tvI.item.pszText = lpszText tvI.item.cchTextMax = LEN(@lpszText) tvI.item.iImage = iImage tvI.item.iSelectedImage = iSelect tvI.item.lParam = index tvIns.item = tvI tvIns.hInsertAfter = hTPrev tvIns.hParent = hTParent hItem = SendMessage(hwndTree, %TVM_INSERTITEM, 0, VARPTR(tvIns)) '<-- GPF here FUNCTION = hItem END FUNCTION
Comment