采用MFC进行打印预览出现如下的错误:
Debug Assertion Failed!File: bardlg.cpp
Line: 48跟踪到出问题的地方是:pView->m_pToolBar = new CDialogBar;
if (!pView->m_pToolBar->Create(pParent, MAKEINTRESOURCE(nIDResource),
CBRS_TOP, AFX_IDW_PREVIEW_BAR))请问如何解决问题该问题调用的代码如下:void CNo3ListView::OnFilePrintPreview() 
{
// TODO: Add your specialized code here and/or call the base class
CListView::OnFilePrintPreview();
}主窗口代码如下:int CNo3Frame::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;// TODO: Add your specialized creation code here
m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
m_wndStatusBar.SetPaneInfo(1,ID_SEPARATOR,SBPS_NORMAL,200);m_wndToolBar.LoadToolBar(IDR_TOLB_FY);CNo3ListView *m_pView = new CNo3ListView;
if (!m_pView->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
{
TRACE0("Failed to create view window\n");
return -1;
}
SetActiveView((CView*)m_pView);return 0;
}

解决方案 »

  1.   

    可以参考这个:http://www.vckbase.net/document/viewdoc/?id=1270
      

  2.   

    楼上你好
    参考的是关于对话框的,现在的问题是关于VIEW的
      

  3.   

    Debug Assertion Failed!pView->m_pToolBar = new CDialogBar;
    if (!pView->m_pToolBar->Create(pParent, MAKEINTRESOURCE(nIDResource),
    CBRS_TOP, AFX_IDW_PREVIEW_BAR))Assert 那条语句呢?是不是 pParent 为空?
      

  4.   

    CString Title;
    Title.LoadString(IDR_MAINFRAME);
    CWnd *pwnd = CWnd::FindWindow(NULL,Title);
    g_pAlarmUnitFrame->Create(NULL,"设备信息", WS_OVERLAPPEDWINDOW, CRect(40,60,830,460), pwnd);
    这样指定父窗口可以吗
    问题依然存在
      

  5.   

    // dialog template must exist and be invisible with WS_CHILD set
    if (!_AfxCheckDialogTemplate(lpszTemplateName, TRUE))
    {
    ASSERT(FALSE);          // invalid dialog template name <<=====问题所在
    PostNcDestroy();        // cleanup if Create fails too soon
    return FALSE;
    }
    以上是跟踪到的问题所在