Getting the CView to respond to the SplitterWindow,Cview messageHandlers in SDI app

I have  made a splitter window in a SDI app, it works great except that it doesnt acknowledge the CView handlers (the button is disabled..grayed out) UNLESS you have picked in the CVIEW window, then the button lights up.

The reason for this is in the CMainFrame to create a SDI splitter I have to return TRUE and not let the function OnCreateClient() do the default action of CFrameWnd::OnCreateClient(lpcs, pContext);(see below)

BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
      //deteled the splitter creation code (its standard stuff)

//by uncommenting this out then you create a view that allows active buttons
//but you will destroy your splitters
//      return CFrameWnd::OnCreateClient(lpcs, pContext);

      return TRUE;//do this so the splitter shows up in the SDI app, but button handlers to
                                  //CView are inactive unless you select the actual view
}

Is there a way to set this up so that even though you are in a sdi app with splitters, if I want to add handlers to the cview class they are enabled aoutomatically , similar to if you did call:
 return CFrameWnd::OnCreateClient(lpcs, pContext);
this will enable all buttons for a CView window, even if you didnt select in the window.

ericcncAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

waelothmanCommented:
I don't know what code you write but I think the following Code will solve your problem
Declare       CSplitterWnd m_Split; in main frame
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
      m_Split.CreateStatic(this,1,2);
                m_Split.CreateView(0,0RUNTIME_CLASS(CView2),CSize(0,0),pContext);
      m_Split.CreateView(0,1,pContext->m_pNewViewClass,CSize(0,0),pContext);
               m_Split.SetActivePane(0,1);
      return true;
}
where CView2 is the new view you did
make sure  if you use CFormView make sure you made the dialog CHILD
if any comment pleas let me know
0
ericcncAuthor Commented:
The issue is that one of my panes is a form view, and the other is the CView, and from above, I'm not sure how you do what you say knowing this?


      // Top splitter window
      if (!m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CFormView),
            CSize(0, 205), pContext)) //CSize(0, 400)
      {
            m_wndSplitter.DestroyWindow();
            return -1;
      }

      // Bottom splitter window
      if (!m_wndSplitter.CreateView(1,0,RUNTIME_CLASS(CViNView),
            CSize(0, 0), pContext)) //CSize(0, 0)
      {
            m_wndSplitter.DestroyWindow();
            return -1;
      }
      

      m_wndSplitter.RecalcLayout();

0
waelothmanCommented:
first you may want to add  m_Split.SetActivePane(0,0); at the end of the function and trturn true
2nd don't user name class CFormView insted make new vie using insert -> class and choose parent calss as CFormView and give it the id of dialog view and then user its name insted of CFormView after including header file
0
ericcncAuthor Commented:
I did the setactive pane, But If I click on the form view the button grays out.

****((((((I'm not sure what you are saying for the 2nd part)))
****((((((can you write me a example)))
I belive you are talking about the proper way to make a from view, of which I did.

((Try this make a sdi app, create a splitter view(two views) , then make a simple form view and place it into a one of two splitters, and the regular cview in the other. Then make a handler in the cview class , and make a button on the toolbar that calls this handler, you will notice that if you dont select the CView pane, it will not light up, but if you do select the cview pane it will....that is what I'm trying to solve....))



The code below is the actual code, the top pane is a formview, the botton is a cview, the form view works fine as well as the cview, but if I make a button function in the cview class the handler does not become active unless I select the cview pane.

      if (!m_wndSplitter.CreateStatic(this, 2, 1,WS_CHILD | WS_VISIBLE,AFX_IDW_PANE_FIRST ))
      {
            TRACE0("Failed to create splitter window\n");
            return FALSE;
      }



      // Top splitter window
      if (!m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CParamView),
            CSize(0, 205), pContext)) //CSize(0, 400)
      {
            m_wndSplitter.DestroyWindow();
            return -1;
      }

      // Bottom splitter window
      if (!m_wndSplitter.CreateView(1,0,RUNTIME_CLASS(CViNView),//RUNTIME_CLASS(CViNView)
            CSize(0, 0), pContext)) //CSize(0, 0)
      {
            m_wndSplitter.DestroyWindow();
            return -1;
      }
      

      m_wndSplitter.RecalcLayout();

      m_wndSplitter.SetActivePane(1,0);
      

      // Set pointers to the two splitter pane frame windows

      m_pFormView= (CFrameWnd*)m_wndSplitter.GetPane(0,0);
      ASSERT(m_pFormView);
      m_pDrawingView = (CFrameWnd*)m_wndSplitter.GetPane(1,0);
      ASSERT(m_pDrawingView);

//by uncommenting this out then you create a view that allows active buttons
//but you will destroy your splitters
//      CFrameWnd::OnCreateClient(lpcs, pContext);
//      return CFrameWnd::OnCreateClient(lpcs, pContext);

      return TRUE;

The form view is created crectly
0
waelothmanCommented:
oh sorry you was talking about the duisable in the toolbar i thought you talk about the form elemts
yes i agree with you in that but the only way to solve this problem is to handel the toolbar message in the main frame not in the view it self and the let this function to call any function you want in the view as

((CViNView*)m_Split.GetPane(0,1))->DoMyFunction();

when the function handel in the main frame it will be independant on active view so the toolbar button will be always on
i hope ypu understand me
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.