MFC在控件上画图

1
2
3
4
5
6
7
8
9
10
11
12
13
14
CStatic* p;
p = (CStatic*)GetDlgItem(IDC_STATIC);
CRect rcStatic;
p->GetClientRect(&rcStatic);
HDC hdc = ::GetDC(*p);

HPEN hPen;
OLE_COLOR m_colOLE;
COLORREF m_colRREF;
m_colOLE = RGB(255, 0, 0);
OleTranslateColor(m_colOLE, NULL, &m_colRREF);
hPen = CreatePen(PS_SOLID, 3, m_colRREF);
SelectObject(hdc, hPen);
Rectangle(hdc, rcStatic.left, rcStatic.top, rcStatic.right, rcStatic.bottom);