J
jonfroehlich
This question involves the OpenNetCF SDF.
Is there a straightforward way to determine whether a form was started
using the SDF Application2 class? That is, Application2.Run(new form())
rather than Application.Run(new form())
I thought maybe I could use the Application2.MessageLoop property;
however, this is not set immediately by the SDF. I inspected the
Application2 source code and saw that the messageLoop variable isn't
set to true until after the mainForm visibility is set to true. This
causes the following code:
protected override void OnLoad(EventArgs e)
{
Debug.WriteLine("OnLoad: Application2.MessageLoop: " +
Application2.MessageLoop);
base.OnLoad(e);
}
protected override void OnGotFocus(EventArgs e)
{
Debug.WriteLine("OnGotFocus: Application2.MessageLoop: " +
Application2.MessageLoop);
base.OnGotFocus(e);
}
protected override void OnActivated(EventArgs e)
{
Debug.WriteLine("OnActivated: Application2.MessageLoop: " +
Application2.MessageLoop);
base.OnActivated(e);
}
to initially print out:
OnLoad: Application2.MessageLoop: False
OnActivated: Application2.MessageLoop: False
OnGotFocus: Application2.MessageLoop: False
If I minimize the form (using the "home" button on the phone) and then
refocus it (using the "back" button on the phone), I'm able to force
OnActivated and OnGotFocus to be called. In this case, finally,
MessageLoop is true.
OnActivated: Application2.MessageLoop: True
OnGotFocus: Application2.MessageLoop: True
There has to be a better way!?
Thanks everyone!
Is there a straightforward way to determine whether a form was started
using the SDF Application2 class? That is, Application2.Run(new form())
rather than Application.Run(new form())
I thought maybe I could use the Application2.MessageLoop property;
however, this is not set immediately by the SDF. I inspected the
Application2 source code and saw that the messageLoop variable isn't
set to true until after the mainForm visibility is set to true. This
causes the following code:
protected override void OnLoad(EventArgs e)
{
Debug.WriteLine("OnLoad: Application2.MessageLoop: " +
Application2.MessageLoop);
base.OnLoad(e);
}
protected override void OnGotFocus(EventArgs e)
{
Debug.WriteLine("OnGotFocus: Application2.MessageLoop: " +
Application2.MessageLoop);
base.OnGotFocus(e);
}
protected override void OnActivated(EventArgs e)
{
Debug.WriteLine("OnActivated: Application2.MessageLoop: " +
Application2.MessageLoop);
base.OnActivated(e);
}
to initially print out:
OnLoad: Application2.MessageLoop: False
OnActivated: Application2.MessageLoop: False
OnGotFocus: Application2.MessageLoop: False
If I minimize the form (using the "home" button on the phone) and then
refocus it (using the "back" button on the phone), I'm able to force
OnActivated and OnGotFocus to be called. In this case, finally,
MessageLoop is true.
OnActivated: Application2.MessageLoop: True
OnGotFocus: Application2.MessageLoop: True
There has to be a better way!?
Thanks everyone!