大悟还俗

邮箱 key_ok@qq.com 我的收集 http://pan.baidu.com/share/home?uk=1177427271
posts - 236, comments - 8, trackbacks - 0, articles - 0
  新随笔  :: 联系 :: 订阅 订阅  :: 管理

RichEdit文字背景色的处理

Posted on 2013-10-09 17:43 大悟还俗 阅读(...) 评论(...) 编辑 收藏
uses RichEdit;

procedure RichEditSetBackColor( // 设置RichEdit文字背景色   mRichEdit: TRichEdit; // Rich编辑框   mBackColor: TColor // 背景色 ); 

var   vCharFormat2: TCharFormat2;
 begin  
 if not Assigned(mRichEdit) then Exit;  
 FillChar(vCharFormat2, SizeOf(vCharFormat2), 0);   vCharFormat2.cbSize := SizeOf(vCharFormat2);   vCharFormat2.dwMask := CFM_BACKCOLOR;   vCharFormat2.crBackColor := mBackColor;   mRichEdit.Perform(EM_SETCHARFORMAT, SCF_SELECTION, Longint(@vCharFormat2)); 
end; { RichEditSetBackColor }

function RichEditGetBackColor( // 获得RichEdit文字背景色   mRichEdit: TRichEdit // Rich编辑框 ): TColor;
 var   vCharFormat2: TCharFormat2; 
begin  
 Result := clNone;  
 if not Assigned(mRichEdit) then Exit;  
 FillChar(vCharFormat2, SizeOf(vCharFormat2), 0);   vCharFormat2.cbSize := SizeOf(vCharFormat2);   vCharFormat2.dwMask := CFM_BACKCOLOR;   mRichEdit.Perform(EM_GETCHARFORMAT, SCF_SELECTION, Longint(@vCharFormat2));  
 Result := vCharFormat2.crBackColor;
 end; { RichEditGetBackColor }
View Code