If you have played any RTS(Real Time Strategy, ie. Starcraft, Age of Empires, Command & Conquer, etc.) game it's common knowledge you mainly move around the map by dragging your mouse to the edges of the window.  Well, I recently started playing an older RTS game, in windowed mode, and the mouse wasn't being locked within the application window which was really annoying.  Even when the game was fullscreen it wouldn't work because I have a dual screen setup.  After a quick Google search I stumbled upon an app called Cursor Lock.  The idea is simple, it locks your mouse cursor within the application window.  In my case I use a hotkey to turn on/off the cursor lock.  Below are the steps on how I set it up:

First download it from here and install it.

The first thing I did was set a hotkey to turn on/off the cursor lock.  I set it to something I wouldn't normally press during a game which is the Pause key.
Next go to Shortcut and select User Mode.  Then make sure to select the Lock Region checkbox and set it to Window Interior.
Again, this is for setting it up for a Windowed Mode game.  A fullscreen game when using more than one monitor may not use the same settings.

The Window option, as opposed to Window Interior, would allow you to resize the window since your mouse can move to the edges of the window, while the Window Interior option will just keep the mouse within the window which would prevent any resizing misclicks.

Once you have that setup you can test it to make sure it works.  Remember to trigger your hotkey if it doesn't lock within the Cursor Lock window.

Now that it works you click the Create Shortcut button and name it whatever you wish.  I saved the shortcut to my Desktop which I then copied over to my Startup folder (You can access the Startup folder by going to Start>All Programs>Right click the Startup folder and drag the shortcut into that folder).  Now when I boot into Windows the application will automatically run and I can trigger the hotkey whenever I want to lock the cursor.

Hope this helps.

*The Program Mode allows you to create a shortcut which will also open whichever game you assign.  I prefer to use a hotkey instead of having multiple game shortcuts.

 
Top