PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
How can I tell if my form was started using Application2?
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
How can I tell if my form was started using Application2?
![]() |
How can I tell if my form was started using Application2? |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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! |
|
|
|
#2 |
|
Guest
Posts: n/a
|
As a follow-up question to this; is there any way to tell if my Form
was started using Application2.ShowDialog(form) rather than form.ShowDialog? Thanks! again! jonfroehlich wrote: > 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! |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Modify the SDF source to set a named event or mutex and look at it from your
code. That's the easiest way I can think of. -- Chris Tacke OpenNETCF Consulting Managed Code in the Embedded World www.opennetcf.com -- "jonfroehlich" <jonfroehlich@gmail.com> wrote in message news:1157566683.463368.290170@h48g2000cwc.googlegroups.com... > As a follow-up question to this; is there any way to tell if my Form > was started using Application2.ShowDialog(form) rather than > form.ShowDialog? > > Thanks! again! > > jonfroehlich wrote: >> 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! > |
|
|
|
#4 |
|
Guest
Posts: n/a
|
OK, I didn't know if this feature was already offered by the SDF.
Thanks for the response Chris! j <ctacke/> wrote: > Modify the SDF source to set a named event or mutex and look at it from your > code. That's the easiest way I can think of. > > > -- > Chris Tacke > OpenNETCF Consulting > Managed Code in the Embedded World > www.opennetcf.com > -- > > > > > "jonfroehlich" <jonfroehlich@gmail.com> wrote in message > news:1157566683.463368.290170@h48g2000cwc.googlegroups.com... > > As a follow-up question to this; is there any way to tell if my Form > > was started using Application2.ShowDialog(form) rather than > > form.ShowDialog? > > > > Thanks! again! > > > > jonfroehlich wrote: > >> 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! > > |
|
|
|
#5 |
|
Guest
Posts: n/a
|
Nope. This would definitely be a new feature request, though I may look at
implementing it in the next release. -- Chris Tacke OpenNETCF Consulting Managed Code in the Embedded World www.opennetcf.com -- "jonfroehlich" <jonfroehlich@gmail.com> wrote in message news:1157583726.413137.324770@d34g2000cwd.googlegroups.com... > OK, I didn't know if this feature was already offered by the SDF. > > Thanks for the response Chris! > > j > > <ctacke/> wrote: >> Modify the SDF source to set a named event or mutex and look at it from >> your >> code. That's the easiest way I can think of. >> >> >> -- >> Chris Tacke >> OpenNETCF Consulting >> Managed Code in the Embedded World >> www.opennetcf.com >> -- >> >> >> >> >> "jonfroehlich" <jonfroehlich@gmail.com> wrote in message >> news:1157566683.463368.290170@h48g2000cwc.googlegroups.com... >> > As a follow-up question to this; is there any way to tell if my Form >> > was started using Application2.ShowDialog(form) rather than >> > form.ShowDialog? >> > >> > Thanks! again! >> > >> > jonfroehlich wrote: >> >> 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! >> > > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

