Include this namespace
using System.Runtime.InteropServices;
Declare the struct like this in your project namespace
namespace XYZ
{
.
.
public struct FLASHINFO
{
public Int32 cbSize;
public IntPtr hwnd;
public int dwFlags;
public UInt32 uCount;
public int dwTimeout;
}
And declare this function in your class
[DllImport("user32.dll")]
public static extern bool FlashWindowEx(
ref FLASHINFO fInfo);
and then wherever you wanna call FlashWindowsEx use the code similar to this one
unsafe
{
FLASHINFO fInfo = new FLASHINFO();
fInfo.cbSize = sizeof(FLASHINFO);
fInfo.dwFlags = 2;
fInfo.hwnd = this.Handle;
fInfo.uCount = 2;
fInfo.dwTimeout = 0;
bool result = FlashWindowEx(ref fInfo);
if (result)
{
MessageBox.Show("Called successfully");
}
}
Open winuser.h and see the values for different flags
To be able to build this project you will have to go to
Project->YourProject Properties... , Configuration Properties->Build
and turn the option "Allow Unsafe Blocks" in the list on the right side to True
I know... I'm myself not too pleased with the unsafe block that I had to insert in the code, I'm trying to find a way around, but you have got the lead too, so if your strike first, do let me know.
Regards
Ankur Verma
.Net and C++ Specialist
Wiley Tech Support
|