我有一个基本的窗口程序,问题是当我尝试在消息循环已经启动后在新线程中创建一个窗口时,窗口显示一秒钟并消失。有人没有这个原因吗?可以在单独的线程中创建窗口吗?
     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(&msg, 0, 0, 0)) 
            {
                TranslateMessage(&msg);
                DispatchMessage(&msg); 
            }
            ::CloseHandle(threadHandle);
            return static_cast<int>(msg.wParam);
        }
        DWORD WINAPI StartUp(LPVOID lpParam) // new thread runs here
        {
             //code to create a new window... 
        }
到目前为止,我发现GetMessage(&msg, 0, 0, 0)如果当前线程中没有窗口,则返回 false ......有没有办法解决这个问题?