Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

splitter window problems

Posted on 1998-10-31
7
Medium Priority
?
640 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 140 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

688 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