Solved

splitter window problems

Posted on 1998-10-31
7
583 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
Comment Utility
How about using InsertRow() (sp?)

Raymond.
0
 

Expert Comment

by:f4817
Comment Utility
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
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 3

Author Comment

by:qocarlos
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
  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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

763 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

12 Experts available now in Live!

Get 1:1 Help Now