5

ShowMessage() in Delphi XE5 shortens text.

Is this new to me, or it is due to the encoded characters when encoding a url? I need to see the entire thing.

I use the following function to encode my url:

function TConnector.EncodeUrl(aDecodedUrl: String): String;
begin
  result:= tIdUri.URLEncode(aDecodedUrl);
end;

I then call in here:

zEncodedUrl := Connector.EncodeUrl('http://' + Connector.Host + 'Node:' + edtPath.Text + '.GetObjectListDataAsJSON');

EDIT: And I get this when passed to ShowMessage:

screenshot

I should note that when debugging and placing my mouse over the zEncodedUrl variable, it shows the full thing.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
LIVESTUFF
  • 137
  • 4
  • 17

1 Answers1

6

That's the native behaviour of the Vista task dialog, at least as called by Delphi. And the Vista task dialog is what gets called when you call ShowMessage on Windows. It will not split lines that are too long. If your text included a space, it would be split.

A simple workaround would be to call good old MessageBox.

MessageBox(Application.MainForm.Handle, PChar(Message), PChar(Caption), MB_OK);

You may want to fine-tune the choice of owner HWND to pass, but you get the idea.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • YES! I was just using that :) But thanks for the great expanation of what is going on. ANy idea if there is an option to switch back to the showmessage window we all like? :) – LIVESTUFF Nov 08 '13 at 19:47
  • 2
    Well, you can set `UseLatestCommonDialogs` to `False`, but that will screw up your file dialogs too. And the resulting message box is pretty lame. It won't break the lines at all. Honestly, `MessageBox` is the best choice here. – David Heffernan Nov 08 '13 at 19:50