Help and Support

FIX: ASSERT in WinOcc.cpp when Hosting a WebBrowser Control in an MFC Container

Article ID:231578
Last Review:November 21, 2006
Revision:2.1
This article was previously published under Q231578
On This Page

SYMPTOMS

Take a CHtmlView based application or have a dialog hosting a web browser control. Go to a local folder. Right-click and select either New Folder or one of the file types listed there. It will ASSERT in WinOcc.cpp, Line 331. This does not have any impact on the release build.

Back to the top

CAUSE

This is due to a bug in MFC for UI activation of an ActiveX control.

Back to the top

RESOLUTION

Override the PreTranslateMessage function in the dialog class or the one derived from CHtmlView. If the message is WM_RBUTTONDOWN, return 0. The code should look like this:

BOOL CMyDialog::PreTranslateMessage(MSG* pMsg) 
{
	if (pMsg->message == WM_RBUTTONDOWN)
		return 0;

	return CDialog::PreTranslateMessage(pMsg);
}
				


This eliminates the possibility of having a context menu for the container.

Back to the top

STATUS

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

This problem was corrected in Visual C++ 6.0.

Back to the top

MORE INFORMATION

Steps to Reproduce Behavior

1.Generate an AppWizard application and select CHtmlView class as the base class of your view class in Step 6 of the AppWizard.
2.Provide a valid path to one of the local folders. Modify the OnInitialUpdate of the view class as shown below:

void CMyHTMLView::OnInitialUpdate()
{
	CHtmlView::OnInitialUpdate();

	Navigate2(_T("C:\\Temp"),NULL,NULL);
}
						
3.Build the EXE and run it.
4.Right-click inside the view and select New Folder.

Back to the top


APPLIES TO
Microsoft Foundation Class Library 4.2, when used with:
  Microsoft Visual C++ 5.0 Enterprise Edition

Back to the top

Keywords: 
kbbug kbcontainer kbctrl kbfix kbnoupdate kbwebbrowser KB231578

Back to the top

Article Translations

 

Other Support Options

  • Contact Microsoft
    Phone Numbers, Support Options and Pricing, Online Help, and more.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.