Hi guys.
I'm writing a game in C++ and DirectX and I'm looking for a way to force the mouse to stay in the center of the window.
I tried this, but it doesn't seem to work. It doesn't give any errors, it simply does nothing.
[code=cpp]
RECT wRect;
GetWindowRect(h Wnd, &wRect);
COORD wCoord = {wRect.left + (CLIENT_WIDTH / 2), wRect.top + (CLIENT_HEIGHT / 2)};
SetConsoleCurso rPosition(
GetStdHandle ( STD_OUTPUT_HAND LE ),
wCoord
);
[/code]
I also tried to use the IDirect3DDevice 9::SetCursorPos ition method but that also did nothing.
[code=cpp]
RECT wRect;
GetWindowRect(h Wnd, &wRect);
d3dDevice->SetCursorPosit ion(
wRect.left + (CLIENT_WIDTH / 2),
wRect.top + (CLIENT_HEIGHT / 2),
D3DCURSOR_IMMED IATE_UPDATE
);
[/code]
Anybody know how I can do this?
I should add that I'm using DirectInput to capture the mouse. Don't think it matters, but then again, what do I know :P
I'm writing a game in C++ and DirectX and I'm looking for a way to force the mouse to stay in the center of the window.
I tried this, but it doesn't seem to work. It doesn't give any errors, it simply does nothing.
[code=cpp]
RECT wRect;
GetWindowRect(h Wnd, &wRect);
COORD wCoord = {wRect.left + (CLIENT_WIDTH / 2), wRect.top + (CLIENT_HEIGHT / 2)};
SetConsoleCurso rPosition(
GetStdHandle ( STD_OUTPUT_HAND LE ),
wCoord
);
[/code]
I also tried to use the IDirect3DDevice 9::SetCursorPos ition method but that also did nothing.
[code=cpp]
RECT wRect;
GetWindowRect(h Wnd, &wRect);
d3dDevice->SetCursorPosit ion(
wRect.left + (CLIENT_WIDTH / 2),
wRect.top + (CLIENT_HEIGHT / 2),
D3DCURSOR_IMMED IATE_UPDATE
);
[/code]
Anybody know how I can do this?
I should add that I'm using DirectInput to capture the mouse. Don't think it matters, but then again, what do I know :P
Comment