void GetRoundedRect(GraphicsPath* pPath, RectF baseRect, float radius){
    if( radius<=0.0F ){ 
        pPath->AddRectangle(baseRect); 
        pPath->CloseFigure(); 
        return;
    }
    if( radius>=(min(baseRect.Width, baseRect.Height))/2.0){
        GetCapsule(pPath, baseRect); 
        return;
    }
    float diameter = radius * 2.0F; 
    RectF arc   ( baseRect.X, baseRect.Y, diameter, diameter); 
    pPath->AddArc( arc, 180, 90 ); 
    arc.X = baseRect.GetRight() -diameter; 
    pPath->AddArc( arc, 270, 90 ); 
    arc.Y = baseRect.GetBottom() -diameter; 
    pPath->AddArc( arc, 0, 90 ); 
    arc.X = baseRect.GetLeft();
    pPath->AddArc( arc, 90, 90 );     
    pPath->CloseFigure(); 
}
void GetCapsule(GraphicsPath* pPath, RectF baseRect){ 
    float diameter; 
   
    TRY{ 
        if( baseRect.Width > baseRect.Height){ 
            diameter = baseRect.Height;            
            RectF arc( baseRect.X, baseRect.Y, diameter, diameter); 
            pPath->AddArc( arc, 90, 180); 
            arc.X = baseRect.GetRight()-diameter; 
            pPath->AddArc( arc, 270, 180); 
        }else if( baseRect.Width < baseRect.Height ){ 
            diameter = baseRect.Width;
            
            RectF arc( baseRect.X, baseRect.Y, diameter, diameter ); 
            pPath->AddArc( arc, 180, 180 ); 
            arc.Y = baseRect.GetBottom() -diameter; 
            pPath->AddArc( arc, 0, 180 ); 
        }else{ 
            pPath->AddEllipse( baseRect ); 
        }
    }CATCH(CException, ex){
        pPath->AddEllipse( baseRect ); 
    }
    END_CATCH
    pPath->CloseFigure(); 
}
사용 예)RectF PaintRect(WndRect.Width()/2-200, WndRect.Height()/2-100, 400, 200); LinearGradientBrush BackBrush(PaintRect , Color(255,255,255), Color(57,109,194), LinearGradientModeVertical); Pen BackPen (Color(57,109,194), 3); GraphicsPath RoundPath; GetRoundedRect(&RoundPath, PaintRect, 10); pMemG->FillPath(&BackBrush, &RoundPath); pMemG->DrawPath(&BackPen, &RoundPath);
자료 참고: codeproject.com
"프로그래밍 / Visual C" 분류의 다른 글
| [MFC] HttpOpenRequest 이용시 0xC0000005: 0xcccccccc 오류 (0) | 2014/03/04 | 
| [MFC] modal dialog(모달 대화상자) 숨긴채로 시작하기 (0) | 2014/03/04 | 
| [MFC] 프로세스 파일 경로 (0) | 2013/09/24 | 
| [MFC] OpenSSL Visual Studio 2008에서 컴파일 및 설치 하기 (0) | 2009/05/11 | 
| [MFC] Visual Studio 2008에서 zlib 1.2.3 컴파일 (0) | 2009/04/21 | 
| IE8설치후 VS2008 스크립트 오류 문제 (4) | 2009/03/31 | 
| 데이크스트라 알고리즘(Dijkstra algorithm) (2) | 2008/12/29 | 
| Microsoft Office 2007 연동 (1) | 2008/06/04 | 
| VC macro __FUNCTION__ UNICODE에서 사용하기 (0) | 2008/03/14 | 
| MulDiv (0) | 2007/12/12 |