I was wondering TestComplete had the ability to 'wrap' its methods around an object passed to it. For example we have a Toolstrip that is embedded within an Infragistics UltraGrid, however we've found a way to reference into the UltraGrid Object to 'extract' the Toolstrip object we need.
Unfortunately the object that we 'extract' does not get TestComplete's nice 'wrapper' methods that allow us to easily interact with the object, such as 'ClickItem','Exists', etc. However we know the object is supported by TestComplete because if we use the 'object explorer tool' (the object properties window) we can grab the Toolstrip with its wrapper methods (we can't use TestComplete's normal WaitWinForm function because of factors beyond our control).
I'm not sure if I've explained this quite right but hopefully this example will help. The following line of code will return a Toolstrip object
From what I understand from the documentation is that because of the way we've indexed into this object TestComplete won't attempt to wrap additional functionality around the object returned, is there a way/method that I can pass this object to that will force TestComplete to wrap the correct functionality around this object?
You are right, TestComplete adds wrapper methods and properties to objects displayed in the Object Browser and does not add these methods and properties to objects which are retrieved via native methods or properties. There is no way to force the tool to do this. However, I can suggest a workaround.
You can use your native object's Handle property to get the Windows handle (the unique identifier of a window) for the object in question and then use the Sys.WindowFromHandle method to get the relevant object with TestComplete's wrapper. Please see the "Sys.WindowFromHandle" help topic for more information.
This is exactly what we needed! This works like a charm. To anyone else trying to implement something similar there is one additional step that you will need to do:
Apparently when getting an Indexed Object TestComplete will see a 'System.IntPtr' object where the Handle Property is, where as Sys.WindowFromHandle requires a Int. To get an int simply call the .ToInt32() method of this object. There is also a .ToInt64(), which from prelim tests on a 32bit machine return the same value .ToInt32() although I cannot say for sure if these can be safely used interchangeably (We also do test automation on the x64 build of our product, but we haven't needed this functionality up there yet, therefore this has been untested, it would be nice though as it would limit the amount of changes that would have to be made with our code base).
Once again thank you Allen your support on these forms has been invaluable.