سؤال

In an MFC application, there is a dockable pane which is divided into 2 rows using CSplitterWndEx. I'm trying to add two dialogs using this splitter:

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;
    } 
 }

Edit:

And here is the code where the splitter is created:

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);

}

This method accepts CWnd as an argument but I pass the dialog itself so when the application is run the pane is divided but dialog controls are not there.

So my question is: Is it possible to add a CDialog object to a pane using CSplitterWndEx?

هل كانت مفيدة؟

المحلول

What about using CFormView derived class?

نصائح أخرى

Maybe what you are looking for is CPaneDialog. Check out the SetPaneSize example from the VS 2008 Feature Pack Samples. Excerps from the sample:

    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 Bar\n");
            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 ();
}

...
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top