title: Docking a child window to the parent window
body: <p>I need my 6 controls (child windows of the main window) to get larger when the main window gets resized by the user (dragging the corners).  I thought I could accomplish this by using the MoveWindow function to change the proportions of each child in the main window's WM_SIZE or WM_SIZING function.  Doing this made the Debug build go strange (multiple windows, image of the window sticking after exiting, etc).  The Release build ran fine but the child windows didn't change when I resized the main window.</p>
  
  <p>I found <a href="http://msdn.microsoft.com/en-us/library/ms632598%28v=VS.85%29.aspx#creating_enumerating_etc" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms632598%28v=VS.85%29.aspx#creating_enumerating_etc</a> used a different method of doing this: by enumerating all the child windows, and the enum callback function handling the window resizing through a unique ID assigned to every child.  Upon trying this myself, it made no difference to the controls when the main window got resized.</p>
  
  <p>Why isn't this working?</p>
  
  <p>In the main windows switch statement:</p>
  
  <pre><code>case WM_SIZING:
          GetClientRect(hwnd, &amp;hwndRect);
          EnumChildWindows(hwnd, EnumChildProc, (LPARAM)&amp;hwndRect);
          break;
  </code></pre>
  
  <p>The child enumerator callback function:</p>
  
  <pre><code>BOOL CALLBACK EnumChildProc(HWND hwndChild, LPARAM lParam)
  {
      LPRECT hwndRect = (LPRECT)lParam;
      switch(GetWindowLong(hwndChild, GWL_ID))
      {
          case ID_CHILD_LLABEL:
              MoveWindow(hwndChild, 0, 0, (hwndRect-&gt;right - hwndRect-&gt;left) - 30, 20,     false);
              break;
          case ID_CHILD_LDIR:
              MoveWindow(hwndChild, 12, 20, (hwndRect-&gt;right - hwndRect-&gt;left) - 40, 20,     false);
              break;
          case ID_CHILD_LLIST:
              MoveWindow(hwndChild, 12, 40, (hwndRect-&gt;right - hwndRect-&gt;left) - 40,         (hwndRect-&gt;bottom - hwndRect-&gt;top) - 238, false);
              break;
      }
  }
  </code></pre>