PRB: Form Cannot Get Focus After You Use SetParent to Move Controls to Another Form (289498)
The information in this article applies to:
- Microsoft Visual Basic Enterprise Edition for Windows 5.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
- Microsoft Visual Basic Professional Edition for Windows 5.0
- Microsoft Visual Basic Professional Edition for Windows 6.0
This article was previously published under Q289498 SYMPTOMS
If you use the SetParent function to move a TextBox control from one form to another and then click the TextBox on the new parent form, you cannot click the original parent form to set the focus back to it.
RESOLUTION
To work around this problem, use the SetWindowLong function to change the TextBox control's window style to WS_CHILD, either before or after the call to SetParent, and then make the control visible. For example, if Text1 is moved from Form1 to Form2, use the following code to resolve this problem:
SetParent Text1.hwnd, Form2.hwnd
SetWindowLong Text1.hwnd, GWL_STYLE, WS_CHILD
Text1.Visible = True
For additional information, see the code sample in the "More Information" section.
REFERENCESFor additional information, click the article number below
to view the article in the Microsoft Knowledge Base:
253814 PRB: SetParent Does Not Change Standard Forms into Child Windows
Modification Type: | Major | Last Reviewed: | 5/15/2001 |
---|
Keywords: | kbAPI kbCtrl kbDSupport kbprb KB289498 |
---|
|