How to highlight a taskbar item

In almost all messengers, when your IM window is minimized on the taskbar, the IM taskbar item changes color or becomes brighter when you have a new message. I was looking for any help on how to do this using .NET Winforms or WPF

Any code examples?

=============================================== === ====================

EDIT: I used FlashWindow for my WPF window.

Link: http://www.aeoth.net/blog/2007/04/27/flashing-the-window-in-wpf-c-2/

+2


a source to share


2 answers


You want to use the FlashWindowEx function . Basically, take a handle to the window, create a FLASHWINFO structure with a handle and how you want the window to flash (continuously until it is opened, etc.), AND don't pass it to FlashWindowEx.



edit: Here's an example on how to do it in C #.

+7


a source


I was still confused as to how to get it to just highlight the taskbar item instead of blinking. Here is the code that ended up working for me (I feel pretty stupid because the counter value is missing to 1, hopefully this will save someone else).



Public Structure FLASHWINFO
  Public cbSize As UInt32
  Public hwnd As IntPtr
  Public dwFlags As UInt32
  Public uCount As UInt32
  Public dwTimeout As UInt32
End Structure

Private Declare Function FlashWindowEx Lib "user32.dll" (ByRef pfwi As FLASHWINFO) As Boolean

Private Const FLASHW_STOP As UInt32 = 0
Private Const FLASHW_CAPTION As UInt32 = 1
Private Const FLASHW_TRAY As UInt32 = 2
Private Const FLASHW_ALL As UInt32 = 3
Private Const FLASHW_TIMER As UInt32 = 4
Private Const FLASHW_TIMERNOFG As UInt32 = 12

Public Shared Sub Flash(ByRef thisForm As Form)   
  Dim flash As New FLASHWINFO With {
    .cbSize = System.Runtime.InteropServices.Marshal.SizeOf(flash),
    .hwnd = thisForm.Handle,
    .dwFlags = FLASHW_TRAY Or FLASHW_TIMERNOFG,
    .uCount = 1}
  'Leaving out .dwCount seems to work just fine for me, the uCount above keeps it from flashing

  FlashWindowEx(flash)
End Sub

      

0


a source







All Articles