Sign in to follow this  
Galaximo

[.net] Mouse hidden but can still click 'x'

Recommended Posts

I'm running a fullscreen Managed DirectX application. I am hiding the mouse using System.Windows.Forms.Cursor.Hide(). Even though the mouse is hidden while in the game if you move the mouse towards the upper right corner of the screen or upper left and click it clicks the 'x' or the window icon respectively. This causes the device to be lost and crashes the app. I've tried looking for a way to keep the mouse restricted to the current window but couldn't find it. That may work if you know how to do it. Any ideas? Thanks.

Share this post


Link to post
Share on other sites
This might be considered a bad practice (or not a good idea), but why not just remove the close button from the form, or disable it by overriding the close button event handler?

Since your app is running fullscreen, I assume you have some other way of closing it (such as an in game menu)?

Share this post


Link to post
Share on other sites
do you care what the mouse position is? You can just do System.Windows.Forms.Cursor.Position = new Point(center of my form).

If you have a cursor in your game, you can just read the position first, difference it with the value that you normally set it to, and add that value to your internal cursor coordinates.

Share this post


Link to post
Share on other sites
Quote:
Original post by Galaximo
Actually, because the application's window isn't maximized, I'm clicking Visual Studio's 'x'. :)

Wait a second. You say you are clicking visual studio's close button, and it is causing your app to close?

If your app is crashing when you switch out of the app, you had probably best handle it in your program. Does the same thing happen when you alt+tab out of your app?

Share this post


Link to post
Share on other sites
Quote:
Original post by Moe
Quote:
Original post by Galaximo
Actually, because the application's window isn't maximized, I'm clicking Visual Studio's 'x'. :)

Wait a second. You say you are clicking visual studio's close button, and it is causing your app to close?
That's fairly normal if you're running the application from within Visual Studio (via the Debug menu).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this