0

I would like to disable WinForms ProgressBar animation. I found a good solution by SLaks for that here:

// Assuming a Form1 with 3 ProgressBar controls
private void Form1_Load(object sender, EventArgs e)
{
  SendMessage(progressBar2.Handle,
  0x400 + 16, //WM_USER + PBM_SETSTATE
  0x0003, //PBST_PAUSED
  0);

 SendMessage(progressBar3.Handle,
   0x400 + 16, //WM_USER + PBM_SETSTATE
   0x0002, //PBST_ERROR
   0);
}

[DllImport("user32.dll", CharSet = CharSet.Unicode)]
static extern uint SendMessage(IntPtr hWnd,
  uint Msg,
  uint wParam,
  uint lParam);

But this code changes the green color to a very ugly yellow or red. How can I keep the original green color?

stuartd
  • 70,509
  • 14
  • 132
  • 163
Bereg Isztria
  • 11
  • 1
  • 2
  • 4
    It cannot be disabled. You'll have to make your own control. There is a decent example in the MSDN article for ProgressBarRenderer. A bit over the top, perhaps, you don't care about the chunks. – Hans Passant Jun 12 '17 at 16:27
  • Thank you :-) It seems there is no easy way to solve this, and I will prepare my own control. – Bereg Isztria Jun 13 '17 at 08:52

0 Answers0