How to Reset the Parent of a Visual Basic ControlLast reviewed: June 21, 1995Article ID: Q80189 |
The information in this article applies to:
- Standard and Professional Editions of Microsoft Visual Basic for Windows, versions 2.0 and 3.0- Microsoft Visual Basic programming system for Windows, version 1.0
SUMMARYVisual Basic version 1.0 does not support overlapping controls. This can be a problem if you want to drag and drop a control from one parent control to another parent control. Using the Windows API SetParent() function call, you can change a control's parent within Visual Basic. Visual Basic versions 2.0 and 3.0 support overlapping controls with the z-order method. For more information on the z-order method, search for the z-order topic in the Visual Basic Help menu.
MORE INFORMATIONA frame, picture box, and form can act as parent controls. Creating a control on top of any of these parent controls creates that control as a child of the parent. When you use the Drag operations, there may be times when you want to move a child control from one parent control to another parent. If you allow the movement and don't change the child's parent, you are creating overlapping controls, which are not supported in Visual basic. The SetParent function changes the parent of a child control. SetParent has the following description:
SetParent%(ByVal hWndChild, ByVal hWndParen%)
Parameter Type/Description ---------- ---------------- hWndChild HWnd/Identifies the child window hWndParent HWnd/Identifies the parent windowThe returned value identifies the previous parent window.
Step-by-Step ExampleThe example below demonstrates how to drag and drop a text box between the form and a picture box on the form. The parent controls are the picture box and the form. The child control is the text box.
Demonstration StepsTry the following steps when running the application:
|
Additional reference words: 1.00 2.00 3.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |