BOOL COXSplitterWnd::SwapPanes(CWnd* pFirstWnd, CWnd* pSecondWnd) { ASSERT(pFirstWnd && pSecondWnd); int nCol1, nCol2, nRow1, nRow2; if (!IsChildPane(pFirstWnd, &nRow1, &nCol1) || !IsChildPane(pSecondWnd, &nRow2, &nCol2)) { return FALSE; } int nID1=IdFromRowCol(nRow1,nCol1); int nID2=IdFromRowCol(nRow2,nCol2); pSecondWnd->SetDlgCtrlID(nID1); pFirstWnd->SetDlgCtrlID(nID2); //exchange by row info CSplitterWnd::CRowColInfo info; CSplitterWnd::CRowColInfo* pInfo1=m_pRowInfo; CSplitterWnd::CRowColInfo* pInfo2=m_pRowInfo; pInfo1+=nID1 - (AFX_IDW_PANE_FIRST + nRow1 * 16 + nCol1); pInfo2+=nID2 - (AFX_IDW_PANE_FIRST + nRow2 * 16 + nCol2); memcpy(&info, pInfo1, sizeof(CSplitterWnd::CRowColInfo)); memcpy(pInfo1, pInfo2, sizeof(CSplitterWnd::CRowColInfo)); memcpy(pInfo2, &info, sizeof(CSplitterWnd::CRowColInfo)); RecalcLayout(); RedrawWindow(); return TRUE; }
//----------------------------------------------------------------------------- // Purpose: // Input : *pWnd - //----------------------------------------------------------------------------- void CMySplitterWnd::ToggleMax(CWnd *pWnd) { int ir, ic; if(!pMaxPrev) { int dummy; // save current info GetRowInfo(0, sizePrev[1][0], dummy); GetRowInfo(1, sizePrev[1][1], dummy); GetColumnInfo(0, sizePrev[0][0], dummy); GetColumnInfo(1, sizePrev[0][1], dummy); } if(pWnd != pMaxPrev) { // maximize this one int iRow, iCol; CRect r; GetClientRect(r); VERIFY(IsChildPane(pWnd, &iRow, &iCol)); for(ir = 0; ir < 2; ir++) { for(ic = 0; ic < 2; ic++) { SetRowInfo(ir, 0, 0); SetColumnInfo(ic, 0, 0); } } SetRowInfo(iRow, r.Height(), 5); SetColumnInfo(iCol, r.Width(), 5); pMaxPrev = pWnd; } else { // restore saved info SetRowInfo(0, sizePrev[1][0], 0); SetRowInfo(1, sizePrev[1][1], 0); SetColumnInfo(0, sizePrev[0][0], 0); SetColumnInfo(1, sizePrev[0][1], 0); pMaxPrev = NULL; } RecalcLayout(); }