2007년 4월 8일 일요일

GDI+ line pattern

void CGdiplusDemoView::OnDraw(CDC* pDC)
{
    Graphics g(pDC->m_hDC);

    Pen pen(Color(255, 0, 0, 0), 3);
    
    /*
    enum DashStyle
    {
        DashStyleSolid,          // 0
        DashStyleDash,           // 1
        DashStyleDot,            // 2
        DashStyleDashDot,        // 3
        DashStyleDashDotDot,     // 4
        DashStyleCustom          // 5
    };
    */
    // 실선
    pen.SetDashStyle(DashStyleSolid);
    g.DrawLine(&pen, 50, 50, 400, 50);
    // 파선
    pen.SetDashStyle(DashStyleDash);
    g.DrawLine(&pen, 50, 100, 400, 100);
    // 점선
    pen.SetDashStyle(DashStyleDot);
    g.DrawLine(&pen, 50, 150, 400, 150);
    // 일점 쇄선
    pen.SetDashStyle(DashStyleDashDot);
    g.DrawLine(&pen, 50, 200, 400, 200);
    // 이점 쇄선
    pen.SetDashStyle(DashStyleDashDotDot);
    g.DrawLine(&pen, 50, 250, 400, 250);
    // 시작점을 5 픽셀 이동
    pen.SetDashOffset(5);
    g.DrawLine(&pen, 50, 260, 400, 260);
    // 사용자 정의 패턴
    REAL dashVals[4] = { 5, 1, 2, 1 };
    pen.SetDashPattern(dashVals, 4);
    g.DrawLine(&pen, 50, 310, 400, 310);
}


댓글 없음: