dockpanelsuite
dockpanelsuite copied to clipboard
Access violation if a message box opens while docking
I have the following code in one of my dock contents. It opens a message box a few seconds after the button is clicked. If I am dragging any panel in the application at the time when the message box opens, an AccessViolationException occurs within MessageBox.Show
.
private void button1_Click(object sender, EventArgs e)
{
timer1.Interval = 3000;
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
timer1.Stop();
MessageBox.Show("test message");
}
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
MessageBox.Show("test message");
needs to be
MessageBox.Show(this, "test message");
If you don't specify an owner, the framework will call GetActiveWindow
and use that. During dragging the active window is the temporary one that contains the dock indicators. Apparently the native MessageBox function doesn't like it when its owner disappears in the way it does here.
This isn't exactly our bug as the original code is arguably wrong, but it's probably a very common mistake that usually only results in the message box having the wrong owner. Is there any way we can make the active window be the content being dragged rather than the container for the indicators?