0

我需要更改RichEditorViewer默认页面的字体颜色属性,但找不到控件名称或属性名称,我需要帮助...

RichEditorViewerInfoBeforePage我需要更改字体颜色):

设置屏幕截图

这是我正在使用的代码:

const
  Custom_Height = 570;
  Custom_ProgressBar_Height = 30;
  Page_Color = $7b2b68;
  Page_Color_Alternative1 = clblack;
  Page_Color_Alternative2 = clwhite;
  Font_Color = $fffbff;

var
  DefaultTop,
  DefaultLeft,
  DefaultHeight,
  DefaultBackTop,
  DefaultNextTop,
  DefaultCancelTop,
  DefaultBevelTop,
  DefaultOuterHeight: Integer;

procedure InitializeWizard();
begin

  DefaultTop := WizardForm.Top;
  DefaultLeft := WizardForm.Left;
  DefaultHeight := WizardForm.Height;
  DefaultBackTop := WizardForm.BackButton.Top;
  DefaultNextTop := WizardForm.NextButton.Top;
  DefaultCancelTop := WizardForm.CancelButton.Top;
  DefaultBevelTop := WizardForm.Bevel.Top;
  DefaultOuterHeight := WizardForm.OuterNotebook.Height;

  // Pages (Size)
  WizardForm.Height := Custom_Height;
  WizardForm.InnerPage.Height := WizardForm.InnerPage.Height + (Custom_Height - DefaultHeight);
  WizardForm.LicensePage.Height := WizardForm.LicensePage.Height + (Custom_Height - DefaultHeight);

  // Pages (Color)
  WizardForm.color := Page_Color_Alternative1;
  WizardForm.FinishedPage.Color  := Page_Color;
  WizardForm.InfoAfterPage.Color := Page_Color;
  WizardForm.InfoBeforePage.Color := Page_Color;
  WizardForm.InnerPage.Color := Page_Color;
  WizardForm.InstallingPage.color := Page_Color;
  WizardForm.LicensePage.Color := Page_Color;
  WizardForm.PasswordPage.color := Page_Color;
  WizardForm.PreparingPage.color := Page_Color;
  WizardForm.ReadyPage.Color := Page_Color;
  WizardForm.SelectComponentsPage.Color  := Page_Color;
  WizardForm.SelectDirPage.Color  := Page_Color;
  WizardForm.SelectProgramGroupPage.color := Page_Color;
  WizardForm.SelectTasksPage.color := Page_Color;
  WizardForm.UserInfoPage.color := Page_Color;
  WizardForm.WelcomePage.color := Page_Color;

  // Controls (Size)
  WizardForm.InfoAfterMemo.Height := (Custom_Height - (DefaultHeight / 2));
  WizardForm.InfoBeforeMemo.Height := (Custom_Height - (DefaultHeight / 2));
  WizardForm.InnerNotebook.Height :=  WizardForm.InnerNotebook.Height + (Custom_Height - DefaultHeight);
  WizardForm.LicenseMemo.Height := WizardForm.LicenseMemo.Height + (Custom_Height - DefaultHeight);
  WizardForm.OuterNotebook.Height := WizardForm.OuterNotebook.Height + (Custom_Height - DefaultHeight);
  WizardForm.ProgressGauge.Height := Custom_ProgressBar_Height
  WizardForm.ReadyMemo.Height := (Custom_Height - (DefaultHeight / 2));
  WizardForm.Taskslist.Height := (Custom_Height - (DefaultHeight / 2));
  WizardForm.WizardBitmapImage.Height := (Custom_Height - (DefaultHeight - DefaultBevelTop));
  WizardForm.WizardBitmapImage2.Height  := (Custom_Height - (DefaultHeight - DefaultBevelTop));

  // Controls (Location)
  WizardForm.BackButton.Top := DefaultBackTop + (Custom_Height - DefaultHeight);
  WizardForm.Bevel.Top := DefaultBevelTop + (Custom_Height - DefaultHeight);
  WizardForm.CancelButton.Top := DefaultCancelTop + (Custom_Height - DefaultHeight);
  WizardForm.LicenseAcceptedRadio.Top := WizardForm.LicenseAcceptedRadio.Top + (Custom_Height - DefaultHeight);
  WizardForm.LicenseNotAcceptedRadio.Top := WizardForm.LicenseNotAcceptedRadio.Top + (Custom_Height - DefaultHeight);
  WizardForm.NextButton.Top := DefaultNextTop + (Custom_Height - DefaultHeight);
  WizardForm.Top := DefaultTop - (Custom_Height - DefaultHeight) div 2;
  //WizardForm.ProgressGauge.Top := (DefaultHeight / 2)

  // Controls (Back Color)
  WizardForm.DirEdit.Color  := Page_Color_Alternative2;
  WizardForm.GroupEdit.Color  := Page_Color_Alternative2;
  WizardForm.InfoAfterMemo.Color := Page_Color_Alternative2;
  WizardForm.InfoBeforeMemo.Color := Page_Color_Alternative2;
  WizardForm.LicenseMemo.Color := Page_Color_Alternative2;
  WizardForm.MainPanel.Color := Page_Color;
  WizardForm.PasswordEdit.Color  := Page_Color_Alternative2;
  WizardForm.ReadyMemo.Color := Page_Color_Alternative2;
  WizardForm.Taskslist.Color := Page_Color;
  WizardForm.UserInfoNameEdit.Color  := Page_Color_Alternative2;
  WizardForm.UserInfoOrgEdit.Color  := Page_Color_Alternative2;
  WizardForm.UserInfoSerialEdit.Color  := Page_Color_Alternative2;

  // Controls (Font Color)
  WizardForm.FinishedHeadingLabel.font.color  := Font_Color;
  WizardForm.InfoafterMemo.font.Color  := Font_Color;
  WizardForm.FinishedLabel.font.color  := Font_Color;
  WizardForm.DirEdit.font.Color  := Page_Color_Alternative1;
  WizardForm.Font.color := Font_Color;
  WizardForm.GroupEdit.font.Color  := Page_Color_Alternative1;
  WizardForm.InfoBeforeMemo.font.Color  := Page_Color_Alternative1;
  WizardForm.LicenseMemo.font.Color  := Page_Color_Alternative1;
  WizardForm.MainPanel.font.Color := Font_Color;
  WizardForm.PageDescriptionLabel.font.color  := Font_Color;
  WizardForm.PageNameLabel.font.color  := Font_Color;
  WizardForm.PasswordEdit.font.Color  := Page_Color_Alternative1;
  WizardForm.Taskslist.font.Color  := Font_Color;
  WizardForm.UserInfoNameEdit.font.Color  := Page_Color_Alternative1;
  WizardForm.UserInfoOrgEdit.font.Color  := Page_Color_Alternative1;
  WizardForm.UserInfoSerialEdit.font.Color  := Page_Color_Alternative1;
  WizardForm.WelcomeLabel1.font.color  := Font_Color;
  WizardForm.WelcomeLabel2.font.color  := Font_Color;
  WizardForm.ReadyMemo.font.Color := Page_Color_Alternative1;
end;
4

2 回答 2

2

您可能正在寻找InfoBeforeMemo:位于InfoBeforePage页面上的 TRichEditViewer 组件

此页面 (NewNotebookPage) 是 TWizardForm (TSetupForm) 的财产。

开始了:

TRichEditViewer = class(TMemo)
  property RTFText: AnsiString; write;
  property UseRichEdit: Boolean; read write;
end;

因此,您需要更改纯 AnsiString 的属性RTFText 。

这意味着它是纯文本,没有“字体”或类似属性。RTF 文本是特殊格式的简单文本,如下所示:

{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}\f0\pard 这是一些 {\b 粗体} 文本。\par }

因此,如果您需要更改字体,您需要手动解析它 - 例如,将fswiss Helvetica更改为您想要的字体并将所有内容保存回来。

更多关于 RTF 的信息:http ://en.wikipedia.org/wiki/Rich_Text_Format

于 2013-04-17T14:50:35.833 回答
1

这是更改了许多属性的简单 RTF 文档:

这是适当的代码:

{\rtf1\ansi\ansicpg1250\deff0\deflang1051{\fonttbl{\f0\fnil\fcharset0 Calibri;}{\f1\fnil\fcharset0 Times New Roman;}} {\colortbl;\red0\green77\blue187;\red255 \green0\blue0;} {*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\sa200\sl276\slmult1\lang9\f0\fs22 你好。这是 \cf1 蓝色文本\cf0 。\cf2 这个文本是 red\cf0 。这是 \i italic \i0 & \b bold\b0 .\par \f1 即使将字体更改为 Times 也是可能的。\fs44 此文本大小为 22。\f0\fs22\par \par \par }

使用标志\cfX您的文本\cf0可以更改颜色,其中 X 是您想要的颜色编号。

颜色保存在文档头部的 colortbl 中(作为 RGB 值,缺少黑色):

{\colortbl;\red0\green77\blue187;\red255\green0\blue0;}

所以黑色 = cf0,蓝色 = cf1,红色 = cf2 等等。

要评估新文本,只需将新文本分配给 RTFText 变量:

WizardForm.InfoBeforeMemo.RTFText := '{\rtf1\ansi\ansicpg1250\deff0\deflang1051{\fonttbl{\f0\fnil\fcharset0 Calibri;}{\f1\fnil\fcharset0 Times New Roman;}}
{\colortbl ;\red0\green77\blue187;\red255\green0\blue0;}
{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\sa200\sl276\slmult1\lang9\f0\fs22 Hello. This is \cf2 blue text\cf0 . \cf2 And this text is red\cf0 . This is \i italic \i0 & \b bold\b0 .\par
\f1 Even changing font to Times is possible. \fs44 This text is 22 size.\f0\fs22\par
\par
\par
}';

在上面的示例中,我将蓝色文本的颜色更改为红色。

于 2013-04-18T05:21:21.483 回答