CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Jul 2013
    Location
    USA
    Posts
    30

    CFormView as Main View

    Is it possible to use a CFormView as the main view without using document support. IE pointing CWinApps m_pMainWnd to the CFrameWnd derived MainFrame and attaching the CFormView from there. It does not seem to be working and I was wondering before I waste any more time on the solution if it is even possible. I know it is an easy solution if I create a true SDI application however I have no use for documents in this application.

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: CFormView as Main View

    It's possible, but I'm not sure what the point would be. You could always create a doc/view app but just not use the doc part of it. It won't to have a CDocument class in your project, and leaving it in is easier than trying to force it to work without it.

  3. #3
    Join Date
    Jul 2013
    Location
    USA
    Posts
    30

    Re: CFormView as Main View

    That's what I was suspecting. Was just hoping I could do it without document support because without registering the doc and calling on new wont the app fail on creation?

  4. #4
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: CFormView as Main View

    You could stop through the OnFileNew code and pull out the document stuff, but again, I don't see the point.

  5. #5
    Join Date
    Jul 2013
    Location
    USA
    Posts
    30

    Re: CFormView as Main View

    True. I just kept the document in added cs.style &= ~FWS_ADDTOTITLE; to precreatewindow and just ignored all other document calls except for the initial creation. I felt it was just easier just to create a blank WIN32 project and add my classes manually instead of using the predefined MFC wizard. Thanks for your feedback though.

  6. #6
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: CFormView as Main View

    Quote Originally Posted by RobNHood View Post
    I felt it was just easier just to create a blank WIN32 project and add my classes manually instead of using the predefined MFC wizard.
    It's rarely ever better to start from scratch when using MFC. Even if you could do it, you usually end up with code that is difficult to maintain (by experienced MFC folks) and often breaks the standard MFC IDE features like the class wizard.

  7. #7
    Join Date
    Jul 2013
    Location
    USA
    Posts
    30

    Re: CFormView as Main View

    I am a retired programmer (turning 50 next month) with VI for over 20 years. It has been a while however since I have had the need to work with Windows GUI since almost all of the programming I have done did not require GUI. So I am a bit rusty in that area but it is all coming back to me. I found it better to always work without the wizards. For MFC I just add #include <afxwin.h> and then set the program configuration to link with MFC and include the optional libs I require and add a rc file then any class is ready to be added via normal means. This always means less overhead, smaller compiled size and only the required includes you actually need. I am not a novice when it comes to programming I have been doing it since the days of DOS I do appreciate your input though and for most I am sure the wizards are fine. I just prefer more control.

  8. #8
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: CFormView as Main View

    Quote Originally Posted by RobNHood View Post
    I am a retired programmer (turning 50 next month) with VI for over 20 years. It has been a while however since I have had the need to work with Windows GUI since almost all of the programming I have done did not require GUI. So I am a bit rusty in that area but it is all coming back to me. I found it better to always work without the wizards. For MFC I just add #include <afxwin.h> and then set the program configuration to link with MFC and include the optional libs I require and add a rc file then any class is ready to be added via normal means. This always means less overhead, smaller compiled size and only the required includes you actually need. I am not a novice when it comes to programming I have been doing it since the days of DOS I do appreciate your input though and for most I am sure the wizards are fine. I just prefer more control.
    My experience is from the pain of taking over built from scratch MFC projects where nothing basically works. In this case, trying to add a new dialog or a view becomes a royal hassle because all the MFC plumbing is broken. Unfortunately, folks that start from scratch generally don't know what they've broken, because they don't use the wizards or the other features.

    That being said, to each his own and that's the cool thing about programming: there are many ways of skinning the cat.

  9. #9
    Join Date
    Jul 2013
    Location
    USA
    Posts
    30

    Re: CFormView as Main View

    If you start with 0 files add add a stdafx.h with 1 line #include <afxwin.h>add a stdafx.cpp with #include "stdafx.h" then link to MFC as shared lib then the MFC Class wizard will work as usual with nothing broken that is all MFC actually requires to function. I have since added 6 dialogs, Propertysheets and pages for configuration, dockable panes, toolbars etc. all functional with no build errors. Just try the bare minimum as I pointed out and afterwards use the class wizard to add a CWinAppEx, CFrameWndEx, CView and CDocument and you will see it is much easier and more efficient than using MFCs wizard and templates.

  10. #10
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: CFormView as Main View

    I'm with Arjay on this one, which is why I suggested use the normal framework but ignore the document. It's going to work, and other programmers will understand it and know how to work with it.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured