🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Moving a window without a title bar

Started by
1 comment, last by illuna 24 years, 9 months ago
I have the same problem!

Whenever the app receives WM_MOUSEMOVE, and the user is holding down the title area of my app, I move the position of the window.
It works ... BUT the window shakes, this is because whenever you manually move the window, it calls the WM_MOVEMOUSE again, causing the window to process double code and move twice in one mouse movement.

I guess you could implement a bool variable to tell the MOUSEMOVE message when it is ok to actually move the window. Maybe make it so it only moves the window every second time.


Anyone know of a better way to do it?

  Downloads:  ZeroOne Realm

Advertisement
Hi

An other problem ~_~; I need to move a window that doesn't have a title bar. So when I click down on the window, I keep in memory the pos (lParam of WM_LBUTTONDOWN), the prev_pos where I was at last click and the ancien_pos, an other variable I need.

Here is the code, it works so-so and the window is shaking a bit. Can anyone help? Email me at illuna@yahoo.com Thanks!

Illuna
-----

case WM_LBUTTONDOWN:
m_prev_mouse_pos.x = pos.x;
m_prev_mouse_pos.y = pos.y;
m_ancient_mouse_pos.x = pos.x;
m_ancient_mouse_pos.y = pos.y;

case WM_MOUSEMOVE:
if ((pos.x != m_ancient_mouse_pos.x) | | (pos.y != m_ancient_mouse_pos.y)){

RECT window_rect;
GetWindowRect(m_parent->gethwnd()),&window_rect);

delta_x = pos.x - m_prev_mouse_pos.x + window_rect.left;
delta_y = pos.y - m_prev_mouse_pos.y + window_rect.top;

memcpy(&m_ancient_mouse_pos, &m_prev_mouse_pos, sizeof(POINTS));
memcpy(&m_prev_mouse_pos, &pos, sizeof(POINTS));

MoveWindow(m_parent->gethwnd(), delta_x, delta_y, window_size.x, window_size.y, TRUE);
}

else
memcpy(&m_prev_mouse_pos, &m_ancient_mouse_pos, sizeof(POINTS));

Sometimes people make the simplest things difficult. Here is the way I do it:

case WM_MOUSEMOVE:

if( wParam == MK_LBUTTON )
SendMessage( hWnd, WM_NCLBUTTONDOWN, HTCAPTION, NULL );

return FALSE;

Thats all it takes.

This topic is closed to new replies.

Advertisement