0

古典的なWindowsエクスプローラーの種類のアプリケーションを実装しようとしています。CpliterWndには2つのペインがあります。左側のペインはCLeftTreeView:public CTreeView右側のペインはCRightPaneFrame:public 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が右側のペインに読み込まれていません。

アプローチの変更に関する提案または現在のアプローチの何が問題になっていますか?

4

1 に答える 1

0

カスタムビューは、CFrameWnd内ではなく、スプリッタウィンドウの右側に直接配置する必要があります。

if (!m_SplitterWnd.CreateView(0, 0, RUNTIME_CLASS(CLeftTreeView), CSize(125, 100), pContext) 
|| !m_SplitterWnd.CreateView(0, 1, RUNTIME_CLASS(CCustomView), CSize(100, 100), pContext))

{
    m_SplitterWnd.DestroyWindow();
    return FALSE;
}
于 2011-03-14T14:53:44.747 に答える