这个嘛……楼下的上,俺要睡觉了(提示:用GDI+,Graphics.DrawImage将你PictureBox上面的Image截取部分进行显示,随着时间推移截取不同的部分)Aman……
解决方案 »
- 八百里加急,win7 socket 问题,在线等!
- 请教!用VS2008能不能生成word2007,主要是生成图表。
- virtual listview修改数据后如何刷新显示?
- 水晶报表子报表问题
- GDI 画线消除锯齿的问题.(简单又不简单)大家来帮忙
- 关于数组的问题
- WPF在导出图片到word的时候 怎么设置图片的大小
- 正则表达式筛选数据(C#)
- C#我做了个PC发送系统时间到单片机!!熟悉串口通讯的帮帮忙谢谢!!
- 怎样实现在form1中点一个botton,运行弹出一个窗口form2??在线等!!!
- 关于C#,跟贴有分!!
- 我的上个问题已经结帖,请老师们接分吧!现在还想问一个很简单很简单很简单的问题:
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.ComponentModel.IContainer components; public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.SuspendLayout();
//
// timer1
//
this.timer1.Enabled = true;
this.timer1.Interval = 10;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Bitmap)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(5, 80);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(16, 16);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(377, 193);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.pictureBox1});
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false); }
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
} private void timer1_Tick(object sender, System.EventArgs e)
{
pictureBox1.Left = pictureBox1.Left + 1;
if(pictureBox1.Left >= this.Width)
pictureBox1.Left = 0;
}
}
}
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;namespace picmove
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.PictureBox pictureBox2;
private System.ComponentModel.IContainer components; public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
pictureBox2.Left=-(this.Width-pictureBox1.Right+pictureBox2.Width);
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}#region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.SuspendLayout();
//
// timer1
//
this.timer1.Enabled = true;
this.timer1.Interval = 10;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Bitmap)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(64, 8);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(256, 256);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// pictureBox2
//
this.pictureBox2.Image = ((System.Drawing.Bitmap)(resources.GetObject("pictureBox2.Image")));
this.pictureBox2.Location = new System.Drawing.Point(-256, 8);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(256, 256);
this.pictureBox2.TabIndex = 1;
this.pictureBox2.TabStop = false;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(400, 277);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.pictureBox2,
this.pictureBox1});
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false); }
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
} private void timer1_Tick(object sender, System.EventArgs e)
{
pictureBox1.Left = pictureBox1.Left + 1;
pictureBox2.Left = pictureBox2.Left + 1;
if(pictureBox1.Left >= this.Width)
pictureBox1.Left =-(this.Width-pictureBox2.Right+pictureBox1.Width);
if(pictureBox2.Left >= this.Width)
pictureBox2.Left =-(this.Width-pictureBox1.Right+pictureBox2.Width); }
}
}
你再试一试用它的size的初始化。
....
在Panel中按时不停的改变PictureBox的Left值,并使其首尾相连,即可实现要求功能。
代码如下:
private void Form1_Load(object sender, System.EventArgs e)
{
pic1.Top=panel1.Top;
pic1.Left=panel1.Left-panel1.Width;
pic1.Height=panel1.Height;
pic1.Width=2*panel1.Width;
pic2.Top=panel1.Top;
pic2.Left=panel1.Left-3*panel1.Width;
pic2.Height=panel1.Height;
pic2.Width=2*panel1.Width;
} private void timer1_Tick(object sender, System.EventArgs e)
{
if(pic1.Left==panel1.Left+panel1.Width) pic1.Left=panel1.Left-3*panel1.Width;
if(pic2.Left==panel1.Left+panel1.Width) pic2.Left=panel1.Left-3*panel1.Width;
pic1.Left+=1;
pic2.Left+=1;
}