tags:

views:

1857

answers:

5

Hi,

How to display Message box in C# as System Modal, something like vbModal in VB6

Thanks

A: 

I think you'll have to roll your own.

A quick search has turned up these two links:

Code Project

Egghead Cafe

ChrisF
+2  A: 

Advanced MessageBoxing with the C# MessageBoxIndirect Wrapper

Dana Holt
Which is the same link as I posted ;)
ChrisF
A: 

Standard message box in C# is modal (cannot access rest of app until messagebox is dismissed).

http://msdn.microsoft.com/en-us/library/aa335423(VS.71).aspx

"A message box is a modal dialog, which means no input (keyboard or mouse click) can occur except to objects on the modal form. "

Edit: I am not sure about Vb6 and messagebox there. Does it use a different type of "modal"?

Maestro1024
This is referring to application modal not system modal
ChrisF
+2  A: 

Are you talking about message boxes, or standard forms? If you're talking about standard forms, the easiest .net equivalent of vbModal is the ShowDialog method of forms. So, rather than the old

myForm.Show vbModal

you use

myForm.ShowDialog();

or

myForm.ShowDialog(myFormOwner);

This halts execution at the ShowDialog line just like the old vbModal used to

Dan F
These are application modal not system modal
ChrisF
Yep. He mentioned vbModal, so I'm hoping he doesn't actually *mean* system modal, and more means "on top of all other windows in my app" :-) It's worth a shot anyway, and people searching for vbModal might learn something at the same time.
Dan F
+1  A: 

You should also be asking yourself if you really want to be creating a system modal message box, its considered bad UI design and that's why its not in .NET out the box.

Mark