Solved

splitter window problems

Posted on 1998-10-31
7
623 Views
Last Modified: 2013-11-20
Hi!
I have created a static splitter window with two views (2 rows, 1 column).
I need to dinamically show or hide the panes. I know how to hide one row:

void CChildFrame::OnHideRow()
{
      m_wndSplitter.ModifyStyle(0,SPLS_DYNAMIC_SPLIT);      
      m_wndSplitter.DeleteRow(m_row);
      m_wndSplitter.ModifyStyle(SPLS_DYNAMIC_SPLIT,0);
}

but now I don't know how to show the previously hidden row.

I  found a CSplitterWnd derived class in codeguru site to show/hide static
panes but it only works for the case of columns and not for rows.

If anybody could help I would be very grateful.

TIA
Carlos
0
Comment
Question by:qocarlos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1324086
How about using InsertRow() (sp?)

Raymond.
0
 

Expert Comment

by:f4817
ID: 1324087
Hello,
I think that the problem is that when you use Delete row, you destroy the row and then you must recreate it, that you lose the previous state of the row. I think you must resize the row at 0 pixel, and then give it the old size value to restore them.
0
 
LVL 1

Expert Comment

by:sudhirbrat
ID: 1324088
Try to set the size of the row instead of deleting the row.

CRect rect;
GetClientRect(rect);
m_wndSplitter.SetRowInfo(0, rect.Height(), rect.Height());
m_wndSplitter.SetRowInfo(1, 0, 0);
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Author Comment

by:qocarlos
ID: 1324089
Hi,

I don't want to resize the row to 0 pixels because I need to remove the splitter drag control.

Any other idea?
0
 
LVL 12

Expert Comment

by:migel
ID: 1324090
Try to use Pane resizing with splitter hiding.
for example:
// hiding splitter
m_wndSplitter.SetWindowPos(NULL, 0, 0, 0,0, SWP_HIDEWINDOW|SWP_NOZORDER|SWP_NOZIZE|SWP_NOMOVE);
CRect rect;

// resize appropriate pane
      GetClientRect(rect);
      m_wndSplitter.SetRowInfo(0, rect.Height(), rect.Height());
      CWnd* pWnd =  m_wndSplitter.GetPane(1, 0);
// hide unneeded pane
     pWnd->.SetWindowPos(NULL, 0, 0, 0,0,  SWP_HIDEWINDOW|SWP_NOZORDER|SWP_NOZIZE|SWP_NOMOVE);







0
 
LVL 3

Author Comment

by:qocarlos
ID: 1324091
Migel,
I've tried your code but doesn't work.
What's wrong with it?
0
 
LVL 1

Accepted Solution

by:
appdev earned 70 total points
ID: 1324092
  Hi, Carlos.
   Maybe, this is the way that you want to change the panes.
You can derive one class from CSplitterWnd.
This is the implementation file :

// Splitter.cpp : implementation file
//

#include "stdafx.h"            
#include "colf.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSplitter

IMPLEMENT_DYNCREATE(CSplitter, CSplitterWnd)

CSplitter::CSplitter()
{
}

CSplitter::~CSplitter()
{
}



BEGIN_MESSAGE_MAP(CSplitter, CSplitterWnd)
      //{{AFX_MSG_MAP(CSplitter)
            // NOTE - the ClassWizard will add and remove mapping macros here.
      //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSplitter message handlers


BOOL CSplitter::ReplaceView(int row, int col, CRuntimeClass* pViewClass, SIZE size)
{
  CCreateContext context;
  BOOL bSetActive;
            
   
  //if ((GetPane(row,col)->IsKindOf(pViewClass))==TRUE)
    //   return FALSE;
                           
   
   // Get pointer to CDocument object so that it can be used in the creation
   // process of the new view
   CDocument * pDoc= ((CView *)GetPane(0,0))->GetDocument();
   CView * pActiveView=GetParentFrame()->GetActiveView();
   if (pActiveView==NULL || pActiveView==GetPane(row,col))
      bSetActive=TRUE;
   else
      bSetActive=FALSE;

    // set flag so that document will not be deleted when view is destroyed
      pDoc->m_bAutoDelete=FALSE;    
    // Delete existing view
   ((CView *) GetPane(row,col))->DestroyWindow();
    // set flag back to default
    pDoc->m_bAutoDelete=TRUE;
 
    // Create new view                      
   
   context.m_pNewViewClass=pViewClass;
   context.m_pCurrentDoc=pDoc;
   context.m_pNewDocTemplate=NULL;
   context.m_pLastView=NULL;
   context.m_pCurrentFrame=NULL;
   
   CreateView(row,col,pViewClass,size, &context);
   
   CView * pNewView= (CView *)GetPane(row,col);
   
   if (bSetActive==TRUE)
      GetParentFrame()->SetActiveView(pNewView);
   
   RecalcLayout();
   GetPane(row,col)->SendMessage(WM_PAINT);
   
   return TRUE;
}


   And this is the header file :


// Splitter.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CSplitter frame with splitter

#ifndef __AFXEXT_H__
#include <afxext.h>
#endif

class CSplitter : public CSplitterWnd
{
      DECLARE_DYNCREATE(CSplitter)
public: //protected:
      CSplitter();           // protected constructor used by dynamic creation

// Attributes
public:

// Operations
public:
      BOOL ReplaceView(int row, int col, CRuntimeClass* pViewClass, SIZE size);

// Overrides
      // ClassWizard generated virtual function overrides
      //{{AFX_VIRTUAL(CSplitter)
      //}}AFX_VIRTUAL

// Implementation
public:
      virtual ~CSplitter();

      // Generated message map functions
      //{{AFX_MSG(CSplitter)
            // NOTE - the ClassWizard will add and remove member functions here.
      //}}AFX_MSG
      DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////


   Now, in your mainframe class add a member variable, this way :

CSplitter m_wndSplitter;

   Add the WM_CREATE message in the Class Wizard.  

BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,
      CCreateContext* pContext)
{
      // create splitter window
      if (!m_wndSplitter.CreateStatic(this, 2, 1))
            return FALSE;

      if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CMyUpView), CSize(200, 100), pContext) ||
            !m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CMyDownView), CSize(50, 50), pContext))
      {
            m_wndSplitter.DestroyWindow();
            return FALSE;
      }
      
      return TRUE;
}

   You can change any view when you want it...
e.g. when the user double click on your View...

CMyUpView::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult)
{
   ...maybe code to check the place (coordinates, item, etc) of the double click...

   SIZE size;
   size.cx=100;
   size.cy=100;
   ((CSplitter *)GetParent())->ReplaceView(1,0,RUNTIME_CLASS(CMyDownView), size);
   ...or...
    ((CSplitter *)GetParent())->ReplaceView(1,0,RUNTIME_CLASS(CBlankView), size);


}

Hope this help you.
Salvador.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Perl Awk Need Help 3 145
Process filename extension 3 218
Complete beginner needs help making a cron job 9 133
How to know only "File created" with EventLog 3 35
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question