How does a C + + learner with a certain foundation learn to program Windows?

Source: Internet
Author: User

Human psychology has a singular character: once learned, the learning process is faced with confusion and puzzled very quickly will forget clean, it seems that everything is natural, it is this. Therefore, the question of "How to get Started", to find top experts to answer, may not be better than a person who has just started to answer. For example, the answer to the highest ticket, is a very proficient in the Windows programming of the high man answer, but this answer can give the beginning to learn how much help the people, I would like to make a question mark first.

some time ago just tutored a student to learn Win32 GUI programming, just see this question, conveniently invited him to answer. Not to give him a summary of the work, but hope to get firsthand experience and personal experience from him, can give a friend who has not yet started to bring a lot of other help. Unfortunately, after reading his answer, I felt that his summary was rather out of place. A good summary, should be able to let a person who has not yet started to read, you can copy his learning process, and learn the same degree as he is now. It's a pity that this summary is all about something that is thin and small, and one of the most critical core issues is not mentioned. I can only stand in my perspective to summarize this question again, I hope this student after reading my summary, can again change his answer, so that it can really start to learn from the people practical. In addition, the answer to these questions I hope he does not use anonymous identity, this is a statement of their own attitude is responsible for it.

Next I'll summarize how I tutor this student to learn Win32 GUI programming:

———— Body ————

This article only touches on the Win32 GUI primer, does not involve other topics of Windows programming, such as network operations, asynchronous IO, system services, thread synchronization and so on, do not because I did not mention those content to jump out of my "irrelevantly replying", I believe the main question is not to ask the topic.

The first and foremost thing to learn about Windows programming is that C must get started. This request sounds like nonsense, but in fact, most of the computer majors in China are not able to achieve the undergraduate degree or even Master's degree, so I have to put it separately to emphasize again. After the introduction of C language and then learn Windows programming, can avoid very many unnecessary setbacks, save a lot of time. Of course, there are a lot of people in the C language without the introduction of the case started the Windows programming learning, everywhere hit the beaten up and still learned Windows programming, and by the way the C language is also introduced, such as me, but I do not feel that this experience is worth to all people. Personally, I think it's a cost-effective way to stay in the black box and start learning about Windows programming by starting with the C language.

As for C + + learning, C + + and Windows programming are two unrelated skill trees, learning C + + does not require you to understand Windows programming, and writing Windows programs does not have to use C + +. Familiarity with C + + may be an indirect help in learning Windows programming, but at least there is no direct connection, and you can start learning Windows programming without learning C + +.

to get started with Windows programming, the most important thing is not to read what textbooks, what tools to use, but first must be the following for the first to learn the very easy confusion of important concepts to understand:

1. Encoding and character set for text. This part needs to master the difference between ANSI mode and Unicode mode (and it is clear that both ANSI and Unicode are misused by terminology); It is clear that these two patterns are actually implemented by a macro Dirty-hack (a significant number of people have been bitten by this macro for the actual job); know how to write Unicode-compatible code by TCHAR, _t (), conditional compilation, and so on, even if the source code for all of the Windows programs you write in the future will be pure Unicode, will no longer support ANSI-mode compilation).

2. Familiar with common Win32 type names (such as LRESULT, WPARAM, UINT, LPCTSTR, etc.), know what is the function call specification (such as __stdcall, __cdecl, etc., and common aliases such as WINAPI, PASCAL and so on. It is not required to remember how these invocation specifications are implemented at the assembly level, just need to know that they are different and presumably understand why they are different and why they cannot be mixed.

3. Understand the approximate principle of handle and resource management. This part of the requirements is relatively simple, a C language is really getting started in the previous study should have been involved in dynamic memory allocation and management, but also in some exercises to implement a similar handle in the object-oriented packaging, so when learning here only to the handle and what he had learned before the link together, This part is not difficult to learn. But suppose you encounter dynamic memory allocation when still make a mess, for the full transfer of the object, life cycle management and so on confused, I personally suggest you go back to the "black box" to the C language to learn about Windows programming.

4. Understand the message model. When a program calls GetMessage, your program is not executing until you receive the message, which is the equivalent of dying there, which is quite counterintuitive for anyone who has never been in touch with Win32 GUI programming, and needs to give enough examples to help him understand why a " You don't get the message, you die there. "Notepad can be done with the mouse a little menu will be able to pop up, no one moved it when the cursor is still at any time flashing a flash and so on. When thinking turns around and understands the concept, it's natural to be clear about why you can't take time-consuming actions in a window, what the UI thread and the worker are for, and when you need to start a worker thread.

5. Understand the form redraw mechanism. This is in fact a sub-topic of the message model, but because it is very disturbing to the person who just started learning, I put it alone as a point. Under Windows 9x, when a form appears above another form, it erases the contents of the following form. When the above form leaves, the following form needs to redraw the content that it has erased. Higher version of Windows although the system can proactively cache the contents of a covered form, from a programmatic point of view, the program Ape still has to follow the previous form-drawing mechanism to write its own program, assuming that its own program is overwritten when it is erased. In order to be able to properly handle the erase and redraw, the content of the drawing form must be done by listening to redraw the message, if you want to change the contents of the form, you can not draw the form at any time, but you must first prepare the content to be drawn but not draw, then send a message trigger redraw message Let the system inform you to draw. The understanding and mastery of these anti-intuitive behaviors is the threshold that must be crossed in the beginner's time.

After all these concepts are mastered, Getting started Win32 GUI programming is a relatively easy thing to do. Next only to find a novice tutorial, step-by-year examples are all over, and then hand-written several GUI applet, almost the same also get started. The student in summing up when mentioned that I recommended a very famous tutorial, I am very sorry to disappoint him, the tutorial in fact, I have not seen it, I just found a tutorial on the internet, looked at the folder, he started to find the knowledge points above are listed, and then sent to him. In short, the introduction of Windows programming, the most important thing is to understand and grasp the above mentioned basic concepts, concepts mastered, no matter what a serious error and flawed textbooks can be used to get started, as for the detailed API how to use, when used to check the manual can be, not necessary to "learn API The use of "as a focus to conquer."

summarize so much first, welcome to add!

Http://www.bcwhy.com/thread-21734-1-1.html

How does a C + + learner with a certain base learn to program Windows?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.