Determine Whether VBX Support Is Enabled at Run Time

Last reviewed: July 22, 1997
Article ID: Q117777
1.00 1.50 WINDOWS kbprg

The information in this article applies to:

  • The Microsoft Foundation Classes (MFC) included with:

        - Microsoft Visual C++ for Windows, versions 1.0 and 1.5
    

SUMMARY

The MFC class library provides support for using VBX controls in a 16-bit Windows-based application. You can call CWinApp::EnableVBX to enable use of VBX controls. You can also determine whether VBX support has been enabled in an MFC program as it is running. This article presents two possible methods of determining whether VBX support has been enabled in applications on MFC, versions 2.0 and 2.5.

NOTE: Both of these methods rely on the use of implementation-specific details of MFC, versions 2.0 and 2.5. The techniques presented here are not guaranteed to function correctly in future versions of MFC.

MORE INFORMATION

Use one of the following methods to determine whether VBX support has been loaded:

  • Check whether the proxy window class associated with VBX controls has been registered. You can do this by writing a global function that attempts to locate the window class, such as the following:

          BOOL IsVBXEnabled()
          {
    
             WNDCLASS ClsInfo;
    
             memset(&ClsInfo,0,sizeof(WNDCLASS));
             return ::GetClassInfo(AfxGetInstanceHandle(),"VBControl",
       &ClsInfo);
          }
    
       -or-
    
    
  • Check your class derived from CWinApp to see whether m_lpfnCleanupVBXFiles is non-NULL. If this member is non-NULL, VBX support has been enabled; otherwise, the member is NULL. For example, suppose that CMyApp is the name of your class that is derived from CWinApp. The following member function can be added to check for VBX support:

          BOOL CMyApp::IsVBXEnabled()
          {
    
             return m_lpfnCleanupVBXFiles != NULL;
          }
    
       This function can be called in any part of your program by including
       the header file for your CWinApp-derived class and using the following:
    
             ((CMyApp*)AfxGetApp())->IsVBXEnabled();
    


Additional reference words: kbinf 1.00 1.50 2.00 2.50 EnableVBX
KBCategory: kbprg
KBSubcategory: MfcVBX
Keywords : kb16bitonly
Technology : kbMfc


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 22, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.