NOTE: I AM TRYING TO SOLVE THE MOUSE ISSUE, NOT THE KEYBOARD PROBLEM, WHICH IS ALREADY SOLVED
So I am creating a Visual Studio 2015 extension, working on the Options pages.
I am using WPF, so I use ElementHost to host a UserControl. At first it wasn't receiving keyboard events, so I implemented the solution at:
WPF TextBox not accepting Input when in ElementHost in Window Forms
A quick run down of the solution:
A) on the UserControl's Loaded event, I do:
var s = HwndSource.FromVisual(this) as HwndSource;
s?.AddHook(ChildHwndSourceHook);
B) In ChildHwndSourceHook(), I do something like:
static IntPtr ChildHwndSourceHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
if (msg == WM_GETDLGCODE)
{
handled = true;
return new IntPtr(DLGC_WANTCHARS | DLGC_WANTARROWS | DLGC_HASSETSEL | DLGC_WANTTAB);
}
return IntPtr.Zero;
}
HOWEVER, now mouse over events seem to be being ignored, as the cursor doesn't change when moving it over textboxes or grid splitters, not even on new Windows I create. Very occasionally, though, the mouse events do work, though, and continue to work until I move to another page or close the dialog. That's the weirdest part.
I've tried everything and have scoured Google all day, but I am no closer to understanding why clicks work fine, but mouse over events don't seem to be registered.
I did try REMOVING the message handler, then opening a Window, but it seems once the handler is added, removing it won't fix anything.
Does anyone know how I can get mouse over events to work on my controls? Thanks so much!