How to Find Out If an Object Is in a Container or NotID: Q134621 The information in this article applies to:
SUMMARYThis article describes how to use the TYPE() function to find out whether or not an object is contained in another object.
MORE INFORMATIONIt is sometimes necessary to know if an object is in a container, and perform an action according to the way an instance of the object is created. For example, a form can be placed on the desktop or in a formset, and the program can perform different tasks depending on the container. The Parent property of an object references the container object of a control. Use the TYPE() function to determine if an object has a parent. For example:
The following example illustrates this method using a command button. If
the control is placed in a toolbar, the Visible property of the toolbar is
set to false (.F.) when the button is released. To run this example, copy
and paste the code into a program (.PRG) file. When the toolbar is
displayed, click the Close button. The toolbar is hidden before it is
released.
Sample CodePUBLIC oTB1,oFrm1 && Define public variables oTb1=CREATE('tbmytool') && Create an instance of the toolbar object oTb1.SHOW oFrm1=CREATE('Frmmyform') && Create an instance of the form object oFrm1.SHOW DEFINE CLASS cmdQuit AS COMMANDBUTTON ENDDEFINE
DEFINE CLASS tbMyTool AS TOOLBAR ENDDEFINE
DEFINE CLASS frmmyform AS FORM ENDDEFINE
Additional reference words: VFoxWin 3.00 form set KBCategory: kbprg kbcode KBSubcategory: FxprgClassoop |
Last Reviewed: August 10, 1995 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |