diff --git a/include/osgViewer/api/Win32/GraphicsWindowWin32 b/include/osgViewer/api/Win32/GraphicsWindowWin32 index 1a95464a5..6fd9603fc 100644 --- a/include/osgViewer/api/Win32/GraphicsWindowWin32 +++ b/include/osgViewer/api/Win32/GraphicsWindowWin32 @@ -97,10 +97,11 @@ class OSGVIEWER_EXPORT GraphicsWindowWin32 : public osgViewer::GraphicsWindow /** WindowData is used to pass in the Win32 window handle attached the GraphicsContext::Traits structure.*/ struct WindowData : public osg::Referenced { - WindowData(HWND window): - _hwnd(window) {} + WindowData(HWND window, bool installEventHandler = true): + _hwnd(window), _installEventHandler(installEventHandler) {} HWND _hwnd; + bool _installEventHandler; }; /** Get native window.*/ diff --git a/src/osgViewer/GraphicsWindowWin32.cpp b/src/osgViewer/GraphicsWindowWin32.cpp index 525b69036..bb5b2e926 100644 --- a/src/osgViewer/GraphicsWindowWin32.cpp +++ b/src/osgViewer/GraphicsWindowWin32.cpp @@ -1242,14 +1242,19 @@ bool GraphicsWindowWin32::setWindow( HWND handle ) return false; } - if (!registerWindowProcedure()) + WindowData *windowData = _traits.get() ? dynamic_cast(_traits->inheritedWindowData.get()) : 0; + + if (!windowData || windowData->_installEventHandler) { - ::wglDeleteContext(_hglrc); - _hglrc = 0; - ::ReleaseDC(_hwnd, _hdc); - _hdc = 0; - _hwnd = 0; - return false; + if (!registerWindowProcedure()) + { + ::wglDeleteContext(_hglrc); + _hglrc = 0; + ::ReleaseDC(_hwnd, _hdc); + _hdc = 0; + _hwnd = 0; + return false; + } } Win32WindowingSystem::getInterface()->registerWindow(_hwnd, this);