Why does my dialog box create an Exception?

S

steve bull

I created a dialog box which runs fine when I call Show() but gives the following unhandled exception when I call
ShowDialog(). It crashes when exiting from the menu item callback that invoked it.


An unhandled exception of type 'System.Runtime.InteropServices.SEHException' occurred in system.windows.forms.dll

Additional information: External component has thrown an exception.



It gives no clue as to where the problem is. Except maybe disposing of the dialog box.


This is the menu item code that creates the dialog box. It crashes on exiting the routine.



private void miViewAperiodic_Click(object sender, System.EventArgs e)
{
Tools.ColorModel.ColorRange selectedColorRange;

/* !++
* ! Code added here for creating and testing color range picker dialog box
* !-- */

ColorRangePicker colorRangePicker;

colorRangePicker = new ColorRangePicker();

colorRangePicker.FormBorderStyle = FormBorderStyle.FixedDialog;
colorRangePicker.ControlBox = false;
colorRangePicker.MinimizeBox = false;
colorRangePicker.MaximizeBox = false;
// colorRangePicker.Show();
colorRangePicker.ShowDialog();

if (colorRangePicker.DialogResult == DialogResult.OK)
{
selectedColorRange = colorRangePicker.SelectedColorRange.Duplicate();
Invalidate();
}

} /* End of miViewAperiodic_Click(object, System.EventArgs) */




Any suggestions would be welcome.


Thanks,

Steve
 
S

steve bull

well, I found the problem. If I get rid of Application.EnableVisualStyles(); in main it works fine.

I'm not sure what the call buys me. I see no difference in how things work.

steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top