<tfoot id='fBHok'></tfoot>
  • <small id='fBHok'></small><noframes id='fBHok'>

    <legend id='fBHok'><style id='fBHok'><dir id='fBHok'><q id='fBHok'></q></dir></style></legend>

    1. <i id='fBHok'><tr id='fBHok'><dt id='fBHok'><q id='fBHok'><span id='fBHok'><b id='fBHok'><form id='fBHok'><ins id='fBHok'></ins><ul id='fBHok'></ul><sub id='fBHok'></sub></form><legend id='fBHok'></legend><bdo id='fBHok'><pre id='fBHok'><center id='fBHok'></center></pre></bdo></b><th id='fBHok'></th></span></q></dt></tr></i><div id='fBHok'><tfoot id='fBHok'></tfoot><dl id='fBHok'><fieldset id='fBHok'></fieldset></dl></div>
          <bdo id='fBHok'></bdo><ul id='fBHok'></ul>

      1. C#任务栏中的Windows 7进度条?

        时间:2023-10-23
          <tbody id='rmcQz'></tbody>
        <tfoot id='rmcQz'></tfoot>

          • <small id='rmcQz'></small><noframes id='rmcQz'>

            • <bdo id='rmcQz'></bdo><ul id='rmcQz'></ul>

              1. <i id='rmcQz'><tr id='rmcQz'><dt id='rmcQz'><q id='rmcQz'><span id='rmcQz'><b id='rmcQz'><form id='rmcQz'><ins id='rmcQz'></ins><ul id='rmcQz'></ul><sub id='rmcQz'></sub></form><legend id='rmcQz'></legend><bdo id='rmcQz'><pre id='rmcQz'><center id='rmcQz'></center></pre></bdo></b><th id='rmcQz'></th></span></q></dt></tr></i><div id='rmcQz'><tfoot id='rmcQz'></tfoot><dl id='rmcQz'><fieldset id='rmcQz'></fieldset></dl></div>
              2. <legend id='rmcQz'><style id='rmcQz'><dir id='rmcQz'><q id='rmcQz'></q></dir></style></legend>

                  本文介绍了C#任务栏中的Windows 7进度条?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如果您在 Windows 7 测试版中注意到,如果您复制文件或其他系统操作,任务栏中的 Windows 资源管理器图标将填满一个绿色进度条,相当于表单上的进度条.有没有一种方法可以在我的 C# 表单中强制我的任务栏进度条与我正在执行的任何任务的进度相匹配?转换、传输、生成,那个进度条有很多用途.

                  If you've noticed in the Windows 7 beta, if you copy files or other system actions, the windows explorer icon in the taskbar will fill up with a green progress bar equivalent to the progress bar on the form. Is there a way that, in my C# forms, I can force my taskbar progress bar to match the progress of whatever task I'm doing? Converting, transferring, generating, there are so many uses for that progress bar.

                  推荐答案

                  我只是想在我的 WinForms 应用程序中添加一些任务栏进度动画,无需下载代码包或切换到 WPF 即可使用 TaskbarItemInfo.

                  I just wanted to add some taskbar progress animation to my WinForms application, without having to download code packs or switch to WPF to use TaskbarItemInfo.

                  解决方案是使用 ITaskbarList3 接口的类:

                  The solution was a class that uses the ITaskbarList3 interface:

                  using System;
                  using System.Runtime.InteropServices;
                  
                  public static class TaskbarProgress
                  {
                      public enum TaskbarStates
                      {
                          NoProgress    = 0,
                          Indeterminate = 0x1,
                          Normal        = 0x2,
                          Error         = 0x4,
                          Paused        = 0x8
                      }
                  
                      [ComImport()]
                      [Guid("ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf")]
                      [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
                      private interface ITaskbarList3
                      {
                          // 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, TaskbarStates state);
                      }
                  
                      [ComImport()]    
                      [Guid("56fdf344-fd6d-11d0-958a-006097c9a090")]
                      [ClassInterface(ClassInterfaceType.None)]
                      private class TaskbarInstance
                      {
                      }
                  
                      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)
                      {
                          if (taskbarSupported) taskbarInstance.SetProgressState(windowHandle, taskbarState);
                      }
                  
                      public static void SetValue(IntPtr windowHandle, double progressValue, double progressMax)
                      {
                          if (taskbarSupported) taskbarInstance.SetProgressValue(windowHandle, (ulong)progressValue, (ulong)progressMax);
                      }
                  }
                  

                  简单易用的示例:

                  TaskbarProgress.SetState(this.Handle, TaskbarProgress.TaskbarStates.Indeterminate);
                  
                  or
                  
                  TaskbarProgress.SetValue(this.Handle, 50, 100);
                  TaskbarProgress.SetState(this.Handle, TaskbarProgress.TaskbarStates.Error);
                  

                  这篇关于C#任务栏中的Windows 7进度条?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:来自 Windows 服务的全局键盘挂钩 下一篇:未找到源,但无法搜索部分或全部事件日志

                  相关文章

                  <legend id='wXXAQ'><style id='wXXAQ'><dir id='wXXAQ'><q id='wXXAQ'></q></dir></style></legend>
                  • <bdo id='wXXAQ'></bdo><ul id='wXXAQ'></ul>
                    <i id='wXXAQ'><tr id='wXXAQ'><dt id='wXXAQ'><q id='wXXAQ'><span id='wXXAQ'><b id='wXXAQ'><form id='wXXAQ'><ins id='wXXAQ'></ins><ul id='wXXAQ'></ul><sub id='wXXAQ'></sub></form><legend id='wXXAQ'></legend><bdo id='wXXAQ'><pre id='wXXAQ'><center id='wXXAQ'></center></pre></bdo></b><th id='wXXAQ'></th></span></q></dt></tr></i><div id='wXXAQ'><tfoot id='wXXAQ'></tfoot><dl id='wXXAQ'><fieldset id='wXXAQ'></fieldset></dl></div>

                      <tfoot id='wXXAQ'></tfoot>

                      <small id='wXXAQ'></small><noframes id='wXXAQ'>