title: Hooking Win32 windows creation/resize/querying sizes
body: <p>I'm trying to "stretch" an existing application.</p>
  
  <p><strong>The goal</strong> is to make an existing application become larger without changing the code of that application.<br>
  <strong>A cosntraint</strong> is that the stretched application will not "notice" it, so if the application query a created window size it'll see the original size and not the resized size.</p>
  
  <p>I managed to resize the windows using <em><code>SetWindowsHookEx</code></em>:</p>
  
  <pre><code>HHOOK hMessHook = SetWindowsHookEx(WH_CBT,CBTProc, hInst, 0);
  </code></pre>
  
  <p>And:</p>
  
  <pre><code>LRESULT CALLBACK CBTProc( __in  int nCode,
                            __in  WPARAM wParam, 
                            __in  LPARAM lParam)
  {
     if (HCBT_CREATEWND == nCode)
     {
        CBT_CREATEWND *WndData = (CBT_CREATEWND*) lParam;
        // Calculate newWidth and newHeight values...
        WndData-&gt;lpcs-&gt;cx = newWidth;
        WndData-&gt;lpcs-&gt;cy = newHeight;
     }
  
     CallNextHookEx(hMessHook, nCode, wParam, lParam);
  }
  </code></pre>
  
  <p>The problem I'm facing is that I'm unable to the make the stretched application see the original sizes.</p>
  
  <p>For example, if a .NET form is created:</p>
  
  <pre><code>public class SimpleForm : Form
  {
      public SimpleForm()
      {
          Width = 100;
          Height = 200;
      }
  }
  </code></pre>
  
  <p>And later the size is queried:</p>
  
  <pre><code>void QuerySize(SimpleForm form)
  {
     int width = form.Width;
     int height = form.Height;
  }
  </code></pre>
  
  <p>I'd like <em><code>width</code></em> and <em><code>height</code></em> be <code>100</code> and <code>200</code> and not the resized values. I was unable to find the right hook which queries the size of an existing window.</p>
  
  <p>What is the right way to hook window size querying?</p>