The information in this article applies to:
SUMMARYThe following article contains the complete contents of the TN002.TXT file installed in the CDK directory of the Professional Edition of Visual Basic version 3.0 for Windows. MORE INFORMATIONTN002.TXTMicrosoft Visual Basic version 3.00 for WindowsMicrosoft Corporation Technical Notes TN002.TXT: Custom Control Version Management This note describes how to use the version management functionality for custom controls. IntroductionVisual Basic provides upward compatibility for custom controls. This means that a custom control created for Visual Basic version 1.0 will run in Visual Basic versions 2.0 and 3.0. If a custom control uses version- specific features, a custom control can always explicitly test for a specific version during initialization and thereby determine whether or not to load.There are cases, however, when a Visual Basic application created with a new version of a custom control runs on a system with an older version of the custom control. Depending on the features and implementation of the custom control, the application may not work correctly -- or worse, may cause VB.EXE or VBRUNx00.DLL to crash. The following sections describe Visual Basic version 3.0's custom control version management system, which can help avoid potential application failure. MODEL StructureThis is the definition of the MODEL structure used in Visual Basic version 3.0. Note the addition of the last field (USHORT usCtlVersion).
Control VersionA custom control developer who wants to take advantage of the version management feature in Visual Basic version 3.0 needs to provide a valid version number in the usCtlVersion field. This value must be an unsigned integer (USHORT), and it should be changed any time the custom control changes its backward compatibility with previous versions.Although any nonzero value is valid, the values 1 and 2 should not be used. Because Visual Basic versions 1.0 and 2.0 do not support version management, Visual Basic automatically assigns values 1 and 2 to any custom control that has the usVersion field in the control's MODEL structure set to VB100_VERSION and VB200_VERSION, respectively. In order to take advantage of version management, you must set the usVersion field of the control's MODEL structure to VB300_VERSION or greater, or use VB_VERSION defined in a Visual Basic version 3.0 VBAPI.H file. This allows Visual Basic to determine whether the usCtlVersion field is defined in the MODEL structure of a given custom control. If the custom control contains a value of 0 in the usCtlVersion field, no version control checks are made on this custom control. How the System WorksWhen you create a Visual Basic executable (.EXE) file that uses a custom control, Visual Basic retrieves the control version number (usCtlVersion) for that control and stores it in a special section of the .EXE file.When you execute the application, the Visual Basic run-time support file (VBRUN300.DLL or greater) checks the control version number recorded in the .EXE file against the version number found in the custom control when it is loaded into the system. If the version found in the .EXE file is greater than the version of the control loaded into the system, Visual Basic displays a notification that the particular custom control (.VBX file) is out of date and will not load, consequently forcing the application to terminate. Additional query words: 3.00
Keywords : |
Last Reviewed: January 25, 2000 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |