<bdo id='1nOz6'></bdo><ul id='1nOz6'></ul>

      <i id='1nOz6'><tr id='1nOz6'><dt id='1nOz6'><q id='1nOz6'><span id='1nOz6'><b id='1nOz6'><form id='1nOz6'><ins id='1nOz6'></ins><ul id='1nOz6'></ul><sub id='1nOz6'></sub></form><legend id='1nOz6'></legend><bdo id='1nOz6'><pre id='1nOz6'><center id='1nOz6'></center></pre></bdo></b><th id='1nOz6'></th></span></q></dt></tr></i><div id='1nOz6'><tfoot id='1nOz6'></tfoot><dl id='1nOz6'><fieldset id='1nOz6'></fieldset></dl></div>

      <small id='1nOz6'></small><noframes id='1nOz6'>

    1. <legend id='1nOz6'><style id='1nOz6'><dir id='1nOz6'><q id='1nOz6'></q></dir></style></legend>
    2. <tfoot id='1nOz6'></tfoot>
    3. 如何使 WPF 窗口在任务栏上闪烁?

      时间:2023-11-11
    4. <i id='uvmcy'><tr id='uvmcy'><dt id='uvmcy'><q id='uvmcy'><span id='uvmcy'><b id='uvmcy'><form id='uvmcy'><ins id='uvmcy'></ins><ul id='uvmcy'></ul><sub id='uvmcy'></sub></form><legend id='uvmcy'></legend><bdo id='uvmcy'><pre id='uvmcy'><center id='uvmcy'></center></pre></bdo></b><th id='uvmcy'></th></span></q></dt></tr></i><div id='uvmcy'><tfoot id='uvmcy'></tfoot><dl id='uvmcy'><fieldset id='uvmcy'></fieldset></dl></div>

      <tfoot id='uvmcy'></tfoot>
    5. <small id='uvmcy'></small><noframes id='uvmcy'>

        <tbody id='uvmcy'></tbody>
          <bdo id='uvmcy'></bdo><ul id='uvmcy'></ul>

              • <legend id='uvmcy'><style id='uvmcy'><dir id='uvmcy'><q id='uvmcy'></q></dir></style></legend>
                本文介绍了如何使 WPF 窗口在任务栏上闪烁?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                在某个特定时刻,我的 WPF 应用程序需要用户关注.我知道可以使 Windows 7 任务栏图标以黄色闪烁.

                A given moment my WPF app needs user attention. I know it is possible to make the Windows 7 taskbar icon to flash with a yellow color.

                到目前为止我试过了:

                • Window.Activate 尝试将窗口置于前台并激活它.
                • Window.Focus 尝试将此元素设置为焦点.
                • Window.Activate Attempts to bring the window to the foreground and activates it.
                • Window.Focus Attempts to set focus to this element.

                有什么建议吗?

                推荐答案

                这是一种可能的解决方案:http://www.jarloo.com/flashing-a-wpf-window/

                Here's one possible solution: http://www.jarloo.com/flashing-a-wpf-window/

                在代码示例中,为 Window 类创建了两个扩展方法:FlashWindow 和 StopFlashingWindow:

                In the code sample, two extensions methods are created for the Window class: FlashWindow and StopFlashingWindow:

                private const UInt32 FLASHW_STOP = 0; //Stop flashing. The system restores the window to its original state.        private const UInt32 FLASHW_CAPTION = 1; //Flash the window caption.        
                private const UInt32 FLASHW_TRAY = 2; //Flash the taskbar button.        
                private const UInt32 FLASHW_ALL = 3; //Flash both the window caption and taskbar button.        
                private const UInt32 FLASHW_TIMER = 4; //Flash continuously, until the FLASHW_STOP flag is set.        
                private const UInt32 FLASHW_TIMERNOFG = 12; //Flash continuously until the window comes to the foreground.  
                
                
                [StructLayout(LayoutKind.Sequential)]        
                private struct FLASHWINFO        
                {            
                    public UInt32 cbSize; //The size of the structure in bytes.            
                    public IntPtr hwnd; //A Handle to the Window to be Flashed. The window can be either opened or minimized.
                
                
                    public UInt32 dwFlags; //The Flash Status.            
                    public UInt32 uCount; // number of times to flash the window            
                    public UInt32 dwTimeout; //The rate at which the Window is to be flashed, in milliseconds. If Zero, the function uses the default cursor blink rate.        
                }         
                
                [DllImport("user32.dll")]        
                [return: MarshalAs(UnmanagedType.Bool)]        
                private static extern bool FlashWindowEx(ref FLASHWINFO pwfi);         
                
                
                
                public static void FlashWindow(this Window win, UInt32 count = UInt32.MaxValue)        
                {            
                    //Don't flash if the window is active            
                    if (win.IsActive) return;             
                    WindowInteropHelper h = new WindowInteropHelper(win);             
                    FLASHWINFO info = new FLASHWINFO 
                    {                                        
                        hwnd = h.Handle,                                        
                        dwFlags = FLASHW_ALL | FLASHW_TIMER,                                        
                        uCount = count,                                        
                        dwTimeout = 0                                    
                    };             
                
                    info.cbSize = Convert.ToUInt32(Marshal.SizeOf(info));            
                    FlashWindowEx(ref info);        
                } 
                
                public static void StopFlashingWindow(this Window win)        
                {            
                    WindowInteropHelper h = new WindowInteropHelper(win);             
                    FLASHWINFO info = new FLASHWINFO();            
                    info.hwnd = h.Handle;            
                    info.cbSize = Convert.ToUInt32(Marshal.SizeOf(info));            
                    info.dwFlags = FLASHW_STOP;            
                    info.uCount = UInt32.MaxValue;            
                    info.dwTimeout = 0;             
                    FlashWindowEx(ref info);        
                }
                

                访问 http://www.jarloo.com/flashing-a-wpf-window/ 获取完整源代码.

                Visit http://www.jarloo.com/flashing-a-wpf-window/ for the complete source.

                相当有趣的场景.我原以为这会很简单.如果我不得不做类似的事情,我会为这个问题添加书签:)

                Pretty interesting scenario. I would have thought it would be something simple. I'll have bookmark this question in the event I ever have to do something similar :)

                这篇关于如何使 WPF 窗口在任务栏上闪烁?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:偏移量 258 处的请求 BLR 无效,未定义函数 HASHMD5? 下一篇:无边框形式的 Windows 7 样式 Dropshadow

                相关文章

                • <bdo id='NOqFu'></bdo><ul id='NOqFu'></ul>
              • <tfoot id='NOqFu'></tfoot>

                1. <legend id='NOqFu'><style id='NOqFu'><dir id='NOqFu'><q id='NOqFu'></q></dir></style></legend>

                  <i id='NOqFu'><tr id='NOqFu'><dt id='NOqFu'><q id='NOqFu'><span id='NOqFu'><b id='NOqFu'><form id='NOqFu'><ins id='NOqFu'></ins><ul id='NOqFu'></ul><sub id='NOqFu'></sub></form><legend id='NOqFu'></legend><bdo id='NOqFu'><pre id='NOqFu'><center id='NOqFu'></center></pre></bdo></b><th id='NOqFu'></th></span></q></dt></tr></i><div id='NOqFu'><tfoot id='NOqFu'></tfoot><dl id='NOqFu'><fieldset id='NOqFu'></fieldset></dl></div>
                  1. <small id='NOqFu'></small><noframes id='NOqFu'>