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. How do make a FormView without Doc/View

How do make a FormView without Doc/View

Scheduled Pinned Locked Moved C / C++ / MFC
learningc++architecturequestion
9 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.
  • J Offline
    J Offline
    Jethro63
    wrote on last edited by
    #1

    Greetings: I am trying to experiment with making an application with flexible windows that show different things and can be opened and closed at will and in no particular order. I do not want to involve the document / view architecture. There's no need for an underlying document; my program receives input data from external ports of various kinds. For openers, I tried to create an SDI application with no Doc/View but whose client is a CFormView, not a CChildView. Why is this hard? Should I REPLACE the CChildView client window with a CFormView? Or, should I create a CFormView and then derive the CChildView from the new CFormView (instead of from CWnd as the App Lizard would have it)? I have a metric tonne of books on the subject of programming in MFC and I have yet to encounter one, just ONE, that clearly explains and lays out the architecture of SDI, MDI, Doc/View, non-Doc/View, splitters, CMainFrame, Views, etc, etc. I would like to understand these things in such a way that I can finally feel that I have some measure of control and choice as to how my application windows behave and can write a program that breaks from the straight jacket that is the MFC App-Lizard. Has anyone out there encountered a book or resource that does this? I mean, explain it to me like I'm 4 years old! Insult my intelligence! Just make it clear! There, I feel better. Thanks in advance to anyone who responds. Cheers, Mark

    D O 2 Replies Last reply
    0
    • J Jethro63

      Greetings: I am trying to experiment with making an application with flexible windows that show different things and can be opened and closed at will and in no particular order. I do not want to involve the document / view architecture. There's no need for an underlying document; my program receives input data from external ports of various kinds. For openers, I tried to create an SDI application with no Doc/View but whose client is a CFormView, not a CChildView. Why is this hard? Should I REPLACE the CChildView client window with a CFormView? Or, should I create a CFormView and then derive the CChildView from the new CFormView (instead of from CWnd as the App Lizard would have it)? I have a metric tonne of books on the subject of programming in MFC and I have yet to encounter one, just ONE, that clearly explains and lays out the architecture of SDI, MDI, Doc/View, non-Doc/View, splitters, CMainFrame, Views, etc, etc. I would like to understand these things in such a way that I can finally feel that I have some measure of control and choice as to how my application windows behave and can write a program that breaks from the straight jacket that is the MFC App-Lizard. Has anyone out there encountered a book or resource that does this? I mean, explain it to me like I'm 4 years old! Insult my intelligence! Just make it clear! There, I feel better. Thanks in advance to anyone who responds. Cheers, Mark

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

      Jethro63 wrote:

      my program receives input data from external ports of various kinds.

      Why would this preclude the use of Doc/View?


      "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

      "There is no death, only a change of worlds." - Native American Proverb

      J 1 Reply Last reply
      0
      • D David Crow

        Jethro63 wrote:

        my program receives input data from external ports of various kinds.

        Why would this preclude the use of Doc/View?


        "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

        "There is no death, only a change of worlds." - Native American Proverb

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

        Hi David: It doesn't necessarily, but MUST I always use Doc/View? I find that I create my application using doc/view and the "doc" component of it goes unused. Then I find it just gets in my way when I want to do something like replace one view with another, or add a new view. Its the principle of the thing really. Can't you just put up a main frame and then throw up whatever child windows you want, when you want without having to deal with all this doc/view baggage? Thank for your response. Mark

        D 1 Reply Last reply
        0
        • J Jethro63

          Hi David: It doesn't necessarily, but MUST I always use Doc/View? I find that I create my application using doc/view and the "doc" component of it goes unused. Then I find it just gets in my way when I want to do something like replace one view with another, or add a new view. Its the principle of the thing really. Can't you just put up a main frame and then throw up whatever child windows you want, when you want without having to deal with all this doc/view baggage? Thank for your response. Mark

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

          Jethro63 wrote:

          Then I find it just gets in my way when I want to do something like replace one view with another, or add a new view.

          In this situation, what is the view displaying?


          "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

          "There is no death, only a change of worlds." - Native American Proverb

          J 1 Reply Last reply
          0
          • D David Crow

            Jethro63 wrote:

            Then I find it just gets in my way when I want to do something like replace one view with another, or add a new view.

            In this situation, what is the view displaying?


            "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

            "There is no death, only a change of worlds." - Native American Proverb

            J Offline
            J Offline
            Jethro63
            wrote on last edited by
            #5

            Could be anything. Let's say I'm connected to a specialized piece of equipment and it is sending messages asynchronously through the USB port to my application. I want to offer my user 3 or 4 different ways of viewing these incoming messages: raw hex data, a scrolling list view, a graphical histogram plot, a statistcial listing. The user should be free to open, close and arrange any number and combination of these windows. At the same time, maybe I would like a "Console Window" where the user enters synchronous commands and the response from the device is displayed in the same window. Still another window (like a form view) that contains push button controls, sliders, edit boxes that handle other types of commands to the device or to the application to control its behavior. I might also want the option to turn on a diagnostics window where special program messages get directed to. I see that all of these windows involve data and I suppose that you could make it fit into the doc/view paradigm if you had a crow-bar and a sledge hammer, but I don't see how it helps me to use a doc/view based approach. I don't use serialization, I am used to saving data in files using old-fashioned read and write commands to an open file pointer. In the end, I always find that the doc/view needs a doc/view template and then I can never figure out how to open up more than one view for the same document data or create an alternate doc/view pair and it all gets way too complicated way too fast. That's my story. Any suggestions would be welcomed. Mark

            1 Reply Last reply
            0
            • J Jethro63

              Greetings: I am trying to experiment with making an application with flexible windows that show different things and can be opened and closed at will and in no particular order. I do not want to involve the document / view architecture. There's no need for an underlying document; my program receives input data from external ports of various kinds. For openers, I tried to create an SDI application with no Doc/View but whose client is a CFormView, not a CChildView. Why is this hard? Should I REPLACE the CChildView client window with a CFormView? Or, should I create a CFormView and then derive the CChildView from the new CFormView (instead of from CWnd as the App Lizard would have it)? I have a metric tonne of books on the subject of programming in MFC and I have yet to encounter one, just ONE, that clearly explains and lays out the architecture of SDI, MDI, Doc/View, non-Doc/View, splitters, CMainFrame, Views, etc, etc. I would like to understand these things in such a way that I can finally feel that I have some measure of control and choice as to how my application windows behave and can write a program that breaks from the straight jacket that is the MFC App-Lizard. Has anyone out there encountered a book or resource that does this? I mean, explain it to me like I'm 4 years old! Insult my intelligence! Just make it clear! There, I feel better. Thanks in advance to anyone who responds. Cheers, Mark

              O Offline
              O Offline
              Office Lineman
              wrote on last edited by
              #6

              This is a method for creating an MFC CFormView application with no document--and the form window is not to be resized. If you don't mind the window being resized, don't do the frame/maximize box step. Sorry about the formatting, but it's from a Word doc, and I'm too lazy to clean up Word 2K's crummy HTML output :laugh::

              1. Create a new MFC AppWizard (exe) project.
              a. MFC AppWizard - Step 1 of 6
              i. Select "Single document" for the application type.
              ii. Uncheck "Document/View architecture support?".
              b. MFC AppWizard - Step 2 of 6 - no changes
              c. MFC AppWizard - Step 3 of 6 - no changes
              d. MFC AppWizard - Step 4 of 6
              i. Set the number of files on the recent file list to 0. (optional - no MRU anyway)
              ii. Press "Advanced..."
              1. Uncheck "Thick frame" and "Maximize box", leaving only "Minimize box" and "System menu" checked. (optional)
              e. MFC AppWizard - Step 5 of 6 - no changes
              f. MFC AppWizard - Step 6 of 6 - no changes
              2. Create a CFormView for the application.
              a. Select Insert->New Form....
              b. Enter a form class name in the "Name" field, e.g. "CMyFormView".
              c. Press OK.
              d. Design the form as desired.
              3. Adjust command handlers in new CFormView-based class.
              a. Using the ClassWizard, insert a handler for OnInitialUpdate.
              b. Add the following code into the OnInitialUpdate handler where indicated:
              GetParentFrame()->RecalcLayout();
              ResizeParentToFit();
              4. Remove ChildView.h and ChildView.cpp from the project. Delete the files.
              5. Remove CChildView references from MainFrm.h
              a. Remove the "#include ChildView.h" directive.
              b. Remove the "CChildView m_wndView" member.
              6. Adjust command handlers in MainFrm.cpp
              a. Remove the OnCmdMsg handler and delete its code.
              b. Remove the OnSetFocus handler and delete its code.
              c. Edit the OnCreate handler
              i. Remove the view creation code:
              // create a view to occupy the client area of the frame
              if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
              {
              TRACE0("Failed to create view window\n");
              return -1;
              }
              ii. Remove the docking capability for the toolbar by commenting out or deleting the indicated lines. (optional)
              7. Adjust application creation in .cpp
              a. Include the view class header, e.g. "#include "MyFormView.h".
              b. Edit the InitInstance function
              i. Replace the frame loading code:
              pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, NULL);
              with the following code:
              CCreateContext

              J P R 3 Replies Last reply
              0
              • O Office Lineman

                This is a method for creating an MFC CFormView application with no document--and the form window is not to be resized. If you don't mind the window being resized, don't do the frame/maximize box step. Sorry about the formatting, but it's from a Word doc, and I'm too lazy to clean up Word 2K's crummy HTML output :laugh::

                1. Create a new MFC AppWizard (exe) project.
                a. MFC AppWizard - Step 1 of 6
                i. Select "Single document" for the application type.
                ii. Uncheck "Document/View architecture support?".
                b. MFC AppWizard - Step 2 of 6 - no changes
                c. MFC AppWizard - Step 3 of 6 - no changes
                d. MFC AppWizard - Step 4 of 6
                i. Set the number of files on the recent file list to 0. (optional - no MRU anyway)
                ii. Press "Advanced..."
                1. Uncheck "Thick frame" and "Maximize box", leaving only "Minimize box" and "System menu" checked. (optional)
                e. MFC AppWizard - Step 5 of 6 - no changes
                f. MFC AppWizard - Step 6 of 6 - no changes
                2. Create a CFormView for the application.
                a. Select Insert->New Form....
                b. Enter a form class name in the "Name" field, e.g. "CMyFormView".
                c. Press OK.
                d. Design the form as desired.
                3. Adjust command handlers in new CFormView-based class.
                a. Using the ClassWizard, insert a handler for OnInitialUpdate.
                b. Add the following code into the OnInitialUpdate handler where indicated:
                GetParentFrame()->RecalcLayout();
                ResizeParentToFit();
                4. Remove ChildView.h and ChildView.cpp from the project. Delete the files.
                5. Remove CChildView references from MainFrm.h
                a. Remove the "#include ChildView.h" directive.
                b. Remove the "CChildView m_wndView" member.
                6. Adjust command handlers in MainFrm.cpp
                a. Remove the OnCmdMsg handler and delete its code.
                b. Remove the OnSetFocus handler and delete its code.
                c. Edit the OnCreate handler
                i. Remove the view creation code:
                // create a view to occupy the client area of the frame
                if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
                {
                TRACE0("Failed to create view window\n");
                return -1;
                }
                ii. Remove the docking capability for the toolbar by commenting out or deleting the indicated lines. (optional)
                7. Adjust application creation in .cpp
                a. Include the view class header, e.g. "#include "MyFormView.h".
                b. Edit the InitInstance function
                i. Replace the frame loading code:
                pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, NULL);
                with the following code:
                CCreateContext

                J Offline
                J Offline
                Jethro63
                wrote on last edited by
                #7

                Hi "Office Lineman": I lost track of this thread and did not discover your response until today. Thank you very much for your instructions. I normally respond right away when somebody takes the time to answer a question that I post, so I feel a bit embarrased that I missed this, especially since it is clear that you spent some time on this response. I followed your instructions and they worked exactly as I had hoped. I was a bit puzzled by the final segment where the "CCreateContext" structure is brought in. After reading up on this structure, I see that most of its fields can be regarded as optional. This has lead me to an example on the MSDN DVD called "VIEWEX" which expands more on the problem that I originally pointed out: It is not obvious or straight forward how to create an application that consists simply of a main frame which can house a variety of different views, opened or closed in no particular order. I have been searching for a general understanding of all of this and it is difficult to get the answers I am looking for. Anyway, thanks again for your instructions. Mark

                1 Reply Last reply
                0
                • O Office Lineman

                  This is a method for creating an MFC CFormView application with no document--and the form window is not to be resized. If you don't mind the window being resized, don't do the frame/maximize box step. Sorry about the formatting, but it's from a Word doc, and I'm too lazy to clean up Word 2K's crummy HTML output :laugh::

                  1. Create a new MFC AppWizard (exe) project.
                  a. MFC AppWizard - Step 1 of 6
                  i. Select "Single document" for the application type.
                  ii. Uncheck "Document/View architecture support?".
                  b. MFC AppWizard - Step 2 of 6 - no changes
                  c. MFC AppWizard - Step 3 of 6 - no changes
                  d. MFC AppWizard - Step 4 of 6
                  i. Set the number of files on the recent file list to 0. (optional - no MRU anyway)
                  ii. Press "Advanced..."
                  1. Uncheck "Thick frame" and "Maximize box", leaving only "Minimize box" and "System menu" checked. (optional)
                  e. MFC AppWizard - Step 5 of 6 - no changes
                  f. MFC AppWizard - Step 6 of 6 - no changes
                  2. Create a CFormView for the application.
                  a. Select Insert->New Form....
                  b. Enter a form class name in the "Name" field, e.g. "CMyFormView".
                  c. Press OK.
                  d. Design the form as desired.
                  3. Adjust command handlers in new CFormView-based class.
                  a. Using the ClassWizard, insert a handler for OnInitialUpdate.
                  b. Add the following code into the OnInitialUpdate handler where indicated:
                  GetParentFrame()->RecalcLayout();
                  ResizeParentToFit();
                  4. Remove ChildView.h and ChildView.cpp from the project. Delete the files.
                  5. Remove CChildView references from MainFrm.h
                  a. Remove the "#include ChildView.h" directive.
                  b. Remove the "CChildView m_wndView" member.
                  6. Adjust command handlers in MainFrm.cpp
                  a. Remove the OnCmdMsg handler and delete its code.
                  b. Remove the OnSetFocus handler and delete its code.
                  c. Edit the OnCreate handler
                  i. Remove the view creation code:
                  // create a view to occupy the client area of the frame
                  if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
                  {
                  TRACE0("Failed to create view window\n");
                  return -1;
                  }
                  ii. Remove the docking capability for the toolbar by commenting out or deleting the indicated lines. (optional)
                  7. Adjust application creation in .cpp
                  a. Include the view class header, e.g. "#include "MyFormView.h".
                  b. Edit the InitInstance function
                  i. Replace the frame loading code:
                  pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, NULL);
                  with the following code:
                  CCreateContext

                  P Offline
                  P Offline
                  permutations
                  wrote on last edited by
                  #8

                  This is absolutely awesome. Thank you so much for posting this! I've been going crazy trying to figure it out.

                  1 Reply Last reply
                  0
                  • O Office Lineman

                    This is a method for creating an MFC CFormView application with no document--and the form window is not to be resized. If you don't mind the window being resized, don't do the frame/maximize box step. Sorry about the formatting, but it's from a Word doc, and I'm too lazy to clean up Word 2K's crummy HTML output :laugh::

                    1. Create a new MFC AppWizard (exe) project.
                    a. MFC AppWizard - Step 1 of 6
                    i. Select "Single document" for the application type.
                    ii. Uncheck "Document/View architecture support?".
                    b. MFC AppWizard - Step 2 of 6 - no changes
                    c. MFC AppWizard - Step 3 of 6 - no changes
                    d. MFC AppWizard - Step 4 of 6
                    i. Set the number of files on the recent file list to 0. (optional - no MRU anyway)
                    ii. Press "Advanced..."
                    1. Uncheck "Thick frame" and "Maximize box", leaving only "Minimize box" and "System menu" checked. (optional)
                    e. MFC AppWizard - Step 5 of 6 - no changes
                    f. MFC AppWizard - Step 6 of 6 - no changes
                    2. Create a CFormView for the application.
                    a. Select Insert->New Form....
                    b. Enter a form class name in the "Name" field, e.g. "CMyFormView".
                    c. Press OK.
                    d. Design the form as desired.
                    3. Adjust command handlers in new CFormView-based class.
                    a. Using the ClassWizard, insert a handler for OnInitialUpdate.
                    b. Add the following code into the OnInitialUpdate handler where indicated:
                    GetParentFrame()->RecalcLayout();
                    ResizeParentToFit();
                    4. Remove ChildView.h and ChildView.cpp from the project. Delete the files.
                    5. Remove CChildView references from MainFrm.h
                    a. Remove the "#include ChildView.h" directive.
                    b. Remove the "CChildView m_wndView" member.
                    6. Adjust command handlers in MainFrm.cpp
                    a. Remove the OnCmdMsg handler and delete its code.
                    b. Remove the OnSetFocus handler and delete its code.
                    c. Edit the OnCreate handler
                    i. Remove the view creation code:
                    // create a view to occupy the client area of the frame
                    if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
                    {
                    TRACE0("Failed to create view window\n");
                    return -1;
                    }
                    ii. Remove the docking capability for the toolbar by commenting out or deleting the indicated lines. (optional)
                    7. Adjust application creation in .cpp
                    a. Include the view class header, e.g. "#include "MyFormView.h".
                    b. Edit the InitInstance function
                    i. Replace the frame loading code:
                    pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, NULL);
                    with the following code:
                    CCreateContext

                    R Offline
                    R Offline
                    Rez_Spain
                    wrote on last edited by
                    #9

                    Man, Maybe this topic is old as f*** but im just so grateful. THANKS Office Lineman!

                    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