Focus problem!

Hello.

Im making a smartphone program for Windows Mobile 5.0 using C#. In this program there is a form. I open other forms on it as a dialog:
using(MyForm form = new MyForm())
{
form.ShowDialog();
}

Here is my problem: when i have opened a dialog on the main form, and press end button(red phone), program losts its focus as it should. But when i give the focus back to my program by pressing its icon, program acts veird:

When i close the dialog with this.Close(), mainform losts its focus again! So i have to press the icon again to get the program visible.

Here's the situation once again:
mainForm opened -> dialog opened -> program losts focus -> program gets focus -> dialog closed -> program losts focus again!

How can i fix this Is there easy way


Answer this question

Focus problem!

  • steveharper

    Closing the dialogs with DialogResult did not help, but thanks for that. I did not realize that setting dialogresult actually closes the dialog, and i had some "weird" problems with exit events.

  • Dmitry Vasilevsky MSFT

    Try closing the dialog by setting the DialogResult property instead of using this.Close().

  • Focus problem!