Ten years of MFC experience known microsoft technology
Author: sunhui
http://www.yesky.com.cn/softchannel/72342389024358400/20050311/1920582_1.shtml
First, first knowledge MFC
I initially knew that MFC was probably in 1993. At that time, Visual C has not yet been available. At that time, the Microsoft's C compiler was still very weak. The official name was Microsoft C / C 7.0, and the MFC version was 1.0, and there is almost no response, The best C development environment during that period is Borland C 3.1, in fact, probably in November 1992, an accidental opportunity, I appreciated Borland's power, I can't remember, I saw a wonderful integrated development environment Turbo C 3.0 for Windows, this is the first C integrated development environment in my memory in my memory. The exciting feeling is still remembering to remember, saying that at least C , Microsoft With Borland is not a level, Borland is obviously higher than Microsoft, Borland products, leaving me a deep impression. At that time, Microsoft's best development platform was Visual Basic 3.0, while Borland's Delphi is in the development phase (Delphi's code name is: "VB Killer") ..., I remembered the past more than ten years ago, I can't help but feel excited .
For more than a decade, I have used many development environments, about Visual Basic, I have used the earliest DOS version, the Windows version of Visual Basic I basically used, I still remember the number of discs of each version of VB installation disk disk . Similarly, I have used all versions of Delphi, especially Delphi 2.0, leaving me an excellent impression. Delphi provides a truly compiled visual development environment, then (around 1994), Delphi can develop a dynamic link library with the GUI, you can imagine, you can load a delphi form in Microsoft Access 2.0 applications, program interaction The feeling is really great.
Borland C is a regret that I can't erase in my heart. From Turbo C to C Builder, I deeply experience Borland's brilliant and helpless, Delphi walks from VB Killer to VB escort (you can imagine ActiveX control development technology in step from Delphi) There are many bovine, early VB has soil, early VB cannot develop dynamic link libraries, so it is unable to develop ActiveX controls, think of it is really inexplicably), Borland C fate is also unjust. Borland C 3.1 will never have, in the development of more than ten years, I have put a lot of energy on C , Borland C has brought me countless excitement, but this classic name is in competing with Microsoft. Gradually lapse ....
The appearance of MFC4.0 makes people feel that Microsoft caught up in C , and the MFC of this version was Win95 launched in Visual C 4 (Microsoft did not have VC3, VC4 previous versions were 2.2, 2.1, 2.0, 1.51 1.5, 1.0). Perhaps the disappointment of the subconscious of Borland C , I don't know the MFC, and when VC 4.2 is launched, I bought this compiler throughout the channel. Second, about Microsoft
About Microsoft, there are countless people to say to this name, this annoying name! I don't know if I like or hate. You are a programmer, your mind may be due to Microsoft's existence, even if you use Linux, you may also be because of Microsoft technical factors. How many years come, this name appears every day, I, in front of him, because you have to face the existence of Windows, but can you hate this name? Do you hate this name? I don't know if I have numb this name.
In 1998, I personally booked a Microsoft MSDN Universal version. I started to comprehensively exposure to this company's development technology. You can imagine that when you face hundreds of technology discs in 1998, you know what is called "thickness". We sometimes say that when "catching" or "reaching" Microsoft's level, we may lack the true understanding of this company "thickness". Entering MSDN, I feel that Microsoft is not a "company", but (or being formed) a "society".
At that time, the famous technical website http://www.codeguru.com All technical information was downloadable (That time http://www.codeguru.com offers the entire website content download service, about 3m or so), the famous WWW. CodeProject.com does not exist. At the beginning, I have always laid in technology comparison Microsoft and Borland, which should say that Borland is not weak than Microsoft, even if someone holds this view, but why borland goes today? And the Microsoft is in the day? A few years ago, how fierce these two companies is, but now there is another "cooperation" scene? Maybe many people think that if Borland does not exist, isn't it more powerful to Microsoft? In fact, Microsoft may be proficient in Chinese history, read "Three Kingdoms", very well, China, in fact, in the form of Borland, is very advantageous for Microsoft, at least in the form of competitors, and in fact Borland has been controlled Microsoft (Microsoft is a big shareholder of Borland). You can see some subtle phenomena: Borland provides a lot of talents for Microsoft, including the Delphi chief designer and the core member of the Borland C compiler; also provides powerful escort services for Microsoft .NET (see C # Builder , Delphi .NET). In 1998, Microsoft's COM technology is basically mature. This technology makes people feel shocking. At that time, Microsoft's opponents made "openDoc" for confrontation "COM", you see several members of the "OpenDoc" camp: IBM, Apple, Borland Novell, you will feel that this camp is very luxurious, powerful. However, the result is a powerful, "OpenDOC" has no death, and "COM" is still vibrant.
Some people say "COM" is not falling, then I don't know how Microsoft. In the competition with "OpenDoc", "COM" is a thorough victory. In the competition with "Java", "COM" has evolved in this process, and Microsoft reflects powerful absorption capacity in this process, and cannot be imagined. Tough. .NET is just a "alias" of COM. For an experienced C programmer, .net is evolution of COM, and the internal .NET is "COM 3.0" in Microsoft (OLE2 is COM 2.0), and "CLR" is an unscrupulous COM object. Someone once asked me, since the Newton era laid the foundation (think about the famous Newton-Leibniz formula), today, math still study "calcination"? The answer is of course still study! The early stage of "calculus" is aimed at functions. Modern "Fiber Bundle" is targeted by "Fiber Bundle", but the basic thinking is unchanged, just "calculus" ideas. Get reasonable extension and evolution, do you know Microsoft? Microsoft Research has a group of super-first mathematicians working for Microsoft, some of which are the winners of the Vilz Prize, and Microsoft is implementing "COM" to ".NET" like "calculus" evolution to "differential flow". From the perspective of scientific concept, COM and Java may be more comprehensive and accurate. Java may be more mature from the maturity of realization, but you see that Microsoft is chasing. Microsoft's Lenovo's Qin Qin during the Warring States Period. The Qin State during the Warring States Period, taking the measures such as "Fight Tracking" and "Weaked and Strong", today's Microsoft is also like this, VB1.0, Microsoft launches "VBX" control technology, and many small companies have survived, Microsoft themselves Does not develop "VBX" components, the same "VBX" into "OCX", Microsoft is not very powerful, but this kind of test is a response to many small companies. In 1997, Microsoft Office 97, 1998 Microsoft launched Visual Studio 6.0, giving a lot of money, providing opportunities for survival, development, such as the MICROSOFT Office 97 integrating Visual Basic for Application 5.0, which makes hundreds of software development The merchant and Microsoft signed the VBA technical license agreement, even if Autodesk has signed this protocol with Microsoft, this protocol makes each integrated VBA product gives a license fee for Microsoft pays 40 $, if you know vsip (Visual Studio Integration Protocol) Agreement, and how many companies signed a VSIP protocol, you really feel the terrible Microsoft's terrible; Microsoft Office 97, Visual Studio 6.0 user interface is very beautiful, why Microsoft's own development tool does not provide similar software Component? You have seen many third-party Microsoft allies have launched their interface libraries to imitate Microsoft, they will not be against Microsoft because they have formed an ecotrial circle that makes Microsoft and these companies to survive.
How much is Microsoft's technical reserves, people outside Microsoft are difficult to say, Microsoft China does not necessarily understand how much, in 1999, when the WTL class library has just emerged, people hope that WTL will be officially supported, or authorize to a Microsoft. A company (you can imagine the Borland C 5.0 built-in ActiveX development mechanism is based on Microsoft ATL class library?), Until today, WTL is still afraid, we fully believe that if Microsoft promotes WTL, WTL is completely popular, but Microsoft does not lack similar technologies, similar libraries include BCL (Base Control Library, a class library for developing a lightweight ActiveX control), Microsoft has a ATL-based class library, this class library is used to develop ACTIVEX Designer, ActiveX Designer is a class of objects that most of the programmers don't know. If you are familiar with Office development, you know that there is a type of object in Office VBA, which is form2, and the report designer in VB6.0 (and the famous Active Reporter) These objects, with this class library, you can provide customized visual design mechanisms for VB6.0 and integrated VBA systems, and today ActiveX Designer has evolved into designers integrated into Visual Studio .NET. . Third, learn from Microsoft
No matter what angle, I think Microsoft is worth learning. If you say that there is a disaster in this era, you should hate this guy, but you must first learn from this guy! I am inadvertently for Microsoft songs, I just want to say that I have the feeling of Microsoft technology for more than a decade.
Microsoft has benefited greatly in research development. If you are interested, you can visit http://research.microsoft.com/, although some Chinese companies have research institutes, but they have a "beads of rice grains compared to Microsoft." Also put the light? " In 2003, I experienced the MICROSOFT Asian Research Institute in Beijing. I saw that China's elites entered Microsoft's desire. In fact, human resources in China, Microsoft Asian Institutes have extended to each The core layers of the famous colleges and universities, I feel that Microsoft does not need "seeking", because as long as Microsoft needs, the elites will "flock", everyone has the reason for "understanding" and yearning to the place. If you swall it to the University of California, I think it can be understood because there are mathematical soils there, because the fruits of the fruit will be proud, because "scientific borders". Is there a national border? I don't know if there is anhydrior? ! Think about the disaster caused by DVD to bring to the domestic industry. I don't know if I should be painful. In the atmosphere of the Microsoft Campus Recruitment, I seem to understand why the "original technology" is less pitiful. I have read several masters written by Microsoft Asian Research Institute. It can be seen that Bill Gate is their spiritual leader and their piety of Microsoft, and domestic research institutions should study Microsoft's use of people. Microsoft seems to be The characters in the Three Kingdoms, I don't know if Liu Bei or Cao Cao, or the mixture of both. I often pass through the Sigma Building. The first Sigma Building has entered the feeling of "pilgrimage", and also has a hand with several levels of Microsoft China, and the tastes are really difficult.
In the Office Wars, domestic software is indeed contest in some aspects, in fact, it is actually boring, and the interface is similar to, or the user habits cannot solve the fundamental problem. A good software developer must be A software used by software, it is hard to imagine a software operational level and poor developer can develop a high level of software. One of my earliest software is Microsoft Word. At that time, the version was 2.0, probably a 1992 thing, Give me a deep impression that I integrates Word Basic in Word. Later, I came into contact with Excel 3.0, I don't expect it, Excel integrated is Excel Basic, and later use of Access Basic 1.0, in these software Before integrated into Office, I feel that these products are very convinced, very Microsoft's style, because you know, even a DOS, Microsoft provides a built-in QBasic or GW Basic. Although there are many technicians, as a technician, I think Microsoft's product concept is definitely the first, from the 1994 Office Series to Office 4.2 formed by 1997. I believe that technical ideas are leading to my country After 2002, the Office product, have you heard of the following statement? "DOS as the era of operating system, Windows is the application software; when Windows is an operating system, the Office becomes Windows of the DOS era; then if this rule, the Office does not replace Windows to become an operating system?", Now in the development field Visual Studio (.NET) is becoming another office, have you noticed? Control the Visual Studio (.NET) integrated development environment is still a Basic language engine (Visual Basic .NET). Unlike many companies, in the technical system, Microsoft almost all products are related, Windows, Office, Visual Studio .NET is different, but the public core is about to be formed, we have seen, core components, Office and Visual Studio .NET increasingly consistent, for example, Microsoft is gradually replacing the core component VBA 6.x of Office 2003, and we still have a gap between some simply rather than Microsoft products. , National procurement or government procurement support companies, do not drill research core technology, only urgent experience in short-term behavior is eager to fight with Microsoft, I don't know if there is a feeling of stunning trees, personal experience is, first learn Microsoft, walk down Learn, learn about Microsoft, in-depth understanding, then call the slogan.
Fourth, why use MFC?
After a few years of competition, Borland's OWL almost disappeared. This OWL is a very beautiful C class library, in the old age of Borland C 3.1, OWL really achieved a unique unclear. However, Borland C 4.0 missed the best time to enter the 32-bit program. Shortly after BC 4.0, the WIN95, Borland rushes, with a small "Pack", make BC4 to compile WIN4-based programs, at the time of Visual C is version 2.0, supporting Window16 version of Visual C 1.51, interesting is that Borland can simultaneously support Win16, Win32, while Microsoft has to provide different compilers for Win16, Win32. However, informal version of Visual C 2.1 and Visual C 2.2 quietly supports the latest features of Win95, the new set of public controls from Win95, in my impression, Borland's support for Win95 new features make MFC The distance from OWL is greatly shortened. Later, Borland C 4.5 did not change this situation, although Borland C 5.0 supports OWL and MFC, it is revealed that Borland C is very regrettable to go to version 5.5. Although C Builder introduces Delphi's VCL library, many C programmers do not buy, because many people with C are more likely to encode the edited mode. The emergence of Visual C 4.0, on the battlefield of C , Borland started.
MFC has developed to today, it has been more than ten years, although it is very different, but it can be sure, more than ten years of technical accumulation has laid the Survival foundation of MFC, even if Microsoft's long-range release, MFC can not launch Windows stage, fact On, Visual Studio .NET after the long-range (Longhorn) still uses the MFC as an important part. In this year's Visual Studio .NET 2005, the location of the MFC in C is still the same. The future of MFC should not worry, as long as you go deep into the .NET class library, you will find that many of the ideological mechanisms of MFC are quietly entering .NET, at the same time, Microsoft's third-party ally has been developed for MFC for more than ten years. A large expansion library, if Microsoft is a boat, the third party allies are the water of the boat. Many people think that MFC does not develop, in fact, a illusion, Visual C 6 interface is very classic, especially in the Docking control strip mechanism, in fact, Visual C 6 is completely MFC written, but the MFC class library control bar The related class is very weak, why? You will see many companies with Microsoft, and they quickly realize the Docking mechanism of Visual C 6 on the basis of MFC. This is the mildness of Microsoft. Microsoft will provide opportunities for allies, and their consistent approach is There are some interesting features in our own commercial products, making other companies to imitate to drive user groups. Borland does not have such a reserve. The prosperity of the MFC third-party market benefits from Microsoft's strategy and wise. Can the MFC cross the platform? It is theoretically, Microsoft does not do, but also a strategy, but there are many important products Microsoft almost MFC ported to other platforms, in fact, MAINSOFT, one of Microsoft partners (Windows source code is lost from this company), In the past few years, it is responsible for porting the MFC program to be transplanted above UINIX, Linux, AIX and other operating systems. The new version of Visual C MFC has supported .NET development, MFC and ATL collaboration better. According to my experience, the three of the MFC, ATL and .Net library can fully integrate into the actual development work. If you are an MFC hipster, I hope that ATL and .NET library can become your faithful left and right hands. So do you have a program that supports MFC, ATL and .NET libraries simultaneously? Of course, Visual Studio .NET IDE is! And Visual Studio .NET IDE also supports addin expansion with the .NET library, if you want to manage ATL and .Net libraries with MFC, continue to support me!
5. Know Application objects
If you are familiar with Microsoft Office, you should further analyze this large software, almost every program in Microsoft Office is two-time development, which benefits from the secondary development mechanism of Microsoft Office, one is based on the COM mechanism. The VBA model and the other is the host based on the .NET framework: Visual Studio Tools for Office. As a programmer, you should parse the technical structure of Office in the technical perspective. Microsoft's software object structure can be used through the tool OLE / COM Object Viewer provided by Visual Studio, through reference type library, you can even get a C header file that describes object information. This is a lot of benefits. A typical office usually has an Application object (or other object with it), which is equivalent to the software hub, here, we don't discuss office, talk about Application objects. Most of the software supported extension (Plugin) has similar structures. Typically, a system application object or a COM object, or a .NET object, if your system exists such objects, your system has fundamentally supporting addIN, plugin mechanism. An ideal approach is to built an ATL object or .NET object in an MFC system, how to do this later. The key to the design Application object is how to plan the properties, methods, events of this object. If you want the system to have good scalability, Application object is critical, which is also an embodiment of architecture art. The so-called addIN (PLUGIN) is the system runtime, which can be expanded according to the object library loaded according to the system. The key factor is to transmit the Application object to the AddIn (Plugin) when the system is loaded. Imagine if the Application just triggers the system event, and the addIN (Plugin) library explains the event, the task of an AddIN (PLUGIN) library is not OK! Therefore, Application object is the key to system design. If you are proficient in the ATL object, add an ATL object in your MFC system, this task can be done with VC Wizard. You have accepted a fact that there is a CXXXAPP object in the MFC program (CWINAPP derived class), now you have to do, add a corresponding ATL object. This object can be created in cxxxapp :: initInstance (). If the ATL object class is CXXXAppObject, it is recommended that you add a member variable in the CXXXAPP object object, for example: ccomobject
m_pappobj = new ccomobject
At the end of the program, release m_pappobj in cxxxapp :: exitInstance (), the statement is as follows:
Delete m_pappobj;
You can set the system's key properties into the properties of CXXXAppObject, such as the system, whether it is a multi-document, and so on. The system hopes that the function of the external call can be implemented as cxxxappObject, depending on your needs. The system requires an external extension function, which is expressed as an event of CXXXAppObject. The key is to trigger events and the event parameters provided in the appropriate location. For example, you can trigger an event onStartup at cxxxapp :: InitInstance () to start the application onStartup, the Plugin captures the event (identity confirmation, initial information query, etc.); you can trigger at cxxxapp :: exitInstance () After the application ends event, the Plugin captures the event to process the user needs the system to exit. All design depends on concrete design. How to load Plugin is an interesting question. If the plugin is implemented as a COM Category (category), you can use COM technology to enumerate this category; you can install plugin to a specific directory or through registry. Plugin's implementation can be used in COM technology, or you can use the .NET framework. Appropriate opportunity, I will provide example ...
Six, postscript
I wrote this article for a moment, it is difficult to say that it is true, still unintentional. A few days ago, I won the game in Sina.com, I think it will win, as a play fan, we have waited for more than ten years, waiting to have a cup of people who belong to the Chinese. I remember that when I still worked at the university, I was still in the university. I said that I said to me in front of me: "Hey, Yesterday, the horse XX won Li Changyi!" At the time, I was watching the newspaper in the office. The people saw that I didn't lift my head. I was very dissatisfied to grab the newspaper, I heard me: "Hello! Horse XX won Li Changyi !! You heard no !!!", I said to him: "You are very strange Well ?! Horsame XX how much disk, do you know? ", Horse XX almost always lost to Li Changyi, people are not surprising, and occasionally win, the Chinese will not find him, Li Changyu weak crown At 17, it was proud of this world. But today, the face is unchanged. A few days ago, the Zhongsijun 5 people, who were gave a flowering flow in the water, Li Changyi is the first world, so that some masters know If an opponent is him, it will order a return flight. This cup, the Chinese people lived, thanked Cui Zheyi, why? Because of this weak crown 19, Li Changyi blocked his big brother, so that the cup has a suspense. When the Chinese media said that South Korea only Li Changyi is very powerful, I don't know what is the heart or self-deception, Li Changyi, 30, I don't know how to force, Japanese years! In the face of this name, it is a bit numb, this Taiji Tiger!
The software industry has come again, the Indian Tiger, which has never been teeth, our software exports are only one-third of India, and we are shocked, how can it be? This forty-third water is very large, it is likely to be more pitiful! At that time, I participated in the official meeting of "Dalian Software Exported to China". The adult said at the meeting: "It is said that our Dalian software exported to the first, the city's leadership hopes today to give this One number, I hope that you can declare the data newspaper, last year's data can also be declared, pay attention, what we want is just data, you carefully, we have a reward, the opportunity is rare! "....... One day, several friends watching CCTV's dialogue program in my house, and the dialogue is a domestic software allocator (the owners of friends, Alpay, etc.), and the other is a delegation of India software. When asked, when the distribution software gap, our Liu Lao (on behalf of Alpi) did not say, according to his views, we have already caught up (India), ..., the meaning of India The level of this level, the Indian party, I still remember: "Whether to catch up, the international market says! In China, Indian programmers are inadequate, the technology is not good, in fact, the Indian software First pay attention to personality, many important US commercial software is developed in India ... "Our public opinion always describes the mediocrity of the consortium of Indian programmers, but the gap is gradually opened, ..., Go, Football (I'm not expressing talking, talking else!) (Example: Benshi Square), he must overcome all the brothers, then live in the interior of Master, do you know what's going on? In the future, this player has to cook for Master, bring children, to engage in health ..., the rest of the door, such a person, the way, has created a generation of Genesis, most of them Duang Fang is now, this is the provenance pattern of early Japanese Go. How many statements have the software? My earliest computer software textbook is an English version of (film-named version), different from us, the author of the book constructs "X-language", they don't talk about what C, Pascal, Basic, once lack For what mechanism, add some ingredients to "X-language". What C, Pascal, Basic, you feel almost, but now it is divided into level! We have a weak ability, but we are very particular in the language of language, don't know if it's right, many programmers may be vanity and use C , in fact, the earth people know, do the database, Delphi , VB is much stronger than C , and it is almost similar, because it is useful or the author does not write, or the author does not understand. Sometimes I am thinking, if there is no domestic demand, what will it? Perhaps the existence of software domestic demand, has created the characteristics of China software, I think the domestic industry has not fully utilized the existence of domestic demand in China, maybe China's software domestic demand is a hard injury in software.