Jump to content

  • Log In with Google      Sign In   
  • Create Account


Moving a window without a title bar


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 illuna   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 September 1999 - 02:52 PM

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));


Sponsor:

#2 SikCiv   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 September 1999 - 02:10 PM

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?


#3 Mike   Members   -  Reputation: 139

Like
Likes
Like

Posted 22 September 1999 - 02:52 PM

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.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS