Testing the Control with Version Support

Testing different versions of the same control is not easy, simply because only one of the versions can be registered at a time. This is one way in which you might check to see if a newer version of the Circle control correctly ignores persistent data stored by an earlier version of the control.

To insert the Circ control in Test Container

  1. From the Tools menu, click ActiveX Control Test Container.

  2. From the Edit menu, click Insert New Control.

    The Insert Control dialog box appears.

  3. From the list box, select Circ Control.

  4. Click OK to close the Insert Control dialog box and insert the control into Test Container.

To test the version checking serialization code

  1. From the Edit menu, click Properties... Circ Control Object.

    The Circ Control Properties dialog box appears.

  2. Change the value of the CircleShape property to FALSE (clear the check box and then click OK).

  3. From the Control menu, click Save to Stream or Save to Storage. Name the file as appropriate.

  4. From the Edit menu, click Delete All.

  5. In CIRC.CPP, change the version number to 2.0 by changing the value of the _wVerMajor global constant to 2.

  6. On the Build menu, click Build Circ.ocx to rebuild the control.

  7. From Test Container's Edit menu, click Insert Control from Stream or Insert Control from Storage, as appropriate. Insert your control.

  8. Select the control. From the Edit menu, click Properties... Circ Control Object.

    The Circ Control Properties dialog box appears.

  9. View the value of the CircleShape property in the property page.

    The persistent data saved in step 3 is version 1.0. When the control is recreated in step 6, the control's version is 2.0. Because the persistent data and the control have different versions, the control's persistent properties are initialized to their default values. The stored values are ignored. In particular, the CircleShape property should be TRUE (the check box will be checked).

  10. Change the value of the CircleShape property to FALSE again (clear the check box, then click OK).

  11. From the Control menu, click Save to Stream or Save to Storage. Name the file as appropriate.

  12. From the Edit menu, click Delete All.

  13. From Test Container's Edit menu, click Insert Control from Stream or Insert Control from Storage, as appropriate. Insert your control.

  14. Select the control. From the Edit menu, click Properties... Circ Control Object.

    The Circ Control Properties dialog box appears.

  15. View the value of the CircleShape property using the property page.

    The persistent data saved in step 11 is version 2.0. When the control is recreated in step 13, the control's version is 2.0. Because the persistent data and the control have the same version, the control's persistent properties are set to the stored values. In particular, the CircleShape property should be FALSE (the check box is cleared).

    When you have finished, close Test Container.

If you want your Circle control to match the control found in the sample directories, be sure to restore the control version to 1.0 (change the value of _wVerMajor in CIRC.CPP to 1 and rebuild the control).

This concludes the Circle tutorial.