Click here to Skip to main content
15,894,955 members
Home / Discussions / C#
   

C#

 
GeneralRe: Java vs .NET - Open Source Pin
DaveyM6916-Mar-09 5:41
professionalDaveyM6916-Mar-09 5:41 
GeneralRe: Java vs .NET - Open Source Pin
dataminers16-Mar-09 5:59
dataminers16-Mar-09 5:59 
GeneralRe: Java vs .NET - Open Source Pin
Eddy Vluggen16-Mar-09 6:10
professionalEddy Vluggen16-Mar-09 6:10 
GeneralRe: Java vs .NET - Open Source Pin
DaveyM6916-Mar-09 11:00
professionalDaveyM6916-Mar-09 11:00 
AnswerRe: Java vs .NET - Open Source Pin
led mike16-Mar-09 5:50
led mike16-Mar-09 5:50 
GeneralRe: Java vs .NET - Open Source Pin
Pete O'Hanlon16-Mar-09 5:59
mvePete O'Hanlon16-Mar-09 5:59 
GeneralRe: Java vs .NET - Open Source Pin
led mike16-Mar-09 6:39
led mike16-Mar-09 6:39 
GeneralRe: Java vs .NET - Open Source Pin
dataminers16-Mar-09 6:02
dataminers16-Mar-09 6:02 
GeneralRe: Java vs .NET - Open Source Pin
Pete O'Hanlon16-Mar-09 6:10
mvePete O'Hanlon16-Mar-09 6:10 
AnswerRe: Java vs .NET - Open Source Pin
Mohammad Dayyan16-Mar-09 9:48
Mohammad Dayyan16-Mar-09 9:48 
QuestionDisplaying multiple images in a picturebox crashes after the first one Pin
Sam Shiell16-Mar-09 3:34
Sam Shiell16-Mar-09 3:34 
AnswerRe: Displaying multiple images in a picturebox crashes after the first one Pin
Dave Kreskowiak16-Mar-09 6:04
mveDave Kreskowiak16-Mar-09 6:04 
AnswerRe: Displaying multiple images in a picturebox crashes after the first one Pin
Sam Shiell17-Mar-09 23:30
Sam Shiell17-Mar-09 23:30 
Questionsmall start up application... Pin
geoNeo_16-Mar-09 3:11
geoNeo_16-Mar-09 3:11 
AnswerRe: small start up application... Pin
musefan16-Mar-09 3:26
musefan16-Mar-09 3:26 
GeneralRe: small start up application... Pin
geoNeo_16-Mar-09 3:33
geoNeo_16-Mar-09 3:33 
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 

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.