Archived

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

Managed DirectInput Event Problem

This topic is 5313 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

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)
        {
            threadData = new Thread(new ThreadStart(this.MouseEvent));
            threadData.Start();

            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);
            // Set a notification event.    
            applicationDevice.SetEventNotification(eventFire);
            // 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]

Share this post


Link to post
Share on other sites