Oh yeah, and your method is flawed. With your method, the player can still accidentally move or close the window as GetWindowRect returns the rectangle including window border and controls. This is not a good method of trapping the mouse.

Thanks for trying to help, but you shouldn't merely parrot back some solution you saw in another thread without thinking if it really does work. I eventually got it to work with the following plugin function:

Code:
/* Captures the mouse */
DLLFUNC void wcmouse_trap()
{
	RECT rect;
	/* Get the rectangle and see if it is different */
	GetClientRect(ev->hWnd,&rect);
	/* Convert to the screen */
	ClientToScreen(ev->hWnd,(LPPOINT)&rect);
	ClientToScreen(ev->hWnd,(LPPOINT)&rect.right);
	/* Clip the rectangle */
	ClipCursor(&rect);
}



This confines the mouse cursor to the client area and not the entire window area so the user cannot accidentally click on the controls or resize the window.

It's just a matter of using mouse_force to look around.

I have created a plugin+C-Script that, when initialized, traps the mouse cursor with an initial pointer appearance of nothing in windowed mode for as long as the window as focus. If you ALT+TAB or otherwise lose the focus, the mouse is released and taken back when the window regains focus.

Last edited by WolfCoder; 03/22/10 08:28.