Child Window On Top of OpenGL
While working with the Windows API, I needed to display a child window over a parent window that was being drawn using OpenGL.
I was doing this because this was a program to assist my study of the Japanese language. I needed to be able to draw an arbitrary Unicode character, such as 私, at an arbitrary location. I also needed a text box control so I could enter text.
This was a 2D application with some continuously updated animation, and the problem I was getting was that the child window would flicker or not draw at all.
My first attempt to solve this problem was to use RedrawWindow function to try and force the child to draw over the top of parent window. This did not remove the flickering.
Finally I found the solution here: Win32 API: How to avoid flickering of basic window controls?
The solution was simply to add WS_CLIPCHILDREN to the parent window style flags when creating it.
Lessons learned besides the obvious: I searched quite a bit before I found the solution, trying various combinations of "OpenGL" "Child Window" "Over" "On Top" In the end I found it with "Windows API Redraw Window" and I was actually just trying to get more information about the "RedrawWindow" function. The takeaway lesson is when searching for a solution, try to find the broader problem you are having, rather than the specific. In this case, the fact I was using OpenGL to draw my parent window was not actually relevant in the solution. The fact that I was redrawing continuously, and that the child was flickering while I did so, was my root problem.












