예제 #1
0
        protected override void WndProc(ref Message msg)
        {
            if (msg.Msg == Win32.WM_HSCROLL)
            {
                // Store the handle for use in Invalidate()
                _hScrollbarHandle = msg.HWnd;
                // Collect info about the position of the horizontal scrollbar
                Win32.ScrollInfo si = new Win32.ScrollInfo();
                si.fMask  = (int)Win32.ScrollInfoMask.SIF_ALL;
                si.cbSize = (uint)Marshal.SizeOf(si);
                Win32.GetScrollInfo(msg.HWnd, 0, ref si);

                if ((msg.WParam.ToInt32() & 0xFF) == Win32.SB_THUMBTRACK)
                {
                    // If the user is in the middle of dragging the scrollbar, we're interested in
                    // the 'track' position
                    _scrollLeft = si.nTrackPos;
                }
                else
                {
                    // Otherwise just the regular scrollbar position
                    _scrollLeft = si.nPos;
                }
                // Force repaint
                base.Invalidate();
            }

            if (!CancelWndProc(msg))
            {
                base.WndProc(ref msg);
            }
        }
예제 #2
0
        private int ScrollInfo(Win32.ScrollBarConstants fnBar)
        {
            Win32.ScrollInfo si = new Win32.ScrollInfo();
            si.cbSize = (uint)Marshal.SizeOf(si);
            si.fMask  = (int)Win32.ScrollInfoMask.SIF_POS;
            if (!Win32.GetScrollInfo(Handle, (int)fnBar, ref si))
            {
                return(0);
            }

            return(si.nPos);
        }
예제 #3
0
        protected override void WndProc(ref Message m)
        {
            int msg = m.Msg;

            if (msg != 256)
            {
                switch (msg)
                {
                case 276:
                case 277:
                    base.WndProc(ref m);
                    this.OnScroll();
                    return;

                default:
                    if (msg == 8270)
                    {
                        switch (((Win32.NMHDR)m.GetLParam(typeof(Win32.NMHDR))).code)
                        {
                        case -181:
                        case -180:
                            base.WndProc(ref m);
                            this.OnScroll();
                            return;

                        default:
                            base.WndProc(ref m);
                            return;
                        }
                    }
                    else
                    {
                        base.WndProc(ref m);
                    }
                    break;
                }
            }
            else
            {
                Win32.ScrollInfo scrollInfo = new Win32.ScrollInfo();
                scrollInfo.fMask = 31;
                Win32.GetScrollInfo(base.Handle, 1, scrollInfo);
                int nPos = scrollInfo.nPos;
                base.WndProc(ref m);
                Win32.GetScrollInfo(base.Handle, 1, scrollInfo);
                int nPos2 = scrollInfo.nPos;
                if (nPos != nPos2)
                {
                    this.OnScroll();
                    return;
                }
            }
        }
예제 #4
0
 public new void Invalidate()
 {
     if (_hScrollbarHandle != IntPtr.Zero)
     {
         // If we've been invalidated, update our drawing code to the new horizontal scrollbar
         // position (which is sometimes spontaneously reset to zero and can't be programmatically
         // set to its former value) - see CA-11405.
         Win32.ScrollInfo si = new Win32.ScrollInfo();
         si.fMask  = (int)Win32.ScrollInfoMask.SIF_ALL;
         si.cbSize = (uint)Marshal.SizeOf(si);
         Win32.GetScrollInfo(_hScrollbarHandle, 0, ref si);
         _scrollLeft = si.nTrackPos; // often zero
     }
     base.Invalidate();
 }
예제 #5
0
        protected override void WndProc(ref Message m)
        {
            int msg = m.Msg;
            if (msg != 256)
            {
                switch (msg)
                {
                case 276:
                case 277:
                    base.WndProc(ref m);
                    this.OnScroll();
                    return;

                default:
                    if (msg == 8270)
                    {
                        switch (((Win32.NMHDR)m.GetLParam(typeof(Win32.NMHDR))).code)
                        {
                        case -181:
                        case -180:
                            base.WndProc(ref m);
                            this.OnScroll();
                            return;

                        default:
                            base.WndProc(ref m);
                            return;
                        }
                    }
                    else
                    {
                        base.WndProc(ref m);
                    }
                    break;
                }
            }
            else
            {
                Win32.ScrollInfo scrollInfo = new Win32.ScrollInfo();
                scrollInfo.fMask = 31;
                Win32.GetScrollInfo(base.Handle, 1, scrollInfo);
                int nPos = scrollInfo.nPos;
                base.WndProc(ref m);
                Win32.GetScrollInfo(base.Handle, 1, scrollInfo);
                int nPos2 = scrollInfo.nPos;
                if (nPos != nPos2)
                {
                    this.OnScroll();
                    return;
                }
            }
        }