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

The Frugal Gourmet

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

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

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