void EMap_Dlg::OnLButtonDown(UINT nFlags, CPoint point)
{
RECT rect;//将光标定义在视图区内
GetWindowRect(&rect); //返回的是屏幕坐标
ClipCursor(&rect); //针对屏幕坐标
GetParent()->ClientToScreen(&point);
oldpoint = point; //point 相对于当前窗口原点
lbutton_down = true;
movewindow = true;
CDialog::OnLButtonDown(nFlags, point);
}void EMap_Dlg::OnMouseMove(UINT nFlags, CPoint point)
{
ClipCursor(NULL);
if(lbutton_down)
{
CRect rect;//将光标定义在视图区内
GetWindowRect(&rect);
oldleftpoint.x = rect.left;
oldleftpoint.y = rect.top;
oldrightpoint.x = rect.right;
oldrightpoint.y = rect.bottom;
GetParent()->ScreenToClient(&rect);
GetParent()->ClientToScreen(&point);
int ix = point.x - oldpoint.x;
int iy = point.y - oldpoint.y;
rect.left = rect.left + ix;
rect.right = rect.right + ix;
rect.top = rect.top + iy;
rect.bottom = rect.bottom + iy;
ReSet_Wnd(rect); //判断视频窗口是否越界 是则重新设置窗口位置
ix = rect.left - oldrect.left;
iy = rect.top - oldrect.top;
GetParent()->RedrawWindow(&oldrect);
MoveWindow(&rect,true);
GetWindowRect(&rect); //返回的是屏幕坐标
ClipCursor(&rect); //针对屏幕坐标
oldrect = rect;
CentrePoint.x = CentrePoint.x + ix;
CentrePoint.y = CentrePoint.y + iy;
oldpoint = point;
// RedrawWindow();
// GetParent()->RedrawWindow();
// GetParent()->GetParent()->PostMessage(PaintLine,channel,0);
}
CDialog::OnMouseMove(nFlags, point);
}我用上面的方法能实现拖动但是不流畅 请高手指点啊
{
RECT rect;//将光标定义在视图区内
GetWindowRect(&rect); //返回的是屏幕坐标
ClipCursor(&rect); //针对屏幕坐标
GetParent()->ClientToScreen(&point);
oldpoint = point; //point 相对于当前窗口原点
lbutton_down = true;
movewindow = true;
CDialog::OnLButtonDown(nFlags, point);
}void EMap_Dlg::OnMouseMove(UINT nFlags, CPoint point)
{
ClipCursor(NULL);
if(lbutton_down)
{
CRect rect;//将光标定义在视图区内
GetWindowRect(&rect);
oldleftpoint.x = rect.left;
oldleftpoint.y = rect.top;
oldrightpoint.x = rect.right;
oldrightpoint.y = rect.bottom;
GetParent()->ScreenToClient(&rect);
GetParent()->ClientToScreen(&point);
int ix = point.x - oldpoint.x;
int iy = point.y - oldpoint.y;
rect.left = rect.left + ix;
rect.right = rect.right + ix;
rect.top = rect.top + iy;
rect.bottom = rect.bottom + iy;
ReSet_Wnd(rect); //判断视频窗口是否越界 是则重新设置窗口位置
ix = rect.left - oldrect.left;
iy = rect.top - oldrect.top;
GetParent()->RedrawWindow(&oldrect);
MoveWindow(&rect,true);
GetWindowRect(&rect); //返回的是屏幕坐标
ClipCursor(&rect); //针对屏幕坐标
oldrect = rect;
CentrePoint.x = CentrePoint.x + ix;
CentrePoint.y = CentrePoint.y + iy;
oldpoint = point;
// RedrawWindow();
// GetParent()->RedrawWindow();
// GetParent()->GetParent()->PostMessage(PaintLine,channel,0);
}
CDialog::OnMouseMove(nFlags, point);
}我用上面的方法能实现拖动但是不流畅 请高手指点啊
不知道是不是你要的效果