InitEventListener Method (EventsListenerBase)

Mercury.QTP.CustomServer Namespace > EventsListenerBase Class : InitEventListener Method

Called once by the OpenText Functional Testing infrastructure to start listening for events. Override this method, adding subscriptions to the events to which you need to listen.

Remarks

Implement the event handler functions for your object. For example:

public void OnMouseDown(object sender, MouseEventArgs e) { // Your implementation of a handler for MouseDown event. if(e.Button != System.Windows.Forms.MouseButtons.Left) return; RecordFunction("MouseDown", RecordingMode.RECORD_SEND_LINE, e.X, e.Y); } Then add your handler in InitEventListenerpublic override void InitEventListener() { Delegate e = new MouseEventHandler(this.OnMouseDown); // Option 1: Using AddHandler. Testing tool or AUT context. // This technique is preferable to Option 2 because // your handler is called first and because the testing tool // guarantees that the handler is released. AddHandler("MouseDown", e); // Option 2: Add the handler directly using Control. AUT context only. // A handler added with += must be released explicitly in your // implementation of ReleaseEventListener\ TargetControl.MouseDown += e; }

Syntax
'Declaration
 
Public MustOverride Sub InitEventListener() 
public abstract void InitEventListener()