PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework How can I tell if my form was started using Application2?

Reply

How can I tell if my form was started using Application2?

 
Thread Tools Rate Thread
Old 06-09-2006, 07:00 PM   #1
jonfroehlich
Guest
 
Posts: n/a
Default How can I tell if my form was started using Application2?


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!

  Reply With Quote
Old 06-09-2006, 07:18 PM   #2
jonfroehlich
Guest
 
Posts: n/a
Default Re: How can I tell if my form was started using Application2?

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!


  Reply With Quote
Old 06-09-2006, 09:55 PM   #3
Guest
 
Posts: n/a
Default Re: How can I tell if my form was started using Application2?

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!

>



  Reply With Quote
Old 07-09-2006, 12:02 AM   #4
jonfroehlich
Guest
 
Posts: n/a
Default Re: How can I tell if my form was started using Application2?

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!

> >


  Reply With Quote
Old 07-09-2006, 12:39 AM   #5
Guest
 
Posts: n/a
Default Re: How can I tell if my form was started using Application2?

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!
>> >

>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off