WPF controls inside Rhino 8 panel not receiving keyboard input

Claude AI find the solution

This is the real answer. McNeel developer Menno’s code from 2013 — and it still works. The fix is a HwndSource hook on the WPF control’s own window responding to WM_GETDLGCODE. It even cites the exact StackOverflow answer explaining the MFC blocker. Let me implement this cleanly:

Ran a command, read a file

Ran a command, read a file

Found the real fix — from McNeel’s own developer @menno. The entire solution is just this:

csharp

var source = HwndSource.FromVisual(_wpfControl) as HwndSource;
source.AddHook(WpfKeyboardHook);

// In the hook:
if (msg == WM_GETDLGCODE) {
    handled = true;
    return DLGC_WANTCHARS | DLGC_WANTARROWS | DLGC_HASSETSEL | DLGC_WANTTAB;
}
1 Like