Custom drop-down list box

Source: Internet
Author: User

Source File 

The drop-down list box, also known as the combination list box, is a complicated control. It has three states: simple, drop down, and drop list. It consists of three controls: edit box, drop-down button, and ListBox. Therefore, the workload of the drop-down list box is quite large. In addition, in some special cases, the drop-down list box has some special requirements, so it is not realistic to fully implement all the functions of the drop-down list box in an example. Based on the above reason, this example simply implements the re-painting of some controls in the drop list state, including read-only edit boxes and drop-down buttons, the ListBox is not repainted in this example.
With a clear goal, we can start to work. First, observe that the drop-down list box and the edit box both have a 3D appearance. I mentioned in the "self-painted editing box" that the 3D appearance of the editing box is not a customer zone. Through the experiment, I found that the 3D appearance in the drop-down list box belongs to the customer area, so we must reload the onpaint function for repainting. As you can see, in this example, I just re-painted the customer area of the drop-down list box, which includes buttons and edit boxes.
To remove the 3D appearance from the customer area, we need to draw borders, backgrounds, text, and buttons. The first three items are easy to say. People with some drawing experience will not have questions about how to draw these items. However, there are some problems with drawing the drop-down button. What is the area of the button? How can I determine the button status? Is the drop-down button a cbutton?
To solve the button drawing problem, I used the comboboxinfo structure, which is the same as the getcomboboxinfo function that obtained the information about the drop-down list box. This structure contains statebutton (Button status) and rcbutton (Button area ). In this way, the button rendering problem can be well solved. For specific implementation, see the source code.
As Article In the beginning, the re-drawing of the drop-down list box is more complex. This article simply implements the self-painting of the customer area. I hope this article will serve as a reference and hope to be discussed and improved together.

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.