19,468
社区成员
发帖
与我相关
我的任务
分享
CPoint pt1 = m_imgrect.TopLeft();//左上角点
CPoint pt2 = m_imgrect.BottomRight();//右下角点
CBrush brush;
brush.CreateSolidBrush(RGB(255, 0, 0));
CBrush* pOldBrush = pDC->SelectObject(&brush);
//矩形上边中间的那个小方框
pDC->Rectangle(CRect(pt1.dx + (pt2.dx - pt1.dx) / 2 - 4, pt1.dy - 4, pt1.dx + (pt2.dx - pt1.dx) / 2 + 4, pt1.dy + 4));
//矩形底边上那个小方框
pDC->Rectangle(CRect(pt1.dx + (pt2.dx - pt1.dx) / 2 - 4, pt2.dy - 4, pt1.dx + (pt2.dx - pt1.dx) / 2 + 4, pt2.dy + 4));
//矩形左边上那个小方框
pDC->Rectangle(CRect(pt1.dx - 4, pt1.dy + (pt2.dy - pt1.dy) / 2 - 4, pt1.dx + 4, pt1.dy + (pt2.dy - pt1.dy) / 2 + 4));
//矩形右边上那个小方框
pDC->Rectangle(CRect(pt2.dx - 4, pt1.dy + (pt2.dy - pt1.dy) / 2 - 4, pt2.dx + 4, pt1.dy + (pt2.dy - pt1.dy) / 2 + 4));
//矩形右上角那个小方框
pDC->Rectangle(CRect(pt2.dx - 4, pt1.dy - 4, pt2.dx + 4, pt1.dy + 4));
//矩形右下角那个小方框
pDC->Rectangle(CRect(pt2.dx - 4, pt2.dy - 4, pt2.dx + 4, pt2.dy + 4));
//矩形左上角那个小方框
pDC->Rectangle(CRect(pt1.dx - 4, pt1.dy - 4, pt1.dx + 4, pt1.dy + 4));
//矩形左下角那个小方框
pDC->Rectangle(CRect(pt1.dx - 4, pt2.dy - 4, pt1.dx + 4, pt2.dy + 4));
pDC->SelectObject(pOldBrush);
switch(m_nSizeFlag)//判断控制块的标志
{
case ALL_MOVE://移动
pt1.dx -= dx;
pt1.dy -= dy;
pt2.dx -= dx;
pt2.dy -= dy;
break;
case TOP_MIDDLE:
pt1.dy -= dy;
break;
case BOTTOM_MIDDLE:
pt2.dy -= dy;
break;
case LEFT_MIDDLE:
pt1.dx -= dx;
break;
case RIGHT_MIDDLE:
pt2.dx -= dx;
break;
case TOP_LEFT:
pt1.dx -= dx;
pt1.dy -= dy;
break;
case TOP_RIGHT:
pt1.dy -= dy;
pt2.dx -= dx;
break;
case BOTTOM_LEFT:
pt1.dx -= dx;
pt2.dy -= dy;
break;
case BOTTOM_RIGHT:
pt2.dx -= dx;
pt2.dy -= dy;
break;
}
m_imgrect.top = pt1.y;
m_imgrect.left = pt1.x;
m_imgrect.bottom = pt2.y;
m_imgrect.right = pt2.x;
int nPreMode = pDC->SetStretchBltMode(COLORONCOLOR);
m_pImage->Draw(pDC->GetSafeHdc(), m_imgrect.left, m_imgrect.top, m_imgrect.Width(), m_imgrect.Height(),
0, 0, m_pImage->GetWidth(), m_pImage->GetWidth());
pDC->SetStretchBltMode(nPreMode);