How to Use a Container Object Instead of a Custom ObjectID: Q132356 The information in this article applies to:
SUMMARYThis article describes how you can use the container control instead of the custom control to obtain additional functionality for your custom controls.
MORE INFORMATIONThe container and custom classes are both Visual FoxPro base classes. Both can contain member objects that are user-defined controls. An object based on the custom class does not have a visual representation and receives the Init, Destroy, and Error events. On another hand, the container class has a visual representation. An object based on the Container class can receive the following events: Click, DragDrop, GotFocus, MouseDown, MouseMove, Resize, Destroy, Error, LostFocus, MouseUp, and UiEnable. The container class is therefore more versatile than the custom class. If you plan on performing operations that require a visual representation, such as moving an object to an area and using the DragDrop event, an object based on the Container class might be appropriate. If you do not want to represent the container visually, you can set the Visible property of the container to false (.F.). For more information about the Container and Custom classes, search for Container object and Custom object in the Visual FoxPro Help file. The following code sample shows how to use an object based on the Container class. In this code, a form is drawn that contains a container and a command button. The command button is dragged to the container. To run this code, copy and paste it into a program (.PRG) file. Once the form is displayed, drag the command button to the left, and drop it in the container. This functionality could not be achieved with a custom class.
Code SamplePUBLIC oForm oForm=CREATEOBJECT('MYFORM') oForm.SHOW *:************************************************************************* *: *: Class:MYFORM BaseClass: FORM *: *:************************************************************************* DEFINE CLASS MYFORM AS FORM ENDDEFINE
*:************************************************************************* *: *: Class:MYCONTAINER BaseClass: CONTAINER *: *:************************************************************************* DEFINE CLASS Mycontainer AS CONTAINER ENDDEFINE
Additional reference words: 3.00 VFoxWin KBCategory: kbprg kbcode KBSubcategory: FxprgClassoop |
Last Reviewed: July 28, 1995 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |