Lock Mouse in primary screen [closed]
I have an application which use secondary monitor to display content. I dont want user to move curser to secondary monitor. I need to restrict the user to use mouse in primary monitor only. How can i do this.
Thanks
The following article describes creating a global hook: Global Hook (code project)
I think this is closer to what you're asking because you wouldn't want to continuously poll with GetCursorPos() function, mentioned in the other answer. However, using the hook and the MouseMove event handler, I would use SetCursorPos() to keep it within bounds.
Cheers,
Jonno
http://pinvoke.net/default.aspx/user32/GetCursorPos.html
http://pinvoke.net/default.aspx/user32/SetCursorPos.html
Use PInvoke to import the calls from the library and simply check the cursor position and adjust accordingly. You might need the resolution size of the monitor to check if it's within the bounds of the first or second screen.
精彩评论