Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Block Style Progressbars in Aero / .NET 4

I have three ProgressBars of the three styles. Blocks and Continuous are now rendering the same, whereas I remember Blocks used to render as Blocks.

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

is this unique to .NET 4, Aero Glass, or Windows 7? How can I tell my app to use the classic Blocks?

like image 939
tsilb Avatar asked Nov 14 '22 09:11

tsilb


1 Answers

use this

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);
}
like image 155
Navid Rahmani Avatar answered Nov 23 '22 23:11

Navid Rahmani