How do I center align text within a ShowMessage
box in Delphi?
I have two lines and want them both to be horizontally centered aligned. Is this even possible with the standard ShowMessage
dialog?
You can use CreateMessageDialog
procedure:
procedure TmyFRM.btn_messageClick(Sender: TObject);
Var
i: Integer;
Begin
With CreateMessageDialog('Your message to display!!', mtInformation, [mbOk], mbOk) do
Try
for i := 0 to ControlCount - 1 do
if Controls[i] is TLabel then
With Controls[i] as TLabel do Begin
Font.Name := 'Fjalla One';
Font.Size := 12;
Alignment := taCenter;
End;
ShowModal;
Finally
Free;
End;
End;
with this procedure you can control you message box, for example if you don't look for Label
s using ControlCount
and Controls[i]
, you can set properties for your whole window of message, like changing "Ok" button font, changing colors and.....
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.