Detecting the Pocket PC Power On/Off button

N

Neville Lang

Hi all,

When I launch my app, one option a user has is to start a 30 second timer
that updates a form. When the user presses the power button on the PPC, the
device turns off, or more correctly, the display is shut down but the app is
still running.

When the user presses the power button again, the screen shows the form that
was displayed before the power was turned off. All OK up to this point.

What I have noticed is that the 30 second timer does not update the form
immediately the power button is touched but may wait for up to a its full 30
seconds depending on the cycle at which the power button was pressed.

My question is: How can I detect that the screen is now on (after the power
button has been pressed) to force a refresh of the form so that I am not
waiting for the 30 second timer?

I have discovered CeRunAppAtEvent but I think that is more to do with
running an app at an event. I am not sure whether this will work for my
scenario where I want to triggering a form refresh at power up on a running
app, if that option is selected by the user.

Regards,
Neville Lang
 
P

Peter Foot [MVP]

You can add in support to your OnActivated method in the form to refresh,
this is called when the application is brought back into focus and should
occur on wakeup.
Another option is to write a small exe which you can call with
RunAppAtEvent, the sole purpose of which is to send your application a
message. Use RegisterWindowMessage to create a message id specific to your
application and send it to HWND_BROADCAST a special handle value which sends
the message system wide. Then use a MessageWindow in your application to
catch the message (using RegisterWindowMessage again to get the same unique
id) and trigger your update.

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

Do have an opinion on the effectiveness of Microsoft Windows Mobile and
Embedded newsgroups? Let us know!
https://www.windowsembeddedeval.com/community/newsgroups
 
N

Neville Lang

Peter,

Thanks for the quick response! I will try out your suggestions.

Regards,
Neville Lang
 
N

Neville Lang

Peter,

I have now found that the OnActivated event is not called when the power
button is pressed. I guess since the app is running and was the one that was
running when the power button was last pressed, the OnActivated is not
called. I tested that it is called when I switch to another app and switch
back again - my test code was called so it proves that this part does work.

I will now try your MessageWindow suggestion.

Regards,
Neville Lang
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top