title: Creating a button in c++ with winapi in a child window doesn't work
body: <p>I want to create a window with two child windows. In both child windows should be a button, but it doesn't show me the buttons and i don't know why. Here is my code:</p>
  <pre><code>
  #include &quot;framework.h&quot;
  #include &quot;projectnameTest.h&quot;
  
  wchar_t* convertCharArrayToLPCWSTR(const char* charArray)
  {
      wchar_t* wString = new wchar_t[4096];
      MultiByteToWideChar(CP_ACP, 0, charArray, -1, wString, 4096);
      return wString;
  }
  
  #define MAX_LOADSTRING 100
  
  constexpr unsigned int bWindowOne = 110; 
  constexpr unsigned int bWindowTwo = 111;
  
  
  HINSTANCE hInst;                               
  bool endloop = false;
  HWND hWnd, hWndOne, hWndTwo;
  HWND hButtonWindowOne, hButtonWindowTwo;
  
  
  const char szWindowOneClass[] = &quot;WindowOneClass&quot;;
  const char szWindowOneTitel[] = &quot;WindowOneTitel&quot;;
  
  const char szWindowTwoClass[] = &quot;WindowTwoClass&quot;;
  const char szWindowTwoTitel[] = &quot;WindowTwoTitel&quot;;
  
  LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);
  LRESULT CALLBACK    WndOneProc(HWND, UINT, WPARAM, LPARAM);
  LRESULT CALLBACK    WndTwoProc(HWND, UINT, WPARAM, LPARAM);
  
  int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
                       _In_opt_ HINSTANCE hPrevInstance,
                       _In_ LPWSTR    lpCmdLine,
                       _In_ int       nCmdShow)
  {
  
      WNDCLASSEXW wcex;
      const char szAppClass[] = &quot;AppClass&quot;;
      const char szAppTitel[] = &quot;AppTitel&quot;;
  
      wcex.cbSize = sizeof(WNDCLASSEX);
      wcex.style = CS_HREDRAW | CS_VREDRAW;
      wcex.lpfnWndProc = WndProc;
      wcex.cbClsExtra = 0;
      wcex.cbWndExtra = 0;
      wcex.hInstance = hInstance;
      wcex.hIcon = NULL;
      wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
      wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
      wcex.lpszMenuName = NULL;
      wcex.lpszClassName = convertCharArrayToLPCWSTR(szAppClass);
      wcex.hIconSm = NULL;
  
      RegisterClassExW(&amp;wcex);
  
      wcex.lpszClassName = convertCharArrayToLPCWSTR(szWindowOneClass);
      wcex.lpfnWndProc = WndOneProc;
      wcex.hIcon = NULL;
  
      RegisterClassExW(&amp;wcex);
  
      wcex.lpszClassName = convertCharArrayToLPCWSTR(szWindowTwoClass);
      wcex.lpfnWndProc = WndTwoProc;
      
      RegisterClassExW(&amp;wcex);
      
      hWnd = CreateWindowExW(NULL,
          convertCharArrayToLPCWSTR(szAppClass),
          convertCharArrayToLPCWSTR(szAppTitel),
          (WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU),
          200,
          150,
          500,
          500,
          NULL,
          NULL,
          hInstance,
          NULL);
  
      
      
  
      ShowWindow(hWnd, nCmdShow);
      UpdateWindow(hWnd);
  
  
      MSG msg;
  
      while (false == endloop)
      {
          if (GetMessage(&amp;msg, NULL, 0, 0))
          {
              TranslateMessage(&amp;msg);
              DispatchMessage(&amp;msg);
          }
  
      }
  
      return 0;
  }
  
  LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  {
      static PAINTSTRUCT ps;
  
      switch (message)
      {
      case WM_CREATE:
      {
          ::hWndOne = CreateWindowExW(NULL,
              convertCharArrayToLPCWSTR(szWindowOneClass),
              convertCharArrayToLPCWSTR(szWindowOneTitel),
              (WS_CHILD | WS_VISIBLE | WS_DLGFRAME),
              10,
              10,
              120,
              120,
              hWnd,
              NULL,
              ((LPCREATESTRUCT)lParam)-&gt;hInstance,
              NULL);
      
          ::hWndTwo = CreateWindowExW(NULL,
              convertCharArrayToLPCWSTR(szWindowTwoClass),
              convertCharArrayToLPCWSTR(szWindowTwoTitel),
              (WS_CHILD | WS_VISIBLE | WS_DLGFRAME),
              300,
              10,
              120,
              120,
              hWnd,
              NULL,
              ((LPCREATESTRUCT)lParam)-&gt;hInstance,
              NULL);
  
      }
      case WM_PAINT:
          {
              HDC hdc = BeginPaint(hWnd, &amp;ps);
              EndPaint(hWnd, &amp;ps);
          }
          break;
      case WM_DESTROY:
          PostQuitMessage(0);
          ::endloop = true;
          break;
      default:
          return DefWindowProc(hWnd, message, wParam, lParam);
      }
      return 0;
  }
  
  LRESULT CALLBACK WndOneProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  {
      static HDC hdc;
      static PAINTSTRUCT ps;
  
      switch (message)
      {
      case WM_CREATE:
      {
          ::hButtonWindowOne = CreateWindowExW(NULL, L&quot;BUTTON&quot;, L&quot;ButtonWindowOne&quot;, NULL, 10, 10, 40, 20, hWnd, (HMENU)bWindowOne, GetModuleHandle(NULL), NULL);
  
      }
      case WM_PAINT:
      {
          hdc = BeginPaint(hWnd, &amp;ps);
          EndPaint(hWnd, &amp;ps);
      }
      break;
      case WM_DESTROY:
          PostQuitMessage(0);
          break;
      default:
          return DefWindowProc(hWnd, message, wParam, lParam);
      }
      return 0;
  }
  
  LRESULT CALLBACK WndTwoProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  {
      static HDC hdc;
      static PAINTSTRUCT ps;
  
      switch (message)
      {
      case WM_CREATE:
      {
          ::hButtonWindowOne = CreateWindowExW(NULL, L&quot;BUTTON&quot;, L&quot;ButtonWindowOne&quot;, NULL, 10, 10, 40, 20, hWnd, (HMENU)bWindowOne, GetModuleHandle(NULL), NULL);
  
      }
      case WM_PAINT:
      {
          hdc = BeginPaint(hWnd, &amp;ps);
          EndPaint(hWnd, &amp;ps);
      }
      break;
      case WM_DESTROY:
          PostQuitMessage(0);
          break;
      default:
          return DefWindowProc(hWnd, message, wParam, lParam);
      }
      return 0;
  }
  </code></pre>
  <p>So I've already tried to create the button in the main window, and it worked, but i don't get why it just doesn't show the button in the child windows, altough it is almost identical. Thank you for your help.</p>