// Copyright (c) Microsoft Corporation. All rights reserved. using System; using System.Runtime.InteropServices; namespace wyDay.Controls { /// /// The primary coordinator of the Windows 7 taskbar-related activities. /// public static class Windows7Taskbar { private static ITaskbarList3 _taskbarList; internal static ITaskbarList3 TaskbarList { get { if (_taskbarList == null) { lock (typeof(Windows7Taskbar)) { if (_taskbarList == null) { _taskbarList = (ITaskbarList3)new CTaskbarList(); _taskbarList.HrInit(); } } } return _taskbarList; } } static readonly OperatingSystem osInfo = Environment.OSVersion; internal static bool Windows7OrGreater { get { return (osInfo.Version.Major == 6 && osInfo.Version.Minor >= 1) || (osInfo.Version.Major > 6); } } /// /// Sets the progress state of the specified window's /// taskbar button. /// /// The window handle. /// The progress state. public static void SetProgressState(IntPtr hwnd, ThumbnailProgressState state) { if(Windows7OrGreater) TaskbarList.SetProgressState(hwnd, state); } /// /// Sets the progress value of the specified window's /// taskbar button. /// /// The window handle. /// The current value. /// The maximum value. public static void SetProgressValue(IntPtr hwnd, ulong current, ulong maximum) { if(Windows7OrGreater) TaskbarList.SetProgressValue(hwnd, current, maximum); } [DllImport("user32.dll", CharSet = CharSet.Auto)] internal static extern int SendMessage(IntPtr hWnd, int wMsg, int wParam, int lParam); } }