0

I need to change the font color property of the RichEditorViewer of the default pages, but I can't find the control names or property name, I need help with this...

The RichEditorViewer of the InfoBeforePage (I need to change the font color):

Setup screenshot

This is the code I'm using:

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;
Deanna
  • 23,876
  • 7
  • 71
  • 156
ElektroStudios
  • 19,105
  • 33
  • 200
  • 417
  • 1
    Correct name for this page is InfoBeforePage which is: property InfoBeforePage: TNewNotebookPage; read; of TWizardForm = class(TSetupForm) – Slappy Apr 17 '13 at 14:39

2 Answers2

2

You are probably looking for InfoBeforeMemo: TRichEditViewer component which is located on page InfoBeforePage

This page (NewNotebookPage) is property of TWizardForm (TSetupForm).

Here we go:

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

So you need to change property RTFText which is pure AnsiString.

That means it is pure text, there is no property 'Font' or similar. RTF text is simple text in special format which looks like this:

{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}\f0\pard This is some {\b bold} text.\par }

So if you need to change the font you need to parse it manually - e.g. by changing fswiss Helvetica to your desired font and saving everything back.

More info about RTF here: http://en.wikipedia.org/wiki/Rich_Text_Format

Slappy
  • 5,250
  • 1
  • 23
  • 29
  • **if you need to change the font you need to parse it manually - e.g. by changing fswiss Helvetica to your desired font and saving everything back.** Thankyou for your answer but I don't understand that part, you can give a example of how to change the font color? and then I need to change the value of the property **RTFText** to what value? – ElektroStudios Apr 17 '13 at 15:40
1

Here is simple RTF document with many attributes changed:

And here is appropriate code for it:

{\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 \cf1 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 }

Changing the color is possible with flag \cfX your text here \cf0 where X is your desired color number.

Colors are saved in colortbl in the head of document (as RGB values, black is missing):

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

so black = cf0, blue = cf1, red = cf2 etc.

To assing new text simply assign your new text to RTFText variable:

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
}';

In the example above I changed color of blue text to red.

Mohsen Safari
  • 6,669
  • 5
  • 42
  • 58
Slappy
  • 5,250
  • 1
  • 23
  • 29
  • Awesome example, I've learned a lot, thankyou. Do you know if I can use a variable into the property value? for example: `const Font_Color = cf0; WizardForm.InfoBeforeMemo.RTFText := '{\rtf1\blablabla\Font_Color}'` ¿? – ElektroStudios Apr 18 '13 at 12:40
  • Oh another little question, I can preserve the text data when changing the .RTFText property? (To preserve the InfoBeforeFile.txt document as text inside the RichEditor)? sorry if I ask too much, but I can't find any info on the web. Maybe I will need something as "SaveStringToFile()" function but the reverse "SaveFileToString()". – ElektroStudios Apr 18 '13 at 12:51
  • Yes, you can use variables. e.g. const FontColor: AnsiString = 'cf0'; WizardForm.InfoBeforeMemo.RTFText := '{\rtf1\blablabla\' + FontColor + '}' – Slappy Apr 19 '13 at 08:30
  • Simply store old text in your variable: var OldText: AnsiString; Oldtext := WizardForm.InfoBeforeMemo.RTFText; – Slappy Apr 19 '13 at 08:31
  • I did what you said, store the text and all with your code examples but then in the line to change the rtf text I get an error saying "Write-only property" and I cannot change the text. If I delete the var Oldtext I can modify the rtftext again... I don't understand it. – ElektroStudios Apr 20 '13 at 05:23
  • I am not sure what you need, please create new question and paste your code there. – Slappy Apr 20 '13 at 18:25
  • http://stackoverflow.com/questions/16123879/innosetup-how-to-load-a-custom-text-into-rtftext – ElektroStudios Apr 20 '13 at 18:44