Sample Control Definition file

Copy code
<Customization>
    <Record>
        <Events>

<!-- 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. -->


                    <Parameter>
                        Sender.Value
                    </Parameter>

<!-- 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;
                    </Parameter>
                </RecordedCommand>
            </Event>
        </Events>
    </Record>

    <Replay>
        <Methods>
<!-- 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. -->

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

<!-- 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. -->

            <MethodBody>
                RtObject.Value = Value;
                System.Windows.Forms.MessageBox.Show(MousePosition,     "Mouse Position at Record Time");
            </MethodBody>
            </Method>
        </Methods>
    </Replay>
</Customization>