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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Switching between two different views in CSplitterWnd

Switching between two different views in CSplitterWnd

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
4 Posts 3 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.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    Hi. please help I have associated one pane of a view created by CSplitterWnd to a CFormView derived class in OnCreateClient, now I want to switch between different CFormView classes at runtime. what is the safe way to do that? should I do that from CDocument class or... thank you

    I 1 Reply Last reply
    0
    • A Anonymous

      Hi. please help I have associated one pane of a view created by CSplitterWnd to a CFormView derived class in OnCreateClient, now I want to switch between different CFormView classes at runtime. what is the safe way to do that? should I do that from CDocument class or... thank you

      I Offline
      I Offline
      Iain Clarke Warrior Programmer
      wrote on last edited by
      #2

      I know Paul Dilascia wrote an article on replacing views many years ago on MSJ[^]. You should also be able to do a search on codeproject for "replacing view" or such. Iain.

      B 1 Reply Last reply
      0
      • I Iain Clarke Warrior Programmer

        I know Paul Dilascia wrote an article on replacing views many years ago on MSJ[^]. You should also be able to do a search on codeproject for "replacing view" or such. Iain.

        B Offline
        B Offline
        bilas
        wrote on last edited by
        #3

        How about this (fragments of my code): //first of all (as example, you need to do it in your way): CMainFrame *pMainFrame=(CMainFrame*)AfxGetMainWnd(); //then change your view (pMainFrame->m_wndSplitter).ReplaceView(RUNTIME_CLASS( CRightView ), CSize(100,100)); //or (pMainFrame->m_wndSplitter).ReplaceView(RUNTIME_CLASS( CColorRight ), CSize(100,100)); Hope, this will help you, bilas.:->

        I 1 Reply Last reply
        0
        • B bilas

          How about this (fragments of my code): //first of all (as example, you need to do it in your way): CMainFrame *pMainFrame=(CMainFrame*)AfxGetMainWnd(); //then change your view (pMainFrame->m_wndSplitter).ReplaceView(RUNTIME_CLASS( CRightView ), CSize(100,100)); //or (pMainFrame->m_wndSplitter).ReplaceView(RUNTIME_CLASS( CColorRight ), CSize(100,100)); Hope, this will help you, bilas.:->

          I Offline
          I Offline
          Iain Clarke Warrior Programmer
          wrote on last edited by
          #4

          It won't help *me* much, or anyone using MFC4.2 (comes with VC++ 6). I've just looked at the docs, and also the relevant header file, and ReplaceView is not a member of CSplitterWnd. It might be under later versions though. Behind the times, I am. If that actually is cut and paste from your code, rather than from memory, I'm surprised there's no paramater for *which* splitter view to change. Or did you have your own splitter pane which only changes (eg.) the pane on the right? Being picky, I would recommend he handles this in his CChildFrame (MDI) or CMainFrame (SDI), so the casting wouldn't be necessary. But I was lazy! But doing the search I recommended comes up with an article on how to do exactly what I think Anonymous wants.

          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