• Advertisement

Archived

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

Moving a window without a title bar

This topic is 6696 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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));

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement