I have also tried to do the similar thing two months before.
According to an example from "OpenGL SUPERBIBLE SE" by RICHARD WRIGHT, I could modify something and finish my task.
But, it seems the method I used is a bit different from yours. However, yours seems more stable coz the OpenGL screen in my simulation program will disappear after the other application's windows overlapped it. Should anyone interest in one done by me, plz email me. I will send you the program including the source in VC6.
just a quick side note...
Most people would I assume would be interested in using a second Opengl window on a dialog as well as a primary rendering context (generally created in a view). There are a couple of things you must do to make this work.
this is all basic stuff... so if your elite, don't bother.
I assume your looking at the tutorial.
add an OnCreate Message to your derived CWnd Class
add this code:
//create the rendering context in (HGLRC m_hGLContext)
if (CWnd::OnCreate(lpCreateStruct) == -1)
// TODO: Add your specialized creation code here
HDC hdc = ::GetDC(m_hWnd);
m_hGLContext = wglCreateContext(hdc) ;
add an OnDestroy Message to your derived CWnd Class
add this code:
//destroy the context
m_hGLContext = NULL;
(From here on this is confined to the OnPaint Message)
2.) get the view...
note, I am using a static cast, that is so I can get at the views HGLRC variable. Also this window(from my app) is located in a tab page in a Dialog Bar, which isn't exactly accessable from the view.
CImagin8App* pApp = (CImagin8App*) AfxGetApp();
CMainFrame* pFrameWnd = static_cast<CMainFrame*> ( pApp->GetMainWnd());
pDoc = static_cast<CImagin8Doc*>(pFrameWnd- >GetActiveDocument());
POSITION pos = pDoc- > GetFirstViewPosition();
pView = static_cast<CImagin8View*>(pDoc->GetNextView(pos));