The GDI + Code 2 I collected over the years

Source: Internet
Author: User

Over the years, I have collectedCode2

It's quite interesting to use vs to draw a picture when you are at work in the past few years. Let's take a look at how the verification code function is implemented with GDI +.

First, let's take a look at how to write text on winform to pave the way.

 

Figure 1 Text

 

Figure 2. Verification Code

What do we do when we see a verification code? Is it strange to see that the number is long? Is the word changed when you click it? Is the font color different? Isn't it clear at a glance? This is intended to prevent some evil people from registering with machines.

Train of Thought 1: The number inside is randomly generated

Enter the official section below.

    1. Random number obtained by the Verification Code

When we click on the Internet, is it an image? Therefore, you should drag an image control on the form and use the image click event.

 

Figure 3. Random number obtained by the Verification Code

My comments on the Code are very clear. For details, refer to the comments above.

In this step, we are faced with two problems: fonts and colors. Then, we need two arrays, one for the font and the other for the color.

 

Figure 4. Change the color and font of the Verification Code

 

Figure 5. Complete the color and font of the Verification Code

Each time a color is drawn, the above Code uses a for loop. When we achieve this step, the noise in the last number is worse. Let's think about it, isn't it just a little worse? Where is the maximum length of these lines? For example, if you draw ten lines, it is a for loop.

 

Figure 6. Drawing Noise

In the end, let's take a look at the last one.

 

Figure 7. Last

When we gradually access aspdot.net, we will find that such verification codes do not need to be manually drawn. However, when drawing verification codes, we need to master the basic programming ideas. Many exquisite GDI + diagrams are made in this way.

Author's recentArticle:
  • The GDI + code I have collected over the years
  • HTML language 3 that you cannot ignore
  • HTML code 2 that you cannot ignore
  • HTML language that you cannot ignore
  • Our common Array
  • Method (above) in C ):
  • Comparison of three cycles

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.