Microsoft KB Archive/190838

= BUG: Using Scriptlet Control in MFC App causes assertion =

Article ID: 190838

Article Last Modified on 5/11/2006

-

APPLIES TO


 * Microsoft Internet Explorer 4.0 128-Bit Edition
 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Internet Explorer 4.01 Service Pack 1
 * Microsoft Internet Explorer 5.0
 * Microsoft Internet Explorer 5.01
 * Microsoft Internet Explorer 5.5

-



This article was previously published under Q190838



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 that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
 Create a new MFC SDI application using AppWizard. 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.  Include WebBridge.h into your view class header file with the following line:   Declare an instance of CWebBridge in your view class like this: CWebBridge m_webBridge;   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);   Open resource.h from your program's directory and add the following: </li> Compile and run your application.</li></ol>
 * 1) include "WebBridge.h"
 * 1) define IDC_WEBBRIDGE 500

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: <ol>  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: using namespace WBLib;
 * 1) import <mshtmlwb.dll> // This DLL should be in your system dir

</li>  Declare an instance of IWebBridgePtr in your view class. IWebBridgePtr is a smart pointer for the IWebBridge interface: IWebBridgePtr m_webBridge; </li>  Initialize COM using CoInitialize. You may want to do this in the constructor for your view class or in OnInitialUpdate: CoInitialize(NULL); </li>  Create and instance of the Scriptlet Component in OnInitialUpdate. void CMyView::OnInitialUpdate {  CView::OnInitialUpdate;
 * 1) include <comdef.h>    // Needed for Compiler COM support

// 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 } }                   </li>  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"); </li></ol>

<div class="references_section">