How do you prevent a Smartphone (sorry, a Windows Mobile 6 Standard) device from falling asleep? I tried everything, including sending null keys:
keybd_event(VK_NONAME, 0, KEYEVENTF_SILENT, 0);
This nasty little trick works but also forces your backlight to the maximum and you may not want it. What I really want to do is mimick going to the Power Management applet and setting the "Display time out" to "Never". With this setting, your Smartphone device will never go to sleep. So how do you achieve this? It's actually quite easy.
The display time out value is stored on the device registry under:
All you have to do is set the Display value (DWORD) to -1 and make the system know that the value changed. How do you break the news? Simple again:
PostMessage(HWND_BROADCAST, WM_WININICHANGE, 0, 0);
If you use this in your application to avoid the device from falling asleep (I also call SystemIdleTimerReset and SHIdleTimerReset every few seconds), please remember to set the value back to the original value.
ListView Adventures – Auto-sizing Uneven Rows
5 weeks ago