Sign in to follow this  

Moving a child window

This topic is 3318 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

Hi, I have a child window, which has no title bar or anything, and would like to implement my own moving code, so that when the user clicks on the area of the client window, they can then drag it. The problem im having is that the WM_MOUSEMOVE commands, dont seem to update often enough, and unless you move the mouse really slow, the cursor goes out of the window while you still have it clicked. im doing the following at the moment, and its behaving horrid, can anyone give me any pointers?
 case WM_MOUSEMOVE:
			
			 if(SelectedEvent)
			 {
				p1.x = p2.x = LOWORD(lParam);
				p1.y = p2.y = HIWORD(lParam);

				ClientToScreen(this->Handle, &p1); //convert this windows pos to screen space
				ScreenToClient(this->mhGraph, &p1); //convert the screen space, to the parent window, of the selected window
				SetWindowPos(SelectedEvent->Handle, 0,p1.x - 5, p1.y - 5, 0, 0, SWP_NOSIZE);
			 }
			 return 0;

		 case WM_LBUTTONDOWN:
			 MessageBeep(1);
			 SelectedEvent = this;
			 return 0;

		 case WM_LBUTTONUP:
			  SelectedEvent = 0;
			 return 0;


Share this post


Link to post
Share on other sites
WOuldn't it be possible to use a boolean to track the mouse button? so if you press the mouse button, you set the boolean to true and when you release the mousebutton you set the boolean to false. then, when you drag the mouse you can just check the current state of the button by checking the boolean.

In you code you do this by remembering the mousedown event, and then taking the mouse handle from that event. I would think the mousemove event would have it's own event with it's own handler, why not pass that one on to SetWindowPos. Since this event would hold the position of the mouse at the time of the move, instead of at the time of the mousedown event.

Share this post


Link to post
Share on other sites

This topic is 3318 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this