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
- Modify some properties of the control (the background color of the control), and then let windows handle the painting.
- Just want to draw some parts of the control by yourself and let windows handle other parts.
- 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