#pas procedure THIRichEdit._work_doFormat; var Text:string; p:byte; oldColor, oldStart, oldEnd: integer; oldBold,oldItalic,oldUnderline:Boolean; begin if (Control.SelLength <> 0) then {no valid selection -> quit} begin Control.RE_CharFmtArea := raSelection; {apply attribute(s) only to selection} oldColor := Control.RE_FmtFontColor; oldBold := Control.RE_FmtBold; oldItalic := Control.RE_FmtItalic; oldUnderline := Control.RE_FmtUnderline; oldStart := Control.SelStart; oldEnd := Control.SelStart+Control.SelLength-1; Control.RE_FmtFontColor := ReadInteger(_Data,_data_Color,0); p := ReadInteger(_Data,_data_Style,0); Control.RE_FmtBold := p and 1 > 0; Control.RE_FmtItalic := p and 2 > 0; Control.RE_FmtUnderline := p and 4 > 0; Control.SelStart := -1; Control.RE_FmtFontColor := oldColor; Control.RE_FmtBold := oldBold; Control.RE_FmtItalic := oldItalic; Control.RE_FmtUnderline := oldUnderline; Control.SelLength:=0; end; end;