You receive an "Unable to get the window handle" exception when you display a child form that contains ActiveX user controls (814736)
The information in this article applies to:
- Microsoft Visual Basic 2005
- Microsoft Visual Basic .NET (2003)
- Microsoft Visual Basic .NET (2002)
- Microsoft Visual C# .NET (2003)
- Microsoft Visual C# .NET (2002)
- Microsoft Visual Basic Enterprise Edition for Windows 4.0
- the operating system: Microsoft Windows 98
SYMPTOMSYou create a Microsoft Windows form (such as Form1), and
then you set the IsMdiContainer property of the form to True. You create a Microsoft Visual Basic 6.0 user control, and then
you add the user control to a Windows form (Form1) in Microsoft Visual Studio
.NET or in Microsoft Visual Studio 2005. If you create the Windows form as the parent form of another Windows form
that contains user controls, you display the child form, and then you run the
application on a computer that runs on the Microsoft Windows 98 operating
system, you receive the following error message: System.InvalidOperationException: Unable to get the window handle
for the 'AxUserControl1' control. Windowless ActiveX controls are not
supported. Note This article assumes that Visual Basic 6.0 and Microsoft .NET
Framework 1.0 are installed on your computer with Windows 98. CAUSEWhen you create a Windows form that contains user controls as
a multiple-document interface (MDI) child form, the Windows form always
destroys the child form, and then re-creates the child form. The Windows form
destroys all the controls on the child form, and then re-creates the controls.
However, the first user control is destroyed, but it is not re-created. The
second user control is not destroyed or re-created. Therefore, you receive the
error when you display the child form, because the first user control hwnd is
NULL.WORKAROUNDTo work around this problem, put the user controls in a Panel control. To do this, follow these steps:
- From the toolbox, drag a Panel control to
Form1.
By default, Panel1 is created. - Move two user controls to Panel1.
- On the Build menu, click Build
Solution.
- In the Bin subfolder of the
WindowsApplication1 project folder, copy the
WindowsApplication1.exe file, and then paste the file in the
Setup1 folder on the computer that runs on Windows 98.
STATUS This
behavior is by design.REFERENCESFor more information, visit the following MSDN Web site:
Modification Type: | Minor | Last Reviewed: | 10/3/2006 |
---|
Keywords: | kbvs2005swept kbvs2005applies kbHotfixServer kbQFE kbsetup kbDeployment kbWindowsForms kbMDI kbCtrl kbControl kbprb KB814736 kbAudDeveloper |
---|
|