Power control question

  • Thread starter Thread starter Tim Johnson
  • Start date Start date
T

Tim Johnson

I'm setting the backlight brightness values and screen-dimming timeouts ok,
by setting registry values then using the OpenNETCF CreateEvent and SetEvent
for "SDKBackLightChangeEvent" to make it take effect. Now I need to control
the power-off timeouts too. I have 2 questions:

1. I notice on my AudioVox PocketPC the SystemIdleTimerReset doesn't work.
It seems to be the case that this only works if "GWES is enabled", which I
think means you ONLY have the standard registry entries set in
HKLM/System/CurrentControlSet/Control/Power. If you ALSO have the
.../Control/Power/Timeouts keys set, as my device does, those take precedence
and cause the reset API call to do nothing. And making changes manually in
Settings/Power control panel only affects the Control/Power/Timeouts keys,
not the Control/Power keys. Is this common on many PocketPC devices?

Control/Power:
ExtPowerOff
BattPowerOff
WakeupPowerOff

vs.

Control/Power/Timeouts:
BattSuspendTimeout
ACSuspendTimeout

2. I can set the right registry keys, but what's the equivalent event
message I can send for power-timeout changes to make it take effect, as I do
for brightness changes?

--

Tim Johnson
High Point Software, Inc.
www.high-point.com
(503) 312-8625
 
Thanks, I'll try that. Seems a little odd though, doesn't that just send a
message to all top-level windows running? So it notifies running apps, but
all I really want to do is notify the operating system about the new power
control timeout settings. Doesn't seem like any other app would really care
about that, only the OS.

--

Tim Johnson
High Point Software, Inc.
www.high-point.com
(503) 312-8625
 
I tried that but it doesn't seem to actually take effect. I can see in the
registry that I've correctly changed the values, and when I bring up the
control panel in Settings/Power I see the settings I configured thru my
program. So for example everything shows it will power-down on either
battery or AC after 1 minute - but it never does.

Maybe it's the lParam I'm using in the following calls? I can't get a
straight story on what to use here, as in this example:

OpenNETCF.Win32.RegistryKey key;

//Set timeouts in /Power/Timeouts registry area

key = OpenNETCF.Win32.Registry.LocalMachine.OpenSubKey

(@"\System\CurrentControlSet\Control\Power\Timeouts", true);

key.SetValue("BattPowerOff", 60);

key.Close();

rc = PostMessage ( (System.IntPtr)HWND_BROADCAST, WM_SETTINGCHANGE, 0,
"Timeouts");

I do this for both the keys in /Power and the other keys in Power/Timeouts.
I have the correct dllimport and constants defined from other newsgroup
samples, and I can see a "true" value come back from the PostMessage call in
the debugger. I've used "Timeouts" and "Power" and "Environment" as lParam,
but still no actual behavior change on the PDA. Any suggestions?
--

Tim Johnson
High Point Software, Inc.
www.high-point.com
(503) 312-8625
 
I'd think LParam and WParam could both be zero. At this point the place I'd
go is to the source for the control panel applet itself that adjusts these
(part of Platform Builder). Typically they broadcast the event and the
shell itself catches it and knows to re-read registry values. Evidently it
doesn't work that way in this case.

-Chris
 
You do enough work that I'd recommend ordering the eval CDs from Microsoft.
It's something like $10 and is a 120 day eval, but you're using it for a
source reference, so that won't affect you.

-Chris
 
Excellent, thanks. And the 0's did seem to work, except no matter I do I
can't make the AudioVox PocketPC Phone Edition pda do a power-off while on
AC power. I think it's a model issue. Changing the Battery power timeout
works fine now though. For the app we're building I really needed control
of two things - before the user logs in but has started the app I want to
power-down after 1 minute; but after he logs in I never want to power down
because we're busy collecting GPS readings. Now I have almost all that, and
if it can't power-down while on AC power I guess that's not a big deal.

Thanks again.

--

Tim Johnson
High Point Software, Inc.
www.high-point.com
(503) 312-8625
 
Actually there is still a problem. The settings changes I make only take
effect AFTER I tap the screen. This applies to brightness, where the effect
is obvious, but also to power timeouts. So if I change the brightness from
bright to dim and change power timeout from never to 1 minute, but don't tap
the screen, then a) screen stays bright, and b) device never hibernates. If
I do the same change and tap the screen, the screen goes dim as requested
and then it hibernates after 1 minute. Any thoughts on this one?

--

Tim Johnson
High Point Software, Inc.
www.high-point.com
(503) 312-8625
 
Back
Top