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

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

Article ID : 956003
Last Review : July 21, 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

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.

Back to the top

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));

        …
}

Back to the top

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.

Back to the top

Resolution

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

Back to the top

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 (http://msdn.microsoft.com/en-us/library/bb982033.aspx)

Reference

CMFCRibbonBar Class (http://msdn.microsoft.com/en-us/library/bb983906.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

Back to the top

Keywords: 
kbnomt kbrapidpub KB956003

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