句柄是以下面的方式传递给osgViewer::Viewer的,
osgViewer::View.getCamera().setGraphicsContext(osg::GraphicsContext);
下面是获得此句柄的方法。
这个句柄就是MFC CView的句柄。
// 向osg视图Viewer发送消息
void PostMsgToViewer(osgViewer::Viewer *pViewer,unsigned int msg,WPARAM wp,LPARAM lp)
{
osgViewer::ViewerBase::Windows windows;
pViewer->getViewerBase()->getWindows(windows);
if(windows.size()==0)
return;
osgViewer::GraphicsWindow *pWin = dynamic_cast<osgViewer::GraphicsWindow *>(windows(0));
PostMessage(pWin,msg,wp,lp);
// 句柄hwnd是以这种方式传递给Viewer的。
// osgViewer::View.getCamera().setGraphicsContext(osg::GraphicsContext);
}
void PostMsgToViewer(osgViewer::Viewer *pViewer,unsigned int msg,WPARAM wp,LPARAM lp)
{
osgViewer::ViewerBase::Windows windows;
pViewer->getViewerBase()->getWindows(windows);
if(windows.size()==0)
return;
osgViewer::GraphicsWindow *pWin = dynamic_cast<osgViewer::GraphicsWindow *>(windows(0));
PostMessage(pWin,msg,wp,lp);
// 句柄hwnd是以这种方式传递给Viewer的。
// osgViewer::View.getCamera().setGraphicsContext(osg::GraphicsContext);
}
url:http://greatverve.cnblogs.com/p/PostMsgToViewer.html
没有环境,代码可能不准确。