private bool SetCharFormat(int mask, int effect, RichTextBoxSelectionAttribute charFormat) { if (!base.IsHandleCreated) { return false; } System.Windows.Forms.NativeMethods.CHARFORMATA lParam = new System.Windows.Forms.NativeMethods.CHARFORMATA { dwMask = mask }; switch (charFormat) { case RichTextBoxSelectionAttribute.None: lParam.dwEffects = 0; break; case RichTextBoxSelectionAttribute.All: lParam.dwEffects = effect; break; default: throw new ArgumentException(System.Windows.Forms.SR.GetString("UnknownAttr")); } return (IntPtr.Zero != System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, base.Handle), 0x444, 1, lParam)); }
/// <include file='doc\RichTextBox.uex' path='docs/doc[@for="RichTextBox.SetCharFormat"]/*' /> /// <devdoc> /// </devdoc> /// <internalonly/> private bool SetCharFormat(int mask, int effect, RichTextBoxSelectionAttribute charFormat) { // check to see if the control has been created if (IsHandleCreated) { NativeMethods.CHARFORMATA cf = new NativeMethods.CHARFORMATA(); cf.dwMask = mask; switch (charFormat) { case RichTextBoxSelectionAttribute.All: cf.dwEffects = effect; break; case RichTextBoxSelectionAttribute.None: cf.dwEffects = 0; break; default: throw new ArgumentException(SR.GetString(SR.UnknownAttr)); } // set the format information return IntPtr.Zero != UnsafeNativeMethods.SendMessage(new HandleRef(this, Handle), RichTextBoxConstants.EM_SETCHARFORMAT, RichTextBoxConstants.SCF_SELECTION, cf); } return false; }