You can create instances of classes in the Class Browser so you can view instances of those classes. For example, if you create an instance of a form or form class, the form is created and displayed.
|When you create an instance of a class, the code in the Init event and possibly other events runs. Before you create an instance, know what code is associated with your classes. If the class requires a particular environment that has not been set up, Visual FoxPro generates errors. The Class Browser does not provide error handling for user-defined classes.|
To create an instance of a class
Open the class library or form in the Class Browser.
In the class list of the Class Browser, select the class or form you want to create an instance of.
Drag the class icon that appears next to the type list in the Class Browser to the main Visual FoxPro window.
Note: If you drag a form or form class to the main Visual FoxPro window, the form is created and displayed. If you drag a control to the main Visual FoxPro window, the control is added to the _SCREEN object. For more information, see _SCREEN System Variable.
To create an instance of the class without displaying it, press and hold the SHIFT key during the drag operation. To suppress error messages when you create instances, press and hold the CTRL key during the drag operation.
To call the appropriate NEWOBJECT( ) or CREATEOBJECT(В ) function to instantiate the class, you can drag the class icon to the Command window.
To remove an object from the _SCREEN object
Use the RemoveObject method for _SCREEN.
For example, suppose you drag the VCR class from Buttons.vcx class in the Visual FoxPro ...\Samples\Classes directory to a form. You can remove the instance of the class from _SCREEN by typing the following line of code in the Command window: