tags:

views:

456

answers:

2

I want to diaplay message boxes that looks good, with the possibillity to use bold/italic text and text with different colors. The standard MessageBox.Show doesn't provide this functionality.

I have been trying to create a message box using the WebBrowser control to display nicely formatted text using HTML-syntax. But I haven't succeeded.

Do you know if this is possible, or do you know any other way to show a message box with formatted text? I want the message box to size itself dynamically to it's content.

(For Windows Forms)

+2  A: 

You could create your own Form class that hosts the WebBrowser control (or an RTF control) to display the formatted content. Just give it an interface (API) similar to MessageBox so you can use it much the same way (e.g., checking the user's Yes/No or Ok/Cancel/etc responses).

For the sizing, you would likely need to check the content being displayed and use some System.Drawing capabilities to get the size of the fonts/content for it. Then size your window accordingly and/or show and hide scrollbars so they're only shown when absolutely necessary.

Jeff Donnici
Yes thanks, thats what I have been trying to do. But the sizing problem is too hard for me to solve because of different reasons. I would be really happy if somebody had working code.
Mikael Sundberg
A: 

I have just created and posted a product, HTML MessageBox, that solves exactly Mikael's problem. It's a drop-in replacement for the standard Windows API MessageBox call, that allows you to use bold, underline, and italic, and fonts. And it behaves like standard MessageBoxes, auto-sizing to the message, word wrapping etc. Plus, it's a small hand-coded control, that doesn't use a heavyweight IE window to display the HTML.

There are interfaces included in the product for calling it with the standard Windows API calling convention, or via COM, or from a .NET class. (Also PowerBuilder, because I originally created this to work in my own PowerBuilder app!)

It's at www.HTML-MessageBox.com.

Dan Cooperstock