----view.cpp
void CPenBrushDemoView::OnDraw(CDC* pDC)
{
CPenBrushDemoDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
CBrush brush(RGB(150, 0, 255));
CBrush* pOldBrush = pDC->SelectObject(&brush);
pDC->Rectangle(100, 100, 200, 200);
pDC->SelectObject(pOldBrush);
}
----view.cpp
void CPenBrushDemoView::OnDraw(CDC* pDC)
{
CPenBrushDemoDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
CBrush brush(RGB(150, 0, 255));
CBrush* pOldBrush = pDC->SelectObject(&brush);
CRect rect;
// 현재 클라이언트 영역을 얻음
GetClientRect(rect);
pDC->Rectangle(rect);
pDC->SelectObject(pOldBrush);
}
----view.cpp
void CPenBrushDemoView::OnDraw(CDC* pDC)
{
CPenBrushDemoDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
CBitmap Bmp;
Bmp.LoadBitmap(IDB_BITMAP1);
CBrush brush;
brush.CreatePatternBrush(&Bmp);
CBrush* pOldBrush = pDC->SelectObject(&brush);
CRect rect;
// 현재 클라이언트 영역을 얻음
GetClientRect(rect);
pDC->Rectangle(rect);
pDC->SelectObject(pOldBrush);
}
24bit = 4byte
트루 컬러 이미지