Problem with MessageBox

I have a problem with MessageBox, which should be modal.

Here is the situation

  • User selects xx from the form
  • MessageBox appears
  • The user opens the built-in soft keyboard (built-in, from the device)
  • The user closes the keyboard.
  • MessageBox loses focus (as modality refutes it!), And the main form is shown in the foreground
  • The application is blocking because the user cannot close the MessageBox.

Here is the code snippet for MessageBox.

MessageBox.Show("message", "caption", MessageBoxButtons.OK, MessageBoxIcon.Asterisk,
                                    MessageBoxDefaultButton.Button1);

Any ideas on how to solve this?

+3
source share
3 answers

This is really the expected behavior in Windows CE (I'm not saying this is correct, just expected).

SIP , . "wierdness", " " - MessageBox , , .

, CF, MessageBox :

private void button1_Click(object sender, EventArgs e)
{
    //MessageBox.Show("message", "caption", MessageBoxButtons.OK, 
    //                                    MessageBoxIcon.Asterisk,
    //                                    MessageBoxDefaultButton.Button1);

    MessageBoxCE(this.Handle, "message", "caption", 0);
}

// renamed to not collide with the Windows.Forms MessageBox class
[DllImport("coredll", EntryPoint="MessageBox")]
private static extern int MessageBoxCE(IntPtr hWnd, string lpText, 
                                       string lpCaption, int Type);

.

, , , MessageBox. CE 5.0 ARM, , MessageBox CF, P/Invoke.

(.. , )? , . , CE, , , OEM , , .

+1

MessageBox.Show( IWin32Window, "this"). , , , - . :

MessageBox.Show Method (IWin32Window, String, String, MessageBoxButtons, MessageBoxIcon, MessageBoxDefaultButton)

Microsoft.

!

0
MessageBox.Show("Please insert Correct Username and Password.", "Login Error",
                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
this.Focus();

. - JavaScript #.

0

Source: https://habr.com/ru/post/1765350/


All Articles