类似QQ底盘闪烁效果

June1991 2010-07-18 04:17:13
类似QQ底盘闪烁效果
...全文
459 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
gohappy2008 2010-07-20
  • 打赏
  • 举报
回复
学习 关注!!
ff1222 2010-07-20
  • 打赏
  • 举报
回复
一直以为是两个图片交替显示,原来还有api
a09 2010-07-20
  • 打赏
  • 举报
回复
学习了,帮顶! UP
qiqishardgel 2010-07-19
  • 打赏
  • 举报
回复
学习了,帮顶!
dylike 2010-07-19
  • 打赏
  • 举报
回复
空白ICO与非空白ICO使用TIMER交替显示
捷哥1999 2010-07-18
  • 打赏
  • 举报
回复
所谓的任务栏闪烁,就是指的,我们打开一个与好友对话的qq窗口后,如果有消息过来,就闪烁,对吗?

那你试试看我提供的代码,我的代码实现了那种方法。

如果你希望实现,没有打开qq对话窗口时,如果某个好友发来消息,在托盘区那里闪烁图标,那么就不要考虑我的方法了。
June1991 2010-07-18
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 computerfox 的回复:]
不要设置notification1.Text看看,你是要在任务栏中闪烁窗口,还是闪烁托盘图标?
[/Quote]
任务栏闪烁,不设置的话仍然有提示。
denbes 2010-07-18
  • 打赏
  • 举报
回复
学习了.
1,用Notifyicon.
2,调用API
FlashWindow(IntPtr hWnd, bool bInvert);
捷哥1999 2010-07-18
  • 打赏
  • 举报
回复
不要设置notification1.Text看看,你是要在任务栏中闪烁窗口,还是闪烁托盘图标?
June1991 2010-07-18
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 zhanlixin 的回复:]
1.首先我们在空白窗体中拖入一个NotifyIcon控件和定时控件
  private System.Windows.Forms.NotifyIcon notifyIcon1;
  private System.Windows.Forms.Timer timer1;
  2.其次,我们准备两张ico图片,用来显示在任务栏,其中一张可用透明的ico图片,分别叫做1.ico和2.ico;并……
[/Quote]
“notification1.Text”闪烁的时候出现提示框。怎么去掉。
捷哥1999 2010-07-18
  • 打赏
  • 举报
回复
然后这么调用:
// Flash window until it recieves focus
FlashWindow.Flash(this);

// Flash window 5 times
FlashWindow.Flash(this, 5);

// Start Flashing "Indefinately"
FlashWindow.Start(this);

// Stop the "Indefinate" Flashing
FlashWindow.Stop(this);
捷哥1999 2010-07-18
  • 打赏
  • 举报
回复
参考:
C#: Flash Window in Taskbar via Win32 FlashWindowEx


下面是封装好的静态类

public static class FlashWindow
{
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool FlashWindowEx(ref FLASHWINFO pwfi);

[StructLayout(LayoutKind.Sequential)]
private struct FLASHWINFO
{
/// <summary>
/// The size of the structure in bytes.
/// </summary>
public uint cbSize;
/// <summary>
/// A Handle to the Window to be Flashed. The window can be either opened or minimized.
/// </summary>
public IntPtr hwnd;
/// <summary>
/// The Flash Status.
/// </summary>
public uint dwFlags;
/// <summary>
/// The number of times to Flash the window.
/// </summary>
public uint uCount;
/// <summary>
/// The rate at which the Window is to be flashed, in milliseconds. If Zero, the function uses the default cursor blink rate.
/// </summary>
public uint dwTimeout;
}

/// <summary>
/// Stop flashing. The system restores the window to its original stae.
/// </summary>
public const uint FLASHW_STOP = 0;

/// <summary>
/// Flash the window caption.
/// </summary>
public const uint FLASHW_CAPTION = 1;

/// <summary>
/// Flash the taskbar button.
/// </summary>
public const uint FLASHW_TRAY = 2;

/// <summary>
/// Flash both the window caption and taskbar button.
/// This is equivalent to setting the FLASHW_CAPTION | FLASHW_TRAY flags.
/// </summary>
public const uint FLASHW_ALL = 3;

/// <summary>
/// Flash continuously, until the FLASHW_STOP flag is set.
/// </summary>
public const uint FLASHW_TIMER = 4;

/// <summary>
/// Flash continuously until the window comes to the foreground.
/// </summary>
public const uint FLASHW_TIMERNOFG = 12;


/// <summary>
/// Flash the spacified Window (Form) until it recieves focus.
/// </summary>
/// <param name="form">The Form (Window) to Flash.</param>
/// <returns></returns>
public static bool Flash(System.Windows.Forms.Form form)
{
// Make sure we're running under Windows 2000 or later
if (Win2000OrLater)
{
FLASHWINFO fi = Create_FLASHWINFO(form.Handle, FLASHW_ALL | FLASHW_TIMERNOFG, uint.MaxValue, 0);
return FlashWindowEx(ref fi);
}
return false;
}

private static FLASHWINFO Create_FLASHWINFO(IntPtr handle, uint flags, uint count, uint timeout)
{
FLASHWINFO fi = new FLASHWINFO();
fi.cbSize = Convert.ToUInt32(Marshal.SizeOf(fi));
fi.hwnd = handle;
fi.dwFlags = flags;
fi.uCount = count;
fi.dwTimeout = timeout;
return fi;
}

/// <summary>
/// Flash the specified Window (form) for the specified number of times
/// </summary>
/// <param name="form">The Form (Window) to Flash.</param>
/// <param name="count">The number of times to Flash.</param>
/// <returns></returns>
public static bool Flash(System.Windows.Forms.Form form, uint count)
{
if (Win2000OrLater)
{
FLASHWINFO fi = Create_FLASHWINFO(form.Handle, FLASHW_ALL, count, 0);
return FlashWindowEx(ref fi);
}
return false;
}

/// <summary>
/// Start Flashing the specified Window (form)
/// </summary>
/// <param name="form">The Form (Window) to Flash.</param>
/// <returns></returns>
public static bool Start(System.Windows.Forms.Form form)
{
if (Win2000OrLater)
{
FLASHWINFO fi = Create_FLASHWINFO(form.Handle, FLASHW_ALL, uint.MaxValue, 0);
return FlashWindowEx(ref fi);
}
return false;
}

/// <summary>
/// Stop Flashing the specified Window (form)
/// </summary>
/// <param name="form"></param>
/// <returns></returns>
public static bool Stop(System.Windows.Forms.Form form)
{
if (Win2000OrLater)
{
FLASHWINFO fi = Create_FLASHWINFO(form.Handle, FLASHW_STOP, uint.MaxValue, 0);
return FlashWindowEx(ref fi);
}
return false;
}

/// <summary>
/// A boolean value indicating whether the application is running on Windows 2000 or later.
/// </summary>
private static bool Win2000OrLater
{
get { return System.Environment.OSVersion.Version.Major >= 5; }
}
}
Zhanlixin 2010-07-18
  • 打赏
  • 举报
回复
1.首先我们在空白窗体中拖入一个NotifyIcon控件和定时控件
  private System.Windows.Forms.NotifyIcon notifyIcon1;
  private System.Windows.Forms.Timer timer1;
  2.其次,我们准备两张ico图片,用来显示在任务栏,其中一张可用透明的ico图片,分别叫做1.ico和2.ico;并且建立两个icon对象分别用来存放两个ico图片;
  private Icon ico1 = new Icon("1.ico");
  private Icon ico2 = new Icon("2.ICO");//透明的图标
  3.在Form_load中初始化notifyicon:
  private void Form1_Load(object sender, System.EventArgs e)
  {
  this.notifyIcon1.Icon=ico1;//设置程序刚运行时显示在任务栏的图标
  this.timer1.Enable = true;//将定时控件设为启用,默认为false;
  }
  4.先设置一个全局变量 i ,用来控制图片索引,然后创建定时事件,双击定时控件就可以编辑
  int i=0;
  private void timer1_Tick(object sender, System.EventArgs e)
  {
  //如果i=0则让任务栏图标变为透明的图标并且退出
  if(i<1)
  {
  this.notifyIcon1.Icon=ico2;
  i++;
  return;
  }
  //如果i!=0,就让任务栏图标变为ico1,并将i置为0;
  else
  this.notifyIcon1.Icon=ico1;
  i=0;
  }
捷哥1999 2010-07-18
  • 打赏
  • 举报
回复
任务栏闪烁?

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧