• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# Managed DirectInput Event Problem

## Recommended Posts

I have a somewhat bizarre problem I was hoping you gurus might be able to help me with. I initialize DirectInput with event notification in the same way suggested in the SDK (below, from SDK):

private void frmUI_Load(object sender, System.EventArgs e)
{

eventFire = new AutoResetEvent(false);

// Create the device.
try
{
applicationDevice = new Device(SystemGuid.Mouse);
}
catch(InputException)
{
MessageBox.Show("Unable to create device. Sample will now exit.");
Close();
}
// Set the cooperative level for the device.
applicationDevice.SetCooperativeLevel(this, CooperativeLevelFlags.NonExclusive| CooperativeLevelFlags.Foreground);
// Acquire the device.
try{ applicationDevice.Acquire(); }
catch{}
}


However, I noticed a bizarre problem using a standard C# form. Whenever I *minimize* the window, my mouse event no longer fires after it is restored and I reacquire the device. Ever. If I alt-tab away from the window, however, the event keeps working after I reaquire the device. To try and figure out my problem, I loaded up the SDK example "scrawl" which utilizes the same standard C# form. I noticed that it has the EXACT SAME issue. So, to try and solve the problem, I loaded the C++ version of the same "scrawl" code. Inexplicably, it works perfectly. Anyone have any idea how I can get my event handler to recognize mouse movement after I minimize the form? [edited by - The Frugal Gourmet on May 28, 2003 9:07:48 PM]

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627654
• Total Posts
2978444

• 10
• 12
• 22
• 13
• 33