简体   繁体   English

WPF中的托管窗口没有鼠标消息

[英]Hosted window in WPF doesn't get mouse messages

Taking it a bit further than hosting WinForms user controls in my WPF application, I am actually hosting Delphi forms, ie top level windows. 与在WPF应用程序中托管WinForms用户控件相比,我实际上托管了Delphi表单,即顶级窗口。 I am doing so through the voodoo in blog post How To Host Top-Level HWNDs In WPF . 我是通过博客文章“ 如何在WPF中托管顶级HWND”中的voodoo来这样做的。

Nearly everything works perfectly. 几乎所有东西都能完美运行。 I send a COM server, built in Delphi, a menu path string, and it sends back a window handle, which I pass to the host control described in the blog. 我发送一个内置于Delphi中的COM服务器,一个菜单路径字符串,然后它发回一个窗口句柄,并将其传递给博客中描述的主机控件。 The Delphi window receives nearly all events (rather, Windows Messages) correctly, without any intervention on my part. Delphi窗口几乎可以正确接收几乎所有事件(而不是Windows消息),而无需我任何干预。

The only problem is the buttons. 唯一的问题是按钮。 They receive a click event/message fine, and work, but now the Delphi guys have added new icons to the buttons, and each button has an active icon, a hover icon, and a click icon. 他们可以很好地接受单击事件/消息,并且可以正常工作,但是现在Delphi家伙已经向按钮添加了新图标,并且每个按钮都有一个活动图标,一个悬停图标和一个单击图标。 They receive none of the messages they should to change these icons. 他们没有收到应更改这些图标的任何消息。 Why do nearly all messages work except these? 为什么除了这些以外几乎所有消息都起作用? What can I read and or do to try and correct this? 我可以阅读和/或做些什么来尝试纠正此问题?

In MouseOver event, send some user message and catch it. 在MouseOver事件中,发送一些用户消息并捕获它。

WPF and Win32 Interoperation WPF和Win32互操作
HWNDs inside WPF > Notable Differences in Input behavior WPF中的HWND>输入行为的显着差异

While the mouse is over the HwndHost, your application does not receive WPF mouse events, and the value of the WPF property IsMouseOver will be false. 当鼠标悬停在HwndHost上时,您的应用程序不会收到WPF鼠标事件,并且WPF属性IsMouseOver的值将为false。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM