任务栏通知发光 [英] Taskbar notification glow

查看:28
本文介绍了任务栏通知发光的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 TCP 聊天应用程序.当收到新消息时,我想让任务栏发光,直到用户再次打开表单(以防它没有获得焦点/激活).

I have a TCP Chat application. When a new message arrives, I want to make the taskbar glow until the user opens the form again (in case it wasn't focus/activated).

我的意思的一个例子:http://puu.sh/4z01n.png

我怎样才能让它发光?

谢谢!

如果您仍然不明白我的意思..我提供的图像是当某些东西发光"时出现在任务栏图标上的图像.意思是有通知.这就是我想要达到的目标.

If you still don't understand what I mean.. The image I provided is what appears ON the icon i nthe taskbar when something "glows". Meaning there is a notifcation. That's what I want to acheive.

推荐答案

希望对你有帮助

[DllImport("User32.dll")]
[return:MarshalAs(UnmanagedType.Bool)]
static extern bool FlashWindowEx(ref FLASHINFO pwfi);


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


[Flags]
        public enum FlashMode {
            /// 
            /// Stop flashing. The system restores the window to its original state.
            /// 
            FLASHW_STOP = 0,
            /// 
            /// Flash the window caption.
            /// 
            FLASHW_CAPTION = 1,
            /// 
            /// Flash the taskbar button.
            /// 
            FLASHW_TRAY = 2,
            /// 
            /// Flash both the window caption and taskbar button.
            /// This is equivalent to setting the FLASHW_CAPTION | FLASHW_TRAY flags.
            /// 
            FLASHW_ALL = 3,
            /// 
            /// Flash continuously, until the FLASHW_STOP flag is set.
            /// 
            FLASHW_TIMER = 4,
            /// 
            /// Flash continuously until the window comes to the foreground.
            /// 
            FLASHW_TIMERNOFG = 12
        }

        public static bool FlashWindow(IntPtr hWnd, FlashMode fm) {
            FLASHWINFO fInfo = new FLASHWINFO();

            fInfo.cbSize = Convert.ToUInt32(Marshal.SizeOf(fInfo));
            fInfo.hwnd = hWnd;
            fInfo.dwFlags = (UInt32)fm;
            fInfo.uCount = UInt32.MaxValue;
            fInfo.dwTimeout = 0;

            return FlashWindowEx(ref fInfo);
        }

取自我的 wiki,位于 Flashing Taskbar

Taken from my wiki at Flashing Taskbar

这篇关于任务栏通知发光的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆