Write it before this article, I use Visual C to have nearly 5 years. During this time, I have also hired Visual Basic and Delphi, but they all tasted and stop; Visual C is always my main business. But what is the result of hard work? I made more than a do two or three months with VB - although I used to use VB - although I used in VB - there are two decent items; however, I paid the biggest enthusiasm And the up to the Visual C , but only three software you can see. Of course, when using Visual C , the MFC helped me very busy. However, when writing this topic, I have already set up my mind: In this article, I only propose to MFC, and I don't say good words. The supporters of Visual C and slow hair, listen to me. I noticed that Mr. Xiangjie is like the MFC's extremely loved by the MFC, and the evaluation of MFC is also tryable to be objective and fair in its "in-depth light-out MFC"; and Master Charles Petzold and Jeff Prosise are in their works. It is only given MFC to praise cautious. Charles Petzold is also very polite to point out the limitations of the MFC. However, some of the authors of some programming books, especially some domestic authors, seems to have unfortunately give the most gorgeous language and the most exaggerated praise to MFC, and open a book from the bookshelf. Let's see it. The preface and the preface, often full of disturbing overflows. How many beginners are attracted by these hints and induced vhetments, thinking that MFC is fully visual, things that are easy to master as VB, when they are in depth, will there be a feeling? I hate all irresponsible exaggerations and show off, especially in order to increase book sales, I don't hesitate to speak with conscience, and my feelings are now the author and books seem to have extensive. My purpose is very clear in the guiding ideology that must be accessed, that is to criticize MFC. Readers who are very familiar with Visual C and MFC, I don't think you have criticized and accuse this article, because you have your own point of view on MFC, you will not mislead it; for Visual C , I hope you are After listening to the praise of Visual C and MFC, listen to another sound, even if it is not completely correct (even full of fallacy), at least let you take your own thoughts to see what you want to learn.
One of the criticisms of MFC: does not support attributes, what is the MFC counter the same other language? Stealing the concept of "Property" in programming language is one of the most important innovations after object-oriented programming. In fact, most programming languages in the market, including VB, Delphi, C Builder and PowerBuilder, etc. As long as the programmer is a simple modification of the properties of the object, it is possible to complete a considerable part of the work, not only to reduce unnecessary labor, but more importantly, it reduces the chance of error, and makes a more complex interface and completing more complex work. It is relatively easy to work. I think most people will agree. If you go to Property things, then like VB and Delphi like this, ActiveX, including Microsoft, has lost most of the charm. This truth, Microsoft should recognize it when you launch Visual Basic 1.0. However, since Visual C is born to now, it seems to have not used Property meaning, although Visual C this name is in a very large program, it has a large program, but it does not learn how to make programming from VB. Simple and easier secret. Some people may say that Data MEMBER OF CLASS is not Property? No, if you use C Builder, you will definitely understand this. The MFC never supports Property, and it will not seem in the future, which means with MFC, you still have to work hard. (ActiveX? Nice, ActiveX supports Property, and MFC supports ActiveX development, but this is not a place where it works in three.)
Two of the criticism of MFC: Monotone processing makes it complicated to make it complicated to this point: use the Visual C development interface, especially the Microsoft so-called "standard" program, than VB, Delphi Or C Builder is much slower. (With the comment, I don't know what Microsoft develops the Windows logo standard, and requires the basis for the programmer to comply with the basis; I don't meet this standard more than 99% of my own procedures.) Why is this? Is it a C language in this area? Certainly not. In my opinion, the culprit is CDOCTemplate in the MFC. This class specifies a very dead and mechanical mechanism, which is one document, a view and a framewnd. Unfortunately, the actual situation is often more complicated. Most of the program that is slightly required for the interface. Most of the requirements of the Document have multiple views, even in some programs, I hope to display multiple documents in the same view: For example, put the performance of the two companies together Comparison. There is also a similar situation to the relationship between View and FrameWnd. However, the mechanism of DOCTEMPLATE makes it quite difficult to change this. Want to achieve your requirements? can. You have to add a new View class. You have to replicate resources from the default IDR_MAINFRAME to the new class. You have to add a custom template with AddDDOCTemplate. You have to retrieve the template list with getFirstDoCtemplatePosition and getNextDoCtemplate. You have to use GetDocString to see if each template meets your requirements. You have to overload CFrameWnd :: OnCreateClient to derive new views. You have to use CView :: Setdlgctrlid and CFrameWnd :: SetActiveView and CFrameWnd :: ReCalcLayout to switch in each view. You have to manage document templates with unapplicted CDOCManager. Do you want ... Anyway, I am afraid.
Three criticisms of MFC: Skating self-sealing, do not think that MFC can be used as a living materials for solid self-sealing. Don't forget, MFC is the product of the same era of Borland OWL (how many people remember o?) Of course, this is not an MFC error. However, if there is no change in the 2.0 version since the system of the class library, does it mean that this class library is already perfect? No, even if Microsoft doesn't dare to be so arrogant. But the fact is that the MFC system has no change since MFC2.0. Each version is updated, but it has added some new classes, and some types of interfaces have been modified, only this is. No, don't use ATL as an improvement of MFC; ATL has never rely on MFC. Everyone knows how much improvement in the C language in these years. Including RTTI, Dynamic Creation, Exception, Standard Template Library, etc. are part of the new C standard. However, Microsoft seems to do not like these new things, and its approach is another stove; there is a two sets of mutually incompatible implementation in the same set of Visual C . In the case of the introduction of the new C standard, Microsoft has realized these mechanisms. It is really a quite a great innovation; but the history is always developing. Why is MFC not to use the functions that have been implemented in the language, not to stubborn Use your own set of old ways? In fact, MFC has almost no beneficial elements in the new C program - although these programs have made a fairly perfect and practical solution to many of the MFC libraries.
Critique of MFC: Natural tendency does not know what you feel about the default items generated by AppWizard. Anyway, my feelings are: this project is used to develop programs such as Word, Excel. It seems that MFC is naturally inclined to have a program. But in fact, this kind of program is less. In Microsoft, it seems that each program should have a File menu, and this menu should have new, open, save, exit these options. In my actual experience, I only have a program that meets such a request. How many people really have to engage a word handler or spreadsheet? For many common, database-based programs, do you need new, open and save? If is the network-based program? Especially in multimedia programs and gaming programs, the framework generated by the MFC is helpful, but it is better to say that it is cumbersome. This is in line with Microsoft's consistent style: you want to just a specific function, but it is a big string that is not coherent, and in many cases, these discrepancies have become troublesome. So, I have to go back to the new generation of "generos" gifts, including a large number of useless menus and toolbar buttons, and then they can start actual work. To be honest, AppWizard also adds me a lot of labor while reducing the workload. The MFC defines a Document-View framework and is considerably widely defined, and can almost represent any data. But in implementation, Document is quite narrow; such as Document defined serialize fixed with a CARCHIVE object, and CARCHIVE is fixed with a CFILE, so that the object that defines document processing can only be Disk file. Moreover, serialization of all data in a serialize is also a mechanism for mechanical and dead plates: it can only handle small quantities and have a data over, and in fact, the program often has to process large block data, and It is impossible to complete it once. In this case, CDocument's processing mechanism is an obstacle. In addition, in many types of programs, cdocument plays a very embarrassing role: For example, in most database programs, cdocument is completely chicken ribs. The actual data processing can only be done by CRecordset; more, for example, in the most Typical Doc-View Programs - Notepad Programs - CDocument is an incomplete thing because it access data is required to help CeditView :: SerializeRaw. Does the DOC-VIEW framework be able to break through these restrictions? It is entirely possible. However, you have to be psychologically prepared. If you want to make this, you must ask for a lot of unapplicared functions and types, these things don't have a document at all, depending on how familiar with your things under MFC "," And whether you are willing to study the source code of MFC - in most cases this is not a pleasant job. If you use these unapproved things, or you don't know how to use it, sorry, Microsoft will not give you any support - Who will teach you not follow Microsoft's logic!