没有焦点的MouseEvent [英] MouseEvent without focus

查看:114
本文介绍了没有焦点的MouseEvent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在开发.NET Framework 3.5,但遇到了一个问题:
有没有一种方法可以处理MouseEvent(MouseEnter,MouseMove等)而无需将焦点放在主窗口上?

感谢所有

Hi,
I''m developing for .NET Framework 3.5 and I''ve got a question:
is there a way to handle the MouseEvents (MouseEnter, MouseMove, ...) without focus on the main window?

Thanks to all

推荐答案

如果您没有回答,编辑您的帖子或对我的评论发表评论,请不要按"answer".

您可以使用Mouse.Capture方法捕获鼠标,然后在它从那里经过的控件之外跟踪它的位置.
Please don''t push ''answer'' if you''re not answering, edit your post, or comment on mine.

You can use the Mouse.Capture method to capture the mouse, and then track it''s position outside the control it was over from there.


如果窗口没有焦点.您可以创建一个全局鼠标钩并将其伪造,但是为什么要让您的应用程序与其他所有Windows应用程序不同?
The events are not going to occur if the window does not have focus. You can do a global mouse hook and fake them, but why would you want your app to behave differently to every other windows app ?


在我的WPF应用程序中,我遇到的问题一个带有一些按钮的工具栏.
当您单击一个按钮时,它会打开一个弹出窗口,而我想不单击就打开另一个按钮的弹出窗口,而是将鼠标悬停在该按钮上.
简而言之,我的工具栏应该像菜单栏一样工作,但是我不能插入某些菜单项,因为我需要在每个子项上使用ContextMenu.

问题是我的弹出窗口有焦点而不是窗口,所以我以为可以找到这种解决方案,但是我对其他所有解决方案都持开放态度.
The problem that in my WPF application, I''ve a ToolBar with some buttons.
When you click on a button it opens a popup, and I want to open the other button''s popups without clicking, but when the mouse is over the button.
In a few words, my toolbar should behave like a menu bar, but I can''t insert some menu items because I need a ContextMenu on each subitem.

The problem is that my popup has focus and not my window, so I thought this solution, but I''m opened to every other solution.


这篇关于没有焦点的MouseEvent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆