BUG: MFC Feature Pack wizard generated code with CFormView-derived view shows Debug Assertion

Article ID: 956003 - View products that this article applies to.
Expand all | Collapse all
Source: Microsoft Support

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.

Action


Note: This article applies to the Visual C++ 2008 Feature Pack
  1. Create a MFC Document/View application.
  2. Under Application Type, select the Project style as “Office”.
  3. Select Use of MFC as “static library”, Click Next.
  4. Under Generated Classes, select the CFormView as base class for application view.
  5. Click Finish.
  6. A message will appear saying “No printing support will be available for CFormView”. Click Yes.
  7. Build and Run your application.

Result



The application shows a debug assertion on f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxribbonbar.cpp, Line: 3891



The following function shows the assertion:

CMFCRibbonCategory* CMFCRibbonBar::AddPrintPreviewCategory()
{
        ...
    // This line shows the assertion
    ENSURE(str1.LoadString(AFX_IDS_ONEPAGE));

        ...
}







Cause

During the initialization of ribbon bar control, the application calls SetQuickAccessDefaultState() to set the Quick Access Toolbar. Inside this function, the ribbon bar tries to recalculate its layout by calling RecalcLayout() function. This function internally checks if printing is supported by the class, then it adds it to the Print Preview Category. While adding it to this category, the application tries to load a printing string resource with ID AFX_IDS_ONEPAGE. Since this resource ID is not part of the application instance, loading it shows an debug assertion.

Resolution



Disable the Print Preview for Ribbon Bar. This can be done using CMFCRibbonBar::EnablePrintPreview function.

More Information







This is a know bug with the wizard-generated code. CFormView classes do not have printing support. After creating the project, the wizard does prompt the message “No printing support will be available for CFormView”, but it fails to generate correct code for ribbon bar for disabling the printing.

Making the following change allows it to work.

void CMainFrame::InitializeRibbon()

{

            ...

            // Disable the Print Preview for Ribbon Bar

            m_wndRibbonBar.EnablePrintPreview(FALSE);

            m_wndRibbonBar.SetQuickAccessCommands(lstQATCmds);

            ...

}

As the application links statically to MFC, the ID will not be available in the application instance. All standard MFC resources are selectively built or not built into your module, based on wizard selections. For dynamic link they are always part of the MFC80[u][d].dll.





See Also

Concepts

MFC Hierarchy Chart

Reference

CMFCRibbonBar Class

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.

Properties

Article ID: 956003 - Last Review: July 21, 2008 - Revision: 1.0
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
Keywords: 
kbnomt kbrapidpub KB956003

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com