diff options
author | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2017-03-18 21:38:42 +0300 |
---|---|---|
committer | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2017-03-18 21:57:50 +0300 |
commit | 84503d3af44292d12e80942b22c9f5d6babd85e6 (patch) | |
tree | c4f4e46ea5fa8c078334446d186dd12a926fa602 /TaskbarProgress.cs | |
parent | 038fa810f90f4c26eeb4539e6f60e6bf7db049a2 (diff) |
Should work on all Windows versions now
Diffstat (limited to 'TaskbarProgress.cs')
-rw-r--r-- | TaskbarProgress.cs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/TaskbarProgress.cs b/TaskbarProgress.cs index 11ecd945..bd957dd4 100644 --- a/TaskbarProgress.cs +++ b/TaskbarProgress.cs @@ -1,5 +1,7 @@ using System;
+using System.Diagnostics;
using System.Runtime.InteropServices;
+using System.Windows.Forms;
public static class TaskbarProgress
{
@@ -47,16 +49,23 @@ public static class TaskbarProgress {
}
- private static ITaskbarList3 taskbarInstance = (ITaskbarList3)new TaskbarInstance();
private static bool taskbarSupported = Environment.OSVersion.Version >= new Version(6, 1);
- public static void SetState(IntPtr windowHandle, TaskbarStates taskbarState)
+ public static void SetState(Form form, TaskbarStates taskbarState)
{
- if (taskbarSupported) taskbarInstance.SetProgressState(windowHandle, taskbarState);
+ if (taskbarSupported)
+ {
+ var taskbarInstance = (ITaskbarList3)new TaskbarInstance();
+ taskbarInstance.SetProgressState(form.Handle, taskbarState);
+ }
}
- public static void SetValue(IntPtr windowHandle, double progressValue, double progressMax)
+ public static void SetValue(Form form, double progressValue, double progressMax)
{
- if (taskbarSupported) taskbarInstance.SetProgressValue(windowHandle, (ulong)progressValue, (ulong)progressMax);
+ if (taskbarSupported)
+ {
+ var taskbarInstance = (ITaskbarList3)new TaskbarInstance();
+ taskbarInstance.SetProgressValue(form.Handle, (ulong)progressValue, (ulong)progressMax);
+ }
}
}
\ No newline at end of file |