Forum Discussion

Test56's avatar
Test56
Contributor
13 years ago

Want to check the status of CheckBox implemented in SysTreeView32



Trying to check the state (checked or unchecked) of checkbox in systreeview32 control [vc application]. Spying revealed that Checked property could not be used, since there is no TVS_CHECKBOXES style defined. The checkbox is implemented using the StateImage.

Tried to use the StateImageIndex, however could not make it generic. Can anybody recommend me on how to use the StateImage property and check the state of checkbox for any item in tree control.





Please refer only attached Checked1 and Check1, i dont know how he other images got added.

4 Replies







  • Hello 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.
  • Hello,



    What should be conveyed to the developer in such a case? Is the TVS_CHECKBOXES style not implemented due to a specific reason?



    I am in a similar situation and I think if you could provide me with some information then I can go talk to the development team and understand why they chose not to include it.



    Sometimes, it could be as simple as enabling a property in the control design code or it could be an intentional decision to exclude certain styles.



    - GJ
  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi,



    It is only your developers who can answer you why this or that property in their code was disabled.

    From your side you can say that the test tool has some requirements and if these requirements are met, then you can create more reliable tests in a shorter time period. Otherwise you will have to to implement some workarounds that will impact both tests reliability (in your case - just because image comparison is extremely unreliable and should be considered as a last resort only) and tests development time.

    Hopefully, you'll have then some discussion and can make some decision acceptable for you and development.
  • irina_lukina's avatar
    irina_lukina
    Super Contributor

    Hi,


    As far as I could find out, if your developers implement the TVS_CHECKBOXES style, the mechanism that is used in your controls at the moment will stop working. So, they will have to modify the code anyway. Also, there are several reasons why your developers may not implement this style. The TVS_CHECKBOXES style lets draw the check boxes using standard functionality provided by the operating system. So, it includes only two states for a check box: checked or unchecked. Also, it doesn't allow changing the icons for the check boxes. So, your developers may not use this style, because they wanted to add more states or other icons for the check boxes (it's just my guess).


    As a conclusion, your developers may agree to implement this style, but, I think, it's "a hundred to one" :)