GDI(6)


ペンスタイルの設定


----view.cpp
void CPenBrushDemoView::OnDraw(CDC* pDC)
{
	CPenBrushDemoDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc)
		return;

	// TODO: 여기에 원시 데이터에 대한 그리기 코드를 추가합니다.
	LOGBRUSH lb;
	lb.lbStyle = BS_SOLID;
	lb.lbColor = RGB(192, 192, 192);

	CPen arNewPen[3];
	CPen* pOldPen = NULL;
	arNewPen[0].CreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_ROUND, 20, &lb);
	arNewPen[1].CreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_SQUARE, 20, &lb);
	arNewPen[2].CreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_FLAT, 20, &lb);

	for (int i = 0; i < 3; i++) {
		pOldPen = pDC->SelectObject(&arNewPen[i]);
		pDC->MoveTo(40, i * 100 + 40); // 시작좌표
		pDC->LineTo(240, i * 100 + 40); // 끝좌표

		pDC->SelectObject(pOldPen);

		pDC->MoveTo(40, i * 100 + 40);
		pDC->LineTo(240, i * 100 + 40);
        
        arNewPen[i].DeleteObject();
	}
}