How might one go about creating a Modeless MessageBox? Do I have to just create my own Windows Form class and use that? If so, is there an easy way of adding a warning icon (rather than inserting my own image of one) and resizing based on text volume?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
Short of writing the code, you could create a small form that in the constructor does the following
SystemIcons.Application
SystemIcons.Asterix
SystemIcons.Error
SystemIcons.Exclamation
SystemIcons.Hand
SystemIcons.Information
SystemIcons.Question
SystemIcons.Shield
SystemIcons.Warning
SystemIcons.WinLogo
If you really wanted, you could listen to an event that is fired when the OK button is pushed.
Note: this will create a Modal dialog box, which is not what the question is asking
here is a sample code
You'll have to create a Form and use
Show()
to display it Modeless.MessageBox.Show(...)
behaved Modal as seen in the example by ghiboz; "Description of the message" is displayed until the user presses a button.With
MessageBox.Show(...)
you get the result as soon as the messagebox is closed; with a modeless message box, your code will have to have a mechanism such as an event to react when the user eventually selects something on your message box.If you need a message box that just displays itself while your code continues running in the background (the box is still modal and will prevent the user from using other windows until OK is clicked), you can always start the message box in its own thread and continue doing what ever you do in the original thread:
You have to either use form and call showDialog()
And for icons use
MessageBoxIcon.Warning
//no commnet
needs more threads and more code(I don't have enough time to write) for concurrent messageboxes.