Microsoft KB Archive/184200

= FIX: Error 405: "Unable to Show Modal Form Within this Context" =

Article ID: 184200

Article Last Modified on 5/12/2003

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Learning Edition
 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q184200



SYMPTOMS
When opening a form from an ActiveX DLL, you may receive the following error:

Unable to show modal form within this context."



CAUSE
This error occurs when all of the following are true:
 * The computer is running Windows 95, Windows 98, or Windows Me.
 * The ActiveX DLL has been compiled.
 * The client application is in the Visual Basic IDE.
 * The client application form has a BorderStyle property set to Dialog.
 * The ActiveX DLL form has been previously opened.



RESOLUTION
Set the BorderStyle of the form in the client application to Fixed Single, and remove the Min and Max buttons from the form. This results in the form behaving in the same manner as a form with a Dialog BorderStyle.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available. This problem no longer occurs in Windows 2000.



Steps to Reproduce Behavior
  Create an ActiveX DLL in Visual Basic. Name the project "SrvDialog." Place the following code in Class1: Option Explicit Public Sub ShowDialog Form2.Show 1 End Sub

  Add a form to the project. Change the Name and Caption properties to "Form2." Place the following code on Form2: Option Explicit Private Sub Form_Click Unload Me      End Sub

 Compile the DLL. Create a Standard EXE project in Visual Basic. Form1 is created by default. Make a reference to SrvDialog.DLL.  Change the BorderStyle property of Form1 to 3 (Fixed Dialog). Place a CommandButton on Form1, and place the following code on Form1: Option Explicit Private Sub Command1_Click Dim x As New SrvDialog.Class1 x.ShowDialog Set x = Nothing End Sub

</li> Run the client application. Click Command1.</li> Click Form2 to unload that form.</li> Click Command1 again and note that Error 405 occurs.</li></ol>

Keywords: kbbug kbfix kbserver kbdll kbforms KB184200

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.