怎样用MFC编程实现画图板?
3个回答
展开全部
建立一个单文档的MFC 添加三个消息响应,WM_LButtonDown WM_LButtonUp WM_MouseMove
在消息响应函数里面添加代码如下即可:
void CDrawView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
Origin_Point=point;
flag=1;
CView::OnLButtonDown(nFlags, point);
}
void CDrawView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
flag=0;
CView::OnLButtonUp(nFlags, point);
}
void CDrawView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CClientDC dc(this);
CPen pen(PS_SOLID,2,RGB(0,255,0));
CPen *oldpen=dc.SelectObject(&pen);
if(flag==1)
{
dc.MoveTo(Origin_Point);
dc.LineTo(point);
Origin_Point=point;
}
dc.SelectObject(oldpen);
CView::OnMouseMove(nFlags, point);
}
在消息响应函数里面添加代码如下即可:
void CDrawView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
Origin_Point=point;
flag=1;
CView::OnLButtonDown(nFlags, point);
}
void CDrawView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
flag=0;
CView::OnLButtonUp(nFlags, point);
}
void CDrawView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CClientDC dc(this);
CPen pen(PS_SOLID,2,RGB(0,255,0));
CPen *oldpen=dc.SelectObject(&pen);
if(flag==1)
{
dc.MoveTo(Origin_Point);
dc.LineTo(point);
Origin_Point=point;
}
dc.SelectObject(oldpen);
CView::OnMouseMove(nFlags, point);
}
东莞大凡
2024-08-07 广告
2024-08-07 广告
OpenCV标定板是东莞市大凡光学科技有限公司在相机标定中常用的工具。它通常由黑白格点按一定规则排列在平面上组成,如棋盘格或圆形格等。在相机标定时,将标定板置于不同位置和姿态下拍摄图像,利用OpenCV库中的函数检测标定板上的角点或圆心,进...
点击进入详情页
本回答由东莞大凡提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询