26 lines
901 B
C#
26 lines
901 B
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using System.Windows.Forms;
|
|
|
|
namespace JD.WinFormExtensions
|
|
{
|
|
public static class ProgressBarExtensions
|
|
{
|
|
const int WM_USER = 0x400;
|
|
const int PBM_SETSTATE = WM_USER + 16;
|
|
const int PBM_GETSTATE = WM_USER + 17;
|
|
|
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
|
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
|
|
|
|
public static ProgressBarState GetState(this ProgressBar progressBar)
|
|
{
|
|
return (ProgressBarState)SendMessage(progressBar.Handle, PBM_GETSTATE, IntPtr.Zero, IntPtr.Zero).ToInt64();
|
|
}
|
|
|
|
public static void SetState(this ProgressBar progressBar, ProgressBarState state)
|
|
{
|
|
SendMessage(progressBar.Handle, PBM_SETSTATE, (IntPtr)state, IntPtr.Zero);
|
|
}
|
|
}
|
|
}
|