Home
Manage Your Code
Snippet: make the task bar blink UI-tools part 1 (C#)
Title: make the task bar blink UI-tools part 1 Language: C#
Description: this is a separate class to make your taskbar blink this is piece of 1 of 2. Written by HawksTalon Views: 94
Author: Wayne Burgess Date Added: 8/6/2008
Copy Code  
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Windows.Forms;
5using System.Runtime.InteropServices;
6 
7namespace UI.Tools
8{
9    public class Forms
10    {
11 
12        [DllImport("USER32.DLL", EntryPoint = "FlashWindowEx")]
13        [return: MarshalAs(UnmanagedType.Bool)]
14        static extern bool FlashWindowEx(ref FLASHWINFO pwfi);
15 
16        [StructLayout(LayoutKind.Sequential)]
17        public struct FLASHWINFO
18        {
19            public UInt32 cbSize;
20            public IntPtr hwnd;
21            public UInt32 dwFlags;
22            public UInt32 uCount;
23            public UInt32 dwTimeout;
24        }
25 
26        public enum dwFlags
27        {
28            //Stop flashing. The system restores the window to its original state. 

29            FLASHW_STOP = 0,
30            //Flash the window caption. 

31            FLASHW_CAPTION = 1,
32            //Flash the taskbar button. 

33            FLASHW_TRAY = 2,
34            //Flash both the window caption and taskbar button.

35            //This is equivalent to setting the FLASHW_CAPTION | FLASHW_TRAY flags. 

36            FLASHW_ALL = 3,
37            //Flash continuously, until the FLASHW_STOP flag is set. 

38            FLASHW_TIMER = 4,
39            //Flash continuously until the window comes to the foreground. 

40            FLASHW_TIMERNOFG = 12
41        };
42 
43        bool IsFormAcive(Form f)
44        {
45            bool Status = false;
46 
47            //* Check if Form is already open, if so then bring it to the front

48            //* If you are using a MDI parent form, include a check to see if the form is an ActiveMdiChild

49            //      if ((f != null) && (f != MainForm.ActiveMdiChild))

50            if ((f != null)) 
51            {
52                f.Activate();
53                Status = true;
54            }
55 
56            return Status;
57        }
58 
59        /// <summary>

60        /// Flashes a window

61        /// </summary>

62        /// <param name="hWnd">The handle to the window to flash</param>

63        /// <returns>whether or not the window needed flashing</returns>

64        public static bool FlashWindowEx(IntPtr hWnd, dwFlags dwFlag, UInt32 uCount, UInt32 dwTimeout)
65        {
66            FLASHWINFO fInfo = new FLASHWINFO();
67 
68            fInfo.cbSize = Convert.ToUInt32(Marshal.SizeOf(fInfo));
69            fInfo.hwnd = hWnd;
70            fInfo.dwFlags = Convert.ToUInt32(dwFlag);
71            fInfo.uCount = uCount;
72            fInfo.dwTimeout = dwTimeout;
73 
74            return FlashWindowEx(ref fInfo);
75        }
76    }
77}
Notes
C# 2.0 .net 2.0