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. Closing initial Document in MDI

Closing initial Document in MDI

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
7 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hi, I'm wondering if anyone knows how I can get rid of the initial document window that displays when an MFC MDI program first starts up? I am writing a program that would acquire images from a scanner. It would not make sense to have an empty white canvas before acquring any scans. I believe there's a function OnDocumentClose function I can use, but I have no idea where I can place such a call. Also, how would I create a new canvas? Is there a "OnDocumentOpen" of sort? Thanks! Jerry

    T D 2 Replies Last reply
    0
    • L Lost User

      Hi, I'm wondering if anyone knows how I can get rid of the initial document window that displays when an MFC MDI program first starts up? I am writing a program that would acquire images from a scanner. It would not make sense to have an empty white canvas before acquring any scans. I believe there's a function OnDocumentClose function I can use, but I have no idea where I can place such a call. Also, how would I create a new canvas? Is there a "OnDocumentOpen" of sort? Thanks! Jerry

      T Offline
      T Offline
      Tim Deveaux
      wrote on last edited by
      #2

      You can suppress this 'new file' action with

      cmdInfo.m\_nShellCommand = CCommandLineInfo::FileNothing;
      

      in your apps InitInstance. Doesn't work for SDI though.

      1 Reply Last reply
      0
      • L Lost User

        Hi, I'm wondering if anyone knows how I can get rid of the initial document window that displays when an MFC MDI program first starts up? I am writing a program that would acquire images from a scanner. It would not make sense to have an empty white canvas before acquring any scans. I believe there's a function OnDocumentClose function I can use, but I have no idea where I can place such a call. Also, how would I create a new canvas? Is there a "OnDocumentOpen" of sort? Thanks! Jerry

        D Offline
        D Offline
        Dave Glick
        wrote on last edited by
        #3

        To answer your second question the way I've always done it is as follows: 1) Find the document template (each template is a different doc/view class - you probably only have one in which case just ignore the last two lines)... POSITION DocPosition; DocPosition = GetFirstDocTemplatePosition(); CDocTemplate* first_template = GetNextDocTemplate(DocPosition); CDocTemplate* second_template = GetNextDocTemplate(DocPosition); CDocTemplate* third_template = GetNextDocTemplate(DocPosition); 2) Create a new file CSomethingDoc* newdoc = STATIC_DOWNCAST(CSomethingDoc, first_template->CreateNewDocument()); 3) Do any work in the Document class you need to and then show the new file CFrameWnd* newframe = first_template->CreateNewFrame(newdoc, NULL); newframe->InitialUpdateFrame(newdoc, TRUE); Hope that helps. -Dave

        J 1 Reply Last reply
        0
        • D Dave Glick

          To answer your second question the way I've always done it is as follows: 1) Find the document template (each template is a different doc/view class - you probably only have one in which case just ignore the last two lines)... POSITION DocPosition; DocPosition = GetFirstDocTemplatePosition(); CDocTemplate* first_template = GetNextDocTemplate(DocPosition); CDocTemplate* second_template = GetNextDocTemplate(DocPosition); CDocTemplate* third_template = GetNextDocTemplate(DocPosition); 2) Create a new file CSomethingDoc* newdoc = STATIC_DOWNCAST(CSomethingDoc, first_template->CreateNewDocument()); 3) Do any work in the Document class you need to and then show the new file CFrameWnd* newframe = first_template->CreateNewFrame(newdoc, NULL); newframe->InitialUpdateFrame(newdoc, TRUE); Hope that helps. -Dave

          J Offline
          J Offline
          Jerry Wang 0
          wrote on last edited by
          #4

          Hi Dave, it's been a while, but thanks for your posted reply on how to create a new document in CWinApp. I didn't get a chance to implement it until now. I have a follow up question I hope you can help me with. The code you described to me is for CWinApp class. How would I be able to do the same thing inside MainFrm class? Obiously GetFirstDocTemplatePosition() is only exsistant in CWinApp, and I do not know of a way to acquire a pointer to CWinApp from MainFrm. Would you know a way to do that? I appreciate it. Thank you. Jerry

          J D 2 Replies Last reply
          0
          • J Jerry Wang 0

            Hi Dave, it's been a while, but thanks for your posted reply on how to create a new document in CWinApp. I didn't get a chance to implement it until now. I have a follow up question I hope you can help me with. The code you described to me is for CWinApp class. How would I be able to do the same thing inside MainFrm class? Obiously GetFirstDocTemplatePosition() is only exsistant in CWinApp, and I do not know of a way to acquire a pointer to CWinApp from MainFrm. Would you know a way to do that? I appreciate it. Thank you. Jerry

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

            Use AfxGetApp(); This can be called from your main frame class. HTH Jignesh

            J 1 Reply Last reply
            0
            • J J Patel

              Use AfxGetApp(); This can be called from your main frame class. HTH Jignesh

              J Offline
              J Offline
              Jerry Wang 0
              wrote on last edited by
              #6

              Worked like a charm!! :-D Thank you thank you.

              1 Reply Last reply
              0
              • J Jerry Wang 0

                Hi Dave, it's been a while, but thanks for your posted reply on how to create a new document in CWinApp. I didn't get a chance to implement it until now. I have a follow up question I hope you can help me with. The code you described to me is for CWinApp class. How would I be able to do the same thing inside MainFrm class? Obiously GetFirstDocTemplatePosition() is only exsistant in CWinApp, and I do not know of a way to acquire a pointer to CWinApp from MainFrm. Would you know a way to do that? I appreciate it. Thank you. Jerry

                D Offline
                D Offline
                Dave Glick
                wrote on last edited by
                #7

                No problem... Try looking into AfxGetApp() -Dave

                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