Focus Window

Hello,

I want to focus a window when I have the mouse over the window. I tried focus() after putting focusable to true, but had no success, can anybody help me?

Thank you in advance,
Artur Carvalho

[212 byte] By [ArturBelico] at [2008-1-10]
# 1
I take it you subscribe to the IsMouseOver-event and then set Focus() in the EventHandler?
Frances83 at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 2
Yes
ArturBelico at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 3
Hmmm, you'd think that would work. Please post your code?
Frances83 at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 4
Thank you for the reply Frances.
I confused the events.I didnt use IsMouseOver. I used the MouseEnter event. Can you explain how you do that with IsMouseOver?

Best Regards,
Artur Carvalho

ArturBelico at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 5

IsMouseOver is a bool and not an event. If you are programmatically bringing the mouse over the window then you can do the following

If (IsMouseOver)

{

window.Focus();

}

SmithaBhat-MSFT at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 6
Thanks for your reply. Im not bringing the mouse over the window programatically.

Ill try to be more specific:

The application is activated when I use a shortcut, even when Im in another application. This shortcut triggers an event that is putting the window visible and in topmost. When Im over the window I want it to have focus so I can use the mouse wheel.

Im using mouse_enter event and it doesnt work. The intermediate solution I used was putting a dummy button so people click on it and the window gets focus. A bit weird, but it does the job.

Ill try to put the code online later.
Thanks again for your replies.

Artur Carvalho

ArturBelico at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 7
You can get the application here. Its not a big problem, but its still an annoyance.

Best Regards,
Artur Carvalho

ArturBelico at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 8
Have you tried the IsMouseDirectlyOver event already?
Bragi at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 9
Bragi, thx for the reply. IsMouseDirectlyOver is not an event, so I dont know how I can use it there. Can you explain to me how you would do it?

Thx,
Artur Carvalho

ArturBelico at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 10
My appoligies, I ment IsMouseDirectlyOverChanged.
Bragi at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...

Visual Studio Orcas

Site Classified