microsoft / microsoft/WPF-Samples
WPFHostingWin32Control: cannot handle OnKeyDown events
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 5.7k
- Forks
- 3.3k
- Avg merge
- 12d 8h
- Merged PRs (30d)
- 2
Description
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in Migration and Interoperability/WPFHostingWin32Control, focusing on the WndProc override shown in the report. Reproduce the sample with keyboard and mouse input and trace whether messages reach that override. Done means identifying the missing input-routing step and documenting or correcting the sample so the relevant events are observable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100