protected override void WndProc(ref Message m)
        {
            try
            {
                switch (m.Msg)
                {
                    case WM.WM_PAINT:
                        if (!_bPainting)
                        {
                            PAINTSTRUCT ps = new PAINTSTRUCT();

                            _bPainting = true;
                            NativeMethods.BeginPaint(m.HWnd, ref ps);
                            DrawScrollBar(m.HWnd, _maskControl.Handle);
                            NativeMethods.ValidateRect(m.HWnd, ref ps.rcPaint);
                            NativeMethods.EndPaint(m.HWnd, ref ps);
                            _bPainting = false;

                            m.Result = Result.TRUE;
                        }
                        else
                        {
                            base.WndProc(ref m);
                        }
                        break;
                    case SBM.SBM_SETSCROLLINFO:
                        DrawScrollBar(m.HWnd, _maskControl.Handle, true, false);
                        base.WndProc(ref m);
                        break;
                    case WM.WM_STYLECHANGED:
                        DrawScrollBar(m.HWnd, _maskControl.Handle, false, true);
                        base.WndProc(ref m);
                        break;
                    case WM.WM_LBUTTONDOWN:
                        _lastMouseDownHistTest = ScrollBarHitTest(m.HWnd);
                        DrawScrollBar(m.HWnd, _maskControl.Handle);
                        base.WndProc(ref m);
                        break;
                    case WM.WM_LBUTTONUP:
                    case WM.WM_MOUSEMOVE:
                        DrawScrollBar(m.HWnd, _maskControl.Handle);
                        base.WndProc(ref m);
                        break;
                    case WM.WM_MOUSELEAVE:
                        DrawScrollBar(m.HWnd, _maskControl.Handle);
                        base.WndProc(ref m);
                        break;
                    case WM.WM_WINDOWPOSCHANGED:
                        WINDOWPOS pos = (WINDOWPOS)Marshal.PtrToStructure(
                            m.LParam, typeof(WINDOWPOS));
                        bool hide = (pos.flags & SWP.SWP_HIDEWINDOW) != 0;
                        bool show = (pos.flags & SWP.SWP_SHOWWINDOW) != 0;
                        if (hide)
                        {
                            _maskControl.SetVisibale(false);
                        }
                        else if (show)
                        {
                            _maskControl.SetVisibale(true);
                        }
                        _maskControl.CheckBounds(m.HWnd);
                        base.WndProc(ref m);
                        break;
                    default:
                        base.WndProc(ref m);
                        break;
                }
            }
            catch
            {
            }
        }
 public static extern IntPtr BeginPaint(
     IntPtr hWnd, ref PAINTSTRUCT ps);
 public static extern bool EndPaint(
     IntPtr hWnd, ref PAINTSTRUCT ps);
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case WM.WM_PAINT:
                    if (!_bPainting)
                    {
                        _bPainting = true;

                        PAINTSTRUCT ps = new PAINTSTRUCT();

                        NativeMethods.BeginPaint(m.HWnd, ref ps);

                        try
                        {
                            DrawProgressBar(m.HWnd);
                        }
                        catch
                        {
                        }

                        NativeMethods.ValidateRect(m.HWnd, ref ps.rcPaint);
                        NativeMethods.EndPaint(m.HWnd, ref ps);

                        _bPainting = false;
                        m.Result = Result.TRUE;
                    }
                    else
                    {
                        base.WndProc(ref m);
                    }
                    break;
                default:
                    base.WndProc(ref m);
                    break;
            }
        }