任务栏通知发光

编程入门 行业动态 更新时间:2024-10-25 18:34:50
本文介绍了任务栏通知发光的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我有一个 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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-25 11:24:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1115311.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:任务栏   通知

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!