Jump to content
  • Advertisement

Archived

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

DragonRider

Mouse and dual monitor

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

Hi, I''ve got a very annoying problem here. My app runs in fullscreen mode using direct3d and directinput. Everything is fine.... except with systems equipped with more than one monitor (extended desktop). The mouse then still works in my app (im using 1 screen only), but the "Windows cursor" still exists and can travel from one screen to another behind my app window. What happens then is if I click while this cursor in shown in the second screen, my app loses focus and gets minimized. How do i correct that? Clipping the windows cursor to my own window? Disabling it? but how Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
I had exactly the same problem and I came up with a solution. Basically I had an underwater environment that I wanted to navigate with mouse and A-S-D-W standard keyboard commands. The function I used was like this:

// This checks the mouse position and updates the local variables accordingly. This is called on each render().
// This is done to support dual monitor, otherwise if OnMouse(mouse args) is used to wait for receiving a mouse
// movement, the update will never come if the mouse leaves the primary monitor and goes to the second one.
// Instead if the mouse is polled continously, going to other monitor can be detected immediately (mouse X
// becomes negative) and so it can be adjusted.
// This way the application would never loose the mouse focus. (which will cause a Direct3D crash if it happens)
private void checkMouse() {
Point pt = Cursor.Position; // get mouse position
mousePosX = pt.X ;
mousePosY = (pt.Y <1)? 1 : pt.Y ; // adjust y
if (mousePosX < 5) { // if mouse X is going out the left side of the primary screen, then centre it
...
pt.X = device.PresentationParameters.BackBufferWidth / 2 ;
mousePosX = pt.X ;
Cursor.Position = pt;
...
}
if (mousePosX > device.PresentationParameters.BackBufferWidth - 5 ) { // if going out from the right side adjust it too.
// (this also takes care of dual monitor situation if the seconday is placed on the right of primary)
...
pt.X = device.PresentationParameters.BackBufferWidth / 2 ;
Cursor.Position = pt;
mousePosX = pt.X ;
...
}
}


Basically I centred the cursor and reset the caculations required to see where the camera is pointing to. This way the mouse never leaves the primary screen.

Hope this helps.

Share this post


Link to post
Share on other sites
First, thanks for your reply.

Is Cursor an object representing your "home-made" cursor? If so, I already did that. I have my own cursor that I clip to my app window. This works well. But this damn windows cursor (the standard white arrow) that I have no use for still exists and roams around in both screens. I causes me problems when I click because both cursors will actually click (mine and windows''). Any way of getting rid of it??

Share this post


Link to post
Share on other sites
No, Cursor is not ''home made''. It is a standard class: System.Windows.Forms.Cursor

It has a static method Cursor.Position which you can get or set the position of the cursor. Another is Cursor.Hide() which displays or hides the cursor. You should certainly be able to do what you want using these to functions alone. Remember, you can''t click with a hidden cursor.

So why have you created a new cursor. the windows one just works fine and can be used in Direct3D anyway.

Share this post


Link to post
Share on other sites
Correct - for full screen apps you shouldnt be using the windows system cursor details as it should be switched off.

the responses above indicate 1) that it wasnt fullscreen for him and 2) the user is using c# which most people probabyl arent

Shrew

Share this post


Link to post
Share on other sites
AAAAAAAAAAAAAA slap me! anyone!!

You were right Useless Hacker! I was so sure I already tried that, but I just realised that I was actually messing around with the keyboard :o(

Anyway, thank you guys

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!