Solved

splitter window problems

Posted on 1998-10-31
7
632 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
Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit 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

Database Solutions Engineer FAQs

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller single-server environments.

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

627 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