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. Question on MFC program execution procedure [modified]

Question on MFC program execution procedure [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
c++debuggingquestion
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.
  • C Offline
    C Offline
    cy163 hotmail com
    wrote on last edited by
    #1

    Hi, ALL I am using VC++ 6.0. I created a single document MFC application. I did not add any new codes to the project. After compiling, the program works fine. To learn the execution procedure, i set some break points within BOOL CxxxApp::InitInstance(), CxxxDoc::OnNewDocument() and CxxxView::OnInitialUpdate(). I run the application in debug mode. I observe that the program first goes into InitInstance(). After exeuting if(! ProcessShellCommand(cmdInfo)) within InitInstance(), the program goes into CxxxDoc,then into CxxxView. After that, the program goes back into InitInstance() again to execute the remaining two statements

    m_pMainWnd->ShowWindow(SW_SHOW);
    m_pMainWnd->UpdateWindow();

    I tried but failed to find the intrinsic reason. What makes the program to run in this manner. I found nowhere CxxxDoc::OnNewDocument() and CxxxView::OnInitialUpdate() are called explicitly

    BOOL CxxxApp::InitInstance()
    {
    AfxEnableControlContainer();

    #ifdef \_AFXDLL
    	Enable3dControls();
    #else
    	Enable3dControlsStatic();
    #endif
    
    SetRegistryKey(\_T("Local...));
    
    LoadStdProfileSettings();
    CSingleDocTemplate \* pDocTemplate;
    pDocTemplate = new CSingleDocTemplate(
    	IDR\_MAINFRAME,
    	RUNTIME\_CLASS(CxxxDoc),
    	RUNTIME\_CLASS(CMainFrame),
    	RUNTIME\_CLASS(CxxxView));
    AddDocTemplate(pDocTemplate);
    CCommandLineInfo cmdInfo;
    ParseCommandLine(cmdInfo);
    if(!**ProcessShellCommand(cmdInfo))<----**
    	return FALSE;
    m\_pMainWnd->ShowWindow(SW\_SHOW);
    m\_pMainWnd->UpdateWindow();
    

    }

    Would you please recommand some reference books or articles on this to me.

    modified on Tuesday, December 14, 2010 8:20 AM

    L D Y 3 Replies Last reply
    0
    • C cy163 hotmail com

      Hi, ALL I am using VC++ 6.0. I created a single document MFC application. I did not add any new codes to the project. After compiling, the program works fine. To learn the execution procedure, i set some break points within BOOL CxxxApp::InitInstance(), CxxxDoc::OnNewDocument() and CxxxView::OnInitialUpdate(). I run the application in debug mode. I observe that the program first goes into InitInstance(). After exeuting if(! ProcessShellCommand(cmdInfo)) within InitInstance(), the program goes into CxxxDoc,then into CxxxView. After that, the program goes back into InitInstance() again to execute the remaining two statements

      m_pMainWnd->ShowWindow(SW_SHOW);
      m_pMainWnd->UpdateWindow();

      I tried but failed to find the intrinsic reason. What makes the program to run in this manner. I found nowhere CxxxDoc::OnNewDocument() and CxxxView::OnInitialUpdate() are called explicitly

      BOOL CxxxApp::InitInstance()
      {
      AfxEnableControlContainer();

      #ifdef \_AFXDLL
      	Enable3dControls();
      #else
      	Enable3dControlsStatic();
      #endif
      
      SetRegistryKey(\_T("Local...));
      
      LoadStdProfileSettings();
      CSingleDocTemplate \* pDocTemplate;
      pDocTemplate = new CSingleDocTemplate(
      	IDR\_MAINFRAME,
      	RUNTIME\_CLASS(CxxxDoc),
      	RUNTIME\_CLASS(CMainFrame),
      	RUNTIME\_CLASS(CxxxView));
      AddDocTemplate(pDocTemplate);
      CCommandLineInfo cmdInfo;
      ParseCommandLine(cmdInfo);
      if(!**ProcessShellCommand(cmdInfo))<----**
      	return FALSE;
      m\_pMainWnd->ShowWindow(SW\_SHOW);
      m\_pMainWnd->UpdateWindow();
      

      }

      Would you please recommand some reference books or articles on this to me.

      modified on Tuesday, December 14, 2010 8:20 AM

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      There are a lot of things here to explain. I suggest you to either buy a book or read MSDN. However to answer you, What you see is what happens when you have the doc/view architecture. Try removing it from the project creation process and you will get a completely different set of code and code flow. WRT this particular instance that you are asking about, the steps are pretty simple actually. A document template is created and marked. The ProcessShellCommand(...) does some bit of processing that creates a document, frame (with menu etc) and the view. Look into that function. The CCommandLineInfo constructor initiates the operation to CCommandLineInfo::FileNew. Then the created window is shown and asked to repaint itself with the call to UpdateWindow() And it all begins in InitInstance() because that is the starting point for the actual creation of the application/process.

      ...byte till it megahertz... my donation to web rubbish

      1 Reply Last reply
      0
      • C cy163 hotmail com

        Hi, ALL I am using VC++ 6.0. I created a single document MFC application. I did not add any new codes to the project. After compiling, the program works fine. To learn the execution procedure, i set some break points within BOOL CxxxApp::InitInstance(), CxxxDoc::OnNewDocument() and CxxxView::OnInitialUpdate(). I run the application in debug mode. I observe that the program first goes into InitInstance(). After exeuting if(! ProcessShellCommand(cmdInfo)) within InitInstance(), the program goes into CxxxDoc,then into CxxxView. After that, the program goes back into InitInstance() again to execute the remaining two statements

        m_pMainWnd->ShowWindow(SW_SHOW);
        m_pMainWnd->UpdateWindow();

        I tried but failed to find the intrinsic reason. What makes the program to run in this manner. I found nowhere CxxxDoc::OnNewDocument() and CxxxView::OnInitialUpdate() are called explicitly

        BOOL CxxxApp::InitInstance()
        {
        AfxEnableControlContainer();

        #ifdef \_AFXDLL
        	Enable3dControls();
        #else
        	Enable3dControlsStatic();
        #endif
        
        SetRegistryKey(\_T("Local...));
        
        LoadStdProfileSettings();
        CSingleDocTemplate \* pDocTemplate;
        pDocTemplate = new CSingleDocTemplate(
        	IDR\_MAINFRAME,
        	RUNTIME\_CLASS(CxxxDoc),
        	RUNTIME\_CLASS(CMainFrame),
        	RUNTIME\_CLASS(CxxxView));
        AddDocTemplate(pDocTemplate);
        CCommandLineInfo cmdInfo;
        ParseCommandLine(cmdInfo);
        if(!**ProcessShellCommand(cmdInfo))<----**
        	return FALSE;
        m\_pMainWnd->ShowWindow(SW\_SHOW);
        m\_pMainWnd->UpdateWindow();
        

        }

        Would you please recommand some reference books or articles on this to me.

        modified on Tuesday, December 14, 2010 8:20 AM

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

        cy163@hotmail.com wrote:

        I found nowhere CxxxDoc::OnNewDocument() and CxxxView::OnInitialUpdate() are called explicitly

        They are called from within the MFC framework.

        "One man's wage rise is another man's price increase." - Harold Wilson

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        "Man who follows car will be exhausted." - Confucius

        1 Reply Last reply
        0
        • C cy163 hotmail com

          Hi, ALL I am using VC++ 6.0. I created a single document MFC application. I did not add any new codes to the project. After compiling, the program works fine. To learn the execution procedure, i set some break points within BOOL CxxxApp::InitInstance(), CxxxDoc::OnNewDocument() and CxxxView::OnInitialUpdate(). I run the application in debug mode. I observe that the program first goes into InitInstance(). After exeuting if(! ProcessShellCommand(cmdInfo)) within InitInstance(), the program goes into CxxxDoc,then into CxxxView. After that, the program goes back into InitInstance() again to execute the remaining two statements

          m_pMainWnd->ShowWindow(SW_SHOW);
          m_pMainWnd->UpdateWindow();

          I tried but failed to find the intrinsic reason. What makes the program to run in this manner. I found nowhere CxxxDoc::OnNewDocument() and CxxxView::OnInitialUpdate() are called explicitly

          BOOL CxxxApp::InitInstance()
          {
          AfxEnableControlContainer();

          #ifdef \_AFXDLL
          	Enable3dControls();
          #else
          	Enable3dControlsStatic();
          #endif
          
          SetRegistryKey(\_T("Local...));
          
          LoadStdProfileSettings();
          CSingleDocTemplate \* pDocTemplate;
          pDocTemplate = new CSingleDocTemplate(
          	IDR\_MAINFRAME,
          	RUNTIME\_CLASS(CxxxDoc),
          	RUNTIME\_CLASS(CMainFrame),
          	RUNTIME\_CLASS(CxxxView));
          AddDocTemplate(pDocTemplate);
          CCommandLineInfo cmdInfo;
          ParseCommandLine(cmdInfo);
          if(!**ProcessShellCommand(cmdInfo))<----**
          	return FALSE;
          m\_pMainWnd->ShowWindow(SW\_SHOW);
          m\_pMainWnd->UpdateWindow();
          

          }

          Would you please recommand some reference books or articles on this to me.

          modified on Tuesday, December 14, 2010 8:20 AM

          Y Offline
          Y Offline
          yu jian
          wrote on last edited by
          #4

          MFC 程序设计

          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