VC++下怎么实现Delphi BCB VB 中的Panel那种容器控件的效果
1个回答
展开全部
在View类中添加OnLButtonDown和OnLButtonUp函数
相应代码如下,LButtonDown中每一个/* */实现一种功能,是我以前照书上的写的,绝对能运行 你自己试下
void CDrawView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_ptOrigin=point;
CView::OnLButtonDown(nFlags, point);
}
void CDrawView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
/*
HDC hdc;
hdc=::GetDC(m_hWnd);
MoveToEx(hdc,m_ptOrigin.x,m_ptOrigin.y,NULL);
LineTo(hdc,point.x,point.y);
::ReleaseDC(m_hWnd,hdc);*/
/*
CDC *pDC=GetDC();
pDC->MoveTo(m_ptOrigin);
pDC->LineTo(point);
ReleaseDC(pDC);*/
/*
CClientDC dc(this);//view Ïà¹Ø
//CClientDC dc(GetParent());//mainFrameÏà¹Ø
dc.MoveTo(m_ptOrigin);
dc.LineTo(point);*/
/*
//CWindowDC dc(this);
//CWindowDC dc(GetParent());//·ÃÎÊ´°¿Ú °üÀ¨±êÌâÀ¸
CWindowDC dc(GetDesktopWindow());//·ÃÎÊÕû¸öÆÁÄ»
dc.MoveTo(m_ptOrigin);
dc.LineTo(point);*/
/*
CPen pen(PS_DASH,1,RGB(0,0,255));//DASH pen
CClientDC dc(this);
CPen *pOldPen=dc.SelectObject(&pen);
dc.MoveTo(m_ptOrigin);
dc.LineTo(point);
dc.SelectObject(pOldPen);*/
/*
CBrush brush(RGB(0,0,255));//画刷
CClientDC dc(this);
dc.FillRect(CRect(m_ptOrigin,point),&brush);*/
/*
CBitmap bitmap; //位图画刷
bitmap.LoadBitmap(IDB_BITMAP1);
CBrush brush(&bitmap);
CClientDC dc(this);
dc.FillRect(CRect(m_ptOrigin,point),&brush);*/
CClientDC dc(this);
//dc.Rectangle(CRect(m_ptOrigin,point));//矩形
CBrush *pBrush=CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH));
CBrush *pOldBrush=dc.SelectObject(pBrush);
dc.Rectangle(CRect(m_ptOrigin,point));
dc.SelectObject(pOldBrush);
CView::OnLButtonUp(nFlags, point);//透明矩形
}
相应代码如下,LButtonDown中每一个/* */实现一种功能,是我以前照书上的写的,绝对能运行 你自己试下
void CDrawView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_ptOrigin=point;
CView::OnLButtonDown(nFlags, point);
}
void CDrawView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
/*
HDC hdc;
hdc=::GetDC(m_hWnd);
MoveToEx(hdc,m_ptOrigin.x,m_ptOrigin.y,NULL);
LineTo(hdc,point.x,point.y);
::ReleaseDC(m_hWnd,hdc);*/
/*
CDC *pDC=GetDC();
pDC->MoveTo(m_ptOrigin);
pDC->LineTo(point);
ReleaseDC(pDC);*/
/*
CClientDC dc(this);//view Ïà¹Ø
//CClientDC dc(GetParent());//mainFrameÏà¹Ø
dc.MoveTo(m_ptOrigin);
dc.LineTo(point);*/
/*
//CWindowDC dc(this);
//CWindowDC dc(GetParent());//·ÃÎÊ´°¿Ú °üÀ¨±êÌâÀ¸
CWindowDC dc(GetDesktopWindow());//·ÃÎÊÕû¸öÆÁÄ»
dc.MoveTo(m_ptOrigin);
dc.LineTo(point);*/
/*
CPen pen(PS_DASH,1,RGB(0,0,255));//DASH pen
CClientDC dc(this);
CPen *pOldPen=dc.SelectObject(&pen);
dc.MoveTo(m_ptOrigin);
dc.LineTo(point);
dc.SelectObject(pOldPen);*/
/*
CBrush brush(RGB(0,0,255));//画刷
CClientDC dc(this);
dc.FillRect(CRect(m_ptOrigin,point),&brush);*/
/*
CBitmap bitmap; //位图画刷
bitmap.LoadBitmap(IDB_BITMAP1);
CBrush brush(&bitmap);
CClientDC dc(this);
dc.FillRect(CRect(m_ptOrigin,point),&brush);*/
CClientDC dc(this);
//dc.Rectangle(CRect(m_ptOrigin,point));//矩形
CBrush *pBrush=CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH));
CBrush *pOldBrush=dc.SelectObject(pBrush);
dc.Rectangle(CRect(m_ptOrigin,point));
dc.SelectObject(pOldBrush);
CView::OnLButtonUp(nFlags, point);//透明矩形
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询