C#入门小程序

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

C#编写的,窗口自左向右自动移动,参考一下。

using System;

using System.Drawing;

using System.Collections;

using ponentModel;

using System.Windows.Forms;

using System.Data;

namespace floatingForm

{

///

/// Summary description for Form1.

///

public class Form1 : System.Windows.Forms.Form

{

private bel label1;

private System.Windows.Forms.Timer timer1;

private ponentModel.IContainer components;

public Form1()

{

//

// Required for Windows Form Designer support

//

InitializeComponent();

//

// TODO: Add any constructor code after InitializeComponent call

//

}

///

/// Clean up any resources being used.

///

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

#region Windows Form Designer generated code

///

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

///

private void InitializeComponent()

{

ponents = new ponentModel.Container();

this.timer1 = new System.Windows.Forms.Timer(ponents);

bel1 = new bel();

this.SuspendLayout();

//

// timer1

//

this.timer1.Enabled = true;

this.timer1.Interval = 10;

this.timer1.Tick += new System.EventHandler(this.Form1_Load);

//

// label1

//

bel1.Dock = System.Windows.Forms.DockStyle.Fill;

bel1.Font = new System.Drawing.Font("Microsoft Sans Serif", 47.99999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));

bel1.ForeColor = System.Drawing.Color.SandyBrown;

bel1.Location = new System.Drawing.Point(0, 0);

= "label1";

bel1.Size = new System.Drawing.Size(360, 166);

bel1.TabIndex = 0;

bel1.Text = "圣诞快乐!";

bel1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;

//

// Form1

//

this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);

this.ClientSize = new System.Drawing.Size(360, 166);

this.Controls.Add(bel1);

this.MaximizeBox = false;

this.MinimizeBox = false;

= "Form1";

this.Text = "漂浮的窗口";

this.Load += new System.EventHandler(this.timer1_Tick);

this.ResumeLayout(false);

}

#endregion

///

/// The main entry point for the application.

///

[STAThread]

static void Main()

{

Application.Run(new Form1());

}

private void timer1_Tick(object sender, System.EventArgs e)

{

Point p = new Point(this.DesktopLocation.X + 1, this.DesktopLocation.Y);

this.DesktopLocation = p;

if (p.X == this.DesktopBounds.Width)

{

Point p2 = new Point(0,370);

this.DesktopLocation = p2;

}

}

private void Form1_Load(object sender, System.EventArgs e)

{

Point p = new Point(0,370);

this.DesktopLocation = p ;

}

}

}

相关文档
最新文档