Re: MFC Splitter roadblock
It almost sounds like you would be better off using TABS rather than radio buttons to select your views.
Re: MFC Splitter roadblock
Quote:
Originally Posted by
zapper222
It almost sounds like you would be better off using TABS rather than radio buttons to select your views.
Hopefully I didn't misquote that earlier.
The idea is to have a list view on the left pane with several items in it. When the user selects an item and/or selects a radio button, the right pane form would change
Re: MFC Splitter roadblock
Wouldn't CSplitterWnd:: DeleteView and CSplitterWnd::CreateView do it for you?
Re: MFC Splitter roadblock
Quote:
Originally Posted by
GCDEF
Wouldn't CSplitterWnd:: DeleteView and CSplitterWnd::CreateView do it for you?
Maybe I am a bit confused on where that should be called out.
In the example I am using now, it is a splitter window without the doc/view architecture.
I have MainFrm, CFormLeft, CFormRight, CRightForm2.
In the OnCreateClient for MainFrm I have:
Code:
if (!m_wndSplitter.CreateStatic(this, 1, 2))
return FALSE;
if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CFormLeft), CSize(125, 100), pContext) ||!m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CFormRight), CSize(100, 100), pContext))
{
m_wndSplitter.DestroyWindow();
return FALSE;
}
I am using two dialogs attached to the Left and Right forms. I have a third dialog for the Right2 form.
What I want to be able to do is to switch to the Right2 when I click a button from the Left form.
Add the event handler for the button but not sure what the next step is. I don't assume I can delete and create a view from the LeftForm button event function.
What function is it up on the MainFrm that would be called when I hit the button on the LeftFrm that I could then do the suggested "Delete then Create" step.
Thanks so much for the information thus far.
Re: MFC Splitter roadblock
Quote:
Originally Posted by
PBarnes
I don't assume I can delete and create a view from the LeftForm button event function.
Why not. I don't know, but I'd try using the two functions I mentioned. Delete the old view and create the new one.
Re: MFC Splitter roadblock
Quote:
Originally Posted by
GCDEF
Why not. I don't know, but I'd try using the two functions I mentioned. Delete the old view and create the new one.
Code:
void CFormLeft::OnBnClickedButtonHello()
{
// TODO: Add your control notification handler code here
//DeleteView
CSplitterWnd::DeleteView(0,1);
}
Output:
Error 1 error C2352: 'CSplitterWnd::DeleteView' : illegal call of non-static member function
CFormLeft has a base class of CFormView.
It is called from MainFrm in the OnCreateClient function to create the splitter.
MainFrm has the m_wndSplitter member which would probably be able to call a delete/create on the views. However, I am not sure how/where I would need to be at in the MainFrm to call that appropriately.
Re: MFC Splitter roadblock
Quote:
Originally Posted by
PBarnes
Code:
void CFormLeft::OnBnClickedButtonHello()
{
// TODO: Add your control notification handler code here
//DeleteView
CSplitterWnd::DeleteView(0,1);
}
Output:
Error 1 error C2352: 'CSplitterWnd::DeleteView' : illegal call of non-static member function
CFormLeft has a base class of CFormView.
It is called from MainFrm in the OnCreateClient function to create the splitter.
MainFrm has the m_wndSplitter member which would probably be able to call a delete/create on the views. However, I am not sure how/where I would need to be at in the MainFrm to call that appropriately.
Put the button handler in your left view, then call AfxGetMainWnd() to get a pointer to your CMainFrame and from there, its m_wndSplitter
Re: MFC Splitter roadblock
Thanks so much for the continued support once again. This has been an incredible headache.
This is the code from the button handler:
Code:
void CFormLeft::OnBnClickedButtonHello()
{
// TODO: Add your control notification handler code here
//CSplitterWnd:: DeleteView and CSplitterWnd::CreateView
CMainFrame* x = (CMainFrame*)AfxGetMainWnd();
x->m_wndSplitter.DeleteView(0,1);
}
What happens now is that I click the button...nothing appears to change. I click the button a second time and it crashes out.
I am assuming this is because I have not replaced the view and it is just coming back to delete something that does not exist.
(Confirmed. So far so good)
The next step is to create the new view in that function.
Code:
void CFormLeft::OnBnClickedButtonHello()
{
// TODO: Add your control notification handler code here
//CSplitterWnd:: DeleteView and CSplitterWnd::CreateView
CMainFrame* x = (CMainFrame*)AfxGetMainWnd();
x->m_wndSplitter.DeleteView(0,1);
x->m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CFormRight2),CSize(100,100), x->m_pContext);
}
You can see that I deleted the view, then attempted to create the new view. I saved the pContext from the MainFrm OnCreateclient() into a class member so I could reuse it here, as you can see.
BEFORE button click:
http://i.imgur.com/Cdf4g.jpg
AFTER button click:
http://i.imgur.com/n6bhz.jpg
Pardon the outside links but I was not sure of the attachment policy on these forums.
As you can see in the After button click, it looks like the second form CFormRight2 is being created, but is then stuffed in the upper left corner of the screen instead of being placed in the previous position of CFormRight (That you can see from the first picture)
Any thoughts on what is happening that I am missing?
Thanks again GCDEF. You have been an enormous help thus far
Re: MFC Splitter roadblock
For some ideas, see the "FormSwap" sample code from the "C++ Q&A" column in the December 1998 issue of Microsoft Systems Journal: http://www.microsoft.com/msj/1298/c/c1298.aspx
Also look at the following KB article: "How to Replace a View in a Splitter Window" at http://support.microsoft.com/kb/q149257/
Mike