RichEdit文字背景色的处理

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

 

你可能感兴趣的:(it)