Add / Remove Splitter Panes
-
I'm writing a application with a nested splitter The first spltter has 2 colomns, the second (in the right colomn) has a number of rows which I want to change programmically (between 2 and 5). In the present implementation I delete the second splitter when i need to add or remove a pane, and "built" the new one with the right number of rows. This implementation has a flaw because although I use the InitialUpdate for every view , nothing happens. Only when I "toutch the splitter-bar, I "see" the updated splitter. Does anyone no this problem and/or has a more elegant solution? I saw a proposal somewhere which hides panes. But in that case, can you then still enlarge the views with the mouse (which I don not want to be possible !) ? Thanks in advance, Bert....
-
I'm writing a application with a nested splitter The first spltter has 2 colomns, the second (in the right colomn) has a number of rows which I want to change programmically (between 2 and 5). In the present implementation I delete the second splitter when i need to add or remove a pane, and "built" the new one with the right number of rows. This implementation has a flaw because although I use the InitialUpdate for every view , nothing happens. Only when I "toutch the splitter-bar, I "see" the updated splitter. Does anyone no this problem and/or has a more elegant solution? I saw a proposal somewhere which hides panes. But in that case, can you then still enlarge the views with the mouse (which I don not want to be possible !) ? Thanks in advance, Bert....
Here is the code who hide / show a row . This code is written especially to hide / show only a row at a time . You can use it also to hide / show more then one row, but be aware to the sequence of hide / show operations. Derive a class from CSplitterWnd, and add this code : void CMySplitterWnd::HideRow(int rowHide) { ASSERT(m_nRows > 1); ASSERT(rowHide < m_nRows); SetActivePane( 0, 0 ); CWnd* pPaneHide = GetPane(rowHide, 0); ASSERT(pPaneHide != NULL); pPaneHide->ShowWindow(SW_HIDE); pPaneHide->SetDlgCtrlID(AFX_IDW_PANE_FIRST + m_nRows); for( int row = rowHide + 1; row < m_nRows; row++ ) { CWnd* pPane = GetPane( row, 0 ); ASSERT( pPane != NULL ); pPane->SetDlgCtrlID( IdFromRowCol(row - 1, 0) ); m_pRowInfo[row-1] = m_pRowInfo[row]; } m_nRows--; m_pRowInfo[m_nRows] = m_pRowInfo[rowHide]; RecalcLayout(); } void CTSplitterWnd::ShowRow(int rowShow) { ASSERT(m_nRows < m_nMaxRows); int rowNew = rowShow; CRowColInfo rowNewInfo = m_pRowInfo[m_nRows]; m_nRows++; int row; CWnd* pPaneShow = GetDlgItem( AFX_IDW_PANE_FIRST + m_nRows); ASSERT(pPaneShow != NULL); pPaneShow->ShowWindow(SW_SHOWNA); for(row = m_nRows - 2; row >= rowNew; row--) { CWnd* pPane = GetPane(row, 0); ASSERT(pPane != NULL); pPane->SetDlgCtrlID(IdFromRowCol(row + 1, 0)); m_pRowInfo[row + 1] = m_pRowInfo[row]; } pPaneShow->SetDlgCtrlID(IdFromRowCol(rowNew, 0)); m_pRowInfo[rowNew] = rowNewInfo; RecalcLayout(); } On this base you can write the functions for hide / show a colon