/// <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); }
/// <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 = WIN32.GetWindowLong(_win.Handle, WIN32.GWL_STYLE); //listStyle |= WIN32.WS_VSCROLL | WIN32.WS_HSCROLL; //listStyle |= WIN32.WS_VSCROLL; //listStyle |= WIN32.WS_HSCROLL; //listStyle = WIN32.SetWindowLong(_win.Handle, WIN32.GWL_STYLE, listStyle); int wndStyle = WIN32.GetWindowLong(_win.Handle, WIN32.GWL_STYLE); bool hsVisible = (wndStyle & WIN32.WS_HSCROLL) != 0; bool vsVisible = (wndStyle & WIN32.WS_VSCROLL) != 0; //Vertical if (vsVisible) { si.fMask = (int)WIN32.ScrollInfoMask.SIF_ALL; si.cbSize = Marshal.SizeOf(si); WIN32.GetScrollInfo(_win.Handle, (int)WIN32.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)WIN32.ScrollInfoMask.SIF_ALL; si.cbSize = Marshal.SizeOf(si); WIN32.GetScrollInfo(_win.Handle, (int)WIN32.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; 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_VERT, ref si)) { VScrollBar1.LargeChange = si.nPage; VScrollBar1.Maximum = si.nMax; VScrollBar1.Minimum = si.nMin; VScrollBar1.SmallChange = 1; VScrollBar1.Update();//.SyncThumbPositionWithLogicalValue(); } 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; HScrollBar1.Update();//.SyncThumbPositionWithLogicalValue(); } } } 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 (!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); }