Forum Discussion

kso's avatar
kso
Occasional Contributor
15 years ago

Delphi VCL Object TStatusBar and TVirtualStringTree TChart

Hi,



I would like to know how to get the information displayed on a TVirtualStringTree.

I can see only the number of RootNodeCount, but how to get the element displayed.



Same question on the TStatusBar. I can see the number of element wPartCount, but

when i try to acces the element using wText(n), i cannot get the text displayed.



Same question on TChart object.



Regards.

10 Replies

  • Hi Karim,



    - TVirtualStringTree


    To work with this control, you need to use the Object Mapping feature of TestComplete. Please follow the steps below:



    1. Double-click your project node in the Project Explorer panel.


    2. Switch to the Properties tab in the project editor.


    3. Select the Object Mapping section of the project properties.


    4. Expand the "Win32 Controls and Windows" node.


    5. Select the Tree view item.


    6. Click the "Add Class Name" button.


    7. Type "TVirtualStringTree" to make TestComplete treat controls of the TVirtualStringTree class as standard TreeView controls.



    After that, TestComplete will be able to record high-level tests with TVirtualStringTree controls.





    - TStatusBar


    Probably, the items of the problematic status bar are owner-drawn. In this case, you can try obtaining the text displayed in these owner-drawn items by using the panels collection returned by the Panels native property of status bar objects. Use native methods and properties of items from this collection to get information on them.






    - TChart


    Currently, this control is not supported by TestComplete. However, you can work with the control's data by using its native Series property. You can find more information on the Series property in the Delphi IDE help system.






    Please note that, to make TestComplete be able to access native properties of Delphi applications, you need to include debug information in your application (see the Using Debug Info Agent With Delphi Applications help topic).



    Let me know if you have additional questions.
  • Hi Karim,

    Did you manage to work with TVirtualStringTree object?? After following the steps provided by david, i can get the name of each individual node item. But i can not perform Select, Expand and Collapse actions on the node Items.

     

    I  appreciate any suggestions. 



    Many thanks,

    Veeresh Kumar 

  • Hi Karim,





    Here is a sample script that demonstrates how to expand the TVirtualStringTree object's nodes:





    Sub Main

      ' This script works with the "<vt contributions>\Examples\Delphi\Minimal\Minimal.exe" sample.

      ' Before executing the script, add four nodes to the tree making the next node a child of the previous one. 





      Dim p, wMain, wTree, strItem

      Set p = Sys.Process("Minimal")

      Set wMain = p.VCLObject("MainForm")

      Set wTree = wMain.VCLObject("VST")

      strItem = "Level 0, Index 0|Level 1, Index 0|Level 2, Index 0|Level 3, Index 0|Level 4, Index 0"

      If clickNode(wTree, strItem) Then

        Log.Message "The '" & strItem & "' node was successfully clicked." 

      End If

    End Sub





    Function clickNode(wTree, strItem)

      Dim tempRes

      wTree.FullCollapse(wTree.RootNode)

      wTree.ClearSelection

      wTree.SetFocusedNode(wTree.RootNode)

      Log.LockEvents(1)

      tempRes = dblClickNode(wTree, strItem)

      Log.UnlockEvents

      clickNode = tempRes 

      If tempRes Then

        Log.Event "The '" & strItem & "' node was clicked."

      Else

        Log.Error "The '" & strItem & "' node was not found."

      End If

    End Function





    Function dblClickNode(wTree, strItem)

      Dim wSelected, arrayItem, itemCount, itemId, item

      

      dblClickNode = False

      If Len(strItem)= 0 Then

        dblClickNode = True

        Exit Function

      End If

      wSelected = wTree.wSelection

      arrayItem = Split(strItem, "|")

      itemCount = wTree.wItemCount

      For itemId = 0 To itemCount - 1 

        item = wTree.wItem(itemId)

        If SameText(item, arrayItem(0)) Then

          Call wTree.DblClickItem(wSelected & "|" & arrayItem(0))

          arrayItem(0) = ""

          dblClickNode = dblClickNode(wTree, Replace(Join(arrayItem, "|"), "|", "", 1, 1))

          Exit Function

        End If    

      Next

    End Function
  • Do you have something like this for Delphi?



    We have a VirtualStringTree with a dynamical number of nodes. All nodes are Level1 children of the root.



    We want to get a specific item (by its name or another property). Its position in the tree can change at every start of the process.



    Methods like "GetFirst", "Get Next" or "GetNodeData" are not available for the mapped object in TestComplete.
  • Has anyone found a solution to this'TVirtualStringTree' object.





  • Hi Valentine,





    Can you describe the issue you're having in detail? If you mean this:

    Methods like "GetFirst", "Get Next" or "GetNodeData" are not available for the mapped object in TestComplete.


    the issue was that Sven addressed a wrong Aliases object in a script.
  • This is not what I mean.

    we have a 'TVirtualStringTree' object which is populated at runtime.

    • The tree then has Items, which in turn can have sub-tree items

    • The property'wItemCount' is 23 as well as the 'wRootItemCount for instance.

    • But when i try to access the 'wItem' property of a specific item or the 'wItems' the application crashes.

    • How do I access these elelments?

  • Hi Valentine,



    To help us investigate why the application (BTW, saying 'the application crashes', do you mean TestComplete or your tested application?) crashes, please follow the steps below:


    1. Download AQtime Standard, which is our free profiling tool, from our web site:


    AQtime Standard


    2. Install the tool.


    3. Start AQtime with the -NotOpenApp command line argument. For example, you can use the following command line:


    "c:\Program Files\SmartBear\AQtime 7\Bin\AQtime.exe" -NotOpenApp


    4. Select the 'File | New Project From Module...' main menu item.


    5. In the Open File dialog, select the executable file of the application and click Open.


    6. Take a look at the AQtime toolbar - there is a combo box. Open it and select the "Tracing | Exception Trace Profiler" item.


    7. Select the "Options | Options..." main menu command - the Options dialog will appear.


    8. Set the "Profiling Time | Event View | General | Exceptions | Depth shown" setting to 100 and click OK.


    9. Click the Run toolbar button (the green arrow) or press F5 to start the profiling.


    10. AQtime will start the application and trace all exceptions that will occur in it until it is closed.


    11. Reproduce the problem.


    12. After the problem occurs, right-click somewhere within the Event View panel (it is opened by default at the bottom of AQtime's window) and select the 'Save All...' item.


    13. Save the panel's contents to an HTML file and send me the file.



    Thanks in advance.






    Another way to get a node's text is to use native properties/methods of the control. Note that you need to compile the application with debug information in order for TestComplete to have access to native methods and properties (see the Open Applications in Delphi help topic for more information). If you don't manage to find appropriate properties/methods, please send us a sample application (it should be compiled with debug information) containing your control, and we'll see how it's possible to get a node's text.