Mercury.QTP.CustomServer Namespace > EventsListenerBase Class : InitEventListener Method |
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 InitEventListener
public override void InitEventListener() { Delegate e = new MouseEventHandler(this.OnMouseDown); // Option 1: Using AddHandler. UFT or AUT context. // This technique is preferable to Option 2 because // your handler is called first and because UFT // 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; }
'Declaration
Public MustOverride Sub InitEventListener()
public abstract void InitEventListener()