adityatan's picture

MessageBox.Show()

Hi there:

I have an OpenTK game window that functions very well. Now, I would like to create an input data from a pop-up window, which will pop-up if the user checks the corresponding Check Box. The simple code is as follows:

 
private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            MessageBox.Show("Hello");
        }

However, when I check the Check Box, the main window freezes and the Message Box does not appear.

I must have missed some steps. Please help me. Thank you.

AT


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

If you are using GLControl, try MessageBox.ShowDialog().

If you are using GameWindow, note that you shouldn't mix GameWindow with WinForms in the same thread, as WinForms will hijack the message pump. If you need to do that, you should create a new AppDomain for the MessageBox - this is the only approach that's guaranteed to work.

adityatan's picture

What is the distinction between GLControl and GameWindow? I might use the word "GameWindow" inappropriately. Thanks.

AT

the Fiddler's picture

GLControl is a WinForms control that you can drag & drop into the Visual Studio designer. It is found in OpenTK.GLControl.dll and is meant for GUIs.

GameWindow is a native window, roughly equivalent to SDL or GLUT. It is found in OpenTK.dll and is generally meant for games.

adityatan's picture

Thank you.

I'm currently using GLControl, then. Futhermore, ".ShowDialog()" does not work. Do you have any other idea?

AT

the Fiddler's picture

MessageBox.Show and ShowDialog offer overloads that take a IWin32Window parameter. Try using those, specifying your main form as the window.

Alternatively, try adding calls to Application.DoEvents() before and after MessageBox.Show(). This shouldn't be necessary under normal circumstances - if it works this way, it means that something is blocking when it shouldn't.

adityatan's picture

Thanks.

I just re do the whole thing--i.e. creating a new Windows Form Application--and things are fine now. Thanks again.

AT