title: c++ creating a window in a new thread
body: <p>I have a basic window program, the problem is when i try to create a window in a new thread after the message loop has already started the window displays for a second and disappears. does anyone no the reason for this? can a window be created in a separate thread? </p>
  
  <pre><code>     int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) 
          {
             ::hInstance =hInstance; // initialize global variables
             ::nCmdShow =nCmdShow; 
  
              // start thread
              HANDLE threadHandle = startThread(StartUp); 
  
              MSG msg;
              while(GetMessage(&amp;msg, 0, 0, 0)) 
              {
                  TranslateMessage(&amp;msg);
                  DispatchMessage(&amp;msg); 
              }
              ::CloseHandle(threadHandle);
  
              return static_cast&lt;int&gt;(msg.wParam);
          }
  
          DWORD WINAPI StartUp(LPVOID lpParam) // new thread runs here
          {
               //code to create a new window... 
  
          }
  </code></pre>
  
  <p>what i figured out so far is that the <code>GetMessage(&amp;msg, 0, 0, 0)</code> returns false if there are no windows in the current thread that it is in... is there a way to get a round this? </p>