SoWinGLWidgetAddHook Method |
Namespace: OIV.Inventor.Win
Hooks are called in the order that they were added. If any hook returns handled= for a message, the hooks after it in the call order are not called for that message.
// Create viewer. Store in class member variable for visibility // in message hook and also to prevent the viewer from being // garbage collected. m_viewer = new SoWinExaminerViewer(this); . . . // Intercept low level Windows messages before viewer handles them. m_viewer.AddHook(WindowMessageHook);
private const int WM_KEYDOWN = 0x0100; private IntPtr WindowMessageHook(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam, ref bool handled) { // Prevent viewer from handling 'S' key. // Send it to the scene graph so OnKeyPress() can handle it. handled = false; if (msg == WM_KEYDOWN) { if (wparam.ToInt32() == 'S') // Key 'S' { handled = true; var evt = new SoKeyboardEvent(); evt.SetKey(SoKeyboardEvent.Keys.S); evt.SetState(SoButtonEvent.States.DOWN); m_viewer.GetSceneManager().ProcessEvent(evt); } } return IntPtr.Zero; }