Beispiel #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  = Win32.GetWindowLong(this._win.Handle, Win32.GWL_STYLE);
                bool hsVisible = (wndStyle & Win32.WS_HSCROLL) != 0;
                bool vsVisible = (wndStyle & Win32.WS_VSCROLL) != 0;

                //horizontal
                if (hsVisible)
                {
                    this.si2.fMask  = (int)Win32.ScrollInfoMask.SIF_ALL;
                    this.si2.cbSize = Marshal.SizeOf(this.si2);
                    Win32.GetScrollInfo(this._win.Handle, (int)Win32.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;

                    Win32.ScrollInfo si = new Win32.ScrollInfo();
                    si.cbSize = Marshal.SizeOf(si);
                    si.fMask  = (int)Win32.ScrollInfoMask.SIF_ALL;
                    if (Win32.GetScrollInfo(listView1.Handle, (int)Win32.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)))
                {
                    Win32.SendMessage(_win.Handle, Win32.WM_HSCROLL, (IntPtr)Win32.SB_TOP, IntPtr.Zero);
                    _win.Invalidate();
                }
            }
            base.WndProc(ref m);
        }
Beispiel #2
0
        protected static ScrollBars GetVisibleScrollbars(Control ctl)
        {
            int  wndStyle  = Win32.GetWindowLong(ctl.Handle, Win32.GWL_STYLE);
            bool hsVisible = (wndStyle & Win32.WS_HSCROLL) != 0;
            bool vsVisible = (wndStyle & Win32.WS_VSCROLL) != 0;

            if (hsVisible)
            {
                return(vsVisible ? ScrollBars.Both : ScrollBars.Horizontal);
            }
            else
            {
                return(vsVisible ? ScrollBars.Vertical : ScrollBars.None);
            }
        }
Beispiel #3
0
        public void SetDGVScrollBarValue(ref DataGridView dgv, ref HScrollBar HSB)
        {
            int listStyle = Win32.GetWindowLong(dgv.Handle, Win32.GWL_STYLE);

            //listStyle |= Win32.WS_VSCROLL | Win32.WS_HSCROLL;
            listStyle |= Win32.WS_HSCROLL;
            listStyle  = Win32.SetWindowLong(dgv.Handle, Win32.GWL_STYLE, listStyle);

            HScrollBar1.Value       = HSB.Value;
            HScrollBar1.Visible     = true;
            HScrollBar1.LargeChange = HSB.LargeChange;
            HScrollBar1.Maximum     = HSB.Maximum;
            HScrollBar1.Minimum     = HSB.Minimum;
            HScrollBar1.SmallChange = HSB.SmallChange;
            HScrollBar1.Update();//.SyncThumbPositionWithLogicalValue();
            //Invalidate();
        }
Beispiel #4
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  = Win32.GetWindowLong(this._win.Handle, Win32.GWL_STYLE);
                bool hsVisible = (wndStyle & Win32.WS_HSCROLL) != 0;
                bool vsVisible = (wndStyle & Win32.WS_VSCROLL) != 0;

                //debug
                //Console.WriteLine("Visible ScrollBars: " + GetVisibleScrollbars(_win));
                //ShowScrollBar(this._win.Handle, (int)ScrollBarDirection.SB_HORZ, false /*false*/);


                //vertical
                if (true)// (vsVisible || hsVisible)
                {
                    int  iWParam = (int)m.WParam;
                    int  iLParam = (int)m.LParam;
                    uint sbCode  = Win32.LoWord(m.WParam);

                    if (sbCode == Win32.SB_THUMBTRACK || sbCode == Win32.SB_THUMBPOSITION)
                    {
                        Win32.ScrollInfo siv = new Win32.ScrollInfo();
                        siv.cbSize = Marshal.SizeOf(siv);
                        siv.fMask  = (int)Win32.ScrollInfoMask.SIF_ALL;
                        Win32.ScrollInfo sih = siv;

                        uint nPos = Win32.HiWord(m.WParam);


                        Win32.GetScrollInfo(this._win.Handle, (int)Win32.ScrollBarDirection.SB_VERT, ref siv);
                        Win32.GetScrollInfo(this._win.Handle, (int)Win32.ScrollBarDirection.SB_HORZ, ref sih);

                        if ((sih.nMax + 0) <= sih.nPage)
                        {
                            this.HScrollBar1.Visible = false;
                        }
                        else
                        {
                            this.HScrollBar1.Visible = true;
                            if (sih.nPage != 0)
                            {
                                this.HScrollBar1.Maximum     = (sih.nMax - sih.nPage) + 1;
                                this.HScrollBar1.Minimum     = sih.nMin;
                                this.HScrollBar1.Value       = sih.nPos;
                                this.HScrollBar1.LargeChange = (int)Math.Round((double)(((double)sih.nMax) / ((double)sih.nPage)));
                                this.HScrollBar1.SyncThumbPositionWithLogicalValue();
                            }
                        }

                        if (vsVisible)
                        {
                            if ((siv.nMax + 0) < siv.nPage)
                            {
                                this.VScrollBar1.Visible = false;
                            }
                            else
                            {
                                this.VScrollBar1.Visible = true;
                                if (siv.nPage != 0)
                                {
                                    this.VScrollBar1.Maximum     = (siv.nMax - siv.nPage) + 1;
                                    this.VScrollBar1.Minimum     = siv.nMin;
                                    this.VScrollBar1.Value       = siv.nPos;
                                    this.VScrollBar1.LargeChange = (int)Math.Round((double)(((double)siv.nMax) / ((double)siv.nPage)));
                                    this.VScrollBar1.SyncThumbPositionWithLogicalValue();
                                }
                            }
                        }
                    }
                }
            }
            base.WndProc(ref m);
        }