Programming is not too difficult (1)

Source: Internet
Author: User

 

I was originally asked by my friends to write an article entitled "A simple introduction to the Windows Kernel. I can't write any more. I think that even if I write such an article with great consideration, it is very limited to solve his problem.
I asked my friend, "Have you read some books about the Windows Kernel ?"
He said: "I have seen it ."
I asked, "What did you tell me ?"
He said: "I know the kernel objects and that the GDI object is not a kernel object ."

......

 

I think the main reason why programming is difficult is: external factors, cannot find a good teacher, cannot buy a good book; internal factors, no good method, no clear direction. As my friend mentioned above, I always put my learning on some concepts that have no substantive effect. Knowing what kernel objects are doesn't matter. Knowing why these kernel objects are necessary and how to use these kernel objects is important. Similarly, it doesn't matter whether a GDI object is a kernel object. It is not difficult for Microsoft to turn it into a kernel object. The purpose of our learning is to make the final application, rather than to add more talk about it after dinner.

I am also engaged in programming-related work for a short period of time. In the meantime, I have read some books and written some programs. However, if I write down the programming knowledge I have learned in detail, it may be tens of thousands of words. It takes three to five nights for everyone to finish reading the program. A few years ago-three or five nights, it's really embarrassing!

We can do an experiment. Find a new book and read it again. Then, you can draw out the content that you don't understand, the content that you don't understand, and the concepts and dictionaries ...... You can see how much content is left.

At this point, we may say that it is a matter of the reader level and the author's expression, but the book is written. I would like to say that, after years of looking back, I think there are too many books, too many places, and the author is also knowledgeable.

I remember that when I was learning Win32 SDK programming, I wrote the preface, preface, and thanks ...... I think there is no problem with his expression. When it comes to practical programming, it is a large part of the code plus some unessential explanations, making you feel angry, early menopause. When writing the first Win32 SDK program, we learned how to create a Win32 Application: Design window class -- register window -- create window -- display and update window -- message loop. We typed in the Code step by step according to the book to debug and run it. Oh, it's successful ...... After a little bit of self-deception, we are stuck in a difficult problem.

We will ask: 1. Why do we not design the "window title, window style, initial position, and window size" when designing the window class; 2. Why do we need to register the window after designing the window? 3. Why showwindow (...) To call updatewindow (...) Refresh the window ......

We can answer some questions by ourselves. For example, question 1: After thinking, we will understand that the design of the "window class" is not to create a completely fixed window, instead, use the same "window class" to create different headers and styles of windows. The common things are designed in the pre-window class, and the personal things are left for the creation of a specific window.

You cannot find the answer to some questions after reading a book, such as question 2. Maybe there is a blank line in the three pages in the book: "This ...... I would like to ask Jesus, "but we have never seen it. In fact, we are all ordinary people, including book authors. On the key issue, our issue must also be the one the author once had. He doesn't give us a good answer, for only one reason-he doesn't understand either. Maybe you will refute me and think that too much explanation will lead to too much space. Which book does it implement is not a meaningless piece of code, or a lot of arguments or macro interpretations? And you can't remember these things.

Some problems, if not explained or misunderstood, will cause one hundred and one thousand problems in the future. Let's think about how hard it will be to find out when the earth or the sun is talking.

For those who are initially involved in Win32 SDK programming, we must explain "Why register a window class ". Because of the first Win32 SDK programming, we will stay in the original programming ideology and think that the Win32 SDK window was created by our program, that is, our program contains window code. In this way, we cannot understand why the window should be registered, nor can we fully understand the Win32 SDK programming mechanism. In the past, if you were to use some libraries or functions written by others, as long as they contain files provided by others, you can link others' code to your own program, become one of them for direct calls by the program. However, for Win32 SDK programming, this is a completely different call. If you think of programming as building a company, calling other functions in the past is like introducing some tools to other companies, and then managing your own use. Win32
The call of SDK functions is like calling other companies by phone or letter.

At this point, it is not difficult to understand why the registration window is required. Since the window is not directly "made" by our program, it is built for us through the windows system. Of course, we have the responsibility to tell Windows system what kind of window needs to be built, and registration is to tell the system what the window class looks like. After understanding this, you can easily understand the messages and callback functions in the future.

For question 3 above, this is not a difficult issue, but a problem that is easily overlooked at the beginning. However, the problem does not exist if it is not ignored. In the consciousness of many programmers, they think that until updatewindow (…) is called (...) The window is displayed normally, and even the updatewindow (...) Is a function that keeps windows refreshed normally. In this way, the program process will be more puzzled, because updatewindow (...) How can I keep refresh windows when it is executed only once in the program? If we call showwindow (…) one day (...) Then, it is found that the updatewindow (…) is not called (...), The window is displayed normally. We have to ask cangtian about updatewindow (...) What is it? Showwindow (...) The window is displayed normally, but it only displays a standard window. If there is an image or something to be displayed in the window, call updatewindow (...) Send a wm_paint message and execute the code in the response wm_paint message.

Programming is not too difficult, just like the Win32 SDK programming mentioned above. I used to remember a lot of things, but I was afraid to write a program. There are not many things I can remember, but every time I write this kind of program, I can keep going. In the past, some people had their own freedom to write a Win32 SDK program code by themselves, but they did not know that such a program is the most dangerous. Wrong code may cause program problems. The correct method is to copy a secure Win32 SDK code and complete the programs you want.

As the saying goes, the meeting is not difficult. But programming is not a very difficult task. This is a big question and cannot be done by myself. In this article, I would like to introduce myself to others.

 

In addition, if I have time on the other day, I will write an article from planning the project to completing the middle of the article. For example, I used a software I used to develop, "3.0 ", in this way, we will share and explore some rare experiences and hope you will enjoy more support. Reference Site: http://www.fmpc.cn/

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.