Exemplo n.º 1
0
// Resize parent
void CSplitterFrame::UpdateParent()
{
    CRect rcParent;
    CRect rcMainFrame;
    CRect rcMainClientFrame;
    CPoint pt = GetAbsPosition();
    CMainFrame* pMainFrame = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd());


    CDlgTemplate &wndParent = *(CDlgTemplate*)GetParent();
    pMainFrame->GetClientRect(&rcMainClientFrame);
    pMainFrame->GetWindowRect(&rcMainFrame);

    pt.x -=rcMainFrame.left;
    pt.y -=rcMainFrame.top;

    wndParent.GetWindowRect(&rcParent);
    wndParent.ShowWindow(SW_HIDE);


    INDEX iWidth = rcParent.right - rcParent.left;
    INDEX iHeight = rcParent.bottom - rcParent.top;

    if(sp_bDockingEnabled) {
        pMainFrame->FloatControlBar(&wndParent,CPoint(rcParent.left,rcParent.top));
        // is splitter attached on left side
        if(sp_uiDockSide == AFX_IDW_DOCKBAR_LEFT) {
            SET_BAR_SIZE(wndParent,rcMainClientFrame.right - pt.x,iHeight);
            // is splitter attached on right side
        } else if(sp_uiDockSide == AFX_IDW_DOCKBAR_RIGHT) {
            SET_BAR_SIZE(wndParent,pt.x,iHeight);
            // is splitter attached on top side
        } else if(sp_uiDockSide == AFX_IDW_DOCKBAR_TOP) {
            SET_BAR_SIZE(wndParent,iWidth,iHeight + sp_ptStartPoint.y - pt.y);
            // is splitter attached on bottom side
        } else if(sp_uiDockSide == AFX_IDW_DOCKBAR_BOTTOM) {
            ASSERT(FALSE);
        }

        // Chose docking side
        INDEX iDockSide = 0;
        // is splitter attached on left side
        if(sp_uiDockSide==AFX_IDW_DOCKBAR_LEFT) {
            iDockSide = AFX_IDW_DOCKBAR_RIGHT;
            // is splitter attached on right side
        } else if(sp_uiDockSide==AFX_IDW_DOCKBAR_RIGHT) {
            iDockSide = AFX_IDW_DOCKBAR_LEFT;
            // is splitter attached on top side
        } else if(sp_uiDockSide==AFX_IDW_DOCKBAR_TOP) {
            iDockSide = AFX_IDW_DOCKBAR_BOTTOM;
            // is splitter attached on bottom side
        } else if(sp_uiDockSide==AFX_IDW_DOCKBAR_BOTTOM) {
            iDockSide = AFX_IDW_DOCKBAR_TOP;
        }
        pMainFrame->DockControlBar(&wndParent,iDockSide);
    } else {
        SET_BAR_SIZE(wndParent,300,300);
        // wndParent.SetWindowPos(&wndBottom,0,0,100,300,SWP_NOZORDER);
        //pMainFrame->FloatControlBar(&wndParent,CPoint(rcParent.left,rcParent.top));
        //pMainFrame->DockControlBar(&wndParent,AFX_IDW_DOCKBAR_BOTTOM);
    }



    wndParent.ShowWindow(SW_SHOW);
    wndParent.UpdateWindow();
}