Esempio n. 1
0
        /// <summary>
        /// Overrided to controll del scrolling of the customControl VScrollBar1
        /// </summary>
        /// <param name="m"></param>
        /// <remarks></remarks>
        protected override void WndProc(ref Message m)
        {
            if (!this.DesignMode && !(!this.Parent.CanFocus | (_win == null)))
            {
                int  wndStyle  = WIN32ScrollBars.GetWindowLong(this._win.Handle, WIN32ScrollBars.GWL_STYLE);
                bool hsVisible = (wndStyle & WIN32ScrollBars.WS_HSCROLL) != 0;
                bool vsVisible = (wndStyle & WIN32ScrollBars.WS_VSCROLL) != 0;

                //horizontal
                if (hsVisible)
                {
                    this.si2.fMask  = (int)WIN32ScrollBars.ScrollInfoMask.SIF_ALL;
                    this.si2.cbSize = Marshal.SizeOf(this.si2);
                    WIN32ScrollBars.GetScrollInfo(this._win.Handle, (int)WIN32ScrollBars.ScrollBarDirection.SB_HORZ, ref this.si2);

                    if ((this.si2.nMax + 0) <= this.si2.nPage)
                    {
                        this.HScrollBar1.Visible = false;
                    }
                    else
                    {
                        this.HScrollBar1.Visible = true;
                        if (this.si2.nPage != 0)
                        {
                            HScrollBar1.LargeChange = si2.nPage;
                            HScrollBar1.Maximum     = si2.nMax;
                            HScrollBar1.Minimum     = si2.nMin;
                            HScrollBar1.SmallChange = 1;
                            this.HScrollBar1.Update();//.SyncThumbPositionWithLogicalValue();
                        }
                    }
                }
                if (_win.GetType() == typeof(System.Windows.Forms.ListView) || (_win.GetType() == typeof(KryptonListView)))
                {
                    ListView listView1 = (ListView)_win;

                    WIN32ScrollBars.ScrollInfo si = new WIN32ScrollBars.ScrollInfo();
                    si.cbSize = Marshal.SizeOf(si);
                    si.fMask  = (int)WIN32ScrollBars.ScrollInfoMask.SIF_ALL;
                    if (WIN32ScrollBars.GetScrollInfo(listView1.Handle, (int)WIN32ScrollBars.ScrollBarDirection.SB_HORZ, ref si))
                    {
                        HScrollBar1.LargeChange = si.nPage;
                        HScrollBar1.Maximum     = si.nMax;
                        HScrollBar1.Minimum     = si.nMin;
                        HScrollBar1.SmallChange = 1;
                        this.HScrollBar1.Update();//.SyncThumbPositionWithLogicalValue();
                    }
                }
                if (_win.GetType() == typeof(KryptonGrid) || _win.GetType() == typeof(System.Windows.Forms.DataGridView) || (_win.GetType() == typeof(KryptonDataGridView)))
                {
                    WIN32ScrollBars.SendMessage(_win.Handle, WIN32ScrollBars.WM_HSCROLL, (IntPtr)WIN32ScrollBars.SB_TOP, IntPtr.Zero);
                    _win.Invalidate();
                }
            }
            base.WndProc(ref m);
        }
        /// <summary>
        /// Overrided to controll del scrolling of the customControl VScrollBar1
        /// </summary>
        /// <param name="m"></param>
        /// <remarks></remarks>
        protected override void WndProc(ref Message m)
        {
            if (!DesignMode && !(!Parent.CanFocus | (_win == null)))
            {
                //int listStyle = WIN32ScrollBars.GetWindowLong(_win.Handle, WIN32ScrollBars.GWL_STYLE);
                //listStyle |= WIN32ScrollBars.WS_VSCROLL | WIN32ScrollBars.WS_HSCROLL;
                //listStyle |= WIN32ScrollBars.WS_VSCROLL;
                //listStyle |= WIN32ScrollBars.WS_HSCROLL;
                //listStyle = WIN32ScrollBars.SetWindowLong(_win.Handle, WIN32ScrollBars.GWL_STYLE, listStyle);

                int  wndStyle  = WIN32ScrollBars.GetWindowLong(_win.Handle, WIN32ScrollBars.GWL_STYLE);
                bool hsVisible = (wndStyle & WIN32ScrollBars.WS_HSCROLL) != 0;
                bool vsVisible = (wndStyle & WIN32ScrollBars.WS_VSCROLL) != 0;

                //Vertical
                if (vsVisible)
                {
                    si.fMask  = (int)WIN32ScrollBars.ScrollInfoMask.SIF_ALL;
                    si.cbSize = Marshal.SizeOf(si);
                    WIN32ScrollBars.GetScrollInfo(_win.Handle, (int)WIN32ScrollBars.ScrollBarDirection.SB_VERT, ref si);

                    if ((si.nMax + 0) <= si.nPage)
                    {
                        VScrollBar1.Visible = false;
                    }
                    else
                    {
                        VScrollBar1.Visible = true;
                        if (si.nPage != 0)
                        {
                            VScrollBar1.LargeChange = si.nPage;
                            VScrollBar1.Maximum     = si.nMax;
                            VScrollBar1.Minimum     = si.nMin;
                            VScrollBar1.SmallChange = 1;
                            VScrollBar1.Update();//.SyncThumbPositionWithLogicalValue();
                        }
                    }
                }

                //horizontal
                if (hsVisible)
                {
                    si.fMask  = (int)WIN32ScrollBars.ScrollInfoMask.SIF_ALL;
                    si.cbSize = Marshal.SizeOf(si);
                    WIN32ScrollBars.GetScrollInfo(_win.Handle, (int)WIN32ScrollBars.ScrollBarDirection.SB_HORZ, ref si);

                    if ((si.nMax + 0) <= si.nPage)
                    {
                        HScrollBar1.Visible = false;
                    }
                    else
                    {
                        HScrollBar1.Visible = true;
                        if (si.nPage != 0)
                        {
                            HScrollBar1.LargeChange = si.nPage;
                            HScrollBar1.Maximum     = si.nMax;
                            HScrollBar1.Minimum     = si.nMin;
                            HScrollBar1.SmallChange = 1;
                            HScrollBar1.Update();//.SyncThumbPositionWithLogicalValue();
                        }
                    }
                }

                if (_win.GetType() == typeof(ListView) || (_win.GetType() == typeof(KryptonListView)))
                {
                    ListView listView1 = (ListView)_win;

                    WIN32ScrollBars.ScrollInfo si = new WIN32ScrollBars.ScrollInfo();
                    si.cbSize = Marshal.SizeOf(si);
                    si.fMask  = (int)WIN32ScrollBars.ScrollInfoMask.SIF_ALL;
                    if (WIN32ScrollBars.GetScrollInfo(listView1.Handle, (int)WIN32ScrollBars.ScrollBarDirection.SB_VERT, ref si))
                    {
                        VScrollBar1.LargeChange = si.nPage;
                        VScrollBar1.Maximum     = si.nMax;
                        VScrollBar1.Minimum     = si.nMin;
                        VScrollBar1.SmallChange = 1;
                        VScrollBar1.Update();//.SyncThumbPositionWithLogicalValue();
                    }


                    si        = new WIN32ScrollBars.ScrollInfo();
                    si.cbSize = Marshal.SizeOf(si);
                    si.fMask  = (int)WIN32ScrollBars.ScrollInfoMask.SIF_ALL;
                    if (WIN32ScrollBars.GetScrollInfo(listView1.Handle, (int)WIN32ScrollBars.ScrollBarDirection.SB_HORZ, ref si))
                    {
                        HScrollBar1.LargeChange = si.nPage;
                        HScrollBar1.Maximum     = si.nMax;
                        HScrollBar1.Minimum     = si.nMin;
                        HScrollBar1.SmallChange = 1;
                        HScrollBar1.Update();//.SyncThumbPositionWithLogicalValue();
                    }
                }
            }

            base.WndProc(ref m);
        }