就是去行的时候,只看到一个小球在桌面上就可以了,我用以下代码只能实现小球在一个正方形的方框内,没不是单独的,请各位高手多多帮忙,兄弟感激不尽.谢谢!using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace yixingtu
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }
        private Region BmpRgn(Bitmap Picture, Color TransparentColor)
        {
            int nWidth = Picture.Width;
            int nHeight = Picture.Height;
            Region rgn = new Region();            rgn.MakeEmpty();            bool isTransRgn;//前一个点是否在透明区
            Color curColor;//当前点的颜色
            Rectangle curRect = new Rectangle();
            curRect.Height = 1;            int x = 0, y = 0;            //逐像素扫描这个图片,找出非透明色部分区域并合并起来。            for (y = 0; y < nHeight; ++y)
            {
                isTransRgn = true;                for (x = 0; x < nWidth; ++x)
                {
                    curColor = Picture.GetPixel(x, y);                    if (curColor == TransparentColor || x == nWidth - 1)//如果遇到透明色或行尾
                    {
                        if (isTransRgn == false)//退出有效
                        {
                            curRect.Width = x - curRect.X;
                            rgn.Union(curRect);
                        }
                    }
                    else//非透明色
                    {
                        if (isTransRgn == true)//进入有效区
                        {
                            curRect.X = x;
                            curRect.Y = y;
                        }                    }//if curColor                    isTransRgn = curColor == TransparentColor;                }//for x
            }//for y            return rgn;
        }
        private void Form1_Load(object sender, EventArgs e)
        {
           
        }        private void button1_Click(object sender, EventArgs e)
        {
            this.Region = BmpRgn(new Bitmap("d:\\a.gif"), Color.FromArgb(0, 0, 0));
        }
    }
}

解决方案 »

  1.   

    用flash来实现吧.相当于QQ宠物这样的功能.
      

  2.   

    需要这么深奥么……
    如果只是满足你开始说的要求的话,是不是可以考虑:
    1. 做一个没有边框的Form
    2. Form的TransparencyKey属性设置为你指定的颜色(可以在设计器里设,也可以用编码动态设)。
    3. 放一个PictureBox。把小球的图片加载上。
    4. 调整合适的大小。然后不就OK了?
      

  3.   

    http://www.cnblogs.com/pcant/articles/1132905.html
      

  4.   

    也就是做一个透明穿透窗口需要用api函数SetWindowLong()修整窗体显示风格并忽略一切消息  
      

  5.   

    C#根据图片创建不规则窗体
    http://so.blogchinese.com/06042/202595/archives/2006/200642518142.html
      

  6.   

    看看以前的一个古老帖子
    http://topic.csdn.net/t/20060322/17/4632557.html
      

  7.   

    主要功能就是程序运行后,在桌面上显示一个小球,谢谢上面各位弟兄,
    TO wartim
    你给我的网站代码和我贴出来一样,但是就是结果是圆在方框里面.
    TO wanghui0380
    你说的的见面我看了,和我要求不同.
      

  8.   

    我试了很正常啊,关键是透明色,你用画笔存绿色画一个原,其他地方都是白的,然后透明色取bmp.getpixel(0,0)就出来个原了