Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

BUG: Using Scriptlet Control in MFC App causes assertion


View products that this article applies to.

This article was previously published under Q190838

↑ Back to the top


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.

↑ Back to the top


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.

↑ Back to the top


Status

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

↑ Back to the top


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);
    					
  6. Open resource.h from your program's directory and add the following:
    #define IDC_WEBBRIDGE 500
    					
  7. Compile and run your application.
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");
    					

↑ Back to the top


References

For more information about developing Web-based solutions for Microsoft Internet Explorer, visit the following Microsoft Web sites: Search on "Dynamic HTML Scriptlets."

↑ Back to the top


Keywords: kbbug, kbctrl, kbpending, kbscript, KB190838

↑ Back to the top

Article Info
Article ID : 190838
Revision : 3
Created on : 5/11/2006
Published on : 5/11/2006
Exists online : False
Views : 507