inno-setuprtfpascalscriptrichedit

Switch Inno Setup license memo to RTL mode


I'm creating a installer with multi language, some of language need RTL direction to show naturally. This is the code I'm using for my license page:

LicenseMemo := TNewMemo.Create(WizardForm);
with LicenseMemo do
begin
  Parent     := WizardForm.LicensePage;
  Left       := ScaleX(0);
  Top        := ScaleY(50);
  Width      := ScaleX(520);
  Height     := ScaleY(210);
  Color      := TColor($d3d3d3);
  Font.Color := clBlack;
  ScrollBars := ssVertical;
  Text       := WizardForm.LicenseMemo.Text;
  LicenseMemo.Font.Size := 12
  ReadOnly   := True;
end;

I know i can make program fully RTL by adding RightToLeft=yes to [LangOptions]. But it makes program look bad – Ii only need RTL for license page. Anyone can help? I use RTF file for the license page.


Solution

  • Use TRichEditViewer and add WS_EX_LAYOUTRTL to its GWL_EXSTYLE:

    const 
      GWL_EXSTYLE = -20;
      WS_EX_LAYOUTRTL = $400000;
    
    function GetWindowLong(hWnd: THandle; Index: Integer): LongInt;
      external 'GetWindowLongW@User32.dll stdcall';
    function SetWindowLong(hWnd: THandle; Index: Integer; NewLong: LongInt): LongInt;
      external 'SetWindowLongW@user32.dll stdcall';
    
    SetWindowLong(
      RichEditViewer.Handle, GWL_EXSTYLE,
      GetWindowLong(RichEditViewer.Handle, GWL_EXSTYLE) or WS_EX_LAYOUTRTL);