• Advertisement
Sign in to follow this  

DirectInput Foreground CooperativeLevel

This topic is 4516 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The following code throws an "OtherApplicationHasPriorityException" on the call to Acquire():
using DI = Microsoft.DirectX.DirectInput;

DI.Device _keyboardDevice = null,

_keyboardDevice = new DI.Device(DI.SystemGuid.Keyboard);
_keyboardDevice.SetCooperativeLevel(form, DI.CooperativeLevelFlags.Foreground|DI.CooperativeLevelFlags.NonExclusive);
_keyboardDevice.Acquire();

I've found numerous posts around the web regarding this problem, but none had any satisfactory solutions. Using Background cooperative level instead of Foreground avoids the exception, but then my app receives input messages even when it is not the active form. An alternative solution would be to simply not process input if my app's form is not the active form, but I haven't found out how to do this yet. I would rather solve this via setting the cooperative level, though. Any thoughts?

Share this post


Link to post
Share on other sites
Advertisement
Its perfectly normal for a DInput app's calls to Acquire() to gracefully fail - you simply need to deal with it in an appropriate way and continue until the calls succeed.

If its not giving you the behaviour that you require then that's another matter.

Share this post


Link to post
Share on other sites
I've had the same problem with foreground, the window has to be visible before you call acquire.

Although i am using c++...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement