views:

32

answers:

2

I like messagebox styles as display in http://dotnetperls.com/messagebox-show (white stripe in the middle, right-aligning for "OK").

However, when I'm trying to reproduce it (in standard C# Windows Form application) using the code like

MessageBox.Show("Dot Net Perls is awesome.");

I get messagebox with a different style, like in www.homeandlearn.co.uk/net/netMessageBox.html.

How can I reproduce white-striped results? .NET applications suppose to be platform independent, so it should not matter if I'm running Win95/XP or 7.

A: 

Yes. It should matter.

The style is dictated by the operating system style configured in Windows Control Panel.

Leniel Macaferi
+1  A: 

Yes, .NET applications are (largely) platform independent. But that doesn't mean they look the same no matter what OS they're running on. If they did that, they would look wrong most of the time. If you make your app look like a Vista app, then a user who's running XP will think it looks strange, because it doesn't look like any of their other apps.

Message boxes have the white background on Vista, and I think on Windows 7 as well. On XP and earlier, your message box's background will be SystemColors.Control instead, which is usually something like gray (but can be customized by the user).

If you want the white background regardless of which OS you're running on (i.e., if you really want your app to look out of place on XP), there's nothing stopping you from writing your own Form.

Joe White