C# Source Code: Changing the backcolor and forecolor (bar color) of a progress bar
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
C# Source Code
Changing the backcolor and forecolor (bar color) of a progress bar
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Thursday, August 05, 2004
Hits:
2333
Category:
Windows Forms/GUI/Controls
Article:
The routine below enables you to change the forecolor and bar color of a .NET progress bar: using System.Drawing; using System.Windows.Forms; using System.Runtime.InteropServices; [DllImport("USER32.DLL")] public static extern int SendMessage(IntPtr hwnd,int msg,int character,int count); ///
/// Sets the forecolor and bar color of a progress bar ///
///
The progress bar to change the color of ///
The color to change to ///
If true sets the forecolor (or bar color), else sets the backcolor. public static void ProgressBarSetColor(ProgressBar progressBar, Color color, bool isForeColor) { const int WM_USER = 1024; //&H400 const int CCM_FIRST = 8192; //&H2000&; const int CCM_SETBKCOLOR = (CCM_FIRST + 1); const int PBM_SETBKCOLOR = CCM_SETBKCOLOR; const int PBM_SETBARCOLOR = (WM_USER + 9); if( isForeColor == true) { SendMessage(progressBar.Handle , PBM_SETBARCOLOR, 0, ColorTranslator.ToWin32(color)); } else { SendMessage(progressBar.Handle, PBM_SETBKCOLOR, 0, ColorTranslator.ToWin32(color)); } } #endreg
Terms and Conditions
Support this site
Download a trial version of the best FTP application on the internet