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 to open project files in my app, like in Visual Studio

How to open project files in my app, like in Visual Studio

Scheduled Pinned Locked Moved C / C++ / MFC
visual-studiocsharptutorialquestionworkspace
5 Posts 2 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
    Jake Palmer
    wrote on last edited by
    #1

    My goal is similar to how Visual Studio opens Project and Workspace files: those file types are associated with VS, but they don't open up Views in the middle of the screen, they just fill in some information. I want to imitate this for opening Projects in my application.:~ Are they using a doc/hidden view for this, or something tricky? :wtf: Any suggestions are appreciated. thanks, Jake

    R J 2 Replies Last reply
    0
    • J Jake Palmer

      My goal is similar to how Visual Studio opens Project and Workspace files: those file types are associated with VS, but they don't open up Views in the middle of the screen, they just fill in some information. I want to imitate this for opening Projects in my application.:~ Are they using a doc/hidden view for this, or something tricky? :wtf: Any suggestions are appreciated. thanks, Jake

      R Offline
      R Offline
      Roman Fadeyev
      wrote on last edited by
      #2

      It's very simple Override InitialUpdateFrame in your DocTemplate like that

      void CProjectDocTemplate::InitialUpdateFrame(CFrameWnd* pFrame, CDocument* pDoc,BOOL bMakeVisible)
      {
      __super :: InitialUpdateFrame(pFrame, pDoc, /*!!!!*/false);
      }

      Moreover, you can even write so:

      void CProjectDocTemplate::InitialUpdateFrame(CFrameWnd* pFrame, CDocument* pDoc,BOOL bMakeVisible)
      {
      pFrame->DestroyWindow();
      }

      just set m_bAutoDelete to false in CYourDocument class before (constructor is the best place for it).

      J 1 Reply Last reply
      0
      • R Roman Fadeyev

        It's very simple Override InitialUpdateFrame in your DocTemplate like that

        void CProjectDocTemplate::InitialUpdateFrame(CFrameWnd* pFrame, CDocument* pDoc,BOOL bMakeVisible)
        {
        __super :: InitialUpdateFrame(pFrame, pDoc, /*!!!!*/false);
        }

        Moreover, you can even write so:

        void CProjectDocTemplate::InitialUpdateFrame(CFrameWnd* pFrame, CDocument* pDoc,BOOL bMakeVisible)
        {
        pFrame->DestroyWindow();
        }

        just set m_bAutoDelete to false in CYourDocument class before (constructor is the best place for it).

        J Offline
        J Offline
        Jake Palmer
        wrote on last edited by
        #3

        Sounds great, but I am just using CMultiDocTemplates in my code. I tried to make a subclass and override InitialUpdateFrame, but I get errors with the constructor, because CMultiDocTemplate has no default constructor. It doesn't seem like MFC wants DocTemplates to be subclassed, since we can't create them in the New Class wizard. So, how did you get that CProjectDocTemplate class? thanks, Jake

        R 1 Reply Last reply
        0
        • J Jake Palmer

          Sounds great, but I am just using CMultiDocTemplates in my code. I tried to make a subclass and override InitialUpdateFrame, but I get errors with the constructor, because CMultiDocTemplate has no default constructor. It doesn't seem like MFC wants DocTemplates to be subclassed, since we can't create them in the New Class wizard. So, how did you get that CProjectDocTemplate class? thanks, Jake

          R Offline
          R Offline
          Roman Fadeyev
          wrote on last edited by
          #4

          Jake Palmer wrote: Sounds great, but I am just using CMultiDocTemplates in my code. It does not matter. Look:

          class CProjectDocTemplate : public CMultiDocTemplate
          {
          public:
          CProjectDocTemplate ( UINT nIDResource, CRuntimeClass* pDocClass, CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass );
          ...
          }

          CProjectDocTemplate ::CProjectDocTemplate ( UINT nIDResource, CRuntimeClass* pDocClass, CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass ):
          CMultiDocTemplate(nIDResource, pDocClass, pFrameClass, pViewClass)

          {
          }
          ....
          // ------- CXXXApp.InitInstance() --------//
          AddDocTemplate( new CProjectDocTemplate(
          IDR_DOC_PROJECT,
          RUNTIME_CLASS(CProjectDoc), // document class
          RUNTIME_CLASS(CMDIChildWnd), // frame class
          RUNTIME_CLASS(CProjectView) // view class
          ));

          Where is the problem?

          1 Reply Last reply
          0
          • J Jake Palmer

            My goal is similar to how Visual Studio opens Project and Workspace files: those file types are associated with VS, but they don't open up Views in the middle of the screen, they just fill in some information. I want to imitate this for opening Projects in my application.:~ Are they using a doc/hidden view for this, or something tricky? :wtf: Any suggestions are appreciated. thanks, Jake

            J Offline
            J Offline
            Jake Palmer
            wrote on last edited by
            #5

            I found a solution: returning FALSE in my document's OnOpenDocument. I get to deal with the file the user opened, but then I don't have to mess around with a doc or view hanging around. How come nobody told me about that? :cool: Jake

            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