Click here to Skip to main content
15,887,083 members
Home / Discussions / C#
   

C#

 
QuestionColoring ProgressBar Pin
eyalbi00716-Mar-09 3:01
eyalbi00716-Mar-09 3:01 
AnswerRe: Coloring ProgressBar Pin
harold aptroot16-Mar-09 3:11
harold aptroot16-Mar-09 3:11 
GeneralRe: Coloring ProgressBar Pin
musefan16-Mar-09 3:17
musefan16-Mar-09 3:17 
GeneralRe: Coloring ProgressBar Pin
eyalbi00716-Mar-09 3:35
eyalbi00716-Mar-09 3:35 
GeneralRe: Coloring ProgressBar Pin
harold aptroot16-Mar-09 3:40
harold aptroot16-Mar-09 3:40 
GeneralRe: Coloring ProgressBar Pin
eyalbi00716-Mar-09 3:55
eyalbi00716-Mar-09 3:55 
GeneralRe: Coloring ProgressBar Pin
harold aptroot16-Mar-09 3:57
harold aptroot16-Mar-09 3:57 
GeneralRe: Coloring ProgressBar Pin
eyalbi00716-Mar-09 4:48
eyalbi00716-Mar-09 4:48 
Here's the code (that indeed does nothing).

What I was hopint it'll do is paint the prorgesss bar in different color than green (the Windows default color), by pressing button2. button1 simply advances the bar.

[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);

public const Int32 PBM_SETBKCOLOR = 0x2001;
public const Int32 PBM_SETBARCOLOR = 0x0409;

public void SetProgressBackColor(Color c)
{/// set the back color of the bar
    int a = c.R;
    int b = c.G;
    int d = c.B;
    int tot = ColorTranslator.ToOle(Color.FromArgb(a, b, d));
    IntPtr j = this.progressBar1.Handle;
    SendMessage(j, PBM_SETBKCOLOR, 0, tot);
}

public void SetProgressForeColor(Color c)
{/// set the forecolor of the bar
    int a = c.R;
    int b = c.G;
    int d = c.B;
    int tot = ColorTranslator.ToOle(Color.FromArgb(a, b, d));
    IntPtr j = this.progressBar1.Handle;
    SendMessage(j, PBM_SETBKCOLOR, 0, tot);
}

private void button1_Click(object sender, 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();
    }
}

private void button2_Click(object sender, EventArgs e)
{
    SetProgressBackColor(System.Drawing.Color.BlueViolet);
    SetProgressForeColor(System.Drawing.Color.Red);
}

GeneralRe: Coloring ProgressBar Pin
harold aptroot16-Mar-09 4:53
harold aptroot16-Mar-09 4:53 
AnswerRe: Coloring ProgressBar Pin
musefan16-Mar-09 3:12
musefan16-Mar-09 3:12 
Answeris not working Pin
Luc Pattyn16-Mar-09 4:19
sitebuilderLuc Pattyn16-Mar-09 4:19 
QuestionAssign Color to text in Rich Textbox Pin
Sajjad Leo16-Mar-09 1:58
Sajjad Leo16-Mar-09 1:58 
AnswerRe: Assign Color to text in Rich Textbox Pin
Blue_Boy16-Mar-09 2:08
Blue_Boy16-Mar-09 2:08 
AnswerRe: Assign Color to text in Rich Textbox Pin
AB777116-Mar-09 2:10
AB777116-Mar-09 2:10 
Questionhow to Merge two datatables in a dataset Pin
Nitin K16-Mar-09 1:40
Nitin K16-Mar-09 1:40 
AnswerRe: how to Merge two datatables in a dataset Pin
Russell Jones16-Mar-09 1:42
Russell Jones16-Mar-09 1:42 
GeneralRe: how to Merge two datatables in a dataset Pin
Nitin K16-Mar-09 1:51
Nitin K16-Mar-09 1:51 
GeneralRe: how to Merge two datatables in a dataset Pin
Russell Jones16-Mar-09 1:56
Russell Jones16-Mar-09 1:56 
QuestionAny idea why this error appears (SEH Exception) Pin
Matjaz-xyz16-Mar-09 1:31
Matjaz-xyz16-Mar-09 1:31 
AnswerRe: Any idea why this error appears (SEH Exception) Pin
Michael Bookatz16-Mar-09 1:38
Michael Bookatz16-Mar-09 1:38 
AnswerRe: Any idea why this error appears (SEH Exception) Pin
Giorgi Dalakishvili16-Mar-09 2:29
mentorGiorgi Dalakishvili16-Mar-09 2:29 
GeneralRe: Any idea why this error appears (SEH Exception) Pin
Matjaz-xyz17-Mar-09 3:35
Matjaz-xyz17-Mar-09 3:35 
QuestionApplication.Idle Event Pin
saksp16-Mar-09 0:02
saksp16-Mar-09 0:02 
AnswerRe: Application.Idle Event Pin
DaveyM6916-Mar-09 0:20
professionalDaveyM6916-Mar-09 0:20 
AnswerRe: Application.Idle Event Pin
#realJSOP16-Mar-09 2:34
mve#realJSOP16-Mar-09 2:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.