title: Create a container in win32 API
body: <p>I am a beginner in Win32 API. I am trying to create a little application that requires a container, but I have problems doing it.</p>
  
  <p>In HTML, I will show you what I want. Its the following code:</p>
  
  <pre class="lang-css prettyprint-override"><code>div{width:120px; height:300px; display:block; overflow-y:auto;}
  button{display:list-item;list-style:none; margin-bottom:3px;}
  </code></pre>
  
  <pre class="lang-html prettyprint-override"><code>&lt;div class="container"&gt;
    &lt;button&gt;button 1&lt;/button&gt;
    &lt;button&gt;button 2&lt;/button&gt;
    &lt;button&gt;button 3&lt;/button&gt;
    &lt;button&gt;button 4&lt;/button&gt;
    &lt;button&gt;button 5&lt;/button&gt;
    &lt;button&gt;button 6&lt;/button&gt;
    &lt;button&gt;button 7&lt;/button&gt;
    &lt;button&gt;button 8&lt;/button&gt;
    &lt;button&gt;button 9&lt;/button&gt;
    &lt;button&gt;button 10&lt;/button&gt;
    &lt;button&gt;button 11&lt;/button&gt;
    &lt;button&gt;button 12&lt;/button&gt;
    &lt;button&gt;button 13&lt;/button&gt;
    &lt;button&gt;button 14&lt;/button&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I have tried to repeat the same display in C++ using this code:</p>
  
  <pre><code>#include &lt;windows.h&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  
  const char *ClsName = "classname";
  const char *WndName = "Windows";
  HINSTANCE hInst;
  
  LRESULT CALLBACK WndProcedure(HWND hWnd, UINT uMsg,
      WPARAM wParam, LPARAM lParam);
  
  int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
      LPSTR lpCmdLine, int nCmdShow)
  {
      MSG        Msg;
      HWND       hWnd;
      WNDCLASSEX WndClsEx;
  
      hInst = hInstance;
  
      // Create the application window
      WndClsEx.cbSize = sizeof(WNDCLASSEX);
      WndClsEx.style = CS_HREDRAW | CS_VREDRAW;
      WndClsEx.lpfnWndProc = WndProcedure;
      WndClsEx.cbClsExtra = 0;
      WndClsEx.cbWndExtra = 0;
      WndClsEx.hIcon = LoadIcon(NULL, IDI_QUESTION);
      WndClsEx.hCursor = LoadCursor(NULL, IDC_ARROW);
      WndClsEx.hbrBackground = (HBRUSH)GetStockObject(WHITE_PEN);
      WndClsEx.lpszMenuName = MAKEINTRESOURCEA(109);
      WndClsEx.lpszClassName = ClsName;
      WndClsEx.hInstance = hInst;
  
      WndClsEx.hIconSm = LoadIcon(NULL, IDI_QUESTION);
      // Register the application
      RegisterClassEx(&amp;WndClsEx);
  
      // Create the window object
      hWnd = CreateWindow(ClsName,
          WndName,
          WS_OVERLAPPEDWINDOW,
          CW_USEDEFAULT,
          CW_USEDEFAULT,
          CW_USEDEFAULT,
          CW_USEDEFAULT,
          NULL,
          NULL,
          hInst,
          NULL);
  
      // Find out if the window was created successfully
      if (!hWnd) // If the window was not created,
          return 0; // stop the application
  
                    // Display the window to the user
      ShowWindow(hWnd, SW_SHOWNORMAL);
      UpdateWindow(hWnd);
  
      // Decode and treat the messages
      // as long as the application is running
      while (GetMessage(&amp;Msg, NULL, 0, 0))
      {
          TranslateMessage(&amp;Msg);
          DispatchMessage(&amp;Msg);
      }
  
      return Msg.wParam;
  };
  //classname
  
  //classname
  using namespace std;
  
   LRESULT CALLBACK WndProcedure(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
       static HWND ws[50], st, sd;
       switch (msg) {
       case WM_DESTROY:
           PostQuitMessage(0); break;
       case WM_CREATE:
           sd = CreateWindow(ClsName, NULL, WS_CHILD | WS_VSCROLL |WS_HSCROLL| WS_BORDER | WS_VISIBLE, 10, 10, 200, 600, hwnd, NULL, hInst, NULL);//Container
           for (int i = 0; i &lt; 114; i++) {
           ws[i] = CreateWindow("Button", ("Button" + to_string(i)).c_str(), WS_VISIBLE | WS_BORDER | WS_CHILD, 10, 25*i + 10, 150, 20, sd, (HMENU)(i + 1), hInst, NULL); //Buttons
           };      
           break;
       default: return DefWindowProc(hwnd, msg, wparam, lparam); break;
       }
   }
  </code></pre>
  
  <p>With this code, I get a container that is infinitely repeated in the the main window.</p>
  
  <p>This is a screenshot of the result;</p>
  
  <p><a href="https://i.stack.imgur.com/MQpff.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MQpff.png" alt="image"></a></p>
  
  <p>I do not understand the result. It seems I have used a loop but I did not.</p>