Click here to Skip to main content
15,892,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Posted

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.
 
Share this answer
 
Comments
95ulisse 2-Jul-10 7:21am    
Thanks for your help! Mouse.Capture is perfect!

PS: I've learnt the lesson! :P
95ulisse 2-Jul-10 14:40pm    
Can I ask a favor?
Can you help me solving this other little problem? http://www.codeproject.com/Messages/3520567/Problem-ToolBar-overflow.aspx

Thanks for you help!
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 ?
 
Share this answer
 
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900