I have a timer class that I created that monitors the license of the software. When an error occurs I call ShowDialog() to show my customized windows form. My problem is how can I disable the parent window? Here's a simple example of my problem. As you can see once the MessageBox pops up, you can still type from the MainForm window.
MainForm1.cs file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace TestProject
{
public partial class MainForm1 : Form
{
public MainForm1()
{
InitializeComponent();
}
private void MainForm1_Load(object sender, EventArgs e)
{
TimerClass1 timer = new TimerClass1();
}
}
}
MessageBox.cs file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace TestProject
{
public partial class MessageBox : Form
{
public MessageBox()
{
InitializeComponent();
this.label1.Text = "Hello There";
this.button1.Text = "OK";
this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
}
}
}
TimerClass1.cs file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;
using System.Windows;
namespace TestProject
{
class TimerClass1
{
Timer _timer;
public TimerClass1()
{
_timer = new Timer(1);
_timer.Elapsed +=new ElapsedEventHandler(_timer_Elapsed);
_timer.Enabled = true;
}
private void _timer_Elapsed(object sender, ElapsedEventArgs e)
{
_timer.Stop();
MessageBox msg = new MessageBox();
msg.ShowDialog();
_timer.Start();
}
}
}