对话框中的属性表ASSERTATION ERROR [英] property sheet in dialog ASSERTATION ERROR

查看:76
本文介绍了对话框中的属性表ASSERTATION ERROR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对话框中的属性表ASSERTATION ERROR
朋友你好
我想将属性表放在程序的一个对话框窗口中.
我创建了4个新类:
从CPropertySheet驱动的CZakladkiBiblioteki
从CPropertyPage驱动的CReBibPage
从CPropertyPage和
驱动的CRoBibPage 从CDialog驱动的CBibliotekaDlg
在文件BibliotekaDlg.h中,我从CZakladkiBiblioteki声明了对象

 ...
受保护的:
...
C_ZakladkiBiblioteki m_ZakladkiBiblioteki;
...
DECLARE_MESSAGE_MAP()
... 


在文件BibliotekaDlg.cpp中具有这样的构造函数:

 CBibliotekaDlg :: CBibliotekaDlg(CWnd * pParent /*   = NULL */ )
:CDialog(CBibliotekaDlg :: IDD,pParent)

,m_ZakladkiBiblioteki(IDC_TAB1, this  1 )
// 我没有这行->错误C2512:"CZakladkiBiblioteki" 
// :没有合适的默认构造函数
{


现在,当我运行程序和按钮时,应该会打开窗口
内部的属性表存在断言错误.
它在行中崩溃:

 CBibliotekaDlg oknobiblioteka; <-断言错误
oknobiblioteka.DoModal(); 


有人可以帮我解决这个问题吗?尝试取消注释默认值NULL.

CBibliotekaDlg::CBibliotekaDlg(CWnd* pParent =NULL)


断言怎么说?在调用堆栈中追溯它,以查看是什么调用触发了它.我看到您在构造函数期间将控制值IDC_TAB1传递给另一个类,如果您尝试在创建"对话框之前不使用此值做任何事情(在构造函数中不会发生),那么您就可以了"会得到一个错误.


自从我使用C ++已经有一段时间了,但是我似乎还记得你还必须提供一个默认的构造函数:

 CBibliotekaDlg :: CBibliotekaDlg():CDialog()
{
} 


property sheet in dialog ASSERTATION ERROR
Hello Friends
I want to put propertysheet in one of my dialogs windows in my program.
I created 4 new classes :
CZakladkiBiblioteki drived from CPropertySheet
CReBibPage drived from CPropertyPage
CRoBibPage drived from CPropertyPage and
CBibliotekaDlg drived from CDialog
in file BibliotekaDlg.h I declared object from CZakladkiBiblioteki

...
protected:
...
CZakladkiBiblioteki m_ZakladkiBiblioteki;
...
DECLARE_MESSAGE_MAP()
...


in file BibliotekaDlg.cpp in have construktor like this :

CBibliotekaDlg::CBibliotekaDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CBibliotekaDlg::IDD, pParent)

	, m_ZakladkiBiblioteki(IDC_TAB1,this,1)
// wihtout this line I have -> error C2512: 'CZakladkiBiblioteki'
// : no appropriate default constructor available
{


Now when I run program and push button which should open window
with property sheet inside I have Assertation Error.
It crashes in line :

CBibliotekaDlg oknobiblioteka; <-- ASSERTATION ERROR
oknobiblioteka.DoModal();


Can someone help me to solved this problem?

解决方案

According to you constructor, you take one argument, pParent, and there''s no default since its commented out. Try uncommenting the default value of NULL.

CBibliotekaDlg::CBibliotekaDlg(CWnd* pParent =NULL)


What does the assertion say? Trace it back in the call stack to see what call triggered it. I see you''re passing a control value IDC_TAB1 to the other class during the constructor, if you try to do anything with this value before the dialog is "created" (which does NOT occur at the constructor) then you''ll get an error.


It''s been a while since I did C++, but I seem to remember that you also have to provide a default constructor:

CBibliotekaDlg::CBibliotekaDlg():CDialog()
{
}


这篇关于对话框中的属性表ASSERTATION ERROR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆