Good morning,
I am the developer of a medium sized PDA application that will be used out on the streets. The PDA will contain some vaguely sensitive data (names and addresses, etc). The encryption on the mobile database is already handled, however if someone got hold of the PDA whilst it was logged in they could happily go through the data until the battery died or they closed the application and had to log in again.
When the users access the PDA application they need to enter their username and PIN number. Version 1 of this software had an event hooked into every button in the system so that when the button was pressed, it updated a variable called LastActionTime. A timer ran on the main form and if that LastActionTime was more than 10 minutes ago then the system would throw up the login form again until the previous user/admin logged back in again (just like the windows lockout screen).
This worked fine... in a sense... the problem with that is that it was only handling buttons and wasn't handling the other controls, like ListViews, PictureBoxes, etc.
Is there any good way of achieving this? For example, is there a way I could extend a Windows Form Class to handle every single event and update that variable accordingly? Or can I do something windows-esque that would handle every single mouse event on the form?
To be completely concise, what I want to achieve is that when the PDA screen/buttons have not been touched for 10 minutes, the PDA will know this and allow me to fire my lockout method.
Any thoughts, help and guidance would be much appreciated.
Edit: I am using Compact Framework 2.0 on Windows Mobile 6.0, however the function needs to work on Windows Mobile 5.0 and above.
One possible solution is to rely on the PDA's entering power idle state. You can register a notification for this using OpenNETCF.WindowsCE.PowerManager.PowerIdle Event. In fact it is a good idea to take into account power management considerations. You can't expect your PDA to be in the same state all the time.
Another solution would be to monitor the inactive event of the input driver (See this link). However, this solution is very device specific.
Unfortunately there is no way in Windows CE to register a global mouse event hook.
The above were OS solutions. There is not an easy way to do it with extending Windows Form and Control classes. Probably you would need to extend all the controls you would be using. The easiest solution would be to implement the GetFocus method for all your controls and the form. You could reset your counter there.
By the way, in a desktop environment this can easily achieved with GetLastInputInfo.