Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Multiple views in one frame

Multiple views in one frame

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Maarten Kools
    wrote on last edited by
    #1

    Hi, I'm creating an MDI application in MFC but I need to display different views which correspond with some user setting. But I can't figure out how to display two different views in the same frame window. So I want to display either view A or view B, not both at the same time. Is this even possible?

    A P M 3 Replies Last reply
    0
    • M Maarten Kools

      Hi, I'm creating an MDI application in MFC but I need to display different views which correspond with some user setting. But I can't figure out how to display two different views in the same frame window. So I want to display either view A or view B, not both at the same time. Is this even possible?

      A Offline
      A Offline
      Anonymous
      wrote on last edited by
      #2

      Try using splitter windows

      M 1 Reply Last reply
      0
      • A Anonymous

        Try using splitter windows

        M Offline
        M Offline
        Maarten Kools
        wrote on last edited by
        #3

        But won't the user be able to move the splitter back and forth? What I exactly want is to have view A be visible with some combo menu selection, and view B being visible with another combo menu selection

        B 1 Reply Last reply
        0
        • M Maarten Kools

          But won't the user be able to move the splitter back and forth? What I exactly want is to have view A be visible with some combo menu selection, and view B being visible with another combo menu selection

          B Offline
          B Offline
          Bob Stanneveld
          wrote on last edited by
          #4

          If that's the only difference between both views, try loading the contents of the combo box at runtime! Then this would be the case: Step 1: Create the window and one or more CDoc's. (Keep the window invisible) Step 2: Load the contents of the combo box dynamically (probably in OnInitialUpdate) according to your specifications. Step 3: Show the window. Good luck!

          A student knows little about a lot. A professor knows a lot about little. I know everything about nothing.

          1 Reply Last reply
          0
          • M Maarten Kools

            Hi, I'm creating an MDI application in MFC but I need to display different views which correspond with some user setting. But I can't figure out how to display two different views in the same frame window. So I want to display either view A or view B, not both at the same time. Is this even possible?

            P Offline
            P Offline
            peterchen
            wrote on last edited by
            #5

            This is for SDI, but can be adapted to SDI the basic idea is to create all views and hide all but the one visible. The Doc/View architecture already takes care of managing multiple views (if used correctly) Clickety[^] or maybe our friend[^] can help


            we are here to help each other get through this thing, whatever it is Vonnegut jr.
            sighist || Agile Programming | doxygen

            1 Reply Last reply
            0
            • M Maarten Kools

              Hi, I'm creating an MDI application in MFC but I need to display different views which correspond with some user setting. But I can't figure out how to display two different views in the same frame window. So I want to display either view A or view B, not both at the same time. Is this even possible?

              M Offline
              M Offline
              mostafa_pasha
              wrote on last edited by
              #6

              To build an MDI application with two views 1. Build an MDI application by using MFC AppWizard. AppWizard will create a skeleton MDI application with a single view. 2. Add a new class derived from the CView class. 3. Add debug and nondebug versions of the GetDocument function. Use the GetDocument functions from your existing view class as a model. 4. Include the header file for the document class in the source file of the new view class. 5. Place the command handlers in the CChildFrame class. It is easier to access the view or the document from CChildFrame rather than from the view class. Use the CFrameWnd::GetActiveView and CFrameWnd::GetActiveDocument functions to access the views and the document. 6. Add a handler for the OnDraw event of the new view class. At this point, you must decide whether you want users to select the type of view at application startup, or whether you want to have your application start with a default view. In either case, the user can select another view at run time. void CMainFrame::OnWindowItalics() { if (0 == m_pItalicsTemplate) { m_pItalicsTemplate = new CMultiDocTemplate( IDR_XXXXTYPE, RUNTIME_CLASS(CXXXXViewsDoc), RUNTIME_CLASS(CChildFrame), RUNTIME_CLASS(CItalicsView)); } CMDIChildWnd* pActiveChild = MDIGetActive(); CDocument* pDocument; if (NULL == pActiveChild || (pDocument = pActiveChild->GetActiveDocument()) == NULL) { TRACE0("Warning: No active document.\n"); AfxMessageBox(AFX_IDP_COMMAND_FAILURE); return; // command failed } CFrameWnd* pFrame = m_pItalicsTemplate-> CreateNewFrame(pDocument, pActiveChild); if (NULL == pFrame) { TRACE0("Warning: failed to create new frame.\n"); return; // command failed } m_pItalicsTemplate->InitialUpdateFrame(pFrame, pDocument); }

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups