I’ve been working at this on and off for a while but essentially I have a class that I call to display message boxes.
I’m trying to get my message boxes to be modal, which is easily done if you specify the form to be modal to.
So my form is declared like this
public partial class MainForm : Form
and it is instantiated like this
var mainForm = new MainForm();
So I have a class that contains methods which open message boxes like this
MainForm.ActiveForm.Invoke(new MethodInvoker(delegate
{
MessageBox.Show(MainForm.ActiveForm, message, title, buttons, icon);
}));
This works fine, but active form only works when the form is active…..
Anyways is there an easy way around this?
I have a solution that works fairly well, but I’m not sure if there is a more elegant solution.
So in MainForm.cs I have
Then in the OnLoad method
Then in my message box method:
Am I missing something here? Is there a better alternative to mainWindow = MainForm.ActiveForm?