C++ MFC CView进入CDockablePane
我需要将CView派生类放入CDockablePane中。是否有任何代码示例,或者有人可以提供这样的代码 我尝试的是: 显然应该很简单,我在网上找到了这样的建议:“只需创建视图,并将其父视图设置为对话框或可固定窗格,或者设置为您想要的窗口类型”。但由于某种原因它不起作用,也许是因为它需要一个框架,我不知道 无论如何,我需要能够做到这一点,而无需创建另一个文档模板类。只需使用现有的文档和视图类即可。以下是一个示例: 从CDockablePane派生的类: //CRichEditPane.hC++ MFC CView进入CDockablePane,c++,visual-c++,mfc,docking,document-view,C++,Visual C++,Mfc,Docking,Document View,我需要将CView派生类放入CDockablePane中。是否有任何代码示例,或者有人可以提供这样的代码 我尝试的是: 显然应该很简单,我在网上找到了这样的建议:“只需创建视图,并将其父视图设置为对话框或可固定窗格,或者设置为您想要的窗口类型”。但由于某种原因它不起作用,也许是因为它需要一个框架,我不知道 无论如何,我需要能够做到这一点,而无需创建另一个文档模板类。只需使用现有的文档和视图类即可。以下是一个示例: 从CDockablePane派生的类: //CRichEditPane.h cla
class CRichEditPane : public CDockablePane
{
DECLARE_DYNAMIC(CRichEditPane)
public:
CRichEditPane();
virtual ~CRichEditPane();
protected:
void AdjustLayout();
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSize(UINT nType, int cx, int cy);
};
//CRichEditPane.cpp
IMPLEMENT_DYNAMIC(CRichEditPane, CDockablePane)
CRichEditPane::CRichEditPane()
{
}
CRichEditPane::~CRichEditPane()
{
}
BEGIN_MESSAGE_MAP(CRichEditPane, CDockablePane)
ON_WM_CREATE()
ON_WM_SIZE()
END_MESSAGE_MAP()
// CRichEditPane message handlers
int CRichEditPane::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDockablePane::OnCreate(lpCreateStruct) == -1)
return -1;
CRuntimeClass *pClass = RUNTIME_CLASS(CRichEditViewInPane);
// calling constructor using IMPLEMENT_DYNCREATE macro
CRichEditViewInPane *pView = (CRichEditViewInPane*)pClass->CreateObject();
if (!pView->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, CRect(0,0,0,0), this, AFX_IDW_PANE_FIRST, NULL))
{
return -1;
}
CRichEditCtrl ctrl;
ctrl.Create(WS_CHILD, CRect(0, 0, 0, 0), this, 10991);
return 0;
}
void CRichEditPane::OnSize(UINT nType, int cx, int cy)
{
CDockablePane::OnSize(nType, cx, cy);
AdjustLayout();
}
从CView派生的视图类:
//CRichEditViewInPane.h
class CRichEditViewInPane : public CRichEditView
{
DECLARE_DYNCREATE(CRichEditViewInPane)
protected:
CRichEditViewInPane(); // protected constructor used by dynamic creation
virtual ~CRichEditViewInPane();
public:
#ifdef _DEBUG
virtual void AssertValid() const;
#ifndef _WIN32_WCE
virtual void Dump(CDumpContext& dc) const;
#endif
#endif
protected:
DECLARE_MESSAGE_MAP()
};
//CRichEditViewInPane。cpp
IMPLEMENT_DYNCREATE(CRichEditViewInPane, CRichEditView)
CRichEditViewInPane::CRichEditViewInPane()
{
}
CRichEditViewInPane::~CRichEditViewInPane()
{
}
BEGIN_MESSAGE_MAP(CRichEditViewInPane, CRichEditView)
END_MESSAGE_MAP()
如何将其更改为FormView?我无法访问Create函数,只能访问CreateEx