Debug Assertion Failed! FILE viewform.cpp , line 69
来源:互联网 发布:木材建筑知乎 编辑:程序博客网 时间:2024/06/05 17:48
学习mfc时遇到了与下面类似的问题,折磨了好几天也找不出个所以然来,偶然看到了下面的文章很轻松就解决了,特转载一下共学之
Debug Assertion Failed! FILE viewform.cpp , line 69
2 {
3 CView *pOldActiveView = GetActiveView();
4 if (pOldActiveView->IsKindOf(pViewClass) == TRUE) {
5 return;
6 }
7 CCreateContext context;
8 context.m_pNewViewClass = pViewClass;
9 context.m_pCurrentDoc = GetActiveDocument();
10 context.m_pLastView = NULL;
11 context.m_pNewDocTemplate = NULL;
12 context.m_pCurrentFrame = NULL;
13 CView *pNewView = (CView *)CreateView(&context);
14 if (pNewView != NULL) {
15 pNewView->ShowWindow(SW_SHOW);
16 pNewView->OnInitialUpdate();
17 SetActiveView(pNewView);
18 RecalcLayout();
19
20 pOldActiveView->DestroyWindow();
21 }
22 }
分割窗口时CFormView与Pane关联时出现的问题
分割窗口时,其中一个窗格Pane,所关联的视,这个视若是从 CEditView, CTreeView, CView等类导出的,则没有问题,若是从 CFormView导出的, 那么编译正常,但执行那个时会出现
---------------------------
Microsoft Visual C++ Debug Library
---------------------------
Debug Assertion Failed!
Program: D:\VC_PROJECT\testMultiPane\Debug\testMultiPane.exe
File: viewform.cpp
Line: 69
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
---------------------------
Abort(A) Retry(R) Ignore(I)
---------------------------
错误,
原因是 CFormView 的导出类,需要与一个Dialog资源关联,这个Dialog的属性必须是ws_child,Style必须选 “下层”SystemMenu和TitleBar属性最好都设为False
参见 http://www.cnweblog.com/vcbird/archive/2005/10/10/36404.html
以前在出现
错误提示时,不知如何处理,在这次通过点击“重试”,debugger停在了
the debugge point to this line
Code:
ASSERT(FALSE); // invalid dialog template name
which appears in the following code snippet of the file VIEWFORM.cpp
Code:
BOOL CFormView::Create(LPCTSTR /*lpszClassName*/, LPCTSTR /*lpszWindowName*/,
DWORD dwRequestedStyle, const RECT& rect, CWnd* pParentWnd, UINT nID,
CCreateContext* pContext)
{
ASSERT(pParentWnd != NULL);
ASSERT(m_lpszTemplateName != NULL);
m_pCreateContext = pContext; // save state for later OnCreate
#ifdef _DEBUG
// dialog template must exist and be invisible with WS_CHILD set
if (!_AfxCheckDialogTemplate(m_lpszTemplateName, TRUE))
{
ASSERT(FALSE); //<====== debugger stops at this line // invalid dialog template name
PostNcDestroy(); // cleanup if Create fails too soon
return FALSE;
}
#endif //_DEBUG
// initialize common controls
VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTLS_REG));
AfxDeferRegisterClass(AFX_WNDCOMMCTLSNEW_REG);
// call PreCreateWindow to get prefered extended style
CREATESTRUCT cs; memset(&cs, 0, sizeof(CREATESTRUCT));
if (dwRequestedStyle == 0)
dwRequestedStyle = AFX_WS_DEFAULT_VIEW;
cs.style = dwRequestedStyle;
if (!PreCreateWindow(cs))
return FALSE;
// create a modeless dialog
if (!CreateDlg(m_lpszTemplateName, pParentWnd))
return FALSE;
m_pCreateContext = NULL;
// we use the style from the template - but make sure that
// the WS_BORDER bit is correct
// the WS_BORDER bit will be whatever is in dwRequestedStyle
ModifyStyle(WS_BORDER|WS_CAPTION, cs.style & (WS_BORDER|WS_CAPTION));
ModifyStyleEx(WS_EX_CLIENTEDGE, cs.dwExStyle & WS_EX_CLIENTEDGE);
SetDlgCtrlID(nID);
CRect rectTemplate;
GetWindowRect(rectTemplate);
SetScrollSizes(MM_TEXT, rectTemplate.Size());
// initialize controls etc
if (!ExecuteDlgInit(m_lpszTemplateName))
return FALSE;
// force the size requested
SetWindowPos(NULL, rect.left, rect.top,
rect.right - rect.left, rect.bottom - rect.top,
SWP_NOZORDER|SWP_NOACTIVATE);
// make visible if requested
if (dwRequestedStyle & WS_VISIBLE)
ShowWindow(SW_NORMAL);
return TRUE;
}
如何,Google “dialog template must exist and be invisible with WS_CHILD set”发现网文
http://www.cnweblog.com/vcbird/archive/2005/10/10/36404.html
呵呵呵,看来解决该有望了,先去吃饭,回来继续
最终的解决办法是这样的,我重建了该工程,选择Insert Resource时选中“IDD_FORMVIEW”
其他代码没有变化
然后就成功了,呵呵呵,我表示非常欣慰,非常感谢在网络上分享的IT同仁们的辛勤耕耘!
- Debug Assertion Failed! FILE viewform.cpp , line 69
- 关于 debug assertion failed, file:dlgdata.cpp,line"44 错误
- 关于 debug assertion failed, file:dlgdata.cpp,line"44 错误
- 引用 Debug Assertion Failed!File:wingdi.cpp Line:1120
- 引用 Debug Assertion Failed!File:wingdi.cpp Line:1120
- VC Debug Assertion Failed File:dlgdata.cpp Line 43
- VC++ Debug Assertion Failed! 错误(File: winmdi.cpp Line: 141)
- Debug Assertion Failed File:dgbdel.cpp Line 52
- Debug Assertion Failed! File:cmdtarg.cpp Line:52
- debug assertion failed, file:dlgdata.cpp,line"43
- debug assertion failed! winocc.cpp line 381
- debug assertion failed, file:dlgdata.cpp,line43
- "debug assertion failed, file:dlgdata.cpp,line43"
- Debug Assertion Failed!........File:dbgdel.cpp
- MFC程序出现“Debug Assertion Failed! File:dlgdata.cpp Line: 43 ”错误
- MFC学习笔记之VC++ Debug Assertion Failed! 错误(File: strex.cpp Line: 690)
- Debug Assertion Failed! File:f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp Line:896
- Debug Assertion Failed!……File:winocc.cpp Line:345……(Press Retry to debug the application)
- C++访问控制符private/protected/public
- 闲来没事自己研究了下RBAC
- ios UIWebView 背景透明
- HTTP返回状态码及错误大全
- 快递接口API
- Debug Assertion Failed! FILE viewform.cpp , line 69
- android studio 国内翻墙更新sdk方法
- Cocos2d中update与fixedUpdate的区别(三)
- key&IDEA
- 十个免费的 Web 压力测试工具
- 对RESTful Web API的理解与设计思路
- 小知识点2
- android.content.res.Resources$NotFoundException: String resource ID #0x1
- 公司分析