COLORREF SetDCPenColor( HDC hdc, // handle to DC COLORREF crColor // new pen color );
SelectObject(hdc,GetStockObject(DC_PEN)); SetDCPenColor(hdc,RGB(00,0xff,00); Rectangle(0,0,20,20); SetDCPenColor(hdc,RGB(00,00,0xff)); Rectangle(0,0,20,20)// The brush color can be changed in a similar manner. SetDCPenColor // and SetDCBrushColor can be used interchangeably with GetStockObject // to change the current color. SelectObject(hDC,GetStockObject(DC_BRUSH)); SetDCBrushColor(hDC,0x0) // Provides the same flexibility as:SelectObject(hDC,GetStockOBject(BLACK_BRUSH));// It is not necessary to call DeleteObject to delete stock objects
HDC hdc, // handle to DC
COLORREF crColor // new pen color
);
SetDCPenColor(hdc,RGB(00,0xff,00);
Rectangle(0,0,20,20);
SetDCPenColor(hdc,RGB(00,00,0xff));
Rectangle(0,0,20,20)// The brush color can be changed in a similar manner. SetDCPenColor
// and SetDCBrushColor can be used interchangeably with GetStockObject
// to change the current color. SelectObject(hDC,GetStockObject(DC_BRUSH));
SetDCBrushColor(hDC,0x0) // Provides the same flexibility as:SelectObject(hDC,GetStockOBject(BLACK_BRUSH));// It is not necessary to call DeleteObject to delete stock objects
{
CImportDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
pDC->SetDCPenColor(RGB(255,0,0));
// TODO: 在此处为本机数据添加绘制代码}
编译提示
d:\Import\ImportView.cpp(54): error C2039: “SetDCPenColor” : 不是“CDC”的成员
Header: Declared in Wingdi.h; include Windows.h.
Library: Use Gdi32.lib.
COLORREF SetDCBrushColor(COLORREF crColor); COLORREF GetDCPenColor() const;
COLORREF SetDCPenColor(COLORREF crColor);#endif
所以,要设置:#define _WIN32_WINNT = 0x0500