private void rich_TextChanged(object sender, EventArgs e) { if (m_busy) { return; } m_busy = true; m_buffer.Text = m_active.Text; m_buffer.SelectAll(); m_buffer.SelectionColor = m_defaultColor; ControlEventArgs args = new ControlEventArgs(m_buffer); OnHighlight(args); m_buffer.SelectionStart = m_active.SelectionStart; m_buffer.SelectionLength = m_active.SelectionLength; Native.SCROLLINFO si = new Native.SCROLLINFO(); si.Size = (uint)Marshal.SizeOf(typeof(Native.SCROLLINFO)); si.Mask = Native.SIF_POS; Native.GetScrollInfo(m_active.Handle, (int)Native.SB_VERT, ref si); Native.SetScrollInfo(m_buffer.Handle, (int)Native.SB_VERT, ref si, true); uint wparam = ((uint)si.Pos << 16) + Native.SB_THUMBPOSITION; Native.SendMessage(m_buffer.Handle, Native.WM_VSCROLL, wparam, 0); Native.SendMessage(m_buffer.Handle, Native.WM_VSCROLL, Native.SB_ENDSCROLL, 0); m_busy = false; RichTextBox temp = m_active; m_active = m_buffer; m_buffer = temp; m_active.BringToFront(); m_active.Show(); m_buffer.Hide(); m_active.Focus(); }
private void rich_TextChanged(object sender, EventArgs e) { if (m_busy) return; m_busy = true; m_buffer.Text = m_active.Text; m_buffer.SelectAll(); m_buffer.SelectionColor = m_defaultColor; ControlEventArgs args = new ControlEventArgs(m_buffer); OnHighlight(args); m_buffer.SelectionStart = m_active.SelectionStart; m_buffer.SelectionLength = m_active.SelectionLength; Native.SCROLLINFO si = new Native.SCROLLINFO(); si.Size = (uint)Marshal.SizeOf(typeof(Native.SCROLLINFO)); si.Mask = Native.SIF_POS; Native.GetScrollInfo(m_active.Handle, (int)Native.SB_VERT, ref si); Native.SetScrollInfo(m_buffer.Handle, (int)Native.SB_VERT, ref si, true); uint wparam = ((uint)si.Pos << 16) + Native.SB_THUMBPOSITION; Native.SendMessage(m_buffer.Handle, Native.WM_VSCROLL, wparam, 0); Native.SendMessage(m_buffer.Handle, Native.WM_VSCROLL, Native.SB_ENDSCROLL, 0); m_busy = false; RichTextBox temp = m_active; m_active = m_buffer; m_buffer = temp; m_active.BringToFront(); m_active.Show(); m_buffer.Hide(); m_active.Focus(); }