|
-
March 31st, 1999, 10:38 AM
#1
Re: Need a splitter like windows exporer
I had a similar situation. My app needed a 3-way splitter. The user sees a window which is split vertically. The left
side is split again horizontally, so the user sees: "File" pane (a tree view) on the top left, "Parameter" pane (a list
view) on the bottom left, and "Image" pane (CScrollView where drawing is done) on the right side. If the user chooses
to hide one of the panes on the left side (File or Parameter), the remaining left-side pane fills the area. If they
choose to hide the remaining left-side pane, the Image pane will occupy the entire window, since now both left-side
panes are hidden. Process is reversed for showing the panes.
Here is how I implemented showing and hiding the lower-left pane. The call to GetActiveDocument is due to my app being
a multi-doc app, and I needed to show/hide the pane for the currently-active document.
CChildFrame is declared like this:
/*
Name: CChildFrame
Remarks:
Frame window for holding the splitter windows.
{Group: Classes - Presentation layer}
*/
class CChildFrame : public CMDIChildWnd
{
DECLARE_DYNCREATE(CChildFrame)
public:
CChildFrame();
CFlexPrintSplitWnd m_wndSplitter1; //first splitter window
CFlexPrintSplitWnd m_wndSplitter2; //second splitter window, embedded in splitter 1
// Attributes
public:
// Operations
public:
...
...
};
/*
Name: OnViewParameters
Description:
User has toggled the Parameter pane. Show/hide the pane based
on its current state.
Return Value:
void
*/
void CChildFrame::OnViewParameters()
{
CFlexPrintDoc *pDoc = (CFlexPrintDoc*)GetActiveDocument();
CRect rect1, rect2, rectChild;
m_wndSplitter1.GetClientRect(&rect1);
m_wndSplitter2.GetClientRect(&rect2);
GetClientRect(&rectChild);
int cxMin, cxCur;
m_wndSplitter1.GetColumnInfo(1, cxCur, cxMin); //get space occupied by Image window
if(pDoc != NULL) // Toggle display of tree view
{
// splitter2 has 2 rows, 1 col: tree is in row0,col0, list is in row1,col0
if(pDoc->m_pListView->IsWindowVisible())
{
//TRACE(_T("hiding list view\n" );
m_wndSplitter2.SetActivePane(0,0); //activate the tree view
pDoc->m_pListView->ShowWindow(SW_HIDE); //hide list view
InvalidateRect(&rect2);
m_wndSplitter2.SetRowInfo(0, rect2.bottom-rect2.top, 0);
m_wndSplitter2.RecalcLayout();
InvalidateRect(&rect2);
//if tree view is hidden and image window is showing, give full space to image
if(!pDoc->m_pTreeView->IsWindowVisible())
{
if(cxCur > 0)
{
//TRACE(_T("making image area fill client rect\n" );
m_wndSplitter2.ShowWindow(SW_HIDE);
m_wndSplitter1.SetColumnInfo(0, 0, 0);
m_wndSplitter1.RecalcLayout();
InvalidateRect(&rectChild);
pDoc->m_pImageView->Invalidate();
}
}
}
else
{
//TRACE(_T("showing list view\n" );
if(!m_wndSplitter2.IsWindowVisible())
{
m_wndSplitter2.ShowWindow(SW_SHOW);
m_wndSplitter1.SetColumnInfo(0, m_nTreeListIdealSize, m_nTreeListMinSize);
m_wndSplitter1.RecalcLayout();
InvalidateRect(&rect2);
}
pDoc->m_pListView->ShowWindow(SW_SHOW);
if(!pDoc->m_pTreeView->IsWindowVisible())
m_wndSplitter2.SetRowInfo(0, 0, 0);
else
m_wndSplitter2.SetRowInfo(0, (rect2.bottom-rect2.top)/2, 0);
m_wndSplitter2.RecalcLayout();
m_wndSplitter2.SetActivePane(1,0); //activate the list view
InvalidateRect(&rect2);
}
}
}
Hope this helps.
Ron
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|