Weird Paint / Focus problem

My program is a Windows MFC Application with multiple dialogs, where 2 of them are OpenGL windows, the first is just a picture that updates a few times a second the second plays video streamed from a few cameras in an angled view.

Both are inherited from CDialog, which another CDialog is their parent which has a timer that calls a tick function that invalidates each dialog

when i start my program up everything runs fine, i can see that both GL Dialogs are running at around 30fps,if i click on the first, everything is fine, they are updating fine. When i click on the second GL Dialog the first one stops updating, then i click on the first one again and it begins updating both fine. I’m pretty sure its not a CPU problem because the CPU stays at around 20-40% during this test.

Im thinking its something to do with the focus and invalidate(0) i call on the tick maybe the paint messages for the unfocused window gets thrown out because the second windows are more important? should i not be calling invalidate and just directly call my paint functions on tick?

Where have you placed the wglMakeCurrent() calls that switch between the different contexts?

I am calling “wglMakeCurrent(m_myhDC,m_hRC);” in my OnPaint function, it is also getting called once on startup when initially the window is setup.

Also when i click on a dialog(both have this function) i have this function( to select a GL object):

HDC hDC = ::GetDC(this->m_hWnd);
::ReleaseDC(this->m_hWnd, hDC);
//find out which object was clicked, where we got the samples for this:

wglMakeCurrent( NULL, NULL );
return # of hits

you’ve released you dc before finishing up with your context, which could very well be a source of considerable ungoodliness (unless maybe you have a cs_owndc class style or some such).

May be a good idea to consider alternatives to GL selection going forward, like color id or maybe even ray casting. Use ray casting myself and have no regrets.