Solved

splitter window problems

Posted on 1998-10-31
7
595 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
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to calculate times for developing software? 8 65
repeatSeparator  java  challenge 13 56
how to monitor remote shell execution on linux 9 97
has22 challenge 11 80
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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…
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 used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

862 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now