Forum Discussion
TanyaYatskovska
Alumni
13 years agoHi Adam,
As far as I understand, you are using the Text Recognition technology to work with your control. There is another way - accessing native properties and methods of the control. See the example below. It was created for the SftTree control version 6.5, however, I suppose that you can use a similar approach.
' The script works with the "<Softelvdm>\SftTree OCX 6.5\Samples\VB6\CellEditing\" sample
Sub Main
Dim p, wMain, wTree, rowId, strCol, cellValue
Set p = Sys.Process("Project1")
Set wMain = p.VBObject("Form1")
wMain.Activate
Set wTree = wMain.VBObject("SftTree1")
rowId = 1
strCol = "First Column"
cellValue = getCellValue(wTree, rowId, strCol)
If VarType(cellValue) = 1 Then
Log.Error "No value is returned."
Else
Log.Message "The [" & rowId & ", '" & strCol & "'] cell's value is '" & cellValue & "'"
End If
cellValue = "<new value>"
If setCellValue(wTree, rowId, strCol, cellValue) Then
Log.Message "The [" & rowId & ", '" & strCol & "'] cell's new value is '" & getCellValue(wTree, rowId, strCol) & "'"
End If
If clickItem(wTree, rowId, strCol) Then
Log.Message "The [" & rowId & ", '" & strCol & "'] cell was successfully clicked."
End If
End Sub
Function getCellValue(wTree, rowId, strCol)
Dim colId
getCellValue = Null
If Not checkRange(wTree, rowId, strCol) Then
Exit Function
End If
colId = getColIdByName(wTree, rowId, strCol)
getCellValue = wTree.Cell(rowId, colId).Text
End Function
Function setCellValue(wTree, rowId, strCol, cellValue)
Dim colId
setCellValue = False
If Not checkRange(wTree, rowId, strCol) Then
Exit Function
End If
colId = getColIdByName(wTree, rowId, strCol)
wTree.Cell(rowId, colId).Text = cellValue
setCellValue = True
End Function
Function clickItem(wTree, rowId, strCol)
Dim colId, oCell, wEdit
clickItem = False
If Not checkRange(wTree, rowId, strCol) Then
Exit Function
End If
colId = getColIdByName(wTree, rowId, strCol)
Set oCell = wTree.Cell(rowId, colId)
oCell.MakeVisible
Call oCell.Edit(0, 0)
Set wEdit = wTree.FindChild("Visible", True)
Log.LockEvents(1)
wEdit.Click
Log.UnlockEvents
Log.Event "The [" & rowId & ", '" & strCol & "'] cell was clicked."
clickItem = True
End Function
Function checkRange(wTree, rowId, strCol)
Dim rowCount, colId, colCount
checkRange = False
rowCount = wTree.ListCount
If rowId < 0 Or rowId > rowCount - 1 Then
Log.Error "Wrong row index."
Exit Function
End If
If getColIdByName(wTree, rowId, strCol) = -1 Then
Log.Error "Wrong column name."
Exit Function
End If
checkRange = True
End function
Function getColIdByName(wTree, rowId, strCol)
Dim colId, colText
colcount = wTree.Columns
For colId = 0 To colCount - 1
colText = wTree.ColumnText(colId)
If SameText(colText, strCol) Then
getColIdByName = colId
Exit Function
End If
Next
getColIdByName = -1
End Function
BTW, in the following survey, you can vote for the target control to be supported in the future:
http://support.smartbear.com/products/more-info/testcomplete-survey/
http://support.smartbear.com/products/more-info/testcomplete-survey/