Search code examples
c#winformsmessagebox

Have winforms MessageBox appear on all screens, or specify Main or Secondary etc.


I have a winforms app which functions as an alert system, however a lot of the people who will use my program will have multiple screens. The alerts are time sensitive, so ideally I'd like them to appear on all screen, or to be able to specify a screen, so the user is more likely to notice it. By default the message boxes appear on the main screen, and I can't find any info on anything really to do with winforms and different monitors.

The doesn't even have to be a message box, if there is another winform function which can be made to do the same functionality but also multiple screens that'd be great.

On a side note is it possible to close multiple messageboxes from only 1 being accepted?


Solution

  • I think the easiest thing to do is create a custom form rather than using the existing message box. That way you can use the Show method rather than ShowDialog. This would allow you show multiple forms and close all of them from a single response.

    As to placing them on multiple screens: You can find the existing screens with System.Windows.Forms.Screen.AllScreens. Each one of those has a Bounds property which will show you what the coordinates and size of each screen is. After you create each custom form you can specify it's Location property to place it on the screen of your choice.