c++loggingmfcuser-activity

Implement user activity logger in old application?


How to go about implementing a user activity logger in MFC application.To get to know what are all the features are used most in an existing application.


Solution

  • You can override the windows procedure of your application window:

    class CMyMainWindow {
        void LogUsageData(UINT message);
        virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
              LogData(message);
              return CWnd::WindowProc(message, wParam, lParam); // route message to message map
         }
    }
    

    Note that the task is not so trivial: LogUsageData should discard most messages, focusing only on the ones defined in the message map.
    However, this should be a good place to start.