Question on MFC program execution procedure [modified]
-
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
-
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
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. TheCCommandLineInfo
constructor initiates the operation toCCommandLineInfo::FileNew
. Then the created window is shown and asked to repaint itself with the call toUpdateWindow()
And it all begins inInitInstance()
because that is the starting point for the actual creation of the application/process....byte till it megahertz... my donation to web rubbish
-
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
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
-
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