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. Two different views in a splitter window, one doc (SDI)

Two different views in a splitter window, one doc (SDI)

Scheduled Pinned Locked Moved C / C++ / MFC
help
4 Posts 4 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
    mandanani
    wrote on last edited by
    #1

    The summary of my problem is this: two different views in a splitter window, one doc (SDI). I want to access the document's members from both views. I've created an application with a CSplitterWnd in my MainFrame. I've created the two views using m_wndSplitter.CreateView(....); That displays fine. Wonderful. I've got a variable in my doc class, int lookie. It's public. My class names are as follows: CThingApp -> the app class CThingDoc -> the doc class CThingControlView -> the form view containing the controls CThingDisplayView -> the graphical view displaying the data CMainFrame -> frame class CThingControlView was created with the whole project. I added CThingDisplayView. So I changed the code in CThingApp:InitInstance() to look like this: //////////////////////////// CSingleDocTemplate* pDocControlTemplate; pDocControlTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CThingDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CThingControlView)); AddDocTemplate(pDocControlTemplate); //////////////////////////// This seems to work. Here's where my confusion sets in. I *thought* I now need to add the following code immediately beneath the above code: //////////////////////////// CSingleDocTemplate* pDocDisplayTemplate; pDocDisplayTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CThingDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CThingDisplayView)); AddDocTemplate(pDocDisplayTemplate); //////////////////////////// I now believe that to be a false assumption because, upon building, the application displays a funny little window with the title new and what appears to be a list of options. There are two options with exactly the same text (which appears to be shortenings of my project name). If I select either one the application then starts. Because this was incorrect behavior, I commented out the second document template code and tried several different ways of just *accessing* the data in CThingDoc from CThingDisplayView. Nothing's working. I'm sure there is a simple solution to this. Something that my examples neglect to tell me or that I'm just not noticing.

    R J D 3 Replies Last reply
    0
    • M mandanani

      The summary of my problem is this: two different views in a splitter window, one doc (SDI). I want to access the document's members from both views. I've created an application with a CSplitterWnd in my MainFrame. I've created the two views using m_wndSplitter.CreateView(....); That displays fine. Wonderful. I've got a variable in my doc class, int lookie. It's public. My class names are as follows: CThingApp -> the app class CThingDoc -> the doc class CThingControlView -> the form view containing the controls CThingDisplayView -> the graphical view displaying the data CMainFrame -> frame class CThingControlView was created with the whole project. I added CThingDisplayView. So I changed the code in CThingApp:InitInstance() to look like this: //////////////////////////// CSingleDocTemplate* pDocControlTemplate; pDocControlTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CThingDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CThingControlView)); AddDocTemplate(pDocControlTemplate); //////////////////////////// This seems to work. Here's where my confusion sets in. I *thought* I now need to add the following code immediately beneath the above code: //////////////////////////// CSingleDocTemplate* pDocDisplayTemplate; pDocDisplayTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CThingDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CThingDisplayView)); AddDocTemplate(pDocDisplayTemplate); //////////////////////////// I now believe that to be a false assumption because, upon building, the application displays a funny little window with the title new and what appears to be a list of options. There are two options with exactly the same text (which appears to be shortenings of my project name). If I select either one the application then starts. Because this was incorrect behavior, I commented out the second document template code and tried several different ways of just *accessing* the data in CThingDoc from CThingDisplayView. Nothing's working. I'm sure there is a simple solution to this. Something that my examples neglect to tell me or that I'm just not noticing.

      R Online
      R Online
      Rage
      wrote on last edited by
      #2

      Here you have a goog tutuorial about the splinter window : http://www.codeproject.com/splitter/splitterwindowtutorial.asp[^] I do not think you need to recreate a template for the second view...

      http://www.readytogiveup.com/[^] - Do something special today.

      1 Reply Last reply
      0
      • M mandanani

        The summary of my problem is this: two different views in a splitter window, one doc (SDI). I want to access the document's members from both views. I've created an application with a CSplitterWnd in my MainFrame. I've created the two views using m_wndSplitter.CreateView(....); That displays fine. Wonderful. I've got a variable in my doc class, int lookie. It's public. My class names are as follows: CThingApp -> the app class CThingDoc -> the doc class CThingControlView -> the form view containing the controls CThingDisplayView -> the graphical view displaying the data CMainFrame -> frame class CThingControlView was created with the whole project. I added CThingDisplayView. So I changed the code in CThingApp:InitInstance() to look like this: //////////////////////////// CSingleDocTemplate* pDocControlTemplate; pDocControlTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CThingDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CThingControlView)); AddDocTemplate(pDocControlTemplate); //////////////////////////// This seems to work. Here's where my confusion sets in. I *thought* I now need to add the following code immediately beneath the above code: //////////////////////////// CSingleDocTemplate* pDocDisplayTemplate; pDocDisplayTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CThingDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CThingDisplayView)); AddDocTemplate(pDocDisplayTemplate); //////////////////////////// I now believe that to be a false assumption because, upon building, the application displays a funny little window with the title new and what appears to be a list of options. There are two options with exactly the same text (which appears to be shortenings of my project name). If I select either one the application then starts. Because this was incorrect behavior, I commented out the second document template code and tried several different ways of just *accessing* the data in CThingDoc from CThingDisplayView. Nothing's working. I'm sure there is a simple solution to this. Something that my examples neglect to tell me or that I'm just not noticing.

        J Offline
        J Offline
        jhwurmbach
        wrote on last edited by
        #3

        Stop fiddling around with the DocumentTemplate! You'll eventually destroy your application and need to start over! Create the splitter with its views a s described in the other post. Then, to access the document, you need to use

        CThingDoc* pDoc = dynamic_cast(GetDocument());
        if()
        {
        //do it
        }

        in your CThingDisplayView and CThingControlView.


        Failure is not an option - it's built right in.

        {

        1 Reply Last reply
        0
        • M mandanani

          The summary of my problem is this: two different views in a splitter window, one doc (SDI). I want to access the document's members from both views. I've created an application with a CSplitterWnd in my MainFrame. I've created the two views using m_wndSplitter.CreateView(....); That displays fine. Wonderful. I've got a variable in my doc class, int lookie. It's public. My class names are as follows: CThingApp -> the app class CThingDoc -> the doc class CThingControlView -> the form view containing the controls CThingDisplayView -> the graphical view displaying the data CMainFrame -> frame class CThingControlView was created with the whole project. I added CThingDisplayView. So I changed the code in CThingApp:InitInstance() to look like this: //////////////////////////// CSingleDocTemplate* pDocControlTemplate; pDocControlTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CThingDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CThingControlView)); AddDocTemplate(pDocControlTemplate); //////////////////////////// This seems to work. Here's where my confusion sets in. I *thought* I now need to add the following code immediately beneath the above code: //////////////////////////// CSingleDocTemplate* pDocDisplayTemplate; pDocDisplayTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CThingDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CThingDisplayView)); AddDocTemplate(pDocDisplayTemplate); //////////////////////////// I now believe that to be a false assumption because, upon building, the application displays a funny little window with the title new and what appears to be a list of options. There are two options with exactly the same text (which appears to be shortenings of my project name). If I select either one the application then starts. Because this was incorrect behavior, I commented out the second document template code and tried several different ways of just *accessing* the data in CThingDoc from CThingDisplayView. Nothing's working. I'm sure there is a simple solution to this. Something that my examples neglect to tell me or that I'm just not noticing.

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          For splitter windows, you only need one CSingleDocTemplate object that is created like:

          CSingleDocTemplate* pDocControlTemplate;
          pDocControlTemplate = new CSingleDocTemplate(
          IDR_MAINFRAME,
          RUNTIME_CLASS(CThingDoc),
          RUNTIME_CLASS(CMainFrame), // main SDI frame window
          RUNTIME_CLASS(NULL));
          AddDocTemplate(pDocControlTemplate);


          "A good athlete is the result of a good and worthy opponent." - David Crow

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

          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