求助!!关于CPropertySheet的问题

来源:互联网  时间:2016/7/17 11:06:40

关于网友提出的“ 求助!!关于CPropertySheet的问题”问题疑问,本网通过在网上对“ 求助!!关于CPropertySheet的问题”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题: 求助!!关于CPropertySheet的问题
描述:

我从CPropertySheet生成了一个新类CMyProperty,在里面添加了三个成员变量(CPropertyPage类),并加了AddPage()了三个页面
然后,我在SDI的View类里面定义了一个CMyProperty类的成员变量,再进行相关操作
但是编译提示:
E:\vcprog\xxxx\xxxxView.cpp(46) : error C2512: 'CMyProperty' : no appropriate default constructor available
为什么呢?
我贴出具体涉及到的代码吧:
ParaSheet.h
#if !defined(AFX_PARASHEET_H__DA82EB55_E6EC_4542_B49D_81CC8E95C25E__INCLUDED_)
#define AFX_PARASHEET_H__DA82EB55_E6EC_4542_B49D_81CC8E95C25E__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ParaSheet.h : header file
//
#include "CalculatingPage.h"
#include "StructurePage.h"
#include "DiscretePage.h"
/////////////////////////////////////////////////////////////////////////////
// CParaSheet
class CParaSheet : public CPropertySheet
{
DECLARE_DYNAMIC(CParaSheet)
// Construction
public:
CParaSheet(LPCTSTR pszCaption);
// Attributes
public://这里
CStructurePage m_StructurePara;
CCalculatingPage m_CalculatingPara;
CDiscretePage m_DiscretePara;
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CParaSheet)
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CParaSheet();
// Generated message map functions
protected:
//{{AFX_MSG(CParaSheet)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PARASHEET_H__DA82EB55_E6EC_4542_B49D_81CC8E95C25E__INCLUDED_)
ParaSheet.cpp
// ParaSheet.cpp : implementation file
//
#include "stdafx.h"
#include "GCFE.h"
#include "ParaSheet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CParaSheet
IMPLEMENT_DYNAMIC(CParaSheet, CPropertySheet)
//这里有改变
CParaSheet::CParaSheet(LPCTSTR pszCaption)
:CPropertySheet(pszCaption, NULL, 0)
{
AddPage(&m_DiscretePara);
AddPage(&m_CalculatingPara);
AddPage(&m_StructurePara);
}
CParaSheet::~CParaSheet()
{
}
BEGIN_MESSAGE_MAP(CParaSheet, CPropertySheet)
//{{AFX_MSG_MAP(CParaSheet)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CParaSheet message handlers
MyView.h中
………………
CParaSheet m_Sheet;
……………………
MyView.cpp
CGCFEView::CGCFEView()
{   //调试时,指示错误位置是这里,就是这个大括号这里
   ………………
}


解决方案1:

在CGCFEView构造函数中给m_Sheet的构造函数传递参数:
CGCFEView::CGCFEView()
:m_Sheet("No No")
{   //调试时,指示错误位置是这里,就是这个大括号这里
   ………………
}

解决方案2:

Propertysheet没有默认的构造函数,你可以这样定义
CParaSheet(LPCTSTR pszCaption = NULL);

上一篇如何清空EditBox中的内容?
下一篇一个很菜的问题,望各位指点。
明星图片
相关文章
《 求助!!关于CPropertySheet的问题》由码蚁之家搜集整理于网络,
联系邮箱:mxgf168#qq.com(#改为@)