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

Source: Internet
Author: User

People's psychology has a wonderful characteristic: once learned, the learning process of the confusion and understanding will soon be forgotten clean, it seems that everything is natural, it should be so. 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 Windows programming high man answer, but such an answer can give beginners a lot of help, I would like to first hit a question mark.

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 assignment, just hope to get firsthand experience and personal experience from him, can bring more help to friends who have not yet started. 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, can copy his learning process, and learn the same degree as he is. It is a pity that this summary is all about the thin stub, but one of the most critical core issues is not mentioned. I can only stand in my perspective to summarize this question again, I hope the student after reading my summary, can revise his answer, so that it can really be useful for beginners. 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 covers 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 requirement sounds like nonsense, but in fact at present, most of the computer majors in China are not able to achieve a graduate degree or even a master's degree, so I have to put it separately to emphasize again. After the introduction of C language and then learn Windows programming, you can avoid 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 began 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 think this experience is worth to everyone. Personally, I think it's a cost-effective way to stay in the black box and start learning about Windows programming before you get started with C.

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 have 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 any textbooks, what tools to use, but to first make clear the following important concepts that are very confusing for beginners:

1. Encoding and character set for text. This part requires mastering the differences between ANSI mode and Unicode mode (and understand that both ANSI and Unicode are in fact a misuse of terminology); understand 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 all 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 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 requirement is relatively simple, a C language really get started students, 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 you learn this here, as long as the handle and what he has learned before the link together, This part is not difficult to learn. But if you encounter dynamic memory allocation is still a mess, for object ownership transfer, 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 running until you receive the message, which is the equivalent of dying there, which is quite counter-intuitive 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 think about why you can't take time-consuming actions in the form process, what the UI threads and worker threads do, and when to start a worker thread.

5. Understand the form redraw mechanism. This is actually a sub-topic of the message model, but due to the introduction of the novice will bring a lot of trouble, so I put it alone as a point. In Windows 9x, when a window appears above another window, it erases the contents of the window below. When the above window leaves, the following window needs to redraw the contents of the erased content. Newer Windows Although the system is able to automatically cache content on a masked form, from a programmatic point of view, programmers still need to follow the previous window drawing mechanism to write their own programs, assuming that their programs are overwritten when they are erased. In order to be able to properly handle the erase and redraw, the content of the drawing window must be done by listening to redraw the message, if you want to change the contents of the window can not be drawn to the window at any time, but to prepare the content to draw but not to draw, and 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.

With these concepts in hand, Getting started Win32 GUI programming is a relatively easy thing to do. Then just find a tutorial, step by step to the sample all over again, and then write a few GUI applet, almost also get started. The student in summing up when mentioned that I recommended a very famous tutorial, I am sorry to let him down, the tutorial actually I have not seen, I just found a tutorial on the internet, looked at the directory, he started to find the knowledge points above are listed, so he was sent. In short, the introduction of Windows programming, the most important thing is to understand and grasp the above mentioned basic concepts, concepts mastered, any one do not have serious errors and mishap of the textbook can be used to get started, as for the specific API how to use, when used to check the manual can be, there is no need to "learning 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 can a basic C + + learner learn Windows programming?

Related Article

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.