Re:OGRE放到mfc里面捕捉不到鼠标?
ExampleFrameListener::ExampleFrameListener() { ... LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***"); ParamList pl; #if 0 size_t windowHnd = 0; std::ostringstream windowHndStr;win->getCustomAttribute("WINDOW", &windowHnd); windowHndStr << windowHnd; pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str())); #endif unsigned long h = (unsigned long)AfxGetMainWnd()->GetSafeHwnd(); pl.insert(std::make_pair(std::string("WINDOW"), StringConverter::toString(h)); pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE"))); pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND"))); pl.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_NONEXCLUSIVE"))); pl.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_FOREGROUND"))); mInputManager = InputManager::createInputSystem( pl ); ... } 或者创建RenderWindow时不传视图窗口的handle,改传MainFrame的 NamevaluePairList miscParams; miscParams["externalWindowHandle"] = StringConverter::toString((unsigned int)AfxGetMainWnd()->GetSafeHwnd()); mWindow = mRoot->createRenderWindow( "View", 640, 480, false, &miscParams ); 这样,ois创建输入对象时使用RenderWindow::getCustomAttribute("WINDOW", &windowHnd);获取到也是mainframe的窗口的handle
|