I have a problem. I created a Window in a thread. I created a mutex so that the Window handle cannot be retrieved via a function until it is not 0.
I also used a while loop to make sure the handle is not 0.
Thing is, the handle is never 0 because CreateWindowEx returns a handle to the Window BEFORE the window is even displayed on screen.
So my mutex and while loop fails. I need to know when the window is fully displayed and finished doing whatever it has to do so I can draw on it from another thread.
The Handle is not 0, the DC is not 0. But when I draw, it draws nothing. If I put a Sleep(100) right after doing CreateWindowEx and ShowWindow, the window is displayed and the image is drawn to it correctly. I also tried while looping IsWindowVisisble(WindowHandle). That also fails.
I don’t want to sleep(100), what can I do?
Don’t try to draw on the window from another thread.
Post some data to the window and let it draw itself based on that data. It needs to be prepared to draw itself in response to a WM_PAINT anyway, and needs whatever data is necessary to do so in any case. Jumping through hoops to do the initial drawing differently is going to add a great deal of work and give you essentially nothing in return,.