Beispiel #1
0
        private void HScrollBar1_miScroll(object sender, ScrollEventArgs e)
        {
            if (_win.GetType() == typeof(System.Windows.Forms.ListView) || (_win.GetType() == typeof(KryptonListView)))
            {
                ListView listView1 = (ListView)_win;

                int nIsAt       = Win32.GetScrollPos(listView1.Handle, Win32.SB_HORZ);
                int nShouldBeAt = (int)e.NewValue;

                int pixelsToScroll = Convert.ToInt32((nShouldBeAt - nIsAt));

                Win32.SendMessage(listView1.Handle, (int)Win32.LVM_SCROLL, pixelsToScroll, 0);

                Invalidate();
            }
            else
            {
                if (_win.GetType() == typeof(KryptonGrid) || _win.GetType() == typeof(System.Windows.Forms.DataGridView) || (_win.GetType() == typeof(KryptonDataGridView)))
                {
                    DataGridView dgv = (DataGridView)_win;
                    if (GetDGHScrollbar(ref dgv, out HSC))
                    {
                        foreach (Control control in dgv.Controls)
                        {
                            if (control is HScrollBar)
                            {
                                HScrollBar hscroll = (HScrollBar)control;
                                if (hscroll.Visible)
                                {
                                    switch (e.Type)
                                    {
                                    case ScrollEventType.ThumbTrack:
                                        if (e.NewValue >= e.OldValue)
                                        {
                                            Win32.SendMessage(_win.Handle, Win32.WM_HSCROLL, (IntPtr)Win32.SB_LINEDOWN, HSC.Handle);
                                        }
                                        else
                                        {
                                            Win32.SendMessage(_win.Handle, Win32.WM_HSCROLL, (IntPtr)Win32.SB_LINEUP, HSC.Handle);
                                        }

                                        Win32.SendMessage(_win.Handle, Win32.WM_HSCROLL, (IntPtr)Win32.SB_THUMBTRACK, HSC.Handle);
                                        break;

                                    default:
                                        Win32.SendMessage(_win.Handle, Win32.WM_HSCROLL, (IntPtr)e.Type, HSC.Handle);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        this.HScrollBar1.Visible = false;
                    }
                }
                else
                {
                    if (_win.GetType() == typeof(System.Windows.Forms.TreeView) || (_win.GetType() == typeof(KryptonTreeView)))
                    {
                        switch (e.Type)
                        {
                        case ScrollEventType.ThumbTrack:
                            if (e.NewValue >= e.OldValue)
                            {
                                Win32.SendMessage(_win.Handle, Win32.WM_HSCROLL, (IntPtr)Win32.SB_LINEDOWN, IntPtr.Zero);
                            }
                            else
                            {
                                Win32.SendMessage(_win.Handle, Win32.WM_HSCROLL, (IntPtr)Win32.SB_LINEUP, IntPtr.Zero);
                            }

                            Win32.SendMessage(_win.Handle, Win32.WM_HSCROLL, (IntPtr)Win32.SB_THUMBTRACK, IntPtr.Zero);
                            break;

                        default:
                            Win32.SendMessage(_win.Handle, Win32.WM_HSCROLL, (IntPtr)e.Type, IntPtr.Zero);
                            break;
                        }
                    }
                    else
                    {
                        Win32.PostMessageA(this._win.Handle, Win32.WM_HSCROLL, Win32.SB_THUMBPOSITION + (0x10000 * this.HScrollBar1.Value), 0);
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Comming from the customControl
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks></remarks>
        private void VScrollBar1_miScroll(object sender, ScrollEventArgs e)
        {
            if (_win.GetType() == typeof(System.Windows.Forms.ListView) || (_win.GetType() == typeof(KryptonListView)))
            {
                ListView listView1 = (ListView)_win;

                IntPtr min = IntPtr.Zero;
                IntPtr max = IntPtr.Zero;
                Win32.GetScrollRange(listView1.Handle, Win32.SB_VERT, ref min, ref max);

                int nMax = max.ToInt32();
                nMax += 3;

                int nHeight        = listView1.DisplayRectangle.Height;
                int ItemRectHeight = listView1.GetItemRect(0).Height;

                int nTimes           = (nHeight - 17) / ItemRectHeight;
                int nScrollPositions = (nMax - nTimes) + 1;

                double nThePos = VScrollBar1.Maximum / nScrollPositions;

                double RealPos = 0.0;
                if (nThePos <= 0.0)
                {
                    RealPos = VScrollBar1.Value;
                }
                else
                {
                    RealPos = VScrollBar1.Value / nThePos;
                }

                int nPos = Win32.GetScrollPos(listView1.Handle, Win32.SB_VERT);

                double nShouldBeAt = RealPos * ItemRectHeight;
                double nIsAt       = nPos * ItemRectHeight;

                int pixelsToScroll = Convert.ToInt32((nShouldBeAt - nIsAt));

                Win32.SendMessage(listView1.Handle, Win32.LVM_SCROLL, IntPtr.Zero, (IntPtr)pixelsToScroll);

                Invalidate();
            }
            else
            {
                if (_win.GetType() == typeof(KryptonGrid) || _win.GetType() == typeof(System.Windows.Forms.DataGridView) || (_win.GetType() == typeof(KryptonDataGridView)))
                {
                    DataGridView dgv = (DataGridView)_win;
                    if (GetDGVScrollbar(ref dgv, out VSB))
                    {
                        foreach (Control control in dgv.Controls)
                        {
                            if (control is VScrollBar)
                            {
                                VScrollBar vscroll = (VScrollBar)control;
                                if (vscroll.Visible)
                                {
                                    switch (e.Type)
                                    {
                                    case ScrollEventType.ThumbTrack:
                                        if (e.NewValue >= e.OldValue)
                                        {
                                            Win32.SendMessage(_win.Handle, Win32.WM_VSCROLL, (IntPtr)Win32.SB_LINEDOWN, VSB.Handle);
                                        }
                                        else
                                        {
                                            Win32.SendMessage(_win.Handle, Win32.WM_VSCROLL, (IntPtr)Win32.SB_LINEUP, VSB.Handle);
                                        }

                                        Win32.SendMessage(_win.Handle, Win32.WM_VSCROLL, (IntPtr)Win32.SB_THUMBTRACK, VSB.Handle);
                                        break;

                                    default:
                                        Win32.SendMessage(_win.Handle, Win32.WM_VSCROLL, (IntPtr)e.Type, VSB.Handle);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        this.VScrollBar1.Visible = false;
                    }
                }
                else
                {
                    if (_win.GetType() == typeof(System.Windows.Forms.TreeView) || (_win.GetType() == typeof(KryptonTreeView)))
                    {
                        switch (e.Type)
                        {
                        case ScrollEventType.ThumbTrack:
                            if (e.NewValue >= e.OldValue)
                            {
                                Win32.SendMessage(_win.Handle, Win32.WM_VSCROLL, (IntPtr)Win32.SB_LINEDOWN, IntPtr.Zero);
                            }
                            else
                            {
                                Win32.SendMessage(_win.Handle, Win32.WM_VSCROLL, (IntPtr)Win32.SB_LINEUP, IntPtr.Zero);
                            }

                            Win32.SendMessage(_win.Handle, Win32.WM_VSCROLL, (IntPtr)Win32.SB_THUMBTRACK, IntPtr.Zero);
                            break;

                        default:
                            Win32.SendMessage(_win.Handle, Win32.WM_VSCROLL, (IntPtr)e.Type, IntPtr.Zero);
                            break;
                        }
                    }
                    else
                    {
                        Win32.PostMessageA(this._win.Handle, Win32.WM_VSCROLL, Win32.SB_THUMBPOSITION + (0x10000 * this.VScrollBar1.Value), 0);
                    }
                }
            }
        }