Atli 5,058
Expert 4TB
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. -
RECT wRect;
-
GetWindowRect(hWnd, &wRect);
-
COORD wCoord = {wRect.left + (CLIENT_WIDTH / 2), wRect.top + (CLIENT_HEIGHT / 2)};
-
SetConsoleCursorPosition(
-
GetStdHandle ( STD_OUTPUT_HANDLE ),
-
wCoord
-
);
-
I also tried to use the IDirect3DDevice9::SetCursorPosition method but that also did nothing. -
RECT wRect;
-
GetWindowRect(hWnd, &wRect);
-
d3dDevice->SetCursorPosition(
-
wRect.left + (CLIENT_WIDTH / 2),
-
wRect.top + (CLIENT_HEIGHT / 2),
-
D3DCURSOR_IMMEDIATE_UPDATE
-
);
-
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
3 8437
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. -
RECT wRect;
-
GetWindowRect(hWnd, &wRect);
-
COORD wCoord = {wRect.left + (CLIENT_WIDTH / 2), wRect.top + (CLIENT_HEIGHT / 2)};
-
SetConsoleCursorPosition(
-
GetStdHandle ( STD_OUTPUT_HANDLE ),
-
wCoord
-
);
-
I also tried to use the IDirect3DDevice9::SetCursorPosition method but that also did nothing. -
RECT wRect;
-
GetWindowRect(hWnd, &wRect);
-
d3dDevice->SetCursorPosition(
-
wRect.left + (CLIENT_WIDTH / 2),
-
wRect.top + (CLIENT_HEIGHT / 2),
-
D3DCURSOR_IMMEDIATE_UPDATE
-
);
-
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 not sure if this might work but try the SetCusorPos function: -
SetCursorPos(CLIENT_WIDTH / 2, CLIENT_HEIGHT / 2);
-
Atli 5,058
Expert 4TB
I'm not sure if this might work but try the SetCusorPos function: -
SetCursorPos(CLIENT_WIDTH / 2, CLIENT_HEIGHT / 2);
-
That works perfectly!
Thanks very much.
That works perfectly!
Thanks very much.
Glad to help .
Sign in to post your reply or Sign up for a free account.
Similar topics
by: brian |
last post by:
Hi,
I am beginner using Python 1.52, GTK 1.2.10, and Glade .0.6.2 to
develop a gui which will kick off various scripts. After checking
some configurations I would like to pop up a window...
|
by: Csaba2000 |
last post by:
I have set onmousedown to change the cursor, but this setting is ignored
(IE 5.5; NN 6.1 on Win 2K Pro) until the mouse is either moved or the
mouse button is released. On Opera 7.01, the setting...
|
by: Yaron Cohen |
last post by:
Hi,
I would like to ask for your help (I am using only IE5.5).
I have a very big table that I would like to sort.
During the sort I would like the cursor changed to 'wait' state and
back to...
|
by: Phil |
last post by:
how do I force a window, pened alone, to be displayed in its frame set?
tried this:
if (parent.location.href == self.location.href) {
window.location.href = '../';
}
the problem is that...
|
by: Andrew Poulos |
last post by:
If I manage to call the following bit of javascript in IE and MZ
w = window.open("", "s", 'status=no,resizable=no,width=450,height=450');
I get a window that is not resizable and without a...
|
by: Bob |
last post by:
I am trying to create a popup page (to act as a menu) from a parent
page. When the parent page (index.jsp) calls my popup function (see
below) it will properly open the correct size browser window...
|
by: Geoff Cox |
last post by:
Hello,
Can I use JavaScript to force a maximised window ?
Thanks
|
by: Daniel Friend |
last post by:
Hi have a window (FormBorderStyle=NONE) and the form is a MDI child. For
some reason the form is not getting focus.
I have tried the following code and nothing seems to work.
sForm.Show()...
|
by: annagel |
last post by:
I am looking for a way to force a Tkinter window into focus on a system
level. I know the force focus method should bring one window of my
application into focus, but it seems I need to have some...
|
by: Jen |
last post by:
I've implemented single-instance functionality in my .exe by using the mutex
method. Works great. But when the .exe detects that it is not the first
instance I want to bring the main window of...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |