Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
;some constants for dlgProc MSG_InitDialog = 0 MSG_Timer = 1 MSG_ButtonPressed = 2 MSG_Close = 11 MSG_ComEvent = 14 RET_Cancel = 0 RET_Normal = -1 RET_NoEnd = -2 ID_TreeViewControl = 003 ID_ImageListControl = 004 TVWFIRST = 0 ;node is placed before all other nodes at the same level of the node named in RELATIVE TVWLAST = 1 ;node is placed after all other nodes at the same level of the node named in RELATIVE TVWNEXT = 2 ;node is placed after the node named in RELATIVE TVWPREVIOUS = 3 ;node is placed before the node named in RELATIVE TVWCHILD = 4 ;node becomes a child of the node named in RELATIVE TVWAUTOMATIC = 0 ;The beforeLabelEdit event is generated when the user clicks on the label of a selected node TVWMANUAL = 1 ;The beforeLabelEdit event is generated only when the StartLabelEdit method is envoked #DefineSubRoutine dlgProc(handle,msg,id,p4,p5) Switch msg ;INITIALIZE DIALOG ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Case MSG_InitDialog ;get object reference for TreeView control on the dialog and populate the tree with some items oTree = DialogObject(handle,ID_TreeViewControl,3) oTree.LineStyle = 1 ;include lines at the root items oTree.Indentation = 3 ;number of spaces to indent oTree.LabelEdit = TVWMANUAL ;don't allow editing node text (label). (can only edit if you invoke the StartLabelEdit method on a node) oNodes = oTree.Nodes oNodes.Add(,,"ONEKEY","ONE") oNodes.Add("ONEKEY",TVWCHILD,"TWOKEY","TWO") oNodes.Add("ONEKEY",TVWCHILD,"THREEKEY","THREE") oNodes.Add("THREEKEY",TVWCHILD,"FOURKEY","FOUR") oFive = oNodes.Add(,,"FIVEKEY","FIVE") oNodes.Add(oFive,TVWCHILD,"SIXKEY","SIX") oFive = 0 ;get object reference for ImageList control on the dialog oImageList = DialogObject(handle,ID_ImageListControl,3) ;------------ HELP NEEDED HERE ----------------------------------------------------------------------------- oImageList.ListImages.Add(,"FolderClosed",picture) ;documentation says use LoadPicture("file name") oImageList.ListImages.Add(,"FolderOpen",picture) ;but that's not going to work. Now what? ;once I get these images on the ImageList control, then I can use them in the TreeView. ;------------ HELP NEEDED HERE ----------------------------------------------------------------------------- ;tell dialog to capture treeview events DialogObject(handle,ID_TreeViewControl,1,"NodeClick",003001) DialogObject(handle,ID_TreeViewControl,1,"Expand",003002) Return RET_NoEnd Break ;ON DIALOG CLOSE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Case MSG_Close oTree = 0 oImageList = 0 Return RET_Normal Break ;ON COM EVENTS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Case MSG_ComEvent ;COM event message ;check what kinds of COM events: Switch p4.identifier Case 003001 ;NODECLICK EVENTS oNode = p4.parameters(1).value nodeKey = oNode.key nodeText = oNode.text childCnt = oNode.children Message("Nodeclick Event",StrCat("Node Text: ",nodeText,@CRLF,"Node Key: ",nodeKey,@CRLF,"Child Count: ",childCnt)) Break Case 003002 ;EXPAND EVENTS oNode = p4.parameters(1).value nodeKey = oNode.key nodeText = oNode.text childCnt = oNode.children Message("Expand Event",StrCat("Node Text: ",nodeText,@CRLF,"Node Key: ",nodeKey,@CRLF,"Child Count: ",childCnt)) Break EndSwitch Return RET_NoEnd Break EndSwitch #EndSubRoutine DlgFormat=`WWWDLGED,6.1` DlgCaption=`Tree Test` DlgX=9999 DlgY=9999 DlgWidth=258 DlgHeight=255 DlgNumControls=004 DlgProcedure=`dlgProc` DlgFont=`DEFAULT` DlgTextColor=`DEFAULT` DlgBackground=`DEFAULT,DEFAULT` DlgConfig=0 Dlg001=`175,235,036,012,PUSHBUTTON,DEFAULT,"OK",1,1,32,DEFAULT,DEFAULT,DEFAULT` Dlg002=`213,235,036,012,PUSHBUTTON,DEFAULT,"Cancel",0,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT` Dlg003=`005,005,244,224,COMCONTROL,DEFAULT,"MSComctlLib.TreeCtrl.2",DEFAULT,3,DEFAULT,DEFAULT,DEFAULT,"255|255|255"` Dlg004=`011,233,072,020,COMCONTROL,DEFAULT,"MSComctlLib.ImageListCtrl.2",DEFAULT,5,DEFAULT,DEFAULT,DEFAULT,DEFAULT` ButtonPushed=Dialog("Dlg") ;FYI: ;SYNTAX FOR Node.Add(RELATIVE,RELATIONSHIP,KEY,TEXT,IMAGE,SELECTEDIMAGE) ;RELATIVE OPTIONAL The index number or key of a pre-existing node. The relationship between the new node and this node is in the RELATIONSHIP argument. ; (If no Node object is named, the new node is placed in the last position of the top node hierarchy) ;RELATIONSHIP OPTIONAL Specifies the relative placement of the node (see TVW constants) ;KEY OPTIONAL A unique string that can be used to retrieve the Node with the Item method ;TEXT OPTIONAL The string that appears in the Node. ;IMAGE OPTIONAL The index of an image in an associated ImageList control ;SELECTEDIMAGE OPTIONAL The index of an image in an associated ImageList control that is shown when the Node is selected.
oIMG = CreateObject("MSComctlLib.ImageListCtrl.2") getIList()The getlist() creates an imagelist from the 'special' 000 control in the Dialog.
#DefineSubRoutine getIList() cImg = StrCat(DirScript(),"nc.gif") oPict=DialogObject(handle, 000, 4, cImg) oIMG.ListImages.add(1, "", oPict) cImg = StrCat(DirScript(),"xpfolder.gif") oPict=DialogObject(handle, 000, 4, cImg) oIMG.ListImages.add(2, "", oPict) cImg = StrCat(DirScript(),"xpmydoc.gif") oPict=DialogObject(handle, 000, 4, cImg) oIMG.ListImages.add(3, "", oPict) #EndSubRoutineThen assign your imagelist to the TreeView
oTree.ImageList = oIMGFinally, when adding nodes use the last parameter to indicate the index of the image
oNode = oNodes.Add(nLevel1, tvwChild, cKey,cLevel ,2)assigns the xpfolder image to the node
Article ID: W17774
Filename: ImageList in TreeView.txt
File Created: 2008:11:25:13:02:32
Last Updated: 2008:11:25:13:02:32