MFC如何实现鼠标拖拽?
比如我按住左键不放,可以画图画线,直到松开后停止。不要只说个用OnLButtonDown,我要详细点的过程,或者是是按住左键,图片可以虽鼠标一起移动...
比如我按住左键不放,可以画图画线,直到松开后停止。
不要只说个用OnLButtonDown,我要详细点的过程,
或者是是按住左键,图片可以虽鼠标一起移动 展开
不要只说个用OnLButtonDown,我要详细点的过程,
或者是是按住左键,图片可以虽鼠标一起移动 展开
展开全部
bool g_bDrawFlag = false;
CPoint oldPoint;
void CTestDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
CDialog::OnLButtonDown(nFlags, point);
g_bDrawFlag = true;
oldPoint = point;
}
void CTestDlg::OnMouseMove(UINT nFlags, CPoint point)
{
CDialog::OnMouseMove(nFlags, point);
if(g_bDrawFlag)
{
CClientDC dc(this);
MoveToEx(dc,oldPoint.x, oldPoint.y, NULL);
LineTo(dc, point.x, point.y);
oldPoint = point;
}
}
void CTestDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
CDialog::OnLButtonUp(nFlags, point);
g_bDrawFlag = false;
}
CPoint oldPoint;
void CTestDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
CDialog::OnLButtonDown(nFlags, point);
g_bDrawFlag = true;
oldPoint = point;
}
void CTestDlg::OnMouseMove(UINT nFlags, CPoint point)
{
CDialog::OnMouseMove(nFlags, point);
if(g_bDrawFlag)
{
CClientDC dc(this);
MoveToEx(dc,oldPoint.x, oldPoint.y, NULL);
LineTo(dc, point.x, point.y);
oldPoint = point;
}
}
void CTestDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
CDialog::OnLButtonUp(nFlags, point);
g_bDrawFlag = false;
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询