共用方式為


CDC::Pie

若要繪製中心和兩個端點是由線條聯結的橢圓形弧線繪製派形。

BOOL Pie(
   int x1,
   int y1,
   int x2,
   int y2,
   int x3,
   int y3,
   int x4,
   int y4 
);
BOOL Pie(
   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
    指定週框 (Bounding Rectangle)。 您可以對 CRect 物件或指標的 RECT 結構之參數的。

  • ptStart
    指定弧形的開始點。 這點在弧形不必完全下方。 您可以對 結構或 CPoint 物件這個參數的。

  • ptEnd
    指定弧形的端點。 這點在弧形不必完全下方。 您可以對 結構或 CPoint 物件這個參數的。

傳回值

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

備註

弧形的中心是 x1、 y1、 x2和 y2 指定週框的中心 (或 lpRect)。 弧形的開始點和結束點由 x3、 y3、 x4和 y4 指定 (或 ptStart 和 ptEnd)。

弧線繪製直線選項的提示,動作會向左邊。 兩個額外行從弧形中心點的每一個端點繪製。 派形區域填滿這個目前的筆刷。 如果 x3 等於 x4 ,並 y3 等於 y4,結果是顯示單行的橢圓形從橢圓形的中心為點 (x3, y3) 或 (x4, y4)。

這個函式會繪製的圖形擴充,一直到 (但不包括權限和底端座標。 這表示該圖表的高度是 y2 – y1 和圖形的寬度是 x2 – x1。 寬度和週框的高度小於 2 個單位和少於 32,767 個單位必須大於零。

範例

void CDCView::DrawPie(CDC* pDC)
{
   // Fill the client area with a simple pie chart. A
   // big blue slice covers 75% of the pie, from
   // 6 o'clock to 3 o'clock. This portion is filled
   // with blue and has a blue edge. The remaining 25%
   // is filled with a red, diagonal hatch and has
   // a red edge.

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

   // Make a couple of pens and similar brushes.
   CPen penBlue, penRed;
   CBrush brushBlue, brushRed;
   CBrush* pOldBrush;
   CPen* pOldPen;

   brushBlue.CreateSolidBrush(RGB(0, 0, 255));
   brushRed.CreateHatchBrush(HS_FDIAGONAL, RGB(255, 0, 0));
   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 with a solid blue fill.

   pOldPen = pDC->SelectObject(&penBlue);
   pOldBrush = pDC->SelectObject(&brushBlue);

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

   // Draw the remaining quarter slice from 6 o'clock
   // to 3 o'clock, counterclockwise, in a red pen with
   // the hatched brush.
   pDC->SelectObject(&penRed);
   pDC->SelectObject(&brushRed);

   // Same parameters, but reverse start and end points.
   pDC->Pie(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

Pie

RECT 結構

POINT 結構

CRect 類別

CPoint 類別