Archived

This topic is now archived and is closed to further replies.

Ranger_One

Making a win32 window drag?

Recommended Posts

Ranger_One    300
Hi, I have an OpenGL window (no frame) and my own OpenGL rendered titlebar for it. Now i want to make it drag like a normal window-but I seem to have a problem with my code. Here is what I do (vc++ 6.0 and win32) On Mouse Button Down: - Store the Window X and Y with GetWindowRect(); - Store the mouse X and Y (in window) - Set the drag flag On Mouse Move & Drag Flag: - Figure the delta x and y for the mouse (from stored coords) - Map the window to the new position with MoveWindow(); - update the stored mouse X and Y so I can get another delta next mouse move ok- the problem I have is that the window trails- and it doesn''t move as fast as the mouse. Is there a way to get the mouse coords on a screen rect level? maybe that would help. Any ideas? Ranger

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Maybe you wanna try this. I got this idea from the skin program tutorial in flipcode.

case WM_LBUTTONDOWN:
SendMessage(hwnd, WM_NCLBUTTONDOWN, (WPARAM) HTCAPTION, (LPARAM) NULL);
break;

This makes the program believes that a left mouse click anywhere on the window is a click on the title bar.

Share this post


Link to post
Share on other sites
Ranger_One    300
not a bad idea- won''t work in this case since I need mouse input in the window.

however- I solved it =)

I needed to use GetCursorPos() to get the true mouse x and y in screen coords, the loss was occuring in the window move and window mouse position routines of windows.

Ranger

Share this post


Link to post
Share on other sites
a person    118
well actually, if you use the WM_MOUSEMOVE values, they are relative to your window. use ClientToScreen() (i think thats the function name) which will convert to screen coordinates you need. though if you got it working with GetCursorPos() then use that.

Share this post


Link to post
Share on other sites