Microsoft KB Archive/247791

From BetaArchive Wiki
Knowledge Base


Article ID: 247791

Article Last Modified on 1/6/2004



APPLIES TO

  • Microsoft Visual C++ 5.0 Professional Edition
  • Microsoft Visual C++ 6.0 Professional Edition
  • Microsoft Visual Basic 5.0 Professional Edition
  • Microsoft Visual Basic 6.0 Professional Edition



This article was previously published under Q247791

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:

171978 Non-Modal Forms Support in Visual Basic DLLs



Additional query words: VBASDK

Keywords: kbprb KB247791