making windows forms or title bar BLink

Hi,

How can I make form backcolor or form's titlebar blink

Thanks,


Answer this question

making windows forms or title bar BLink

  • Allan Kemp

    Thanks, might sound very basic, but can you show me how to consume it How can I pass IntPtr handleToWindow
  • Seyed

    From the form i want to blink I call it like this:


    FlashWindow.FlashWindowAPI(this.Handle);
     

  • Dougal

    I tried it on one of my apps and it worked fine.  Are you trying to have this happen while your app is processing a ton of data or something   If so, you may need to use a multi-threaded timer, which I'm not too familiar with. 

    Be sure that your timer is enabled (they're disabled by default) and a decent interval is set.  When I tested it on mine I left the interval set to the default (100) which seemed to be a pretty good timing for a blink effect.  I tested it with Visual Studio 2005 RC.

  • Glynnder

    This would work but for some reason in my application I cant use this. Is there any other way of doing this


  • Sweety103741

    I forgot this struct, you'll need this too


    using System;
        using System.Runtime.InteropServices;

        [StructLayout(LayoutKind.Sequential)]
        public struct FLASHWINFO
        {
            public uint cbSize;
            public IntPtr hwnd;
            public uint dwFlags;
            public uint uCount;
            public uint dwTimeout;
        }


     


  • Pavel Dournov - MSFT

    Another option:  have you tried using the FlashWindow method located in User32.dll

    http://www.codeproject.com/csharp/c__and_api.asp

    Search that page for the text FlashWindow - there's a comment on there with a suggestion on how to implement it.

  • jvlake

    I use a call to Win API for this. I wrapped it in this class:

      


      using System;
        using System.Runtime.InteropServices;

        public class FlashWindow
        {
            // Methods
            private FlashWindow()
            {
            }

            public static bool FlashWindowAPI(IntPtr handleToWindow)
            {
                FLASHWINFO flashwinfo1 = new FLASHWINFO();
                flashwinfo1.cbSize = (uint) Marshal.SizeOf(flashwinfo1);
                flashwinfo1.hwnd = handleToWindow;
                flashwinfo1.dwFlags = 15;
                flashwinfo1.uCount = uint.MaxValue;
                flashwinfo1.dwTimeout = 0;
                return (FlashWindow.FlashWindowEx(ref flashwinfo1) == 0);
            }

            [DllImport("user32.dll")]
            private static extern short FlashWindowEx(ref FLASHWINFO pwfi);


            // Fields
            public const uint FLASHW_ALL = 3;
            public const uint FLASHW_CAPTION = 1;
            public const uint FLASHW_STOP = 0;
            public const uint FLASHW_TIMER = 4;
            public const uint FLASHW_TIMERNOFG = 12;
            public const uint FLASHW_TRAY = 2;
        }
    }


     


  • ngmvista

    Have you tried a Timer control  


    private void timer1_Tick(object sender, EventArgs e)

    {

    if (this.BackColor == SystemColors.Control)

    this.BackColor = Color.Blue;

    else

    this.BackColor = SystemColors.Control;

    }


     


  • making windows forms or title bar BLink