采用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;
}
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;
}
解决方案 »
- 为什么我开发的MFC程序有的是XP风格的按钮,有的确是传统的2000风格的按钮?
- 想做个P2P网络电视,不知道思路,大家来说下原理
- win2000共享问题
- 怎么创建一个新创建,而且没有焦点呢?
- 滚动条的莫名其妙问题,在线等
- 大家遇到过这样的问题没有,我用splitterwnd分成上1下2 三个视图,但是~~~~~~~~~~~~~~
- 讨论:ActiveX Controls Developing Giude
- 谁能帮我解释一下帧内预测部分的每一句代码
- CArray 二维动态数组,并且定义的是结构体的动态数组,但二维时不能实现?(在线等)
- sendmessage的执行效率?具体内容请进
- 为何VC6的菜单中的profile是灰色的不能点?
- 请帮忙推荐一款17寸纯平显示器,大概多少钱?
参考的是关于对话框的,现在的问题是关于VIEW的
if (!pView->m_pToolBar->Create(pParent, MAKEINTRESOURCE(nIDResource),
CBRS_TOP, AFX_IDW_PREVIEW_BAR))Assert 那条语句呢?是不是 pParent 为空?
Title.LoadString(IDR_MAINFRAME);
CWnd *pwnd = CWnd::FindWindow(NULL,Title);
g_pAlarmUnitFrame->Create(NULL,"设备信息", WS_OVERLAPPEDWINDOW, CRect(40,60,830,460), pwnd);
这样指定父窗口可以吗
问题依然存在
if (!_AfxCheckDialogTemplate(lpszTemplateName, TRUE))
{
ASSERT(FALSE); // invalid dialog template name <<=====问题所在
PostNcDestroy(); // cleanup if Create fails too soon
return FALSE;
}
以上是跟踪到的问题所在