|
我在MFC中创建一个对话框,其右侧动态创建了一个CView的子类CTDFlowView的实例,仿照osgViewerMFC那个例子,写了
int CTDFlowView::OnCreate( LPCREATESTRUCT lpCreateStruct )
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
MessageBox(_T("OnCreate"),_T("OnCreate"),MB_OK);
m_pOsg = new cOSG(m_hWnd);
m_pOsg->InitOSG("cow.osg");
mThreadHandle = (HANDLE)_beginthread( &cOSG::Render,0,m_pOsg);
TRACE(_T("CTDFlowView::OnCreate"));
return 0;
}
可是在对话框右侧仅出现了一片背景色深蓝色,没有出现那只可爱的牛,模型路径是没问题的,因为直接创建单文档工程时可以看到牛。
动态创建CTDFlowView的代码(在CMainDlg::OnInitDialog()函数中):
CCreateContext pContext;
CWnd* pFrameWnd = this;
pContext.m_pCurrentDoc = new CTDViewDoc;
pContext.m_pNewViewClass = RUNTIME_CLASS(CTDFlowView);
CTDFlowView *pView =(CTDFlowView *) ((CFrameWnd*)pFrameWnd)->CreateView(&pContext);
m_pFlowView =pView;
m_workflowRect.left = m_leftPanelRect.right +2 ;
m_workflowRect.right = rtClient.right -1 ;
m_workflowRect.top = TOP_PADDING ;
m_workflowRect.bottom = rtClient.Height();
m_pFlowView ->MoveWindow(m_workflowRect);
m_pFlowView->ShowWindow(SW_NORMAL);
求教各位前辈,O(∩_∩)O谢谢!
|
|