11.04.2014 Views

Advanced MFC Programming

Advanced MFC Programming

Advanced MFC Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 11. Sample: Simple Paint<br />

CString szText="Clip Region";<br />

CSize size;<br />

int i, j;<br />

UINT uTextAlign;<br />

CRect rect;<br />

CPoint pt;<br />

……<br />

}<br />

size=pDC->GetTextExtent(szText);<br />

uTextAlign=pDC->SetTextAlign(TA_UPDATECP);<br />

GetClientRect(rect);<br />

pt=CPoint(0, 0);<br />

for(j=0; jMoveTo(0, pt.y);<br />

for(i=0; iTextOut(0, pt.y, szText);<br />

}<br />

pt.y+=size.cy;<br />

}<br />

pDC->SetTextAlign(uTextAlign);<br />

pDC->SelectClipRgn(NULL);<br />

The output result is shown in Figure 11-7.<br />

Figure 11-7. Text output is confined within the region<br />

11.7 Path<br />

Basics<br />

Path is another type of powerful GDI object that can be used together with device context. A path can<br />

be seen as a closed figure that is formed by drawing trails. For example, Figure 11-8 shows a path that is<br />

made up of alternative lines and curves.<br />

353

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!