Microsoft KB Archive/262441

= PRB: Run-Time Error Message '400' : Form Already Displayed ; Can't Show Modally =

Article ID: 262441

Article Last Modified on 1/11/2001

-

APPLIES TO


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

-



This article was previously published under Q262441



SYMPTOMS
When you try to display a modal dialog box window in the Click event of a TabStrip control from Microsoft Windows Common Controls 6.0 Service Pack 3 (SP3), you receive the following error message:

Run-time error '400' :

Form already displayed ; can't show modally.

This message appears only with the service pack 3 version of Mscomctl.ocx.



CAUSE
This behavior occurs because the mouse capture is not released, so all of the mouse inputs still go to the TabStrip control window instead of the modal window.



RESOLUTION
Make a call to the ReleaseCapture API function before displaying the modal form. This releases the mouse capture from the TabStrip control window and restores normal mouse input processing.



Steps to Reproduce Behavior
 Create a Standard EXE project in Visual Basic. Form1 is added by default. From the Project menu, add another form, Form2, to the project. On the Project menu, click Components, click to select Microsoft Windows Common Controls 6.0 (SP3) on the Components dialog box, and then click OK. Add a TabStrip control to Form1 from the Toolbox.  In the General Declarations section for Form1, paste the following code: Private Sub TabStrip1_Click Form2.Top = Form1.Top + Form1.Height Form2.Show vbModal End Sub  Run the project and click the TabStrip control to display Form2.</li> Click the TabStrip control again and note that the error described in the &quot;Symptoms&quot; section is displayed.</li></ol>

Workaround
<ol>  To work around the problem, paste the following API declaration in the general Declaration Section for Form1: Private Declare Function ReleaseCapture Lib &quot;user32&quot; Alias _ &quot;ReleaseCapture&quot; As Long </li>  Modify the TabStrip1_Click event on Form1 as follows: Private Sub TabStrip1_Click ReleaseCapture Form2.Show vbModal End Sub </li> Run the test again and note that the error does not appear.</li></ol>

Additional query words: 400

Keywords: kbapi kbcmnctrls kbtabctrl kbprb kbctrl kbpending KB262441

-

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

© Microsoft Corporation. All rights reserved.