当前位置: 动力学知识库 > 问答 > 编程问答 >

delphi - How to set the TRichedit default paragraph background color

问题描述:

I try to set the TRichEdit control default paragraph bg color with this code:

//******************************************************************************

class procedure TRichEditUtility.setBGColor( aRE_ : TTNTRichEdit; bgColor_ : cardinal; default_ : boolean = FALSE );

//******************************************************************************

var

cf: TCharFormat2;

begin

if ( aRE_ <> NIL ) then

begin

fillchar(cf, sizeof(cf), 0);

cf.cbSize := sizeof( cf );

cf.dwMask := CFM_BACKCOLOR;

cf.crBackColor := bgColor_;

if ( default_ ) then

aRE_.Perform( EM_SETCHARFORMAT, SPF_SETDEFAULT, lparam(@cf) )

else

aRE_.Perform( EM_SETCHARFORMAT, SCF_SELECTION, lparam(@cf) );

end else

raise EInvalidInputParameter.create_string( 'TRichEditUtility', 'setBGColor', 'aRE_', CONST_chars_NIL );

end;

But the value of the SPF_SETDEFAULT constant is unknown!

Can somebody tell me its value? (Or the file name which define its value)

网友答案:

Here is how to resolve this issue, and any issue of this nature.

  • Perform a websearch for SPF_SETDEFAULT.
  • This takes you to the documentation for EM_SETCHARFORMAT.
  • That document lists Richedit.h as the required header.
  • Locate Richedit.h in your copy of the Windows SDK and search for SPF_SETDEFAULT.
  • That search yields this: #define SPF_SETDEFAULT 0x0004.
  • So in Delphi you define the constant like this: const SPF_SETDEFAULT = $0004.
分享给朋友:
您可能感兴趣的文章:
随机阅读: