Originally Posted By: CocaCola
@3run how do I lock the mouse in the engine window?
I do not want deactivate the engine window by klicked out of the window, by looks arround with the player.
, copy the code within the spoiler tags and call lockmouse(); or unlockmouse(); . Could be that you need to include #include <windows.h> or #include <stdio.h> .
Click to reveal..

byte mouse_lock_on_off = 0;
void lock_mouse(var on_off)
{
mouse_lock_on_off = (byte)(on_off != NULL);

byte _toggle = window_focus;

RECT temp_rect;
GetClientRect(hWnd, &temp_rect);
ClientToScreen(hWnd, &temp_rect);
ClientToScreen(hWnd, &temp_rect.right);

if(_toggle)
{
ClipCursor(&temp_rect);
}

while(mouse_lock_on_off)
{
GetClientRect(hWnd, &temp_rect);
ClientToScreen(hWnd, &temp_rect);
ClientToScreen(hWnd, &temp_rect.right);

if(_toggle && !window_focus)
{
_toggle = 0;
ClipCursor(NULL);
}

if(!_toggle && window_focus)
{
_toggle = 1;
ClipCursor(&temp_rect);
}

wait(1);
}

ClipCursor(NULL);
}


var mouse_lock = 0;
function lockmouse()
{
if (mouse_lock == 0) { mouse_lock = 1; lock_mouse(1); }
}
function unlockmouse()
{
if (mouse_lock == 1) { mouse_lock = 0; lock_mouse(0); }
}

Last edited by Reconnoiter; 03/31/16 19:21.