/// <summary> /// Resets back color of specified text part to original. Doesn't return cursor to original position! /// </summary> /// <param name="startIndex">First character.</param> /// <param name="length">Text length.</param> public void ResetBackColor(int startIndex, int length) { SelectionStart = startIndex; SelectionLength = length; Native.CharFormat2 format = new Native.CharFormat2(); format.cbSize = Marshal.SizeOf(format); format.dwMask = Native.CFM_BACKCOLOR; format.dwEffects = Native.CFE_AUTOBACKCOLOR; Native.SendMessage(Handle, Native.EM_SETCHARFORMAT, Native.SCF_SELECTION, ref format); }
/// <summary> /// Resets both fore and back color of specified text part to original. Doesn't return cursor to original position! /// </summary> /// <param name="startIndex">First character.</param> /// <param name="length">Text length.</param> public void ResetColors(int startIndex, int length) { SelectionStart = startIndex; SelectionLength = length; Native.CharFormat2 format = new Native.CharFormat2(); format.cbSize = Marshal.SizeOf(format); format.dwMask = Native.CFM_BACKCOLOR | Native.CFM_COLOR; format.dwEffects = Native.CFE_AUTOBACKCOLOR | Native.CFE_AUTOCOLOR; Native.SendMessage(Handle, Native.EM_SETCHARFORMAT, Native.SCF_SELECTION, ref format); }
/// <summary> /// Sets back color of specified text part. Doesn't return cursor to original position! /// </summary> /// <param name="startIndex">First colored character.</param> /// <param name="length">Colored text length.</param> /// <param name="color">New text color.</param> public void SetBackColor(int startIndex, int length, System.Drawing.Color color) { SelectionStart = startIndex; SelectionLength = length; Native.CharFormat2 format = new Native.CharFormat2(); format.cbSize = Marshal.SizeOf(format); format.dwMask = Native.CFM_BACKCOLOR; format.crTextColor = ColorTranslator.ToOle(color); Native.SendMessage(Handle, Native.EM_SETCHARFORMAT, Native.SCF_SELECTION, ref format); }
/// <summary> /// Sets color of specified text part. Doesn't return cursor to original position! /// </summary> /// <param name="startIndex">First colored character.</param> /// <param name="length">Colored text length.</param> /// <param name="color">New text color.</param> public void SetColor(int startIndex, int length, System.Drawing.Color color) { SelectionStart = startIndex; SelectionLength = length; Native.CharFormat2 format = new Native.CharFormat2(); format.cbSize = Marshal.SizeOf(format); format.dwMask = Native.CFM_COLOR; format.crTextColor = ColorTranslator.ToOle(color); Native.SendMessage(Handle, Native.EM_SETCHARFORMAT, Native.SCF_SELECTION, ref format); }