共用方式為


CDC::RoundRect

使用畫筆的目前筆,繪製具有圓角的矩形。

BOOL RoundRect( 
   int x1, 
   int y1, 
   int x2, 
   int y2, 
   int x3, 
   int y3  
); 
BOOL RoundRect( 
   LPCRECT lpRect,
   POINT point  
);

參數

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

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

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

  • y2
    指定矩形的右下角的 Y 座標 (以邏輯單位 (Logical Unit)。

  • x3
    指定用於之橢圓形的寬度繪製圓角 (以邏輯單位 (Logical Unit)。

  • y3
    指定用於橢圓形的高度繪製圓角 (以邏輯單位 (Logical Unit)。

  • lpRect
    以邏輯單位指定週框 (Bounding Rectangle)。 您可以對 CRect 物件或指標的 RECT 結構之參數的。

  • point
    point X 座標指定橢圓形的寬度繪製圓角 (以邏輯單位 (Logical Unit)。 point Y 座標指定橢圓形的高度繪製圓角 (以邏輯單位 (Logical Unit)。 您可以對 結構或 CPoint 物件這個參數的。

傳回值

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

備註

使用目前的筆刷,矩形的內部填滿。

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

範例

void CDCView::DrawRoundRect(CDC* pDC)
{
   // create and select a solid blue brush
   CBrush brushBlue(RGB(0, 0, 255));
   CBrush* pOldBrush = pDC->SelectObject(&brushBlue);

   // create and select a thick, black pen
   CPen penBlack;
   penBlack.CreatePen(PS_SOLID, 3, RGB(0, 0, 0));
   CPen* pOldPen = pDC->SelectObject(&penBlack);

   // get our client rectangle
   CRect rect;
   GetClientRect(rect);

   // shrink our rect 20 pixels in each direction
   rect.DeflateRect(20, 20);

   // Draw a thick black rectangle filled with blue 
   // corners rounded at a 17-unit radius. Note that 
   // a radius of three or less is not noticable because 
   // the pen is three units wide.
   pDC->RoundRect(rect, CPoint(17, 17));

   // put back the old objects
   pDC->SelectObject(pOldBrush);
   pDC->SelectObject(pOldPen);
}

需求

Header: afxwin.h

請參閱

參考

CDC 類別

階層架構圖表

CDC::Rectangle

RoundRect

CRect Class

RECT 結構

POINT 結構

CPoint Class