Form start effects

Source: Internet
Author: User
"Effect Chart"


"Train of Thought":

In the form of the onload first make the form invisible, and then from the inside out, one layer to draw rectangle, and finally let the form visible

Difficulties

The first output of the rectangle to have a place to show that the Main form is not, because when the rectangle, the form is not visible, here using the desktop desktop

"Code as follows"

1. Join namespaces

Using System.Drawing.Imaging;

Using System.Runtime.InteropServices;

2. Declaring Win32 Api GetDC ()

[DllImport ("user32")]

public static extern system.intptr GetDC (system.intptr DC);

3. Declaring variables

System.Drawing.Graphics G; Draw a tablet

Pen p=new Pen (color.black,1); Brush

int startx,starty,wx,wy,step; Startx,starty,wx,wy determines a rectangle

int cx,cy; Cx,cy the width and height of the client for form

4. Add the following code to the OnLoad on form

This. Visible=false;

Step=1;

G=GRAPHICS.FROMHDC (GetDC (System.IntPtr.Zero));

Cx=this. Clientsize.width;

Cy=this. Clientsize.height;

This. Visible=false;

Step=1;

while (STEP<=CX/2)

{

Startx=cx/2-step;

STARTY=CY*STARTX/CX;

Wx=2*step;

WY=WX*CY/CX;

Startx+=this. Left;

Starty+=this. Top+this. Height-this.clientsize.height;

G.drawrectangle (P,startx,starty,wx,wy);

System.Threading.Thread.Sleep (100);

step+=10;

}

This. Visible=true;



PS: This is the first time to publish the original, everyone a lot of advice


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.