PRB: Modeless Forms in VB ActiveX DLL's Don't Display in VC++ Clients

ID: Q247791


The information in this article applies to:
  • Microsoft Visual C++, 32-bit Professional Edition, versions 5.0, 5.0sp1, 5.0sp2, 5.0sp3, 6.0
  • Microsoft Visual Basic Professional Edition for Windows, versions 5.0, 6.0


SYMPTOMS

Modeless forms in Visual Basic ActiveX DLLs do not display in a Visual C++ application. Instead, a dialog box comes up informing the user that the client doesn't support Modeless Forms.


CAUSE

In order to work properly, a Visual Basic modeless form requires access to the message loop of the client application. This access is provided by a COM object known as the Component Manager, which is integrated directly into the message loop of the client application. In order to determine if the client supports modeless forms, Visual Basic gets a reference to the message filter for the application, and calls IUnknown::QueryInterface for the Component Manager's primary interface. If this works, modeless forms can be supported. If it fails, the client cannot support modeless forms.


RESOLUTION

To allow in-process components to detect at run time whether a client application supports the display of modeless forms, Visual Basic provides the Boolean NonModalAllowed property of the App object.

An in-process component should test this property before showing a modeless form. If the value is True, the form can be shown vbModeless. If the value is False, showing a modeless form causes run-time error 369. The component should degrade gracefully by showing the form vbModal instead.

For example:


If App.NonModalAllowed Then
   Form1.Show vbModeless
Else
   Form1.Show vbModal
EndIf 


STATUS

This behavior is by design.


REFERENCES

For additional information about Visual Basic Modeless Forms, please click the article number(s) below to view the article(s) in the Microsoft Knowledge Base:

Q171978 Non-Modal Forms Support in Visual Basic DLLs

Additional query words: VBASDK

Keywords : kbSDKVBA kbGrpDSO kbDSupport
Version : WINDOWS:5.0,6.0; winnt:5.0,5.0sp1,5.0sp2,5.0sp3,6.0
Platform : WINDOWS winnt
Issue type : kbprb


Last Reviewed: December 20, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.