Discussion on MS Vsual C
--VSUAL C learning to talk about johnny.deng
The technical problem of all the best, especially for the C : C language itself is one, the naming rules of the MFC huge library are their second. The basic movements of the well-known Windows program are unattended is the three, objects to the idea and Application Framework's packaging is four. Just entered the hall of Vsual C , my head is like a big screen, I can't stay; all categories are extremely representative, I have forgotten; many global variables, global functions, no macro makes me dizzy.
The process is more difficult, and the gem is more embarrassed. Here, write my feelings, I hope everyone will give correct.
First, this is my true feeling:
First, about the "debugging" of the program: I started to get more and more profound programs in the program design, from the initial Delphi, I started to change the debugging work: a dozens of rows of procedures may Will not debug this word, especially in the Delphi era of driving, I feel that debugging is just a small tool for editing and compilation, because the error rarely occurs, and will be easily resolved; approaching C and hundreds thousand Write program, I started to feel debugging work hardships and insurmountable, without any other way to see the wrong end from the no-shaped lengthy program, only debug it, watch it, step by step.
Second, about "Help": The help of the Delphi era is my best friend, no him, I am almost unshiring, retreating the Valley. But to VSUAL C , I found that the help seem to write to our beginners to see, the lengthy macro, many parameters, "Deo's English", you don't even want to stop in "help" "F1".
What else? I think: I want to compare Delphi and vsual C in the Philippine Cognition of Vsual C , please give more teachers to correct:
It should first be pointed out that both can generate each other Object files with each other.
(1) Compiler: I personally think that Borland's compiler is the leader, Borland has always had the best compiler development group in the world (although Anders Hejlsberg leaves). Vsual C is easy to give a short false appearance of a program, which is because .dll. For example, such as MDI routines: New ... | Projeces | MDI Application in Delphi, use MDI App Wizard in Vsual C ; generated program function is very similar. The following is the comparison result:
(Delphi open optimization, VSUAL C uses minimum code optimization)
Delphi 6 Vsual C 6.0
Dynamic Link 46.5K 112K
Static Link 477k 2.04M
(2) Grammatical description: a Multiple inheritance: Object Pascal does not support multiple inheritance, Object Pascal implements multiple inheritance through the interface (Interface). The Interface can not only introduce objects implemented with Object Pascal, but also into objects implemented by other languages, and VCL is not used to inherit. C is of course not to say! B object template: Object Pascal does not support object template. Because the object template is a macro language implementation. C overload: Object Pascal supports the overload of the function / process, does not support operator overload. C all support. (3) Implementation: C more emphasizes flexibility, while Object Pascal is more implicit and beautiful.
⑷ Using the range: A General Delphi seems to be driven, Vsual C can make any hardware allowed work; b is in the development of the database, Delphi is more resorted;
⑸ Application Frame: VCL is more technical than MFC, which is more technical, and it is more in the sky in the sky, and the MFC is encapsulated in a lower order. It is not very object, this is history. Left remains!
Second, MS VSUAL C mechanism:
I can only talk about the basic mechanism you should know about VSUAL C programming from the crude understanding of VSUAL C , and divide it into these aspects (if you pay attention, I have ever sent something about MFC) :
(1) The execution process of Windows program:
The program initialization process calls CREATEWINDOW, establish a window for the program, as a screen stage of the program, the CERATEWINDOW generates a window to send the wm_create directly to the window function, the latter can then do some initialization operations (profile, open files, read the initial data ...); In the process of programs, constantly capture messages from the message queue from the message queue; if this message is WM_QUIT, getMessage will pass the 0 and end the While loop, end the entire program DispatchMessage helps with the Windows User module Supervise, assisted the message to the window function, the message will be discriminated and executed; the program is not performed two steps; when the user presses the close command in the system menu, the system is sent out after the WM_CLOSE, usually the fierce window function after not intercept this message and deal with it by the DefWindowProc, DefWindowProc by calling WM_CLOSE, call DestroyWindow the window clear, DestroyWindow itself will send WM_DESTROY; WM_DESTROY standard procedure is to reflect the notes of PostQuitMessage; PostQuitMessage nothing else, just send WM_QUIT Message, ready to get getMessage in the message loop, end the message loop.
(2) Application Framework Application:
Application Framework has become the mainstream tool developed on the PC platform. He reduced our time to spend the time of the vast Windows API, bringing the revolution on object-oriented programming concepts and methods, so that we can work hard in a group of excellent engineers. On the heart, inherit its results and develop its own procedures. Among them, OWL and MFC are among the leaders. Tools with Application Framework have similar to the Windows API feature, but they don't have the huge, but they don't have the huge size of Application Framework, and there is no advanced macro, they just "have object-oriented. The nature of the class, they can only make the app to achieve more, these features such as numerical operations, data structures, drawings, memory management, etc., these classes can only be incorporated into applications in one piece, but Application Framework This is a complete program model that has all the basic functions required by the standard application, which is closely integrated with the Application Framework, forming a large model in which there is no inter-object structure. (3) VISUAL C program: in (1) About the implementation of the Windows SDK program, there is also a process of entering, executing, and ending in the MFC, and the two have similar, just because MFC is originally packaged for Windows APIS, but Compared with the Win32 program, the head is clear, the MFC program is more difficult to ponder, it seems that it is difficult to understand, in fact, the program process of the MFC is so clear. In Scheme RAW WINDOWS API procedure is such that: WINMIAN -àREGISTERCLASSàCREATEWINDOWàGETMESSAGE / DISPATCHMESSAGEàWINDOW PROCDDUREàAPIS; MFC in the program flow is: CWINAPP substituted WINMAIN status, the program represents the body, representing a main window CFRAMEWND; also from the head of the program files It can be seen in some ends: STDAFX.H is loaded into AFXWIN.H, and AfxWin.h contains AFX.H, and Afx.h has also been loaded into AFXVER_.H.
The AFXVER_.H has also loaded AFXV_W32.H, and the latter also loaded Windows.h, which is exactly that the SDK program needs to be loaded.
⑷ message mapping mechanism: a, message classification: wm_command, this is a message generated by the UI (user interface), may come from the menu or accelerator button or the toolbar button, received by the ccmdtarget; standard message, except WM_COMMAND Any of WM_ is as followed by CWnd classes; Control Notification, this is an control generated, accepted by its parent window, notifying some situations. b, message dispatch mechanism: Replaced the message assignment in GetMessage / DispatchMessage, Visual C is implemented by the definition macro in each class. The definition of three macros is in Afxwin.h, because of the space and time limit, I only extract a graphic of the secondary data structure, as shown. The message function of this class is contacted by the MessageMap structure type, and the MessageMap of his parent class is associated with a huge message network.
Third, good at learning, be a good programmer:
(1) I think, the programmer should not depend on the development tool, and the programmer should have a thinking, a spirit, a concept. Just like Richard.m.stallman, there is your own spirit and struggle for free software. Just like seeking Bo Jun, struggling for the revitalization of the national software. This is a real programmer.
(2) The program written by the programmer is not an algorithm syntax, but to meet the tools for user needs. To meet user needs, we must consider all aspects, such as business, human-machine interaction, efficiency, etc., not just a language ( Syntax) problem, language (syntax) is just a tool, I only know the grammar, I don't know other, the programming machine
(3) Learning VC must have a fanatical enthusiasm, otherwise it is difficult to persist, to learn VC, must have a deep understanding of C , a deep understanding of the Windows operating mechanism. Especially those who want to be VC masters. I used to see a programming experience for VC, first extracted:
1. Technology-based, language is time.
2. MFC's single class is useful, and DOC / View is careful.
3. OOP should be careful, causing a lot of work and bad code using improper use.
4. If possible, consider using Delphi (CBuilder VCL).
5. To a certain level, you must learn COM.
Fourth, conclusion:
Finally, he also extracted that the words of the process of learning vsual C as a conclusion: vsual C is like the ejaculation in the "Lietian Dragon Slay", it is a treasure, but it is very difficult, Vsual C master is rare animal!
1 Look at the C grammar book, know the concept of the class.
2 Turn the VC Getting Started Tutorial, familiar with the development environment and common interface MFC classes.
3 Write a small game, don't know the place reference example (MSDN), the goal: cultivate the necessary skill.
4 Write communication class, find this example, the target: familiar with the underlying characteristics.
5 Become a VC master.
The language does not have the language of the language, the structure is rigorous, the execution speed is fast, the error rate is low, the size is small, the sacrifice is time, the development cycle is too long, in the society, this is clear, obvious Although there is a bit of a little or less, although the speed is slow, the volume is huge, the error rate is high, the structure is not rigorous but the development cycle is short, there is a sentence, learn, learn, all!
Total number of words: Pure text 3012; character: 4427