Forum Discussion
- tristaanogreEsteemed ContributorAs far as I am aware, there is not a functionality wrapped around the Sender parameter. I've never seen it used in any functional capacity where you can get information from it nor am I aware of any documentation concerning it.
As far as I know, it is a parameter used internally by TestComplete to indicate the Event control that fired off the event being executed in the handler. For example, note the screenshot attached. Any events fired off in this project would have one of two Event controls, depending upon what handlers are being executed.
I think, with regards to standard scripting and keyword testing, the Sender parameter is not used. Not having used event handlers outside of standard script development, I can't say much more than that. - hlalumiereRegular ContributorAfter reading up a little bit, the type of sender in this case would be an Event Control (http://support.smartbear.com/viewarticle/56944/) and if you could instanciate it by its class id (which isn't shown anywhere AFAIK), you would have access to 4 methods that would allow you to attach or detach handlers to or from that same object that just fired the event. It could be mildly useful i guess, for example if you wanted to implement a "restart from where it last failed" feature in your scripting project...
- hlalumiereRegular ContributorThe sender parameter is a mostly universally accepted convention for event signatures. Most events will fire carrying a sender object, and usually also an eventarg object. In this particular case (OnStopTest) it might not be very useful, however it is usually used in cases when you need a reference to the specific instance of an object in memory. Sender is defined as an object, and to use it you would need to cast it to the proper type through late binding. For example:
Sub MyObject_SomeCoolEvent(sender, e)
Set instance = CreateObject("MyObjectClass")
Set instance = sender
...
End Sub
First you create an instance of the object class you know sender really is underneath that "object" hood to dimension and type the object, then you assign it your sender reference. Now you can access all of the intended members. In this case, you would have to figure out what type of object the event is referencing to be able to use its members beyond the base class (object) members. - jose_pitaSuper Contributor
- ali_jaferOccasional ContributorI am aware of the documentation link given above, what i am specifically interested in is particular usage of "Sender" parameter with the help of any exmaple, i.e. how can we use "Sender" inside the body of GeneralEvents_OnStopTest
- ali_jaferOccasional ContributorThanks Robert for nice explanation, you mentioned about screenshot attached. I don't see any attachment... please guide if I am missing anything.
- tristaanogreEsteemed ContributorWhoops! My apologies! I've added the screenshot now.
Related Content
Recent Discussions
- 2 hours ago
- 6 days ago
- 10 days ago