Problem: MFC application with CHtmlView-derived view may stay running invisibly after closure if Active Accessibility client used

Problem: MFC application with CHtmlView-derived view may stay running invisibly after closure if Active Accessibility client used

Article ID : 954251
Last Review : June 10, 2008
Revision : 1.0
Source: Microsoft Support

Back to the top

RAPID PUBLISHING

RAPID PUBLISHING ARTICLES PROVIDE INFORMATION DIRECTLY FROM WITHIN THE MICROSOFT SUPPORT ORGANIZATION. THE INFORMATION CONTAINED HEREIN IS CREATED IN RESPONSE TO EMERGING OR UNIQUE TOPICS, OR IS INTENDED SUPPLEMENT OTHER KNOWLEDGE BASE INFORMATION.

Back to the top

Action

1. Create a MFC Document/View application with CHtmlView as the base class for the application view.
2. Turn On and use an Active Accessibility Client application like Magnifier. Clients may also include accessibility aids, automated testing tools, and some computer-based training applications.

Back to the top

Result

Your application may stay running without a window (and be listed in Task Manager) even after it has been closed.

Back to the top

Cause

CFormView is the base class for CHtmlView which enables the Active Accessibility support for the application by calling EnableActiveAccessibility() in the class constructor. This in turn creates accessible interface objects responsible to communicate with the client application. The problem created by CHtmlView, unlike other CFormViews, is that it bypasses the cleanup for active accessibility thus causing the application to stay loaded. This can be clearly seen by overriding CHtmlView:OnDestroy() which by default does nothing.

We have also seen that the implementation of the Magnifier (magnify.exe) in Windows versions prior to Vista will not always release references to the accessibility objects.

Back to the top

Resolution

There are two known workarounds for this issue.  Use either one, according to your needs or preferences:

1. Override the CHtmlView-derived class OnDestroy handler to call CFormView::OnDestroy() and post a WM_QUIT to the main thread by calling PostQuitMessage().

void CTestHtmlView::OnDestroy()
{

      CFormView::OnDestroy();

      PostQuitMessage(0);

}

2. Override the CHtmlView derived class OnDestroy handler to release the Active Accessibility objects and post a WM_QUIT to the main thread by calling PostQuitMessage(). 

void CTestHtmlView::OnDestroy()
{
      if (m_pProxy != NULL)
      {
            m_pProxy->SetServer(NULL, NULL);
            m_pProxy = NULL;
      }
      if (m_pStdObject != NULL)
      {
            m_pStdObject->Release();
            m_pStdObject = NULL;
      }

      PostQuitMessage(0);
}

Back to the top

More Information

How Active Accessibility Works (http://msdn.microsoft.com/en-us/library/ms697335(VS.85).aspx)

Back to the top

DISCLAIMER

MICROSOFT AND/OR ITS SUPPLIERS MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY, RELIABILITY OR ACCURACY OF THE INFORMATION CONTAINED IN THE DOCUMENTS AND RELATED GRAPHICS PUBLISHED ON THIS WEBSITE (THE “MATERIALS”) FOR ANY PURPOSE. THE MATERIALS MAY INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS AND MAY BE REVISED AT ANY TIME WITHOUT NOTICE.

TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, MICROSOFT AND/OR ITS SUPPLIERS DISCLAIM AND EXCLUDE ALL REPRESENTATIONS, WARRANTIES, AND CONDITIONS WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO REPRESENTATIONS, WARRANTIES, OR CONDITIONS OF TITLE, NON INFRINGEMENT, SATISFACTORY CONDITION OR QUALITY, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THE MATERIALS.

Back to the top


APPLIES TO
• Microsoft Visual Studio 2008 Academic Edition
• Microsoft Visual Studio 2008 Professional Edition
• Microsoft Visual Studio 2008 Standard Edition
• Microsoft Visual Studio Team System 2008 Database Edition
• Microsoft Visual Studio Team System 2008 Architecture Edition
• Microsoft Visual Studio Team System 2008 Development Edition
• Microsoft Visual Studio Team System 2008 Test Edition
• Microsoft Visual Studio Team System 2008 Team Foundation Server
• Microsoft Visual Studio Team System 2008 Team Suite
• Microsoft Visual Studio 2005 Express Edition
• Microsoft Visual Studio 2005 Professional Edition
• Microsoft Visual Studio 2005 Service Pack 1
• Microsoft Visual Studio 2005 Standard Edition
• Microsoft Visual Studio 2005 Team Edition for Software Architects
• Microsoft Visual Studio 2005 Team Foundation Server
• Microsoft Visual Studio 2005 Standard Edition academic license
• Microsoft Visual Studio 2005 Team Edition for Database Professionals
• Microsoft Visual Studio .NET 2003 Enterprise Architect
• Microsoft Visual Studio .NET 2003 Enterprise Developer
• Microsoft Visual Studio .NET 2003 Professional Edition
• Microsoft Visual Studio .NET 2003 Professional Special Edition
• Microsoft Visual Studio .NET 2003 Service Pack 1
• Microsoft Visual Studio .NET 2003 Academic Edition
• Microsoft Visual Studio 2005 Team Edition for Software Developers
• Microsoft Visual Studio 2005 Team Edition for Software Testers

Back to the top

Keywords: 
kbnomt kbrapidpub KB954251

Back to the top

 

Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
Microsoft Corporation. All rights reserved. Terms of Use | Trademarks


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

Leave a Reply

*
To prove that you're not a bot, enter this code
Anti-Spam Image