Inno Setup button caption with line breaks

1.1k views Asked by At

I am trying to create a button caption that contains a line break:

Button.Caption := 'Line1' + #13#10 + 'Line2';

However, the standard line break character #13#10 does not appear to work in this case as I am getting:

Line1Line2

displayed on the button. What is the correct syntax to break a button caption across more than one line?

1

There are 1 answers

0
Martin Prikryl On BEST ANSWER

Based on Newline character in caption of button (in Delphi):

function GetWindowLong(Wnd: HWnd; Index: Integer): LongInt;
  external '[email protected] stdcall';
function SetWindowLong(Wnd: HWnd; Index: Integer; NewLong: LongInt): LongInt;
  external '[email protected] stdcall';

const
  GWL_STYLE = -16;
  BS_MULTILINE = $2000;

procedure InitializeWizard();
var
  Button: TNewButton;
begin
  Button := TNewButton.Create(WizardForm);
  Button.Left := ScaleX(16);
  Button.Top := WizardForm.NextButton.Top - ScaleX(8);
  Button.Width := WizardForm.NextButton.Width;
  Button.Height := WizardForm.NextButton.Height + ScaleY(16);
  Button.Parent := WizardForm;

  SetWindowLong(Button.Handle, GWL_STYLE, 
    GetWindowLong(Button.Handle, GWL_STYLE) or BS_MULTILINE);

  Button.Caption := 'foo' + #13#10 + 'bar';
end;

Button with new line