title: C++ Create popup window
body: <p>I want to make a popup window appear when I hit a button that is located on the main window of my program. I have looked everywhere for popup window examples, and most answers just showed me how to make a window, buttt I already have a main window in my application.</p>
  
  <p>Basically the difficulty I am having is knowing where to put the new window class and code for my popup window(since I want the pop window to have different properties than my main one). Should it also be in the WinMain function or should it be in one of the cases in the CALLBACK WndProcedure section?</p>
  
  <p>some of the code I have for my window is:</p>
  
  <pre><code>WNDCLASSEX wc;
  HWND hwnd;
  MSG Msg;
  
  wc.cbSize        = sizeof(WNDCLASSEX);
  wc.style         = 0;
  wc.lpfnWndProc   = WndProc;
  wc.cbClsExtra    = 0;
  wc.cbWndExtra    = 0;
  wc.hInstance     = hInstance;
  wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
  wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
  wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
  wc.lpszMenuName  = NULL;
  wc.lpszClassName = g_szClassName;
  wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
  
  if(!RegisterClassEx(&amp;wc))
  {
      MessageBox(NULL, "Window Registration Failed!", "Error!",
          MB_ICONEXCLAMATION | MB_OK);
      return 0;
  }
  
  hwnd = CreateWindowEx(
      WS_EX_CLIENTEDGE,
      g_szClassName,
      "The title of my window",
      WS_OVERLAPPEDWINDOW,
      CW_USEDEFAULT, CW_USEDEFAULT, 240, 120,
      NULL, NULL, hInstance, NULL);
  
  if(hwnd == NULL)
  {
      MessageBox(NULL, "Window Creation Failed!", "Error!",
          MB_ICONEXCLAMATION | MB_OK);
      return 0;
  }
  
  ShowWindow(hwnd, nCmdShow);
  UpdateWindow(hwnd);
  </code></pre>
  
  <p>I just am not sure where to put it... Should it be placed in the code that is activated when the button is pressed, or should it stay in the WinMain function, together with the information of the other window?</p>
  
  <p>I hope you can understand my predicament, I am somewhat new to programming.</p>