WPF WIN32 hwndhost WM_MOUSEMOVE WM_MOUSEHOVER

匆匆过客 提交于 2019-12-06 16:24:07

You need to handle WM_NCHITTEST. Until you do, it won't send you mouse messages.

// C++/CLI implementation of HwndHost.WndProc().
virtual IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, bool% handled) override
{
    switch (msg)
    {
        case WM_NCHITTEST:
        {
            handled = true;
        return IntPtr(HTCLIENT);
        }
    }

    return IntPtr::Zero;
}

It would appear that the Border element in WPF prevents the OnMouseLeftButtonDown being thrown. My temporary solution until I find a better one is to change the WPF border to a WPF button then all mouse events are triggered.

Not ideal for most people but as I am using it to render 3D onto it doesn't matter what is underneath it.

Why don't you register a WndClass and get messages delivered to your own WndProc instead of hooking the message pump? I suspect you'd get much better results.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!