Sample Control Definition file

Copy code

<!-- During a recording session, when the Microsoft event MouseUp occurs, -->
<!-- a line is added to the test that calls a test object method named SetValue. -->
<!-- The SetValue test object method receives a value and a set of coordinates. -->

            <Event name="MouseUp" enabled="true">
                <RecordedCommand name="SetValue">

<!-- The UFT reserved word Sender represents the object on which -->
<!-- the event occurred. Sender.value returns the control value after the  -->
<!-- mouse button was lifted. -->


<!-- This code creates the xy variable, which contains the mouse  -->
<!-- coordinates (supplied by Windows) at the time the mouse button  -->
<!-- was lifted. Because this next parameter element contains code, the -->
<!-- lang attribute is specified. Parameter is a UFT reserved word  -->
<!-- that must contain the value to use for the test object method argument. -->

                    <Parameter lang="C#">
                        String xy;
                        xy = EventArgs.X + ";" + EventArgs.Y;
                        Parameter = xy;

<!-- When running a test step that contains the SetValue test object  -->
<!-- method and its arguments, UFT uses the information in this  -->
<!-- element to determine how to perform the test object method on the  -->
<!-- control. -->
            <Method name="SetValue">

<!-- The first test object method argument is used for the Value -->
<!-- parameter in the MethodBody code. The second  test object method  -->
<!-- argument is used for the MousePosition parameter in the MethodBody  -->
<!-- code. -->

                    <Parameter type="int" name="Value" />
                    <Parameter type="String" name="MousePosition" />

<!-- UFT sets the property 'value' of the control to the value recorded  -->
<!-- during the record session and then prints a message indicating the  -->
<!-- location of the mouse at the time of the event. -->

                RtObject.Value = Value;
                System.Windows.Forms.MessageBox.Show(MousePosition,     "Mouse Position at Record Time");