Confusing M draw and owner draw

Source: Internet
Author: User

Recently, I was busy beautifying the interface. However, WinCE provided fewer functions than the desktop, and fewer controls were available on the Internet (later I found that there were still some, there is no right to speak without research! :(). Fortunately, it is easy for me to learn from other people's code, and also free up buttons with images, irregular buttons, and listctrl that can display images in each line. I hope that I can sort this information out and write it into a blog recently. I will not mention it this time. The confusing M draw and owner draw are described here.
There may be many people who do not know much about these two concepts, or have never heard of them, let alone their differences! Unfortunately, I used to be one of them...
Literally, custom draw can be interpreted as a standard drawing, while owner draw can be expressed as a custom drawing. Let's first look at what is customization? In other words

  1. Modify some properties of the control (the background color of the control), and then let windows handle the painting.
  2. Just want to draw some parts of the control by yourself and let windows handle other parts.
  3. You can draw the entire control by yourself, so you do not need to do anything in windows.

In this case, the owner draw can be equivalent to the third case mentioned above, that is, you must process all the work of the Drawing Control. More work is required, more complex, and more time is spent. Therefore, custom draw is the first choice, and there is no way to choose the owner draw -- do you like to find things ?...
So how does the custom draw and notify windows of your decision? Therefore, the message nm_customdraw must be processed. The function prototype for receiving the message is as follows:
Void oncustomdrawmylist (nmhdr * pnmhdr, lresult * presult)
The pnmhdr parameter contains the control's window handle, ID, and so on. Of course, it is important to include information about the current draw phase, which has four phases in total:

  • Before painting
  • After painting
  • Before Erasure
  • After Erasure

You can draw at the corresponding stage and notify windows of what work to do. How can you notify me? Use the presult parameter.

Maybe you think it's strange that this is over? I was going to translate the original blog text into Chinese in detail. Unfortunately, I was defeated. It is better to give a general description only. After all, no matter the original text or translated articles are long. For more information, see the following link:
Http://www.codeproject.com/KB/list/lvcustomdraw.aspx? MSG = 875581

Http://blog.csdn.net/dylgsy/article/details/818550

Http://blog.csdn.net/ryanzll/article/details/7294379

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.