3

I'm trying to archive the blinking effect as shown in the image with my C# main form. I've Googled a lot and I've seen that it is possible with System.Windows.Shell and TaskbarItemInfo. This seems much more easy than downloading and importing those dlls.

I know how to make a new TaskbarItemInfo, but I don't know how I can connect it to the main form.

Any suggestions how I can do this with the System.Windows.Shell reference?

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Anton
  • 542
  • 1
  • 6
  • 16
  • does this SO question/answer help? http://stackoverflow.com/questions/73162/how-to-make-the-taskbar-blink-my-application-like-messenger-does-when-a-new-mess Also you mention an image don't see one in your question. – Mark Hall Aug 03 '14 at 16:04
  • Are you talking about reporting *progress* in the taskbar icon? Like the green/yellow/red states? – Cody Gray - on strike Aug 03 '14 at 16:07
  • @MarkHall Forgot to upload the image. Isn't it possible without importing dlls? – Anton Aug 03 '14 at 16:09
  • Judging from your image, yes. In that case, it's simple: `this.TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Paused;` See also: http://10rem.net/blog/2009/12/09/overlaying-icons-on-the-windows-7-taskbar-with-wpf-4 – Cody Gray - on strike Aug 03 '14 at 16:09
  • @CodyGray That could also come in handy. – Anton Aug 03 '14 at 16:09
  • @CodeGray 'Project' does not contain a definition for 'TaskbarItemInfo' and no extension method 'TaskbarItemInfo' accepting a first argument of type 'Project' could be found – Anton Aug 03 '14 at 16:11
  • @Anton is this winforms or Wpf? if winforms look at this question/answer http://stackoverflow.com/questions/1146574/how-do-i-code-a-progress-bar-for-windows-7-to-also-update-itself-on-the-taskbar You will need to download the the Windows API CodePack. per Wilka's answer – Mark Hall Aug 03 '14 at 16:17
  • I've seen that answer before, but the link is dead. – Anton Aug 03 '14 at 16:21
  • @Anton It appears to be available though Nuget. http://www.nuget.org/packages/Microsoft.WindowsAPICodePack-Core/ Though in this case it might be easier just to PInvoke like the first link I shared. – Mark Hall Aug 03 '14 at 16:34
  • @MarkHall I don't have NuGet, isn't there any zip or installer that I can download? – Anton Aug 03 '14 at 17:26
  • @Anton Not that I could find. – Mark Hall Aug 03 '14 at 17:27
  • Is looking at the documentation overrated nowadays? [`TaskBarItemInfo` is in the `System.Windows.Shell` namespace](http://msdn.microsoft.com/en-us/library/system.windows.shell.taskbariteminfo.aspx). You will need a `using` statement. That really shouldn't be so hard to figure out. – Cody Gray - on strike Aug 12 '14 at 08:36
  • Possible duplicate of [Window application flash like orange on taskbar when minimize](https://stackoverflow.com/questions/11309827/window-application-flash-like-orange-on-taskbar-when-minimize) – Jim Fell Jun 06 '19 at 13:42
  • Possible duplicate of [Taskbar notification glow](https://stackoverflow.com/questions/18979534/taskbar-notification-glow) – Guilherme Lemmi Jun 11 '19 at 19:54

1 Answers1

1

Cant See the image..are you talking about the windows 7 blinking effect

To make a new TaskbarItemInfo:

public TaskbarItemInfo TaskbarItemInfo { get; set; }

    public Form1()
    {
        InitializeComponent();

        this.TaskbarItemInfo = new TaskbarItemInfo();//
    }

But I prefer this:

using System.Runtime.InteropServices;

    [DllImport("user32.dll")]
    public static extern int FlashWindow(IntPtr Hwnd, bool Revert); 

    // check if window is minimised

    private void Form4_Resize(object sender, EventArgs e)

    {

         if (this.WindowState == FormWindowState.Minimized)

             FlashWindow(this.Handle, false);

    }

This should work..

Also // 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);

Ryu
  • 191
  • 10