使用CSplitterWndEx将两个对话框(CDialog)添加到dockablepane(CDockablePane



在MFC应用程序中,有一个可停靠的窗格,使用CSplitterWndEx分为2行。我正在尝试使用这个拆分器添加两个对话框:

BOOL CPaneSplitter::AddWindow(int row, int col, CWnd* pWnd , CString clsName ,
DWORD dwStyle,DWORD dwStyleEx, SIZE sizeInit)
{
    // set the initial size for that pane
    m_pColInfo[col].nIdealSize = sizeInit.cx;
    m_pRowInfo[row].nIdealSize = sizeInit.cy;
    ASSERT(pWnd->m_hWnd == NULL);       // not yet created
    // Create with the right size (wrong position)
    CRect rect(CPoint(0,0), sizeInit);
    if (!pWnd->CreateEx(dwStyleEx,clsName,NULL,dwStyle,rect,this,IdFromRowCol(row,                    col)))
    { 
        return FALSE;
    } 
 }
编辑:

下面是创建分配器的代码:

int CSplitePane::OnCreate(LPCREATESTRUCT lp)
{
    if(CDockablePane::OnCreate(lp)==-1)
        return -1;
    m_wndSplitter.CreateStatic(this,2,1);

    DWORD dwStyle = WS_CHILD | WS_VISIBLE ;
    if(!m_wndSplitter.AddWindow(0,0,&m_ChildDlg1,_T("My_Dailog_Pane"),dwStyle,0,CSize(100,100)))
        return -1;  
    m_ChildDlg1.ShowWindow(SW_SHOWDEFAULT);
    dwStyle = WS_CHILD | WS_VISIBLE | LVS_REPORT  | LVS_SHAREIMAGELISTS;
    if(!m_wndSplitter.AddWindow(1,0,&m_wndList,WC_LISTVIEW,dwStyle,0,CSize(100,100)))
        return -1; 
        m_wndList.ModifyStyle(LVS_TYPEMASK, LVS_ICON);
    return 0 ;
}
void CSplitePane::OnSize(UINT nType,int cx,int cy)
{
    CDockablePane::OnSize(nType,cx,cy);
    int cyTlb =0;// m_wndToolbar.CalcFixedLayout(FALSE, TRUE).cy;
    CRect rect;
    GetClientRect(rect);
    m_ChildDlg1.SetWindowPos(NULL,rect.left, rect.top, rect.Width(),rect.Height(),SWP_NOACTIVATE|SWP_NOZORDER);
    m_wndSplitter.SetWindowPos(NULL,rect.left
    , rect.top + cyTlb
    , rect.Width()  , rect.Height() - cyTlb , SWP_NOZORDER | SWP_NOACTIVATE);
}

此方法接受CWnd作为参数,但我传递了对话框本身,因此当应用程序运行时,窗格被划分,但对话框控件不存在。

我的问题是:是否可以使用CSplitterWndEx添加CDialog对象到窗格?

如何使用CFormView派生类?

也许你正在寻找的是CPaneDialog。查看VS 2008特性包示例中的SetPaneSize示例。示例节选:

    void CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
            ...
        if (!m_wndDlgBar.Create (_T("DialogBar"), this, TRUE,
                         MAKEINTRESOURCE (IDD_DLG_BAR), 
                         WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI, 
                         ID_VIEW_DLGBAR))
        {
            TRACE0("Failed to create Dialog Barn");
            return FALSE;      // fail to create
        }
        m_wndDlgBar.EnableDocking(CBRS_ALIGN_ANY);
        m_wndDlgBar.DockToWindow (&m_wndWorkSpace, CBRS_ALIGN_BOTTOM);
        ...
    }
void CMainFrame::OnViewDialogBar() 
{
    ShowPane (&m_wndDlgBar, !(m_wndDlgBar.IsVisible ()), FALSE, TRUE);
    RecalcLayout ();
}
...

相关内容

  • 没有找到相关文章

最新更新