title: Detecting if paste event occurred inside a rich text box
body: <p>Is there a way by which we can find out if a clip board paste event occurred in a rich text box? This event would be used in order to do certain stuff, with the pasted block of text.</p>
  
  <p>thanks</p>
  
  <p>Here is my code</p>
  
  <pre><code> protected override void WndProc(ref System.Windows.Forms.Message m)
      {
          if (m.Msg == WM_PASTE)
          {
              OnPasteOccurred();
              MessageBox.Show("Pas");
          }
          if (m.Msg == 0x000F)
          {
              if (PaintControl)
              {
                  base.WndProc(ref m);
              }
              else
              {
                  m.Result = IntPtr.Zero;
              }
          }
          else
          {
              base.WndProc(ref m);
          }
      }
  </code></pre>
  
  <p><strong>Edit</strong></p>
  
  <p>I wish to do some syntax highlighting or indentation based on paste events, something which this particular <a href="http://www.codeproject.com/Articles/27744/Net-Script-Editor-C-Vb-net-Mini-IDE" rel="noreferrer">code editor</a> seems to be doing very efficiently. I don't know how it is doing it. Would require help in this particular direction. I am pretty sure that there must some native Win32 code or something like that can be intercepted. I have tried tracking down keys, mouse events and it is not pretty. </p>