我正在尝试创建一个包含换行符的按钮标题:
Button.Caption := 'Line1' + #13#10 + 'Line2';
但是,标准换行符#13#10
在这种情况下似乎不起作用,因为我得到了:
Line1Line2
显示在按钮上。在多行中打破按钮标题的正确语法是什么?
答案 0 :(得分:2)
基于Newline character in caption of button(在Delphi中):
function GetWindowLong(Wnd: HWnd; Index: Integer): LongInt;
external 'GetWindowLongW@user32.dll stdcall';
function SetWindowLong(Wnd: HWnd; Index: Integer; NewLong: LongInt): LongInt;
external 'SetWindowLongW@user32.dll 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;