共用方式為


CDC::Arc

繪製橢圓弧形。

BOOL Arc( 
   int x1, 
   int y1, 
   int x2, 
   int y2, 
   int x3, 
   int y3, 
   int x4, 
   int y4  
); 
BOOL Arc( 
   LPCRECT lpRect, 
   POINT ptStart, 
   POINT ptEnd  
);

參數

  • x1
    指定週框左上角的 X 座標 (以邏輯單位 (Logical Unit)。

  • y1
    指定週框左上角的 Y 座標 (以邏輯單位 (Logical Unit)。

  • x2
    指定週框右下角的 X 座標 (以邏輯單位 (Logical Unit)。

  • y2
    指定週框 (Bounding Rectangle) 右下角的 Y 座標 (以邏輯單位 (Logical Unit)。

  • x3
    指定定義弧形的開始點的 X 座標 (以邏輯單位 (Logical Unit)。 這點在弧形不必完全下方。

  • y3
    指定定義弧形的開始點的 Y 座標 (以邏輯單位 (Logical Unit)。 這點在弧形不必完全下方。

  • x4
    指定定義弧形端點點的 X 座標 (以邏輯單位 (Logical Unit)。 這點在弧形不必完全下方。

  • y4
    指定定義弧形端點點的 Y 座標 (以邏輯單位 (Logical Unit)。 這點在弧形不必完全下方。

  • lpRect
    指定週框 (以邏輯單位 (Logical Unit)。 您可以 LPRECTCRect 物件這個參數的。

  • ptStart
    指定定義弧形的開始點的 X 和 Y 座標 (以邏輯單位 (Logical Unit)。 這點在弧形不必完全下方。 您可以對 結構或 CPoint 物件這個參數的。

  • ptEnd
    指定定義弧形的目的端座標點的 X 和 Y 座標 (以邏輯單位 (Logical Unit)。 這點在弧形不必完全下方。 您可以對 結構或 CPoint 物件這個參數的。

傳回值

如果不是零,則函式成功,則為 0。

備註

弧線要使用函式是指定的週框所定義的橢圓形的區段。

弧形的實際開始點是從週框 (Bounding Rectangle) 的中央繪製穿過傳遞指定的起始點交集橢圓形的點。 弧形的實際結束點是從週框 (Bounding Rectangle) 的中央繪製穿過傳遞指定的端點相交橢圓形的點。 弧形的左側進行繪製。 因為這不是關閉的圖形,它並沒有填滿。 矩形的寬度和高度小於 2 個單位和少於 32,767 個單位必須大於零。

範例

void CDCView::DrawArc(CDC* pDC)
{
   // Fill the client area with a thin circle. The circle's 
   // interior is not filled. The circle's perimeter is 
   // blue from 6 o'clock to 3 o'clock and red from 3 
   // o'clock to 6 o'clock. 

   // Get the client area.
   CRect rectClient;
   GetClientRect(rectClient);

   // Make a couple of pens.
   CPen penBlue;
   CPen penRed;
   CPen* pOldPen;

   penBlue.CreatePen(PS_SOLID | PS_COSMETIC, 1, RGB(0, 0, 255));
   penRed.CreatePen(PS_SOLID | PS_COSMETIC, 1, RGB(255, 0, 0));

   // Draw from 3 o'clock to 6 o'clock, counterclockwise, 
   // in a blue pen.

   pOldPen = pDC->SelectObject(&penBlue);

   pDC->Arc(rectClient,
      CPoint(rectClient.right, rectClient.CenterPoint().y),
      CPoint(rectClient.CenterPoint().x, rectClient.right));

   // Draw from 6 o'clock to 3 o'clock, counterclockwise, 
   // in a red pen.
   pDC->SelectObject(&penRed);

   // Keep the same parameters, but reverse start 
   // and end points.
   pDC->Arc(rectClient,
      CPoint(rectClient.CenterPoint().x, rectClient.right),
      CPoint(rectClient.right, rectClient.CenterPoint().y));

   // Restore the previous pen.
   pDC->SelectObject(pOldPen);
}

需求

Header: afxwin.h

請參閱

參考

CDC 類別

階層架構圖表

CDC::Chord

Arc

POINT 結構

RECT 結構