Detecting when my .NETCF application is "restarted"

  • Thread starter Thread starter Jon Pawley
  • Start date Start date
J

Jon Pawley

Hi.

I'm getting to grips with .NETCF, and have read/seen/heard a fair bit
about the "Smart Minimize" functionality that the Pocket PC 2002
mandates. It seems a bit of a cack-handed way of doing things, but I
guess we have to live with it. You know--I'm sure you do--it would be
really nice if there was an OS generated event that an application
could detect when it was being Smart Minimized... anyway, I digress...

What I am really after now is a way to detect when an .NETCF
application is "restarted" or brought out of the "Smart Minimized"
state.

Does anyone know how this could be done? Could you give me a few
pointers? That would be most appreciated.

Cheers,

Jon
 
Take a look at this discussion, it might help you further:
http://groups.google.nl/[email protected]#link1. A
combination of the events / properties that are mentioned in the discussion
should be enough to determine if you are smart minimized or if you are
temporary disabled because a modal dialog box is displayed. Oh one thing
that is not answered in it is the actual event that you get when being
re-activeated. It is the activated event. Hope this helps.
 
Maarten,

Hi, many thanks for your reply.

Thanks for the pointer to the previous thread--I had looked over that
previously, but it was good to get it back in mind.

So, I have been able to catch the Activate event on my form. Was a wee
bit stumped by this initially as the Visual Studio .NET 2003 Forms
Designer doesn't offer the Activate event as an option when adding
events to the form (and neither does it offer the Deactivated event).
I had naively figured that it would allow you to add all the available
events... not to worry.

So, thanks to Katie Schaeffer for pointing out that the Deactivated
event can be used to detect when a form is being "dismissed" or "smart
minimized" or even having a message box pop up in front of it. My
understanding is that the Deactivated event can be used to detect when
the form is being removed from teh top of the Z order.

And thanks to Maarten for pointing out that the Activate event can be
used to detect when the form is being brought back to the front of the
Z order. I cn indeed use this to tell when the form is being "brought
back."

However, as Vinay and Christoph have, I think, pointed out, it is
still pretty difficult to tell the difference between:

1) a form being deactivated because another form is being displayed on
top of the current one,

2) a form is being deactivated because a MessageBox is being displayed
on top of it, and

3) a form is being deactivate because the OS is Smart Minimizing it.

(For some of us, it is this third scenario which is particularly
important.)

Katie did suggest using the Enabled property of the form being
deactivated to determine whether the form was being deactivated
because of a Smart Minimize or not, but I could not see any difference
of value in the Enabled property in the three scenarios above.


Neither can I tell the difference between:

4) a form being activated because it has just been created at the top
of the Z order,

5) a form being activated because a form or MessageBox that was on top
of it has just been dismissed, or

6) a form has just been activated because the application has just
been "restored" after a "Smart Minimize".



Is there a way to tell the difference in these situations?


Katie has suggested that the MinimizeBox be st to false, thereby
changing the (x) Smart Minimize button into a form-closing (ok)
button. This is potentially a solution for some Pocket PC apps, but
not one that has to comply with the "Designed For Windows Mobile" logo
requirements. It would be really handy if Microsoft provided sample
techniques for situations that are stipulated by their logo
requirements, rather than being proscriptive ("thou shalt not...") and
not providing a solution to business requirements.

So, I am still looking for a definitve solution...

Cheers,

Jon
 
Jon,

thank you very much for this mail. You understood my absolutely correct.
I gave up that last time because the answers didn't respond to my
questions, but it wasn't my top target at that time so I just gave up.
But thanks again for the very detailed description of the scenarios, I
was too lazy for that. ;-) Maybe you have better luck. I'm waiting for
the answers ...

Christoph

P.S.: I was also a bit surprised to see a link to the thread I started,
because I didn't think it would help ... ;-)
 
Well Jon,

In a little test application I noticed one remarkable difference, although
for sure undocumented and I wouldn't count on it, however let me share it
with you.

If a form is deactivated because of showing another form or a messagebox on
top of it the order of events is as follows:

Validating
Validated
LostFocus
DeActivated

If a form is deactivated because of using the smart minimize button or
because another application is activated there is a subtle difference in the
order in which the events are fired:

DeActivated
Validating
Validated
LostFocus

However, when the original form becomes active again there is no difference,
the sequence of events will be the same in any case:

Activated
GotFocus

I tested this on the PPC 2002 emulator and on a HP Jornada 548 PPC device,
both with the same behavior. I am not suggesting that you should use the
order of events to determine how you got de-activated since I am sure this
is undocumented behavior and I would not trust it to remain like this.
 
Dear Maarten,

Many thanks, again, for your time. This info is what I was after, so
thanks for going to the trouble of writing your wee demo app.

Cheers,

Jon
 
Yes, thanks for the ideas, but this shouldn't be the solution. There
should be a way provided from MS!
My scenario again:
If you push a special button on your PPC that minimizes everything or
you just leave your app open and restart your PPC next day, everything
gets minimized (at least on my iPAQ). So, when you try to restart the
app, the last opened window gets shown, you can open new windows, but
you can never go back "behind" the window that was open when you
restarted the PPC. So, if you were in the middle of your app for
example, you can't log out, because you can reach that window. It is
minimized somewhere deep in the OS. This is not good and should get
solved by MS, but we are all used to work after MS' bugs. So I want to
create a little stack where I put my windows when they get shown, and I
remove them from the stack when they get minimized and I show the one on
top. But I need to be shure that the window gets minimized to do that!!
So, Katie, if you read this, please try some serious investigation
before you answer!
Thanks,
Christoph
 
I have another idea:
MS just changes the guidelines for PPC, so the "OK" also means that it
gets minimized. And all .NET CF developer catch the close event, do what
they want to do and hide the form after that.
It's not the solution for "app is 'restarted'", but it could be a
solution for my problem. ;-)
Merry Christmas,
Christoph
 
Christophe,

It would make a lot of other people unhappy though. ;-)

Merry Christmas to you too!
 
Hi all,

Thanks for all the posts on this issue. We've actually isolated and fixed
a couple of bugs around the z-order issues customers are running into (and
also linked a few bugs to the OS team).

For v2 we're also hoping to add a few features to make this scenario
better, such as owned forms (allowing you to associate forms with a main
form, which alleviates the problem Christoph is running into and also makes
it possible to have just one form per application displayed in the Running
Programs dialog list).

Unfortunately I don't have any new information on this topic beyond the
information Jon and Maarten have provided.

Thanks,
-Katie

This posting is provided "AS IS" with no warranties, and confers no rights.

***.Net Compact Framework Info***
Faq:
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.a
spx
QuickStarts: http://samples.gotdotnet.com/quickstart/CompactFramework/
Samples:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/h
tml/CompactfxTechArt.asp

--------------------
| From: "Ginny Caughey [MVP]" <[email protected]>
| References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| Subject: Re: Detecting when my .NETCF application is "restarted"
| Date: Mon, 22 Dec 2003 11:15:39 -0500
| Lines: 22
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| NNTP-Posting-Host: rrcs-midsouth-24-199-182-238.biz.rr.com 24.199.182.238
| Path:
cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.
phx.gbl
| Xref: cpmsftngxa07.phx.gbl
microsoft.public.dotnet.framework.compactframework:41548
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| Christophe,
|
| It would make a lot of other people unhappy though. ;-)
|
| Merry Christmas to you too!
| --
| Ginny Caughey
| .Net Compact Framework MVP
|
| | > I have another idea:
| > MS just changes the guidelines for PPC, so the "OK" also means that it
| > gets minimized. And all .NET CF developer catch the close event, do what
| > they want to do and hide the form after that.
| > It's not the solution for "app is 'restarted'", but it could be a
| > solution for my problem. ;-)
| > Merry Christmas,
| > Christoph
| >
|
|
|
 
Hi Katie,

so there is hope at least for the future. Hmm, I just looked up what
alleviate means. To my disappointment, it's not something like delete or
remove or vanish or ... ;-) Well, I have "alleviated" the problems so
that I think the customer can work with the application, but I will post
that in a separate mail.
In your mail I read about v2. Is that the next one to come? At the
moment we have SP2 Re-release (always funny ;-)). Will v2 be the next
one? And will it be Q2/Q3 2004?
Thanks,
Christoph
 
Hi Christoph,

I'm sorry about my wording - take the sentence to mean 'For our next
version we are working on some additional features that will empower
customers to have more control over the z-order behavior of their forms'.
And as you have guessed, these features couldn't be put into SP2 because
they involve object model additions. Of course, I can make no public
announcement as to what timeframe these features will be available. I just
wanted to let you know - we are listening to you, and take the problems and
issues you are running into very seriously.
I'm glad to hear you were able to work around these issues for your
customers.

-Katie

This posting is provided "AS IS" with no warranties, and confers no rights.

***.Net Compact Framework Info***
Faq:
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.a
spx
QuickStarts: http://samples.gotdotnet.com/quickstart/CompactFramework/
Samples:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/h
tml/CompactfxTechArt.asp

--------------------
| From: "C. Vollmer" <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| Subject: Re: Detecting when my .NETCF application is "restarted"
| Date: Tue, 23 Dec 2003 09:55:21 +0100
| Organization: T-Online
| Lines: 44
| Message-ID: <[email protected]>
| References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| Mime-Version: 1.0
| Content-Type: text/plain; charset=us-ascii; format=flowed
| Content-Transfer-Encoding: 7bit
| X-Trace: news.t-online.com 1072170001 02 12279 SjIXG9s6GDd+b9H 031223
09:00:01
| X-Complaints-To: (e-mail address removed)
| X-ID: ZZLcd6ZeZeWBQjfk0MnbLqOwQquNBo-YoVTWmZCdh9l+94Q3lbj9r0
| User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; de-AT; rv:1.5)
Gecko/20031007
| X-Accept-Language: de-de, de, en-us, en
| In-Reply-To: <[email protected]>
| Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08
.phx.gbl!newsfeed00.sul.t-online.de!newsmm00.sul.t-online.com!t-online.de!ne
ws.t-online.com!not-for-mail
| Xref: cpmsftngxa07.phx.gbl
microsoft.public.dotnet.framework.compactframework:41613
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| Hi Katie,
|
| so there is hope at least for the future. Hmm, I just looked up what
| alleviate means. To my disappointment, it's not something like delete or
| remove or vanish or ... ;-) Well, I have "alleviated" the problems so
| that I think the customer can work with the application, but I will post
| that in a separate mail.
| In your mail I read about v2. Is that the next one to come? At the
| moment we have SP2 Re-release (always funny ;-)). Will v2 be the next
| one? And will it be Q2/Q3 2004?
| Thanks,
| Christoph
|
| Katie Schaeffer [MSFT] schrieb:
| > Hi all,
| >
| > Thanks for all the posts on this issue. We've actually isolated and
fixed
| > a couple of bugs around the z-order issues customers are running into
(and
| > also linked a few bugs to the OS team).
| >
| > For v2 we're also hoping to add a few features to make this scenario
| > better, such as owned forms (allowing you to associate forms with a
main
| > form, which alleviates the problem Christoph is running into and also
makes
| > it possible to have just one form per application displayed in the
Running
| > Programs dialog list).
| >
| > Unfortunately I don't have any new information on this topic beyond the
| > information Jon and Maarten have provided.
| >
| > Thanks,
| > -Katie
| >
| > This posting is provided "AS IS" with no warranties, and confers no
rights.
| >
| > ***.Net Compact Framework Info***
| > Faq:
| >
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.a
| > spx
| > QuickStarts: http://samples.gotdotnet.com/quickstart/CompactFramework/
| > Samples:
| >
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/h
| > tml/CompactfxTechArt.asp
| >
|
|
 
Back
Top