title: child dialog window inside a dialog window
body: <p>I want to create 2 dialog windows, one is a child of the other one. Below is part of the code.
  When I click the menu item "Parent", it created the 2 dialog and set one as a child of the other one, as the picture showed:</p>
  
  <p><img src="https://i.stack.imgur.com/i3M1j.png" alt="enter image description here"></p>
  
  <p>The problem is that they are both invisible. They have been sized as indicated by Spy++.
  Even if I use ShowWindow and UpdateWindow, it doesn't help.</p>
  
  <p>Here is my first queston:</p>
  
  <p><code>How to fix this?</code></p>
  
  <p>Now the reason I want do create child dialog windows is: Look at the following picture,</p>
  
  <p><img src="https://i.stack.imgur.com/zkwJP.png" alt="enter image description here"></p>
  
  <p>it has a Preference dialog which contains child dialogs (the bounded rectangle by black line). These child dialog windows are used to group related options. So if uses choose an item in the left side TreeView, it hides a child dialog window and show another child dialog window to provide different options.</p>
  
  <p>Now the second question:</p>
  
  <p><code>Is my code is the correct way to achieve such work?</code></p>
  
  <hr>
  
  <p>Update 2:</p>
  
  <p>Here is the solution!</p>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms644996%28v=vs.85%29.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/windows/desktop/ms644996%28v=vs.85%29.aspx</a></p>
  
  <hr>
  
  <p>Update:</p>
  
  <p>Thank you guys.</p>
  
  <p>After using <code>CreateDialog</code> (for child dialog) instead <code>DialogBox(...)</code>, using <code>DS_CONTROL</code> instead <code>WS_CHILD</code>, and remove <code>OK</code> button (and its corresponding wndproc) from child dialog, I got</p>
  
  <p><img src="https://i.stack.imgur.com/8GZqq.png" alt="enter image description here"></p>
  
  <p>I can even move the child dialog inside parent dialog. Remove <code>CAPTION "Child Dialog"</code> in the resource script file doesn't help.</p>
  
  <ol>
  <li><p>How (what flags should be used) to make Child Dialog fits in Parent Dialog seamlessly,? This means that : No title bar, no border...etc. (Use <code>SetWindowLong</code> and <code>WS_BORDER</code> after child dialog is created? Or something particulr for dialog?)</p></li>
  <li><p>The OK button of parent dialog doesn't work anymore. How to fix this? I don't understand how to manage the dialog procedures in this parent-child dialog case. Any reference for it?</p></li>
  </ol>
  
  <hr>
  
  <p>Here is my code:</p>
  
  <pre><code>1. Message handler for dialogs:
  
  INT_PTR CALLBACK Child(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  {
      UNREFERENCED_PARAMETER(lParam);
      switch (message)
      {
      case WM_INITDIALOG:
          {
              hChild = hDlg;
              return (INT_PTR)TRUE;
          }
      case WM_COMMAND:
          if (LOWORD(wParam) == IDOK)
          {
              EndDialog(hDlg, LOWORD(wParam));
              return (INT_PTR)TRUE;
          }
          break;
      }
      return (INT_PTR)FALSE;
  }
  
  INT_PTR CALLBACK Parent(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  {
      UNREFERENCED_PARAMETER(lParam);
      switch (message)
      {
      case WM_INITDIALOG:
          {
              hParent = hDlg;
              DialogBox(hInst, MAKEINTRESOURCE(IDD_CHILD), hParent, Child);
              SetParent(hChild, hParent);
              return (INT_PTR)TRUE;
          }
      case WM_COMMAND:
          if (LOWORD(wParam) == IDOK)
          {
              EndDialog(hDlg, LOWORD(wParam));
              return (INT_PTR)TRUE;
          }
      break;
      }
      return (INT_PTR)FALSE;
  }
  
  2. Dialog Templates in resource file
  
  IDD_CHILD DIALOGEX 0, 0, 70, 50
  
  
  STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
  CAPTION "Child Dialog"
  FONT 8, "MS Shell Dlg"
  BEGIN
      LTEXT           "Child Dialog",IDC_STATIC,10,5,35,8,SS_NOPREFIX
      DEFPUSHBUTTON   "OK",IDOK,10,25,50,14,WS_GROUP
  END
  
  IDD_DIALOG_PARENT DIALOGEX 0, 0, 250, 150
  STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
  CAPTION "Parent Dialog"
  FONT 8, "MS Shell Dlg"
  BEGIN
      LTEXT           "Parent",IDC_STATIC,42 - 20,14,35,8,SS_NOPREFIX
      DEFPUSHBUTTON   "OK",IDOK,188, 126,50,14,WS_GROUP
  END
  </code></pre>