SetDCPenColor应该怎么使用?为什么我在VC2003中使用时提示不是CDC类的函数,提示和MSDN上都说有这个函数.

解决方案 »

  1.   

    COLORREF SetDCPenColor(
      HDC hdc,          // handle to DC
      COLORREF crColor  // new pen color
    );
      

  2.   

    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
      

  3.   

    void CImportView::OnDraw(CDC* pDC)
    {
    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”的成员
      

  4.   

    MFC Library Reference   CDC::SetDCPenColor
    Header: Declared in Wingdi.h; include Windows.h.
    Library: Use Gdi32.lib.
      

  5.   

    注意:Included in Windows 2000 and later.#if (_WIN32_WINNT >= 0x0500) COLORREF GetDCBrushColor() const;
    COLORREF SetDCBrushColor(COLORREF crColor); COLORREF GetDCPenColor() const;
    COLORREF SetDCPenColor(COLORREF crColor);#endif
    所以,要设置:#define _WIN32_WINNT = 0x0500