首页  编辑  

不同的下划线风格

Tags: /超级猛料/VCL/Memo&Edit&Richedit/RichEdit、RxRichEdit/   Date Created:

use different underline styles for Text in TRichEdit?

uses

 RichEdit;

// Underline styles

const

 CFU_UNDERLINETHICK = 9;

 CFU_UNDERLINEWAVE = 8;

 CFU_UNDERLINEDASHDOTDOT = 7;

 CFU_UNDERLINEDASHDOT = 6;

 CFU_UNDERLINEDASH = 5;

 CFU_UNDERLINEDOTTED = 4;

 CFU_UNDERLINE = 1;

 CFU_UNDERLINENONE = 0;

procedure RE_SetCharFormat(ARichEdit: TRichEdit; AUnderlineType: Byte; AColor: Word);

var

 // The CHARFORMAT2 structure contains information about

 // character formatting in a rich edit control.

 Format: CHARFORMAT2;

begin

 FillChar(Format, SizeOf(Format), 0);

 with Format do

 begin

   cbSize := SizeOf(Format);

   dwMask := CFM_UNDERLINETYPE;

   bUnderlineType := AUnderlineType or AColor;

   ARichEdit.Perform(EM_SETCHARFORMAT, SCF_SELECTION, Longint(@Format));

 end;

end;

// Underline the current selection with a CFU_UNDERLINEWAVE line style (color red);

procedure TForm1.Button1Click(Sender: TObject);

begin

 RE_SetCharFormat(RichEdit1, CFU_UNDERLINEWAVE, $50);

end;

img_10120.bmp (111.6KB)