描述:
如题。谢谢。控件怎样响应容器的mouse点击呢、我把它放到一个dialog中、在Lbuttondown中写代码 、可我移动到控件上面时没有触发Lbuttondown,请问要怎样做?
解决方案1:
void CMyView::OnDraw(CDC* pDC)
{
// Find the client area.
CRect rect;
GetClientRect(rect);
// Draw with a thick blue pen.
CPen penBlue(PS_SOLID, 5, RGB(0, 0, 255));
CPen* pOldPen = pDC->SelectObject(&penBlue);
// And a solid red brush.
CBrush brushRed(RGB(255, 0, 0));
CBrush* pOldBrush = pDC->SelectObject(&brushRed);
// Find the midpoints of the top, right, left, and bottom
// of the client area. They are the vertices of the polygon.
CPoint pts[4];
pts[0].x = rect.left + rect.Width()/2;
pts[0].y = rect.top;
pts[1].x = rect.right;
pts[1].y = rect.top + rect.Height()/2;
pts[2].x = pts[0].x;
pts[2].y = rect.bottom;
pts[3].x = rect.left;
pts[3].y = pts[1].y;
// Calling Polygon on the array draws three lines
// between the points and an additional line to
// close the shape from the last point to the first point.
pDC->Polygon(pts, 4);
// Put back the old objects.
pDC->SelectObject(pOldPen);
pDC->SelectObject(pOldBrush);
}
上MSDN,搜索polygon的例子
在列出的主题里找:“Step 1: Creating the Project”