c#: 任务栏进度显示(TaskbarManager)
Win7及以上系统支持任务栏进度条,为有进度类应用显示进度于任务栏,甚为方便。
以c#之WinForm实现其,大多采用Windows API Code Pack这个方案,加多引用,比较繁琐,而我总也打不开了其页面。
鄙人不喜欢多引用东西,即寻求方法抽取其相关代码,简化其应用。费些工夫,实现效果。
一、TaskbarManager
此为抽取必要代码而组成同名类,全部代码如下:
- //抽取TaskBar代码,用其设置任务栏进度部分
- //Copyright (c) Microsoft Corporation. All rights reserved.
- using System;
- using System.Diagnostics;
- using System.Runtime.InteropServices;
- namespace wApp
- {
- /// <summary>
- /// Represents an instance of the Windows taskbar
- /// </summary>
- public class TaskbarManager
- {
- // Hide the default constructor
- private TaskbarManager()
- {
- }
- // Best practice recommends defining a private object to lock on
- private static object _syncLock = new object();
- private static TaskbarManager _instance;
- /// <summary>
- /// Represents an instance of the Windows Taskbar
- /// </summary>
- public static TaskbarManager Instance
- {
- get
- {
- if (_instance == null)
- {
- lock (_syncLock)
- {
- if (_instance == null)
- _instance = new TaskbarManager();
- }
- }
- return _instance;
- }
- }
- /// <summary>
- /// Indicates whether this feature is supported on the current platform.
- /// </summary>
- public static bool IsPlatformSupported
- {
- get { return Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.CompareTo(new Version(, )) >= ; }
- }
- /// <summary>
- /// Displays or updates a progress bar hosted in a taskbar button of the main application window
- /// to show the specific percentage completed of the full operation.
- /// </summary>
- /// <param name="currentValue">An application-defined value that indicates the proportion of the operation that has been completed at the time the method is called.</param>
- /// <param name="maximumValue">An application-defined value that specifies the value currentValue will have when the operation is complete.</param>
- public void SetProgressValue(int currentValue, int maximumValue)
- {
- if (IsPlatformSupported)
- TaskbarList.Instance.SetProgressValue(
- OwnerHandle,
- Convert.ToUInt32(currentValue),
- Convert.ToUInt32(maximumValue));
- }
- /// <summary>
- /// Displays or updates a progress bar hosted in a taskbar button of the given window handle
- /// to show the specific percentage completed of the full operation.
- /// </summary>
- /// <param name="windowHandle">The handle of the window whose associated taskbar button is being used as a progress indicator.
- /// This window belong to a calling process associated with the button's application and must be already loaded.</param>
- /// <param name="currentValue">An application-defined value that indicates the proportion of the operation that has been completed at the time the method is called.</param>
- /// <param name="maximumValue">An application-defined value that specifies the value currentValue will have when the operation is complete.</param>
- public void SetProgressValue(int currentValue, int maximumValue, IntPtr windowHandle)
- {
- if (IsPlatformSupported)
- TaskbarList.Instance.SetProgressValue(
- windowHandle,
- Convert.ToUInt32(currentValue),
- Convert.ToUInt32(maximumValue));
- }
- /// <summary>
- /// Sets the type and state of the progress indicator displayed on a taskbar button of the main application window.
- /// </summary>
- /// <param name="state">Progress state of the progress button</param>
- public void SetProgressState(TaskbarProgressBarState state)
- {
- if (IsPlatformSupported)
- TaskbarList.Instance.SetProgressState(OwnerHandle, (TaskbarProgressBarStatus)state);
- }
- /// <summary>
- /// Sets the type and state of the progress indicator displayed on a taskbar button
- /// of the given window handle
- /// </summary>
- /// <param name="windowHandle">The handle of the window whose associated taskbar button is being used as a progress indicator.
- /// This window belong to a calling process associated with the button's application and must be already loaded.</param>
- /// <param name="state">Progress state of the progress button</param>
- public void SetProgressState(TaskbarProgressBarState state, IntPtr windowHandle)
- {
- if (IsPlatformSupported)
- TaskbarList.Instance.SetProgressState(windowHandle, (TaskbarProgressBarStatus)state);
- }
- private IntPtr _ownerHandle;
- /// <summary>
- /// Sets the handle of the window whose taskbar button will be used
- /// to display progress.
- /// </summary>
- internal IntPtr OwnerHandle
- {
- get
- {
- if (_ownerHandle == IntPtr.Zero)
- {
- Process currentProcess = Process.GetCurrentProcess();
- if (currentProcess != null && currentProcess.MainWindowHandle != IntPtr.Zero)
- _ownerHandle = currentProcess.MainWindowHandle;
- }
- return _ownerHandle;
- }
- }
- }
- /// <summary>
- /// Represents the thumbnail progress bar state.
- /// </summary>
- public enum TaskbarProgressBarState
- {
- /// <summary>
- /// No progress is displayed.
- /// </summary>
- NoProgress = ,
- /// <summary>
- /// The progress is indeterminate (marquee).
- /// </summary>
- Indeterminate = 0x1,
- /// <summary>
- /// Normal progress is displayed.
- /// </summary>
- Normal = 0x2,
- /// <summary>
- /// An error occurred (red).
- /// </summary>
- Error = 0x4,
- /// <summary>
- /// The operation is paused (yellow).
- /// </summary>
- Paused = 0x8
- }
- /// <summary>
- /// Provides internal access to the functions provided by the ITaskbarList4 interface,
- /// without being forced to refer to it through another singleton.
- /// </summary>
- internal static class TaskbarList
- {
- private static object _syncLock = new object();
- private static ITaskbarList4 _taskbarList;
- internal static ITaskbarList4 Instance
- {
- get
- {
- if (_taskbarList == null)
- {
- lock (_syncLock)
- {
- if (_taskbarList == null)
- {
- _taskbarList = (ITaskbarList4)new CTaskbarList();
- _taskbarList.HrInit();
- }
- }
- }
- return _taskbarList;
- }
- }
- }
- [GuidAttribute("56FDF344-FD6D-11d0-958A-006097C9A090")]
- [ClassInterfaceAttribute(ClassInterfaceType.None)]
- [ComImportAttribute()]
- internal class CTaskbarList { }
- [ComImportAttribute()]
- [GuidAttribute("c43dc798-95d1-4bea-9030-bb99e2983a1a")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- internal interface ITaskbarList4
- {
- // ITaskbarList
- [PreserveSig]
- void HrInit();
- [PreserveSig]
- void AddTab(IntPtr hwnd);
- [PreserveSig]
- void DeleteTab(IntPtr hwnd);
- [PreserveSig]
- void ActivateTab(IntPtr hwnd);
- [PreserveSig]
- void SetActiveAlt(IntPtr hwnd);
- // ITaskbarList2
- [PreserveSig]
- void MarkFullscreenWindow(
- IntPtr hwnd,
- [MarshalAs(UnmanagedType.Bool)] bool fFullscreen);
- // ITaskbarList3
- [PreserveSig]
- void SetProgressValue(IntPtr hwnd, UInt64 ullCompleted, UInt64 ullTotal);
- [PreserveSig]
- void SetProgressState(IntPtr hwnd, TaskbarProgressBarStatus tbpFlags);
- [PreserveSig]
- void RegisterTab(IntPtr hwndTab, IntPtr hwndMDI);
- [PreserveSig]
- void UnregisterTab(IntPtr hwndTab);
- [PreserveSig]
- void SetTabOrder(IntPtr hwndTab, IntPtr hwndInsertBefore);
- [PreserveSig]
- void SetTabActive(IntPtr hwndTab, IntPtr hwndInsertBefore, uint dwReserved);
- [PreserveSig]
- HResult ThumbBarAddButtons(
- IntPtr hwnd,
- uint cButtons,
- [MarshalAs(UnmanagedType.LPArray)] ThumbButton[] pButtons);
- [PreserveSig]
- HResult ThumbBarUpdateButtons(
- IntPtr hwnd,
- uint cButtons,
- [MarshalAs(UnmanagedType.LPArray)] ThumbButton[] pButtons);
- [PreserveSig]
- void ThumbBarSetImageList(IntPtr hwnd, IntPtr himl);
- [PreserveSig]
- void SetOverlayIcon(
- IntPtr hwnd,
- IntPtr hIcon,
- [MarshalAs(UnmanagedType.LPWStr)] string pszDescription);
- [PreserveSig]
- void SetThumbnailTooltip(
- IntPtr hwnd,
- [MarshalAs(UnmanagedType.LPWStr)] string pszTip);
- [PreserveSig]
- void SetThumbnailClip(
- IntPtr hwnd,
- IntPtr prcClip);
- // ITaskbarList4
- void SetTabProperties(IntPtr hwndTab, SetTabPropertiesOption stpFlags);
- }
- internal enum TaskbarProgressBarStatus
- {
- NoProgress = ,
- Indeterminate = 0x1,
- Normal = 0x2,
- Error = 0x4,
- Paused = 0x8
- }
- internal enum ThumbButtonMask
- {
- Bitmap = 0x1,
- Icon = 0x2,
- Tooltip = 0x4,
- THB_FLAGS = 0x8
- }
- [Flags]
- internal enum ThumbButtonOptions
- {
- Enabled = 0x00000000,
- Disabled = 0x00000001,
- DismissOnClick = 0x00000002,
- NoBackground = 0x00000004,
- Hidden = 0x00000008,
- NonInteractive = 0x00000010
- }
- internal enum SetTabPropertiesOption
- {
- None = 0x0,
- UseAppThumbnailAlways = 0x1,
- UseAppThumbnailWhenActive = 0x2,
- UseAppPeekAlways = 0x4,
- UseAppPeekWhenActive = 0x8
- }
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
- internal struct ThumbButton
- {
- /// <summary>
- /// WPARAM value for a THUMBBUTTON being clicked.
- /// </summary>
- internal const int Clicked = 0x1800;
- [MarshalAs(UnmanagedType.U4)]
- internal ThumbButtonMask Mask;
- internal uint Id;
- internal uint Bitmap;
- internal IntPtr Icon;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = )]
- internal string Tip;
- [MarshalAs(UnmanagedType.U4)]
- internal ThumbButtonOptions Flags;
- }
- /// <summary>
- /// HRESULT Wrapper
- /// </summary>
- public enum HResult
- {
- /// <summary>
- /// S_OK
- /// </summary>
- Ok = 0x0000,
- /// <summary>
- /// S_FALSE
- /// </summary>
- False = 0x0001,
- /// <summary>
- /// E_INVALIDARG
- /// </summary>
- InvalidArguments = unchecked((int)0x80070057),
- /// <summary>
- /// E_OUTOFMEMORY
- /// </summary>
- OutOfMemory = unchecked((int)0x8007000E),
- /// <summary>
- /// E_NOINTERFACE
- /// </summary>
- NoInterface = unchecked((int)0x80004002),
- /// <summary>
- /// E_FAIL
- /// </summary>
- Fail = unchecked((int)0x80004005),
- /// <summary>
- /// E_ELEMENTNOTFOUND
- /// </summary>
- ElementNotFound = unchecked((int)0x80070490),
- /// <summary>
- /// TYPE_E_ELEMENTNOTFOUND
- /// </summary>
- TypeElementNotFound = unchecked((int)0x8002802B),
- /// <summary>
- /// NO_OBJECT
- /// </summary>
- NoObject = unchecked((int)0x800401E5),
- /// <summary>
- /// Win32 Error code: ERROR_CANCELLED
- /// </summary>
- Win32ErrorCanceled = ,
- /// <summary>
- /// ERROR_CANCELLED
- /// </summary>
- Canceled = unchecked((int)0x800704C7),
- /// <summary>
- /// The requested resource is in use
- /// </summary>
- ResourceInUse = unchecked((int)0x800700AA),
- /// <summary>
- /// The requested resources is read-only.
- /// </summary>
- AccessDenied = unchecked((int)0x80030005)
- }
- }
静态类实现方法(推荐使用这个):
- using System;
- using System.Diagnostics;
- using System.Runtime.InteropServices;
- namespace wApp
- {
- /// <summary>
- /// Represents an instance of the Windows taskbar
- /// </summary>
- public static class TaskbarManager
- {
- /// <summary>
- /// Sets the handle of the window whose taskbar button will be used
- /// to display progress.
- /// </summary>
- private static IntPtr ownerHandle = IntPtr.Zero;
- static TaskbarManager()
- {
- var currentProcess = Process.GetCurrentProcess();
- if (currentProcess != null && currentProcess.MainWindowHandle != IntPtr.Zero)
- ownerHandle = currentProcess.MainWindowHandle;
- }
- /// <summary>
- /// Indicates whether this feature is supported on the current platform.
- /// </summary>
- private static bool IsPlatformSupported
- {
- get { return Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.CompareTo(new Version(, )) >= ; }
- }
- /// <summary>
- /// Displays or updates a progress bar hosted in a taskbar button of the main application window
- /// to show the specific percentage completed of the full operation.
- /// </summary>
- /// <param name="currentValue">An application-defined value that indicates the proportion of the operation that has been completed at the time the method is called.</param>
- /// <param name="maximumValue">An application-defined value that specifies the value currentValue will have when the operation is complete.</param>
- public static void SetProgressValue(int currentValue, int maximumValue)
- {
- if (IsPlatformSupported && ownerHandle != IntPtr.Zero)
- TaskbarList.Instance.SetProgressValue(
- ownerHandle,
- Convert.ToUInt32(currentValue),
- Convert.ToUInt32(maximumValue));
- }
- /// <summary>
- /// Displays or updates a progress bar hosted in a taskbar button of the given window handle
- /// to show the specific percentage completed of the full operation.
- /// </summary>
- /// <param name="windowHandle">The handle of the window whose associated taskbar button is being used as a progress indicator.
- /// This window belong to a calling process associated with the button's application and must be already loaded.</param>
- /// <param name="currentValue">An application-defined value that indicates the proportion of the operation that has been completed at the time the method is called.</param>
- /// <param name="maximumValue">An application-defined value that specifies the value currentValue will have when the operation is complete.</param>
- public static void SetProgressValue(int currentValue, int maximumValue, IntPtr windowHandle)
- {
- if (IsPlatformSupported)
- TaskbarList.Instance.SetProgressValue(
- windowHandle,
- Convert.ToUInt32(currentValue),
- Convert.ToUInt32(maximumValue));
- }
- /// <summary>
- /// Sets the type and state of the progress indicator displayed on a taskbar button of the main application window.
- /// </summary>
- /// <param name="state">Progress state of the progress button</param>
- public static void SetProgressState(TaskbarProgressBarState state)
- {
- if (IsPlatformSupported && ownerHandle != IntPtr.Zero)
- TaskbarList.Instance.SetProgressState(ownerHandle, (TaskbarProgressBarStatus)state);
- }
- /// <summary>
- /// Sets the type and state of the progress indicator displayed on a taskbar button
- /// of the given window handle
- /// </summary>
- /// <param name="windowHandle">The handle of the window whose associated taskbar button is being used as a progress indicator.
- /// This window belong to a calling process associated with the button's application and must be already loaded.</param>
- /// <param name="state">Progress state of the progress button</param>
- public static void SetProgressState(TaskbarProgressBarState state, IntPtr windowHandle)
- {
- if (IsPlatformSupported)
- TaskbarList.Instance.SetProgressState(windowHandle, (TaskbarProgressBarStatus)state);
- }
- }
- /// <summary>
- /// Represents the thumbnail progress bar state.
- /// </summary>
- public enum TaskbarProgressBarState
- {
- /// <summary>
- /// No progress is displayed.
- /// </summary>
- NoProgress = ,
- /// <summary>
- /// The progress is indeterminate (marquee).
- /// </summary>
- Indeterminate = 0x1,
- /// <summary>
- /// Normal progress is displayed.
- /// </summary>
- Normal = 0x2,
- /// <summary>
- /// An error occurred (red).
- /// </summary>
- Error = 0x4,
- /// <summary>
- /// The operation is paused (yellow).
- /// </summary>
- Paused = 0x8
- }
- /// <summary>
- /// Provides internal access to the functions provided by the ITaskbarList4 interface,
- /// without being forced to refer to it through another singleton.
- /// </summary>
- internal static class TaskbarList
- {
- private static object _syncLock = new object();
- private static ITaskbarList4 _taskbarList;
- internal static ITaskbarList4 Instance
- {
- get
- {
- if (_taskbarList == null)
- {
- lock (_syncLock)
- {
- if (_taskbarList == null)
- {
- _taskbarList = (ITaskbarList4)new CTaskbarList();
- _taskbarList.HrInit();
- }
- }
- }
- return _taskbarList;
- }
- }
- }
- [GuidAttribute("56FDF344-FD6D-11d0-958A-006097C9A090")]
- [ClassInterfaceAttribute(ClassInterfaceType.None)]
- [ComImportAttribute()]
- internal class CTaskbarList { }
- [ComImportAttribute()]
- [GuidAttribute("c43dc798-95d1-4bea-9030-bb99e2983a1a")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- internal interface ITaskbarList4
- {
- // ITaskbarList
- [PreserveSig]
- void HrInit();
- [PreserveSig]
- void AddTab(IntPtr hwnd);
- [PreserveSig]
- void DeleteTab(IntPtr hwnd);
- [PreserveSig]
- void ActivateTab(IntPtr hwnd);
- [PreserveSig]
- void SetActiveAlt(IntPtr hwnd);
- // ITaskbarList2
- [PreserveSig]
- void MarkFullscreenWindow(
- IntPtr hwnd,
- [MarshalAs(UnmanagedType.Bool)] bool fFullscreen);
- // ITaskbarList3
- [PreserveSig]
- void SetProgressValue(IntPtr hwnd, UInt64 ullCompleted, UInt64 ullTotal);
- [PreserveSig]
- void SetProgressState(IntPtr hwnd, TaskbarProgressBarStatus tbpFlags);
- [PreserveSig]
- void RegisterTab(IntPtr hwndTab, IntPtr hwndMDI);
- [PreserveSig]
- void UnregisterTab(IntPtr hwndTab);
- [PreserveSig]
- void SetTabOrder(IntPtr hwndTab, IntPtr hwndInsertBefore);
- [PreserveSig]
- void SetTabActive(IntPtr hwndTab, IntPtr hwndInsertBefore, uint dwReserved);
- [PreserveSig]
- HResult ThumbBarAddButtons(
- IntPtr hwnd,
- uint cButtons,
- [MarshalAs(UnmanagedType.LPArray)] ThumbButton[] pButtons);
- [PreserveSig]
- HResult ThumbBarUpdateButtons(
- IntPtr hwnd,
- uint cButtons,
- [MarshalAs(UnmanagedType.LPArray)] ThumbButton[] pButtons);
- [PreserveSig]
- void ThumbBarSetImageList(IntPtr hwnd, IntPtr himl);
- [PreserveSig]
- void SetOverlayIcon(
- IntPtr hwnd,
- IntPtr hIcon,
- [MarshalAs(UnmanagedType.LPWStr)] string pszDescription);
- [PreserveSig]
- void SetThumbnailTooltip(
- IntPtr hwnd,
- [MarshalAs(UnmanagedType.LPWStr)] string pszTip);
- [PreserveSig]
- void SetThumbnailClip(
- IntPtr hwnd,
- IntPtr prcClip);
- // ITaskbarList4
- void SetTabProperties(IntPtr hwndTab, SetTabPropertiesOption stpFlags);
- }
- internal enum TaskbarProgressBarStatus
- {
- NoProgress = ,
- Indeterminate = 0x1,
- Normal = 0x2,
- Error = 0x4,
- Paused = 0x8
- }
- internal enum ThumbButtonMask
- {
- Bitmap = 0x1,
- Icon = 0x2,
- Tooltip = 0x4,
- THB_FLAGS = 0x8
- }
- [Flags]
- internal enum ThumbButtonOptions
- {
- Enabled = 0x00000000,
- Disabled = 0x00000001,
- DismissOnClick = 0x00000002,
- NoBackground = 0x00000004,
- Hidden = 0x00000008,
- NonInteractive = 0x00000010
- }
- internal enum SetTabPropertiesOption
- {
- None = 0x0,
- UseAppThumbnailAlways = 0x1,
- UseAppThumbnailWhenActive = 0x2,
- UseAppPeekAlways = 0x4,
- UseAppPeekWhenActive = 0x8
- }
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
- internal struct ThumbButton
- {
- /// <summary>
- /// WPARAM value for a THUMBBUTTON being clicked.
- /// </summary>
- internal const int Clicked = 0x1800;
- [MarshalAs(UnmanagedType.U4)]
- internal ThumbButtonMask Mask;
- internal uint Id;
- internal uint Bitmap;
- internal IntPtr Icon;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = )]
- internal string Tip;
- [MarshalAs(UnmanagedType.U4)]
- internal ThumbButtonOptions Flags;
- }
- /// <summary>
- /// HRESULT Wrapper
- /// </summary>
- public enum HResult
- {
- /// <summary>
- /// S_OK
- /// </summary>
- Ok = 0x0000,
- /// <summary>
- /// S_FALSE
- /// </summary>
- False = 0x0001,
- /// <summary>
- /// E_INVALIDARG
- /// </summary>
- InvalidArguments = unchecked((int)0x80070057),
- /// <summary>
- /// E_OUTOFMEMORY
- /// </summary>
- OutOfMemory = unchecked((int)0x8007000E),
- /// <summary>
- /// E_NOINTERFACE
- /// </summary>
- NoInterface = unchecked((int)0x80004002),
- /// <summary>
- /// E_FAIL
- /// </summary>
- Fail = unchecked((int)0x80004005),
- /// <summary>
- /// E_ELEMENTNOTFOUND
- /// </summary>
- ElementNotFound = unchecked((int)0x80070490),
- /// <summary>
- /// TYPE_E_ELEMENTNOTFOUND
- /// </summary>
- TypeElementNotFound = unchecked((int)0x8002802B),
- /// <summary>
- /// NO_OBJECT
- /// </summary>
- NoObject = unchecked((int)0x800401E5),
- /// <summary>
- /// Win32 Error code: ERROR_CANCELLED
- /// </summary>
- Win32ErrorCanceled = ,
- /// <summary>
- /// ERROR_CANCELLED
- /// </summary>
- Canceled = unchecked((int)0x800704C7),
- /// <summary>
- /// The requested resource is in use
- /// </summary>
- ResourceInUse = unchecked((int)0x800700AA),
- /// <summary>
- /// The requested resources is read-only.
- /// </summary>
- AccessDenied = unchecked((int)0x80030005)
- }
- }
二、使用方法
它有一静态公用变量Instance,直引用即可;或以静态类直接引用,而不再加以.Instance。以引用静态类为例:
- private void trackBar_ValueChanged(object sender, EventArgs e)
- {
- TaskbarManager.SetProgressValue(trackBar.Value, trackBar.Maximum);
- }
- private void btnNoProgress_Click(object sender, EventArgs e)
- {
- TaskbarManager.SetProgressState(TaskbarProgressBarState.NoProgress);
- }
- private void btnIndeterminate_Click(object sender, EventArgs e)
- {
- TaskbarManager.SetProgressState(TaskbarProgressBarState.Indeterminate);
- }
- private void btnNormal_Click(object sender, EventArgs e)
- {
- TaskbarManager.SetProgressState(TaskbarProgressBarState.Normal);
- TaskbarManager.SetProgressValue(trackBar.Value, trackBar.Maximum);
- }
- private void btn_Click(object sender, EventArgs e)
- {
- TaskbarManager.SetProgressState(TaskbarProgressBarState.Error);
- TaskbarManager.SetProgressValue(trackBar.Value, trackBar.Maximum);
- }
- private void btnPaused_Click(object sender, EventArgs e)
- {
- TaskbarManager.SetProgressState(TaskbarProgressBarState.Paused);
- TaskbarManager.SetProgressValue(trackBar.Value, trackBar.Maximum);
- }
三、效果如下图示:
参考资料:
Windows 7 progress bar in taskbar in C#? - Stack Overflow
c#: 任务栏进度显示(TaskbarManager)的更多相关文章
- Qt创建任务栏进度条
一.正文 任务栏进度条是Windows7就引入的一种UI形式,通常用于显示软件当前正在执行的任务的进度(如编译程序的进度.下载任务的进度).如下: 在Qt中使用任务栏进度条也是非常容易的一件事情.Qt ...
- TaskBarProgress(任务栏进度条)
原文:TaskBarProgress(任务栏进度条) </Grid> { { InitializeComponent(); Loaded += } { BackgroundWorker w ...
- html5 图片上传,支持图片预览、压缩、及进度显示,兼容IE6+及标准浏览器
以前写过上传组件,见 打造 html5 文件上传组件,实现进度显示及拖拽上传,兼容IE6+及其它标准浏览器,对付一般的上传没有问题,不过如果是上传图片,且需要预览的话,就力有不逮了,趁着闲暇时间,给上 ...
- Retrofit2文件上传下载及其进度显示
序 前面一篇文章介绍了Retrofit2的基本使用,这篇文章接着介绍使用Retrofit2实现文件上传和文件下载,以及上传下载过程中如何实现进度的显示. 文件上传 定义接口 1 2 3 @Multip ...
- [cocos2d]场景切换以及切换进度显示
本文主要分两个部分叙述,第一是场景切换,第二是场景切换的进度显示. 一.场景切换 参考learn-iphone-and-ipad-cocos2d-game-development 第五章内容 coco ...
- Python多线程同步命令行模拟进度显示
最近在一个Python(3.5)的小项目中需要用到多线程加快处理速度,同时需要显示进度,于是查了些资料找到几个实现方法:线程池的map-reduce和Queue结合线程的实现.这里简单的实例介绍一下Q ...
- nginx上传模块nginx_upload_module和nginx_uploadprogress_module模块进度显示,如何传递GET参数等。
ownload:http://www.grid.net.ru/nginx/download/nginx_upload_module-2.2.0.tar.gzconfigure and make : . ...
- 超赞的CSS3进度条 可以随进度显示不同颜色
原文:超赞的CSS3进度条 可以随进度显示不同颜色 现在的WEB已经不是以前的WEB了,传输更大的数据量,有着更加复杂的计算,这就需要利用进度条来提高用户体验,必要时可以让用户耐心等待,不至于因操作卡 ...
- WPF中任务栏只显示主窗口
我们在用WPF开发的时候,常常会遇到在主窗口打开的情况下,去显示子窗口,而此时任务栏同时显示主窗口与子窗口.这样看起来很不美观.所以在弹出子窗口之前,设置它的几个相应属性,便不会出现这种问题了. // ...
随机推荐
- 排序算法练习--JAVA(:内部排序:插入、选择、冒泡、快速排序)
排序算法是数据结构中的经典算法知识点,也是笔试面试中经常考察的问题,平常学的不扎实笔试时候容易出洋相,回来恶补,尤其是碰到递归很可能被问到怎么用非递归实现... 内部排序: 插入排序:直接插入排序 选 ...
- Vue创建头部组件示例
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta ht ...
- 记一次php脚本memory exhausted
表象报错如下: Error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 16651985 bytes) 出 ...
- 3.3-1933 problem A
#include <stdio.h> int main(void){ int h; while(scanf("%d", &h) != EOF){ * (h-); ...
- JAVA AES CBC 加密 解密
AES 256 , KEY 的长度为 32字节(32*8=256bit). AES 128 , KEY 的长度为 16字节(16*8=128bit) CBC 模式需要IV, IV的值是固定写死,还是当 ...
- C++类中this指针的理解
先要理解class的意思.class应该理解为一种类型,象int,char一样,是用户自定义的类型.用这个类型可以来声明一个变量,比如int x, myclass my等等.这样就像变量x具有int类 ...
- Entity Framework Code first 可能会导致循环或多个级联路径.
用code first映射数据库报错 Introducing FOREIGN KEY constraint 'FK_dbo.Roles_dbo.SubSystems_SubSystemID' on t ...
- 前端-JavaScript1-1——JavaScript简介
1.1 JavaScript用途 前端三层: 结构层 HTML 从语义的角度描述页面的结构 样式层 CSS 从审美的角度装饰页面 行为层 J ...
- 测试WCF遇到的一些问题
win7+iis7 1.localhost访问bad request错误. 主机地址不要指定为127.0.0.1.设置为”全部未分配“. 2.错误 500.19(由于权限不足而无法读取配置文件)的问题 ...
- js基础系列之【作用域】
声明:形成本文的出发点仅仅是个人总结记录,避免遗忘,并非详实的教程:文中引用了经过个人加工的其它作者的内容,并非原创.学海无涯 什么是作用域? 作用域就是一套规则,用于确定在何处以及如何查找变量(标识 ...