Click or drag to resize
SoWinGLWidgetAddHook Method
Adds an event handler that receives all messages dispatched to this window.

Namespace: OIV.Inventor.Win
Assembly: OIV.Inventor.Win (in OIV.Inventor.Win.dll) Version: 2024.2.2.0 (10.16.2.0)
Syntax
public void AddHook(
	SoWinGLWidgetWindowMessageHook hook
)

Parameters

hook
Type: OIV.Inventor.WinSoWinGLWidgetWindowMessageHook
The handler implementation (based on the WindowMessageHook delegate) that receives the window messages.
Remarks

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.

Examples
Example code Part 1:
C#
// 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);
Examples
Example code Part 2:
C#
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;
}
See Also