MFC 滑鼠雙擊響應單擊事件
阿新 • • 發佈:2019-02-16
void CMainFrame::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CPen Newpen,*pOldPen;
CBrush Newbrush,*pOldBrush;
Newpen.CreatePen(PS_SOLID,3,RGB(75,0,130));//建立畫筆(畫筆風格,粗細,顏色)
Newbrush.CreateSolidBrush(RGB(255,215,0));//建立畫刷,可以設定畫刷的顏色
pOldPen=dc.SelectObject(&Newpen);//獲取畫筆
pOldBrush=dc.SelectObject(&Newbrush);//獲取畫刷
m_Rodius=sqrt((BeginPoint.x-EndPoint.x)*(BeginPoint.x-EndPoint.x) + (BeginPoint.y-EndPoint.y)*(BeginPoint.y-EndPoint.y));
if (m_No == 1)
{
dc.Ellipse(m_PointX-m_Rodius,m_PointY-m_Rodius,m_PointX+m_Rodius,m_PointY+m_Rodius);
}
else
{
UpdateWindow();
}
dc.SelectObject(pOldPen);
dc.SelectObject(pOldBrush);
Newpen.DeleteObject();
Newbrush.DeleteObject();
// Do not call CFrameWnd::OnPaint() for painting messages
}
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CPen Newpen,*pOldPen;
CBrush Newbrush,*pOldBrush;
Newpen.CreatePen(PS_SOLID,3,RGB(75,0,130));//建立畫筆(畫筆風格,粗細,顏色)
Newbrush.CreateSolidBrush(RGB(255,215,0));//建立畫刷,可以設定畫刷的顏色
pOldPen=dc.SelectObject(&Newpen);//獲取畫筆
pOldBrush=dc.SelectObject(&Newbrush);//獲取畫刷
m_Rodius=sqrt((BeginPoint.x-EndPoint.x)*(BeginPoint.x-EndPoint.x) + (BeginPoint.y-EndPoint.y)*(BeginPoint.y-EndPoint.y));
if (m_No == 1)
{
dc.Ellipse(m_PointX-m_Rodius,m_PointY-m_Rodius,m_PointX+m_Rodius,m_PointY+m_Rodius);
}
else
{
UpdateWindow();
}
dc.SelectObject(pOldPen);
dc.SelectObject(pOldBrush);
Newpen.DeleteObject();
Newbrush.DeleteObject();
// Do not call CFrameWnd::OnPaint() for painting messages
}