BUG: Using Scriptlet Control in MFC App causes assertion

ID: Q190838


The information in this article applies to:
  • Microsoft Internet Explorer (Programming) versions 4.0, 4.01, 4.01 SP1, 5.0


SYMPTOMS

When using the Microsoft Scriptlet Component in a Visual C++ MFC SDI application, calling the CWebBridge::Create method causes an assertion in Occsite.cpp at line 1475.


RESOLUTION

If you want to use the Scriptlet Componenet in Visual C++ applications, you must automate the component. Please see the MORE INFORMATION section for an example of how to do this.


STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.


MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a new MFC SDI application using AppWizard.


  2. Add the Microsoft Scriptlet Component to your Project from the Project | Add to Project | Components and Controls menu. Choose "Microsoft Scriptlet Component" from the "Registered ActiveX Controls" folder. This will insert a class named CWebBridge.


  3. Include WebBridge.h into your view class header file with the following line:
    
    #include "WebBridge.h" 


  4. Declare an instance of CWebBridge in your view class like this:
    
    CWebBridge m_webBridge; 


  5. In the implementation of your view class's OnInitialUpdate, create the component like this:
    
    CRect rc;
    m_webBridge.Create(NULL, WS_VISIBLE|WS_CHILD, rc, this,
                       IDC_WEBBRIDGE); 


When you run your application you will receive the assertion described in the SUMMARY section of this article.

Workaround

In order to work around this problem, you can use the #import command to create smart pointer classes for the Microsoft Scriptlet Component. Then you can use this component as you normally would. The following are the steps to follow in order to implement this solution in your code:
  1. Import the Microsoft Scriptlet Component in-proc server DLL into your project by placing the following code in the header file for your view class or in stdafx.h:
    
    #import <mshtmlwb.dll>  // This DLL should be in your system dir
    using namespace WBLib;
    
    #include <comdef.h>     // Needed for Compiler COM support 


  2. Declare an instance of IWebBridgePtr in your view class. IWebBridgePtr is a smart pointer for the IWebBridge interface:
    
    IWebBridgePtr m_webBridge; 


  3. Initialize COM using CoInitialize. You may want to do this in the constructor for your view class or in OnInitialUpdate:
    
    CoInitialize(NULL); 


  4. Create and instance of the Scriptlet Component in OnInitialUpdate.
    
    void CMyView::OnInitialUpdate()
    {
       CView::OnInitialUpdate();
    
       // Create an instance of the Scriptlet Component.
       // Here, I am asking for a pointer to the IWebBridge interface.
       // You could ask for IWBScriptControl or query for it later.
       HRESULT hr = CoCreateInstance(_uuidof(Scriptlet), NULL,
                                     CLSCTX_INPROC_SERVER,
                                     _uuidof(IWebBridge),
                                     (void**)&m_webBridge);
       if (SUCCEEDED(hr))
       {
          // Insert some code here
       }
    } 


  5. Use the Scriptlet Component like normal. For example, if you want to find out if scrollbars are on or off, you would use this code:
    
    BOOL bScrollbar;
    bScrollbar = m_webBridge->GetScrollbar();
    TRACE("Scrollbar is %s\n", bScrollbar ? "on" : "off"); 



REFERENCES

For more information, please see the MSDN Web Workshop:

http://msdn.microsoft.com/workshop/default.asp
Search on "Dynamic HTML Scriptlets."

© Microsoft Corporation 1998, All Rights Reserved.
Contributions by Scott Roberts, Microsoft Corporation

Additional query words:

Keywords : kbCtrl kbIE400bug kbIE401bug kbScript kbIE401sp1bug kbIE500bug
Version :
Platform :
Issue type : kbbug


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