在visual c++ 6.0 同 visuac++ 2005如何畫圖?

我想用visual c++6.0 或 2005 畫圖,但找不到graphic 的 library

visual c++內有沒有 graphic 的library 供人畫圖(長方形,圓形)?

好果有, 那library 是什麼? 當中有什麼 function可用?

如果沒有,要額外install 什麼才令使visual c++可畫圖?

在哪裡可以免費下載?

1 Answer

Rating
  • 阿一
    Lv 7
    1 decade ago
    Favorite Answer

    To draw a rectangle, you can use the CDC::Rectangle() method. Its syntax is:

    BOOL Rectangle(int x1, int y1, int x2, int y2); As seen on the figure and the formula, a rectangle spans from coordinates (x1, y1) to (x2, y2). Here is an example:

    void CExoView::OnDraw(CDC* pDC)

    {

    pDC->Rectangle(20, 20, 226, 144);

    }

    圖片參考:http://functionx.com/MFCFundamentals/lessons/image...

    When drawing a rectangle, if the value of x2 is less than that of x1, then the x2 coordinate would mark the left beginning of the figure. This scenario would also apply if the y2 coordinate were lower than y1.

    To draw a rectangle, you can also use a RECT or a CRect object. The syntax you would use is:

    BOOL Rectangle(LPCRECT lpRect); In this case, you must have defined a RECT or a CRect value and pass it as a pointer to the Rectangle() method. Here is an example:

    void CExoView::OnDraw(CDC* pDC)

    {

    CRect Recto(328, 125, 48, 25);

    pDC->Rectangle(&Recto);

    }

    圖片參考:http://functionx.com/MFCFundamentals/lessons/image...

    A square is a rectangle whose sides are all equal. Therefore, to draw a square, when specifying the arguments of the Rectangle() method, make sure that |x1 - x2| = |y1 - y2|.

    The CDC class provides another function member you can use to draw a rectangle. This time you can control how the edges of the rectangle would be drawn. The method used is called DrawEdge and its syntax is:

    BOOL DrawEdge(LPRECT lpRect, UINT nEdge, UINT nFlags); The lpRect argument is passed as a pointer to a RECT or CRect, which is the rectangle that would be drawn.

    The nEdge value specifies how the interior and the exterior of the edges of the rectangle would be drawn. It can be a combination of the following constants:

    Value Description BDR_RAISEDINNER The interior edge will be raised BDR_SUNKENINNER The interior edge will be sunken BDR_RAISEDOUTER The exterior edge will be raised BDR_SUNKENOUTER The exterior edge will be sunken These values can be combined using the bitwise OR operator. On the other hand, you can use the following constants instead:

    Value Used For EDGE_DUMP BDR_RAISEDOUTER | BDR_SUNKENINNER EDGE_ETCHED BDR_SUNKENOUTER | BDR_RAISEDINNER EDGE_RAISED BDR_RAISEDOUTER | BDR_RAISEDINNER EDGE_SUNKEN BDR_SUNKENOUTER | BDR_SUNKENINNER The nFlags value specifies what edge(s) would be drawn. It can have one of the following values:

    Value Description BF_RECT The entire rectangle will be drawn BF_TOP Only the top side will be drawn BF_LEFT Only the left side will be drawn BF_BOTTOM Only the bottom side will be drawn BF_RIGHT Only the right side will be drawn BF_TOPLEFT Both the top and the left sides will be drawn BF_BOTTOMLEFT Both the bottom and the left sides will be drawn BF_TOPRIGHT Both the top and the right sides will be drawn BF_BOTTOMRIGHT Both the bottom and the right sides will be drawn BF_DIAGONAL_ENDBOTTOMLEFT A diagonal line will be drawn from the top-right to the bottom-left corners BF_DIAGONAL_ENDBOTTOMRIGHT A diagonal line will be drawn from the top-left to the bottom-right corners BF_DIAGONAL_ENDTOPLEFT A diagonal line will be drawn from the bottom-right to the top-left corners BF_DIAGONAL_ENDTOPRIGHT A diagonal line will be drawn from the bottom-left to the top-right corners Here is an example:

    void CExoView::OnDraw(CDC* pDC)

    {

    CRect Recto(20, 20, 225, 115);

    pDC->DrawEdge(&Recto, BDR_RAISEDOUTER | BDR_SUNKENINNER, BF_RECT);

    }

    圖片參考:http://functionx.com/MFCFundamentals/lessons/image...

Still have questions? Get your answers by asking now.