3

Often times when our app uses TaskDialog to display a simple dialog box, Windows will wrap the last word of pszContent to a second line. In those scenarios, we'd much prefer the dialog box be widened just a bit and keep pszContent on a single line.

Anyone know if this is possible without adding additional buttons to the dialog box? (That's the only workaround I've found after searching online. And not an acceptable workaround for me.)

Example of silly wrapping that I'd like to avoid.

Jon Robertson
  • 591
  • 6
  • 18
  • 3
    Did you try using a non-breaking space before the 2? – Raymond Chen Jul 05 '12 at 16:25
  • I had not, but I just now did. This allows me to control where to wrap the line but does not prevent wrapping. If the space between 'line' and '2' is changed, then "line 2" is wrapped to second line. If the space between 'to' and 'line' is also changed, then 'to line 2' is on second line. The non-breaking space is preventing a wrap where it is used, but not preventing the overall wrap. Thanks for the suggestion. I was hopeful, considering the source. ;) – Jon Robertson Jul 05 '12 at 17:49
  • 2
    I thought you just wanted to fix the orphaned 2. If you want to prevent any line breaks anywhere in the line, then you have to change all spaces to non-breaking. When you use Task Dialog, you are saying "I am not concerned about precise details of presentation. I will let Windows decide where the line breaks should be." – Raymond Chen Jul 05 '12 at 19:14
  • That makes sense (all spaces to non-breaking). A vast majority of the time, we're happy with where Windows decides the line breaks should be. Just not a few occasional scenarios. I'll upvote your response. But if you post it as an answer, I'll mark it Answered. – Jon Robertson Jul 05 '12 at 19:48
  • 1
    Although now there is the issue that a long line with no breaks is truncated and ellipsis are added. To see how well TaskDialog handles the non-breaking space, I just tested a 78 character message with no breaks. The message was truncated to 67 characters and ellipsis added afterwards. Widening the dialog box to fit this message wouldn't make it _that_ much larger. (Interestingly, Ctrl-C still copies the complete text.) I suppose creating our own TaskDialog styled dialog is the only true solution. (We'd want to keep the same UI style that users expect.) – Jon Robertson Jul 05 '12 at 19:59
  • 1
    Can't you call [`TaskDialogIndirect`](http://msdn.microsoft.com/en-us/library/windows/desktop/bb760544.aspx) and set [`TASKDIALOGCONFIG.cxWidth`](http://msdn.microsoft.com/en-us/library/windows/desktop/bb787473.aspx) to the desired with? (If it's 0, the ideal width is calculated automatically, which is what you're seeing now.) – Cody Gray - on strike Jul 17 '13 at 05:42

0 Answers0