Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WPFHostingWin32Control: cannot handle OnKeyDown events #664

Open
juanmanzanero opened this issue Oct 12, 2024 · 0 comments
Open

WPFHostingWin32Control: cannot handle OnKeyDown events #664

juanmanzanero opened this issue Oct 12, 2024 · 0 comments

Comments

@juanmanzanero
Copy link

juanmanzanero commented Oct 12, 2024

Issue related to: https://github.com/microsoft/WPF-Samples/tree/main/Migration%20and%20Interoperability/WPFHostingWin32Control

Hello,

Thank you for this very complete solution to hosting a Win32 inside WPF. I am running into an issue: I want to handle Key Down/Up events ocurring inside the Win32 but I am failing to do so. These seem to get lost somewhere as I do not receive them in the 'WndProc' override

        protected override IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            switch (msg)
            {
                case (0x0100):
                case (0x0101):
                case (0x0102):
                case (0x0103):
                case (0x0104):
                case (0x0105):
                case (0x0106):
                case (0x0107):
                case (0x0109):
                    Trace.WriteLine("I am receiving keyboard inputs!");
                    break;
            }
            handled = false;
            return IntPtr.Zero;
        }

I happens the same with Mouse-related messages. Can someone explain to me what's missing?

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant