title: How to read the data from lParam (the pointers value)
body: <p>I made a small application that sends text to notepad via SendMessage and EM_REPLACESEL.</p>
  
  <p>Now I’m trying to hook notepad to get the EM_REPLACESEL value (the lParam value and in this case the “GET THIS TEXT” text).</p>
  
  <p><img src="https://i.stack.imgur.com/8scNL.jpg" alt="Picture from Spy++"></p>
  
  <p><strong>EDIT</strong>: See this picture: <a href="https://i.stack.imgur.com/8scNL.jpg" rel="nofollow noreferrer">http://i.stack.imgur.com/8scNL.jpg</a></p>
  
  <p>The hook works fine, my problem is to listen for the EM_REPLACESEL message and grab the value from the lParam.</p>
  
  <p>This code works fine, when messages are sent to notepad:</p>
  
  <pre><code>LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam) 
  {
      Beep (2000,100);
      return(CallNextHookEx(g_hHook, nCode, wParam, lParam));
  }
  </code></pre>
  
  <p>So now I want to intercept EM_REPLACESEL messages. This <strong>do not</strong> work:</p>
  
  <pre><code>LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam) 
  {
      if (nCode == EM_REPLACESEL)
      {
          Beep (2000,100);
      }
      return(CallNextHookEx(g_hHook, nCode, wParam, lParam));
  }
  </code></pre>
  
  <p>1)  How to listen for the EM_REPLACESEL message?</p>
  
  <p>2)  When I have gotten the message how to grab the lParam value and e.g. show it in a MessageBox. Something like this:</p>
  
  <pre><code>LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam) 
  {
      if (nCode == EM_REPLACESEL)
      {
          MSG *lpMsg;
          lpMsg = (MSG *) lParam;
          MessageBox(NULL,(LPCWSTR)lpMsg,NULL,NULL);
      }
      return(CallNextHookEx(g_hHook, nCode, wParam, lParam));
  }
  </code></pre>
  
  <p>Thanks</p>