画出红色矩形框(还需修改)

void CVIDEO::OnLButtonDown(UINT nFlags, CPoint point)
{
 // TODO: 在此添加消息处理程序代码和/或调用默认值
 CMainFrame* pMainFrm = (CMainFrame *)AfxGetApp()->GetMainWnd();

 ClientToScreen(&point);
 CRect rect;
 GetDlgItem(IDC_STATIC1)->GetClientRect(rect);
 GetDlgItem(IDC_STATIC1)->ClientToScreen(rect);

 if ((pMainFrm->IsAviFile||pMainFrm->IsCamera)&&rect.PtInRect(point))
 {
  startPoint=point;
  endPoint=point;
  selection=cvRect(point.x,point.y,0,0);
  drawingflag=TRUE;
  if (playflag) KillTimer(1); 
 }
 CFormView::OnLButtonDown(nFlags, point);
}

void CVIDEO::OnMouseMove(UINT nFlags, CPoint point)
{
 // TODO: 在此添加消息处理程序代码和/或调用默认值
 if (!drawingflag)  
  return;   
 CClientDC   dc(this);  
 dc.DPtoLP(&point); //映射每个点的坐标,或大小的尺寸,到GDI的逻辑坐标系统的设备坐标系统。
 dc.SelectStockObject(NULL_BRUSH);   

 CPen pen, *oldPen;
 pen.CreatePen(PS_SOLID,1,RGB(255,0,0)); 
 oldPen =dc.SelectObject(&pen); 

 dc.SetROP2(R2_NOT);


 dc.MoveTo(startPoint);
 dc.LineTo(startPoint.x,endPoint.y);
 dc.MoveTo(startPoint.x,endPoint.y);
 dc.LineTo(endPoint);
 dc.MoveTo(endPoint);
 dc.LineTo(endPoint.x,startPoint.y);
 dc.MoveTo(endPoint.x,startPoint.y);
 dc.LineTo(startPoint);

 endPoint=point;
 dc.MoveTo(startPoint);
 dc.LineTo(startPoint.x,endPoint.y);
 dc.MoveTo(startPoint.x,endPoint.y);
 dc.LineTo(endPoint);
 dc.MoveTo(endPoint);
 dc.LineTo(endPoint.x,startPoint.y);
 dc.MoveTo(endPoint.x,startPoint.y);
 dc.LineTo(startPoint);

 dc.SelectObject(oldPen);
 
 CFormView::OnMouseMove(nFlags, point);
}

void CVIDEO::OnLButtonUp(UINT nFlags, CPoint point)
{
 // TODO: 在此添加消息处理程序代码和/或调用默认值
 if (drawingflag)  
 {
  drawingflag=false;   

  CClientDC   dc(this);   
  dc.DPtoLP(&point);   
  dc.SelectStockObject(NULL_BRUSH);   

  CPen pen, *oldPen; 
  pen.CreatePen(PS_SOLID,1,RGB(255,0,0)); 
  oldPen =dc.SelectObject(&pen); 

  dc.SetROP2( R2_COPYPEN );  
  dc.MoveTo(startPoint);
  dc.LineTo(startPoint.x,endPoint.y);
  dc.MoveTo(startPoint.x,endPoint.y);
  dc.LineTo(endPoint);
  dc.MoveTo(endPoint);
  dc.LineTo(endPoint.x,startPoint.y);
  dc.MoveTo(endPoint.x,startPoint.y);
  dc.LineTo(startPoint);

  dc.SelectObject(oldPen);

  selection.width=abs(point.x-selection.x);
  selection.height=abs(point.y-selection.y);
  selectionflag=-1;
  if(playflag) SetTimer(1,m_fps,NULL);
 }
 
 CFormView::OnLButtonUp(nFlags, point);
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值