title: Hook WH_GETMESSAGE message
body: <p>I'm trying to hook <code>WH_GETMESSAGE</code> from my class to determine the moment when specific window is resizing. However, looks like the hook isn't set.</p>
  
  <p>Class from where I try to hook:</p>
  
  <pre><code>class WindowDisplayHelper : // public ...
  {    
  public:
      // some other public methods here
      void SetMsgHook();
  protected:
      LRESULT CALLBACK GetMsgProcHook(int code, WPARAM wParam, LPARAM lParam);
      static LRESULT CALLBACK MsgPoc(int code, WPARAM wParam, LPARAM lParam);
  private:
      // some other private members there
      HWND m_windowHandle;
      bool m_isWindowResizing = false;
      static HHOOK m_msgHook;
      static WindowsDisplayHelperMasterWindow* m_pThis;
  };
  </code></pre>
  
  <p>.cpp file:</p>
  
  <pre><code>WindowDisplayHelper* WindowDisplayHelper ::m_pThis = nullptr;
  HHOOK WindowDisplayHelper ::m_msgHook = NULL;
  
  void WindowDisplayHelper ::SetMsgHook()
  {
      m_pThis = this;
      m_msgHook = SetWindowsHookEx(WH_GETMESSAGE, MsgPoc, NULL, 0);
  }
  
  LRESULT CALLBACK WindowDisplayHelper::MsgPoc(int code, WPARAM wParam, LPARAM lParam)
  {
      if (m_pThis != nullptr)
      {
          return m_pThis-&gt;GetMsgProcHook(code, wParam, lParam);
      }
      return CallNextHookEx(0, code, wParam, lParam);
  }
  
  LRESULT CALLBACK WindowDisplayHelper::GetMsgProcHook(int code, WPARAM wParam, LPARAM lParam)
  {
      DUMPER_INFO("Hooked");
      if (code &lt; 0)
      {
          return CallNextHookEx(0, code, wParam, lParam);
      }
      MSG* lpmsg = (MSG*)lParam;
      DUMPER_INFO("Hooked for HWND: %p. Current window %p", lpmsg-&gt;hwnd, m_windowHandle);
      if (lpmsg-&gt;hwnd != m_windowHandle)
      {
          return CallNextHookEx(0, code, wParam, lParam);
      }
      if (lpmsg-&gt;message == WM_ENTERSIZEMOVE &amp;&amp; !m_isWindowResizing)
      {
          DUMPER_INFO("Start window resizing");
          m_isWindowResizing = true;
      }
      else if (lpmsg-&gt;message == WM_EXITSIZEMOVE &amp;&amp; m_isWindowResizing)
      {
          DUMPER_INFO("Stop window resizing");
          m_isWindowResizing = false;
      }
  
      return CallNextHookEx(0, code, wParam, lParam);
  }
  </code></pre>
  
  <p>Here is how I create WindowDisplayHelper object:</p>
  
  <pre><code>bool DisplayManager::CreateWindowDisplay(TDisplayId displayId, void * windowHandle)
  {
      auto helper = boost::make_shared&lt;WindowDisplayHelper&gt;(windowHandle);
      helper-&gt;SetMsgHook();
      AddDisplayHelper(displayId, helper);
  
      return true;
  }
  </code></pre>
  
  <p>Though I call SetMsgHook() after the object is created, looks like hook isn't set, because I don't see any debug outputs in my log file and <code>m_isWindowResizing</code> variable always == false. So the question is why my hook doesn't work?
  Thanks.</p>