Reputation: 489
I am working on Delphi 7. I want to change the messageDlg width.
I mean my message test is very long because of that message is displaying in 2 lines but i want to display message only in one line.
Below is my single line of code
MessageDlg('i want to display only in oneline i want to display only in oneline i want to display only in oneline i want to display only in oneline i want to display only in oneline',mtError,[mbok],0)
Above message is displaying in 2 lines but i want to display message only in one line.
Upvotes: 1
Views: 3045
Reputation: 612794
In Delphi 7 the MessageDlg
function is implemented on top of CreateMessageDialog
. You can call that method and have a TForm
instance be returned to you. You can then widen that form, widen its label, and then show the form.
var
Form: TForm;
Label: TLabel;
....
Form := CreateMessageDialog(Msg, mtError, [mbOK]);
try
Label := Form.FindComponent('Message');
Label.Width := Label.Width + ExtraWidth;
Form.ClientWidth := Form.ClientWidth + ExtraWidth;
Form.Position := poScreenCenter;
ShowModal;
finally
Form.Free;
end;
All that remains is for you to work out ExtraWidth
. Look in the implementation of CreateMessageDialog
for inspiration there. Presumably you'd want to include logic to avoid making the form too wide, spreading beyond the width of a monitor and so on.
Upvotes: 11