hi i created a little bit of code for colouring progressbars ( back and forecolor )
to test :Code:using System.Runtime.InteropServices; ///// at top of code window ^^^^^^^ ///// [DllImport("User32.Dll")] public static extern int SendMessage(int hwnd,int wMsg,int wParam,int lParam); public const int PBM_SETBKCOLOR = 0x2001; public const int PBM_SETBARCOLOR = 0x409; ///// in designer area ^^^^^^^^ ///// //// public void SetProgressBackColor(Color c) {/// set the back color of the bar int a=Convert.ToInt32(c.R.ToString()); int b=Convert.ToInt32(c.G.ToString()); int d=Convert.ToInt32(c.B.ToString()); int tot=Convert.ToInt32(ColorTranslator.ToOle(Color.FromArgb(a,b,d)).ToString()); int j=this.progressBar1.Handle.ToInt32(); SendMessage(j,PBM_SETBKCOLOR,0,tot); } public void SetProgressForeColor(Color c) {/// set the forecolor of the bar int a=Convert.ToInt32(c.R.ToString()); int b=Convert.ToInt32(c.G.ToString()); int d=Convert.ToInt32(c.B.ToString()); int tot=Convert.ToInt32(ColorTranslator.ToOle(Color.FromArgb(a,b,d)).ToString()); int j=this.progressBar1.Handle.ToInt32(); SendMessage(j,PBM_SETBARCOLOR,0,tot); } private void button4_Click(object sender, System.EventArgs e) {//// set colour to your choice. SetProgressBackColor(System.Drawing.Color.BlueViolet); SetProgressForeColor(System.Drawing.Color.Red); }
obviously naming your controls as nessacaryCode:private void button1_Click(object sender, System.EventArgs e) { this.progressBar1.Minimum = 1; this.progressBar1.Maximum = 10000; this.progressBar1.Step = 1; this.progressBar1.Value = 1; for(int i=progressBar1.Minimum; i<=progressBar1.Maximum; i++) { progressBar1.PerformStep(); } }
![]()


Reply With Quote