Disable WinForms ProgressBar animation

后端 未结 6 1801
温柔的废话
温柔的废话 2020-12-03 22:03

Is there a possbility to disable animation of the progress bar?

I need it for some pocess which is paused and not running at the moment. An average user would think

6条回答
  •  长情又很酷
    2020-12-03 22:15

    You can use the Vista progress bar's paused state, like this:

    // 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);
    

提交回复
热议问题