Skip to main content
GameDev.net gamedev.net
🔒 Locked

Compensating for window resizing

Started by _Phalanx_ Nov 5, 2004 at 8:08 PM 7 replies 1.2k views
Original Post
_Phalanx_
_Phalanx_
Hey, i am using these calls to get the cursor. However these calls return improper results when i resize the window, how do i account for this? If i cant, how to I disable window resizing? POINT MousePos; GetCursorPos(&MousePos); ScreenToClient(hWnd, &MousePos); The screen to client just comensates for moving the window, but not resizing it.
Wan
Wan
Quote:
However these calls return improper results when i resize the window, how do i account for this?


You mean while resizing the window?
Because I don't see how the coordinates of a mouse pointer relative to the client window change when resizing it.
Anyway, you can handle the change in cursor position at the WM_MOUSEMOVE command, I think you can figure out the position using the LPARAM and WPARAM.

Quote:
If i cant, how to I disable window resizing?


You could choose different window style flags.
Or, to be absolutely sure, capture the appropriate window message (I think it was something like WM_MINMAXINFO).

I'm sorry I'm so unclear about the actual window message constants and all, but I really have to go right now and have no time to check things. But I thought, what the heck, one more reply ;)
_Phalanx_
_Phalanx_
The problem is this: My back buffer is 600x900, the window is normally 600x900, but if the size changes, then the cursor coordinated will not longer be in 600x900. I need it to scale the results so that the coordinates are always inside my back buffer size. do you understand what I mean?
dsage
dsage
Can I ask what is wrong with using WM_MOVE and updating the clip list. As for window that cant be resized...

WS_OVERLAPPED | WS_CAPTION |			WS_VISIBLE    | WS_MINIMIZEBOX |WS_SYSMENU    | WS_BORDER,
_Phalanx_
_Phalanx_
could you explain that a bit better dsage, that went right over my head.
dsage
dsage
You could also use WM_MOUSEMOVE.

switch(msg){	case WM_MOUSEMOVE: // check for mouse x,y change	{		// get mouse x,y		mouseX = LOWORD(lparam);		mouseY = HIWORD(lparam);		if(wparam == MK_LBUTTON)		{			// if left mouse button down...		}	} break;}
dsage
dsage
Did this help?
DAN200
DAN200
I think what you're asking is how to scale you're client mouse co-ordinates to act like they were within the smaller window when they're in the bigger one.

The answer is simple multiplication.

Say your window is originally 800x600, and you ALWAYS want you're mouse co-ordinates to be 800 for the far right edge and 600 for the bottom, no matter the actual size of the window.

After you get your mouse co-ordinates do something like the following:

mouse.x = (mouse.x * 800) / windowwidth;
mouse.y = (mouse.y * 600) / windowwidth;
drekkar
drekkar
if you decide to go for the non resizing window you can just AND NOT WS_SIZEBOX and WS_MAXIMIZEBOX from whatever styles you are using
ex.
WS_OVERLAPPEDWINDOW & ~ (WS_SIZEBOX | WS_MAXIMIZEBOX)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.