我正在尝试实现经典的 Windows 资源管理器类型的应用程序,CpliterWnd 有两个窗格:左窗格是 CLeftTreeView:公共 CTreeView 右窗格是 CRightPaneFrame:公共 CFrameWnd,CRightPaneFrame 有一个成员变量 m_pCustomView。
CustomView 是我添加到对话框资源的类(使用资源编辑器和添加类向导进行编辑)
class CustomView : public CFormView
{
DECLARE_DYNCREATE(CustomView)
public: // Changed to public so that i can instantiate this view on heap
CustomView(); // protected constructor used by dynamic creation
virtual ~CustomView();
BOOL Create(LPCTSTR A, LPCTSTR B, DWORD C,
const RECT& D, CWnd* E, UINT F, CCreateContext* G); // To override the protected specifier of CFormView::Create()
MainFrame.cpp 具有以下条目
if (!m_SplitterWnd.CreateView(0, 0, RUNTIME_CLASS(CLeftTreeView), CSize(125, 100), pContext) || !m_SplitterWnd.CreateView(0, 1, RUNTIME_CLASS(CRightPaneFrame), CSize(100, 100), pContext))
{
m_SplitterWnd.DestroyWindow();
return FALSE;
}
后来在 CRightPaneFrame
BOOL CRightPaneFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
m_pCustomView = new CustomView;
m_pCustomView->Create(NULL,NULL,0L,CFrameWnd::rectDefault,this,VIEW_CUSTOM, pContext);
SetActiveView(m_pCustomView);
m_pCustomView->ShowWindow(SW_NORMAL);
RecalcLayout();
return true;
}
我不知道我做错了什么,但 CustomView 没有加载到右窗格中。
关于改变方法的任何建议或当前方法有什么问题?