Forum Discussion
Dmitry_Nikolaev
Staff
14 years agoHello Rajat,
If a SysTreeView32 control does not have the 'TVS_CHECKBOXES' window style, TestComplete cannot work with the control's checkboxes. In this case, to check whether a check box is checked, in a script you can compare the image of the application's check box with a baseline checked box image. To do this, you need to add the baseline image to the Regions collection of your project. Upon doing this, you will be able to use the below script. Don't forget to replace the dummies in angle brackets "<>" with the actual values.
Sub Test
Set tree = <myTree>
If isBoxChecked(tree, <item name>) Then
Log.Message "Checked"
Else
Log.Message "Unchecked"
End If
End Sub
Function isBoxChecked(tree, itemName)
isBoxChecked = False
Set node = tree.wItems.Item(itemName)
Set img = node.StateImage
If Regions.Compare(<The image name of the Regions collection's item>, img, False, False, False, 0, lmNone) Then
isBoxChecked = True
End If
End Function
I have also attached a short video demonstrating how you can add a baseline image of the checked box to the Regions collection.
Please let me know if this works for you.