Custom editing box

Source: Internet
Author: User

Source File 

The edit box is one of the commonly used controls, and it is also a complicated control with full self-implementation. In this example, a simple self-drawing of the editing box is implemented, while retaining its own powerful functions, the border, background, text color, and disabled color of the editing box are replaced.
To re-paint, we must know what to paint. By observing the default editing box, we can clearly see that the editing box has three basic parts that need to be drawn, which are 3D border, background, and text, further analysis shows that they are two parts of a basic window, namely the customer zone and non-customer zone. In this way, we will know what functions should be used to draw specific areas. As the source code is provided, we will only discuss the basic principles and technical details here, but will list them in many places.Code.
In order to draw non-customer zones, I have reloaded the onncpaint function. This function can easily remove the 3D appearance of the editing box and draw it as we want. As for the customer area, I did not reload the onpaint function to keep the edit box cursor blinking, character processing, automatic return, and other functions. That is to say, I did not redraw the customer area, but chose an alternative method.
The edit box is used to edit the text, and all we want to change is the text and background color. Through this analysis, we will know what we need to do, that is, set the text color and background color. The method I used is to overload the ctlcolor function. In the function, different colors are set based on the different States that are disabled and enabled in the edit box, which achieves the expected purpose.
Strictly speaking, I did not re-paint the edit box, but simply drew the edge, but it also achieved the expected results. Of course, there are still many unsatisfactory examples. If you have better ideas, we hope we can share them with you.

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.