We need to record how much time a user may spend in a set of forms. The main challenge is to detect if the user is interacting with the app. So far, I’ve found this link (http://blog.opennetcf.com/ctacke/2009/05/19/DetectingApplicationIdle.aspx) provided an idea solution but our company is very conservative on open source/3rd party libraries. (I knew installing message filter at form level is another option but it may make the existing app unnecessarily complex. Ideally, I want to install message filter at app level.)
Thanks in advance for any idea or solution.
Windows Mobile sets a named event when the user interacts with the system. The name of the event is stored in:
HKLM\System\GWE\ActivityEvent. You can setup a thread to wait for this named event to be signaled and figure out if your form is active when the event was triggered. You can use GetForegroundWindow to determine if your window had focus while the event was set.Another possibility is to subclass your forms using GetWindowLong and SetWindowLong. That would cause all of the messages received by your form to be passed to a new WndProc function. You can check for activity messages (WM_LBUTTONDOWN, WM_LBUTTONUP, WM_COMMAND, etc.) in the WndProc function and then pass the messages back to the original WndProc using the CallWndProc function.