Microsoft KB Archive/182032

= FIX: MsgBox "Permission Denied" Error in WebBrowser Control =

Article ID: 182032

Article Last Modified on 11/24/2003

-

APPLIES TO

 Microsoft Visual Basic, Scripting Edition 1.1 Microsoft Visual Basic, Scripting Edition 2.0 Microsoft Internet Explorer 3.0 Microsoft Internet Explorer 3.01 Microsoft Internet Explorer 3.02 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 4.2 Enterprise Edition

 Microsoft Visual C++ 4.2 Professional Edition</li></ul>

 Microsoft Visual C++ 5.0 Enterprise Edition</li></ul>

 Microsoft Visual C++ 5.0 Professional Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q182032

<div class="symptoms_section">

SYMPTOMS
When navigating to a page in an application that hosts the Microsoft WebBrowser control, you will get the following scripting error message:

Permission Denied

This error occurs specifically at a location in script code where the VBScript method MsgBox is called.

It also occurs if the WebBrowser control is being hosted using Visual C++ and the Microsoft Foundation Classes' (MFC) default control containment support.

<div class="cause_section">

CAUSE
This error occurs because the IOleInPlaceFrame implementation of the control container is not returning S_OK from the EnableModeless method.

MFC's control containment support returns E_NOTIMPL, which causes the scripting engine to not allow a message box to be displayed; hence, the "Permission Denied" error.

<div class="resolution_section">

RESOLUTION
Modify the control container to return S_OK from the IOleInPlaceFrame::EnableModeless method. EnableModeless should prepare the top-level frame for the display or removal of a modal dialog box based on the supplied Boolean parameter. Refer to the documentation for IOleInPlaceFrame::EnableModeless for more information on how to implement this method.

This problem does not occur when hosting the Internet Explorer 4.0 WebBrowser control in an MFC application.

<div class="status_section">

STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug has been corrected in Microsoft Internet Explorer 4.0.

<div class="moreinformation_section">

MORE INFORMATION
MFC containers can use a call to CWinApp::EnableModeless to fully implement this function and return S_OK. Here is a code sample: STDMETHODIMP CMyOleControlContainer::XMyOleIPFrame::EnableModeless(BOOL    f)   { METHOD_PROLOGUE_EX(CMyOleControlContainer, OleIPFrame)

CWinApp* pApp = AfxGetApp; if ( ! pApp ) return E_FAIL;

pApp->EnableModeless( f ); return S_OK; }

<div class="references_section">