日期:2014-05-18  浏览次数:21163 次

在C# winform窗体中怎么实现 无缝走马灯 效果啊 急用!!
在C# winform窗体中怎么实现 无缝走马灯 效果啊
请大家帮帮忙! 谢谢!

------解决方案--------------------
这是我在另外一个帖子发的代码,原理大致相同,不妨试试:
C# code

// RainDrops.cs
// compile with:   csc /t:winexe RainDrops.cs
using System;
using System.Drawing;
using System.Windows.Forms;

public class Form1 : Form
{
    Bitmap rainDrops;
    Timer timer = new Timer();
    int top = 0;

    public Form1()
    {
        this.Size = new Size(300, 300);
        Rectangle rect = this.ClientRectangle;

        rainDrops = new Bitmap(rect.Width, rect.Height * 2);
        using (Graphics g = Graphics.FromImage(rainDrops))
        {
            g.Clear(Color.LightBlue);

            Random random = new Random();
            for (int i = 0; i < 1000; i++)
            {
                int x = random.Next() % rect.Width;
                int y = random.Next() % rect.Height;
                int dot = random.Next() % 5;

                g.FillEllipse(Brushes.White, x, y, dot, dot);
                g.FillEllipse(Brushes.White, x, y+rect.Height, dot, dot);
            }
        }
        timer.Interval = 200;
        timer.Enabled = true;
        timer.Tick += delegate { Invalidate(); };

    }

    protected override void OnPaint(PaintEventArgs e)
    {
        int height = this.ClientRectangle.Height;
        top += 10;
        if (top > height) top = 0;
        e.Graphics.DrawImageUnscaled(rainDrops, 0, top - height);
    }

    protected override void OnPaintBackground(PaintEventArgs e)
    {
    }

    static void Main()
    {
        Application.Run(new Form1());
    }
}