TreeView ActiveX

Question: Does anyone have any samples of how to use the TreeView ActiveX or similar controls that may be better? I have an Access database in my ToolBook application that I want to have cascading lists.

Answer: We use the TList ActiveX control for our ToolBook Translation System product. Here are a couple of handlers that might help:

to get addItemToTList string itemName, string strParentIndex, string itemTag
        system object ttst_s_tListID

        local itemNum
        local long parentIndex
        local string objectTypeLine

        -- add groupName if part of itemTag

        objectTypeLine = textline 2 of itemTag

        if objectTypeLine contains "_" AND "widget" is not in itemTag
                itemName = itemName && "(group " & quote & getGroupNameFromTag(word 1 of objectTypeLine) & quote & ")"
        end if

        -- second parameter must be null or of type long
        if isNumber(strParentIndex)
                parentIndex = strParentIndex
                get extAddItem(itemName, parentIndex) of ttst_s_tListID
        else
                get extAddItem(itemName) of ttst_s_tListID
        end if
        itemNum = extNewIndex of ttst_s_tListID
        if itemTag <> null
                extItemTag(itemNum) of ttst_s_tListID = itemTag
        end if

        return itemNum
end addItemToTList

-- this code is in the script for the TList control itself

to handle checkForNewSelection
        system string ttst_s_itemTag

        local object tListID
        local string itemTag
        local long itemNum

        tListID = self
        itemNum = extListIndex of tListID
        if itemNum = -1
                break
        end if

        itemTag = extItemTag(itemNum) of tListID
        if itemTag = null
                break
        end if
        get checkForUpdate() of currentPage of mainWindow
        ttst_s_itemTag = itemTag
        send ttst_LoadSelectedRecord
end checkForNewSelection

to handle extClick
        if target = self then
                send checkForNewSelection
        end
        forward
end extClick

Note that ToolBook itself used the TList for older versions of the Catalog and might use a version of it for the Book Explorer. So you can sniff through their code for examples as well.

The user followed up with this response: Thanks for the starter, I have managed to get data into the TList control and extract the data selected by the user, but I want to use more of the options available in the ActiveX. I can retrieve the methods used in the control, but they don’t equate to the help that is provided with the control. Usually they give VB examples and I’m not sure how to translate them to ToolBook, I have been using the trial and error message with a little bit of success, but it is a bit frustrating. I read an example of what I want to do on a VB forum giving the following example. Can anyone put me in the right direction to convert this to ToolBook.

TList1.Grid.Cols = 2
TList1.Grid.ShowColTitles = true
TList1.Grid.ShowRowTitles = true
TList1.Grid.ColDefs(0).Width = 600
TList1.Grid.ColDefs(1).Width = 1200
TList1.Grid.ColDefs(1).CellDef Font.Bold = true 
TList1.Grid.ColDefs(1).CellDef Font.Size = 11 
TList1.Grid.ColDefs(1).CellDef Font.Name = 'Arial'
TList1.Grid.Cells(0,1). "Value" = 'Job No'

Putting the data in from the database

While

Cells(i,1). Value = rsJonNo.Fields(JobNo)

I wrote down the example so it may not be technically correct in the VB script. So far I have been using the script below to populate the control

to handle buttonClick
	system dbconn,dbrecset,dbfields,@Code,@First,@Last,@Status
	local @Text
	
	mySQL = "SELECT AssetNo, LevelFLD, AssetLink FROM HierTBL Order by LevelFLD ASC"--WHERE LevelFLD = '1'" --'" & @Code & "'"
	send dbView(mysql)
	while NOT (extEOF of dbRecSet)
		if extitem[1] of dbfields = 0
			get extAddItem(extitem[0] of dbfields) of tlist "test"
		else
			get extAddItem(extitem[2] of dbfields,extitem[1] of dbfields -1) of tlist "test"
		end
		get MoveNext() of dbrecset
		increment @Text
	end
	get extClose() of dbRecSet
	get extClose() of dbconn
end

Again, any assistance would be appreciated.

Jeff responded: It sounds like you are making good progress. Working with ActiveX controls is challenging as you have seen. The gist of the approach is to reverse the order and put “ext” on the front. So

TList1.Grid.Cols = 2

Would be:

extCols of extGrid of tListId = 2

Since the Grid is a separate object, I like to put it in its own variable. That way you can look at in the debugger. If it has a number associated with it (something big like 11009832), then you are typically in good shape. So I would do something like this:

local tListId
local gridId

tListId = TList "xyz" of this page
gridId = extGrid of tListId

extCols of gridId = 2
extShowColTitles of gridId = TRUE
etc.

The propertyList(), methodList() and eventList() OpenScript functions are real helpful. I like to combine them with sortList and listToTextline as shown below to give a nice display. Be sure to run this from the Command Window while in reader mode:

put textlineToList(sortList(methodList(TList id 4 of Page id 11)))

Here is the result:

extAboutBox
extAddItem
extAddItem2
extAddItem2Ex
extBeforeDrag
extCheckRuntimeLicense
extClear
extCopyBuffer
extDropTarget
extFastAddItem
extFastAddItemEx
extFindItem
extFindValue
extFreeBuffer
extGetItemByXY
extGetItemRect
extHitTest
extIndexByBM
extIsClipboardFormatAvailable
extIsValidBM
extIsValidBuffer
extLoadBuffer
extLoadData
extOnDragDrop
extOnDragOver
extPasteBuffer
extRefresh
extRefreshItems
extRemoveItem
extSaveBuffer
extSaveData
extTranslateIndex
extUpdateBackground
extWebGoBack
extWebGoForward
extWebNavigate

Similarly for properties:

put listToTextline(sortList(propertyList(TList id 4 of Page id 11)))

allowAuthorActivate
allowReaderActivate
bounds
ext_Dummy1
ext_Dummy2
ext_LcPresent
extActiveGrid
extAdd
extAppearance
extAutoExpand
extAutoScrDuringDragDrop
extBackColor
extBackPicture
extBackPictureAlignment
extBackwardCompatibility
extBorderStyle
extBottomIndex
extCaption
extClearItem
extClipboard
extCoerceIndex
extColDelimiter
extConvertTabsToCols
extCopyItem
extCopyItemSub
extCopyOne
extCopySelected
extCurrentIndexMethod
extCurrentItem
extCurrentItemBM
extCurrentParent
extDefItemCellAlignment
extDefItemCellBackColor
extDefItemCellBorderColor
extDefItemCellBorderStyle
extDefItemCellPictureAlignment
extDefItemCellTextAlignment
extDefMultiLine
extDisableNoScroll
extDragHighlight
extDrawFocusRect
extEnabled
extEnvironment
extExpand
extExpandChildren
extExpandEx
extExpandNewItem
extExplorerCompatible
extFile
extFixedSize
extFont
extFontBold
extFontItalic
extFontName
extFontSize
extFontStrikethru
extFontUnderline
extForeColor
extFullPath
extGradientColorFrom
extGradientColorTo
extGradientStyle
extGrid
extHasGrid
extHasSubItems
exthWnd
extImage
extImageStretch
extIndent
extInsert
extInsertItem
extInvBorderStyle
extInvImage
extInvStyle
extIsClipboardAvailable
extIsItemVisible
extItemAlwaysHidden
extItemBackColor
extItemBM
extItemCell
extItemEditText
extItemFontBold
extItemFontItalic
extItemFontName
extItemFontSize
extItemFontStrike
extItemFontUnder
extItemForeColor
extItemGrid
extItemHasGrid
extItemHasValue
extItemHeight
extItemImageDefHeight
extItemImageDefWidth
extItemIntValue
extItemLngValue
extItemMark
extItemMultiLine
extItemNextSibling
extItemParent
extItemParentBM
extItemPicValue
extItemPMPicType
extItemPrevSibling
extItemSngValue
extItemSorted
extItemSortingKey
extItemStrValue
extItemTag
extItemType
extItemURL
extItemValues
extItemVirtualCount
extItemVirtualParent
extLevelDefs
extList
extListCount
extListCountEx
extListIndex
extLoadAndAdd
extLoadAndInsert
extMarkedItemsAlwaysHidden
extMarkHeight
extMarkPicture
extMarkTag
extMarkWidth
extMouseIcon
extMousePointer
extMSOutlineAdd
extMultiSelect
extNewIndex
extNoIntegralHeight
extNoPictureRoot
extOLEDropMode
extPathSeparator
extPicInMultiLine
extPictureClosed
extPictureInverted
extPictureLeaf
extPictureList
extPictureListCount
extPictureMark
extPictureMinus
extPictureOpen
extPicturePalette
extPicturePlus
extPictureRoot
extPictureType
extRedraw
extSave
extSaveOne
extSaveSub
extScrollbars
extScrollHorz
extSelBackColor
extSelected
extSelectEx
extSelForeColor
extSelItemCount
extSelItemIndex
extShift
extShiftStep
extShowCaption
extShowChildren
extShowHiddenItems
extShowTitles
extSmartDragDrop
extTabStopDistance
extText
extTitleHeight
extTitlePicture
extTitleText
extTitleVisible
extTitleWidth
extToolTipsBackColor
extToolTipsForeColor
extToolTipsMode
extToolTipsViewStyle
extTopIndex
extTransparentBackground
extTransparentBitmap
extTransparentBitmapColor
extTreeLinesColor
extTreeLinesStyle
extTriggerEvents
extVersion
extViewStyle
extViewStyleEx
extWebAutoNavigate
extWebTargetFrame
extWebURLBase
extWidthOfText
extWidthOfTextMin
extXOffset
hasPropertyDialog
idNumber
layer
methods
name
notifyAfterMessages
notifyBeforeMessages
object
parent
position
script
sendToolbookMessages
sharedScript
size
suspendMessages
uniqueName
userProperties
visible

Finally for events:

put listToTextline(sortList(eventList(TList id 4 of Page id 11)))

ButtonClick
ButtonDoubleClick
ButtonDown
ButtonUp
extAfterEditing
extClick
extCollapse
extDblClick
extEditingKeyDown
extEditingKeyPress
extEditingKeyUp
extExpand
extGridCellClick
extGridCellDblClick
extHScroll
extItemClick
extItemDblClick
extItemQueryData
extKeyDown
extKeyPress
extKeyUp
extMarkClick
extMarkDblClick
extMouseDown
extMouseMove
extMouseUp
extOLEDragDrop
extOLEDragOver
extPictureClick
extPictureDblClick
extPlusMinusClick
extPlusMinusDblClick
extRequestEditing
extVScroll
KeyChar
KeyDown
KeyUp
RightButtonDoubleClick
RightButtonDown
RightButtonUp

Unfortunately, you can’t use the same technique to find the properties, events, and methods of objects within the control like extGrid. In that case, you’ll need to use the control documentation and experiment. Where possible, put each individual object into a variable so that you can see if you can create the reference to it correctly.

Advertisements

About Jeff Rhodes
Jeff Rhodes is the Chief Technical Officer and owner of Platte Canyon Multimedia Software Corporation, a leader in developing commercial software that Improves the Lives of Training Developers. He graduated at the top of his class at the Air Force Academy, where he earned a Bachelor of Science in Electrical Engineering. Jeff received a Masters degree in Economics from the London School of Economics, which he attended under a British Marshall Scholarship. Jeff is the author of "Programming for e-Learning Developers: ToolBook, Flash, JavaScript, & Silverlight" and "VBTrain.Net: Creating Computer and Web Based Training with Visual Basic .NET." He also co-wrote "The ToolBook Companion." He has had numerous articles on training development published and is a frequent presenter at conferences both in the U.S. and Europe. Jeff lives in Colorado Springs with his wife Sue and sons Derek and Michael.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: