bsp; return 0;
---- 3) 对OnDestroy函数修改:
void CTestmdiView::OnDestroy()
{
// 确保删除的是正确的视图及其绘制上下文
wglMakeCurrent(m_pCDC- >GetSafeHdc(), m_hRC);
if (m_hRC!=NULL)
::wglDeleteContext(m_hRC);
// destroy Win Device Context
if(m_pCDC)
delete m_pCDC;
..
//Todo: ..
}
---- 4)OnDraw()函数做如下修改:
void CTestmdiView::OnDraw()
{
..
//Todo: .
wglMakeCurrent(m_pCDC- >GetSafeHdc(), m_hRC);
if (pApp- >m_iCount%2==0)
{
//第偶数个视图, 画正方形
DrawSquare();
}
else
{
//第奇数个视图,画圆
DrawCircle();
}
//注意画完之后立即断开DC与RC的关联,
使其他视图在激活时能正确与RC相联
wglMakeCurrent(NULL, NULL);
}
---- 5)PreCreateWindow(CREATESTRUCT &cs)函数:
BOOL CTestmdiView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window
class or styles here by modifying
// the CREATESTRUCT cs
// OpenGL的要求:
cs.style |= WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
// MDI 应用的要求:
cs.lpszClass = AfxRegisterWndClass(CS_OWNDC |
CS_HREDRAW | CS_VREDRAW);
return CView::PreCreateWindow(cs);
}