Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2003-11-02
6
389 Views
Last Modified: 2010-04-17
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.

0
Comment
Question by:ericcnc
  • 3
  • 2
6 Comments
 
LVL 5

Expert Comment

by:waelothman
ID: 9704108
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
 

Author Comment

by:ericcnc
ID: 9707663
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
 
LVL 5

Expert Comment

by:waelothman
ID: 9708413
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
 

Author Comment

by:ericcnc
ID: 9711426
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
 
LVL 5

Accepted Solution

by:
waelothman earned 250 total points
ID: 9711612
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
allswap challenge 6 116
Hide vba in gp 7 104
Beginner to Unreal Engine 4 5 94
Octopus Deploy: need a Time Event that fires every midnight 2 15
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…

828 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