代码之家  ›  专栏  ›  技术社区  ›  tsilb

如何在Aero/.net4中获得块样式的progressbar

  •  5
  • tsilb  · 技术社区  · 16 年前

    我有三种风格的进度条。Blocks和Continuous现在呈现的是相同的,而我记得以前的Blocks是作为Blocks呈现的。

    http://www.kconnolly.net/pics/pb.jpg

    这是.NET4、Aero Glass还是Windows7所独有的?如何让我的应用程序使用经典块?

    1 回复  |  直到 16 年前
        1
  •  1
  •   Navid Rahmani    15 年前

    用这个

    public class ContinuousProgressBar : ProgressBar 
    { 
        public ContinuousProgressBar() 
        { 
            this.Style = ProgressBarStyle.Continuous; 
        }
        protected override void CreateHandle()
        {
            base.CreateHandle();
            try
            {
                SetWindowTheme(this.Handle, "", "");
            }
            catch 
            { 
            }
        }
    
        [System.Runtime.InteropServices.DllImport("uxtheme.dll")]  
        private static extern int SetWindowTheme(IntPtr hwnd, string appname, string idlist);
    }