At this time, there is only one dialog in the Resource's dialog box:
Run down to discover, here if the CRichEditView is selected:
If you click Save As, the suffix will appear here:
Let's look at its Class View:
What is the difference between a document and a view? A document has only one copy, and the view can have multiple copies, for example, for a txt it is a document:
But you can open n times:
Let's follow the code flow. Let's look at the app first, which is the class that characterizes the application, with its constructor as follows:
The definition of this class in its header file is as follows:
We can see in the app file:
This defines an app's own class, where we place breakpoints, and run, and so on, we step into the Theapp constructor:
But as we step in, we come to the CWinApp constructor:
This CWinApp is the parent of Theapp. This class has its own parent class:
So I stepped into the CWinThread constructor:
Step Into:
Step forward again to come:
There's nothing to do here, one step into its subclass, and then back to the subclass of subclasses, until we go back to:
Many steps have actually been performed. We step into, run to here:
But found in the Watch window that the this pointer is not CWinApp but his subclass:
Why?
See also: http://blog.csdn.net/ningyaliuhebei/article/details/42292147 's explanation. Because the object we are creating is mfcfirstsinefile, he will pass the address of the created object, that is, the address of the Theapp as a parameter to the Theapp constructor, and the Theapp constructor calls the CWinApp constructor first. The parameter passed to CWinApp is the address of Theapp.
The following is a class view to understand the MFC structure.
In CMainFrame, you perform some creation operations, such as creating toolbars, status bars:
Alt+g into the first oncreate you can also see that it creates help:
Then look at PreCreateWindow, which has a macro function:
Go into:
The form class is registered inside this function.
When you finish creating the form, you also hook it up:
The hook function hooks up the WH_CBT message:
This message is triggered when Windows activates, generates, releases (shuts down), minimizes, maximizes, or alters the window.
There's one behind:
Here is the implementation of the shortcut keys. In the resource view, we can also see these shortcut keys:
To proceed, execute to here:
A form has been updated:
But stuck can't move. Perform:
The entire form is displayed:
Go back and you'll see:
This function is to completely let the form run up. Let's look at the code:
There is no stopping to receive messages here. The pumpmessage in the top is executed:
After run, the program is up and running.
A detailed description of the--MFC encapsulation mechanism in Windows programming step