简体   繁体   English

如何设置TRichedit默认段落背景颜色

[英]How to set the TRichedit default paragraph background color

I try to set the TRichEdit control default paragraph bg color with this code: 我尝试使用以下代码设置TRichEdit控件的默认段落bg颜色:

//******************************************************************************
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! 但是SPF_SETDEFAULT常数的值未知!

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 . SPF_SETDEFAULT执行网络SPF_SETDEFAULT
  • This takes you to the documentation for EM_SETCHARFORMAT . 这将带您到EM_SETCHARFORMAT的文档。
  • That document lists Richedit.h as the required header. 该文档将Richedit.h列为必需的标头。
  • Locate Richedit.h in your copy of the Windows SDK and search for SPF_SETDEFAULT . 在Windows SDK副本中找到Richedit.h ,然后搜索SPF_SETDEFAULT
  • That search yields this: #define SPF_SETDEFAULT 0x0004 . 该搜索将得出以下结果: #define SPF_SETDEFAULT 0x0004
  • So in Delphi you define the constant like this: const SPF_SETDEFAULT = $0004 . 因此,在Delphi中,您可以这样定义常量: const SPF_SETDEFAULT = $0004

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM