In my program on startup a splash window with a button appears. When this window is closed then I want the main app to be shown. My problems are that both windows are shown and when closing the splash window it causes both to close.
In my program on startup a splash window with a button appears. When this window is closed then I want the main app to be shown. My problems are that both windows are shown and when closing the splash window it causes both to close.
Close the splash screen from the main window's create event
Code:case WM_CREATE: // Do something, and finally: SendMessage(hWndSplash, WM_CLOSE, 0, 0); break;
I tried that and still didn't work as I want it to. This splash screen is suppose be closed by the button. Also, sending the WM_CLOSE message still causes both windows to close.
Let me guess, you're posting a WM_QUIT message somewhere in your splash screens window procedure? (Either SendMessage(hWnd, WM_QUIT, 0, 0) or PostQuitMessage(0))
Here's a quote from MSDN:
So if your code looks something like this:If the function retrieves a message other than WM_QUIT, the return value is nonzero.
If the function retrieves the WM_QUIT message, the return value is zero.
If there is an error, the return value is -1. For example, the function fails if hWnd is an invalid window handle or lpMsg is an invalid pointer. To get extended error information, call GetLastError.
Then GetMessage will return 0 when the WM_QUIT message is posted and your program will exit. Solution: Don't post a WM_QUIT message in your spash screens window procedure.Code:while (GetMessage(...) > 0) { TranslateMessage(&msg); DispatchMessage(&msg); }
You're right, Eibro, that was my problem. Thanks for the help