原窗口使用API函数AnimateWindow 使对窗口产生淡淡入效果但是改变了窗口的TRANSPARENCYKEY属性后....AnimateWindow 不能使用0x00040000,和0x00080000进行 淡入淡出.
有什么办法可以解决吗?>

解决方案 »

  1.   

    有的。假设你要在五秒内完成这个效果,那你就动态设定窗体的Opacity属性。让它在指定时间内变化就是了。
      

  2.   

    Opacity 属性使您可以指定窗体及其控件的透明度级别。将此属性设置为小于 100% (1.00) 的值时,会使整个窗体(包括边框)更透明。将此属性设置为值 0% (0.00) 时,会使窗体完全不可见。可以使用此属性提供不同级别的透明度,或者提供如窗体逐渐进入或退出视野这样的效果。例如,可以通过将 Opacity 属性设置为值 0% (0.00),并逐渐增加该值直到它达到 100% (1.00),使一个窗体逐渐进入视野。
      

  3.   

    下面的代码示例演示如何创建以 75% 的不透明度显示的窗体。该代码示例创建一个新窗体,该窗体位于屏幕的中央,其 Opacity 属性被设置为更改窗体的不透明度。该代码示例还设置 Size 属性来提供大于默认窗体大小的窗体。该代码示例假定该示例中定义的方法是从事件处理程序的另一个窗体或其他方法中调用。private void CreateMyOpaqueForm()
    {
       // Create a new form.
       Form form2 = new Form();
       // Set the text displayed in the caption.
       form2.Text = "My Form";
       // Set the opacity to 75%.
       form2.Opacity = .75;
       // Size the form to be 300 pixels in height and width.
       form2.Size = new Size(300,300);
       // Display the form in the center of the screen.
       form2.StartPosition = FormStartPosition.CenterScreen;   // Display the form as a modal dialog box.
       form2.ShowDialog();
    }
      

  4.   

    这里有个变暗的例子.你参考一下么
    // Form1.cs
    // Compile with  csc /t:winexe form1.csusing System;
    using System.IO;
    using System.Drawing;
    using System.Drawing.Imaging;
    using System.Windows.Forms;public partial class Form1 : Form
    {
        Bitmap bg;
        Timer timer = new Timer();
        Form form;    public Form1()
        {
            Rectangle workArea = Screen.PrimaryScreen.WorkingArea;
            using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
            {
                // Get HBITMAP of desktop window
                IntPtr desktopDC = g.GetHdc();
                const int OBJ_BITMAP = 7;
                IntPtr desktopBitmap = GetCurrentObject(desktopDC, OBJ_BITMAP);
                Bitmap bm = Bitmap.FromHbitmap(desktopBitmap);            // change to 256 indexed color
                bg = bm.Clone(workArea, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
                MemoryStream bitStream = new MemoryStream();
                bg.Save(bitStream, ImageFormat.Gif);
                bg = new Bitmap(bitStream);
            }        this.SuspendLayout();
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.TopMost = true;
            this.WindowState = FormWindowState.Maximized;
            this.ResumeLayout(false);        timer.Interval = 200;
            timer.Enabled = true;
            timer.Tick += delegate
            {
                ColorPalette palette = bg.Palette;
                for (int i = 0; i < palette.Entries.Length; i++)
                {
                    Color c = palette.Entries[i];
                    int gray = (c.R + c.G + c.B) / 3;
                    gray =  gray - gray / 10;                int r = Math.Max(0, c.R - (c.R - gray) / 3);
                    int g = Math.Max(0, c.G - (c.G - gray) / 3);
                    int b = Math.Max(0, c.B - (c.B - gray) / 3);
                    palette.Entries[i] = Color.FromArgb(r, g, b);
                }
                bg.Palette = palette;
                Invalidate();
            };        // show a form
            form = new Form();
            form.Text = "Ctrl+F4 to close me";
            form.Show(this);        form.Disposed += delegate { Close(); };
            this.Activated += delegate { form.Activate(); };
        }
        protected override void OnPaintBackground(PaintEventArgs e)
        {
        }    protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.DrawImageUnscaled(bg, 0, 0);
        }    static void Main()
        {
            Application.Run(new Form1());
        }    [System.Runtime.InteropServices.DllImport("gdi32.dll")]
        internal extern static IntPtr GetCurrentObject(IntPtr hdc, ushort objectType);
    }
      

  5.   

    为什么设置了TRANSPARENCYKEY属性.AnimateWindow 函数不能正常使用...而且使窗口不能透明...?
    没办法的话..下午就改用渐变Opacity 值了..
      

  6.   

    弄個timer,在timer_tick里面遞增或者遞減窗口的transparent
      

  7.   

    支持用Opacity 我曾经做过。在1.5秒之内完成从完全透明到完全不透明。效果不错。。