Windows 7 Progress Bar in Taskbar in C#

How do I code a progress bar for Windows 7 to also update itself on the taskbar?

There's a good article in MSDN magazine about the new taskbar APIs. And yes, the feature is awesome :-)

Essentially, it's all about implementing IFileOperation. There's a good article about using it in managed code here.

.NET Progress bar in taskbar on windows 7

You have to download the Windows API Code Pack for .NET and use those components to interact with Windows 7 (assuming you're not using .NET 4.0).

If you are using .NET 4.0, you should include the System.Windows.Shell namespace to gain access to the Windows 7 task bar features.

How do you show progress in the Taskbar with Winform C# 4.5

Here's a short example that you should be able to use to tailor to your needs:

    System.Windows.Window w = new System.Windows.Window();
w.TaskbarItemInfo = new System.Windows.Shell.TaskbarItemInfo() { ProgressState = System.Windows.Shell.TaskbarItemProgressState.Normal };
w.Loaded += delegate {
Action<Object> callUpdateProgress = (o) => {
w.TaskbarItemInfo.ProgressValue = (double) o;
};

Thread t = new Thread(() => {
for (int i = 1; i <= 10; i++) {
w.Dispatcher.BeginInvoke(callUpdateProgress, 1.0 * i / 10);
Thread.Sleep(1000);
}
});
t.Start();
};

System.Windows.Application app = new System.Windows.Application();
app.Run(w);

To make the above work you need to have using System.Threading; at top and also add references of: PresentationCore, PresentationFramework, SystemXaml, WindowsBase.

Show a progressbar in taskbar while form is minimized

http://windowsteamblog.com/windows/b/developers/archive/2009/07/28/windows-7-taskbar-dynamic-overlay-icons-and-progress-bars.aspx

Taskbar.ProgressBar.State = 
(TaskbarButtonProgressState)Enum.Parse(
typeof(TaskbarButtonProgressState),
(string)comboBoxProgressBarStates.SelectedItem);

if (Taskbar.ProgressBar.State != TaskbarButtonProgressState.Indeterminate)
Taskbar.ProgressBar.CurrentValue = progressBar1.Value;

Marquee progressbar in windows 7 taskbar

I've did it successfully (in .NET 2.0) with the help of these two references:

  • Info on MSDN
  • Posting on SO

The marquee is done with the "Indeterminate" mode. An excerpt from my code can be found here.

Win7 progress bar on the application icon in the task bar?

The number one result from a Google search for "taskbar progress wpf":

Showing Progress in the Windows 7 Taskbar with WPF 4

Display progress bar in the program's task bar icon

Yes.

http://code.msdn.microsoft.com/WindowsAPICodePack

This has a lot of Windows Vista/7 features for .NET (C#/VB/etc.), including Task Bar Progress Bars.



Related Topics



Leave a reply



Submit