GPS strategy and detecting minimized apps

H

Hilton

Hi,

Running CF 1.0:

If I leave the GPS thread running, it drains the battery. So, I need to
turn it on and off at the appropriate times. If I turn it on/off when
opening specific forms, it takes a few seconds to get up and running which I
don't really like. So, I'd like to start the thread when the app is
maximized (normal) and stop the thread when the app is minimized or closed.
But how do I detect when the app gets minimized? FormWindowState only has
Normal and Maximized, not Minimized. I tried IsWindowVisible(IntPtr hWnd)
but that always returned true.

If this is not the best strategy (or possible), what else can you suggest to
turn start/stop the GPS thread at the appropriate times?

Thanks,

Hilton
 
H

Hilton

I was planning on reading that article tonight - perfect/bad timing. :)
Thanks Chris and thanks again for making the PDF available.

Hilton
 
H

Hilton

Chris,

It looks like WindowWatcher is close to what I'd like, but not exactly. If
the user is running my app and it is being displayed, then he displays
another window (e.g. contacts, or IE etc) briefly, then minimizes that and
returns to my app, I'm assuming WindowWatcher will let us know that the PID
changed twice - once to IE, then back again to my app's PID. However, it
doesn't seem correct that I close the GPS, then re-open it in this case.

I *think* it makes more sense to detect minimize and restore only, not a
window being displayed on top on mine.

Having said that, I'm working on a solution that uses some of the code from
your example. I'll report back.

Hilton
 
C

Chris Tacke, eMVP

I don't know that in WinMo there's any difference between "minimized" and
some other window in fromnt of your. I think the "minimize" in WinMo is
actually just a "send to back of z-order" call.

You could always add a timer to it and only shut off the GPS if your app has
been in the back for some period of time.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com
 

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