Changing View in Static CSplitter Wnd 
Author Message
 Changing View in Static CSplitter Wnd


writes

Quote:
>Hi!

>I have already created a static splitter wnd. with a Tree View and
>CScrollView.

>At certain pt. of time in my application, I want to replace TreeView
>with some other view. How can I do that?

>I found DeleteView for CSplitterWnd. But how do I add/Insert view after
>initial creation in CreateClient?

>Any help is appriciated.

>Leena

Finally some else wants to do this!!!

I have been thinking for some time now how to achieve this.  I have
recently been reading some articals in Dr. Dobbs Journal (web address
is: www.ddj.com) which I have found very useful.  Check out the
undocumented corner sections (Dec 96, Feb 97), "Appling CSplitterWnd
Internals".  

I have a good approach as how to achieve this, I am planning on coding a
base class derived from CSplitterWnd over the next two weeks.

--
Gwyn Cole



Thu, 01 Jul 1999 03:00:00 GMT  
 Changing View in Static CSplitter Wnd

Hi Gwyn/Leena,

Check out the source code (yes - you have to do this sometimes
when you push the MFC envelope) to CreateView/DeleteView
in mfc\src\winsplit.cpp and you should be able to create
a CSplitter derivative (might want to use the one we did
for DDJ as a starting point) that has a SwitchView()
api in it.

If you get it working, please post it here for the benefit
of all!

May the MFC gods be with you,

Scot
Stingray
http://www.stingsoft.com

Quote:


> writes
> >Hi!

> >I have already created a static splitter wnd. with a Tree View and
> >CScrollView.

> >At certain pt. of time in my application, I want to replace TreeView
> >with some other view. How can I do that?

> >I found DeleteView for CSplitterWnd. But how do I add/Insert view after
> >initial creation in CreateClient?

> >Any help is appriciated.

> >Leena

> Finally some else wants to do this!!!

> I have been thinking for some time now how to achieve this.  I have
> recently been reading some articals in Dr. Dobbs Journal (web address
> is: www.ddj.com) which I have found very useful.  Check out the
> undocumented corner sections (Dec 96, Feb 97), "Appling CSplitterWnd
> Internals".

> I have a good approach as how to achieve this, I am planning on coding a
> base class derived from CSplitterWnd over the next two weeks.

> --
> Gwyn Cole



Fri, 02 Jul 1999 03:00:00 GMT  
 Changing View in Static CSplitter Wnd

Hey,
I agree with Scot.  It might be better to create the views you need
initially and just show and hide them when you want to switch between the
two.
Here is some code I wrote awhile ago where I changed the top views in my
splitter:
(The names have been changed to protect the innocent)

First put two member variables in your top view class header file i.e.:
CFirstView * pFirstView;
CSecondView * pSecondView;

In the OnInitialUpdate of the top view of the splitter:
void CTopView::OnInitialUpdate()
{
        CScrollView::OnInitialUpdate();

        CRect rClient;
        GetClientRect(rClient);

        CRuntimeClass* pRuntimeClass = RUNTIME_CLASS( CFirstView );
        pFirstView = (CFirstView*)pRuntimeClass->CreateObject();
        ASSERT( pFirstView->IsKindOf( RUNTIME_CLASS( CFirstView) ) );

        pRuntimeClass = RUNTIME_CLASS( CSecondView );
        pSecondView = (CSecondView *)pRuntimeClass->CreateObject();
        ASSERT( pSecondView->IsKindOf( RUNTIME_CLASS( CSecondView ) ) );

        CCreateContext context;
        context.m_pCurrentDoc = GetDocument();

        pFirstView->Create(NULL,NULL,WS_CHILD|WS_VISIBLE,rStatic,this,AFX_IDW_PANE_
FIRST,&context);
        pFirstView->ShowWindow(SW_SHOW);
        GetParentFrame()->SetActiveView(pFirstView);

        pSecondView->Create(NULL,NULL,WS_CHILD|WS_VISIBLE,rStatic,this,AFX_IDW_PANE
_FIRST+1,&context);
        pSecondView->ShowWindow(SW_HIDE);

        CSize sizeTotal;
        //Todo: determine correct initial size
        sizeTotal.cx = sizeTotal.cy = 200;
        SetScrollSizes(MM_TEXT, sizeTotal);

Quote:
}

Then I added handlers for OnSize and for switching views

void CTopView::OnSize(UINT nType, int cx, int cy)
{
  CScrollView::OnSize(nType, cx, cy);

  if (pFirstView && pSecondView)
    {
    pFirstView->SetWindowPos(0,0,0,cx,cy,SWP_NOMOVE,SWP_NOZORDER);  
    pSecondView->SetWindowPos(0,0,0,cx,cy,SWP_NOMOVE,SWP_NOZORDER);  
    }

Quote:
}

void CTopView::OnSecondView()
{
  if (pFirstView && pSecondView )
    {
    pFirstView->ShowWindow(SW_HIDE),
    pSecondView->ShowWindow(SW_SHOW);
    GetParentFrame()->SetActiveView(pSecondView);
    }

Quote:
}

void CTopView::OnFirstView()
{
  if (pFirstView && pSecondView )
    {
    pSecondView->ShowWindow(SW_HIDE);
    pFirstView->ShowWindow(SW_SHOW);
    GetParentFrame()->SetActiveView(pFirstView);
    }

Quote:
}

If you have any questions feel free to e-mail me.
Later,
Robert Groat

PS Also, could you please look at my post on the Toolbar problem I am
having.  It seems painfully simple but I haven't solved it yet.



| Hi Gwyn/Leena,
|
| Check out the source code (yes - you have to do this sometimes
| when you push the MFC envelope) to CreateView/DeleteView
| in mfc\src\winsplit.cpp and you should be able to create
| a CSplitter derivative (might want to use the one we did
| for DDJ as a starting point) that has a SwitchView()
| api in it.
|
| If you get it working, please post it here for the benefit
| of all!
|
| May the MFC gods be with you,
|
| Scot
| Stingray
| http://www.stingsoft.com
|
|
|
| >

| > writes
| > >Hi!
| > >
| > >I have already created a static splitter wnd. with a Tree View and
| > >CScrollView.
| > >
| > >At certain pt. of time in my application, I want to replace TreeView
| > >with some other view. How can I do that?
| > >
| > >I found DeleteView for CSplitterWnd. But how do I add/Insert view
after
| > >initial creation in CreateClient?
| > >
| > >Any help is appriciated.
| > >
| > >Leena
| >
| > Finally some else wants to do this!!!
| >
| > I have been thinking for some time now how to achieve this.  I have
| > recently been reading some articals in Dr. Dobbs Journal (web address
| > is: www.ddj.com) which I have found very useful.  Check out the
| > undocumented corner sections (Dec 96, Feb 97), "Appling CSplitterWnd
| > Internals".
| >
| > I have a good approach as how to achieve this, I am planning on coding
a
| > base class derived from CSplitterWnd over the next two weeks.
| >
| > --
| > Gwyn Cole
|



Sat, 03 Jul 1999 03:00:00 GMT  
 Changing View in Static CSplitter Wnd

******
I apologize if this is a repost.
I posted it to my newserver and it appeared, but it didn't appear in
msnews.microsoft.com news server list.
Has anyone else seen this phenomenon? ...Do you see one posting or two?
******

Hey,
I agree with Scot.  It might be better to create the views you need
initially and just show and hide them when you want to switch between the
two.
Here is some code I wrote awhile ago where I changed the top views in my
splitter:
(The names have been changed to protect the innocent)

First put two member variables in your top view class header file i.e.:
CFirstView * pFirstView;
CSecondView * pSecondView;

In the OnInitialUpdate of the top view of the splitter:
void CTopView::OnInitialUpdate()
{
        CScrollView::OnInitialUpdate();

        CRect rClient;
        GetClientRect(rClient);

        CRuntimeClass* pRuntimeClass = RUNTIME_CLASS( CFirstView );
        pFirstView = (CFirstView*)pRuntimeClass->CreateObject();
        ASSERT( pFirstView->IsKindOf( RUNTIME_CLASS( CFirstView) ) );

        pRuntimeClass = RUNTIME_CLASS( CSecondView );
        pSecondView = (CSecondView *)pRuntimeClass->CreateObject();
        ASSERT( pSecondView->IsKindOf( RUNTIME_CLASS( CSecondView ) ) );

        CCreateContext context;
        context.m_pCurrentDoc = GetDocument();

        pFirstView->Create(NULL,NULL,WS_CHILD|WS_VISIBLE,rStatic,this,AFX_IDW_PANE_

FIRST,&context);
        pFirstView->ShowWindow(SW_SHOW);
        GetParentFrame()->SetActiveView(pFirstView);

        pSecondView->Create(NULL,NULL,WS_CHILD|WS_VISIBLE,rStatic,this,AFX_IDW_PANE

_FIRST+1,&context);
        pSecondView->ShowWindow(SW_HIDE);

        CSize sizeTotal;
        //Todo: determine correct initial size
        sizeTotal.cx = sizeTotal.cy = 200;
        SetScrollSizes(MM_TEXT, sizeTotal);

Quote:
}

Then I added handlers for OnSize and for switching views

void CTopView::OnSize(UINT nType, int cx, int cy)
{
  CScrollView::OnSize(nType, cx, cy);

  if (pFirstView && pSecondView)
    {
    pFirstView->SetWindowPos(0,0,0,cx,cy,SWP_NOMOVE,SWP_NOZORDER);  
    pSecondView->SetWindowPos(0,0,0,cx,cy,SWP_NOMOVE,SWP_NOZORDER);  
    }

Quote:
}

void CTopView::OnSecondView()
{
  if (pFirstView && pSecondView )
    {
    pFirstView->ShowWindow(SW_HIDE),
    pSecondView->ShowWindow(SW_SHOW);
    GetParentFrame()->SetActiveView(pSecondView);
    }

Quote:
}

void CTopView::OnFirstView()
{
  if (pFirstView && pSecondView )
    {
    pSecondView->ShowWindow(SW_HIDE);
    pFirstView->ShowWindow(SW_SHOW);
    GetParentFrame()->SetActiveView(pFirstView);
    }

Quote:
}

If you have any questions feel free to e-mail me.
Later,
Robert Groat

PS Also, could you please look at my post on the Toolbar problem I am
having.  It seems painfully simple but I haven't solved it yet.



| Hi Gwyn/Leena,
|
| Check out the source code (yes - you have to do this sometimes
| when you push the MFC envelope) to CreateView/DeleteView
| in mfc\src\winsplit.cpp and you should be able to create
| a CSplitter derivative (might want to use the one we did
| for DDJ as a starting point) that has a SwitchView()
| api in it.
|
| If you get it working, please post it here for the benefit
| of all!
|
| May the MFC gods be with you,
|
| Scot
| Stingray
| http://www.stingsoft.com
|
|
|
| >

| > writes
| > >Hi!
| > >
| > >I have already created a static splitter wnd. with a Tree View and
| > >CScrollView.
| > >
| > >At certain pt. of time in my application, I want to replace TreeView
| > >with some other view. How can I do that?
| > >
| > >I found DeleteView for CSplitterWnd. But how do I add/Insert view
after
| > >initial creation in CreateClient?
| > >
| > >Any help is appriciated.
| > >
| > >Leena
| >
| > Finally some else wants to do this!!!
| >
| > I have been thinking for some time now how to achieve this.  I have
| > recently been reading some articals in Dr. Dobbs Journal (web address
| > is: www.ddj.com) which I have found very useful.  Check out the
| > undocumented corner sections (Dec 96, Feb 97), "Appling CSplitterWnd
| > Internals".
| >
| > I have a good approach as how to achieve this, I am planning on coding
a
| > base class derived from CSplitterWnd over the next two weeks.
| >
| > --
| > Gwyn Cole
|



Sat, 03 Jul 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. CSplitter/CTreeView with changing document/view on right side

2. CSplitter in CSplitter

3. Dynamic change pane for a CSplitterWnd with static view

4. Changing Views in Static Splitter?

5. Q: Change views in a static splitter window

6. Changing a static splitter's views dynamically?

7. Q: How do I embed a splitter wnd in another splitter wnd

8. Wnd::Create vs Wnd::CreateEx

9. How can I open a minimized wnd on top of a maximized wnd

10. Need wnd like channel-wnd in IE4

11. When are all views created (splitter-wnd)?

12. MDI Child Wnd, statusbar, scrollbar and list view as reportview

 

 
Powered by phpBB® Forum Software