Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Prevent Window Focus Change
Message
From
05/05/2009 15:34:52
 
 
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Environment versions
Environment:
C# 3.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01397901
Message ID:
01398005
Views:
40
>>I'm trying to help a disabled person with a small bit of code to help him play a game easier. He is limited to a trackball and a single button.
>>
>>Currently he uses the onscreen keyboard and has managed to play other games using it. I've created a small bit of code to try and make his live easier. It uses hover buttons for the keys. When the mouse pointer enters the button it sends key down, when it moves off the button it sends key up.
>>
>>I have that working and I think (or hope) he's going to like it. It worked pretty well when I tested it.
>>
>>I want to add one more piece of functionality to it. If he clicks while over my control, I want to send a different key stroke. Not a problem, I can do that. However, when I do that window focus shifts from the game to my control.
>>
>>I found this on MSDN:
>>
>>http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/48737c2b-7e6f-4ade-ac1c-7dd2f5cc2b88/
>>
>>That works to prevent my window from activating, but it still causes the game to loose focus. I can set the focus back to the game, but I would prefer if it just never lost focus.
>>
>>Anyone have any ideas on how you might do that?
>
>I wonder whether, instead of a button, it might be better to use a control from higher up the inheritance chain that doesn't implement the default click behaviour? Haven't got WPF in front of me but maybe ContentControl is far enough? Just a thought,
>Viv

Actually my hover buttons are just rectangles, so they don't have a default behavior. Good idea though, I added e.Handled to the PreviewMouseDown and that didn't help.

I can't give it a proper test till tomorrow, it may be OK the way it is with the game I am designing it for, but there are other ones that it would cause problems with.
Previous
Reply
Map
View

Click here to load this message in the networking platform