This is actually somewhat expected behavior under Windows CE (I'm not saying it's right, just expected).
When you click on the SIP button down in the corner of the desktop, your entire app loses focus and focus is passed to the Task Bar. You can see similar "wierdness" by clicking on your application's Task Bar button - the MessageBox will lose focus, even though by all rights you should just be sending focus to the app that is already running.
You can see that it's not a CF bug by changing your MessageBox call like so:
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);
And you get the exact same behavior.
The one thing that is not expected is that the parent Form is coming up above the MessageBox. I just tested on an ARM-based CE 5.0 device I have on my desktop and the MessageBox stays on top in both the CF and the P/Invoke versions.
Are you able to repro this behavior with a very basic app (i.e. just one form, one button)? If so then it sounds like a platform issue. One thing to remember about using CE is that since the OEM has a lot of control over how the OS is actually implemented, you can never rule out a platform bug for behaviors.