首页 > csdn导入, 技术, 转载 > [存档]浅谈:切换视时基于FormView的对话框属性设置与ASSERT报错的问题

[存档]浅谈:切换视时基于FormView的对话框属性设置与ASSERT报错的问题

这是在做EVC的作业时碰到的问题,查到的文章,存个档~~~

最近做的项目中用到了FormView切换视图,其主要原理是:先新建一些Dialog对话框,然后给这些对话框绑定对应的View,注意:这些View要基于FormView。
一开始还好好的,利用切换视的代码进行的很顺利(网上的相关代码很多,我就不赘述了),但是,后来新加了两个Dialog,不知我怎么弄的,奇怪的事发生了:先前添加了Dialog都能正常的切换,但是,一切换新添加的Dialog,每次运行到:

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);          // invalid dialog template name
PostNcDestroy();        // cleanup if Create fails too soon
return FALSE;
}
#endif //_DEBUG


中的ASSERT时就报错,而在Release版本下却不会报错。我检查了一下这两个新加的Dialog与先前的Dialog属性有哪些不同,原来是自己把后来加的Dialog的Visible属性设置成了TRUE了, 根据代码的要求是:对话框模板必须存在,属性要设置成不可见和子窗口风格。SystemMenu和TitleBar属性最好都设为False,改完以后,一切正常~~
注:还有一种方法就是在添加Dialog资源时,在Dialog列表上点右键->添加资源,选择Dialog->IDD_FORMVIEW,再点“新建”按钮,这样新建出来的Dialog属性就会自动配好了

分类: csdn导入, 技术, 转载 标签:
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word


Warning: fsockopen() has been disabled for security reasons in /home/onlymars/public_html/wp/wp-includes/class-snoopy.php on line 1148